Exemple #1
0
    protected void Delete_Click(object sender, EventArgs e)
    {
        EInbox o = new EInbox();

        o.InboxID = CurID;
        if (db.select(dbConn, o))
        {
            o.Delete(dbConn);
            //string uploadFolder = uploadFolder = AppUtils.GetDocumentUploadFolder(dbConn);

            //DBFilter attachmentFilter = new DBFilter();
            //attachmentFilter.add(new Match("InboxID", o.InboxID));
            //ArrayList attachmentList = EInboxAttachment.db.select(dbConn, attachmentFilter);

            //foreach (EInboxAttachment attachment in attachmentList)
            //{
            //    try
            //    {
            //        string UploadFile = System.IO.Path.Combine(uploadFolder, attachment.InboxAttachmentStoredFileName);
            //        if (System.IO.File.Exists(UploadFile))
            //            System.IO.File.Delete(UploadFile);
            //    }
            //    catch
            //    {
            //    }
            //    finally
            //    {
            //        EInboxAttachment.db.delete(dbConn, attachment);
            //    }
            //}
            //db.delete(dbConn, o);
        }
        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/Inbox_List.aspx");
    }
Exemple #2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        EInbox o = new EInbox();

        o.InboxID = CurID;
        if (db.select(dbConn, o))
        {
            System.Collections.Generic.List <string> inboxTypeArray = new System.Collections.Generic.List <string>(o.InboxType.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries));
            if (inboxTypeArray.Contains(EInbox.INBOX_TYPE_FOR_ECHANNEL) && !inboxTypeArray.Contains(EInbox.INBOX_TYPE_FOR_ECHANNEL_SUBMITTED))
            {
                if (inboxTypeArray.Contains(EInbox.INBOX_TYPE_AUTOPAY_FILE))
                {
                    HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/eChannel_SubmitAutopayFile.aspx?inboxID=" + CurID);
                }
                else if (inboxTypeArray.Contains(EInbox.INBOX_TYPE_MPF_FILE))
                {
                    HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/eChannel_SubmitMPFContributionFile.aspx?inboxID=" + CurID);
                }
                eChannelRow.Visible = false;
            }
            else
            {
                PageErrors errors = PageErrors.getErrors(db, this.Master);
                errors.addError("File is already submitted");
            }
        }
        //HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/Inbox_List.aspx");
    }
    protected void Repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        DataRowView row = (DataRowView)e.Item.DataItem;

        EInbox obj = new EInbox();

        db.toObject(((DataRowView)e.Item.DataItem).Row, obj);

        CheckBox cb = (CheckBox)e.Item.FindControl("ItemSelect");

        WebFormUtils.LoadKeys(db, row, cb);

        if (obj.UserID.Equals(0))
        {
            cb.Visible = false;
        }
        Label InboxFromUserName = (Label)e.Item.FindControl("InboxFromUserName");
        Label InboxCreateDate   = (Label)e.Item.FindControl("InboxCreateDate");
        Label InboxSubject      = (Label)e.Item.FindControl("InboxSubject");

        InboxFromUserName.Text = obj.InboxFromUserName;
        InboxCreateDate.Text   = obj.InboxCreateDate.ToString("yyyy-MM-dd HH:mm:ss");
        InboxSubject.Text      = obj.InboxSubject;

        if (obj.InboxReadDate.Ticks.Equals(0))
        {
            InboxFromUserName.Font.Bold = true;
            InboxCreateDate.Font.Bold   = true;
            InboxSubject.Font.Bold      = true;
        }

        cb.Visible = toolBar.DeleteButton_Visible;
    }
        public override bool Execute()
        {
            try
            {
                TaxationDiskProcess process = new TaxationDiskProcess(dbConn, taxFormID);

                string taxFileName;
                string fileExtension = ".txt";
                if (fileFormat.Equals("XML", StringComparison.CurrentCultureIgnoreCase))
                {
                    taxFileName   = process.GenerateToXML();
                    fileExtension = ".xml";
                }
                else
                {
                    taxFileName = process.GenerateToFile();
                }

                DateTime generateDate = AppUtils.ServerDateTime();

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

                string autoPayFileNameExtension = taxFileName.Substring(taxFileName.LastIndexOf("."));
                string outputTaxFileName        = "TaxationFile_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + fileExtension;
                string strTaxTmpFile            = System.IO.Path.Combine(strTmpFolder, System.IO.Path.GetFileName(taxFileName));
                System.IO.File.Move(taxFileName, strTaxTmpFile);

                string strTmpReportFilePath = string.Empty;
                string reportOutputFileName = string.Empty;
                if (!fileExtension.Equals(".xml"))
                {
                    HROne.Reports.Taxation.ControlListProcess rpt = new HROne.Reports.Taxation.ControlListProcess(dbConn, taxFormID, NameOfSignature);

                    string reportFileName          = rpt.ReportExportToFile(string.Empty, "PDF", false);
                    string reportFileNameExtension = reportFileName.Substring(reportFileName.LastIndexOf("."));
                    reportOutputFileName = "TaxControlList_" + generateDate.ToString("yyyyMMddHHmmss") + reportFileNameExtension;
                    strTmpReportFilePath = System.IO.Path.Combine(strTmpFolder, System.IO.Path.GetFileName(reportFileName));
                    System.IO.File.Move(reportFileName, strTmpReportFilePath);
                    rpt.Dispose();
                }
                string InboxMessageType = string.Empty;

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

                inbox.AddInboxAttachment(dbConn, outputTaxFileName, strTaxTmpFile);
                if (!string.IsNullOrEmpty(strTmpReportFilePath))
                {
                    inbox.AddInboxAttachment(dbConn, reportOutputFileName, strTmpReportFilePath);
                }

                dbConn.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);
        }
    public DataView loadData(ListInfo info, DBManager db, Repeater repeater)
    {
        DBFilter filter = binding.createFilter();

        if (info != null && info.orderby != null && !info.orderby.Equals(""))
        {
            filter.add(info.orderby, info.order);
        }
        else
        {
            filter.add("inb.InboxCreateDate", false);
        }

        OR orUserIDFilter = new OR();

        orUserIDFilter.add(new Match("inb.UserID", WebUtils.GetCurUser(Session).UserID));
        orUserIDFilter.add(new Match("inb.UserID", 0));
        filter.add(orUserIDFilter);
        filter.add(new NullTerm("inb.InboxDeleteDate"));
        string select = "inb.*";
        string from   = "from [" + db.dbclass.tableName + "] inb ";

        DataTable table = WebUtils.GetDataTableFromSelectQueryWithFilter(dbConn, select, from, filter, info);

        foreach (DataRow row in table.Rows)
        {
            EInbox obj = new EInbox();
            db.toObject(row, obj);

            if (string.IsNullOrEmpty(obj.InboxSubject))
            {
                row["InboxSubject"] = AppUtils.GetActualInboxSubject(dbConn, obj);
            }
            if (string.IsNullOrEmpty(obj.InboxFromUserName))
            {
                row["InboxFromUserName"] = obj.GetFromUserName(dbConn);
            }
        }


        view = new DataView(table);

        if (repeater != null)
        {
            repeater.DataSource = view;
            repeater.DataBind();
        }

        return(view);
    }
        public override bool Execute()
        {
            try
            {
                string exportFileName = reportProcess.ReportExportToFile(reportTemplateFileName, ExportFormat, IsLocalize);

                string exportFileNameExtension = exportFileName.Substring(exportFileName.LastIndexOf("."));
                string outputFileName          = OutputFilenamePrefix + "_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + exportFileNameExtension;

                EInbox inbox        = EInbox.CreateAndSaveInboxMessage(dbConn, user.UserID, 0, 0, 0, string.Empty, string.Empty, ReportName, string.Empty, new DateTime());
                string strTmpFolder = HROne.Common.Folder.GetOrCreateApplicationTempFolder().FullName;// System.IO.Path.GetTempPath(); //Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
                string strTmpFile   = System.IO.Path.Combine(strTmpFolder, System.IO.Path.GetFileName(exportFileName));
                System.IO.File.Move(exportFileName, strTmpFile);

                inbox.AddInboxAttachment(dbConn, outputFileName, strTmpFile);

                //string uploadFolder = AppUtils.GetDocumentUploadFolder(dbConn);
                //string relativePath = @"Inbox\" + inbox.InboxID + "_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + ".hrd";
                //string destinationFile = System.IO.Path.Combine(uploadFolder, relativePath);
                //System.IO.DirectoryInfo inboxDirectoryInfo = new DirectoryInfo(System.IO.Path.GetDirectoryName(destinationFile));
                //if (!inboxDirectoryInfo.Exists)
                //    inboxDirectoryInfo.Create();
                //zip.Compress(strTmpFolder, System.IO.Path.GetFileName(strTmpFile), destinationFile);
                //System.IO.File.Delete(outputFileName);


                //EInboxAttachment attachment = new EInboxAttachment();
                //attachment.InboxID = inbox.InboxID;
                //attachment.InboxAttachmentOriginalFileName = outputFileName;
                //attachment.InboxAttachmentStoredFileName = relativePath;
                //attachment.InboxAttachmentIsCompressed = true;
                //attachment.InboxAttachmentSize = new System.IO.FileInfo(destinationFile).Length;
                //EInboxAttachment.db.insert(dbConn, attachment);

                dbConn.Dispose();
                reportProcess.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();
                reportProcess.Dispose();
            }
            return(false);
        }
    protected void Delete_Click(object sender, EventArgs e)
    {
        EUser activeUser = WebUtils.GetCurUser(Session);

        EUser c = new EUser();

        c.UserID = CurID;
        if (EUser.db.select(dbConn, c))
        {
            bool isAllowDelete = true;
            if (activeUser.UsersCannotCreateUsersWithMorePermission)
            {
                if (!c.UsersCannotCreateUsersWithMorePermission)
                {
                    isAllowDelete = false;
                }
                else if (!c.IsAllowSubmitPermission(dbConn, activeUser.UserID))
                {
                    isAllowDelete = false;
                }
            }

            if (isAllowDelete)
            {
                WebUtils.StartFunction(Session, FUNCTION_CODE);
                c.UserAccountStatus = "D";
                db.update(dbConn, c);
                WebUtils.EndFunction(dbConn);
                EInbox.DeleteAllByUserID(dbConn, c.UserID);
            }
            else
            {
                PageErrors errors = PageErrors.getErrors(db, Page.Master);
                errors.clear();

                errors.addError(PageErrorMessage.ERROR_INVALID_PERMISSION);
                return;
            }
        }
        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "User_List.aspx");
    }
    protected void Delete_Click(object sender, EventArgs e)
    {
        ArrayList list = WebUtils.SelectedRepeaterItemToBaseObjectList(db, Repeater, "ItemSelect");

        EUser activeUser = WebUtils.GetCurUser(Session);

        if (activeUser != null)
        {
            foreach (EUser user in list)
            {
                if (EUser.db.select(dbConn, user))
                {
                    bool isAllowDelete = true;
                    if (activeUser.UsersCannotCreateUsersWithMorePermission)
                    {
                        if (!user.UsersCannotCreateUsersWithMorePermission)
                        {
                            isAllowDelete = false;
                        }
                        else if (!user.IsAllowSubmitPermission(dbConn, activeUser.UserID))
                        {
                            isAllowDelete = false;
                        }
                    }

                    if (isAllowDelete)
                    {
                        WebUtils.StartFunction(Session, FUNCTION_CODE);
                        user.UserAccountStatus = "D";
                        db.update(dbConn, user);
                        WebUtils.EndFunction(dbConn);
                        EInbox.DeleteAllByUserID(dbConn, user.UserID);
                    }
                }
            }
        }
        loadData(info, db, Repeater);
    }
