public static void GenerateBirthdayInboxMessage(DatabaseConnection dbConn, int UserID, int NoticeDaysBefore, int NoticeDaysAfter) { if (NoticeDaysBefore < 0) { NoticeDaysBefore = 30; } if (NoticeDaysAfter < 0) { NoticeDaysAfter = 30; } const string INBOX_TYPE = EInbox.INBOX_TYPE_DATE_OF_BIRTH; DBFilter DateOfBirthFilter = new DBFilter(); DateOfBirthFilter.add(AppUtils.AddRankDBTerm(UserID, "EmpID", true)); //DateOfBirthFilter.add(new Match("EmpDateOfBirth", ">=", AppUtils.ServerDateTime().Date.AddYears(-YEAR_DIFFERENT).AddDays(-NOTICEDAYSAFTER))); //DateOfBirthFilter.add(new Match("EmpDateOfBirth", "<=", AppUtils.ServerDateTime().Date.AddYears(-YEAR_DIFFERENT).AddDays(NOTICEDAYSBEFORE))); DBFilter existsInboxFilter = new DBFilter(); existsInboxFilter.add(new MatchField(EEmpPersonalInfo.db.dbclass.tableName + ".EmpID", EInbox.db.dbclass.tableName + ".EmpID")); existsInboxFilter.add(new MatchField(EEmpPersonalInfo.db.dbclass.tableName + ".EmpID", EInbox.db.dbclass.tableName + ".InboxRelatedRecID")); existsInboxFilter.add(new MatchField(EEmpPersonalInfo.db.dbclass.tableName + ".EmpDateOfBirth", EInbox.db.dbclass.tableName + ".InboxRelatedReferenceDate")); existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".InboxType", INBOX_TYPE)); existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".UserID", UserID)); existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".InboxCreateDate", ">=", AppUtils.ServerDateTime().Date.AddDays(-(NoticeDaysBefore + NoticeDaysAfter)))); Exists existsInbox = new Exists(EInbox.db.dbclass.tableName, existsInboxFilter, true); DateOfBirthFilter.add(existsInbox); DBFilter existsEmpTerminationFilter = new DBFilter(); existsEmpTerminationFilter.add(new MatchField(EEmpPersonalInfo.db.dbclass.tableName + ".EmpID", EEmpTermination.db.dbclass.tableName + ".EmpID")); existsEmpTerminationFilter.add(new Match("EmpTermLastDate", "<=", AppUtils.ServerDateTime().Date)); Exists notExistsEmpTermination = new Exists(EEmpTermination.db.dbclass.tableName, existsEmpTerminationFilter, true); DateOfBirthFilter.add(notExistsEmpTermination); System.Collections.ArrayList empInfoList = EEmpPersonalInfo.db.select(dbConn, DateOfBirthFilter); DateTime BirthdayPeriodFrom = AppUtils.ServerDateTime().Date.AddDays(-NoticeDaysAfter); DateTime BirthdayPeriodTo = AppUtils.ServerDateTime().Date.AddDays(NoticeDaysBefore); foreach (EEmpPersonalInfo empInfo in empInfoList) { DateTime dateOfBirth = empInfo.EmpDateOfBirth; int yearCount = 0; while (dateOfBirth <= BirthdayPeriodFrom) { yearCount++; dateOfBirth = empInfo.EmpDateOfBirth.AddYears(yearCount); } if (dateOfBirth <= BirthdayPeriodTo) { EInbox.CreateAndSaveInboxMessage(dbConn, UserID, 0, empInfo.EmpID, empInfo.EmpID, string.Empty, INBOX_TYPE, string.Empty, string.Empty, empInfo.EmpDateOfBirth); } } }
public static void GenerateWorkPermitExpiryInboxMessage(DatabaseConnection dbConn, int UserID, int NoticeDaysBefore, int NoticeDaysAfter) { if (NoticeDaysBefore < 0) { NoticeDaysBefore = 30; } if (NoticeDaysAfter < 0) { NoticeDaysAfter = 30; } const string INBOX_TYPE = EInbox.INBOX_TYPE_WORKPERMITEXPIRY; DBFilter WorkPermitExpiryFilter = new DBFilter(); WorkPermitExpiryFilter.add(AppUtils.AddRankDBTerm(UserID, "EmpID", true)); WorkPermitExpiryFilter.add(new Match("EmpPermitExpiryDate", ">=", AppUtils.ServerDateTime().Date.AddDays(-NoticeDaysAfter))); WorkPermitExpiryFilter.add(new Match("EmpPermitExpiryDate", "<=", AppUtils.ServerDateTime().Date.AddDays(NoticeDaysBefore))); DBFilter existsInboxFilter = new DBFilter(); existsInboxFilter.add(new MatchField(EEmpPermit.db.dbclass.tableName + ".EmpID", EInbox.db.dbclass.tableName + ".EmpID")); existsInboxFilter.add(new MatchField(EEmpPermit.db.dbclass.tableName + ".EmpPermitID", EInbox.db.dbclass.tableName + ".InboxRelatedRecID")); existsInboxFilter.add(new MatchField(EEmpPermit.db.dbclass.tableName + ".EmpPermitExpiryDate", EInbox.db.dbclass.tableName + ".InboxRelatedReferenceDate")); existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".InboxType", INBOX_TYPE)); existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".UserID", UserID)); existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".InboxCreateDate", ">=", AppUtils.ServerDateTime().Date.AddDays(-(NoticeDaysBefore + NoticeDaysAfter)))); Exists existsInbox = new Exists(EInbox.db.dbclass.tableName, existsInboxFilter, true); WorkPermitExpiryFilter.add(existsInbox); DBFilter existsEmpTerminationFilter = new DBFilter(); existsEmpTerminationFilter.add(new MatchField(EEmpPermit.db.dbclass.tableName + ".EmpID", EEmpTermination.db.dbclass.tableName + ".EmpID")); existsEmpTerminationFilter.add(new Match("EmpTermLastDate", "<=", AppUtils.ServerDateTime().Date)); Exists notExistsEmpTermination = new Exists(EEmpTermination.db.dbclass.tableName, existsEmpTerminationFilter, true); WorkPermitExpiryFilter.add(notExistsEmpTermination); System.Collections.ArrayList empInfoList = EEmpPermit.db.select(dbConn, WorkPermitExpiryFilter); foreach (EEmpPermit empWorkPermit in empInfoList) { EInbox.CreateAndSaveInboxMessage(dbConn, UserID, 0, empWorkPermit.EmpID, empWorkPermit.EmpPermitID, string.Empty, INBOX_TYPE, string.Empty, string.Empty, empWorkPermit.EmpPermitExpiryDate); } }
public static void GenerateTerminationInboxMessage(DatabaseConnection dbConn, int UserID, int NoticeDaysBefore, int NoticeDaysAfter) { if (NoticeDaysBefore < 0) { NoticeDaysBefore = 15; } if (NoticeDaysAfter < 0) { NoticeDaysAfter = 15; } const string INBOX_TYPE = EInbox.INBOX_TYPE_TERMINATION; DBFilter TerminationFilter = new DBFilter(); TerminationFilter.add(AppUtils.AddRankDBTerm(UserID, "EmpID", true)); TerminationFilter.add(new Match("EmpTermLastDate", ">=", AppUtils.ServerDateTime().Date.AddDays(-NoticeDaysAfter))); TerminationFilter.add(new Match("EmpTermLastDate", "<=", AppUtils.ServerDateTime().Date.AddDays(NoticeDaysBefore))); DBFilter existsInboxFilter = new DBFilter(); existsInboxFilter.add(new MatchField(EEmpTermination.db.dbclass.tableName + ".EmpID", EInbox.db.dbclass.tableName + ".EmpID")); existsInboxFilter.add(new MatchField(EEmpTermination.db.dbclass.tableName + ".EmpTermID", EInbox.db.dbclass.tableName + ".InboxRelatedRecID")); existsInboxFilter.add(new MatchField(EEmpTermination.db.dbclass.tableName + ".EmpTermLastDate", EInbox.db.dbclass.tableName + ".InboxRelatedReferenceDate")); existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".InboxType", INBOX_TYPE)); existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".UserID", UserID)); existsInboxFilter.add(new Match(EInbox.db.dbclass.tableName + ".InboxCreateDate", ">=", AppUtils.ServerDateTime().Date.AddDays(-(NoticeDaysBefore + NoticeDaysAfter)))); Exists existsInbox = new Exists(EInbox.db.dbclass.tableName, existsInboxFilter, true); TerminationFilter.add(existsInbox); System.Collections.ArrayList empInfoList = EEmpTermination.db.select(dbConn, TerminationFilter); foreach (EEmpTermination empTerm in empInfoList) { //EEmpPersonalInfo empInfo = new EEmpPersonalInfo(); //empInfo.EmpID = empTerm.EmpID; //if (EEmpPersonalInfo.db.select(dbConn, empInfo)) EInbox.CreateAndSaveInboxMessage(dbConn, UserID, 0, empTerm.EmpID, empTerm.EmpTermID, string.Empty, INBOX_TYPE, string.Empty, string.Empty, empTerm.EmpTermLastDate); } }
protected void TrialRunProcess(object obj) { TrialRunParameter parameter = (TrialRunParameter)obj; //HROne.DataAccess.DatabaseConnection.SetDefaultDatabaseConnection(parameter.dbConn); if (Session["PayrollTrialRunThreadMessage"] == null) { Session.Add("PayrollTrialRunThreadMessage", string.Empty); } //string strEmpIDList = DecryptedRequest["EmpID"]; ArrayList list = parameter.EmpInfoList; int intTotal = list.Count; //if (int.TryParse(DecryptedRequest["Total"], out intTotal) && list.Count > 0) //{ int payPeriodID = parameter.PayPeriodID; bool isRecurringPayment = parameter.isRecurringPayment; bool isClaimsAndDeduction = parameter.isClaimsAndDeduction; bool isYearEndBonus = parameter.isYearEndBonus; bool isAdditionalRemuneration = parameter.isAdditionalRemuneration; bool isSkipMPFCal = parameter.isSkipMPFCal; //string[] strEmpIDListArray; //int intProgress = 0; //strEmpIDListArray = strEmpIDList.Split(new char[] { '_' }); //intProgress = 0; DateTime dtStartTime = AppUtils.ServerDateTime(); int UserID = parameter.UserID; // while (AppUtils.ServerDateTime().Subtract(dtStartTime).TotalMilliseconds < 200 && list.Count > 0) AppUtils.StartFunction(parameter.dbConn, UserID, FUNCTION_CODE, 0, true); HROne.Payroll.PayrollProcess payrollProcess = new HROne.Payroll.PayrollProcess(parameter.dbConn); while (list.Count > 0) { EEmpPersonalInfo empInfo = (EEmpPersonalInfo)list[0]; //int intEmpID; //if (int.TryParse(strEmpIDListArray[intProgress], out intEmpID)) //{ DBFilter filter = new DBFilter(); filter.add(new Match("EmpID", empInfo.EmpID)); filter.add(AppUtils.AddRankDBTerm(UserID, "EmpID", true)); if (EEmpPersonalInfo.db.count(parameter.dbConn, filter) > 0) { bool hasError = false; AppUtils.StartChildFunction(parameter.dbConn, empInfo.EmpID); try { payrollProcess.PayrollTrialRun(payPeriodID, empInfo.EmpID, isRecurringPayment, isClaimsAndDeduction, isAdditionalRemuneration, isYearEndBonus, isSkipMPFCal, UserID); } catch (Exception ex) { Session["PayrollTrialRunThreadProgressMessage"] = ex.ToString(); hasError = true; } AppUtils.EndChildFunction(parameter.dbConn); if (hasError) { break; } } //} //intProgress++; //if (intProgress == strEmpIDListArray.GetLength(0)) // break; list.Remove(empInfo); Session["PayrollTrialRunThreadProgressMessage"] = (intTotal - list.Count).ToString() + " of " + intTotal.ToString(); } AppUtils.EndFunction(parameter.dbConn); Session.Remove("PayrollTrialRunThread"); Session.Remove("PayrollTrialRun_EmpList"); //if (list.Count == 0) //{ // //Timer1.Enabled = false; // //System.Threading.Thread thread = ((System.Threading.Thread)Session["PayrollTrialRunThread"])..Abort(); // Session.Remove("PayrollTrialRunThread"); // Session.Remove("PayrollTrialRun_EmpList"); //} //else //{ // //Session["PayrollTrialRun_EmpList"] = list; // ////string strRemainder = string.Join("_", strEmpIDListArray, intProgress, strEmpIDListArray.GetLength(0) - intProgress); // //Response.Write(@"<script language='javascript'>"); // //Response.Write(@"setTimeout('Redirect()',500);"); // //Response.Write(@"function Redirect()"); // //Response.Write(@"{"); // //Response.Write(@"window.location = 'Payroll_TrialRunProcess.aspx?" // // + "PayPeriodID=" + DecryptedRequest["PayPeriodID"] // // + "&RecurringPayment=" + DecryptedRequest["RecurringPayment"] // // + "&ClaimsAndDeduction=" + DecryptedRequest["ClaimsAndDeduction"] // // + "&YearEndBonus=" + DecryptedRequest["YearEndBonus"] // // + "&SkipMPFCal=" + DecryptedRequest["SkipMPFCal"] // // + "&Total=" + intTotal // // //+ "&EmpID=" + strRemainder // // + "';"); // //Response.Write(@"}"); // //Response.Write(@"</script>"); //} //} }
// End 0000179, KuangWei, 2015-03-20 protected virtual void LoadRosterTableEventList() { eventList = new RosterTableEventList(); //resourceList = new SchedulerResourceList(); DBFilter rosterTableFilter = new DBFilter(); rosterTableFilter.add(new Match("RosterTableDate", ">=", DateFrom.AddDays(-1).Date)); rosterTableFilter.add(new Match("RosterTableDate", "<=", DateTo.AddMilliseconds(-1).Date)); DBFilter rosterClientSiteFilter = new DBFilter(); OR orRosterClientSiteIDTerms = new OR(); orRosterClientSiteIDTerms.add(new Match("rc.RosterClientSiteID", -1)); //OR orEmpHierarchyTerms = null; OR orEmpPosRosterTableGroupTerms = null; foreach (object obj in RosterClientSiteIDList) { ERosterClientSite site = null; if (obj is string) { string rosterClientSiteString = (string)obj; int rosterClientSiteID = 0; site = new ERosterClientSite(); if (int.TryParse(rosterClientSiteString, out rosterClientSiteID)) { site.RosterClientSiteID = rosterClientSiteID; } else { } } else if (obj is ERosterClientSite) { site = (ERosterClientSite)obj; } if (site != null) { orRosterClientSiteIDTerms.add(new Match("rc.RosterClientSiteID", site.RosterClientSiteID)); if (ShowEmployeeRosterWithSameSite) { if (ERosterClientSite.db.select(dbConn, site)) { //ERosterClient rosterClient = new ERosterClient(); //rosterClient.RosterClientID = site.RosterClientID; //if (ERosterClient.db.select(dbConn, rosterClient)) //{ // DBFilter hElementFilter = new DBFilter(); // hElementFilter.add(new Match("HLevelID", rosterClient.RosterClientMappingSiteCodeToHLevelID)); // ArrayList hElementList = EHierarchyElement.db.select(dbConn, hElementFilter); // foreach (EHierarchyElement hElement in hElementList) // { // if (hElement.HElementCode.Trim().Equals(site.RosterClientSiteCode.ToString().Trim())) // { // DBFilter sub = new DBFilter(); // sub.add(new MatchField("epi.EmpPosID", "eeh.EmpPosID")); // sub.add(new Match("eeh.HLevelID", hElement.HLevelID)); // sub.add(new Match("eeh.HElementID", hElement.HElementID)); // if (orEmpHierarchyTerms == null) // orEmpHierarchyTerms = new OR(); // orEmpHierarchyTerms.add(new Exists(EEmpHierarchy.db.dbclass.tableName + " eeh", sub)); // } // } //} DBFilter rosterTableGroupFilter = new DBFilter(); rosterTableGroupFilter.add(new MatchField("ertg.RosterTableGroupID", "rtg.RosterTableGroupID")); rosterTableGroupFilter.add(new Match("RosterClientSiteID", site.RosterClientSiteID)); if (orEmpPosRosterTableGroupTerms == null) { orEmpPosRosterTableGroupTerms = new OR(); } orEmpPosRosterTableGroupTerms.add(new Exists(ERosterTableGroup.db.dbclass.tableName + " rtg", rosterTableGroupFilter)); } } } } OR orRosterTableTerms = new OR(); if (ShowRosterCodeWithoutSiteMapping) { orRosterClientSiteIDTerms.add(new Match("rc.RosterClientSiteID", 0)); DBFilter notExistsFilter = new DBFilter(); notExistsFilter.add(new MatchField("RosterTable.RosterCodeID", "nic.RosterCodeID")); orRosterTableTerms.add(new Exists(ERosterCode.db.dbclass.tableName + " nic", notExistsFilter, true)); } rosterClientSiteFilter.add(orRosterClientSiteIDTerms); orRosterTableTerms.add(new IN("RosterCodeID", "Select rc.RosterCodeID From " + ERosterCode.db.dbclass.tableName + " rc", rosterClientSiteFilter)); //if (orEmpHierarchyTerms != null) //{ // DBFilter empRosterTableGroupFilter = new DBFilter(); // empRosterTableGroupFilter.add(orEmpHierarchyTerms); // empRosterTableGroupFilter.add(new Match("ertg.empRosterTableGroupEffFr", "<=", DateTo)); // OR orEmpPosEffToTerms = new OR(); // orEmpPosEffToTerms.add(new Match("ertg.empRosterTableGroupEffTo", ">=", DateFrom)); // orEmpPosEffToTerms.add(new NullTerm("ertg.empRosterTableGroupEffTo")); // empRosterTableGroupFilter.add(orEmpPosEffToTerms); // orRosterTableTerms.add(new IN("EmpID", "Select distinct EmpID From " + EEmpPositionInfo.db.dbclass.tableName + " epi ", empRosterTableGroupFilter)); //} if (orEmpPosRosterTableGroupTerms != null) { DBFilter empRosterTableGroupFilter = new DBFilter(); empRosterTableGroupFilter.add(orEmpPosRosterTableGroupTerms); empRosterTableGroupFilter.add(new Match("ertg.empRosterTableGroupEffFr", "<=", DateTo)); OR orEmpPosEffToTerms = new OR(); orEmpPosEffToTerms.add(new Match("ertg.empRosterTableGroupEffTo", ">=", DateFrom)); orEmpPosEffToTerms.add(new NullTerm("ertg.empRosterTableGroupEffTo")); empRosterTableGroupFilter.add(orEmpPosEffToTerms); orRosterTableTerms.add(new IN("EmpID", "Select distinct EmpID From " + EEmpRosterTableGroup.db.dbclass.tableName + " ertg ", empRosterTableGroupFilter)); } rosterTableFilter.add(orRosterTableTerms); if (UserID > 0) { rosterTableFilter.add(AppUtils.AddRankDBTerm(UserID, "EmpID", true)); } ArrayList rosterTableList = ERosterTable.db.select(dbConn, rosterTableFilter); eventList.AddRange(GenerateEventList(rosterTableList)); DBFilter leaveAppFilter = new DBFilter(); leaveAppFilter.add(new Match("LeaveAppDateTo", ">=", DateFrom.AddDays(-1))); leaveAppFilter.add(new Match("LeaveAppDateFrom", "<=", DateTo)); if (!ShowRosterCodeWithoutSiteMapping && orEmpPosRosterTableGroupTerms != null) { DBFilter empRosterTableGroupFilter = new DBFilter(); empRosterTableGroupFilter.add(orEmpPosRosterTableGroupTerms); empRosterTableGroupFilter.add(new Match("ertg.empRosterTableGroupEffFr", "<=", DateTo)); OR orEmpPosEffToTerms = new OR(); orEmpPosEffToTerms.add(new Match("ertg.empRosterTableGroupEffTo", ">=", DateFrom)); orEmpPosEffToTerms.add(new NullTerm("ertg.empRosterTableGroupEffTo")); empRosterTableGroupFilter.add(orEmpPosEffToTerms); leaveAppFilter.add(new IN("EmpID", "Select distinct EmpID From " + EEmpRosterTableGroup.db.dbclass.tableName + " ertg ", empRosterTableGroupFilter)); } eventList.AddRange(GenerateEventList(ELeaveApplication.db.select(dbConn, leaveAppFilter))); // Put the holiday list at the end of the collection so that the item can be display at the top of the day. eventList.AddRange(GenerateEventList(HolidayDBObjectList(DateFrom, DateTo))); }