Example #1
0
        private bool PrepareAndSendMail(string[] certificateNo, string COMPANY_NAME, string CLIENT_CERTIFICATE_SEND_EMAIL_ADDRESS, DateTime?EXPIRATION_DATE, string PASSWORD, int FY)
        {
            //get config object for CTS010
            BOL_CONFIG config = new BOL_CONFIG("CTS080", con);

            string documentFilePath = config.getStringValue("email.attached.doc.filePath");
            string path             = config.getStringValue("email.attached.client.filePath");
            string clientFilePath   = path + @"\" + FY.ToString();

            Dictionary <string, string> filePaths = new Dictionary <string, string>()
            {
                { "Document", documentFilePath },
                { "Certificate", clientFilePath }
            };

            List <string> CERTIFICATES          = new List <string>();
            string        CLIENT_CERTIFICATE_NO = "";

            foreach (string item in certificateNo)
            {
                if (string.IsNullOrEmpty(CLIENT_CERTIFICATE_NO))
                {
                    CLIENT_CERTIFICATE_NO += item;
                }
                else
                {
                    CLIENT_CERTIFICATE_NO += "\n" + item;
                }
                CERTIFICATES.Add(item);
            }

            Dictionary <string, string> map = new Dictionary <string, string>()
            {
                { "${companyName}", COMPANY_NAME },
                { "${clientCertificate}", CLIENT_CERTIFICATE_NO },
                { "${expirationDate}", EXPIRATION_DATE.ToString() },
                { "${password}", PASSWORD },
            };

            //prepare for mail header
            string template_base_name    = "CTS080_ClientCertificate";
            string subject               = config.getStringValue("emailSubject.client"); //come from config table
            String distributionAddressCC = config.getStringValue("emailAddress.cc");

            string file_path, body;

            try
            {
                //read email template
                file_path = HttpContext.Current.Server.MapPath("~/Templates/Mail/" + template_base_name + ".txt");
                body      = System.IO.File.ReadAllText(file_path);
            }
            catch (Exception)
            {
                return(false);
            }

            //send mail
            return(Utility.Mail.sendClientCertificateMail(CLIENT_CERTIFICATE_SEND_EMAIL_ADDRESS, distributionAddressCC, subject, body, map, filePaths, CERTIFICATES));
        }
        private bool DisapproveSendMail(string COMPANY_NAME, string INPUT_PERSON, string INPUT_PERSON_EMAIL_ADDRESS, out DataTable template)
        {
            DataTable message = new DataTable();

            message.Columns.Add("Error Message");
            message.Columns.Add("Message");
            message.Columns.Add("SendMail");
            message.Columns.Add("EmailAddressCC");
            message.Columns.Add("TemplateString");
            message.Columns.Add("SubjectString");

            //get config object for CTS030
            BOL_CONFIG config = new BOL_CONFIG("CTS030", con);


            Dictionary <string, string> map = new Dictionary <string, string>()
            {
                { "${companyName}", COMPANY_NAME },
                { "${inputPerson}", INPUT_PERSON },
            };

            //prepare for mail header
            string template_base_name = "CTS030_ApprovalOfApplicationToSupplierDenied";
            string subject            = config.getStringValue("emailSubject.supplier.denied");
            string cc = config.getStringValue("emailAddress.cc");

            template = message;
            //read email template
            string body = "";

            try
            {
                string file_path = HttpContext.Current.Server.MapPath("~/Templates/Mail/" + template_base_name + ".txt");
                body = System.IO.File.ReadAllText(file_path);
            }
            catch (Exception)
            {
                return(false);
            }

            message.Clear();
            DataRow dtRow = message.NewRow();

            dtRow["SendMail"]       = INPUT_PERSON_EMAIL_ADDRESS;
            dtRow["EmailAddressCC"] = cc;
            dtRow["TemplateString"] = body.Replace("${companyName}", COMPANY_NAME).Replace("${inputPerson}", INPUT_PERSON);
            dtRow["SubjectString"]  = subject;
            message.Rows.Add(dtRow);
            template = message;
            return(true);
        }
        private bool PrepareAndSendMail(BOL_REQUEST_DETAIL oREQUEST_DETAIL, bool REQUEST, string GD_CODE)
        {
            //prepare for mail parameters
            BOL_CONFIG config             = new BOL_CONFIG("CTS020", con);
            string     toAddress          = REQUEST ? config.getStringValue("emailAddress.to.gdCheckReq") : config.getStringValue("emailAddress.to.gdChecked");
            string     ccAddress          = config.getStringValue("emailAddress.cc");
            string     template_base_name = REQUEST ? "CTS020_GdCheckReq" : "CTS020_GdChecked";
            string     subject            = REQUEST ? config.getStringValue("emailSubject.gdCheckReq") : config.getStringValue("emailSubject.gdChecked");

            subject = subject.Replace("${companyName}", oREQUEST_DETAIL.COMPANY_NAME);
            Dictionary <string, string> map;

            //prepare for mail mapping
            if (REQUEST)
            {
                map = new Dictionary <string, string>()
                {
                    { "${nmlCodeNissan}", oREQUEST_DETAIL.NML_CODE_NISSAN },
                    { "${nmlCodeNs}", oREQUEST_DETAIL.NML_CODE_NS },
                    { "${nmlCodeJatco}", oREQUEST_DETAIL.NML_CODE_JATCO },
                    { "${nmlCodeAk}", oREQUEST_DETAIL.NML_CODE_AK },
                    { "${nmlCodeNk}", oREQUEST_DETAIL.NML_CODE_NK },
                    { "${companyNoBox}", oREQUEST_DETAIL.COMPANY_NO_BOX },
                    { "${companyName}", oREQUEST_DETAIL.COMPANY_NAME },
                    { "${userId}", CURRENT_USER }
                };
            }
            else
            {
                map = new Dictionary <string, string>()
                {
                    { "${nmlCodeNissan}", oREQUEST_DETAIL.NML_CODE_NISSAN },
                    { "${nmlCodeNs}", oREQUEST_DETAIL.NML_CODE_NS },
                    { "${nmlCodeJatco}", oREQUEST_DETAIL.NML_CODE_JATCO },
                    { "${nmlCodeAk}", oREQUEST_DETAIL.NML_CODE_AK },
                    { "${nmlCodeNk}", oREQUEST_DETAIL.NML_CODE_NK },
                    { "${companyNoBox}", oREQUEST_DETAIL.COMPANY_NO_BOX },
                    { "${companyName}", oREQUEST_DETAIL.COMPANY_NAME },
                    { "${gdCode}", GD_CODE },
                    { "${userId}", CURRENT_USER }
                };
            }


            //read email template
            string file_path = HttpContext.Current.Server.MapPath("~/Templates/Mail/" + template_base_name + ".txt");
            string body      = System.IO.File.ReadAllText(file_path);

            //send mail
            return(Utility.Mail.sendMail(toAddress, ccAddress, subject, body, map));
        }
