public GenerateMPFContributionFileTaskFactory(DatabaseConnection dbConn, EUser user, string ReportName, GenericMPFFile mpfFileProcess, ArrayList empList, int MPFPlanID, DateTime PayPeriodFr, DateTime PayPeriodTo, System.Globalization.CultureInfo reportCultureInfo) { this.dbConn = dbConn.createClone(); this.user = user; this.ReportName = ReportName; this.mpfFileProcess = mpfFileProcess; this.MPFPlanID = MPFPlanID; this.empList = empList; this.PayPeriodFr = PayPeriodFr; this.PayPeriodTo = PayPeriodTo; this.reportCultureInfo = reportCultureInfo; }
private GenericMPFFile getMPFFileObject() { GenericMPFFile mpfFileObject = mpfFileControl.CreateMPFFileObject(); //else // mpfFileObject = new GenericMPFFile(dbConn); //if (MPFFileType.SelectedValue.Equals("HSBC")) // bankFileObject = bankFileControlCreateMPFFileObject(); //if (MPFFileType.SelectedValue.Equals("SCB")) // bankFileObject = Payroll_GenerateMPFFile_SCBControl.CreateMPFFileObject(); //if (MPFFileType.SelectedValue.Equals("CitiBank")) // bankFileObject = Payroll_GenerateMPFFile_CitiBankControl.CreateMPFFileObject(); //if (bankFileObject == null) // bankFileObject=new GenericMPFFile(); return(mpfFileObject); }
protected void btnGenerate_Click(object sender, EventArgs e) { PageErrors errors = PageErrors.getErrors(db, Page.Master); errors.clear(); ArrayList empList = new ArrayList(); foreach (RepeaterItem i in empRepeater.Items) { CheckBox cb = (CheckBox)i.FindControl("ItemSelect"); if (cb.Checked) { EEmpPersonalInfo o = (EEmpPersonalInfo)EEmpPersonalInfo.db.createObject(); WebFormUtils.GetKeys(EEmpPersonalInfo.db, o, cb); empList.Add(o); } } string strEmpList = string.Empty; string strPayBatchList = string.Empty; string strPayPeriodRequest = string.Empty; DateTime dtPayPeriodFr = new DateTime(); DateTime dtPayPeriodTo = new DateTime(); if (empList.Count > 0) { foreach (EEmpPersonalInfo o in empList) { if (strEmpList == string.Empty) { strEmpList = ((EEmpPersonalInfo)o).EmpID.ToString(); } else { strEmpList += "_" + ((EEmpPersonalInfo)o).EmpID.ToString(); } } if (DateTime.TryParse(PayPeriodFr.Value, out dtPayPeriodFr) && DateTime.TryParse(PayPeriodTo.Value, out dtPayPeriodTo)) { strPayPeriodRequest = "&PayPeriodFr=" + dtPayPeriodFr.Ticks + "&PayPeriodTo=" + dtPayPeriodTo.Ticks; } else { errors.addError("Invalid Date Format"); } // errors.addError("Complete"); //Response.Write("<script>alert('Completed'); </script>"); } else { errors.addError("Employee or Payroll Batch not selected"); } if (errors.isEmpty()) { GenericMPFFile mpfFileProcess = getMPFFileObject(); if (mpfFileProcess == null) { errors.addError("Generate MPF File is not available for that MPF Scheme"); return; } if (mpfFileProcess is HSBCMPFGatewayFileEncrypted) { string keyFolderPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "BankKey"); string keyPath = string.Empty; string HSBCKeyFileName = "HSBC.pub"; string HangSengKeyFileName = "HASE.pub"; string password = "******"; int intMPFPlanID = 0; if (int.TryParse(MPFPlanID.SelectedValue, out intMPFPlanID)) { EMPFPlan mpfPlan = new EMPFPlan(); mpfPlan.MPFPlanID = intMPFPlanID; if (EMPFPlan.db.select(dbConn, mpfPlan)) { EMPFScheme mpfScheme = new EMPFScheme(); mpfScheme.MPFSchemeID = mpfPlan.MPFSchemeID; if (EMPFScheme.db.select(dbConn, mpfScheme)) { if (mpfScheme.MPFSchemeTrusteeCode.Equals("HSBC")) { keyPath = System.IO.Path.Combine(keyFolderPath, HSBCKeyFileName); if (Application["MasterDBConfig"] != null) { DatabaseConnection masterDBConn = ((DatabaseConfig)Application["MasterDBConfig"]).CreateDatabaseConnectionObject(); string HSBCKeyPath = HROne.SaaS.Entities.ESystemParameter.getParameter(masterDBConn, HROne.SaaS.Entities.ESystemParameter.PARAM_CODE_BANKKEY_HSBC_PATH); string HSBCPassword = HROne.SaaS.Entities.ESystemParameter.getParameterWithEncryption(masterDBConn, HROne.SaaS.Entities.ESystemParameter.PARAM_CODE_BANKKEY_HSBC_PASSWORD); if (!string.IsNullOrEmpty(HSBCKeyPath) && !string.IsNullOrEmpty(HSBCPassword)) { keyPath = HSBCKeyPath; password = HSBCPassword; } } } else if (mpfScheme.MPFSchemeTrusteeCode.Equals("HangSeng")) { keyPath = System.IO.Path.Combine(keyFolderPath, HangSengKeyFileName); if (Application["MasterDBConfig"] != null) { DatabaseConnection masterDBConn = ((DatabaseConfig)Application["MasterDBConfig"]).CreateDatabaseConnectionObject(); string HASEKeyPath = HROne.SaaS.Entities.ESystemParameter.getParameter(masterDBConn, HROne.SaaS.Entities.ESystemParameter.PARAM_CODE_BANKKEY_HASE_PATH); string HASEPassword = HROne.SaaS.Entities.ESystemParameter.getParameterWithEncryption(masterDBConn, HROne.SaaS.Entities.ESystemParameter.PARAM_CODE_BANKKEY_HASE_PASSWORD); if (!string.IsNullOrEmpty(HASEKeyPath) && !string.IsNullOrEmpty(HASEPassword)) { keyPath = HASEKeyPath; password = HASEPassword; } } } } } } HSBCMPFGatewayFileEncrypted mpfFileEncrypted = (HSBCMPFGatewayFileEncrypted)mpfFileProcess; mpfFileEncrypted.publicKeyFile = keyPath; mpfFileEncrypted.publicKeyPassword = password; } HROneConfig config = HROneConfig.GetCurrentHROneConfig(); if (config.GenerateReportAsInbox) { if (EInboxAttachment.GetTotalSize(dbConn, 0) < WebUtils.productLicense(Session).MaxInboxSizeMB * 1000 * 1000) { HROne.TaskService.GenerateMPFContributionFileTaskFactory reportTask = new HROne.TaskService.GenerateMPFContributionFileTaskFactory(dbConn, user, lblReportHeader.Text, mpfFileProcess, empList, int.Parse(MPFPlanID.SelectedValue), dtPayPeriodFr, dtPayPeriodTo, ci); AppUtils.reportTaskQueueService.AddTask(reportTask); errors.addError(HROne.Translation.PageMessage.REPORT_GENERATING_TO_INBOX); } else { errors.addError(HROne.Translation.PageMessage.INBOX_SIZE_EXCEEDED); } } else { try { mpfFileProcess.LoadMPFFileDetail(empList, int.Parse(MPFPlanID.SelectedValue), dtPayPeriodFr, dtPayPeriodTo); FileInfo mpfFileInfo = mpfFileProcess.GenerateMPFFile(); string mpfFilename = mpfFileProcess.ActualMPFFileName(); WebUtils.TransmitFile(Response, mpfFileInfo.FullName, mpfFilename, true); } catch (Exception ex) { errors.addError(ex.Message); } } } // emploadData(empInfo, EEmpPayroll.db, empRepeater); }