public override bool Execute()
        {
            try
            {
                mpfFileProcess.LoadMPFFileDetail(empList, MPFPlanID, PayPeriodFr, PayPeriodTo);
                FileInfo mpfFile      = mpfFileProcess.GenerateMPFFile();
                DateTime generateDate = AppUtils.ServerDateTime();

                string strTmpFolder = HROne.Common.Folder.GetOrCreateApplicationTempFolder().FullName;// System.IO.Path.GetTempPath(); //Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);

                string mpfFileName          = mpfFile.FullName;
                string mpfFileNameExtension = mpfFileName.Substring(mpfFileName.LastIndexOf("."));
                string outputMPFFileName    = mpfFileProcess.ActualMPFFileName(); //"MPFFile_" + generateDate.ToString("yyyyMMddHHmmss") + mpfFileNameExtension;
                string strMPFTmpFile        = System.IO.Path.Combine(strTmpFolder, System.IO.Path.GetFileName(mpfFileName));
                System.IO.File.Move(mpfFileName, strMPFTmpFile);

                string ChequeNo = "";   // cheque no for AIA only, not applicable to iMgr

                HROne.MPFFile.MPFRemittanceStatementProcess remittanceStatementProcess = new HROne.MPFFile.MPFRemittanceStatementProcess(dbConn, empList, MPFPlanID, PayPeriodFr, PayPeriodTo, ChequeNo);

                string exportFileName          = remittanceStatementProcess.ReportExportToFile(string.Empty, "PDF", true);
                string exportFileNameExtension = exportFileName.Substring(exportFileName.LastIndexOf("."));
                string outputFileName          = "MPFRemittanceStatement_" + generateDate.ToString("yyyyMMddHHmmss") + exportFileNameExtension;
                string strTmpFile = System.IO.Path.Combine(strTmpFolder, System.IO.Path.GetFileName(exportFileName));
                System.IO.File.Move(exportFileName, strTmpFile);

                string InboxMessageType = string.Empty;
                // currently only gateway format is supported for directly submitted
                if (mpfFileProcess is HSBCMPFGatewayFile && !(mpfFileProcess is HSBCMPFGatewayFileEncrypted))
                {
                    InboxMessageType = EInbox.INBOX_TYPE_MPF_FILE + "|" + EInbox.INBOX_TYPE_FOR_ECHANNEL;
                }

                EInbox inbox = EInbox.CreateAndSaveInboxMessage(dbConn, user.UserID, 0, 0, 0, string.Empty, InboxMessageType, ReportName, string.Empty, new DateTime());

                inbox.AddInboxAttachment(dbConn, outputMPFFileName, strMPFTmpFile);
                inbox.AddInboxAttachment(dbConn, outputFileName, strTmpFile);

                if (mpfFileProcess is HSBCMPFGatewayFileEncrypted)
                {
                    HROne.MPFFile.HSBCMPFGatewayFileEncryptedCoverProcess coverProcess = new HROne.MPFFile.HSBCMPFGatewayFileEncryptedCoverProcess(dbConn, (HSBCMPFGatewayFileEncrypted)mpfFileProcess);

                    string exportCoverFileName          = coverProcess.ReportExportToFile(string.Empty, "PDF", true);
                    string exportCoverFileNameExtension = exportCoverFileName.Substring(exportCoverFileName.LastIndexOf("."));
                    string outputCoverFileName          = "Cover_" + generateDate.ToString("yyyyMMddHHmmss") + exportCoverFileNameExtension;
                    string strCoverTmpFile = System.IO.Path.Combine(strTmpFolder, System.IO.Path.GetFileName(exportCoverFileName));
                    System.IO.File.Move(exportCoverFileName, strCoverTmpFile);

                    inbox.AddInboxAttachment(dbConn, outputCoverFileName, strCoverTmpFile);
                    coverProcess.Dispose();
                }

                dbConn.Dispose();
                remittanceStatementProcess.Dispose();
                return(true);
            }
            catch (Exception ex)
            {
                EInbox inbox = EInbox.CreateAndSaveInboxMessage(dbConn, user.UserID, 0, 0, 0, string.Empty, string.Empty, ReportName, ex.Message + "\r\n" + ex.StackTrace, new DateTime());
                dbConn.Dispose();
            }
            return(false);
        }
    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())
        {
            try
            {
                HROne.MPFFile.MPFRemittanceStatementProcess rpt = new HROne.MPFFile.MPFRemittanceStatementProcess(dbConn, empList, int.Parse(MPFPlanID.SelectedValue), dtPayPeriodFr, dtPayPeriodTo, txtChequeNo.Text.ToUpper());

                string reportFileName = WebUtils.GetLocalizedReportFile(Server.MapPath("~/Report_Payroll_MPFRemittanceStatement.rpt"));
                WebUtils.ReportExport(dbConn, user, errors, lblReportHeader.Text, Response, rpt, reportFileName, ((Button)sender).CommandArgument, "MPFRemittanceStatement", true);
            }
            catch (Exception ex)
            {
                errors.addError(ex.Message);
            }
        }
//        emploadData(empInfo, EEmpPayroll.db, empRepeater);
    }