Example #4
0
        public byte[] GetTempFile(string FILENAME)
        {
            BOL_CONFIG config            = new BOL_CONFIG("SYSTEM", con);
            String     tempStorageFolder = config.getStringValue("temp.dir");

            return(GetFile(tempStorageFolder, FILENAME));
        }
        private bool SendMailToMaintenance(string COMPANY_NO_BOX, string REQ_TYPE, string COMPANY_NAME, string CHANGE_ITEMS, string REG_DEADLINE, out DataTable template)
        {
            DataTable message = new DataTable();

            message.Columns.Add("Error Message");
            message.Columns.Add("Message");
            message.Columns.Add("SendMail");
            message.Columns.Add("EmailAddressCC");
            message.Columns.Add("TemplateString");
            message.Columns.Add("SubjectString");

            //get config object for CTS030
            BOL_CONFIG config = new BOL_CONFIG("CTS030", con);


            Dictionary <string, string> map = new Dictionary <string, string>()
            {
                { "${reqType}", REQ_TYPE },
                { "${companyNoBox}", COMPANY_NO_BOX },
                { "${companyName}", COMPANY_NAME },
                { "${changedItem}", CHANGE_ITEMS },
                { "${systemRegistDeadline}", REG_DEADLINE },
                { "${userId}", CURRENT_USER },
            };

            //prepare for mail header
            string template_base_name = "CTS030_ApprovalOfApplication";
            string subject            = config.getStringValue("emailSubject.notice");
            string cc = config.getStringValue("emailAddress.cc");
            string to = config.getStringValue("emailAddress.to");

            template = message;
            //read email template
            string body = "";

            try
            {
                string file_path = HttpContext.Current.Server.MapPath("~/Templates/Mail/" + template_base_name + ".txt");
                body = System.IO.File.ReadAllText(file_path);
            }
            catch (Exception)
            {
                return(false);
            }
            //send mail
            return(Utility.Mail.sendMail(to, cc, subject, body, map));
        }
Example #6
0
        private bool PrepareAndSendMail(DataTable companyNoBoxData, string COMPANY_NO_BOX, string COMPANY_NAME, string CLIENT_CERTIFICATE_NO, string CLIENT_CERTIFICATE_SEND_EMAIL_ADDRESS, DateTime?EXPIRATION_DATE, string PASSWORD, int FY)
        {
            //get config object for CTS010
            BOL_CONFIG config = new BOL_CONFIG("CTS080", con);

            string documentFilePath = config.getStringValue("email.attached.doc.filePath");
            string path             = config.getStringValue("email.attached.client.filePath");
            string clientFilePath   = path + FY.ToString();

            string[] filePaths = { documentFilePath, clientFilePath };

            foreach (DataRow row in companyNoBoxData.Rows)
            {
                CLIENT_CERTIFICATE_NO += row["CLIENT_CERTIFICATE_NO"].ToString() + "\n";
            }


            Dictionary <string, string> map = new Dictionary <string, string>()
            {
                { "${companyName}", COMPANY_NAME },
                { "${clientCertificate}", CLIENT_CERTIFICATE_NO },
                { "${expirationDate}", EXPIRATION_DATE.ToString() },
                { "${password}", PASSWORD },
            };

            //prepare for mail header
            string template_base_name    = "CTS080_ClientCertificate";
            string subject               = config.getStringValue("emailSubject.client"); //come from config table
            String distributionAddressCC = config.getStringValue("emailAddress.cc");

            string file_path, body;

            try
            {
                //read email template
                file_path = HttpContext.Current.Server.MapPath("~/Templates/Mail/" + template_base_name + ".txt");
                body      = System.IO.File.ReadAllText(file_path);
            }
            catch (Exception)
            {
                return(false);
            }

            //send mail
            return(Utility.Mail.sendMail(CLIENT_CERTIFICATE_SEND_EMAIL_ADDRESS, distributionAddressCC, subject, body, map, filePaths));//NEED TO FILL CLIENT CERTIFICATE SEND MAIL ADDRESS
        }