Exemple #9
0
    protected bool loadObject()
    {
        EInbox obj   = new EInbox();
        bool   isNew = WebFormWorkers.loadKeys(db, obj, DecryptedRequest);

        if (!db.select(dbConn, obj))
        {
            if (CurID <= 0)
            {
                return(false);
            }
            else
            {
                HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx");
            }
        }
        if (obj.UserID != 0 && obj.UserID != user.UserID)
        {
            HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx");
        }
        if (obj.InboxReadDate.Ticks.Equals(0))
        {
            obj.InboxReadDate = AppUtils.ServerDateTime();
            db.update(dbConn, obj);
        }
        if (obj.InboxType.Equals(EInbox.INBOX_TYPE_DATE_OF_BIRTH) || obj.InboxType.Equals(EInbox.INBOX_TYPE_DATE_OF_BIRTH_18) || obj.InboxType.Equals(EInbox.INBOX_TYPE_DATE_OF_BIRTH_65) || obj.InboxType.Equals(EInbox.INBOX_TYPE_PROBATION))
        {
            HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/Emp_View.aspx?EmpID=" + obj.EmpID);
        }
        else if (obj.InboxType.Equals(EInbox.INBOX_TYPE_TERMINATION))
        {
            HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/EmpTab_Termination_View.aspx?EmpID=" + obj.EmpID);
        }
        else if (obj.InboxType.Equals(EInbox.INBOX_TYPE_WORKPERMITEXPIRY))
        {
            HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/Emp_Permit_view.aspx?EmpID=" + obj.EmpID + "&EmpPermitID=" + obj.InboxRelatedRecID);
        }
        Hashtable values = new Hashtable();

        db.populate(obj, values);
        binding.toControl(values);

        InboxFromUserID.Text = obj.GetFromUserName(dbConn);
        InboxSubject.Text    = AppUtils.GetActualInboxSubject(dbConn, obj);
        DBFilter inboxAttachmentFilter = new DBFilter();

        inboxAttachmentFilter.add(new Match("InboxID", obj.InboxID));
        ArrayList inboxAttachmentList = EInboxAttachment.db.select(dbConn, inboxAttachmentFilter);

        if (inboxAttachmentList.Count > 0)
        {
            InboxAttachmentRepeater.DataSource = inboxAttachmentList;
            InboxAttachmentRepeater.DataBind();
        }
        else
        {
            AttachmentRow.Visible = false;
        }
        System.Collections.Generic.List <string> inboxTypeArray = new System.Collections.Generic.List <string>(obj.InboxType.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries));
        if (inboxTypeArray.Contains(EInbox.INBOX_TYPE_FOR_ECHANNEL) && !inboxTypeArray.Contains(EInbox.INBOX_TYPE_FOR_ECHANNEL_SUBMITTED))
        {
            eChannelRow.Visible = true;
            InboxMessage.Text  += "<br/>"
                                  + "<p style=\"color:red\">" + HttpUtility.HtmlEncode(HROne.Translation.PageMessage.BANKFILE_CONSOLIDATION_MESSAGE) + "<br/>"
                                  + HttpUtility.HtmlEncode(HROne.Translation.PageMessage.BANKFILE_CLEARING_MESSAGE) + "</p><br/>";
        }
        else
        {
            eChannelRow.Visible = false;
        }

        return(true);
    }
        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);
        }
