Beispiel #1
0
        private void HandleModify(BOL_REQUEST_ID oREQUEST_ID, DataRow row)
        {
            string     strMsg         = "";
            REQUEST_ID DAL_REQUEST_ID = new REQUEST_ID(con);

            if (!DAL_REQUEST_ID.IsAlreadyUpdated(oREQUEST_ID, out strMsg)) // If updated_at is not already modified
            {
                //update the record
                oREQUEST_ID.GD = string.IsNullOrEmpty(oREQUEST_ID.GD_CODE) ? 0 : 2;
                oREQUEST_ID.PASSWORD_EXPIRATION_DATE = oREQUEST_ID.DISABLED_FLG == "*" ? null : oREQUEST_ID.PASSWORD_EXPIRATION_DATE;
                oREQUEST_ID.PASSWORD_SET_DATE        = oREQUEST_ID.DISABLED_FLG == "*" ? null : oREQUEST_ID.PASSWORD_SET_DATE;
                DAL_REQUEST_ID.Update(oREQUEST_ID, CURRENT_DATETIME, CURRENT_USER, out strMsg);
            }
            else
            {
                ResponseUtility.ReturnFailMessage(row);
                return;
            }

            //return message and MK value
            if (String.IsNullOrEmpty(strMsg)) //success
            {
                ResponseUtility.ReturnSuccessMessage(row, UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER);
            }
            else //failed
            {
                ResponseUtility.MailSendingFail(row);
            }
        }