Example #7
0
        private bool PrepareAndSendMail(BOL_REQUEST_ID oREQUEST_ID)
        {
            //get config object for CTS010
            BOL_CONFIG config = new BOL_CONFIG("CTS010", con);

            //prepare for mail mapping
            string expire_date = oREQUEST_ID.PASSWORD_EXPIRATION_DATE == null ? "" : ((DateTime)oREQUEST_ID.PASSWORD_EXPIRATION_DATE).ToString("yyyy/MM/dd HH:mm");

            Dictionary <string, string> map = new Dictionary <string, string>()
            {
                { "${companyName}", oREQUEST_ID.COMPANY_NAME },
                { "${aventailUserName}", config.getStringValue("email.aventail.user.name") },       // come from config table
                { "${aventailPassword}", config.getStringValue("email.aventail.user.password") },   // come from config table
                { "${companyNoBox}", oREQUEST_ID.COMPANY_NO_BOX },
                { "${password}", oREQUEST_ID.PASSWORD },
                { "${limitDate}", expire_date },
                { "${updUserId}", CURRENT_USER }
            };

            //prepare for mail header
            string template_base_name = "CTS010_CompanyCode";
            string subject            = config.getStringValue("emailSubject.login.info");
            string cc = config.getStringValue("emailAddress.cc");

            //read email template
            string body = "";

            try
            {
                string file_path = HttpContext.Current.Server.MapPath("~/Templates/Mail/" + template_base_name + ".txt");
                body = System.IO.File.ReadAllText(file_path);
            }
            catch (Exception)
            {
                return(false);
            }

            //send mail
            return(Utility.Mail.sendMail(oREQUEST_ID.EMAIL_ADDRESS, cc, subject, body, map));
        }
        private bool PrepareAndSendMail()
        {
            //get config object for CTS050
            BOL_CONFIG config = new BOL_CONFIG("CTS050", con);

            BOL_CONFIG system_conf = new BOL_CONFIG("SYSTEM", con);

            //prepare for mail mapping
            Dictionary <string, string> map = new Dictionary <string, string>()
            {
                { "${companyNoBox}", GetParameterByKey("COMPANY_NO_BOX") },
                { "${companyName}", GetParameterByKey("COMPANY_NAME") },
                { "${userId}", CURRENT_USER },
                { "${systemRegistDeadline}", GetParameterByKey("SYSTEM_REGISTER_DEADLINE") },
                { "${changedItem}", GetParameterByKey("AMIGO_COOPERATION_CHENGED_ITEMS") }
            };

            //prepare for mail header
            string template_base_name = "CTS050_SystemRegistrationReq";
            string to = system_conf.getStringValue("mail.send.to.l2");
            string cc = system_conf.getStringValue("mail.send.to.sales");
            string subject = config.getStringValue("emailSubject.systemRegistrationReq");
            string file_path, body;

            try
            {
                //read email template
                file_path = HttpContext.Current.Server.MapPath("~/Templates/Mail/" + template_base_name + ".txt");
                body      = System.IO.File.ReadAllText(file_path);
            }
            catch (Exception)
            {
                return(false);
            }

            //send mail
            return(Utility.Mail.sendMail(to, cc, subject, body, map));
        }
        private bool PrepareAndSendMail(USAGE_INFO_REGISTRATION oUSAGE_INFO_REG)
        {
            //get config object for CTS010
            BOL_CONFIG config       = new BOL_CONFIG("CTS070", con);
            BOL_CONFIG systemConfig = new BOL_CONFIG("SYSTEM", con);

            //prepare for mail mapping

            Dictionary <string, string> map = new Dictionary <string, string>()
            {
                { "${companyNoBox}", oUSAGE_INFO_REG.COMPNAY_NO_BOX },
                { "${ediAccount}", oUSAGE_INFO_REG.EDI_ACCOUNT },
                { "${userId}", CURRENT_USER }
            };

            //prepare for mail header
            string template_base_name = "CTS070_RegOfUsageInfo";
            string subject            = config.getStringValue("emailSubject.notice"); //come from config table

            string SendingAddress = systemConfig.getStringValue("mail.send.to.sales");
            string SendingAddressCCs = config.getStringValue("emailAddress.cc");
            string file_path, body;

            try
            {
                //read email template
                file_path = HttpContext.Current.Server.MapPath("~/Templates/Mail/" + template_base_name + ".txt");
                body      = System.IO.File.ReadAllText(file_path);
            }
            catch (Exception)
            {
                return(false);
            }

            //send mail
            return(Utility.Mail.sendMail(SendingAddress, SendingAddressCCs, subject, body, map));
        }
Example #10
0
        private static MailConfig GetMailConfig()
        {
            BOL_CONFIG oCONFIG = new BOL_CONFIG("SYSTEM", Properties.Settings.Default.MyConnection);
            MailConfig config  = new MailConfig();

            config.From    = oCONFIG.getStringValue("email.from");
            config.ReplyTo = oCONFIG.getStringValue("email.reply-to");
            config.Host    = oCONFIG.getStringValue("email.smtp.host");
            try
            {
                config.Port = int.Parse(oCONFIG.getStringValue("email.smtp.port"));
            }
            catch (Exception)
            {
                config.Port = 25;
            }
            try
            {
                config.StartTLS = bool.Parse(oCONFIG.getStringValue("email.smtp.starttls"));
            }
            catch (Exception)
            {
                config.StartTLS = false;
            }

            try
            {
                config.Auth = bool.Parse(oCONFIG.getStringValue("email.smtp.auth"));
            }
            catch (Exception)
            {
                config.Auth = false;
            }

            config.User     = oCONFIG.getStringValue("email.smtp.user");
            config.Password = oCONFIG.getStringValue("email.smtp.password");
            config.SSLTrust = oCONFIG.getStringValue("email.ssl.trust");

            return(config);
        }
