Exemplo n.º 1
0
        public MetaResponse GeneratePassword()
        {
            try
            {
                //generate raw password
                string raw_password = Crypto.GenerateRawPassword();

                #region PreparePasswordResultTable
                DataTable dt = new DataTable();
                dt.Columns.Add("PASSWORD");
                dt.Columns.Add("PASSWORD_SET_DATE");
                dt.Columns.Add("PASSWORD_EXPIRATION_DATE");
                #endregion

                //get expire date from config tbl
                BOL_CONFIG config = new BOL_CONFIG("CTS010", con);

                //add row and data
                DateTime startDate = DateTime.Now;
                DateTime stopDate  = DateTime.Today.AddDays(config.getIntValue("password.days.add") + 1).AddTicks(-1);

                DataRow dr = dt.NewRow();
                dr["PASSWORD"]          = raw_password;
                dr["PASSWORD_SET_DATE"] = startDate.ToString("yyyy/MM/dd HH:mm");

                //get from config table
                dr["PASSWORD_EXPIRATION_DATE"] = stopDate.ToString("yyyy/MM/dd HH:mm");
                dt.Rows.Add(dr);

                response.Data = Utility.Utility_Component.DtToJSon(dt, "Password Generate");

                //return response
                response.Status = 1;
                timer.Stop();
                response.Meta.Duration = timer.Elapsed.TotalSeconds;
                return(response);
            }
            catch (Exception ex)
            {
                return(ResponseUtility.GetUnexpectedResponse(response, timer, ex));
            }
        }
        public MetaResponse NotiSendingPreview(string COMPANY_NAME, string COMPANY_NO_BOX, string REQ_SEQ, string EDI_ACCOUNT, string authHeader)
        {
            try
            {
                //int status;
                //message for pop up
                DataTable messagecode = new DataTable();
                messagecode.Columns.Add("Message");
                DataRow dr = messagecode.NewRow();

                string strMessage = "";
                //get config object for CTS060
                BOL_CONFIG config = new BOL_CONFIG("SYSTEM", con);
                int        FY     = config.getIntValue("client.certificate.FY");
                status = 1;
                int clientCertificateDiff = DAL_REQUEST_DETAIL.GetClientCertificateDiff(COMPANY_NO_BOX, REQ_SEQ, FY.ToString(), out strMessage);

                using (TransactionScope dbTxn = new TransactionScope())
                {
                    for (int i = 1; i <= clientCertificateDiff; i++)
                    {
                        #region SearchClientCertificateNo
                        string clientCertificateNo = DAL_CLIENT_CERTIFICATE.GetClientCertificateNo(FY.ToString(), out strMessage);
                        if (!string.IsNullOrEmpty(clientCertificateNo))
                        {
                            #region UpdateWithClientCertificateNo
                            status = UpdateWithClientCertificateNO(clientCertificateNo, COMPANY_NO_BOX, CURRENT_USER, strMessage);
                            #endregion
                            if (status == 0)
                            {
                                dbTxn.Dispose();
                                response.Status  = 0;
                                response.Message = Utility.Messages.Jimugo.E000WB005;
                                dr["Message"]    = Utility.Messages.Jimugo.E000WB005;
                                messagecode.Rows.Add(dr);
                                response.Data = Utility_Component.DtToJSon(messagecode, "Message");
                                return(response);
                            }
                        }
                        else
                        {
                            response.Status  = 0;
                            response.Message = Utility.Messages.Jimugo.E000WB004;
                            dr["Message"]    = Utility.Messages.Jimugo.E000WB004;
                            messagecode.Rows.Add(dr);
                            response.Data = Utility_Component.DtToJSon(messagecode, "Message");
                            return(response);
                        }
                        #endregion
                    }
                    if (status == 2)
                    {
                        dbTxn.Complete();
                    }
                }

                if (status == 1 || status == 2)
                {
                    #region GetPDFData

                    DataTable dtPDFData = DAL_REQUEST_DETAIL.GetPDFData(COMPANY_NO_BOX, REQ_SEQ, out strMessage);

                    DataTable dtPDFData1 = DAL_REQ_ADDRESS.GetPDFData1(COMPANY_NO_BOX, REQ_SEQ, out strMessage);

                    DataTable dtPDFData2 = DAL_REQ_ADDRESS.GetPDFData2(COMPANY_NO_BOX, REQ_SEQ, out strMessage);

                    string req_seq = REQ_SEQ.Length != 1 ? REQ_SEQ :  REQ_SEQ.ToString().PadLeft(2, '0');

                    string saveFileName = COMPANY_NO_BOX + "-" + "3" + "-" + req_seq + "_完了通知書(" + EDI_ACCOUNT.Replace("@", "") + ")_" + COMPANY_NAME + "様_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf";

                    response = getPDF(COMPANY_NO_BOX, COMPANY_NAME, dtPDFData, dtPDFData1, dtPDFData2, saveFileName, status);

                    #endregion
                }
                else
                {
                    response.Status  = 0;
                    response.Message = Utility.Messages.Jimugo.I000WB001;
                    dr["Message"]    = Utility.Messages.Jimugo.I000WB001;
                    messagecode.Rows.Add(dr);
                    response.Data = Utility_Component.DtToJSon(messagecode, "Message");
                    return(response);
                }

                return(response); //process 3 successful
            }
            catch (Exception ex)
            {
                return(ResponseUtility.GetUnexpectedResponse(response, timer, ex));
            }
        }