Beispiel #2
0
        public MetaResponse SendMail(string CompanyCodeList)
        {
            try
            {
                string    strMsg  = "";
                DataTable dgvList = Utility.Utility_Component.JsonToDt(CompanyCodeList);

                for (int i = 0; i < dgvList.Rows.Count; i++)
                {
                    //cast to REQUEST_ID object
                    BOL_REQUEST_ID oREQUEST_ID = new BOL_REQUEST_ID();
                    oREQUEST_ID = Cast_REQUEST_ID(dgvList.Rows[i]);

                    REQUEST_ID DAL_REQUEST_ID = new REQUEST_ID(con);

                    if (!DAL_REQUEST_ID.IsAlreadyUpdated(oREQUEST_ID, out strMsg)) // If updated_at is not already modified
                    {
                        bool mailSuccess = PrepareAndSendMail(oREQUEST_ID);

                        if (mailSuccess)
                        {
                            //update email sent date
                            oREQUEST_ID.EMAIL_SEND_DATE = TEMP;
                            DAL_REQUEST_ID.UpdateMailDate(oREQUEST_ID, CURRENT_DATETIME, CURRENT_USER, out strMsg);
                            if (String.IsNullOrEmpty(strMsg))
                            {
                                //success message
                                dgvList.Rows[i]["EMAIL_SEND_DATE"] = UPDATED_AT_DATETIME;
                                ResponseUtility.ReturnMailSuccessMessage(dgvList.Rows[i], UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER);
                            }
                            else
                            {
                                //fail message
                                ResponseUtility.MailSendingFail(dgvList.Rows[i]);
                            }
                        }
                        else
                        {
                            ResponseUtility.MailSendingFail(dgvList.Rows[i]);
                        }
                    }
                    else
                    {
                        ResponseUtility.ReturnFailMessage(dgvList.Rows[i]);
                    }
                }
                response.Status = 1;
                response.Data   = Utility.Utility_Component.DtToJSon(dgvList, "Mail status");;
                timer.Stop();
                response.Meta.Duration = timer.Elapsed.TotalSeconds;
                return(response);
            }
            catch (Exception ex)
            {
                return(ResponseUtility.GetUnexpectedResponse(response, timer, ex));
            }
        }
        public MetaResponse GDConfirmRequest(string list)
        {
            try
            {
                string    msg     = "";
                DataTable dgvList = Utility.Utility_Component.JsonToDt(list);

                for (int i = 0; i < dgvList.Rows.Count; i++)
                {
                    BOL_REQUEST_DETAIL oREQUEST_DETAIL = new BOL_REQUEST_DETAIL();
                    BOL_REQUEST_ID     oREQUEST_ID     = new BOL_REQUEST_ID();

                    //cast into objects
                    oREQUEST_ID     = Cast_REQUEST_ID(dgvList.Rows[i]);
                    oREQUEST_DETAIL = Cast_REQUEST_DETAIL(dgvList.Rows[i]);

                    //send mail
                    bool mailSuccess = PrepareAndSendMail(oREQUEST_DETAIL, true, null);

                    if (mailSuccess)
                    {
                        REQUEST_ID DAL_REQUEST_ID = new REQUEST_ID(con);
                        if (!DAL_REQUEST_ID.IsAlreadyUpdated(oREQUEST_ID, out msg))
                        {
                            //set GD to 1
                            oREQUEST_ID.GD = 1;

                            //insert the record
                            DAL_REQUEST_ID.GDConfirmationRequestUpdate(oREQUEST_ID, CURRENT_DATETIME, CURRENT_USER, out msg);

                            //return message and MK value
                            if (String.IsNullOrEmpty(msg)) //success
                            {
                                ResponseUtility.ReturnSuccessMessage(dgvList.Rows[i], UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER, string.Format(Utility.Messages.Jimugo.I000ZZ016, "GD確認依頼"));
                            }
                            else //failed
                            {
                                ResponseUtility.ReturnFailMessage(dgvList.Rows[i]);
                            }
                        }
                    }
                    else
                    {
                        ResponseUtility.MailSendingFail(dgvList.Rows[i]);
                    }
                }
                response.Status = 1;
                response.Data   = Utility.Utility_Component.DtToJSon(dgvList, "GD Confirm Request");;
                timer.Stop();
                response.Meta.Duration = timer.Elapsed.TotalSeconds;
                return(response);
            }
            catch (Exception ex)
            {
                return(ResponseUtility.GetUnexpectedResponse(response, timer, ex));
            }
        }
        public MetaResponse GDConfirmComplete(string list)
        {
            try
            {
                string    msg     = "";
                DataTable dgvList = Utility.Utility_Component.JsonToDt(list);

                for (int i = 0; i < dgvList.Rows.Count; i++)
                {
                    //cast into objects
                    BOL_REQUEST_DETAIL oREQUEST_DETAIL = new BOL_REQUEST_DETAIL();
                    BOL_REQUEST_ID     oREQUEST_ID     = new BOL_REQUEST_ID();
                    oREQUEST_DETAIL = Cast_REQUEST_DETAIL(dgvList.Rows[i]);
                    oREQUEST_ID     = Cast_REQUEST_ID(dgvList.Rows[i]);

                    //get GD code By COMPANY NO BOX
                    REQUEST_ID DAL_REQUEST_ID = new REQUEST_ID(con);
                    string     GD_CODE        = DAL_REQUEST_ID.GetGDCode(oREQUEST_ID.COMPANY_NO_BOX.ToString(), out msg);

                    if (string.IsNullOrEmpty(msg))
                    {
                        #region Send Mail
                        bool mailSuccess = PrepareAndSendMail(oREQUEST_DETAIL, false, GD_CODE);

                        if (mailSuccess) //success
                        {
                            ResponseUtility.ReturnSuccessMessage(dgvList.Rows[i], UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER, string.Format(Utility.Messages.Jimugo.I000ZZ016, "GD確認完了"));
                        }
                        else //failed
                        {
                            ResponseUtility.MailSendingFail(dgvList.Rows[i]);
                        }
                        #endregion
                    }
                    else
                    {
                        ResponseUtility.ReturnFailMessage(dgvList.Rows[i]);
                    }
                }
                response.Status = 1;
                response.Data   = Utility.Utility_Component.DtToJSon(dgvList, "GD Confirmation Complete");;
                timer.Stop();
                response.Meta.Duration = timer.Elapsed.TotalSeconds;
                return(response);
            }
            catch (Exception ex)
            {
                return(ResponseUtility.GetUnexpectedResponse(response, timer, ex));
            }
        }
        public MetaResponse SettingCompleteMail(string UsageInfoRegList)
        {
            try
            {
                string    msg     = "";
                DataTable dgvList = Utility.Utility_Component.JsonToDt(UsageInfoRegList);

                for (int i = 0; i < dgvList.Rows.Count; i++)
                {
                    USAGE_INFO_REGISTRATION oUSAGE_INFO_REG = new USAGE_INFO_REGISTRATION();
                    oUSAGE_INFO_REG = CAST_TO_USAGE_INFO_REGISTRATION(dgvList.Rows[i]);

                    REQUEST_DETAIL DAL_REQUEST_DETAIL = new REQUEST_DETAIL(con);
                    DAL_REQUEST_DETAIL.UpdateSystemSettingStatus(2, oUSAGE_INFO_REG.COMPNAY_NO_BOX, CURRENT_USER, CURRENT_DATETIME, out msg);

                    if (string.IsNullOrEmpty(msg))
                    {
                        bool mailSuccess = PrepareAndSendMail(oUSAGE_INFO_REG);

                        if (mailSuccess)
                        {
                            dgvList.Rows[i]["SYSTEM_SETTING_STATUS"] = 2;
                            ResponseUtility.ReturnMailSuccessMessage(dgvList.Rows[i], UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER);
                        }
                        else
                        {
                            ResponseUtility.MailSendingFail(dgvList.Rows[i]);
                        }
                    }
                    else
                    {
                        ResponseUtility.MailSendingFail(dgvList.Rows[i]);
                    }
                }

                response.Data = Utility.Utility_Component.DtToJSon(dgvList, "Mail status");;
                timer.Stop();
                response.Meta.Duration = timer.Elapsed.TotalSeconds;
                return(response);
            }
            catch (Exception ex)
            {
                return(ResponseUtility.GetUnexpectedResponse(response, timer, ex));
            }
        }
        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);
                }
            }
        }