Example #11
0
        public Response DeleteTempFile(string FILENAME)
        {
            BOL_CONFIG config            = new BOL_CONFIG("SYSTEM", con);
            String     tempStorageFolder = config.getStringValue("temp.dir");
            Response   response          = new Response();

            string[] filenames = FILENAME.Split(';');
            response.Status = 1;
            for (int i = 0; i < filenames.Length; i++)
            {
                try
                {
                    System.IO.File.Delete(tempStorageFolder + "/" + filenames[i]);
                }
                catch (Exception)
                {
                    response.Status = 0;
                }
            }

            return(response);
        }
        public MetaResponse SubmitOrderRegister(string list, System.Web.HttpPostedFile file)
        {
            using (TransactionScope dbTxn = new TransactionScope())
            {
                try
                {
                    string msg = "";
                    //set global PARAMETERS
                    PARAMETERS = Utility.Utility_Component.JsonToDt(list);

                    #region Update REQUEST_DETAIL
                    //cast to REQUEST DETAIL OBJECT
                    BOL_REQUEST_DETAIL oREQUEST_DETAIL = new BOL_REQUEST_DETAIL();
                    oREQUEST_DETAIL = Cast_REQUEST_DETAIL();
                    oREQUEST_DETAIL.SYSTEM_SETTING_STATUS = 1;

                    REQUEST_DETAIL DAL_REQUEST_DETAIL = new REQUEST_DETAIL(con);
                    DAL_REQUEST_DETAIL.Update(oREQUEST_DETAIL, CURRENT_DATETIME, CURRENT_USER, out msg);

                    //rollback if not success
                    if (!String.IsNullOrEmpty(msg))
                    {
                        dbTxn.Dispose();
                        return(ResponseUtility.ReturnFailMessage(response, timer, BodyMessage));
                    }
                    #endregion

                    #region Insert CUSTOMER MASTER
                    //COUNT IN CUSTOMER MASTER
                    string   COMPANY_NAME     = GetParameterByKey("COMPANY_NAME");
                    string   COMPANY_NO_BOX   = GetParameterByKey("COMPANY_NO_BOX");
                    string   CONTRACT_PLAN    = GetParameterByKey("CONTRACT_PLAN");
                    int      TRANSACTION_TYPE = int.Parse(GetParameterByKey("TRANSACTION_TYPE"));
                    int      REQ_SEQ          = int.Parse(GetParameterByKey("REQ_SEQ"));
                    int      REQ_TYPE         = int.Parse(GetParameterByKey("REQ_TYPE"));
                    DateTime START_USE_DATE   = DateTime.Parse(GetParameterByKey("START_USE_DATE"));

                    CUSTOMER_MASTER DAL_CUSTOMER_MASTER = new CUSTOMER_MASTER(con);
                    int             customer_count      = DAL_CUSTOMER_MASTER.getCustomerCountByKeys(COMPANY_NO_BOX, TRANSACTION_TYPE, START_USE_DATE, REQ_SEQ, out msg);

                    if (customer_count == 0) //if customer not found
                    {
                        DataTable           LatestCustomer   = new DataTable();
                        BOL_CUSTOMER_MASTER oCUSTOMER_MASTER = new BOL_CUSTOMER_MASTER();

                        if (REQ_TYPE == 2)
                        {
                            LatestCustomer = DAL_CUSTOMER_MASTER.GetTopCustomerByKeys(COMPANY_NO_BOX, TRANSACTION_TYPE, START_USE_DATE, out msg);

                            if (LatestCustomer.Rows.Count > 0)
                            {
                                oCUSTOMER_MASTER = Cast_CUSTOMER_MASTER(LatestCustomer.Rows[0]);
                                oCUSTOMER_MASTER.UPDATE_CONTENT = 3;
                            }
                            else //Need another message?
                            {
                                dbTxn.Dispose();
                                return(ResponseUtility.ReturnFailMessage(response, timer, BodyMessage));
                            }
                        }
                        if (REQ_TYPE == 1)
                        {
                            oCUSTOMER_MASTER.UPDATE_CONTENT = 1;
                        }
                        //insert info form screen
                        oCUSTOMER_MASTER.COMPANY_NO_BOX   = COMPANY_NO_BOX;
                        oCUSTOMER_MASTER.TRANSACTION_TYPE = TRANSACTION_TYPE;
                        oCUSTOMER_MASTER.EFFECTIVE_DATE   = START_USE_DATE;
                        oCUSTOMER_MASTER.REQ_SEQ          = REQ_SEQ;

                        DAL_CUSTOMER_MASTER.Insert(oCUSTOMER_MASTER, CURRENT_DATETIME, CURRENT_USER, out msg);

                        //rollback if not success
                        if (!String.IsNullOrEmpty(msg))
                        {
                            dbTxn.Dispose();
                            return(ResponseUtility.ReturnFailMessage(response, timer, BodyMessage));
                        }

                        #region Insert Browsing supplier CUSTOMER MASTER
                        BOL_CUSTOMER_MASTER oBROWSING_SUPPLIER = new BOL_CUSTOMER_MASTER();


                        if (CONTRACT_PLAN == "PRODUCT" && REQ_TYPE == 2)
                        {
                            DateTime NEW_EFFECTIVE_DATE = Convert.ToDateTime(DAL_CUSTOMER_MASTER.GetEffectiveDateForNewApplyingTime(oREQUEST_DETAIL.COMPANY_NO_BOX, TRANSACTION_TYPE, START_USE_DATE, out msg));
                            if ((NEW_EFFECTIVE_DATE.Month + NEW_EFFECTIVE_DATE.Day) != (START_USE_DATE.Month + START_USE_DATE.Day))
                            {
                                oBROWSING_SUPPLIER = Cast_CUSTOMER_MASTER(LatestCustomer.Rows[0]);
                                oBROWSING_SUPPLIER.COMPANY_NO_BOX   = COMPANY_NO_BOX;
                                oBROWSING_SUPPLIER.TRANSACTION_TYPE = TRANSACTION_TYPE;
                                oBROWSING_SUPPLIER.EFFECTIVE_DATE   = Convert.ToDateTime(START_USE_DATE.Year + "/" + NEW_EFFECTIVE_DATE.Month + "/" + NEW_EFFECTIVE_DATE.Day);
                                oBROWSING_SUPPLIER.UPDATE_CONTENT   = 3;
                                oBROWSING_SUPPLIER.REQ_SEQ          = REQ_SEQ;
                                DAL_CUSTOMER_MASTER.Insert(oBROWSING_SUPPLIER, CURRENT_DATETIME, CURRENT_USER, out msg);
                            }

                            //rollback if not success
                            if (!String.IsNullOrEmpty(msg))
                            {
                                dbTxn.Dispose();
                                return(ResponseUtility.ReturnFailMessage(response, timer, BodyMessage));
                            }
                        }
                        #endregion
                    }
                    #endregion

                    #region Insert REPORT_HISTORY
                    //Insert Report_History
                    BOL_REPORT_HISTORY oREPORT_HISTORY = new BOL_REPORT_HISTORY();
                    oREPORT_HISTORY.COMPANY_NO_BOX = COMPANY_NO_BOX;
                    oREPORT_HISTORY.REQ_SEQ        = REQ_SEQ;
                    oREPORT_HISTORY.REPORT_TYPE    = 4;

                    REPORT_HISTORY DAL_REPORT_HISTORY = new REPORT_HISTORY(con);
                    int            HISTORY_SEQ        = DAL_REPORT_HISTORY.GetReportHistorySEQ(COMPANY_NO_BOX, oREPORT_HISTORY.REPORT_TYPE, oREPORT_HISTORY.REQ_SEQ, out msg);

                    //rollback if not success
                    if (!String.IsNullOrEmpty(msg))
                    {
                        dbTxn.Dispose();
                        return(ResponseUtility.ReturnFailMessage(response, timer, BodyMessage));
                    }

                    oREPORT_HISTORY.REPORT_HISTORY_SEQ = HISTORY_SEQ;
                    oREPORT_HISTORY.OUTPUT_AT          = Utility_Component.dtColumnToDateTime(DateTime.Now.ToString());
                    oREPORT_HISTORY.OUTPUT_FILE        = COMPANY_NO_BOX + "-1-" + REQ_SEQ + "_注文書_" + COMPANY_NAME + "様.pdf";
                    oREPORT_HISTORY.EMAIL_ADDRESS      = null;

                    DAL_REPORT_HISTORY.Insert(oREPORT_HISTORY, CURRENT_DATETIME, CURRENT_USER, out msg);

                    //rollback if not success
                    if (!String.IsNullOrEmpty(msg))
                    {
                        dbTxn.Dispose();
                        return(ResponseUtility.MailSendingFail(response, timer, BodyMessage));
                    }
                    #endregion

                    #region Save File
                    //get destination path form config table
                    BOL_CONFIG config      = new BOL_CONFIG("CTS050", con);
                    string     destination = config.getStringValue("fileSavePath.purchaseOrder");
                    SaveFile(file, destination, oREPORT_HISTORY.OUTPUT_FILE, out msg);

                    if (!string.IsNullOrEmpty(msg))
                    {
                        dbTxn.Dispose();
                        response.Status = 0;
                        timer.Stop();
                        response.Meta.Duration = timer.Elapsed.TotalSeconds;
                        response.Message       = "File Path Not Found";
                        //add in body message
                        DataRow row = BodyMessage.NewRow();
                        row["Error Message"] = "File Path Not Found";
                        BodyMessage.Rows.Add(row);
                        response.Data = Utility_Component.DtToJSon(BodyMessage, "Message");
                        return(response);
                    }
                    #endregion

                    #region SendMail
                    bool mailSuccess = PrepareAndSendMail();

                    if (!mailSuccess)
                    {
                        dbTxn.Dispose();
                        return(ResponseUtility.MailSendingFail(response, timer, BodyMessage));
                    }
                    #endregion

                    //all process success
                    dbTxn.Complete();
                    response.Status  = 1;
                    response.Message = string.Format(Utility.Messages.Jimugo.I000ZZ016, "注文登録");
                    DataRow dr = BodyMessage.NewRow();
                    dr["Message"]        = response.Message;
                    dr["UPDATED_AT"]     = UPDATED_AT_DATETIME;
                    dr["UPDATED_AT_RAW"] = CURRENT_DATETIME;
                    BodyMessage.Rows.Add(dr);
                    response.Data = Utility_Component.DtToJSon(BodyMessage, "Message");
                    timer.Stop();
                    response.Meta.Duration = timer.Elapsed.TotalSeconds;
                    return(response);
                }
                catch (Exception ex)
                {
                    dbTxn.Dispose();
                    ResponseUtility.GetUnexpectedResponse(response, timer, ex);
                    //add in body message
                    DataRow dr = BodyMessage.NewRow();
                    dr["Error Message"] = "something went wrong.";
                    BodyMessage.Rows.Add(dr);
                    response.Data = Utility_Component.DtToJSon(BodyMessage, "Message");
                    return(response);
                }
            }
        }
        public MetaResponse getPDF(string COMPANY_NO_BOX, String COMPANY_NAME, DataTable dt, DataTable dt1, DataTable dt2, String fileName, int status)
        {
            #region Declare
            int    i = 10;
            string fullName;
            string emailAddress;
            string phoneNo;

            #endregion

            BOL_CONFIG conf = new BOL_CONFIG("CTS060", con);
            String     templateStorageFolder = conf.getStringValue("template.Path.CompletionNotification");

            string   file_path = HttpContext.Current.Server.MapPath("~/" + templateStorageFolder);
            FileInfo info      = new FileInfo(file_path);
            Workbook workbook  = new Workbook();
            //Load excel file
            workbook.LoadFromFile(file_path);
            Worksheet sheet = workbook.Worksheets[0];

            if (dt.Rows.Count > 0)
            {
                CONTRACT_PLAN   = dt.Rows[0]["CONTRACT_PLAN"] == null ? "" : dt.Rows[0]["CONTRACT_PLAN"].ToString();
                BOX_SIZE        = dt.Rows[0]["BOX_SIZE"] == null ? "" : dt.Rows[0]["BOX_SIZE"].ToString();
                PLAN_AMIGO_CAI  = dt.Rows[0]["PLAN_AMIGO_CAI"] == null ? "" : dt.Rows[0]["PLAN_AMIGO_CAI"].ToString();
                PLAN_AMIGO_BIZ  = dt.Rows[0]["PLAN_AMIGO_BIZ"] == null ? "" : dt.Rows[0]["PLAN_AMIGO_BIZ"].ToString();
                OP_FLAT         = dt.Rows[0]["OP_FLAT"] == null ? "" : dt.Rows[0]["OP_FLAT"].ToString();
                CONTRACT_CSP    = dt.Rows[0]["CONTRACT_CSP"] == null ? "" : dt.Rows[0]["CONTRACT_CSP"].ToString();
                OP_CLIENT       = dt.Rows[0]["OP_CLIENT"] == null ? "" : dt.Rows[0]["OP_CLIENT"].ToString();
                OP_BASIC_SEVICE = dt.Rows[0]["OP_SERVICE"] == null ? "" : dt.Rows[0]["OP_SERVICE"].ToString();
                SFTP            = dt.Rows[0]["A"] == null ? "" : dt.Rows[0]["A"].ToString();
                HTTPS           = dt.Rows[0]["B"] == null ? "" : dt.Rows[0]["B"].ToString();
                JNX_URL         = dt.Rows[0]["C"] == null ? "" : dt.Rows[0]["C"].ToString();
                IPSEC           = dt.Rows[0]["D"] == null ? "" : dt.Rows[0]["D"].ToString();
                TP = dt.Rows[0]["E"] == null ? "" : dt.Rows[0]["E"].ToString();
                AMIGO_COMPANY_NAME    = dt.Rows[0]["F"] == null ? "" : dt.Rows[0]["F"].ToString();
                INTERNET_URL          = dt.Rows[0]["G"] == null ? "" : dt.Rows[0]["G"].ToString();
                EDI_ACCOUNT           = dt.Rows[0]["EDI_ACCOUNT"] == null ? "" : dt.Rows[0]["EDI_ACCOUNT"].ToString();
                ADM_USER_ID           = dt.Rows[0]["ADM_USER_ID"] == null ? "" : dt.Rows[0]["ADM_USER_ID"].ToString();
                ADM_PASSWORD          = dt.Rows[0]["ADM_PASSWORD"] == null ? "" : dt.Rows[0]["ADM_PASSWORD"].ToString();
                ATDL_USER_ID          = dt.Rows[0]["ATDL_USER_ID"] == null ? "" : dt.Rows[0]["ATDL_USER_ID"].ToString();
                ATDL_USER_PASSWORD    = dt.Rows[0]["ATDL_PASSWORD"] == null ? "" : dt.Rows[0]["ATDL_PASSWORD"].ToString();
                SSHGW_USER_ID         = dt.Rows[0]["SSHGW_USER_ID"] == null ? "" : dt.Rows[0]["SSHGW_USER_ID"].ToString();
                SSHGW_PUBLIC_KEY      = dt.Rows[0]["SSHGW_PUBLIC_KEY"] == null ? "" : dt.Rows[0]["SSHGW_PUBLIC_KEY"].ToString();
                CAI_SERVER_IP_ADDRESS = dt.Rows[0]["CAI_SERVER_IP_ADDRESS"] == null ? "" : dt.Rows[0]["CAI_SERVER_IP_ADDRESS"].ToString();
                SSH_USER              = dt.Rows[0]["K"] == null ? "" : dt.Rows[0]["K"].ToString();
                PRIVATE_KEY           = dt.Rows[0]["L"] == null ? "" : dt.Rows[0]["L"].ToString();
                AMIGO_IP              = dt.Rows[0]["NETWORK"] == null ? "" : dt.Rows[0]["NETWORK"].ToString();
                PASSWORD              = dt.Rows[0]["PASSWORD"] == null ? "" : dt.Rows[0]["PASSWORD"].ToString();
                CLIENT_CERTIFICATE_NO = dt.Rows[0]["CLIENT_CERTIFICATE_NO"] == null ? "" : dt.Rows[0]["CLIENT_CERTIFICATE_NO"].ToString();
                SUPPORT_NAME          = dt.Rows[0]["H"] == null ? "" : dt.Rows[0]["H"].ToString();
                SUPPORT_MAIL_ADDRESS  = dt.Rows[0]["I"] == null ? "" : dt.Rows[0]["I"].ToString();
                SUPPORT_PHONE_NUMBER  = dt.Rows[0]["J"] == null ? "" : dt.Rows[0]["J"].ToString();
            }

            sheet.Range["F3"].Text = COMPANY_NAME;
            sheet.Range["F4"].Text = CONTRACT_PLAN;
            sheet.Range["B7"].Text = BOX_SIZE;
            sheet.Range["E7"].Text = PLAN_AMIGO_CAI;
            sheet.Range["H7"].Text = PLAN_AMIGO_BIZ;
            sheet.Range["K7"].Text = OP_FLAT;
            sheet.Range["N7"].Text = CONTRACT_CSP;
            sheet.Range["Q7"].Text = OP_CLIENT;
            sheet.Range["T7"].Text = OP_BASIC_SEVICE;

            int totalRows = dt1.Rows.Count;
            int extraRows = totalRows - 10 < 0 ? 0 : totalRows - 10;


            if (extraRows > 0)
            {
                int firstColumn = 2;
                int lastColumn  = 24;
                int firstRow    = 11;
                int lastRow     = 11 + extraRows;
                //rows count
                int copyRows = lastRow - firstRow;

                //insert rows count
                sheet.InsertRow(firstRow + 1, copyRows);
                for (int row = 0; row < extraRows; row++)
                {
                    CellRange originDataRang = sheet.Range[firstRow, firstColumn, firstRow, lastColumn];
                    CellRange targetDataRang = sheet.Range[firstRow + row + 1, firstColumn, firstRow + row + 1, lastColumn];
                    sheet.Copy(originDataRang, targetDataRang, true);
                }
            }
            #region ClientCertificateNo Add
            string[] clientCertificate = CLIENT_CERTIFICATE_NO.Split(',');
            int      extraCertificateRowCount;
            if ((clientCertificate.Length) % 4 == 0)
            {
                extraCertificateRowCount = (clientCertificate.Length / 4) - 1;
            }
            else
            {
                extraCertificateRowCount = (clientCertificate.Length / 4);
            }

            if (extraCertificateRowCount > 0)
            {
                int firstRow = 53 + extraRows;
                int lastRow  = 53 + extraRows + extraCertificateRowCount;
                int copyRows = lastRow - firstRow;

                //insert rows count
                sheet.InsertRow(firstRow + 1, copyRows);
            }


            int b = 0;
            for (int x = 0; x < (extraCertificateRowCount + 1); x++)
            {
                string certificates = "";
                for (int a = 0; a < 4; a++)
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(certificates))
                        {
                            certificates = certificates + ", " + clientCertificate[b];
                        }
                        else
                        {
                            certificates = clientCertificate[b];
                        }
                        b++;
                    }
                    catch (Exception)
                    {
                    }
                }
                sheet.Range["G" + (53 + extraRows + x)].Text = certificates;
            }
            #endregion

            foreach (DataRow row in dt1.Rows)
            {
                fullName     = "B" + i;
                emailAddress = "F" + i;
                phoneNo      = "U" + i;
                sheet.Range["U" + i + ":" + "X" + i].Merge();
                sheet.Range[fullName].Text     = row["SERVICE_CONTACT_NAME"].ToString();
                sheet.Range[emailAddress].Text = row["SERVICE_MAIL_ADDRESS"].ToString();
                sheet.Range[phoneNo].Text      = row["SERVICE_PHONE_NUMBER"].ToString();
                i++;
            }

            sheet.Range["G" + (33 + extraRows)].Text = COMPANY_NO_BOX == null ? "" : COMPANY_NO_BOX.Substring(0, 7);
            sheet.Range["G" + (34 + extraRows)].Text = EDI_ACCOUNT;
            sheet.Range["H" + (35 + extraRows)].Text = ADM_USER_ID;
            sheet.Range["Q" + (35 + extraRows)].Text = ADM_PASSWORD;
            sheet.Range["H" + (36 + extraRows)].Text = ATDL_USER_ID;
            sheet.Range["Q" + (36 + extraRows)].Text = ATDL_USER_PASSWORD;

            sheet.Range["G" + (39 + extraRows)].Text = SSHGW_USER_ID;
            sheet.Range["G" + (40 + extraRows)].Text = SSHGW_PUBLIC_KEY;
            sheet.Range["G" + (41 + extraRows)].Text = CAI_SERVER_IP_ADDRESS;

            int z = 42 + extraRows;
            foreach (DataRow row in dt2.Rows)
            {
                sheet.Range["G" + z].Text = row["ERROR_MAIL_ADDRESS"].ToString();
                z++;
            }

            sheet.Range["G" + (47 + extraRows)].Text = SSH_USER;
            sheet.Range["G" + (48 + extraRows)].Text = PRIVATE_KEY;
            sheet.Range["G" + (49 + extraRows)].Text = AMIGO_IP;

            sheet.Range["G" + (52 + extraRows)].Text = PASSWORD;

            sheet.Range["B" + (56 + extraRows + extraCertificateRowCount)].Text = SUPPORT_NAME;
            sheet.Range["G" + (56 + extraRows + extraCertificateRowCount)].Text = SUPPORT_MAIL_ADDRESS;
            sheet.Range["P" + (56 + extraRows + extraCertificateRowCount)].Text = SUPPORT_PHONE_NUMBER;

            sheet.Range["G" + (22 + extraRows)].Text = SFTP;
            sheet.Range["G" + (23 + extraRows)].Text = HTTPS;
            sheet.Range["G" + (25 + extraRows)].Text = JNX_URL;
            sheet.Range["G" + (26 + extraRows)].Text = IPSEC;
            sheet.Range["G" + (27 + extraRows)].Text = TP;
            sheet.Range["G" + (28 + extraRows)].Text = AMIGO_COMPANY_NAME;
            sheet.Range["G" + (30 + extraRows)].Text = INTERNET_URL;

            //footer color
            sheet.PageSetup.RightFooter = sheet.PageSetup.RightFooter.Replace("K00-034", "KC0C0C0");

            //page break
            if (extraCertificateRowCount + extraRows < 0)
            {
                sheet.PageSetup.IsFitToPage = false;
            }

            BOL_CONFIG config            = new BOL_CONFIG("SYSTEM", con);
            String     tempStorageFolder = config.getStringValue("temp.dir");
            string     savePath          = tempStorageFolder + "/" + fileName;

            //Save excel file to pdf file.
            workbook.SaveToFile(savePath, Spire.Xls.FileFormat.PDF);

            DataTable result = new DataTable();
            result.Clear();
            result.Columns.Add("FILENAME");
            result.Columns.Add("MessageCode");
            DataRow dr = result.NewRow();
            dr["FILENAME"]    = fileName;
            dr["MessageCode"] = status;
            result.Rows.Add(dr);

            response.Data   = Utility.Utility_Component.DtToJSon(result, "pdfData");
            response.Status = 1;
            return(response);
        }
        public MetaResponse SendMailCreate(string list)  //add more parameter
        {
            #region Parameters
            //message for pop up
            DataTable messagecode = new DataTable();
            messagecode.Columns.Add("Error Message");

            DataTable dtParameter = Utility.Utility_Component.JsonToDt(list);

            COMPANY_NO_BOX = dtParameter.Rows[0]["COMPANY_NO_BOX"].ToString();
            REQ_SEQ        = Convert.ToInt32(dtParameter.Rows[0]["REQ_SEQ"].ToString());
            QUOTATION_DATE = dtParameter.Rows[0]["QUOTATION_DATE"].ToString();
            ORDER_DATE     = dtParameter.Rows[0]["ORDER_DATE"].ToString();
            COMPLETION_NOTIFICATION_DATE = dtParameter.Rows[0]["COMPLETION_NOTIFICATION_DATE"].ToString();
            COMPANY_NAME  = dtParameter.Rows[0]["COMPANY_NAME"].ToString();
            EMAIL_ADDRESS = dtParameter.Rows[0]["EMAIL_ADDRESS"].ToString();
            EDI_ACCOUNT   = dtParameter.Rows[0]["EDI_ACCOUNT"].ToString();
            FILENAME      = dtParameter.Rows[0]["FILENAME"].ToString();
            #endregion
            string msg = "";
            try
            {
                using (TransactionScope dbtnx = new TransactionScope())
                {
                    #region Update RequestDetail For CompleteNotificationSending
                    DAL_REQUEST_DETAIL.SendMailUpdate(TEMP.ToString("yyyy/MM/dd"), COMPANY_NO_BOX, REQ_SEQ, CURRENT_DATETIME, CURRENT_USER, out msg);
                    #endregion

                    if (String.IsNullOrEmpty(msg))
                    {
                        #region InsertReportHistroy
                        DateTime now = DateTime.Now;

                        string outputFile = COMPANY_NO_BOX + "-" + "3" + "-" + REQ_SEQ.ToString().PadLeft(2, '0') + "_完了通知書(" + EDI_ACCOUNT.Replace("@", "") + ")_" + COMPANY_NAME + "様" + ".pdf";
                        string msgText    = outputFile;

                        int REPORTHISTORY_SEQ = DAL_REPORT_HISTORY.GetReportHistorySEQ(COMPANY_NO_BOX, 5, REQ_SEQ, out msg);

                        if (string.IsNullOrEmpty(msg))
                        {
                            DAL_REPORT_HISTORY.InsertNotiSending(COMPANY_NO_BOX, REQ_SEQ, REPORTHISTORY_SEQ, outputFile, EMAIL_ADDRESS, CURRENT_USER, UPDATED_AT_DATETIME, CURRENT_DATETIME, out msg);

                            if (string.IsNullOrEmpty(msg))
                            {
                                BOL_CONFIG config  = new BOL_CONFIG("CTS060", con);
                                BOL_CONFIG config1 = new BOL_CONFIG("SYSTEM", con);

                                string temPath = config1.getStringValue("temp.dir");
                                temPath = temPath + "/" + FILENAME;

                                string pdfSavePath = config.getStringValue("fileSavePath.completionNotice");
                                pdfSavePath = pdfSavePath + "/" + outputFile;

                                //CopyAndMove File
                                int res = MovePdfFile(temPath, pdfSavePath);

                                if (res == 1)
                                {
                                    //BOL_CONFIG config1 = new BOL_CONFIG("SYSTEM", con);
                                    string zipStorageFolder = config1.getStringValue("temp.dir") + "/" + outputFile.Replace(".pdf", ".zi_");

                                    string PASSWORD = config.getStringValue("password.Attachment");

                                    //Create ZipFile With Password
                                    bool zipgenerate = ZipGenerator(temPath, PASSWORD, zipStorageFolder, outputFile);

                                    if (zipgenerate)
                                    {
                                        #region SendMail
                                        String emailAddressCC = config.getStringValue("emailAddress.cc");
                                        string tempString     = PrepareAndSendMail(COMPANY_NAME, PASSWORD);

                                        if (tempString != null)
                                        {
                                            string    subjectString = config.getStringValue("emailSubject.notice");
                                            DataTable result        = new DataTable();
                                            result.Clear();
                                            result.Columns.Add("ZipFileName");
                                            result.Columns.Add("EmailAddressCC");
                                            result.Columns.Add("TemplateString");
                                            result.Columns.Add("SubjectString");
                                            result.Columns.Add("COMPLETE_NOTIFICATION_DATE");
                                            result.Columns.Add("UPDATED_AT");
                                            result.Columns.Add("UPDATED_AT_RAW");

                                            DataRow dtRow = result.NewRow();
                                            dtRow["ZipFileName"]                = outputFile.Replace(".pdf", ".zi_");
                                            dtRow["EmailAddressCC"]             = emailAddressCC;
                                            dtRow["TemplateString"]             = tempString;
                                            dtRow["SubjectString"]              = subjectString.Replace("${companyName}", COMPANY_NAME);
                                            dtRow["COMPLETE_NOTIFICATION_DATE"] = TEMP.ToString("yyyy/MM/dd");
                                            dtRow["UPDATED_AT"]     = UPDATED_AT_DATETIME;
                                            dtRow["UPDATED_AT_RAW"] = CURRENT_DATETIME;

                                            result.Rows.Add(dtRow);
                                            dbtnx.Complete();
                                            response.Data   = Utility.Utility_Component.DtToJSon(result, "pdfData");
                                            response.Status = 1;
                                            return(response);
                                        }
                                        else
                                        {
                                            return(ResponseUtility.ReturnFailMessage(response, timer, messagecode, Utility.Messages.Jimugo.E000WB018));
                                        }
                                        #endregion
                                    }
                                    else
                                    {
                                        return(ResponseUtility.ReturnFailMessage(response, timer, messagecode, Utility.Messages.Jimugo.E000WB007));
                                    }
                                }
                                else
                                {
                                    return(ResponseUtility.ReturnFailMessage(response, timer, messagecode, String.Format(Utility.Messages.Jimugo.E000WB001, msgText)));
                                }
                            }
                            else
                            {
                                return(ResponseUtility.ReturnFailMessage(response, timer, messagecode, Utility.Messages.Jimugo.E000WB003));
                            }
                        }
                        else
                        {
                            return(ResponseUtility.ReturnFailMessage(response, timer, messagecode, Utility.Messages.Jimugo.E000WB002));
                        }

                        #endregion
                    }
                    else
                    {
                        return(ResponseUtility.ReturnFailMessage(response, timer, messagecode, Utility.Messages.Jimugo.E000WB002));
                    }
                }
            }
            catch (Exception ex)
            {
                return(ResponseUtility.GetUnexpectedResponse(response, timer, ex));
            }
        }