using Ease.Core.DataAccess; using Ease.Core.Model; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Reflection; namespace HRM.BO { #region WFMovementTran public class WFFlowHistory { public int tranID { get; set; } public int uniqueNumber { get; set; } public DateTime tranDate { get; set; } public int employeeID { get; set; } public string employeeNo { get; set; } public string employeeName { get; set; } public string tranStatusString { get; set; } public DateTime? StatusUpdateDate { get; set; } public EnumwfStatus status { get; set; } public string remarks { get; set; } public string description { get; set; } } public class WFMovementTran : ObjectTemplate//, IworkflowInterface { #region Constructor public WFMovementTran() { _WFMovementTranID = 0; _FromEmployeeID = 0; _FromNodeID = 0; _WFTypeID = 0; _WFRuleID = 0; _ObjectID = 0; _IsActive = true; _Senttime = DateTime.Now; _Status = EnumwfStatus.Received; _Uniquenumber = 0; _Remarks = ""; _Tier = 1; _objectDescription = ""; } #endregion #region Property(s) #region Property WFMovementTranID : ID private int _WFMovementTranID; public int WFMovementTranID { get { return _WFMovementTranID; } set { _WFMovementTranID = value; } } #endregion #region Property FromEmployeeID : int private int _FromEmployeeID; public int FromEmployeeID { get { return _FromEmployeeID; } set { _FromEmployeeID = value; } } #endregion #region FromNodeID : int private int _FromNodeID; public int FromNodeID { get { return _FromNodeID; } set { _FromNodeID = value; } } #endregion #region Property UserID : int private int _userID; public int UserID { get { return _userID; } set { _userID = value; } } #endregion #region Property WFSetupID : int private int _WFTypeID; public int WFTypeID { get { return _WFTypeID; } set { _WFTypeID = value; } } #endregion #region Property WFRuleID : int private int _WFRuleID; public int WFRuleID { get { return _WFRuleID; } set { _WFRuleID = value; } } #endregion #region Property ObjectID : int private int _ObjectID; public int ObjectID { get { return _ObjectID; } set { _ObjectID = value; } } #endregion #region Property IsActive : bool private bool _IsActive; public bool IsActive { get { return _IsActive; } set { _IsActive = value; } } #endregion #region Property Senttime : DateTime private DateTime _Senttime; public DateTime Senttime { get { return _Senttime; } set { _Senttime = value; } } #endregion #region Property Status : Enum private EnumwfStatus _Status; public EnumwfStatus Status { get { return _Status; } set { _Status = value; } } #endregion #region Property Uniquenumber : int private int _Uniquenumber; public int UniqueNumber { get { return _Uniquenumber; } set { _Uniquenumber = value; } } #endregion #region Property Remarks : string private string _Remarks; public string Remarks { get { return _Remarks; } set { _Remarks = value; } } #endregion #region Tier : int private int _Tier; public int Tier { get { return _Tier; } set { _Tier = value; } } #endregion #region Property ObjectDescription : string private string _objectDescription; public string ObjectDescription { get { return _objectDescription; } set { _objectDescription = value; } } #endregion public List WFMTasks { get; set; } public List WFMNexts { get; set; } public WFSetup WFSetup { get; set; } //#region WFMovementTask : WFMovementTask //private List _wfMTasks; //public List WFMTasks //{ // get // { // if (_wfMTasks == null) _wfMTasks = new List(); // return _wfMTasks; // } // set // { // _wfMTasks = value; // } //} //#endregion //#region WFMovementNext : WFMovementNext //private List _wfMNexts; //public List WFMNexts //{ // get // { // if (_wfMNexts == null) // _wfMNexts = WFMovementTran.Get4WFMovementNext(this.ID); // return _wfMNexts; // } // set // { // _wfMNexts = value; // } //} //#endregion //#region WFMovementNext : WFMovementNext //private WFSetup _wfsetup; //public WFSetup WFSetup //{ // get // { // if (_wfsetup == null) _wfsetup = WFSetup.Get(_WFSetupID); // return _wfsetup; // } // set // { // _wfsetup = value; // } //} //#endregion #endregion //#region Function //public static TransactionContext GetTransactionContext(bool openTransaction) //{ // return WFMovementTran.Service.GetTransactionContext(openTransaction); //} //#region Save //public int Save() //{ // return WFMovementTran.Service.Save(this); //} //public int Save(TransactionContext tc) //{ // return WFMovementTran.Service.Save(this, tc); //} //#endregion ////#region Delete ////public void Delete() ////{ //// WFMovementTran.Service.Delete(ID); ////} ////#endregion ////public bool IsException(WFReceiveStatus nStatus) ////{ //// foreach (WFMovementNext oItem in this.WFMNexts) //// { //// if (oItem.ReceiveStatus != EnumWFReceiveStatus.NOT_YET_OPEN) //// { //// if (oItem.Status != nStatus) //// { //// return false; //// } //// } //// } //// return true; ////} //public void SetSourceObjectStatus() //{ // object nstatus = null; // Type ty = null; // ConfigurationManager omanager = new ConfigurationManager(); // ty = System.Reflection.Assembly.GetCallingAssembly().GetType("Payroll.BO." + this.WFSetup.WFType.SourceObjectName.Trim()); // object sourceObject = System.Activator.CreateInstance(ty); // if (sourceObject == null) throw new ServiceException("unable to create object instance from object name:" + this.WFSetup.WFType.SourceObjectName // + ". please check availability of the object in the Payroll.Report assembly."); // System.Type[] pararemterTypes = new System.Type[1]; // pararemterTypes[0] = ID.GetType(); // System.Reflection.MethodInfo methodInfoDel = (sourceObject.GetType()).GetMethod("Get", pararemterTypes); // object[] parameterValue = new object[1]; // parameterValue[0] = this.ObjectID; // if (methodInfoDel != null) // sourceObject = methodInfoDel.Invoke(sourceObject, parameterValue); // else throw new ServiceException("function: Get(ID) is not exist in the object:" + this.WFSetup.WFType.SourceObjectName); // parameterValue[0] = this.Status; // System.Reflection.MethodInfo sourceStatusMenthod = (sourceObject.GetType()).GetMethod("GetStatusbyWf"); // if (sourceStatusMenthod != null) // nstatus = sourceStatusMenthod.Invoke(sourceObject, parameterValue); // else throw new ServiceException("function: GetStatusbyWf is not exist in the object:" + this.WFSetup.WFType.SourceObjectName); // this.WFSetup.WFType.SourceObjectStatus = (int)nstatus; //} //public void SetSourceObjectStatus(TransactionContext tc) //{ // object nstatus = null; // Type ty = null; // ConfigurationManager omanager = new ConfigurationManager(); // ty = System.Reflection.Assembly.GetCallingAssembly().GetType("Payroll.BO." + this.WFSetup.WFType.SourceObjectName.Trim()); // object sourceObject = System.Activator.CreateInstance(ty); // if (sourceObject == null) throw new ServiceException("unable to create object instance from object name:" + this.WFSetup.WFType.SourceObjectName // + ". please check availability of the object in the Payroll.Report assembly."); // System.Type[] pararemterTypes = new System.Type[2]; // pararemterTypes[0] = ID.GetType(); // pararemterTypes[1] = tc.GetType(); // System.Reflection.MethodInfo methodInfoDel = (sourceObject.GetType()).GetMethod("Get", pararemterTypes); // object[] parameterValue = new object[2]; // parameterValue[0] = this.ObjectID; // parameterValue[1] = tc; // if (methodInfoDel != null) // sourceObject = methodInfoDel.Invoke(sourceObject, parameterValue); // else throw new ServiceException("function: Get(ID) is not exist in the object:" + this.WFSetup.WFType.SourceObjectName); // parameterValue = new object[1]; // parameterValue[0] = this.Status; // System.Reflection.MethodInfo sourceStatusMenthod = (sourceObject.GetType()).GetMethod("GetStatusbyWf"); // if (sourceStatusMenthod != null) // nstatus = sourceStatusMenthod.Invoke(sourceObject, parameterValue); // else throw new ServiceException("function: GetStatusbyWf is not exist in the object:" + this.WFSetup.WFType.SourceObjectName); // this.WFSetup.WFType.SourceObjectStatus = (int)nstatus; //} //public string GetSourceObjectDescription() //{ // object nstatus = null; // Type ty = null; // ConfigurationManager omanager = new ConfigurationManager(); // ty = System.Reflection.Assembly.GetCallingAssembly().GetType("Payroll.BO." + this.WFSetup.WFType.SourceObjectName.Trim()); // object ofrm = System.Activator.CreateInstance(ty); // if (ofrm == null) throw new ServiceException("unable to create object instance from object name:" + this.WFSetup.WFType.SourceObjectName // + ". please check availability of the object in the Payroll.Report assembly."); // System.Type[] pararemterTypes = new System.Type[1]; // pararemterTypes[0] = ID.GetType(); // System.Reflection.MethodInfo methodInfoDel = (ofrm.GetType()).GetMethod("Get", pararemterTypes); // object[] parameterValue = new object[1]; // parameterValue[0] = this.ObjectID; // object sourceObject = null; // if (methodInfoDel != null) // sourceObject = methodInfoDel.Invoke(ofrm, parameterValue); // else throw new ServiceException("function: Get(ID) is not exist in the object:" + this.WFSetup.WFType.SourceObjectName); // System.Reflection.MethodInfo sourceStatusMenthod = (sourceObject.GetType()).GetMethod("WFDesciption"); // if (sourceStatusMenthod != null) // nstatus = sourceStatusMenthod.Invoke(sourceObject, null); // else throw new ServiceException("function: GetStatusbyWf is not exist in the object:" + this.WFSetup.WFType.SourceObjectName); // return nstatus.ToString(); //} //public string GetStatusString() //{ // string sStatus = ""; // switch (this.Status) // { // case enumwfStatus.Received: // sStatus = "Initiate"; // break; // case enumwfStatus.Passed: // sStatus = "Approved"; // break; // case enumwfStatus.Decline: // sStatus = "Decline"; // break; // case enumwfStatus.Revert: // sStatus = "revert"; // break; // case enumwfStatus.End: // sStatus = "Approved and Completed"; // break; // case enumwfStatus.Exception: // sStatus = "raise error"; // break; // default: // sStatus = "raise error"; // break; // } // return sStatus; //} //public static string GetStatusForNotify(enumwfStatus fstatus) //{ // string sStatus = ""; // switch (fstatus) // { // case enumwfStatus.Received: // sStatus = "Received"; // break; // case enumwfStatus.Passed: // sStatus = "Approved"; // break; // case enumwfStatus.Decline: // sStatus = "Decline"; // break; // case enumwfStatus.Revert: // sStatus = "revert"; // break; // case enumwfStatus.Approve: // sStatus = "Approved"; // break; // case enumwfStatus.End: // sStatus = "Approved & Completed"; // break; // case enumwfStatus.Exception: // sStatus = "raise error"; // break; // default: // sStatus = "raise error"; // break; // } // return sStatus; //} //public void UpdateStatus(OrganogramBasic oNode, string sRemarks, enumwfStatus nstatus) //{ // foreach (WFMovementNext oItem in this.WFMNexts) // { // //if (oNode.ID.Integer == oItem.NodeID.Integer) // //{ // oItem.Status = nstatus; // oItem.Remarks = sRemarks; // oItem.ReceiveStatus = EnumWFReceiveStatus.ALREADY_OPENED; // //} // } //} //public bool IsReadytoMoveNextTier(WFSetupRule oRule) //{ // #region Not Required all approvar approval // if (oRule.ReqAppAll == false) // { // foreach (WFMovementNext oItem in this.WFMNexts) // { // if (oItem.ReceiveStatus == EnumWFReceiveStatus.ALREADY_OPENED) // { // return true; // } // } // } // #endregion Not Required all approvar approval // #region Required all approvar approval // else // { // int nCount = 0; // foreach (WFMovementNext oItem in this.WFMNexts) // { // if (oItem.ReceiveStatus == EnumWFReceiveStatus.ALREADY_OPENED) // { // nCount = nCount + 1; // } // } // if (nCount == this.WFMNexts.Count) // { // return true; // } // } // #endregion Required all approvar approval // return false; //} //public string GetRemarks() //{ // string sApprovars = ""; // foreach (WFMovementNext oItem in this.WFMNexts) // { // sApprovars = sApprovars + oItem.Remarks + " "; // } // return sApprovars; //} //#region Get //public static WFMovementTran Get(int WFMovementId) //{ // WFMovementTran wfMovementTran = null; // #region Cache Header // wfMovementTran = (WFMovementTran)_cache["Get", WFMovementId]; // if (wfMovementTran != null) // return wfMovementTran; // #endregion // wfMovementTran = WFMovementTran.Service.Get(WFMovementId); // #region Cache Footer // _cache.Add(wfMovementTran, "Get", WFMovementId); // #endregion // return wfMovementTran; //} //public static WFMovementNext GetReceivedWFNext(int wfsetupid, int objectID) //{ // WFMovementNext wfMovementTran = null; // wfMovementTran = WFMovementTran.Service.GetReceivedWFNext(wfsetupid, objectID); // return wfMovementTran; //} //public static List Get() //{ // #region Cache Header // List wfMovementTran = _cache["Get"] as List; // if (wfMovementTran != null) // return wfMovementTran; // #endregion // try // { // wfMovementTran = Service.Get(); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(wfMovementTran, "Get"); // #endregion // return wfMovementTran; //} //public static List Get4WFMovementTask(int wftranid) //{ // #region Cache Header // List oWFMovementTask = _cache["Get4WFMovementTask", wftranid] as List; // if (oWFMovementTask != null) // return oWFMovementTask; // #endregion // try // { // oWFMovementTask = Service.Get4WFMovementTask(wftranid); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(oWFMovementTask, "Get4WFMovementTask", wftranid); // #endregion // return oWFMovementTask; //} //public static List GetWFMovementTasks() //{ // #region Cache Header // List oWFMovementTask = _cache["GetWFMovementTasks"] as List; // if (oWFMovementTask != null) // return oWFMovementTask; // #endregion // try // { // oWFMovementTask = Service.GetWFMovementTasks(); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(oWFMovementTask, "GetWFMovementTasks"); // #endregion // return oWFMovementTask; //} //public static List GetEMployeeNotification(int employeeID) //{ // return Service.GetNotificationItems(employeeID); //} //public static DataSet GetNotificationAndPendingJobCount(int employeeID) //{ // return Service.GetNotificationAndPendingJobCount(employeeID); //} //public static DataTable GetNotification(int employeeID) //{ // return Service.GetNotification(employeeID); //} //public static DataTable GetPendingJob(int employeeID) //{ // return Service.GetPendingJob(employeeID); //} //public static List Get4WFMovementNext(int wftranid) //{ // #region Cache Header // List oWFMovementNext = _cache["Get4WFMovementNext", wftranid] as List; // if (oWFMovementNext != null) // return oWFMovementNext; // #endregion // try // { // oWFMovementNext = Service.Get4WFMovementNext(wftranid); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(oWFMovementNext, "Get4WFMovementNext", wftranid); // #endregion // return oWFMovementNext; //} //public static List Get4WFMovementNext(int UniqueNumber) //{ // #region Cache Header // List oWFMovementNext = _cache["Get4WFMovementNext", UniqueNumber] as List; // if (oWFMovementNext != null) // return oWFMovementNext; // #endregion // try // { // oWFMovementNext = Service.Get4WFMovementNext(UniqueNumber); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(oWFMovementNext, "Get4WFMovementNext", UniqueNumber); // #endregion // return oWFMovementNext; //} //public static WFMovementTask GetWFMovementTask(int movementraskid) //{ // WFMovementTask oWFMovementNext = null; // try // { // oWFMovementNext = Service.GetWFMovementTask(movementraskid); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return oWFMovementNext; //} //public static List GetWFMovementByWFType(int wfFTypeID) //{ // #region Cache Header // List wfMovementTran = _cache["Get"] as List; // if (wfMovementTran != null) // return wfMovementTran; // #endregion // try // { // wfMovementTran = Service.GetWFMovementByWFType(wfFTypeID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(wfMovementTran, "Get"); // #endregion // return wfMovementTran; //} //#endregion //public static List ReceivedItems(int employeeid) //{ // return WFMovementTran.Service.ReceivedItems(employeeid); //} //public static List GetAllItems(int uniqueNumber) //{ // return WFMovementTran.Service.GetAllItems(uniqueNumber); //} //public static int GetReceivedItemsCount(int employeeid) //{ // return WFMovementTran.Service.ReceivedItemsCount(employeeid); //} //public static int GetNotificationItemsCount(int employeeid) //{ // return WFMovementTran.Service.GetNotificationItemCount(employeeid); //} //public void Update_MovementNext(int tranID, int newEmployeeID, int empID, int NodeID, string remarks) //{ // WFMovementTran.Service.Update_MovementNext(tranID, newEmployeeID, empID, NodeID, remarks); //} //public void Submit(WFMovementTran PrvTran) //{ // WFMovementTran.Service.Submit(PrvTran, this); //} //public void UpdateSysNotification(int movementTaskID, bool bstatus) //{ // WFMovementTran.Service.UpdateSysNotification(movementTaskID, bstatus); //} //public List GetDetails() //{ // List opJobsDetail = new List(); // return opJobsDetail; //} //#endregion //#region Service Factory //internal static IWFMovementTranService Service //{ // get { return Services.Factory.CreateService(typeof(IWFMovementTranService)); } //} //#endregion } #endregion public class ActorDetail { public bool IsMale { get; set; } public int EmployeeID { get; set; } public string Name { get; set; } public string Designation { get; set; } public string Department { get; set; } public string GetActorDetail() { string str = ""; if (this.IsMale != null) str = (this.IsMale == true) ? "Mr. " : "Ms. "; str = str + this.Name; if (this.Designation != string.Empty && this.Designation != null && this.Designation != "") str = str + ", " + this.Designation; if (this.Department != string.Empty && this.Department != null && this.Department != "") str = str + ", " + this.Department; return str; } } #region Interface public interface IWFMovementTranService { TransactionContext GetTransactionContext(bool openTransaction); WFMovementTran Get(int id); WFMovementNext GetReceivedWFNext(int wfsetupid, int objectID); List Get(); WFMovementTask GetWFMovementTask(int movementTaskID); List Get4WFMovementTask(int id); List Get4WFMovementNext(int tranid); List Get4WFMovementNextWithTranID(int UniqueNumber); OrganogramBasic InitiatorNode(int uniquenumber); WFMovementTran InitiatorTran(int uniquenumber); bool IsInitiator(int UnqNumber, int oEmpID); // int GetUniqueNumber(); string GetApproversName(int tranID, int empid); List ReceivedItems(int employeeid); DataTable PendingJobsMobile(int employeeid); int ReceivedItemsCount(int employeeid); string GetPendingJobNotificationCount(int employeeid); List GetPendingItems(int employeeid); List GetNotificationItems(int employeeid); int GetNotificationItemCount(int employeeid); List GetAllItems(int nUniqueNumber); List GetWFMovementTasks(); List GetWFMovementByWFType(int wFTypeID); DataSet GetNotificationAndPendingJobCount(int employeeid); DataTable GetNotification(int employeeid); List GetPendingJob(int employeeid); DataTable GetReceivedItems(int payrolltypeid, int? wftypeid, int? employeeid); //int Save(WFMovementTran wfMovementTran); //int Save(WFMovementTran wFMovementTran, TransactionContext tc); List GetFlowHistories(int? tranID, int? uniqueNumber); void Delete(int WFMovementTranId); //void Submit(WFMovementTran PrvTran, WFMovementTran NextTran); void UpdateSysNotification(int movementTaskID, bool status); void Update_MovementNext(int tranID, int newEmployeeID, int empID, string remarks); void ForceComplete(List otrans); List GetClaimRequisitionTranItemsForApproval(int employeeID); List GetClaimRequisitionTranItemHistory(int claimId, int employeId); List GetFlowHistoriesByObjectID(int? objectId, int wfTypeId, int? employeeId); WFMovementTran GetWfTranByObjectId(int objectId, int wfTypeId, int wfruleId); } #endregion }