Exemple #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!WebUtils.CheckAccess(Response, Session))
        {
            return;
        }

        int InboxAttachmentID = 0;
        int InboxID           = 0;

        try
        {
            InboxAttachmentID = int.Parse(DecryptedRequest["InboxAttachmentID"]);
            InboxID           = int.Parse(DecryptedRequest["InboxID"]);
        }
        catch
        {
            return;
        }

        //string pathDelimiter = System.IO.Path.DirectorySeparatorChar.ToString();

        EInboxAttachment inboxAttachment = new EInboxAttachment();

        inboxAttachment.InboxAttachmentID = InboxAttachmentID;

        if (EInboxAttachment.db.select(dbConn, inboxAttachment))
        {
            if (inboxAttachment.InboxID.Equals(InboxID))
            {
                EInbox inbox = new EInbox();
                inbox.InboxID = InboxID;
                if (EInbox.db.select(dbConn, inbox))
                {
                    if (inbox.UserID.Equals(user.UserID) || inbox.UserID.Equals(0))
                    {
                        string documentFilePath = inboxAttachment.GetDocumentPhysicalPath(dbConn);
                        string transferFilePath = documentFilePath;
                        string strTmpFolder     = string.Empty;
                        if (inboxAttachment.InboxAttachmentIsCompressed)
                        {
                            transferFilePath = inboxAttachment.GetExtractedFilePath(dbConn);
                        }
                        if (System.IO.File.Exists(transferFilePath))
                        {
                            Response.ClearContent();
                            Response.ClearHeaders();
                            Response.ContentType = "application/download"; //Fixed download problem on https
                            Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(inboxAttachment.InboxAttachmentOriginalFileName));
                            Response.AppendHeader("Content-Length", new System.IO.FileInfo(transferFilePath).Length.ToString());
                            Response.Expires = -1;
                            Response.WriteFile(transferFilePath, true);
                            Response.Flush();
                            //                    WebUtils.TransmitFile(Response, strTmpFolder + pathDelimiter+ fileList[0], empDocument.EmpDocumentOriginalFileName, true);
                        }
                        inboxAttachment.RemoveExtractedFile();
                        Response.End();
                    }
                }
            }
        }
    }
        public override bool Execute()
        {
            try
            {
                bankFileProcess.LoadBankFileDetail(payBatchList, empList);
                FileInfo bankFile     = bankFileProcess.GenerateBankFile();
                DateTime generateDate = AppUtils.ServerDateTime();

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

                string autoPayFileName          = bankFile.FullName;
                string autoPayFileNameExtension = autoPayFileName.Substring(autoPayFileName.LastIndexOf("."));
                string outputAutoPayFileName    = bankFileProcess.ActualBankFileName(); //"BankFile_" + generateDate.ToString("yyyyMMddHHmmss") + autoPayFileNameExtension;
                string strAutoPayTmpFile        = System.IO.Path.Combine(strTmpFolder, System.IO.Path.GetFileName(autoPayFileName));
                System.IO.File.Move(autoPayFileName, strAutoPayTmpFile);

                HROne.BankFile.AutopayListProcess autoPayListProcess = new HROne.BankFile.AutopayListProcess(dbConn, bankFileProcess.CreateAutopayListDataSet(), PayPeriodFr, reportCultureInfo);

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

                foreach (EPayrollBatch payBatch in payBatchList)
                {
                    payBatch.PayBatchFileGenDate = generateDate;
                    payBatch.PayBatchValueDate   = valueDate;
                    payBatch.PayBatchFileGenBy   = user.UserID;
                    EPayrollBatch.db.update(dbConn, payBatch);
                }
                HROne.Payroll.PayrollProcess.UpdateEmpPayrollValueDate(dbConn, payBatchList, empList, valueDate, true, bankFileProcess.IsGenerateChequePayment, false, false);

                string InboxMessageType = string.Empty;
                if (bankFileProcess is HSBCBankFile && !(bankFileProcess is HSBCBankFileEncrypted))
                {
                    if (!((HSBCBankFile)bankFileProcess).UseBIBFormat)
                    {
                        InboxMessageType = EInbox.INBOX_TYPE_AUTOPAY_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, outputAutoPayFileName, strAutoPayTmpFile);
                inbox.AddInboxAttachment(dbConn, outputFileName, strTmpFile);

                if (bankFileProcess is HSBCBankFileEncrypted)
                {
                    HROne.BankFile.HSBCBankFileEncryptedCoverProcess coverProcess = new HROne.BankFile.HSBCBankFileEncryptedCoverProcess(dbConn, (HSBCBankFileEncrypted)bankFileProcess);

                    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();
                autoPayListProcess.Dispose();
                return(true);
            }
            catch (NegativeAmountException ex)
            {
                string    message           = HROne.Common.WebUtility.GetLocalizedStringByCode("ERROR_BANKFILE_NEGATIVE", "Bank file should not contain negative amount");
                ArrayList errorBankFileList = ex.GetErrorBankFileDetailList();
                foreach (GenericBankFileDetail detail in errorBankFileList)
                {
                    message += "\r\n- " + HROne.Common.WebUtility.GetLocalizedString("EmpNo") + ": " + detail.EmpNo + ", " + HROne.Common.WebUtility.GetLocalizedString("Amount") + ": " + detail.Amount;
                }
                EInbox inbox = EInbox.CreateAndSaveInboxMessage(dbConn, user.UserID, 0, 0, 0, string.Empty, string.Empty, ReportName, message, new DateTime());
            }
            catch (InvalidEEBankAccountException ex)
            {
                string message = ex.Message;
                message += "\r\n- " + ex.EmpNo + " - " + ex.EmpName;
                EInbox inbox = EInbox.CreateAndSaveInboxMessage(dbConn, user.UserID, 0, 0, 0, string.Empty, string.Empty, ReportName, message, new DateTime());
            }
            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);
        }