using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35; using Ease.CoreV35.Model; using Ease.CoreV35.Caching; using System.Data.Linq.Mapping; using System.Data; namespace Payroll.BO { #region SAPDataProcess [Serializable] public class SAPDataProcess : AuditTrailBase { #region Cache Store private static Cache _cache = new Cache(typeof(SAPDataProcess)); #endregion #region Constructor public SAPDataProcess() { _ProcessDate = DateTime.MinValue; _ProcessStatus = EnumSAPProcessStatus.None; _ProcessTime = string.Empty; _ProcessBy = null; _MailCompleted = EnumSendMail.None; _CutOffday = 0; _SourceFileName = string.Empty; } #endregion #region Properties #region ProcessDate : DateTime private DateTime _ProcessDate; public DateTime ProcessDate { get { return _ProcessDate; } set { base.OnPropertyChange("ProcessDate", _ProcessDate, value); _ProcessDate = value; } } #endregion #region ProcessStatus : EnumSAPProcessStatus private EnumSAPProcessStatus _ProcessStatus; public EnumSAPProcessStatus ProcessStatus { get { return _ProcessStatus; } set { base.OnPropertyChange("ProcessStatus",(short) _ProcessStatus,(short) value); _ProcessStatus = value; } } #endregion #region ProcessTime : String private string _ProcessTime; public string ProcessTime { get { return _ProcessTime; } set { base.OnPropertyChange("ProcessTime", _ProcessTime, value); _ProcessTime = value; } } #endregion #region ProcessBy : ID private ID _ProcessBy; public ID ProcessBy { get { return _ProcessBy; } set { base.OnPropertyChange("ProcessBy", _ProcessBy, value); _ProcessBy = value; } } #endregion #region CutOffday : Int private int _CutOffday; public int CutOffday { get { return _CutOffday; } set { base.OnPropertyChange("CuffOffday", _CutOffday, value); _CutOffday = value; } } #endregion #region MailCompleted : bool private EnumSendMail _MailCompleted; public EnumSendMail MailCompleted { get { return _MailCompleted; } set { base.OnPropertyChange("MailCompleted", (short)_MailCompleted, (short)value); _MailCompleted = value; } } #endregion #region SourceFileName : String private string _SourceFileName; public string SourceFileName { get { return _SourceFileName; } set { base.OnPropertyChange("SourceFileName", _SourceFileName, value); _SourceFileName = value; } } #endregion #region SAPDataProcess Detail : SAPDataProcess Detail private ObjectsTemplate _details; public ObjectsTemplate Details { get { if (_details == null) _details = new ObjectsTemplate(); return _details; } set { _details = value; } } #endregion #region SAPDataDumps : ObjectsTemplate private ObjectsTemplate _SAPDataDumps; public ObjectsTemplate SAPDataDumps { get { if (_SAPDataDumps == null) _SAPDataDumps = new ObjectsTemplate(); return _SAPDataDumps; } set { _SAPDataDumps = value; } } #endregion #region Employees : SAPEmployees private ObjectsTemplate _SAPEmployees; public ObjectsTemplate SAPEmployees { get { if (_SAPEmployees == null) _SAPEmployees = new ObjectsTemplate(); return _SAPEmployees; } set { _SAPEmployees = value; } } #endregion #region EmpLifeCycle : SAPEmpLifeCycles private ObjectsTemplate _SAPEmpLifeCycles; public ObjectsTemplate SAPEmpLifeCycles { get { if (_SAPEmpLifeCycles == null) _SAPEmpLifeCycles = new ObjectsTemplate(); return _SAPEmpLifeCycles; } set { _SAPEmpLifeCycles = value; } } #endregion #region EmpBankAccounts : EmployeeBankAccount private ObjectsTemplate _EmpBankAccounts; public ObjectsTemplate EmpBankAccounts { get { if (_EmpBankAccounts == null) _EmpBankAccounts = new ObjectsTemplate(); return _EmpBankAccounts; } set { _EmpBankAccounts = value; } } #endregion #region ErrorList : SAPDataProcessDetail private ObjectsTemplate _ErrorList; public ObjectsTemplate ErrorList { get { if (_ErrorList == null) _ErrorList = new ObjectsTemplate(); return _ErrorList; } set { _ErrorList = value; } } #endregion #region SuccessList : SAPDataProcessDetail private ObjectsTemplate _SuccessList; public ObjectsTemplate SuccessList { get { if (_SuccessList == null) _SuccessList = new ObjectsTemplate(); return _SuccessList; } set { _SuccessList = value; } } #endregion #region Service Factory ISAPDataProcessService : ISAPDataProcessService internal static ISAPDataProcessService Service { get { return Services.Factory.CreateService(typeof(ISAPDataProcessService)); } } #endregion #endregion #region Functions public static SAPDataProcess Get(ID nID) { SAPDataProcess oSAPDataProcess = null; #region Cache Header oSAPDataProcess = (SAPDataProcess)_cache["Get", nID]; if (oSAPDataProcess != null) return oSAPDataProcess; #endregion oSAPDataProcess = SAPDataProcess.Service.Get(nID); #region Cache Footer _cache.Add(oSAPDataProcess, "Get", nID); #endregion return oSAPDataProcess; } public static SAPDataProcess Get(DateTime dSAPDate) { SAPDataProcess oSAPDataProcess = null; #region Cache Header oSAPDataProcess = (SAPDataProcess)_cache["Get", dSAPDate]; if (oSAPDataProcess != null) return oSAPDataProcess; #endregion oSAPDataProcess = SAPDataProcess.Service.Get(dSAPDate); #region Cache Footer _cache.Add(oSAPDataProcess, "Get", dSAPDate); #endregion return oSAPDataProcess; } public static SAPDataProcessDetail GetSAPDetails(ID nID) { SAPDataProcessDetail oSAPDataProcessDetail = null; #region Cache Header oSAPDataProcessDetail = (SAPDataProcessDetail)_cache["Get", nID]; if (oSAPDataProcessDetail != null) return oSAPDataProcessDetail; #endregion oSAPDataProcessDetail = SAPDataProcess.Service.GetSAPDetails(nID); #region Cache Footer _cache.Add(oSAPDataProcessDetail, "Get", nID); #endregion return oSAPDataProcessDetail; } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate SAPDataProcesss = _cache["Get"] as ObjectsTemplate; if (SAPDataProcesss != null) return SAPDataProcesss; #endregion try { SAPDataProcesss = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(SAPDataProcesss, "Get"); #endregion return SAPDataProcesss; } public ID Save() { base.SetAuditTrailProperties(); return SAPDataProcess.Service.Save(this); } public void Delete(ID id) { SAPDataProcess.Service.Delete(id); } public void Process(bool IsSystemInfoNeeded) { try { SAPDataProcess.Service.Process(IsSystemInfoNeeded); } catch (Exception ex) { throw new ServiceException(ex.Message); } } public void EffectPrevious(bool IsSystemInfoNeeded) { try { SAPDataProcess.Service.EffectPrevious(IsSystemInfoNeeded); } catch (Exception ex) { throw new ServiceException(ex.Message); } } public static bool IsFileSuccessfullyRead(string filename) { bool bIsFileRead = false; bIsFileRead = SAPDataProcess.Service.GetFileReadStatus(filename); return bIsFileRead; } #endregion public DataTable GetSapDataProcessDetail(ID ID) { DataSet ds = null; try { ds = Service.GetSapDataProcessDetail(ID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds.Tables[0]; } public DataTable GetSapProcessDifferentErrors() { DataSet ds = null; try { ds = Service.GetSapProcessDifferentErrors(); } catch (Exception e) { throw new Exception(e.Message, e); } return ds.Tables[0]; } } #endregion #region ISAPDataProcess Service public interface ISAPDataProcessService { SAPDataProcess Get(ID id); SAPDataProcess Get(DateTime dSAPDate); SAPDataProcessDetail GetSAPDetails(ID id); ObjectsTemplate Get(); ID Save(SAPDataProcess item); DataSet GetSapDataProcessDetail(ID ID); void Delete(ID id); void Process(bool IsSystemInfoNeeded); bool GetFileReadStatus(string filename); DataSet GetSapProcessDifferentErrors(); void EffectPrevious(bool IsSystemInfoNeeded); } #endregion }