1339 lines
62 KiB
C#
1339 lines
62 KiB
C#
|
|
using Ease.Core.Model;
|
|
|
|
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
|
|
namespace HRM.BO
|
|
{
|
|
public class WFManager<T> where T : IworkflowInterface
|
|
{
|
|
#region class variable
|
|
private OrganogramBasic _ogNode;
|
|
private Employee _employee = null;
|
|
private WFSetup _wfSetup = null;
|
|
private WFMovementTran _MoveTran = null;
|
|
private T _wfinterface;
|
|
public Action<WFMovementTran> Notification;
|
|
|
|
#endregion class variable
|
|
|
|
#region constructor
|
|
public WFManager(T ob, Employee oEmployee)
|
|
{
|
|
//_wfinterface = ob;
|
|
//_employee = oEmployee;
|
|
//List<OrganogramEmployee> emps = (new OrganogramService()).GetByEmp(oEmployee.ID);
|
|
//if (emps == null || emps.Count == 0)
|
|
//{
|
|
// throw new Exception("Employee is not posted in Organ-O-Gram.");
|
|
//}
|
|
//else _ogNode = OrganogramBasic.Get(emps[0].NodeID);
|
|
//_wfSetup = WFSetup.Get(_wfinterface.SetupID);
|
|
}
|
|
private T ConvertToT<T>(IworkflowInterface oTran) where T : IworkflowInterface
|
|
{
|
|
return (T)oTran;
|
|
}
|
|
public WFManager(int nTranID, Employee oEmployee)
|
|
{
|
|
//_MoveTran = WFMovementTran.Get((nTranID));
|
|
//_wfinterface = this.ConvertToT<T>(_MoveTran);
|
|
|
|
//_employee = oEmployee;
|
|
//List<OrganogramEmployee> oganogramNode = OrganogramEmployee.GetByEmp(_employee.ID);
|
|
//if (oganogramNode == null || oganogramNode.Count == 0)
|
|
//{
|
|
// throw new Exception("Employee is not yet assinged in Organ-O-Gram.");
|
|
//}
|
|
//else _ogNode = OrganogramBasic.Get(oganogramNode[0].NodeID);
|
|
|
|
//_wfSetup = WFSetup.Get(_MoveTran.SetupID);
|
|
//_MoveTran.WFSetup = _wfSetup;
|
|
}
|
|
#endregion constructor
|
|
//public bool IsInitiator(int ntranID)
|
|
//{
|
|
// OrganogramBasic oNode = WFMovementTran.Service.InitiatorNode(_MoveTran.Uniquenumber);
|
|
// if (oNode != null)
|
|
// {
|
|
// if (oNode.ID == _ogNode.ID)
|
|
// {
|
|
// return true;
|
|
// }
|
|
// }
|
|
// return false;
|
|
//}
|
|
//public bool IsInitiator()
|
|
//{
|
|
// return _wfSetup.IsInitiator(_ogNode);
|
|
//}
|
|
|
|
//public List<OrganogramBasic>[] Path()
|
|
//{
|
|
// List<OrganogramBasic>[] oPath = _wfSetup.GetFullPath(_ogNode);
|
|
// return oPath;
|
|
//}
|
|
//public List<OrganogramBasic>[] Path(WFMovementTran wfTran)
|
|
//{
|
|
// List<OrganogramBasic>[] oPath = _wfSetup.GetFullPath(_wfSetup.GetRule(wfTran.WFRuleID), wfTran.Tier, _ogNode);
|
|
// return oPath;
|
|
//}
|
|
|
|
//public void InitiateProcess(int nObjectID, string sRemarks)
|
|
//{
|
|
// try
|
|
// {
|
|
// string sTaskRemrks = "";
|
|
// WFSetupRule oRule;
|
|
// WFMovementTran oTran = new WFMovementTran();
|
|
|
|
// oTran.WFSetup = _wfSetup;
|
|
// oTran.FromNodeID = _ogNode.ID;
|
|
// oTran.FromEmployeeID = _employee.ID;
|
|
|
|
// oTran.Remarks = sRemarks;
|
|
// oTran.SetupID = _wfSetup.ID;
|
|
// if (oTran.Remarks == "Cancel request")
|
|
// oTran.Status = enumwfStatus.Cancel_Request;
|
|
// else
|
|
// oTran.Status = enumwfStatus.Received;
|
|
// //oTran.Status = enumwfStatus.Received;
|
|
// oRule = _wfSetup.GetNodeRule(_ogNode);
|
|
// oTran.WFRuleID = oRule.ID;
|
|
// List<WFMovementNext> onextItems = new List<WFMovementNext>();
|
|
|
|
// onextItems = Approvers(oRule, workflowConstants.WF_Initiator_Tier + 1);
|
|
|
|
// oTran.WFMNexts = new List<WFMovementNext>();
|
|
// WFMovementNext oNext = new WFMovementNext();
|
|
// oNext.Status = enumwfStatus.Passed;
|
|
// oNext.Description = onextItems[0].Description;
|
|
// oNext.EmployeeID = oTran.FromEmployeeID;
|
|
// oNext.NodeID = oTran.FromNodeID;
|
|
// oNext.ReceiveStatus = EnumWFReceiveStatus.ALREADY_OPENED;
|
|
// oNext.Remarks = sRemarks;
|
|
// oTran.WFMNexts.Add(oNext);
|
|
// oTran.WFMNexts.AddRange(onextItems);
|
|
|
|
// oTran.Tier = oTran.Tier + 1;
|
|
// oTran.Uniquenumber = WFMovementTran.Service.GetUniqueNumber();
|
|
// oTran.ObjectID = (nObjectID);
|
|
// oTran.Senttime = DateTime.Now;
|
|
// oTran.ObjectDescription = _wfinterface.ObjectDescription; // get the object description from interface
|
|
// oTran.SetSourceObjectStatus();
|
|
// sTaskRemrks = oTran.ObjectDescription;
|
|
// // sTaskRemrks = "(" + _employee.EmployeeNo + ") " + _employee.Name
|
|
// //+ " has submitted a " + _wfSetup.WFType.Name + " Application";
|
|
|
|
// _MoveTran = oTran;
|
|
// oTran.WFMTasks = this.MoveMentTasks(oTran.WFMNexts, oRule, workflowConstants.WF_Initiator_Tier, 0, enumwfStatus.Received, sTaskRemrks);
|
|
|
|
|
|
// oTran.Save();
|
|
|
|
// if (Notification != null)
|
|
// {
|
|
// Notification(oTran);
|
|
// }
|
|
|
|
// SendMail(oTran);
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// throw new ServiceException(ex.Message);
|
|
// }
|
|
//}
|
|
|
|
//public void InitiateProcess(Employee approver, string sRemarks)
|
|
//{
|
|
// try
|
|
// {
|
|
// int nObjectID = null;
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
|
|
// string sTaskRemrks = "";
|
|
// WFSetupRule oRule;
|
|
// WFMovementTran oTran = new WFMovementTran();
|
|
|
|
// oTran.WFSetup = _wfSetup;
|
|
// oTran.FromNodeID = _ogNode.ID;
|
|
// oTran.FromEmployeeID = _employee.ID;
|
|
|
|
// oTran.Remarks = sRemarks;
|
|
// oTran.SetupID = _wfSetup.ID;
|
|
// if (oTran.Remarks == "Cancel request")
|
|
// oTran.Status = enumwfStatus.Cancel_Request;
|
|
// else
|
|
// oTran.Status = enumwfStatus.Received;
|
|
|
|
// oRule = _wfSetup.GetNodeRule(_ogNode);
|
|
// oTran.WFRuleID = oRule.ID;
|
|
|
|
// List<WFMovementNext> onextItems = new List<WFMovementNext>();
|
|
|
|
// //onextItems = Approvers(oRule, workflowConstants.WF_Initiator_Tier + 1);
|
|
// onextItems = Approvers(approver);
|
|
|
|
// oTran.WFMNexts = new List<WFMovementNext>();
|
|
// WFMovementNext oNext = new WFMovementNext();
|
|
// oNext.Status = enumwfStatus.Passed;
|
|
// oNext.Description = onextItems[0].Description;
|
|
// oNext.EmployeeID = oTran.FromEmployeeID;
|
|
// oNext.NodeID = oTran.FromNodeID;
|
|
// oNext.ReceiveStatus = EnumWFReceiveStatus.ALREADY_OPENED;
|
|
// oNext.Remarks = sRemarks;
|
|
// oTran.WFMNexts.Add(oNext);
|
|
// oTran.WFMNexts.AddRange(onextItems);
|
|
|
|
// oTran.Tier = oTran.Tier + 1;
|
|
// oTran.Uniquenumber = WFMovementTran.Service.GetUniqueNumber();
|
|
// oTran.Senttime = DateTime.Now;
|
|
// oTran.ObjectDescription = _wfinterface.ObjectDescription; // get the object description from interface
|
|
// // sTaskRemrks = "(" + _employee.EmployeeNo + ") " + _employee.Name
|
|
// //+ " has submitted a " + _wfSetup.WFType.Name + " Application";
|
|
|
|
// _MoveTran = oTran;
|
|
// oTran.WFMTasks = this.MoveMentTasks(oTran.WFMNexts, oRule, workflowConstants.WF_Initiator_Tier, 0, enumwfStatus.Received, sTaskRemrks);
|
|
|
|
// tc = WFMovementTran.GetTransactionContext(true);
|
|
// if (_wfinterface is LeaveEntry)
|
|
// {
|
|
// LeaveEntry lEntry = _wfinterface as LeaveEntry;
|
|
// nObjectID = lEntry.Save(tc);
|
|
// }
|
|
// //else if (_wfinterface is Resignation)
|
|
// //{
|
|
// // Resignation resignation = _wfinterface as Resignation;
|
|
// // nObjectID = resignation.Save(tc);
|
|
// //}
|
|
// else if (_wfinterface is HRRequest)
|
|
// {
|
|
// //
|
|
// }
|
|
|
|
// oTran.ObjectID = nObjectID;
|
|
// oTran.SetSourceObjectStatus(tc);
|
|
// sTaskRemrks = oTran.ObjectDescription;
|
|
// oTran.WFMTasks.ForEach(x => x.Description = sTaskRemrks);
|
|
// oTran.Save(tc);
|
|
// tc.End();
|
|
// SendMail(oTran);
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// #region Handle Exception
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(ex);
|
|
// throw new ServiceException(ex.Message, ex);
|
|
// #endregion
|
|
// }
|
|
// }
|
|
// catch (MailSenderException ex)
|
|
// {
|
|
// throw ex;
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// throw new ServiceException(ex.Message);
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //try
|
|
// //{
|
|
// // string sTaskRemrks = "";
|
|
// // WFSetupRule oRule;
|
|
// // WFMovementTran oTran = new WFMovementTran();
|
|
|
|
// // oTran.WFSetup = _wfSetup;
|
|
// // oTran.FromNodeID = _ogNode.ID;
|
|
// // oTran.FromEmployeeID = _employee.ID;
|
|
|
|
// // oTran.Remarks = sRemarks;
|
|
// // oTran.SetupID = _wfSetup.ID;
|
|
// // oTran.Status = enumwfStatus.Received;
|
|
// // oRule = _wfSetup.GetNodeRule(_ogNode);
|
|
// // oTran.WFRuleID = oRule.ID;
|
|
|
|
// // List<WFMovementNext> onextItems = new List<WFMovementNext>();
|
|
|
|
// // onextItems = Approvers(approver);
|
|
|
|
// // oTran.WFMNexts = new List<WFMovementNext>();
|
|
// // WFMovementNext oNext = new WFMovementNext();
|
|
// // oNext.Status = enumwfStatus.Passed;
|
|
// // oNext.Description = onextItems[0].Description;
|
|
// // oNext.EmployeeID = oTran.FromEmployeeID;
|
|
// // oNext.NodeID = oTran.FromNodeID;
|
|
// // oNext.ReceiveStatus = EnumWFReceiveStatus.ALREADY_OPENED;
|
|
// // oNext.Remarks = sRemarks;
|
|
// // oTran.WFMNexts.Add(oNext);
|
|
// // oTran.WFMNexts.AddRange(onextItems);
|
|
|
|
// // oTran.Tier = oTran.Tier + 1;
|
|
// // oTran.Uniquenumber = WFMovementTran.Service.GetUniqueNumber();
|
|
// // oTran.ObjectID = (nObjectID);
|
|
// // oTran.Senttime = DateTime.Now;
|
|
// // oTran.ObjectDescription = _wfinterface.ObjectDescription; // get the object description from interface
|
|
// // oTran.SetSourceObjectStatus();
|
|
// // sTaskRemrks = oTran.ObjectDescription;
|
|
// // // sTaskRemrks = "(" + _employee.EmployeeNo + ") " + _employee.Name
|
|
// // //+ " has submitted a " + _wfSetup.WFType.Name + " Application";
|
|
|
|
// // _MoveTran = oTran;
|
|
// // oTran.WFMTasks = this.MoveMentTasks(oTran.WFMNexts, oRule, workflowConstants.WF_Initiator_Tier, 0, enumwfStatus.Received, sTaskRemrks);
|
|
|
|
|
|
// // oTran.Save();
|
|
|
|
// // if (Notification != null)
|
|
// // {
|
|
// // Notification(oTran);
|
|
// // }
|
|
|
|
// // SendMail(oTran);
|
|
// //}
|
|
// //catch (Exception ex)
|
|
// //{
|
|
// // throw new ServiceException(ex.Message);
|
|
// //}
|
|
//}
|
|
|
|
//public void InitiateProcess(string sRemarks)
|
|
//{
|
|
// try
|
|
// {
|
|
// int nObjectID = null;
|
|
// TransactionContext tc = null;
|
|
// try
|
|
// {
|
|
|
|
// string sTaskRemrks = "";
|
|
// WFSetupRule oRule;
|
|
// WFMovementTran oTran = new WFMovementTran();
|
|
|
|
// oTran.WFSetup = _wfSetup;
|
|
// oTran.FromNodeID = _ogNode.ID;
|
|
// oTran.FromEmployeeID = _employee.ID;
|
|
|
|
// oTran.Remarks = sRemarks;
|
|
// oTran.SetupID = _wfSetup.ID;
|
|
// if (oTran.Remarks == "Cancel request")
|
|
// oTran.Status = enumwfStatus.Cancel_Request;
|
|
// else
|
|
// oTran.Status = enumwfStatus.Received;
|
|
|
|
// oRule = _wfSetup.GetNodeRule(_ogNode);
|
|
// oTran.WFRuleID = oRule.ID;
|
|
|
|
// List<WFMovementNext> onextItems = new List<WFMovementNext>();
|
|
|
|
// onextItems = Approvers(oRule, workflowConstants.WF_Initiator_Tier + 1);
|
|
|
|
// oTran.WFMNexts = new List<WFMovementNext>();
|
|
// WFMovementNext oNext = new WFMovementNext();
|
|
// oNext.Status = enumwfStatus.Passed;
|
|
// oNext.Description = onextItems[0].Description;
|
|
// oNext.EmployeeID = oTran.FromEmployeeID;
|
|
// oNext.NodeID = oTran.FromNodeID;
|
|
// oNext.ReceiveStatus = EnumWFReceiveStatus.ALREADY_OPENED;
|
|
// oNext.Remarks = sRemarks;
|
|
// oTran.WFMNexts.Add(oNext);
|
|
// oTran.WFMNexts.AddRange(onextItems);
|
|
|
|
// oTran.Tier = oTran.Tier + 1;
|
|
// oTran.Uniquenumber = WFMovementTran.Service.GetUniqueNumber();
|
|
// oTran.Senttime = DateTime.Now;
|
|
// oTran.ObjectDescription = _wfinterface.ObjectDescription; // get the object description from interface
|
|
// // sTaskRemrks = "(" + _employee.EmployeeNo + ") " + _employee.Name
|
|
// //+ " has submitted a " + _wfSetup.WFType.Name + " Application";
|
|
|
|
// _MoveTran = oTran;
|
|
// oTran.WFMTasks = this.MoveMentTasks(oTran.WFMNexts, oRule, workflowConstants.WF_Initiator_Tier, 0, enumwfStatus.Received, sTaskRemrks);
|
|
|
|
// tc = WFMovementTran.GetTransactionContext(true);
|
|
// if (_wfinterface is LeaveEntry)
|
|
// {
|
|
// LeaveEntry lEntry = _wfinterface as LeaveEntry;
|
|
// nObjectID = lEntry.Save(tc);
|
|
// }
|
|
// //else if (_wfinterface is Resignation)
|
|
// //{
|
|
// // Resignation resignation = _wfinterface as Resignation;
|
|
// // nObjectID = resignation.Save(tc);
|
|
// //}
|
|
// else if (_wfinterface is HRRequest)
|
|
// {
|
|
// //
|
|
// }
|
|
|
|
// oTran.ObjectID = nObjectID;
|
|
// oTran.SetSourceObjectStatus(tc);
|
|
// sTaskRemrks = oTran.ObjectDescription;
|
|
// oTran.WFMTasks.ForEach(x => x.Description = sTaskRemrks);
|
|
// oTran.Save(tc);
|
|
// tc.End();
|
|
// SendMail(oTran);
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// #region Handle Exception
|
|
// if (tc != null)
|
|
// tc.HandleError();
|
|
// ExceptionLog.Write(ex);
|
|
// throw new ServiceException(ex.Message, ex);
|
|
// #endregion
|
|
// }
|
|
// }
|
|
// catch (MailSenderException ex)
|
|
// {
|
|
// throw ex;
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// throw new ServiceException(ex.Message);
|
|
// }
|
|
//}
|
|
|
|
//public void SubmitProcess(int nTranID, string sRemarks, EnumWFSubmitStatus submitStatus)
|
|
//{
|
|
// switch (submitStatus)
|
|
// {
|
|
// case EnumWFSubmitStatus.Accept:
|
|
// Submit(nTranID, sRemarks);
|
|
// break;
|
|
// case EnumWFSubmitStatus.Reject:
|
|
// Decline(nTranID, sRemarks);
|
|
// break;
|
|
// case EnumWFSubmitStatus.Revert:
|
|
// RevertSubmit(nTranID, sRemarks);
|
|
// break;
|
|
// default:
|
|
// break;
|
|
// }
|
|
//}
|
|
|
|
//private void Submit(int nTranID, string Remarks)
|
|
//{
|
|
// WFMovementTran oNextApprovar = null;
|
|
// WFSetupRule oRule = _wfSetup.GetRule(_MoveTran.WFRuleID);
|
|
// string sTaskRemrks = "";
|
|
// try
|
|
// {
|
|
|
|
// _MoveTran.UpdateStatus(_ogNode, Remarks, enumwfStatus.Approve);
|
|
|
|
// if (_MoveTran.IsReadytoMoveNextTier(oRule) && oRule.HasNextApprovar(_ogNode, _MoveTran.Tier + 1))
|
|
// {
|
|
// oNextApprovar = new WFMovementTran();
|
|
|
|
|
|
// oNextApprovar.FromNodeID = _ogNode.ID;
|
|
// oNextApprovar.FromEmployeeID = _employee.ID;
|
|
// oNextApprovar.Remarks = _MoveTran.GetRemarks();
|
|
// oNextApprovar.SetupID = _wfSetup.ID;
|
|
// oNextApprovar.WFRuleID = oRule.ID;
|
|
// oNextApprovar.Uniquenumber = _MoveTran.Uniquenumber;
|
|
// oNextApprovar.ObjectID = _MoveTran.ObjectID;
|
|
|
|
// oNextApprovar.Tier = _MoveTran.Tier + 1;
|
|
// oNextApprovar.WFMNexts = this.Approvers(oRule, _MoveTran.Tier + 1);
|
|
|
|
// // In Rule manual,
|
|
// if (oRule.WFRuleType == EnumWFRuleType.Manual && oNextApprovar.WFMNexts.Count == 1)
|
|
// {
|
|
// if (oNextApprovar.WFMNexts[0].EmployeeID == _employee.ID)
|
|
// {
|
|
// _MoveTran.Tier = _MoveTran.Tier + 1;
|
|
// Submit(_MoveTran.ID.Integer, Remarks);
|
|
// return;
|
|
// }
|
|
// }
|
|
// oNextApprovar.Status = enumwfStatus.Received;
|
|
// if (_MoveTran.Status == enumwfStatus.Cancel_Request)
|
|
// {
|
|
// _MoveTran.Status = enumwfStatus.Cancel_Request;
|
|
// }
|
|
// else
|
|
// _MoveTran.Status = enumwfStatus.Passed;
|
|
// // _MoveTran.Status = enumwfStatus.Passed;
|
|
|
|
|
|
// oNextApprovar.ObjectDescription = oNextApprovar.GetSourceObjectDescription(); // get the object description from interface
|
|
// LeaveEntry le = null;
|
|
// HRRequest loanreq = null;
|
|
// if (_MoveTran.WFMNexts != null && _MoveTran.WFMNexts.Count > 0 && _MoveTran.WFMNexts[0].EmployeeID == _employee.ID) //if Resubmit
|
|
// {
|
|
// sTaskRemrks = oNextApprovar.ObjectDescription;
|
|
// }
|
|
// else if (_wfSetup.WFType.SourceObjectName == "LeaveEntry")
|
|
// {
|
|
// le = new LeaveEntry().Get(_MoveTran.ObjectID);
|
|
// sTaskRemrks = _employee.Name + " has approved your " + le.Leave.Description + " from " +
|
|
// le.AppliedFromDate.ToString("dd MMM yyyy") + " to " +
|
|
// le.AppliedToDate.ToString("dd MMM yyyy");
|
|
// }
|
|
// else if (_wfSetup.WFType.SourceObjectName == "HRRequest")
|
|
// {
|
|
// loanreq = HRRequest.Get(_MoveTran.ObjectID);
|
|
// Loan loan = Loan.Get(loanreq.LoanID);
|
|
// sTaskRemrks = _employee.Name + " has approved your " + loanreq.Amount + " taka " + loan.Name;
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// sTaskRemrks = _employee.Name + " has approved your " + _wfSetup.WFType.Name + " Application ";
|
|
// }
|
|
|
|
// oNextApprovar.WFMTasks = this.MoveMentTasks(oNextApprovar.WFMNexts, oRule, _MoveTran.Tier, _MoveTran.Uniquenumber, enumwfStatus.Passed, sTaskRemrks);
|
|
|
|
// oNextApprovar.SetSourceObjectStatus();
|
|
|
|
// oNextApprovar.Submit(_MoveTran);
|
|
// if (Notification != null)
|
|
// {
|
|
// Notification(_MoveTran);
|
|
// }
|
|
// SendMail(oNextApprovar);
|
|
// }
|
|
// else
|
|
// {
|
|
// if (_MoveTran.Remarks == "Cancel request" || _MoveTran.Status == enumwfStatus.Cancel_Request)
|
|
// _MoveTran.Status = enumwfStatus.Cancel;
|
|
// else
|
|
// _MoveTran.Status = enumwfStatus.End;
|
|
// //_MoveTran.Status = enumwfStatus.End;
|
|
// _MoveTran.Remarks = sTaskRemrks;
|
|
// _MoveTran.SetSourceObjectStatus();
|
|
|
|
|
|
// foreach (WFMovementNext otran in _MoveTran.WFMNexts)
|
|
// otran.Status = enumwfStatus.End;
|
|
// LeaveEntry le = null;
|
|
// Recognition recognition = null;
|
|
// if (_wfSetup.WFType.SourceObjectName == "LeaveEntry")
|
|
// {
|
|
// le = new LeaveEntry().Get(_MoveTran.ObjectID);
|
|
// if (_MoveTran.Status == enumwfStatus.Cancel)
|
|
// {
|
|
// sTaskRemrks = _employee.Name + " has approved your cancel request of " + le.Leave.Description + " from " +
|
|
// le.AppliedFromDate.ToString("dd MMM yyyy") + " to " +
|
|
// le.AppliedToDate.ToString("dd MMM yyyy");
|
|
// }
|
|
// else
|
|
// {
|
|
|
|
// sTaskRemrks = _employee.Name + " has approved your " + le.Leave.Description + " from " +
|
|
// le.AppliedFromDate.ToString("dd MMM yyyy") + " to " +
|
|
// le.AppliedToDate.ToString("dd MMM yyyy");
|
|
// }
|
|
// }
|
|
// else if (_wfSetup.WFType.SourceObjectName == "Recognition")
|
|
// {
|
|
// string empName = string.Empty;
|
|
// string tableBody = string.Empty;
|
|
// int count = 1;
|
|
// recognition = Recognition.Get(_MoveTran.ObjectID);
|
|
// List<RecognitionDetail> recognitionDetails = recognition.RecognitionDetails;
|
|
// List<Employee> employee = Employee.Get();
|
|
|
|
// recognitionDetails.ForEach(r => empName = empName + (employee.Where(e => e.ID.Integer == r.EmployeeID.Integer).Select(e => e.Name).FirstOrDefault()) + ", ");
|
|
// recognitionDetails.ForEach(r => tableBody = tableBody + "<tr>" + "<td align='left' style='border:0.5px solid;'>" + count++ + "</td>" + "<td align='left' style='border:0.5px solid;'>" + employee.Where(e => e.ID.Integer == r.EmployeeID.Integer).Select(e => e.Name).FirstOrDefault() + "</td>" + "<td align='right' style='border:0.5px solid;'>" + r.Amount.ToString("#,###") + "</td>" + "</tr>");
|
|
|
|
// string tableNominatedEmp = "<table style='border:1px solid; border-collapse: collapse;'>" +
|
|
// "<thead style='background-color: #ffb113;'>" +
|
|
// "<tr>" +
|
|
// "<th style='border:0.5px solid;'>SI</th>" +
|
|
// "<th style='border:0.5px solid;'>Nominated Employee</th>" +
|
|
// "<th style='border:0.5px solid;'>Amount</th>" +
|
|
// "</tr>" +
|
|
// "</thead>" +
|
|
// "<tbody>" +
|
|
// tableBody +
|
|
// "<tr style='background-color: #ffb113;'>" +
|
|
// "<td></td><td>Grand Total</td><td align='right'>" + recognitionDetails.Sum(r => r.Amount).ToString("#,###") + "</td>" +
|
|
// "</tr>" +
|
|
// "</tbody>" +
|
|
// "</table><br/><br/>";
|
|
// sTaskRemrks = " " + "Your YES Tier 1 recognition for the following persons has been approved.<br/><br/>" + tableNominatedEmp;
|
|
// }
|
|
// else
|
|
// {
|
|
// sTaskRemrks = _employee.Name + ", " + _employee.DescriptionText + " has approved your " + _wfSetup.WFType.Name + " Application " + " and approval process completed successfully.";
|
|
// }
|
|
// _MoveTran.WFMTasks = this.MoveMentTasks(_MoveTran.WFMNexts, oRule, _MoveTran.Tier, _MoveTran.Uniquenumber, enumwfStatus.End, sTaskRemrks);
|
|
|
|
|
|
// _MoveTran.Save();
|
|
// if (_MoveTran.WFMTasks != null)
|
|
// {
|
|
// if (Notification != null)
|
|
// {
|
|
// Notification(_MoveTran);
|
|
// }
|
|
// SendMail(_MoveTran);
|
|
// }
|
|
// }
|
|
|
|
|
|
// }
|
|
// catch (Exception Ex)
|
|
// {
|
|
// throw new ServiceException(Ex.Message);
|
|
// }
|
|
//}
|
|
//private void Decline(int nTranID, string Remarks)
|
|
//{
|
|
// string sTaskRemrks = "";
|
|
// try
|
|
// {
|
|
// WFSetupRule oRule = _wfSetup.GetRule(_MoveTran.WFRuleID);
|
|
// _MoveTran.UpdateStatus(_ogNode, Remarks, enumwfStatus.Decline);
|
|
// //LeaveEntry le = null;
|
|
// //if (_wfSetup.WFType.SourceObjectName == "LeaveEntry")
|
|
// //{
|
|
// // le = new LeaveEntry().Get(_MoveTran.ObjectID);
|
|
// // sTaskRemrks = _employee.Name + " has declined your " + le.Leave.Description + " from " +
|
|
// // le.AppliedFromDate.ToString("dd MMM yyyy") + " to " +
|
|
// // le.AppliedToDate.ToString("dd MMM yyyy");
|
|
// //}
|
|
// //else
|
|
// //{
|
|
// // sTaskRemrks = _employee.Name + ", " + _employee.DescriptionText + " has declined your " + _wfSetup.WFType.Name + " Application ";
|
|
// //}
|
|
// //if (_MoveTran.IsReadytoMoveNextTier(oRule))
|
|
// //{
|
|
// // _MoveTran.Status = enumwfStatus.Decline;
|
|
// //}
|
|
// if (_MoveTran.IsReadytoMoveNextTier(oRule))
|
|
// {
|
|
// if (_MoveTran.Remarks == "Cancel request" || _MoveTran.Status == enumwfStatus.Cancel_Request)
|
|
// {
|
|
// _MoveTran.Status = enumwfStatus.End;
|
|
// sTaskRemrks = _wfSetup.WFType.Name + " Cancel request has been Declined by " + " " + _employee.Name + ", " + _employee.DescriptionText;
|
|
// }
|
|
// else
|
|
// {
|
|
// _MoveTran.Status = enumwfStatus.Decline;
|
|
// sTaskRemrks = _wfSetup.WFType.Name + " Application has been Declined by " + " " + _employee.Name + ", " + _employee.DescriptionText;
|
|
// }
|
|
// }
|
|
|
|
// _MoveTran.WFMTasks = this.MoveMentTasks(_MoveTran.WFMNexts, oRule, _MoveTran.Tier, _MoveTran.Uniquenumber, enumwfStatus.Decline, sTaskRemrks);
|
|
// _MoveTran.Remarks = sTaskRemrks;
|
|
|
|
// _MoveTran.SetSourceObjectStatus();
|
|
|
|
// _MoveTran.Save();
|
|
// if (Notification != null)
|
|
// {
|
|
// Notification(_MoveTran);
|
|
// }
|
|
// SendMail(_MoveTran);
|
|
|
|
// }
|
|
// catch (Exception Ex)
|
|
// {
|
|
// throw new ServiceException(Ex.Message);
|
|
// }
|
|
//}
|
|
//private void RevertSubmit(int nTranID, string Remarks)
|
|
//{
|
|
// WFMovementTran oNextApprovar = null;
|
|
// string sTaskRemrks = "";
|
|
// try
|
|
// {
|
|
// WFSetupRule oRule = _wfSetup.GetRule(_MoveTran.WFRuleID);
|
|
// _MoveTran.UpdateStatus(_ogNode, Remarks, enumwfStatus.Revert);
|
|
// if (_MoveTran.IsReadytoMoveNextTier(oRule))
|
|
// {
|
|
// oNextApprovar = new WFMovementTran();
|
|
|
|
// oNextApprovar.FromNodeID = _ogNode.ID;
|
|
// oNextApprovar.FromEmployeeID = _employee.ID;
|
|
// oNextApprovar.Remarks = _MoveTran.GetRemarks(); //_employee.Name + ": " + Remarks;
|
|
|
|
// oNextApprovar.SetupID = _wfSetup.ID;
|
|
// oNextApprovar.WFRuleID = oRule.ID;
|
|
// oNextApprovar.Uniquenumber = _MoveTran.Uniquenumber;
|
|
// /*For Initiator Tier will be one*/
|
|
// oNextApprovar.Tier = _MoveTran.Tier > workflowConstants.WF_Initiator_Tier ? _MoveTran.Tier - 1 : _MoveTran.Tier;
|
|
// oNextApprovar.ObjectID = _MoveTran.ObjectID;
|
|
// oNextApprovar.WFMNexts = this.RevertApprovers();
|
|
// LeaveEntry le = null;
|
|
|
|
// if (_wfSetup.WFType.SourceObjectName == "LeaveEntry")
|
|
// {
|
|
// le = new LeaveEntry().Get(_MoveTran.ObjectID);
|
|
// sTaskRemrks = _employee.Name + " has reverted your " + le.Leave.Description + " from " +
|
|
// le.AppliedFromDate.ToString("dd MMM yyyy") + " to " +
|
|
// le.AppliedToDate.ToString("dd MMM yyyy");
|
|
// }
|
|
// else
|
|
// {
|
|
// sTaskRemrks = _employee.Name + " has reverted your " + _wfSetup.WFType.Name + " Application ";
|
|
// }
|
|
// //oNextApprovar.WFMTasks = this.MoveMentTasks(oNextApprovar.WFMNexts, oRule, _MoveTran.Tier, _MoveTran.Uniquenumber, enumwfStatus.Revert, sTaskRemrks);
|
|
// oNextApprovar.Status = enumwfStatus.Received;
|
|
// oNextApprovar.ObjectDescription = sTaskRemrks;// _wfinterface.ObjectDescription; // get the object description from interface
|
|
// _MoveTran.Status = enumwfStatus.Passed;
|
|
|
|
// oNextApprovar.SetSourceObjectStatus();
|
|
|
|
// oNextApprovar.Submit(_MoveTran);
|
|
// if (Notification != null)
|
|
// {
|
|
// Notification(oNextApprovar);
|
|
// }
|
|
// SendMail(oNextApprovar);
|
|
// }
|
|
// else
|
|
// {
|
|
// _MoveTran.Status = enumwfStatus.Exception;
|
|
// _MoveTran.SetSourceObjectStatus();
|
|
|
|
// _MoveTran.Save();
|
|
// }
|
|
// }
|
|
// catch (Exception Ex)
|
|
// {
|
|
// throw new ServiceException(Ex.Message);
|
|
// }
|
|
//}
|
|
|
|
//private List<WFMovementNext> Approvers(WFSetupRule oWFRule, int nTier)
|
|
//{
|
|
// List<WFMovementNext> oNextApps = new List<WFMovementNext>();
|
|
// WFSetupRule oRule = oWFRule;
|
|
// OrganogramBasic initNode = null;
|
|
// List<OrganogramBasic> oApprovarNodes = null;
|
|
// //if (_wfSetup.WFType.SourceObjectName == "LeaveEntry" && nTier == 3) // It will need for IPDC
|
|
// //{
|
|
// // initNode = OrganogramBasic.GetbyEmployeeid(_MoveTran.FromEmployeeID);
|
|
// // oApprovarNodes = _wfSetup.Approvers(oRule, initNode, nTier);
|
|
// //}
|
|
|
|
// if (_wfSetup.WFType.SourceObjectName == "LeaveEntry" && nTier == 3)
|
|
// {
|
|
// Employee emp = Employee.Get(_MoveTran.FromEmployeeID);
|
|
// if (emp != null && emp.LineManagerID != null && !emp.LineManagerID.IsUnassigned)
|
|
// {
|
|
// WFMovementNext oNextApp = new WFMovementNext();
|
|
// oNextApp.Status = enumwfStatus.Received;
|
|
// //oNextApp.NodeID = oItem.ID;
|
|
// oNextApp.EmployeeID = emp.LineManagerID;
|
|
// oNextApp.Description = "(" + _employee.EmployeeNo + ") " + _employee.Name + ", " + _employee.DescriptionText + " has applied " + _wfSetup.WFType.Name + " Application";
|
|
// oNextApps.Add(oNextApp);
|
|
// //initNode = OrganogramBasic.GetbyEmployeeid(emp.LineManagerID);
|
|
// //oApprovarNodes = new List<OrganogramBasic>();
|
|
// //oApprovarNodes.Add(initNode);// _wfSetup.Approvers(oRule, initNode, nTier);
|
|
// }
|
|
// else
|
|
// {
|
|
// throw new ServiceException("Approver node/Position (" + _ogNode.PositionName + ") is Vacant.");
|
|
// }
|
|
// }
|
|
// else if (_wfSetup.WFType.SourceObjectName == "LeaveEntry" && nTier == 4)
|
|
// {
|
|
// WFMovementTran inittran = WFMovementTran.Service.InitiatorTran(_MoveTran.Uniquenumber);
|
|
// Employee emp = Employee.Get(inittran.FromEmployeeID);
|
|
// if (emp != null && emp.SecondLineManagerID != null && !emp.SecondLineManagerID.IsUnassigned)
|
|
// {
|
|
// WFMovementNext oNextApp = new WFMovementNext();
|
|
// oNextApp.Status = enumwfStatus.Received;
|
|
// //oNextApp.NodeID = oItem.ID;
|
|
// oNextApp.EmployeeID = emp.SecondLineManagerID;
|
|
// oNextApp.Description = "(" + _employee.EmployeeNo + ") " + _employee.Name + ", " + _employee.DescriptionText + " has applied " + _wfSetup.WFType.Name + " Application";
|
|
// oNextApps.Add(oNextApp);
|
|
// // initNode = WFMovementTran.Service.InitiatorTran(_MoveTran.Uniquenumber);//.GetbyEmployeeid(emp.SecondLineManagerID);
|
|
// //oApprovarNodes = new List<OrganogramBasic>();
|
|
// //oApprovarNodes.Add(initNode);// = _wfSetup.Approvers(oRule, initNode, nTier);
|
|
// }
|
|
// else
|
|
// {
|
|
// throw new ServiceException("Approver node/Position (" + _ogNode.PositionName + ") is Vacant.");
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// oApprovarNodes = _wfSetup.Approvers(oRule, _ogNode, nTier);
|
|
|
|
// foreach (OrganogramBasic oItem in oApprovarNodes)
|
|
// {
|
|
// foreach (OrganogramEmployee oemp in oItem.OrganEmployees)
|
|
// {
|
|
// WFMovementNext oNextApp = new WFMovementNext();
|
|
// oNextApp.Status = enumwfStatus.Received;
|
|
// oNextApp.NodeID = oItem.ID;
|
|
// oNextApp.EmployeeID = oemp.EmployeeID;
|
|
// oNextApp.Description = "(" + _employee.EmployeeNo + ") " + _employee.Name + ", " + _employee.DescriptionText + " has applied " + _wfSetup.WFType.Name + " Application";
|
|
// oNextApps.Add(oNextApp);
|
|
// }
|
|
// }
|
|
// }
|
|
// if (oNextApps.Count == 0)
|
|
// throw new ServiceException("Approver node/Position (" + _ogNode.PositionName + ") is Vacant.");
|
|
// return oNextApps;
|
|
//}
|
|
|
|
//private List<WFMovementNext> Approvers(Employee approver)
|
|
//{
|
|
// List<WFMovementNext> oNextApps = new List<WFMovementNext>();
|
|
// OrganogramBasic oApprovarNodes = OrganogramBasic.GetbyEmployeeid(approver.ID);
|
|
// if (oApprovarNodes != null)
|
|
// {
|
|
|
|
// WFMovementNext oNextApp = new WFMovementNext();
|
|
// oNextApp.Status = enumwfStatus.Received;
|
|
// oNextApp.NodeID = oApprovarNodes.ID;
|
|
// oNextApp.EmployeeID = approver.ID;
|
|
// oNextApp.Description = "(" + _employee.EmployeeNo + ") " + _employee.Name + " has applied " + _wfSetup.WFType.Name + " Application";
|
|
// oNextApps.Add(oNextApp);
|
|
|
|
|
|
// }
|
|
// if (oNextApps.Count == 0)
|
|
// throw new ServiceException("Approver node/Position (" + _ogNode.PositionName + ") is Vacant.");
|
|
// return oNextApps;
|
|
|
|
//}
|
|
|
|
//private List<WFMovementNext> RevertApprovers()
|
|
//{
|
|
|
|
// List<WFMovementNext> oNextApps = new List<WFMovementNext>();
|
|
// WFMovementNext oNextApp = new WFMovementNext();
|
|
|
|
// OrganogramBasic InitiatorNode = WFMovementTran.Service.InitiatorNode(_MoveTran.Uniquenumber);
|
|
// WFSetupRule oRule = _wfSetup.GetRule(_MoveTran.WFRuleID);
|
|
// OrganogramBasic oNode = _wfSetup.InitiatorToTierNode(InitiatorNode, oRule, _MoveTran.Tier - 1);
|
|
|
|
// oNextApp.NodeID = oNode.ID;
|
|
// Employee emp = oNode.GetAssignedEmployee();
|
|
// oNextApp.EmployeeID = emp.ID;
|
|
// oNextApp.Status = enumwfStatus.Received;
|
|
// oNextApp.Description = "(" + _employee.EmployeeNo + ") " + _employee.Name + " revert your " + _wfSetup.WFType.Name + " Application";
|
|
// oNextApps.Add(oNextApp);
|
|
// return oNextApps;
|
|
//}
|
|
|
|
//private WFMovementTask RefreshMovementTaskObj(int empID, int nodeID, EnumWFNotifyType notifyType, bool status, string Remarks, enumMailSendType mailSendType)
|
|
//{
|
|
// WFMovementTask oDTask = new WFMovementTask();
|
|
// oDTask.EmployeeID = empID;
|
|
// oDTask.NodeID = nodeID;
|
|
// oDTask.TasksType = notifyType;
|
|
// oDTask.Status = status;
|
|
// oDTask.Description = Remarks;
|
|
// oDTask.MailSendType = mailSendType;
|
|
// oDTask.SentTime = DateTime.Today;
|
|
// return oDTask;
|
|
//}
|
|
|
|
//private List<WFMovementTask> MoveMentTasks(List<WFMovementNext> WFnexts, WFSetupRule rule, int nTier, int uniqueNumber, enumwfStatus ntrantype, string sTaskRemarks)
|
|
//{
|
|
// List<WFMovementTask> oWFTasks = new List<WFMovementTask>();
|
|
|
|
// try
|
|
// {
|
|
// #region find the doted line and include them into cc
|
|
// if (workflowConstants.WF_Initiator_Tier == nTier)
|
|
// {
|
|
// List<OrganogramBasic> oDLines = _ogNode.GetAthorities(EnumAuthorityType.Doted);
|
|
// if (oDLines != null)
|
|
// {
|
|
// foreach (OrganogramBasic oNode in oDLines)
|
|
// {
|
|
// if (oNode.EmployeeAssigned == true)
|
|
// {
|
|
// Employee emp = oNode.GetAssignedEmployee();
|
|
// //System notification
|
|
// oWFTasks.Add(RefreshMovementTaskObj(emp.ID, oNode.ID, EnumWFNotifyType.SysNotification, false, sTaskRemarks, enumMailSendType.CC));
|
|
// //Email notification
|
|
// oWFTasks.Add(RefreshMovementTaskObj(emp.ID, oNode.ID, EnumWFNotifyType.Email, false, sTaskRemarks, enumMailSendType.CC));
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// // Send mail to Matrix line authority
|
|
|
|
// List<OrganogramBasic> oMLines = _ogNode.GetAthorities(EnumAuthorityType.Reporting);
|
|
// if (oDLines != null)
|
|
// {
|
|
// foreach (OrganogramBasic oNode in oMLines)
|
|
// {
|
|
// if (oNode.EmployeeAssigned == true)
|
|
// {
|
|
// Employee emp = oNode.GetAssignedEmployee();
|
|
// //System notification
|
|
// WFMovementTask otst = RefreshMovementTaskObj(emp.ID, oNode.ID, EnumWFNotifyType.SysNotification, false, sTaskRemarks, enumMailSendType.CC);
|
|
// oWFTasks.Add(otst);
|
|
// otst.Description = _MoveTran.ObjectDescription;
|
|
// //Email notification
|
|
// WFMovementTask otsts = RefreshMovementTaskObj(emp.ID, oNode.ID, EnumWFNotifyType.Email, false, sTaskRemarks, enumMailSendType.CC);
|
|
// oWFTasks.Add(otsts);
|
|
// otsts.Description = _MoveTran.ObjectDescription;
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// }
|
|
// #endregion
|
|
|
|
|
|
// #region find straight line and include them into to
|
|
// if (nTier > workflowConstants.WF_Initiator_Tier)
|
|
// {
|
|
// OrganogramBasic oBasic = WFMovementTran.Service.InitiatorNode(uniqueNumber);
|
|
// if (oBasic.EmployeeAssigned == true)
|
|
// {
|
|
// foreach (OrganogramEmployee enodeemp in oBasic.OrganEmployees)
|
|
// {
|
|
// //System notification
|
|
|
|
// string sapprover = "";
|
|
// if (_MoveTran.Status != enumwfStatus.End && _MoveTran.Status != enumwfStatus.Decline && _MoveTran.Status != enumwfStatus.Revert && (_MoveTran.Status == enumwfStatus.Received && WFnexts.Count > 0 && _MoveTran.FromEmployeeID != WFnexts[0].EmployeeID))
|
|
// {
|
|
// sapprover = " and waiting for Approval of ";
|
|
// foreach (WFMovementNext onext in WFnexts)
|
|
// {
|
|
// if (onext.Status == enumwfStatus.Received)
|
|
// {
|
|
// Employee oemp = Employee.Get(onext.EmployeeID);
|
|
// sapprover = sapprover + oemp.Name + ", " + oemp.DescriptionText;
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
|
|
// WFMovementTask otst = RefreshMovementTaskObj(enodeemp.EmployeeID, oBasic.ID, EnumWFNotifyType.SysNotification, false, sTaskRemarks, enumMailSendType.To);
|
|
// if (oWFTasks.GetItem(otst) == null)
|
|
// {
|
|
|
|
|
|
// oWFTasks.Add(otst);
|
|
// otst.Description = /*"Your " + */ sTaskRemarks + sapprover + ".";
|
|
// //Email notification
|
|
// WFMovementTask otsts = RefreshMovementTaskObj(enodeemp.EmployeeID, oBasic.ID, EnumWFNotifyType.Email, false, sTaskRemarks, enumMailSendType.To);
|
|
// oWFTasks.Add(otsts);
|
|
// otsts.Description = sTaskRemarks + sapprover + ".";
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// foreach (WFMovementNext onext in WFnexts)
|
|
// {
|
|
// if (onext.Status == enumwfStatus.Received && onext.EmployeeID != _MoveTran.FromEmployeeID)
|
|
// {
|
|
// WFMovementTask otst = RefreshMovementTaskObj(onext.EmployeeID, onext.NodeID, EnumWFNotifyType.Email, false, sTaskRemarks, enumMailSendType.To);
|
|
// if (oWFTasks.GetItem(otst) == null)
|
|
// {
|
|
// if (onext.Status != enumwfStatus.Revert)
|
|
// otst.Description = _MoveTran.ObjectDescription + " " + sTaskRemarks + ". Your approval is also required. ";
|
|
// oWFTasks.Add(otst);
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// #region if application decline notify to all approver sequence
|
|
// if (ntrantype == enumwfStatus.Decline)
|
|
// {
|
|
// //List<OrganogramBasic>[] oPaths = _wfSetup.GetFullPathOnTier(rule, nTier - 1, WFMovementTran.Service.InitiatorNode(uniqueNumber));
|
|
// //for (int i = 0; i < oPaths.Length; i++)
|
|
// //{
|
|
// // foreach (OrganogramBasic oNode in oPaths[i])
|
|
// // {
|
|
// // if (oNode.EmployeeAssigned == false) continue;
|
|
// // foreach (OrganogramEmployee enodeemp in oNode.OrganEmployees)
|
|
// // {
|
|
// // //System notification
|
|
// // WFMovementTask otst = RefreshMovementTaskObj(enodeemp.EmployeeID, oNode.ID, EnumWFNotifyType.SysNotification, false, sTaskRemarks, enumMailSendType.To);
|
|
// // if (oWFTasks.GetItem(otst) == null)
|
|
// // {
|
|
// // oWFTasks.Add(otst);
|
|
// // //Email notification
|
|
// // oWFTasks.Add(RefreshMovementTaskObj(enodeemp.EmployeeID, oNode.ID, EnumWFNotifyType.Email, false, sTaskRemarks, enumMailSendType.To));
|
|
// // }
|
|
// // }
|
|
// // }
|
|
// //}
|
|
// }
|
|
// #endregion if application decline notify to all approver sequence
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// foreach (WFMovementNext onext in WFnexts)
|
|
// {
|
|
// if (onext.EmployeeID != _employee.ID) // For Initatior don't need send mail
|
|
// {
|
|
// WFMovementTask otst = RefreshMovementTaskObj(onext.EmployeeID, onext.NodeID, EnumWFNotifyType.Email, false, sTaskRemarks, enumMailSendType.To);
|
|
// if (oWFTasks.GetItem(otst) == null)
|
|
// {
|
|
// otst.Description = otst.Description;// +" Your approval is required.";
|
|
// oWFTasks.Add(otst);
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// #endregion
|
|
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// throw new ServiceException(ex.Message);
|
|
// }
|
|
// return oWFTasks;
|
|
//}
|
|
|
|
//public void SendMail(WFMovementTran oTran)
|
|
//{
|
|
// MailSender sender = null;
|
|
|
|
// try
|
|
// {
|
|
// sender = new MailSender();
|
|
|
|
|
|
// //Send Email With Link
|
|
// Employee nextemployee = null;
|
|
// List<Employee> oEmployees = Employee.Get();
|
|
|
|
// foreach (WFMovementTask next in oTran.WFMTasks)
|
|
// {
|
|
// string sbody = "";
|
|
// if (next.TasksType == EnumWFNotifyType.SysNotification) continue;
|
|
// nextemployee = new Employee();
|
|
// nextemployee = oEmployees.FirstOrDefault(e => e.ID.Integer == next.EmployeeID.Integer);
|
|
|
|
// sender = new MailSender();
|
|
// sender.AddTo(nextemployee.EmailAddress.Trim());
|
|
// sbody = "Dear " + nextemployee.Name + "," + "<br/><br/>" + next.Description + "";
|
|
// sender.Body = sbody;
|
|
|
|
// sender.Link = Ease.CoreV35.Utility.ConfigUtility.GetAppSettings("WebAddress");
|
|
// //sender.Body = sender.Body.Replace("<br>", Environment.NewLine);
|
|
// LeaveEntry le = null;
|
|
// Loan loan = null;
|
|
|
|
// if (_wfSetup.WFType.SourceObjectName == "LeaveEntry")
|
|
// {
|
|
// le = new LeaveEntry().Get(_MoveTran.ObjectID);
|
|
|
|
// if (sbody.Contains("reverted"))
|
|
// {
|
|
// sender.Subject = le.Leave.Description + " application has been reverted ";
|
|
// }
|
|
// else if (sbody.Contains("declined"))
|
|
// {
|
|
// sender.Subject = le.Leave.Description + " application has been declined ";
|
|
// }
|
|
// else if (sbody.Contains("approved"))
|
|
// {
|
|
// sender.Subject = le.Leave.Description + " application has been approved ";
|
|
// }
|
|
// else
|
|
// {
|
|
// sender.Subject = le.Leave.Description + " Application from " + oEmployees.FirstOrDefault(e => e.ID.Integer == _MoveTran.FromEmployeeID.Integer).Name;
|
|
// }
|
|
// }
|
|
// else if (_wfSetup.WFType.SourceObjectName == "HRRequest")
|
|
// {
|
|
// loan = Loan.Get(_MoveTran.ObjectID);
|
|
|
|
// if (sbody.Contains("reverted"))
|
|
// {
|
|
// sender.Subject = loan.Name + " application has been reverted ";
|
|
// }
|
|
// else if (sbody.Contains("declined"))
|
|
// {
|
|
// sender.Subject = loan.Name + " application has been declined ";
|
|
// }
|
|
// else if (sbody.Contains("approved"))
|
|
// {
|
|
// sender.Subject = loan.Name + " application has been approved ";
|
|
// }
|
|
// else
|
|
// {
|
|
// sender.Subject = loan.Name + " Application from " + oEmployees.FirstOrDefault(e => e.ID.Integer == _MoveTran.FromEmployeeID.Integer).Name;
|
|
// }
|
|
// }
|
|
// else if (_wfSetup.WFType.SourceObjectName == "Recognition")
|
|
// {
|
|
// if (sbody.Contains("recognition") && sbody.Contains("approved"))
|
|
// {
|
|
|
|
// sender.Subject = "YES Tier 1 nomination from " + oEmployees.FirstOrDefault(e => e.ID.Integer == oTran.WFMNexts.LastOrDefault().EmployeeID.Integer).Name;
|
|
// }
|
|
// else if (sbody.Contains("recognition"))
|
|
// {
|
|
// sender.Subject = "YES Tier 1 nomination from " + oEmployees.FirstOrDefault(e => e.ID.Integer == _MoveTran.FromEmployeeID.Integer).Name;
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// if (sbody.Contains("reverted"))
|
|
// {
|
|
// sender.Subject = _wfSetup.WFType.Name + " application has been reverted ";
|
|
// }
|
|
// else if (sbody.Contains("declined"))
|
|
// {
|
|
// sender.Subject = _wfSetup.WFType.Name + " application has been declined ";
|
|
// }
|
|
// else if (sbody.Contains("approved"))
|
|
// {
|
|
// sender.Subject = _wfSetup.WFType.Name + " application has been approved ";
|
|
// }
|
|
// else
|
|
// {
|
|
// sender.Subject = _wfSetup.WFType.Name + " Application from " + oEmployees.FirstOrDefault(e => e.ID.Integer == _MoveTran.FromEmployeeID.Integer).Name;
|
|
// }
|
|
// }
|
|
// string checkSendMail = Ease.CoreV35.Utility.ConfigUtility.GetAppSettings("SendMethod");
|
|
// if (checkSendMail != "")
|
|
// {
|
|
// sender.SendMail();
|
|
// oTran.UpdateSysNotification(next.ID, true);
|
|
// }
|
|
// }
|
|
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// //throw new ServiceException(ex.Message);
|
|
// throw new CustomException(EnumExceptionType.Informational, "Successfully submitted but system could not send E-mail. You do not need to submit it again.");
|
|
// }
|
|
|
|
//}
|
|
|
|
//public string IntApproversNames()
|
|
//{
|
|
// string sApprovars = "";
|
|
// try
|
|
// {
|
|
// List<WFMovementNext> oNextApps = Approvers(_wfSetup.GetNodeRule(_ogNode), workflowConstants.WF_Initiator_Tier + 1);
|
|
// foreach (WFMovementNext onext in oNextApps)
|
|
// {
|
|
// OrganogramBasic obasic = OrganogramBasic.Get(onext.NodeID);
|
|
// if (obasic.EmployeeAssigned == false) continue;
|
|
// foreach (OrganogramEmployee enemp in obasic.OrganEmployees)
|
|
// {
|
|
// sApprovars = sApprovars + "(" + enemp.Employee.EmployeeNo + ") " + enemp.Employee.Name;
|
|
// }
|
|
// }
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// sApprovars = ex.Message;
|
|
// }
|
|
|
|
// return sApprovars;
|
|
//}
|
|
//public string ApproversNames(int nTranID)
|
|
//{
|
|
// string sApprovars = "";
|
|
// try
|
|
// {
|
|
// WFSetupRule oRule = _wfSetup.GetRule(_MoveTran.WFRuleID);
|
|
// if (oRule.HasNextApprovar(_ogNode, _MoveTran.Tier + 1))
|
|
// {
|
|
// List<WFMovementNext> oNextApps = Approvers(oRule, _MoveTran.Tier + 1);
|
|
|
|
// // there is a posiblity in rule manual, approvar and next approvar are same person.
|
|
// // so there is no need to flow two time same person.
|
|
// // for example emplaoyee is Department head and HR manager and work flow defined Emloyee >> LM >> Department Head >> HR Manager
|
|
// // while Department head approve work flow will be completed.
|
|
// if (oRule.WFRuleType == EnumWFRuleType.Manual && oNextApps.Count == 1)
|
|
// {
|
|
// if (oNextApps[0].EmployeeID == _employee.ID)
|
|
// {
|
|
// if (oRule.HasNextApprovar(_ogNode, _MoveTran.Tier + 2))
|
|
// {
|
|
// oNextApps = this.Approvers(oRule, _MoveTran.Tier + 2);
|
|
// }
|
|
// else sApprovars = "After your approval Work flow will be completed";
|
|
// }
|
|
// }
|
|
|
|
|
|
// foreach (WFMovementNext onext in oNextApps)
|
|
// {
|
|
|
|
// if (_wfSetup.WFType.SourceObjectName == "LeaveEntry")
|
|
// {
|
|
// Employee emp = Employee.Get(onext.EmployeeID);
|
|
// sApprovars = sApprovars + "(" + emp.EmployeeNo + ") " + emp.Name;
|
|
// }
|
|
// else
|
|
// {
|
|
// OrganogramBasic obasic = OrganogramBasic.Get(onext.NodeID);
|
|
// if (obasic.EmployeeAssigned == false) continue;
|
|
// foreach (OrganogramEmployee enemp in obasic.OrganEmployees)
|
|
// {
|
|
// sApprovars = sApprovars + "(" + enemp.Employee.EmployeeNo + ") " + enemp.Employee.Name;
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// sApprovars = "After your approval Work flow will be completed";
|
|
// }
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// sApprovars = ex.Message;
|
|
// }
|
|
|
|
// return sApprovars;
|
|
//}
|
|
|
|
//public string RevertNodeName(int nTranID)
|
|
//{
|
|
// string sSender = "";
|
|
// try
|
|
// {
|
|
|
|
// OrganogramBasic InitiatorNode = WFMovementTran.Service.InitiatorNode(_MoveTran.Uniquenumber);
|
|
// WFSetupRule oRule = _wfSetup.GetRule(_MoveTran.WFRuleID);
|
|
// OrganogramBasic oNode = _wfSetup.InitiatorToTierNode(InitiatorNode, oRule, _MoveTran.Tier - 1);
|
|
// sSender = "(" + oNode.GetAssignedEmployee().EmployeeNo + ")" + oNode.GetAssignedEmployee().Name;
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// sSender = "Error has been detected during looking for revert employee, Contract to system administrator; Error:" + ex.Message;
|
|
// }
|
|
|
|
// return sSender;
|
|
//}
|
|
//public string NotifiableNodes()
|
|
//{
|
|
// string sDotedNodes = "";
|
|
// try
|
|
// {
|
|
// HashSet<int> ohset = new HashSet<int>();
|
|
// List<OrganogramBasic> oDLines = _ogNode.GetAthorities(EnumAuthorityType.Doted);
|
|
// if (workflowConstants.WF_Initiator_Tier == _MoveTran.Tier)
|
|
// {
|
|
// if (oDLines != null)
|
|
// {
|
|
// foreach (OrganogramBasic dline in oDLines)
|
|
// {
|
|
// if (dline.EmployeeAssigned == true)
|
|
// {
|
|
// Employee emp = dline.GetAssignedEmployee();
|
|
// sDotedNodes = "(" + emp.EmployeeNo + ")" + emp.Name;
|
|
// ohset.Add(emp.ID.Integer);
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
|
|
// List<OrganogramBasic> oMLines = _ogNode.GetAthorities(EnumAuthorityType.Reporting);
|
|
// if (oDLines != null)
|
|
// {
|
|
// foreach (OrganogramBasic oNode in oMLines)
|
|
// {
|
|
// if (oNode.EmployeeAssigned == true)
|
|
// {
|
|
// Employee emp = oNode.GetAssignedEmployee();
|
|
// sDotedNodes = "(" + emp.EmployeeNo + ")" + emp.Name;
|
|
// ohset.Add(emp.ID.Integer);
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// //if (_MoveTran != null && _MoveTran.Tier > workflowConstants.WF_Initiator_Tier)
|
|
// //{
|
|
// // WFSetupRule rule = _wfSetup.GetRule(_MoveTran.WFRuleID);
|
|
// // List<OrganogramBasic>[] oPaths = null;
|
|
// // oPaths = _wfSetup.GetFullPathOnTier(rule, _MoveTran.Tier - 1, WFMovementTran.Service.InitiatorNode(_MoveTran.Uniquenumber));
|
|
// // for (int i = 0; i < oPaths.Length; i++)
|
|
// // {
|
|
// // //if ((_MoveTran.Tier - 2) == i) continue; //to employee doesn't need to include in cc
|
|
|
|
// // foreach (OrganogramBasic og in oPaths[i])
|
|
// // {
|
|
|
|
// // if (og.EmployeeAssigned == true && og.ID.Integer != _ogNode.ID.Integer)
|
|
// // {
|
|
// // Employee emp = og.GetAssignedEmployee();
|
|
// // if(ohset.Contains(emp.ID.Integer)==false)
|
|
// // sDotedNodes = sDotedNodes + " (" + emp.EmployeeNo + ")" + emp.Name;
|
|
// // }
|
|
// // }
|
|
// // }
|
|
// //}
|
|
|
|
|
|
// #region find straight line and include them into to
|
|
// if (_MoveTran != null && _MoveTran.Tier > workflowConstants.WF_Initiator_Tier)
|
|
// {
|
|
// OrganogramBasic oBasic = WFMovementTran.Service.InitiatorNode(_MoveTran.Uniquenumber);
|
|
// if (oBasic.EmployeeAssigned == true)
|
|
// {
|
|
// Employee emp = oBasic.GetAssignedEmployee();
|
|
// //System notification
|
|
// if (ohset.Contains(emp.ID.Integer) == false)
|
|
// sDotedNodes = sDotedNodes + " (" + emp.EmployeeNo + ")" + emp.Name;
|
|
// }
|
|
|
|
|
|
// }
|
|
// #endregion
|
|
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
|
|
// sDotedNodes = "Error has been detected during looking for doted-line employee(s), Contract to system administrator; Error:" + ex.Message;
|
|
// }
|
|
|
|
// return sDotedNodes;
|
|
//}
|
|
|
|
//public static WFMovementTran GetWFMovementTran(int nTranID)
|
|
//{
|
|
// try
|
|
// {
|
|
// WFMovementTran oMTran = WFMovementTran.Service.Get((nTranID));
|
|
|
|
// return oMTran;
|
|
// }
|
|
// catch
|
|
// {
|
|
// }
|
|
// return null;
|
|
//}
|
|
//public static int ObjectID(int nTranID)
|
|
//{
|
|
// string sDescription = string.Empty;
|
|
// try
|
|
// {
|
|
// WFMovementTran oMTran = WFMovementTran.Service.Get((nTranID));
|
|
// return oMTran.ObjectID.Integer;
|
|
// }
|
|
// catch
|
|
// {
|
|
// sDescription = "Error on getting WF Type. Contact your administrator.";
|
|
// }
|
|
// return -1;
|
|
//}
|
|
}
|
|
}
|