Beispiel #7
0
        public MetaResponse SendMail(string ClientCertificateList)
        {
            try
            {
                string    strMsg          = "";
                bool      mailSuccess     = false;
                ArrayList company_no_boxs = new ArrayList();

                DataTable dgvList = Utility.Utility_Component.JsonToDt(ClientCertificateList);

                List <string> l_SentMail = new List <string>();

                for (int i = 0; i < dgvList.Rows.Count; i++)
                {
                    DataRow dr = dgvList.Rows[i];
                    string  l_COMPANY_NO_BOX = dr["COMPANY_NO_BOX"].ToString();

                    var certificate_list = dgvList.AsEnumerable().Where(row => row.Field <string>("COMPANY_NO_BOX") == l_COMPANY_NO_BOX).Select(s => s.Field <string>("CLIENT_CERTIFICATE_NO")).ToArray();


                    BOL_CLIENT_CERTIFICATE oCLIENT_CERTIFICATE = new BOL_CLIENT_CERTIFICATE();

                    oCLIENT_CERTIFICATE = Cast_CLIENT_CERTIFICATE(dr);  //check method
                    BOL_REQUEST_DETAIL oREQUEST_DETAIL = new BOL_REQUEST_DETAIL();
                    oREQUEST_DETAIL = Cast_REQUEST_DETAIL(dr);


                    CLIENT_CERTIFICATE DAL_CLIENT_CERTIFICATE = new CLIENT_CERTIFICATE(con);

                    if (l_SentMail.Where(x => x == l_COMPANY_NO_BOX).ToList().Count <= 0)
                    {
                        l_SentMail.Add(l_COMPANY_NO_BOX);

                        mailSuccess = PrepareAndSendMail(certificate_list, oREQUEST_DETAIL.COMPANY_NAME, oREQUEST_DETAIL.CLIENT_CERTIFICATE_SEND_EMAIL_ADDRESS, oCLIENT_CERTIFICATE.EXPIRATION_DATE, oCLIENT_CERTIFICATE.PASSWORD, oCLIENT_CERTIFICATE.FY);

                        if (mailSuccess)
                        {
                            //update email sent date
                            DAL_CLIENT_CERTIFICATE.EmailButtonUpdate(oCLIENT_CERTIFICATE, UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER, out strMsg);

                            if (String.IsNullOrEmpty(strMsg))
                            {
                                //success
                                dr["DISTRIBUTION_DATE"] = UPDATED_AT_DATETIME;
                                ResponseUtility.ReturnMailSuccessMessage(dr, UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER);
                            }
                            else
                            {
                                //already use in another process
                                ResponseUtility.ReturnFailMessage(dr);
                            }
                        }
                        else
                        {
                            //fail message
                            ResponseUtility.MailSendingFail(dr);
                        }
                    }
                    else
                    {
                        //update email sent date
                        DAL_CLIENT_CERTIFICATE.EmailButtonUpdate(oCLIENT_CERTIFICATE, UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER, out strMsg);

                        if (String.IsNullOrEmpty(strMsg))
                        {
                            //success
                            dr["DISTRIBUTION_DATE"] = UPDATED_AT_DATETIME;
                            ResponseUtility.ReturnMailSuccessMessage(dr, UPDATED_AT_DATETIME, CURRENT_DATETIME, CURRENT_USER);
                        }
                        else
                        {
                            //already use in another process
                            ResponseUtility.ReturnFailMessage(dr);
                        }
                    }
                }

                response.Data = Utility.Utility_Component.DtToJSon(dgvList, "Mail status");;
                timer.Stop();
                response.Meta.Duration = timer.Elapsed.TotalSeconds;
                return(response);
            }
            catch (Exception ex)
            {
                return(ResponseUtility.GetUnexpectedResponse(response, timer, ex));
            }
        }