コード例 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="Node"></param>
 /// <param name="XPath"></param>
 /// <param name="Code"></param>
 /// <returns></returns>
 public static string SelectSingleNode(this XmlNode Node, string XPath, ref SysCode Code)
 {
     return(Node.SelectSingleNode(XPath, ref Code, true));
 }
コード例 #2
0
 public async Task <ApiResult <string> > EditStatusCode(SysCode parm)
 {
     return(await _sysCodeService.ModifyStatusAsync(parm));
 }
コード例 #3
0
        public SysCode CreatOrUpdate(SysCode sysCode)
        {
            var result = _responsitory.InsertOrUpdate(sysCode);

            return(result);
        }
コード例 #4
0
        public void ProcessRequest(HttpContext context)
        {
            this.MyUtility.InitLog("GetImageBase64");

            context.Response.Clear();
            context.Response.ContentType = "application/json";

            string json = string.Empty, data = string.Empty, message = string.Empty;

            SysCode code = SysCode.B000;

            XmlDocument xmlDoc = null;

            string xPath = string.Empty, strSql = string.Empty;

            List <IDataParameter> para = null;

            DataTable dt = null;

            string USERID = string.Empty;

            string year_and_month = string.Empty;

            string session_key = string.Empty, session_info = string.Empty;

            Aspose.Pdf.License license = new Aspose.Pdf.License();

            license.SetLicense("Aspose.Pdf.lic");

            IMAGE_BASE64_CLASS.IMAGE_BASE64_ITEM[] image_item_list = null;
            try
            {
                #region 取得參數

                data = context.GetRequest("data");

                if (String.IsNullOrEmpty(data))
                {
                    throw new Utility.ProcessException(string.Format("參數為空值"), ref code, SysCode.E004);
                }

                this.MyUtility.WriteLog(Mode.LogMode.DEBUG, context, string.Format("DATA.JSON:{0}", data));

                #endregion

                xmlDoc = JsonConvert.DeserializeXmlNode(data);

                XmlNode xmlNodeProcessInfo = xmlDoc.SelectSingleNode(xPath = string.Format("./CHANGINGTEC/PROCESS_INFO"));

                if (xmlNodeProcessInfo == null)
                {
                    throw new Utility.ProcessException(xPath, ref code, SysCode.E003);
                }

                USERID = xmlNodeProcessInfo.SelectSingleNode(string.Format("USERID"), ref code, false);

                session_key = xmlNodeProcessInfo.SelectSingleNode(string.Format("SESSION_KEY"), ref code, false);

                this.MyUtility.WriteLog(context, string.Format("SESSION_KEY:{0}", session_key));

                if (String.IsNullOrEmpty(session_key))
                {
                    year_and_month = xmlNodeProcessInfo.SelectSingleNode(string.Format("YM"), ref code);

                    this.MyUtility.CheckAndCreateTable(context, year_and_month, ref code);

                    string CHANNEL_CODE     = xmlNodeProcessInfo.SelectSingleNode(string.Format("CHANNEL_CODE"), ref code);
                    string TXN_TYPE         = xmlNodeProcessInfo.SelectSingleNode(string.Format("TXN_TYPE"), ref code);
                    string TXN_ID           = xmlNodeProcessInfo.SelectSingleNode(string.Format("TXN_ID"), ref code);
                    string REPORT_SERIAL_NO = xmlNodeProcessInfo.SelectSingleNode(string.Format("REPORT_SERIAL_NO"), ref code);
                    string GUID             = xmlNodeProcessInfo.SelectSingleNode(string.Format("GUID"), ref code);

                    this.MyUtility.DBLog(context, SysCode.B001, "GetImageBase64", string.Empty, USERID, session_info = string.Format("{0}_{1}_{2}_{3}_{4}_{5}", year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_SERIAL_NO, GUID));

                    strSql = this.MyUtility.Select.FILE_TABLE(year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_SERIAL_NO, GUID, ref para);

                    #region SQL Debug

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    dt = this.MyUtility.DBConn.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                    if (dt.Rows.Count.Equals(0))
                    {
                        year_and_month = year_and_month.GetPreviousYM();

                        this.MyUtility.CheckAndCreateTable(context, year_and_month, ref code);

                        strSql = this.MyUtility.Select.FILE_TABLE(year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_SERIAL_NO, GUID, ref para);

                        #region SQL Debug

                        this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                        this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                        #endregion

                        dt = this.MyUtility.DBConn.GeneralSqlCmd.ExecuteToDataTable(strSql, para);
                    }
                }
                else
                {
                    year_and_month = session_key.Split('-')[0];

                    this.MyUtility.CheckAndCreateTable(context, year_and_month, ref code);

                    this.MyUtility.DBLog(context, SysCode.B001, "GetImageBase64", string.Empty, USERID, session_info = string.Format("{0}_{1}", year_and_month, session_key));

                    strSql = this.MyUtility.Select.FILE_TABLE(year_and_month, session_key, ref para);

                    #region SQL Debug

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    dt = this.MyUtility.DBConn.GeneralSqlCmd.ExecuteToDataTable(strSql, para);
                }
                if (dt.Rows.Count.Equals(0))
                {
                    throw new Utility.ProcessException(string.Format("查無資料"), ref code, SysCode.E007);
                }

                this.MyUtility.DBLog(context, SysCode.A001, "GetImageBase64", session_key = dt.Rows[0]["SESSION_KEY"].ToString(), USERID, string.Empty);

                this.MyUtility.WriteLog(context, string.Format("SESSION_KEY:{0}", session_key));

                DataRow[] dr_pdf = dt.Select(string.Format("FILE_TYPE=1"));

                string pdf_file_full_path = string.Empty;

                bool pdf_exists = false;

                if (dr_pdf.Length > 0)
                {
                    string pdf_file_root = dr_pdf[0]["FILE_ROOT"].ToString();

                    string pdf_file_path = dr_pdf[0]["FILE_PATH"].ToString();

                    pdf_file_full_path = pdf_file_root.FilePathCombine(pdf_file_path);

                    pdf_exists = File.Exists(pdf_file_full_path);

                    this.MyUtility.WriteLog(context, string.Format("{0},{1}", pdf_file_full_path, pdf_exists));
                }
                DataRow[] dr_image = dt.Select(string.Format("FILE_TYPE=11"));

                this.MyUtility.WriteLog(context, string.Format("Image.Count:{0}", dr_image.Length));

                if (dr_image.Length.Equals(0))
                {
                    throw new Utility.ProcessException(string.Format("查無資料"), ref code, SysCode.E007);
                }

                image_item_list = new IMAGE_BASE64_CLASS.IMAGE_BASE64_ITEM[dr_image.Length];

                for (int i = 0; i < dr_image.Length; i++)
                {
                    session_key = dr_image[i]["SESSION_KEY"].ToString();

                    string file_id = dr_image[i]["FILE_ID"].ToString();

                    int file_seq = Convert.ToInt16(dr_image[i]["FILE_SEQ"].ToString());

                    string file_root = dr_image[i]["FILE_ROOT"].ToString();

                    string file_path = dr_image[i]["FILE_PATH"].ToString();

                    string file_full_path = file_root.FilePathCombine(file_path);

                    bool exists = File.Exists(file_full_path);

                    this.MyUtility.WriteLog(context, string.Format("{0},{1},{2}", file_seq, file_full_path, exists));

                    if (!exists && pdf_exists)
                    {
                        #region PDF 切割
                        try
                        {
                            using (Document pdfDocument = new Document(pdf_file_full_path))
                            {
                                Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(150);

                                Aspose.Pdf.Devices.JpegDevice jpegDeviceLarge = new Aspose.Pdf.Devices.JpegDevice(resolution);

                                if (file_seq <= 0 || file_seq > pdfDocument.Pages.Count)
                                {
                                    this.MyUtility.WriteLog(Mode.LogMode.ERROR, context, string.Format("PDF.Pages.Count:{0},FILE_SEQ:{1}", pdfDocument.Pages.Count, file_seq));

                                    throw new Utility.ProcessException(string.Format("查無影像檔及無法從PDF內拆檔"), ref code, SysCode.E005);
                                }
                                jpegDeviceLarge.Process(pdfDocument.Pages[file_seq], file_full_path);

                                if (!File.Exists(file_full_path))
                                {
                                    throw new Utility.ProcessException(string.Format("頁次{0}拆檔失敗", file_seq), ref code, SysCode.E005);
                                }
                            }
                        }
                        catch (System.Exception ex)
                        {
                            this.MyUtility.WriteLog(Mode.LogMode.ERROR, context, ex.ToString());

                            throw new Utility.ProcessException(ex.Message, ref code, SysCode.E005);
                        }
                        #endregion
                    }
                    if (!File.Exists(file_full_path))
                    {
                        throw new Utility.ProcessException(string.Format("頁次{0}圖檔不存在", file_seq), ref code, SysCode.E001);
                    }

                    image_item_list[i] = new IMAGE_BASE64_CLASS.IMAGE_BASE64_ITEM()
                    {
                        FILE_ID = file_id, BODY = file_full_path.FileSerialize()
                    };
                }
                this.MyUtility.DBLog(context, SysCode.B000, "GetImageBase64", session_key, USERID, session_info);
            }
            catch (System.Exception ex)
            {
                message = ex.Message;

                this.MyUtility.WriteLog(Mode.LogMode.ERROR, context, ex.ToString());

                code = !code.Equals(SysCode.B000) ? code : SysCode.E999;

                this.MyUtility.DBLog(context, code, "GetImageBase64", session_key, USERID, ex.Message);

                this.MyUtility.SendEMail(context, "GetImageBase64", session_key, code);
            }
            finally
            {
                json = JsonConvert.SerializeObject(new IMAGE_BASE64_RESPOSE()
                {
                    CHANGINGTEC = new IMAGE_BASE64_SYSTEM_CLASS()
                    {
                        SYSTEM = new IMAGE_BASE64_SYSTEM_INFO_CLASS()
                        {
                            //CODE = code.Equals(SysCode.B000) ? SysCode.A000.ToString() : code.Equals(SysCode.E007) ? SysCode.A003.ToString() : code.ToString(),
                            CODE      = code.Equals(SysCode.B000) ? SysCode.A000.ToString() : code.ToString(),
                            MESSAGE   = message.EncryptBase64(),
                            CASE_INFO = new IMAGE_BASE64_CLASS()
                            {
                                JPG_ITEM = image_item_list
                            }
                        }
                    }
                });
                dt = null;

                license = null;

                xmlDoc = null;

                para = null;

                this.MyUtility.CloseConn();

                xmlDoc = null;

                GC.Collect(); GC.WaitForPendingFinalizers();

                context.Response.Write(json);
                context.Response.End();
            }
        }
コード例 #5
0
 public async Task <ApiResult <string> > Modify([FromBody] SysCode model) => await _sysCodeService.Modify(model);
コード例 #6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.Clear();
            context.Response.ContentType = "application/json";

            string json = string.Empty, data = string.Empty, message = string.Empty;

            SysCode code = SysCode.A000;

            XmlDocument xmlDoc = null;

            string xPath = string.Empty, strSql = string.Empty;

            List <IDataParameter> para = null;

            string USERID = string.Empty;

            string year_and_month = DateTime.Now.ToString("yyyyMM");

            string session_key = string.Empty;

            bool exists = false;

            DataTable dt = null;

            Hashtable para_data = null;

            int result = -1;

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

            try
            {
                #region 取得參數

                data = context.GetRequest("data");

                if (String.IsNullOrEmpty(data))
                {
                    throw new Utility.ProcessException(string.Format("參數為空值"), ref code, SysCode.E004);
                }

                #endregion

                xmlDoc = JsonConvert.DeserializeXmlNode(data);

                XmlNode xmlNodeProcessInfo = xmlDoc.SelectSingleNode(xPath = string.Format("./CHANGINGTEC/PROCESS_INFO"));

                if (xmlNodeProcessInfo == null)
                {
                    throw new Utility.ProcessException(xPath, ref code, SysCode.E003);
                }

                USERID = xmlNodeProcessInfo.SelectSingleNode(string.Format("USERID"), ref code, false);

                string TRANSACTION_ID = xmlNodeProcessInfo.SelectSingleNode(string.Format("TRANSACTION_ID"), ref code, false);

                this.MyUtility.InitPDFUploadLog(string.Format("PDFUploadFile_{0}", DateTime.Now.Hour.ToString()));

                this.MyUtility.WritePDFUploadLog(Mode.LogMode.DEBUG, context, string.Format("DATA.JSON:{0}", data));

                this.MyUtility.DBLog(context, SysCode.A001, "PDFUploadFile", session_key, USERID, string.Empty);

                string PDF_BASE64 = xmlNodeProcessInfo.SelectSingleNode(string.Format("PDF_BASE64"), ref code);

                string INI_BASE64 = xmlNodeProcessInfo.SelectSingleNode(string.Format("INI_BASE64"), ref code);

                string MODE = xmlNodeProcessInfo.SelectSingleNode(string.Format("MODE"), ref code).ToUpper();

                if (!String.IsNullOrEmpty(MODE))
                {
                    year_and_month = xmlNodeProcessInfo.SelectSingleNode(string.Format("YM"), ref code);
                }

                #region WACH_PATH

                strSql = this.MyUtility.Select.SETTING("WACH_PATH", ref para);

                #region SQL Debug

                this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, strSql);

                this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                #endregion

                string wach_dir_path = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteByColumnName(strSql, para, "PARAMETER");

                exists = Directory.Exists(wach_dir_path);

                this.MyUtility.WritePDFUploadLog(Mode.LogMode.INFO, context, string.Format("WACH_PATH:{0},{1}", wach_dir_path, exists));

                if (!exists)
                {
                    throw new Utility.ProcessException(string.Format("目錄不存在:{0}", wach_dir_path), ref code, SysCode.E001);
                }

                #endregion

                if (String.IsNullOrEmpty(PDF_BASE64) || String.IsNullOrEmpty(INI_BASE64))
                {
                    throw new Utility.ProcessException(string.Format("缺少檔案內容"), ref code, SysCode.E006);
                }

                int case_version = 1;

                para_data = new Hashtable();
                para_data.Add("VERSION", case_version.ToString());
                para_data.Add("CREATE_USERID", USERID);
                para_data.Add("MODIFY_USERID", USERID);

                #region ReadINI

                this.MyUtility.WritePDFUploadLog(Mode.LogMode.INFO, context, string.Format("ReadINI.Start"));

                string line = string.Empty;

                //using (MemoryStream memStream = new MemoryStream(Convert.FromBase64String(INI_BASE64.Replace(" ", "+"))))
                //{
                //    using (StreamReader file = new StreamReader(memStream, Encoding.UTF8))
                //    {
                //        string[] lines = file.ReadToEnd().Split(new char[] { '\n' });

                //        Parallel.ForEach(lines, (currentLines) =>
                //        {
                //            if (currentLines.IndexOf('=') == -1) return;

                //            string[] line_temp = currentLines.Trim().Split('=');

                //            this.MyUtility.WritePDFUploadLog(Mode.LogMode.DEBUG, context, line);

                //            if (!para_data.ContainsKey(line_temp[0].Trim().ToUpper()))
                //            {
                //                this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.INFO, context, string.Format("INI:{0}", line));

                //                para_data.Add(line_temp[0].Trim().ToUpper(), line_temp[1].Trim());
                //            }

                //        });

                //    }
                //}
                using (StreamReader file = new StreamReader(new MemoryStream(Convert.FromBase64String(INI_BASE64.Replace(" ", "+"))), Encoding.UTF8))
                {
                    while ((line = file.ReadLine()) != null)
                    {
                        if (line.IndexOf('=') == -1)
                        {
                            continue;
                        }

                        string[] line_temp = line.Trim().Split('=');

                        this.MyUtility.WritePDFUploadLog(Mode.LogMode.DEBUG, context, line);

                        if (!para_data.ContainsKey(line_temp[0].Trim().ToUpper()))
                        {
                            this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.INFO, context, string.Format("INI:{0}", line));

                            para_data.Add(line_temp[0].Trim().ToUpper(), line_temp[1].Trim());
                        }
                    }
                    file.Close();
                }
                this.MyUtility.WritePDFUploadLog(Mode.LogMode.INFO, context, string.Format("ReadINI.End"));

                #endregion

                if (!para_data.ContainsKey("TXN_DATE"))
                {
                    throw new Utility.ProcessException(string.Format("TXN_DATE is Null"), ref code, SysCode.E004);
                }

                this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.INFO, context, string.Format("TXN_DATE:{0}", para_data.ContainsKey("TXN_DATE")));

                if (para_data.ContainsKey("TXN_DATE"))
                {
                    year_and_month = DateTime.Parse(para_data["TXN_DATE"].ToString().ToDate()).ToString("yyyyMM");
                }

                this.MyUtility.CheckAndCreateTable(context, year_and_month, ref code);

                session_key = Guid.NewGuid().GenerateSessionKey(year_and_month);

                para_data.Add("SESSION_KEY", session_key);

                this.MyUtility.WritePDFUploadLog(Mode.LogMode.INFO, context, string.Format("SESSION_KEY:{0}", session_key));

                string case_state = string.Empty, file_path = string.Empty, ini_file_path = string.Empty;

                bool pdf_split = true;

                if (String.IsNullOrEmpty(MODE))
                {
                    #region Anew

                    if (!para_data.ContainsKey("TXN_ID") ||
                        !para_data.ContainsKey("GUID") ||
                        !para_data.ContainsKey("CHANNEL_CODE") ||
                        !para_data.ContainsKey("TXN_TYPE") ||
                        !para_data.ContainsKey("REPORT_SERIAL_NO"))
                    {
                        throw new Utility.ProcessException(string.Format("INI內容必要資料不足"), ref code, SysCode.E004);
                    }

                    strSql = this.MyUtility.Select.CASE_TABLE(year_and_month, para_data["CHANNEL_CODE"].ToString(), para_data["TXN_TYPE"].ToString(), para_data["TXN_ID"].ToString(), para_data["REPORT_SERIAL_NO"].ToString(), para_data["GUID"].ToString(), ref para);

                    #region SQL Debug

                    this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    dt = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                    bool case_data_check = dt != null && dt.Rows.Count > 0;

                    this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.INFO, context, string.Format("CheckCase:{0}", case_data_check));

                    string case_session_key = session_key;

                    if (case_data_check)
                    {
                        pdf_split = false;

                        if (!para_data.ContainsKey("TRANS_STATE"))
                        {
                            para_data.Add("TRANS_STATE", "REPT");
                        }
                        else
                        {
                            para_data["TRANS_STATE"] = "REPT";
                        }
                    }
                    bool check = para_data["TRANS_STATE"].ToString().Equals("LIVE") && para_data.ContainsKey("SUPERVISOR_ID") && !String.IsNullOrEmpty(para_data["SUPERVISOR_ID"].ToString());

                    this.MyUtility.WritePDFUploadLog(Mode.LogMode.INFO, context, string.Format("TRANS_STATE.LIVE:{0},{1}", para_data["TRANS_STATE"].ToString(), check));

                    //if (check)
                    //{
                    //    if (!para_data.ContainsKey("AUTHORIZE_ID")) para_data.Add("AUTHORIZE_ID", para_data["SUPERVISOR_ID"].ToString());
                    //    else para_data["AUTHORIZE_ID"] = para_data["SUPERVISOR_ID"].ToString();

                    //    if (!para_data.ContainsKey("AUTHORIZE_ID_DATE")) para_data.Add("AUTHORIZE_ID_DATE", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                    //    else para_data["AUTHORIZE_ID_DATE"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

                    //    this.MyUtility.WritePDFUploadLog(Mode.LogMode.INFO, context, string.Format("AUTHORIZE_ID:{0}", para_data["AUTHORIZE_ID"].ToString()));
                    //}
                    strSql = this.MyUtility.Insert.CASE_TABLE(para_data, year_and_month, ref para);

                    #region SQL Debug

                    this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    result = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                    this.MyUtility.WritePDFUploadLog(Mode.LogMode.INFO, context, string.Format("Result:{0}", result));

                    if (!result.Equals(1))
                    {
                        throw new Utility.ProcessException(string.Format("案件資料新增失敗"), ref code, SysCode.E002);
                    }

                    file_path = Path.Combine(wach_dir_path, string.Format("[ANEW]_{0}_{1}_{2}_{3}.pdf", year_and_month, case_version.ToString(), case_session_key, USERID));

                    file_path.DeleteSigleFile();

                    ini_file_path = Path.Combine(wach_dir_path, string.Format("[ANEW]_{0}_{1}_{2}_{3}.ini", year_and_month, case_version.ToString(), case_session_key, USERID));

                    ini_file_path.DeleteSigleFile();

                    #endregion
                }
                else if (MODE.Equals("updateTxNo".ToUpper()))
                {
                    #region updateTxNo

                    if (!para_data.ContainsKey("CHANNEL_CODE") ||
                        !para_data.ContainsKey("TXN_TYPE") ||
                        !para_data.ContainsKey("TXN_ID") ||
                        !para_data.ContainsKey("REPORT_SERIAL_NO") ||
                        !para_data.ContainsKey("GUID"))
                    {
                        throw new Utility.ProcessException(string.Format("INI內容必要資料不足"), ref code, SysCode.E004);
                    }

                    strSql = this.MyUtility.Select.CASE_TABLE_UPDATE_TXNO(year_and_month, para_data["CHANNEL_CODE"].ToString(), para_data["TXN_TYPE"].ToString(), para_data["TXN_ID"].ToString(), para_data["REPORT_SERIAL_NO"].ToString(), ref para);

                    #region SQL Debug

                    this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    dt = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                    bool case_data_check = dt != null && dt.Rows.Count > 0;

                    if (!case_data_check)
                    {
                        year_and_month = year_and_month.GetPreviousYM();

                        strSql = this.MyUtility.Select.CASE_TABLE_UPDATE_TXNO(year_and_month, para_data["CHANNEL_CODE"].ToString(), para_data["TXN_TYPE"].ToString(), para_data["TXN_ID"].ToString(), para_data["REPORT_SERIAL_NO"].ToString(), ref para);

                        #region SQL Debug

                        this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, strSql);

                        this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                        #endregion

                        dt = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                        case_data_check = dt != null && dt.Rows.Count > 0;
                    }
                    if (!case_data_check)
                    {
                        throw new Utility.ProcessException(string.Format("查詢資料不存在"), ref code, SysCode.E007);
                    }

                    this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.INFO, context, string.Format("Data.Count:{0}", dt.Rows.Count));

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["REPORT_SERIAL_NO"] != DBNull.Value && !String.IsNullOrEmpty(dt.Rows[i]["REPORT_SERIAL_NO"].ToString().Trim()))
                        {
                            continue;
                        }

                        strSql = this.MyUtility.Update.CASE_TABLE_REPORT_SERIAL_NO(year_and_month, dt.Rows[i]["SESSION_KEY"].ToString().Trim(), para_data["REPORT_SERIAL_NO"].ToString(), USERID, ref para);

                        #region SQL Debug

                        this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, strSql);

                        this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                        #endregion

                        result = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                        this.MyUtility.WritePDFUploadLog(Mode.LogMode.INFO, context, string.Format("Result:{0}", result));

                        if (!result.Equals(1))
                        {
                            throw new Utility.ProcessException(string.Format("變更REPORT_SERIAL_NO失敗,SESSION_KEY={0}", dt.Rows[i]["SESSION_KEY"].ToString().Trim()), ref code, SysCode.E002);
                        }
                    }
                    strSql = this.MyUtility.Insert.CASE_TABLE(para_data, year_and_month, ref para);

                    #region SQL Debug

                    this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    result = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                    this.MyUtility.WritePDFUploadLog(Mode.LogMode.INFO, context, string.Format("Result:{0}", result));

                    if (!result.Equals(1))
                    {
                        throw new Utility.ProcessException(string.Format("案件資料新增失敗"), ref code, SysCode.E002);
                    }

                    file_path = Path.Combine(wach_dir_path, string.Format("[UPDATE_TXNO]_{0}_{1}_{2}_{3}.pdf", year_and_month, case_version.ToString(), session_key, USERID));

                    file_path.DeleteSigleFile();

                    ini_file_path = Path.Combine(wach_dir_path, string.Format("[UPDATE_TXNO]_{0}_{1}_{2}_{3}.ini", year_and_month, case_version.ToString(), session_key, USERID));

                    ini_file_path.DeleteSigleFile();

                    #endregion
                }
                else if (MODE.Equals("rewrite".ToUpper()))
                {
                    #region rewrite

                    if (!para_data.ContainsKey("CHANNEL_CODE") ||
                        !para_data.ContainsKey("TXN_TYPE") ||
                        !para_data.ContainsKey("TXN_ID") ||
                        !para_data.ContainsKey("REPORT_SERIAL_NO") ||
                        !para_data.ContainsKey("GUID"))
                    {
                        throw new Utility.ProcessException(string.Format("INI內容必要資料不足"), ref code, SysCode.E004);
                    }

                    strSql = this.MyUtility.Select.CASE_TABLE(year_and_month, para_data["CHANNEL_CODE"].ToString(), para_data["TXN_TYPE"].ToString(), para_data["TXN_ID"].ToString(), para_data["REPORT_SERIAL_NO"].ToString(), para_data["GUID"].ToString(), ref para);

                    #region SQL Debug

                    this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    dt = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                    bool case_data_check = dt != null && dt.Rows.Count > 0;

                    if (!case_data_check)
                    {
                        year_and_month = year_and_month.GetPreviousYM();

                        strSql = this.MyUtility.Select.CASE_TABLE(year_and_month, para_data["CHANNEL_CODE"].ToString(), para_data["TXN_TYPE"].ToString(), para_data["TXN_ID"].ToString(), para_data["REPORT_SERIAL_NO"].ToString(), para_data["GUID"].ToString(), ref para);

                        #region SQL Debug

                        this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, strSql);

                        this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                        #endregion

                        dt = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                        case_data_check = dt != null && dt.Rows.Count > 0;
                    }
                    if (!case_data_check)
                    {
                        throw new Utility.ProcessException(string.Format("查詢資料不存在"), ref code, SysCode.E007);
                    }

                    this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.INFO, context, string.Format("Data.Count:{0}", dt.Rows.Count));

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        strSql = this.MyUtility.Update.CASE_TABLE_GUID(year_and_month, dt.Rows[i]["SESSION_KEY"].ToString().Trim(), para_data["GUID"].ToString(), para_data["TXN_TIME"].ToString(), para_data["TRANS_STATE"].ToString(), USERID, ref para);

                        #region SQL Debug

                        this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, strSql);

                        this.MyUtility.WritePDFUploadLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                        #endregion

                        result = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                        this.MyUtility.WritePDFUploadLog(Mode.LogMode.INFO, context, string.Format("Result:{0}", result));

                        if (!result.Equals(1))
                        {
                            throw new Utility.ProcessException(string.Format("變更GUID失敗,SESSION_KEY={0}", dt.Rows[i]["SESSION_KEY"].ToString().Trim()), ref code, SysCode.E002);
                        }
                    }
                    file_path = Path.Combine(wach_dir_path, string.Format("[REWRITE]_{0}_{1}_{2_{3}}.pdf", year_and_month, case_version.ToString(), session_key, USERID));

                    file_path.DeleteSigleFile();

                    ini_file_path = Path.Combine(wach_dir_path, string.Format("[REWRITE]_{0}_{1}_{2}_{3}.ini", year_and_month, case_version.ToString(), session_key, USERID));

                    ini_file_path.DeleteSigleFile();

                    #endregion
                }
                else
                {
                    throw new Utility.ProcessException(string.Format("MODE參數錯誤"), ref code, SysCode.E004);
                }

                if (pdf_split)
                {
                    this.MyUtility.CreateFile(ini_file_path, INI_BASE64, ref code);

                    this.MyUtility.CreateFile(file_path, PDF_BASE64, ref code);
                }
                this.MyUtility.DBConnTransac.GeneralSqlCmd.Transaction.Commit();

                this.MyUtility.DBLog(context, SysCode.A002, "PDFUploadFile", session_key, USERID, string.Empty);
                try
                {
                    foreach (string path in delete_list)
                    {
                        path.DeleteSigleFile();
                    }
                }
                catch (System.Exception ex) { this.MyUtility.WritePDFUploadLog(Mode.LogMode.ERROR, context, string.Format("Delete.File.Exception::\r\n{0}", ex.ToString())); }
            }
            catch (System.Exception ex)
            {
                this.MyUtility.Rollback();

                message = ex.Message;

                this.MyUtility.WritePDFUploadLog(Mode.LogMode.ERROR, context, ex.ToString());

                code = !code.Equals(SysCode.A000) ? code : SysCode.E999;

                this.MyUtility.DBLog(context, code, "PDFUploadFile", session_key, USERID, ex.Message);

                this.MyUtility.SendEMail(context, "PDFUploadFile", session_key, code);
            }
            finally
            {
                json = JsonConvert.SerializeObject(new PDF_UPLOAD_FILE_RESPOSE()
                {
                    CHANGINGTEC = new PDF_UPLOAD_FILE_SYSTEM_CLASS()
                    {
                        SYSTEM = new PDF_UPLOAD_FILE_SYSTEM_INFO_CLASS()
                        {
                            CODE         = code.ToString(),
                            MESSAGE      = message.EncryptBase64(),
                            PROCESS_INFO = new Dictionary <string, string>()
                            {
                                { "SESSION_KEY", session_key }, { "YM", year_and_month }
                            }
                        }
                    }
                });
                dt = null;

                xmlDoc = null;

                para = null;

                this.MyUtility.CloseConnTransac();

                xmlDoc = null;

                GC.Collect(); GC.WaitForPendingFinalizers();

                context.Response.Write(json);
                context.Response.End();
            }
        }
コード例 #7
0
        public void ProcessRequest(HttpContext context)
        {
            this.MyUtility.InitLog("CloseSession");

            context.Response.Clear();
            context.Response.ContentType = "application/json";

            string json = string.Empty, data = string.Empty, message = string.Empty;

            SysCode code = SysCode.A000;

            XmlDocument xmlDoc = null;

            string xPath = string.Empty, strSql = string.Empty;

            List <IDataParameter> para = null;

            string session_key = string.Empty, session_temp_dir_path = string.Empty;

            string year_and_month = string.Empty;

            DirectoryInfo dirInfo = null;

            DataTable dt = null;

            Hashtable para_data = null;

            string USERID = string.Empty;

            int result = -1;

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

            bool exists = false;

            try
            {
                #region 取得參數

                data = context.GetRequest("data");

                if (String.IsNullOrEmpty(data))
                {
                    throw new Utility.ProcessException(string.Format("參數為空值"), ref code, SysCode.E004);
                }

                this.MyUtility.WriteLog(Mode.LogMode.DEBUG, context, string.Format("DATA.JSON:{0}", data));

                #endregion

                xmlDoc = JsonConvert.DeserializeXmlNode(data);

                XmlNode xmlNodeProcessInfo = xmlDoc.SelectSingleNode(xPath = string.Format("./CHANGINGTEC/PROCESS_INFO"));

                if (xmlNodeProcessInfo == null)
                {
                    throw new Utility.ProcessException(xPath, ref code, SysCode.E003);
                }

                USERID = xmlNodeProcessInfo.SelectSingleNode(string.Format("SESSION_KEY"), ref code);

                session_key = xmlNodeProcessInfo.SelectSingleNode(string.Format("SESSION_KEY"), ref code);

                this.MyUtility.CheckAndCreateTable(context, year_and_month, ref code);

                #region SESSION_TEMP_PATH

                strSql = this.MyUtility.Select.SETTING("SESSION_TEMP_PATH", ref para);

                #region SQL Debug

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                #endregion

                string session_temp_root_path = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteByColumnName(strSql, para, "PARAMETER");

                exists = Directory.Exists(session_temp_root_path);

                this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("SESSION_TEMP_PATH (ROOT):{0},{1}", session_temp_root_path, exists));

                if (!exists)
                {
                    throw new Utility.ProcessException(string.Format("目錄不存在:{0}", session_temp_root_path), ref code, SysCode.E001);
                }

                #endregion

                #region SESSION_TEMP_PATH

                session_temp_dir_path = Path.Combine(session_temp_root_path, session_key);

                exists = Directory.Exists(session_temp_dir_path);

                this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("SESSION_TEMP_PATH:{0},{1}", session_temp_dir_path, exists));

                if (!exists)
                {
                    throw new Utility.ProcessException(string.Format("目錄不存在:{0}", session_temp_dir_path), ref code, SysCode.E001);
                }

                #endregion

                #region FILE_ROOT

                strSql = this.MyUtility.Select.SETTING("FILE_ROOT", ref para);

                #region SQL Debug

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                #endregion

                string file_root = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteByColumnName(strSql, para, "PARAMETER");

                exists = Directory.Exists(file_root);

                this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("FILE_ROOT:{0},{1}", file_root, exists));

                if (!exists)
                {
                    throw new Utility.ProcessException(string.Format("目錄不存在:{0}", file_root), ref code, SysCode.E001);
                }

                #endregion

                dirInfo = new DirectoryInfo(session_temp_dir_path);

                FileInfo xml_file = dirInfo.GetFiles("*.xml")[0];

                year_and_month = xml_file.Name.Replace(xml_file.Extension, "").Split('_')[1];

                this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("YM:{0}", year_and_month));

                xmlDoc = new XmlDocument();
                xmlDoc.Load(xml_file.FullName);

                xml_file = null;

                xmlNodeProcessInfo = xmlDoc.SelectSingleNode(xPath = string.Format("./PROCESS_INFO"));

                string CHANNEL_CODE = xmlNodeProcessInfo.SelectSingleNode(string.Format("CHANNEL_CODE"), ref code);
                string TXN_TYPE     = xmlNodeProcessInfo.SelectSingleNode(string.Format("TXN_TYPE"), ref code);
                string TXN_ID       = xmlNodeProcessInfo.SelectSingleNode(string.Format("TXN_ID"), ref code);
                string REPORT_TYPE  = xmlNodeProcessInfo.SelectSingleNode(string.Format("REPORT_TYPE"), ref code);
                string GUID         = xmlNodeProcessInfo.SelectSingleNode(string.Format("GUID"), ref code);

                strSql = this.MyUtility.Select.CASE_TABLE(year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_TYPE, GUID, ref para);

                #region SQL Debug

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                #endregion

                dt = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                bool case_data_check = dt != null && dt.Rows.Count > 0;

                string case_state = string.Empty, file_path = string.Empty;

                int case_version = 1;

                if (case_data_check)
                {
                    #region 重覆件處理 (FILE_TABLE)

                    case_version = Convert.ToInt32(dt.Rows[0]["VERSION"].ToString().Trim());

                    case_state = dt.Rows[0]["CASE_STATE"].ToString().Trim();

                    session_key = dt.Rows[0]["SESSION_KEY"].ToString().Trim();

                    if (case_state.Equals("1"))
                    {
                        throw new Utility.ProcessException(string.Format("重覆上傳"), ref code, SysCode.E008);
                    }

                    strSql = this.MyUtility.Select.FILE_TABLE(year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_TYPE, GUID, ref para);

                    #region SQL Debug

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    dt = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                    this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("File.Total:{0}", dt.Rows.Count));

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        delete_image_list.Add(dt.Rows[i]["FILE_ROOT"].ToString().FilePathCombine(dt.Rows[i]["FILE_PATH"].ToString()));
                    }
                    strSql = this.MyUtility.Delete.FILE_TABLE(year_and_month, session_key, case_version.ToString(), ref para);

                    #region SQL Debug

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    result = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                    this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("Result:{0}", result));

                    #endregion
                }

                #region INSERT.CASE_TABLE

                para_data = new Hashtable();
                para_data.Add("SESSION_KEY", session_key);
                para_data.Add("CHANNEL_CODE", CHANNEL_CODE);
                para_data.Add("TXN_TYPE", TXN_TYPE);
                para_data.Add("TXN_ID", TXN_ID);
                para_data.Add("REPORT_TYPE", REPORT_TYPE);
                para_data.Add("GUID", GUID);
                para_data.Add("VERSION", case_version.ToString());
                para_data.Add("CREATE_USERID", USERID);
                para_data.Add("MODIFY_USERID", USERID);

                string ini_file_path = Path.Combine(session_temp_dir_path, string.Format("{0}.ini", session_key));

                if (File.Exists(ini_file_path))
                {
                    #region ReadINI

                    this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("ReadINI.Start"));

                    string line = string.Empty;

                    using (StreamReader file = new StreamReader(ini_file_path, Encoding.UTF8))
                    {
                        while ((line = file.ReadLine()) != null)
                        {
                            if (line.IndexOf('=') == -1)
                            {
                                continue;
                            }

                            string[] line_temp = line.Trim().Split('=');

                            this.MyUtility.WriteLog(Mode.LogMode.DEBUG, context, line);

                            if (!para_data.ContainsKey(line_temp[0].Trim().ToUpper()))
                            {
                                para_data.Add(line_temp[0].Trim().ToUpper(), line_temp[1].Trim());
                            }
                        }
                        file.Close();
                    }
                    this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("ReadINI.End"));

                    #endregion
                }
                strSql = this.MyUtility.Insert.CASE_TABLE(para_data, year_and_month, ref para);

                #region SQL Debug

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                #endregion

                result = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("Result:{0}", result));

                if (!result.Equals(1))
                {
                    throw new Utility.ProcessException(string.Format("案件資料新增失敗"), ref code, SysCode.E002);
                }

                #endregion

                FileInfo[] files = dirInfo.GetFiles();

                string file_dir_path = file_root.CreateSubDirectory();

                for (int i = 0; i < files.Length; i++)
                {
                    FileInfo fi = files[i];

                    if (fi.Extension.ToLower().EndsWith(".xml"))
                    {
                        continue;
                    }

                    bool is_image_file = fi.Name.ToUpper().StartsWith("[FILE]");

                    bool is_ini_file = fi.Extension.ToLower().EndsWith(".ini");

                    string[] file_infos = fi.Name.Replace(fi.Extension, "").Replace("[FILE]_", "").Split('_');

                    #region IMAGE

                    string file_id = Guid.NewGuid().ToString();

                    string image_full_path = Path.Combine(file_dir_path, string.Format("{0}{1}", file_id, fi.Extension));

                    file_path = image_full_path.Replace(file_root, "");

                    if (file_path.StartsWith(@"\") || file_path.StartsWith("/"))
                    {
                        file_path = file_path.Remove(0, 1);
                    }

                    Hashtable ht = new Hashtable();
                    ht.Add("FILE_ID", file_id);
                    ht.Add("SESSION_KEY", session_key);
                    ht.Add("VERSION", case_version);
                    ht.Add("FILE_ROOT", file_root);
                    ht.Add("FILE_PATH", file_path);
                    ht.Add("FILE_SIZE", fi.Length);

                    if (is_image_file)
                    {
                        ht.Add("FILE_TYPE", Convert.ToInt16(file_infos[0]));
                        ht.Add("FILE_SEQ", Convert.ToInt16(file_infos[1]));
                        ht.Add("FILE_NAME", file_infos[2]);
                    }
                    else
                    {
                        ht.Add("FILE_TYPE", is_ini_file ? 2 : 3);
                        ht.Add("FILE_SEQ", 1);
                        ht.Add("FILE_NAME", "001");
                    }
                    strSql = this.MyUtility.Insert.FILE_TABLE(ht, year_and_month, ref para);

                    #region SQL Debug

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    result = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                    if (!result.Equals(1))
                    {
                        throw new Exception(string.Format("資料新增失敗::{0}", fi.Name));
                    }

                    fi.CopyTo(image_full_path);

                    fi = null;

                    if (!File.Exists(image_full_path))
                    {
                        throw new Exception(string.Format("檔案搬移失敗::{0}", fi.Name));
                    }

                    delete_image_list.Add(image_full_path);

                    #endregion
                }
                files = null;

                this.MyUtility.DBConnTransac.GeneralSqlCmd.Transaction.Commit();

                this.MyUtility.DBLog(context, code, "CloseSession", session_key, USERID, message);

                try { session_temp_dir_path.DeleteDirectory(); } catch (System.Exception ex) { this.MyUtility.WriteLog(Mode.LogMode.ERROR, context, ex.ToString()); }
            }
            catch (System.Exception ex)
            {
                this.MyUtility.Rollback();

                message = ex.Message;

                this.MyUtility.WriteLog(Mode.LogMode.ERROR, context, ex.ToString());

                code = !code.Equals(SysCode.A000) ? code : SysCode.E999;

                this.MyUtility.DBLog(context, code, "CloseSession", session_key, USERID, ex.Message);

                if (delete_image_list != null)
                {
                    foreach (string e in delete_image_list)
                    {
                        e.DeleteSigleFile();
                    }
                }

                this.MyUtility.SendEMail(context, "CloseSession", session_key, code);
            }
            finally
            {
                json = JsonConvert.SerializeObject(new CLOSE_SESSION_RESPOSE()
                {
                    CHANGINGTEC = new CLOSE_SESSION_SYSTEM_CLASS()
                    {
                        SYSTEM = new CLOSE_SESSION_SYSTEM_INFO_CLASS()
                        {
                            CODE        = code.ToString(),
                            MESSAGE     = message.EncryptBase64(),
                            SESSION_KEY = session_key,
                            YM          = year_and_month
                        }
                    }
                });
                dt = null;

                dirInfo = null;

                xmlDoc = null;

                para = null;

                this.MyUtility.CloseConnTransac();

                xmlDoc = null;

                GC.Collect(); GC.WaitForPendingFinalizers();

                context.Response.Write(json);
                context.Response.End();
            }
        }
コード例 #8
0
 public async Task <ApiResult <string> > UpdateStatus([FromBody] SysCode model)
 {
     return(await _sysCodeService.ModifyStatusAsync(model));
 }
コード例 #9
0
 public VersionedRoute(string template, SysCode allowedTags)
     : this(template, DefaultAllowedApiVersion, allowedTags)
 {
 }
コード例 #10
0
    /// <summary>
    /// 生成订单
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCopyOrder_Click(object sender, EventArgs e)
    {
        decimal TotalAmount = 0; //订单总价

        Hi.Model.DIS_Order OrderInfoModel = null;

        OrderInfoModel = OrderInfoBll.GetModel(Id);

        if (OrderInfoModel != null)
        {
            OrderInfoModel.ReceiptNo = SysCode.GetNewCode("销售单");

            //TotalAmount	总价
            //AuditAmount	审核后总价
            //OtherAmount	其它费用

            OrderInfoModel.PayState     = (int)Enums.PayState.未支付;
            OrderInfoModel.OState       = (int)Enums.OrderState.待审核;
            OrderInfoModel.PayedAmount  = 0;
            OrderInfoModel.ReturnState  = 0;
            OrderInfoModel.DisUserID    = this.UserID;
            OrderInfoModel.CreateUserID = this.UserID;
            OrderInfoModel.CreateDate   = DateTime.Now;

            OrderInfoModel.AuditUserID       = 0;
            OrderInfoModel.AuditDate         = DateTime.MinValue;
            OrderInfoModel.AuditRemark       = "";
            OrderInfoModel.ReturnMoneyDate   = DateTime.MinValue;
            OrderInfoModel.ReturnMoneyUserId = 0;
            OrderInfoModel.ReturnMoneyUser   = "";
            OrderInfoModel.ts         = DateTime.Now;
            OrderInfoModel.dr         = 0;
            OrderInfoModel.modifyuser = 0;

            List <Hi.Model.DIS_OrderDetail> l = OrderDetailBll.GetList("", " OrderId=" + Id, "");

            List <Hi.Model.DIS_OrderDetail> dl = new List <Hi.Model.DIS_OrderDetail>();

            foreach (Hi.Model.DIS_OrderDetail item in l)
            {
                item.Price       = 0;
                item.AuditAmount = 0;
                item.sumAmount   = item.Price * item.GoodsNum;

                TotalAmount += item.sumAmount;

                item.ts         = DateTime.Now;
                item.dr         = 0;
                item.modifyuser = 0;

                dl.Add(item);
            }
            OrderInfoModel.TotalAmount = TotalAmount;
            OrderInfoModel.AuditAmount = TotalAmount;
            OrderInfoModel.OtherAmount = 0;

            int OrderId = OrderInfoType.TansOrder(OrderInfoModel, dl);

            if (OrderId > 0)
            {
                //Utils.AddSysBusinessLog(this.CompID, "Order", OrderId.ToString(), "订单新增", "");
                JScript.AlertMsg(this, "新增成功!", "OrderCreateInfo.aspx?Id=" + OrderId);
            }
        }
    }
コード例 #11
0
 public async Task <ApiResult <string> > Add([FromBody] SysCode model)
 {
     return(await _sysCodeService.AddAsync(model));
 }
コード例 #12
0
        public void ProcessRequest(HttpContext context)
        {
            this.MyUtility.InitLog("GetImageURL");

            context.Response.Clear();
            context.Response.ContentType = "application/json";

            string json = string.Empty, data = string.Empty, message = string.Empty;

            SysCode code = SysCode.B000;

            XmlDocument xmlDoc = null;

            string xPath = string.Empty, strSql = string.Empty;

            List <IDataParameter> para = null;

            DataTable dt = null;

            string USERID = string.Empty;

            string year_and_month = DateTime.Now.ToString("yyyyMM");

            string session_key = string.Empty, session_info = string.Empty;

            IMAGE_URL_CLASS.IMAGE_URL_ITEM[] image_item_list = null;
            try
            {
                #region 取得參數

                data = context.GetRequest("data");

                if (String.IsNullOrEmpty(data))
                {
                    throw new Utility.ProcessException(string.Format("參數為空值"), ref code, SysCode.E004);
                }

                this.MyUtility.WriteLog(Mode.LogMode.DEBUG, context, string.Format("DATA.JSON:{0}", data));

                #endregion

                xmlDoc = JsonConvert.DeserializeXmlNode(data);

                XmlNode xmlNodeProcessInfo = xmlDoc.SelectSingleNode(xPath = string.Format("./CHANGINGTEC/PROCESS_INFO"));

                if (xmlNodeProcessInfo == null)
                {
                    throw new Utility.ProcessException(xPath, ref code, SysCode.E003);
                }

                USERID = xmlNodeProcessInfo.SelectSingleNode(string.Format("USERID"), ref code, false);

                session_key = xmlNodeProcessInfo.SelectSingleNode(string.Format("SESSION_KEY"), ref code, false);

                this.MyUtility.WriteLog(context, string.Format("SESSION_KEY:{0}", session_key));

                if (String.IsNullOrEmpty(session_key))
                {
                    year_and_month = xmlNodeProcessInfo.SelectSingleNode(string.Format("YM"), ref code);

                    this.MyUtility.CheckAndCreateTable(context, year_and_month, ref code);

                    string CHANNEL_CODE     = xmlNodeProcessInfo.SelectSingleNode(string.Format("CHANNEL_CODE"), ref code);
                    string TXN_TYPE         = xmlNodeProcessInfo.SelectSingleNode(string.Format("TXN_TYPE"), ref code);
                    string TXN_ID           = xmlNodeProcessInfo.SelectSingleNode(string.Format("TXN_ID"), ref code);
                    string REPORT_SERIAL_NO = xmlNodeProcessInfo.SelectSingleNode(string.Format("REPORT_SERIAL_NO"), ref code);
                    string GUID             = xmlNodeProcessInfo.SelectSingleNode(string.Format("GUID"), ref code);

                    this.WaitingCase(context, year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_SERIAL_NO, GUID);

                    this.MyUtility.DBLog(context, SysCode.B001, "GetImageURL", string.Empty, USERID, session_info = string.Format("{0}_{1}_{2}_{3}_{4}_{5}", year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_SERIAL_NO, GUID));

                    strSql = this.MyUtility.Select.FILE_TABLE(year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_SERIAL_NO, GUID, ref para);

                    #region SQL Debug

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    dt = this.MyUtility.DBConn.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                    if (dt.Rows.Count.Equals(0))
                    {
                        year_and_month = year_and_month.GetPreviousYM();

                        this.MyUtility.CheckAndCreateTable(context, year_and_month, ref code);

                        strSql = this.MyUtility.Select.FILE_TABLE(year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_SERIAL_NO, GUID, ref para);

                        #region SQL Debug

                        this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                        this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                        #endregion

                        dt = this.MyUtility.DBConn.GeneralSqlCmd.ExecuteToDataTable(strSql, para);
                    }
                }
                else
                {
                    year_and_month = session_key.Split('-')[0];

                    this.MyUtility.CheckAndCreateTable(context, year_and_month, ref code);

                    this.WaitingCase(context, year_and_month, session_key);

                    this.MyUtility.DBLog(context, SysCode.B001, "GetImageURL", string.Empty, USERID, session_info = string.Format("{0}_{1}", year_and_month, session_key));

                    strSql = this.MyUtility.Select.FILE_TABLE(year_and_month, session_key, ref para);

                    #region SQL Debug

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    dt = this.MyUtility.DBConn.GeneralSqlCmd.ExecuteToDataTable(strSql, para);
                }
                if (dt.Rows.Count.Equals(0))
                {
                    throw new Utility.ProcessException(string.Format("查無資料"), ref code, SysCode.E007);
                }

                this.MyUtility.DBLog(context, SysCode.A001, "GetImageURL", session_key = dt.Rows[0]["SESSION_KEY"].ToString(), USERID, string.Empty);

                this.MyUtility.WriteLog(context, string.Format("SESSION_KEY:{0}", session_key));

                DataRow[] dr_image = dt.Select(string.Format("FILE_TYPE=11"));

                this.MyUtility.WriteLog(context, string.Format("Image.Count:{0}", dr_image.Length));

                if (dr_image.Length.Equals(0))
                {
                    throw new Utility.ProcessException(string.Format("查無資料"), ref code, SysCode.E007);
                }

                image_item_list = new IMAGE_URL_CLASS.IMAGE_URL_ITEM[dr_image.Length];

                for (int i = 0; i < dr_image.Length; i++)
                {
                    session_key = dr_image[i]["SESSION_KEY"].ToString();

                    string file_id = dr_image[i]["FILE_ID"].ToString();

                    int file_seq = Convert.ToInt16(dr_image[i]["FILE_SEQ"].ToString());

                    int file_type = Convert.ToInt16(dr_image[i]["FILE_TYPE"].ToString());

                    string file_root = dr_image[i]["FILE_ROOT"].ToString();

                    string file_path = dr_image[i]["FILE_PATH"].ToString();

                    string file_full_path = file_root.FilePathCombine(file_path);

                    this.MyUtility.WriteLog(context, string.Format("AbsoluteUri:{0}", context.Request.Url.AbsoluteUri));

                    string image_url = context.Request.Url.AbsoluteUri.Replace("GetImageURL", "");

                    image_url = image_url.EndsWith("/") ? image_url.Remove(image_url.Length - 1, 1) : image_url;

                    image_url = string.Format("{0}/{1}?data={2}", image_url, "Images", string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}", file_id, file_type, year_and_month, session_key, file_full_path, file_seq.ToString(), USERID).EncryptDES());

                    this.MyUtility.WriteLog(context, string.Format("ImageUrl:{0}", image_url));

                    image_item_list[i] = new IMAGE_URL_CLASS.IMAGE_URL_ITEM()
                    {
                        FILE_ID = file_id, URL = image_url.EncryptBase64()
                    };
                }
                this.MyUtility.DBLog(context, SysCode.B000, "GetImageURL", session_key, USERID, session_info);
            }
            catch (System.Exception ex)
            {
                message = ex.Message;

                this.MyUtility.WriteLog(Mode.LogMode.ERROR, context, ex.ToString());

                code = !code.Equals(SysCode.B000) ? code : SysCode.E999;

                this.MyUtility.DBLog(context, code, "GetImageURL", session_key, USERID, ex.Message);

                this.MyUtility.SendEMail(context, "GetImageURL", session_key, code);
            }
            finally
            {
                json = JsonConvert.SerializeObject(new IMAGE_URL_RESPOSE()
                {
                    CHANGINGTEC = new IMAGE_URL_SYSTEM_CLASS()
                    {
                        SYSTEM = new IMAGE_URL_SYSTEM_INFO_CLASS()
                        {
                            //CODE = code.Equals(SysCode.B000) ? SysCode.A000.ToString() : code.Equals(SysCode.E007) ? SysCode.A003.ToString() : code.ToString(),
                            CODE      = code.Equals(SysCode.B000) ? SysCode.A000.ToString() :  code.ToString(),
                            MESSAGE   = message.EncryptBase64(),
                            CASE_INFO = new IMAGE_URL_CLASS()
                            {
                                JPG_ITEM = image_item_list
                            }
                        }
                    }
                });
                dt = null;

                xmlDoc = null;

                para = null;

                this.MyUtility.CloseConn();

                xmlDoc = null;

                GC.Collect(); GC.WaitForPendingFinalizers();

                context.Response.Write(json);
                context.Response.End();
            }
        }
コード例 #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Context"></param>
        /// <param name="YM"></param>
        /// <param name="CHANNEL_CODE"></param>
        /// <param name="TXN_TYPE"></param>
        /// <param name="TXN_ID"></param>
        /// <param name="REPORT_SERIAL_NO"></param>
        /// <param name="GUID"></param>
        private void WaitingCase(HttpContext Context, string YM, string CHANNEL_CODE, string TXN_TYPE, string TXN_ID, string REPORT_SERIAL_NO, string GUID)
        {
            SysCode code = SysCode.B000;

            List <IDataParameter> para = null;

            string year_and_month = YM, year_and_month_previous = year_and_month.GetPreviousYM();

            int count = 0;

            while (true)
            {
                if (count.Equals(0))
                {
                    this.MyUtility.CheckAndCreateTable(Context, year_and_month, ref code);
                }

                string strSql = this.MyUtility.Select.CASE_TABLE(year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_SERIAL_NO, GUID, ref para);

                #region SQL Debug

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, Context, strSql);

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, Context, para.ToLog());

                #endregion

                string case_state = this.MyUtility.DBConn.GeneralSqlCmd.ExecuteByColumnName(strSql, para, "CASE_STATE");

                this.MyUtility.WriteLog(Context, string.Format("CASE_STATE:{0},COUNT:{1}", case_state, count));

                if (String.IsNullOrEmpty(case_state))
                {
                    if (count.Equals(0))
                    {
                        this.MyUtility.CheckAndCreateTable(Context, year_and_month_previous, ref code);
                    }

                    strSql = this.MyUtility.Select.CASE_TABLE(year_and_month_previous, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_SERIAL_NO, GUID, ref para);

                    #region SQL Debug

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, Context, strSql);

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, Context, para.ToLog());

                    #endregion

                    case_state = this.MyUtility.DBConn.GeneralSqlCmd.ExecuteByColumnName(strSql, para, "CASE_STATE");

                    this.MyUtility.WriteLog(Context, string.Format("CASE_STATE:{0},COUNT:{1}", case_state, count));
                }
                if (case_state.Equals("0"))
                {
                    break;
                }

                System.Threading.Thread.Sleep(100);

                count++;
            }
            para = null;
        }
コード例 #14
0
        public void ProcessRequest(HttpContext context)
        {
            this.MyUtility.InitLog("UploadFile");

            context.Response.Clear();
            context.Response.ContentType = "application/json";

            string year_and_month = DateTime.Now.ToString("yyyyMM");

            string json = string.Empty, data = string.Empty, message = string.Empty;

            SysCode code = SysCode.A000;

            XmlDocument xmlDoc = null;

            string xPath = string.Empty, strSql = string.Empty;

            List <IDataParameter> para = null;

            DataTable dt = null;

            Dictionary <string, string> session_key = new Dictionary <string, string>();

            session_key.Add("SESSION_KEY", Guid.NewGuid().GenerateSessionKey(year_and_month));
            session_key.Add("YM", year_and_month);

            Hashtable para_data = null;

            string USERID = string.Empty;

            int result = -1;

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

            bool exists = false;

            try
            {
                #region 取得參數

                data = context.GetRequest("data");

                if (String.IsNullOrEmpty(data))
                {
                    throw new Utility.ProcessException(string.Format("參數為空值"), ref code, SysCode.E004);
                }

                this.MyUtility.WriteLog(Mode.LogMode.DEBUG, context, string.Format("DATA.JSON:{0}", data));

                #endregion

                xmlDoc = JsonConvert.DeserializeXmlNode(data);

                XmlNode xmlNodeProcessInfo = xmlDoc.SelectSingleNode(xPath = string.Format("./CHANGINGTEC/PROCESS_INFO"));

                if (xmlNodeProcessInfo == null)
                {
                    throw new Utility.ProcessException(xPath, ref code, SysCode.E003);
                }

                USERID = xmlNodeProcessInfo.SelectSingleNode(string.Format("USERID"), ref code, false);

                this.MyUtility.DBLog(context, SysCode.A001, "UploadFile", session_key["SESSION_KEY"], USERID, string.Empty);

                this.MyUtility.CheckAndCreateTable(context, year_and_month, ref code);

                #region WACH_PATH

                strSql = this.MyUtility.Select.SETTING("WACH_PATH", ref para);

                #region SQL Debug

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                #endregion

                string wach_dir_path = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteByColumnName(strSql, para, "PARAMETER");

                exists = Directory.Exists(wach_dir_path);

                this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("WACH_PATH:{0},{1}", wach_dir_path, exists));

                if (!exists)
                {
                    throw new Utility.ProcessException(string.Format("目錄不存在:{0}", wach_dir_path), ref code, SysCode.E001);
                }

                #endregion

                string FILE_EXTENSION = xmlNodeProcessInfo.SelectSingleNode(string.Format("FILE_EXTENSION"), ref code).ToLower();
                string PDF_BASE64     = xmlNodeProcessInfo.SelectSingleNode(string.Format("PDF_BASE64"), ref code);
                string INI_BASE64     = xmlNodeProcessInfo.SelectSingleNode(string.Format("INI_BASE64"), ref code, false);
                string CHANNEL_CODE   = xmlNodeProcessInfo.SelectSingleNode(string.Format("CHANNEL_CODE"), ref code);
                string TXN_TYPE       = xmlNodeProcessInfo.SelectSingleNode(string.Format("TXN_TYPE"), ref code);
                string TXN_ID         = xmlNodeProcessInfo.SelectSingleNode(string.Format("TXN_ID"), ref code);
                string REPORT_TYPE    = xmlNodeProcessInfo.SelectSingleNode(string.Format("REPORT_TYPE"), ref code);
                string GUID           = xmlNodeProcessInfo.SelectSingleNode(string.Format("GUID"), ref code);

                strSql = this.MyUtility.Select.CASE_TABLE(year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_TYPE, GUID, ref para);

                #region SQL Debug

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                #endregion

                dt = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                bool case_data_check = dt != null && dt.Rows.Count > 0;

                string case_state = string.Empty, file_path = string.Empty;

                int case_version = 1;

                if (case_data_check)
                {
                    #region 重覆件處理 (FILE_TABLE)

                    case_version = Convert.ToInt32(dt.Rows[0]["VERSION"].ToString().Trim());

                    case_state = dt.Rows[0]["CASE_STATE"].ToString().Trim();

                    if (case_state.Equals("1"))
                    {
                        throw new Utility.ProcessException(string.Format("重覆上傳"), ref code, SysCode.E008);
                    }

                    session_key["SESSION_KEY"] = dt.Rows[0]["SESSION_KEY"].ToString().Trim();

                    strSql = this.MyUtility.Select.FILE_TABLE(year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_TYPE, GUID, ref para);

                    #region SQL Debug

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    dt = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                    this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("File.Total:{0}", dt.Rows.Count));

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        delete_list.Add(dt.Rows[i]["FILE_ROOT"].ToString().FilePathCombine(dt.Rows[i]["FILE_PATH"].ToString()));
                    }
                    strSql = this.MyUtility.Delete.FILE_TABLE(year_and_month, session_key["SESSION_KEY"].ToString(), case_version.ToString(), ref para);

                    #region SQL Debug

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    result = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                    this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("Result:{0}", result));

                    #endregion
                }
                file_path = Path.Combine(wach_dir_path, string.Format("[ANEW]_{0}_{1}_{2}_{3}.{4}", year_and_month, case_version.ToString(), session_key["SESSION_KEY"].ToString(), USERID, FILE_EXTENSION));

                file_path.DeleteSigleFile();

                string ini_file_path = Path.Combine(wach_dir_path, string.Format("[ANEW]_{0}_{1}_{2}_{3}.ini", year_and_month, case_version.ToString(), session_key["SESSION_KEY"].ToString(), USERID));

                ini_file_path.DeleteSigleFile();

                if (!String.IsNullOrEmpty(INI_BASE64))
                {
                    this.MyUtility.CreateFile(ini_file_path, INI_BASE64, ref code);
                }

                para_data = new Hashtable();
                para_data.Add("SESSION_KEY", session_key["SESSION_KEY"].ToString());
                para_data.Add("CHANNEL_CODE", CHANNEL_CODE);
                para_data.Add("TXN_TYPE", TXN_TYPE);
                para_data.Add("TXN_ID", TXN_ID);
                para_data.Add("REPORT_TYPE", REPORT_TYPE);
                para_data.Add("GUID", GUID);
                para_data.Add("VERSION", case_version.ToString());
                para_data.Add("CREATE_USERID", USERID);
                para_data.Add("MODIFY_USERID", USERID);

                if (File.Exists(ini_file_path))
                {
                    #region ReadINI

                    this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("ReadINI.Start"));

                    string line = string.Empty;

                    using (StreamReader file = new StreamReader(ini_file_path, Encoding.UTF8))
                    {
                        while ((line = file.ReadLine()) != null)
                        {
                            if (line.IndexOf('=') == -1)
                            {
                                continue;
                            }

                            string[] line_temp = line.Trim().Split('=');

                            this.MyUtility.WriteLog(Mode.LogMode.DEBUG, context, line);

                            if (!para_data.ContainsKey(line_temp[0].Trim().ToUpper()))
                            {
                                para_data.Add(line_temp[0].Trim().ToUpper(), line_temp[1].Trim());
                            }
                        }
                        file.Close();
                    }
                    this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("ReadINI.End"));

                    #endregion
                }

                if (case_data_check)
                {
                    #region 重覆件處理 (CASE_TABLE)

                    strSql = this.MyUtility.Delete.CASE_TABLE(year_and_month, session_key["SESSION_KEY"].ToString(), case_version.ToString(), ref para);

                    #region SQL Debug

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    result = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                    this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("Result:{0}", result));

                    #endregion
                }
                strSql = this.MyUtility.Insert.CASE_TABLE(para_data, year_and_month, ref para);

                #region SQL Debug

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                #endregion

                result = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("Result:{0}", result));

                if (!result.Equals(1))
                {
                    throw new Utility.ProcessException(string.Format("案件資料新增失敗"), ref code, SysCode.E002);
                }

                this.MyUtility.CreateFile(file_path, PDF_BASE64, ref code);

                this.MyUtility.DBConnTransac.GeneralSqlCmd.Transaction.Commit();

                this.MyUtility.DBLog(context, SysCode.A002, "UploadFile", session_key["SESSION_KEY"], USERID, string.Empty);
                try
                {
                    foreach (string path in delete_list)
                    {
                        path.DeleteSigleFile();
                    }
                }
                catch (System.Exception ex) { this.MyUtility.WriteLog(Mode.LogMode.ERROR, context, string.Format("Delete.File.Exception::\r\n{0}", ex.ToString())); }
            }
            catch (System.Exception ex)
            {
                this.MyUtility.Rollback();

                message = ex.Message;

                this.MyUtility.WriteLog(Mode.LogMode.ERROR, context, ex.ToString());

                code = !code.Equals(SysCode.A000) ? code : SysCode.E999;

                this.MyUtility.DBLog(context, code, "UploadFile", session_key["SESSION_KEY"], USERID, ex.Message);

                this.MyUtility.SendEMail(context, "UploadFile", session_key["SESSION_KEY"], code);
            }
            finally
            {
                json = JsonConvert.SerializeObject(new UPLOAD_FILE_RESPOSE()
                {
                    CHANGINGTEC = new UPLOAD_FILE_SYSTEM_CLASS()
                    {
                        SYSTEM = new UPLOAD_FILE_SYSTEM_INFO_CLASS()
                        {
                            CODE         = code.ToString(),
                            MESSAGE      = message.EncryptBase64(),
                            PROCESS_INFO = session_key
                        }
                    }
                });
                dt = null;

                xmlDoc = null;

                session_key = null;

                para = null;

                para_data = null;

                this.MyUtility.CloseConnTransac();

                xmlDoc = null;

                GC.Collect(); GC.WaitForPendingFinalizers();

                context.Response.Write(json);
                context.Response.End();
            }
        }
コード例 #15
0
        private static SysCode DefaultSysCode = SysCode.H5;//请求端未声明SysCode时,默认为H5

        public VersionConstraint(int allowedVersion, SysCode allowedSysCode, List <VersionRange> allowedClientVersionRangeList)
        {
            AllowedVersion = allowedVersion;
            AllowedSysCode = allowedSysCode;
            AllowedClientVersionRangeList = allowedClientVersionRangeList;
        }
コード例 #16
0
 public VersionedRoute(string template, int apiVersion, SysCode allowedTags)
     : this(template, apiVersion, allowedTags, DefaultAllowedClientVersionRange)
 {
 }
コード例 #17
0
ファイル: OrderZDInfo.aspx.cs プロジェクト: kkwkk/ybyzt
    /// <summary>
    /// 复制订单
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCopy_Click(object sender, EventArgs e)
    {
        decimal TotalAmount = 0;            //订单总价
        string  LogRemark   = string.Empty; //日志备注
        int     Audit       = 0;            //是否审核

        Hi.Model.DIS_Order OrderInfoModel = null;
        try
        {
            OrderInfoModel = OrderBll.GetModel(KeyID);

            if (OrderInfoModel != null)
            {
                String guid = Guid.NewGuid().ToString().Replace("-", "");
                OrderInfoModel.GUID      = guid;
                OrderInfoModel.ReceiptNo = SysCode.GetNewCode("销售单");

                Audit = OrderInfoType.OrderEnAudit((int)Enums.AddType.网页下单, OrderInfoModel.DisID, OrderInfoModel.Otype);
                OrderInfoModel.IsAudit = Audit;

                //收货地址
                Hi.Model.BD_DisAddr DisAddr = new Hi.BLL.BD_DisAddr().GetModel(OrderInfoModel.AddrID);
                if (DisAddr != null)
                {
                    OrderInfoModel.AddrID    = OrderInfoModel.AddrID;
                    OrderInfoModel.Principal = DisAddr.Principal;
                    OrderInfoModel.Phone     = DisAddr.Phone;
                    OrderInfoModel.Address   = DisAddr.Address;
                }

                OrderInfoModel.PayState     = (int)Enums.PayState.未支付;
                OrderInfoModel.OState       = (int)Enums.OrderState.未提交;
                OrderInfoModel.PayedAmount  = 0;
                OrderInfoModel.ReturnState  = 0;
                OrderInfoModel.ArriveDate   = DateTime.MinValue;
                OrderInfoModel.DisUserID    = this.UserID;
                OrderInfoModel.CreateUserID = this.UserID;
                OrderInfoModel.CreateDate   = DateTime.Now;

                OrderInfoModel.AuditUserID       = 0;
                OrderInfoModel.AuditDate         = DateTime.MinValue;
                OrderInfoModel.AuditRemark       = "";
                OrderInfoModel.ReturnMoneyDate   = DateTime.MinValue;
                OrderInfoModel.ReturnMoneyUserId = 0;
                OrderInfoModel.ReturnMoneyUser   = "";
                OrderInfoModel.ts         = DateTime.Now;
                OrderInfoModel.dr         = 0;
                OrderInfoModel.modifyuser = 0;

                //订单商品明细
                List <Hi.Model.DIS_OrderDetail> l = OrderDetailBll.GetList("", " OrderId=" + KeyID, "");

                List <Hi.Model.DIS_OrderDetail> dl = new List <Hi.Model.DIS_OrderDetail>();

                foreach (Hi.Model.DIS_OrderDetail item in l)
                {
                    //获取商品最新价格
                    decimal Price = SelectGoods.GoodsNewPrice(item.GoodsinfoID, this.DisID, CompID);
                    item.Price       = Price;
                    item.AuditAmount = Price;
                    item.sumAmount   = Price * item.GoodsNum;

                    TotalAmount += item.sumAmount;

                    item.ts         = DateTime.Now;
                    item.dr         = 0;
                    item.modifyuser = 0;

                    dl.Add(item);
                }
                OrderInfoModel.TotalAmount = TotalAmount;
                OrderInfoModel.AuditAmount = TotalAmount;
                //OrderInfoModel.OtherAmount = 0;
                LogRemark += " 下单总价:" + TotalAmount.ToString("N");
                int OrderId = OrderInfoType.TansOrder(OrderInfoModel, dl);

                if (OrderId > 0)
                {
                    Utils.AddSysBusinessLog(this.CompID, "Order", OrderId.ToString(), "订单新增", LogRemark);
                    JScript.AlertMethod(this, "复制成功", JScript.IconOption.正确, "function (){ location.replace('" + ("neworder/orderdetail.aspx?KeyID=" + Common.DesEncrypt(OrderId.ToString(), Common.EncryptKey)) + "'); }");
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
コード例 #18
0
 public VersionedRoute(string template, SysCode allowedTags, params string[] allowedClientVersionRangeString)
     : this(template, DefaultAllowedApiVersion, DefaultAllowedSysCode, allowedClientVersionRangeString)
 {
 }
コード例 #19
0
 public H5ResponseViewModel(SysCode sysCode, T data)
 {
     Code      = (int)sysCode;
     Message   = EnumExtention.GetDescription(sysCode);
     this.data = data;
 }
コード例 #20
0
        public void ProcessRequest(HttpContext context)
        {
            this.MyUtility.InitLog("UpdateState");

            context.Response.Clear();
            context.Response.ContentType = "application/json";

            string json = string.Empty, data = string.Empty, message = string.Empty;

            SysCode code = SysCode.A000;

            XmlDocument xmlDoc = null;

            string xPath = string.Empty, strSql = string.Empty;

            List <IDataParameter> para = null;

            DataTable dt = null;

            string USERID = string.Empty;

            string year_and_month = DateTime.Now.ToString("yyyyMM");

            string session_key = string.Empty;

            int result = -1;

            try
            {
                #region 取得參數

                data = context.GetRequest("data");

                if (String.IsNullOrEmpty(data))
                {
                    throw new Utility.ProcessException(string.Format("參數為空值"), ref code, SysCode.E004);
                }

                this.MyUtility.WriteLog(Mode.LogMode.DEBUG, context, string.Format("DATA.JSON:{0}", data));

                #endregion

                xmlDoc = JsonConvert.DeserializeXmlNode(data);

                XmlNode xmlNodeProcessInfo = xmlDoc.SelectSingleNode(xPath = string.Format("./CHANGINGTEC/PROCESS_INFO"));

                if (xmlNodeProcessInfo == null)
                {
                    throw new Utility.ProcessException(xPath, ref code, SysCode.E003);
                }

                USERID = xmlNodeProcessInfo.SelectSingleNode(string.Format("USERID"), ref code, false);

                year_and_month = xmlNodeProcessInfo.SelectSingleNode(string.Format("YM"), ref code);

                string CHANNEL_CODE     = xmlNodeProcessInfo.SelectSingleNode(string.Format("CHANNEL_CODE"), ref code);
                string TXN_TYPE         = xmlNodeProcessInfo.SelectSingleNode(string.Format("TXN_TYPE"), ref code);
                string TXN_ID           = xmlNodeProcessInfo.SelectSingleNode(string.Format("TXN_ID"), ref code);
                string REPORT_SERIAL_NO = xmlNodeProcessInfo.SelectSingleNode(string.Format("REPORT_SERIAL_NO"), ref code);
                string GUID             = xmlNodeProcessInfo.SelectSingleNode(string.Format("GUID"), ref code);

                string TRANS_STATE     = xmlNodeProcessInfo.SelectSingleNode(string.Format("TRANS_STATE"), ref code);
                string CHARGE          = xmlNodeProcessInfo.SelectSingleNode(string.Format("CHARGE"), ref code);
                string CHARGE_DATE     = DateTime.Parse(xmlNodeProcessInfo.SelectSingleNode(string.Format("CHARGE_DATE"), ref code)).ToString("yyyy/MM/dd HH:mm:ss");
                string SUPERVISOR      = xmlNodeProcessInfo.SelectSingleNode(string.Format("SUPERVISOR"), ref code);
                string SUPERVISOR_DATE = DateTime.Parse(xmlNodeProcessInfo.SelectSingleNode(string.Format("SUPERVISOR_DATE"), ref code)).ToString("yyyy/MM/dd HH:mm:ss");

                this.MyUtility.CheckAndCreateTable(context, year_and_month, ref code);

                strSql = this.MyUtility.Select.CASE_TABLE(year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_SERIAL_NO, GUID, ref para);

                #region SQL Debug

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                #endregion

                dt = this.MyUtility.DBConn.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                if (dt.Rows.Count.Equals(0))
                {
                    throw new Utility.ProcessException(string.Format("查詢資料不存在"), ref code, SysCode.E007);
                }

                bool is_delete = TRANS_STATE.Trim().ToUpper().Equals("AF") || TRANS_STATE.Trim().ToUpper().Equals("AG");

                session_key = dt.Rows[0]["SESSION_KEY"].ToString().Trim();

                string case_state = dt.Rows[0]["CASE_STATE"].ToString().Trim();

                string case_version = dt.Rows[0]["VERSION"].ToString().Trim();

                strSql = this.MyUtility.Update.CASE_TABLE_TRANSSTATE(year_and_month
                                                                     , TRANS_STATE
                                                                     , CHARGE
                                                                     , CHARGE_DATE
                                                                     , SUPERVISOR
                                                                     , SUPERVISOR_DATE
                                                                     , is_delete ? "99" : case_state
                                                                     , USERID
                                                                     , CHANNEL_CODE
                                                                     , TXN_TYPE
                                                                     , TXN_ID
                                                                     , REPORT_SERIAL_NO
                                                                     , GUID
                                                                     , ref para);

                #region SQL Debug

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                #endregion

                result = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("Result:{0}", result));

                if (!result.Equals(1))
                {
                    throw new Utility.ProcessException(string.Format("案件狀態變更失敗"), ref code, SysCode.E002);
                }

                if (is_delete)
                {
                    strSql = this.MyUtility.Update.FILE_TABLE_STOP(year_and_month, session_key, case_version, ref para);

                    #region SQL Debug

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    result = this.MyUtility.DBConn.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                    this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("Result:{0}", result));

                    if (result.Equals(0))
                    {
                        throw new Utility.ProcessException(string.Format("檔案刪除失敗"), ref code, SysCode.E002);
                    }
                }
                this.MyUtility.DBLog(context, code, "UpdateState", session_key, USERID, string.Empty);
            }
            catch (System.Exception ex)
            {
                message = ex.Message;

                this.MyUtility.WriteLog(Mode.LogMode.ERROR, context, ex.ToString());

                code = !code.Equals(SysCode.A000) ? code : SysCode.E999;

                this.MyUtility.DBLog(context, code, "UpdateState", session_key, string.Empty, ex.Message);

                this.MyUtility.SendEMail(context, "UpdateState", session_key, code);
            }
            finally
            {
                json = JsonConvert.SerializeObject(new UPLOAD_STATE_RESPOSE()
                {
                    CHANGINGTEC = new UPLOAD_STATE_SYSTEM_CLASS()
                    {
                        SYSTEM = new SYSTEM_INFO_CLASS()
                        {
                            CODE    = code.ToString(),
                            MESSAGE = message.EncryptBase64()
                        }
                    }
                });
                dt = null;

                xmlDoc = null;

                para = null;

                this.MyUtility.CloseConn();

                xmlDoc = null;

                GC.Collect(); GC.WaitForPendingFinalizers();

                context.Response.Write(json);
                context.Response.End();
            }
        }
コード例 #21
0
ファイル: OrderZdtsAdd.aspx.cs プロジェクト: kkwkk/ybyzt
    /// <summary>
    /// 生成订单
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string  ReceiptNo   = string.Empty;
        string  Otype       = string.Empty;
        string  ArriveDate  = string.Empty;
        decimal TotalAmount = 0;
        decimal OtherAmount = 0;
        string  DisUser     = string.Empty;
        string  DisUserId   = string.Empty;
        string  LogRemark   = string.Empty; //日志备注

        string Remark = string.Empty;
        string str    = string.Empty;

        if (this.DisListID.Disid == "")
        {
            str += " - 代理商不能为空。\\r\\n";
        }
        if (this.txtunit.Value == "")
        {
            str += " - 费用名称不能为空。\\r\\n";
        }
        if (this.txtOtherAmount.Value.ToDecimal(0) <= 0)
        {
            str += " - 账单金额不能为0。\\r\\n";
        }

        if (this.txtRemark.Value != "")
        {
            Remark = Common.NoHTML(this.txtRemark.Value.Trim().ToString());
            if (Remark.Length > 400)
            {
                str += " - 账单备注不能大于400个字符。\\r\\n";
            }
        }

        if (str != "")
        {
            JScript.AlertMsgOne(this, str, JScript.IconOption.错误, 2500);
            return;
        }

        try
        {
            Hi.Model.DIS_Order OrderInfoModel = null;
            DisId = Convert.ToInt32(this.DisListID.Disid);

            decimal Amount = Convert.ToDecimal(this.txtOtherAmount.Value);
            TotalAmount = Amount;

            if (this.txtArriveDate.Value.Trim() != "")
            {
                ArriveDate = Common.NoHTML(this.txtArriveDate.Value.Trim().ToString());
            }
            else
            {
                ArriveDate = DateTime.MinValue.ToString();
            }
            DisUser   = Common.NoHTML(this.txtDisUser.InnerText.Trim().ToString());
            DisUserId = Common.NoHTML(this.hidDisUserId.Value.Trim().ToString());

            OrderInfoModel = OrderInfoBll.GetModel(KeyID);

            LogRemark += " 账单总价:" + Amount.ToString("N");



            #region 新增订单

            //新增订单
            String guid = Guid.NewGuid().ToString().Replace("-", "");

            ReceiptNo = SysCode.GetZD_NewCode("账单", 1);

            OrderInfoModel = new Hi.Model.DIS_Order();

            OrderInfoModel.GUID      = guid;
            OrderInfoModel.CompID    = this.CompID;
            OrderInfoModel.DisID     = DisId;
            OrderInfoModel.ReceiptNo = ReceiptNo;


            int OState = 1;

            //无需审核
            OState = (int)Enums.OrderState.已审;
            OrderInfoModel.IsAudit = 1;

            OrderInfoModel.OState       = OState;
            OrderInfoModel.Remark       = Remark;
            OrderInfoModel.CreateUserID = this.UserID;
            OrderInfoModel.CreateDate   = DateTime.Now;

            //总价
            OrderInfoModel.TotalAmount = TotalAmount;
            OrderInfoModel.AuditAmount = TotalAmount;
            OrderInfoModel.OtherAmount = OtherAmount;

            OrderInfoModel.ArriveDate = ArriveDate.ToDateTime();
            OrderInfoModel.DisUserID  = DisUserId.ToInt(0);

            OrderInfoModel.Otype   = (int)Enums.OType.推送账单;
            OrderInfoModel.AddType = (int)Enums.AddType.网页下单;

            OrderInfoModel.ts = DateTime.Now;
            //OrderInfoModel.vdef9 = "0";

            OrderInfoModel.vdef2 = this.txtunit.Value.Trim();//费用科目



            int OrderId = new Hi.BLL.DIS_Order().Add(OrderInfoModel);

            if (OrderId > 0)
            {
                Utils.AddSysBusinessLog(this.CompID, "Order", OrderId.ToString(), "账单新增", LogRemark);

                //代理商手机号
                string Phone = Common.GetDis(DisId, "Phone");
                string msg   = "您的账单:" + ReceiptNo + "已经生成," + this.txtunit.Value.Trim() + ":" + TotalAmount + "元,请尽快完成付款![ " + Common.GetCompValue(CompID, "CompName") + " ]";

                //账单推送向代理商推送信息提示
                Common.GetPhone(Phone, msg);

                string Id = Common.DesEncrypt(OrderId.ToString(), Common.EncryptKey);

                ClientScript.RegisterStartupScript(this.GetType(), "add", "<script>window.location.href ='OrderZdtsInfo.aspx?KeyID=" + Id + "';</script>");
            }

            #endregion
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
コード例 #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        try
        {
            //模块权限。
            SysCodeType sct = SysCodeTypeSrv.GetSysCodeTypeByTag("rights");

            StringBuilder sb = new StringBuilder();

            if (Request.QueryString["mode"] == "new")
            {
                divTitleMess.InnerText = "新增模块";

                if (sct != null)
                {
                    for (int i = 0; i < sct.SysCodes.Count; i++)
                    {
                        SysCode sc = sct.SysCodes[i] as SysCode;
                        sb.Append("<div><input type=checkbox id='" + sc.Tag + "' />" + sc.Name + "</div>");
                    }
                    divRights.InnerHtml = sb.ToString();
                }
            }
            else if (Request.QueryString["mode"] == "edit")
            {
                divTitleMess.InnerText = "编辑模块";

                string id = Request.QueryString["id"];
                if (id != null)
                {
                    Module m = CommonSrv.LoadObjectById(typeof(Module), id) as Module;
                    txtModuleTag.Value       = m.Tag;
                    txtModuleName.Value      = m.Name;
                    txtModuleOrderId.Value   = m.OrderId.ToString();
                    txtaModuleRemark.Value   = m.Remark;
                    txtModuleModuleUrl.Value = m.ModuleUrl;
                    cbModuleDisabled.Checked = (m.Disabled == 1);

                    if (sct != null)
                    {
                        for (int i = 0; i < sct.SysCodes.Count; i++)
                        {
                            SysCode sc = sct.SysCodes[i] as SysCode;
                            if (m.ModuleRights.Contains(sc.Tag))
                            {
                                sb.Append("<div><input type=checkbox checked id='" + sc.Tag + "' />" + sc.Name + "</div>");
                            }
                            else
                            {
                                sb.Append("<div><input type=checkbox id='" + sc.Tag + "' />" + sc.Name + "</div>");
                            }
                        }
                        divRights.InnerHtml = sb.ToString();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "<script type=\"text/javascript\">error=true;</script>");
            log.Error(null, ex);
        }
    }
コード例 #23
0
 public async Task <ApiResult <string> > Add([FromBody] SysCode model) => await _sysCodeService.Add(model);
コード例 #24
0
 public int Insert(SysCode sc)
 {
     return(db.Insert <SysCode>(sc));
 }
コード例 #25
0
 public async Task <ApiResult <string> > AddCodeType(SysCode parm)
 {
     return(await _sysCodeService.AddAsync(parm));
 }
コード例 #26
0
 public int Update(SysCode sc)
 {
     return(db.Update <SysCode>(sc));
 }
コード例 #27
0
        public void ProcessRequest(HttpContext context)
        {
            this.MyUtility.InitLog("T24UpdateTransState");

            context.Response.Clear();
            context.Response.ContentType = "application/json";

            string json = string.Empty, data = string.Empty, message = string.Empty;

            SysCode code = SysCode.A000;

            XmlDocument xmlDoc = null;

            string xPath = string.Empty, strSql = string.Empty;

            List <IDataParameter> para = null;

            string USERID = string.Empty, SESSION_KEY = string.Empty, TRANS_STATE = string.Empty;

            string year_and_month = DateTime.Now.ToString("yyyyMM");

            DataTable dt = null;

            int result = -1;

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

            try
            {
                #region 取得參數

                data = context.GetRequest("data");

                if (String.IsNullOrEmpty(data))
                {
                    throw new Utility.ProcessException(string.Format("參數為空值"), ref code, SysCode.E004);
                }

                this.MyUtility.WriteLog(Mode.LogMode.DEBUG, context, string.Format("DATA.JSON:{0}", data));

                #endregion

                xmlDoc = JsonConvert.DeserializeXmlNode(data);

                XmlNode xmlNodeProcessInfo = xmlDoc.SelectSingleNode(xPath = string.Format("./CHANGINGTEC/PROCESS_INFO"));

                if (xmlNodeProcessInfo == null)
                {
                    throw new Utility.ProcessException(xPath, ref code, SysCode.E003);
                }

                SESSION_KEY = xmlNodeProcessInfo.SelectSingleNode("SESSION_KEY", ref code);

                TRANS_STATE = xmlNodeProcessInfo.SelectSingleNode("TRANS_STATE", ref code);

                this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("SESSION_KEY:{0}", SESSION_KEY));

                this.MyUtility.DBLog(context, SysCode.A001, "T24UpdateTransState", SESSION_KEY, USERID, string.Empty);

                bool is_delete = TRANS_STATE.Trim().ToUpper().Equals("DELE");

                this.MyUtility.CheckAndCreateTable(context, year_and_month, ref code);

                strSql = this.MyUtility.Select.CASE_TABLE_T24_Trans(year_and_month, SESSION_KEY, ref para);

                #region SQL Debug

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                #endregion

                dt = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("dt.Rows.Count:{0}", dt.Rows.Count.ToString()));

                bool case_data_check = dt != null && dt.Rows.Count > 0;

                if (!case_data_check)
                {
                    year_and_month = year_and_month.GetPreviousYM();

                    strSql = this.MyUtility.Select.CASE_TABLE_T24_Trans(year_and_month, SESSION_KEY, ref para);

                    #region SQL Debug

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    dt = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                    case_data_check = dt != null && dt.Rows.Count > 0;
                }
                if (!case_data_check)
                {
                    throw new Utility.ProcessException(string.Format("查詢資料不存在"), ref code, SysCode.E007);
                }

                if (is_delete)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["CASE_STATE"].ToString() == "0")
                        {
                            strSql = this.MyUtility.Update.FILE_TABLE_STOP(year_and_month, dt.Rows[i]["SESSION_KEY"].ToString(), ref para);

                            #region SQL Debug

                            this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                            this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                            #endregion

                            result = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                            this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("Result:{0}", result));
                        }
                    }
                }
                this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("TRANS_STATE:{0}", TRANS_STATE));

                strSql = this.MyUtility.Update.CASE_TABLE_T24_TRANS_STATE_Trans(year_and_month, SESSION_KEY, TRANS_STATE.ToUpper(), USERID, ref para);

                #region SQL Debug

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                #endregion

                result = this.MyUtility.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                this.MyUtility.WriteLog(Mode.LogMode.INFO, context, string.Format("Result:{0}", result));

                this.MyUtility.DBConnTransac.GeneralSqlCmd.Transaction.Commit();

                this.MyUtility.DBLog(context, SysCode.A002, "T24UpdateTransState", SESSION_KEY, USERID, string.Empty);
            }
            catch (System.Exception ex)
            {
                this.MyUtility.Rollback();

                message = ex.Message;

                this.MyUtility.WriteLog(Mode.LogMode.ERROR, context, ex.ToString());

                code = !code.Equals(SysCode.A000) ? code : SysCode.E999;

                this.MyUtility.DBLog(context, code, "T24UpdateTransState", SESSION_KEY, USERID, ex.Message);

                this.MyUtility.SendEMail(context, "T24UpdateTransState", SESSION_KEY, code);
            }
            finally
            {
                json = JsonConvert.SerializeObject(new T24UPDATE_STATE_RESPOSE_RESPOSE()
                {
                    CHANGINGTEC = new T24UPDATE_STATE_RESPOSE_SYSTEM_CLASS()
                    {
                        SYSTEM = new SYSTEM_INFO_CLASS()
                        {
                            CODE    = code.ToString(),
                            MESSAGE = message.EncryptBase64()
                        }
                    }
                });
                dt = null;

                xmlDoc = null;

                para = null;

                this.MyUtility.CloseConnTransac();

                xmlDoc = null;

                GC.Collect(); GC.WaitForPendingFinalizers();

                context.Response.Write(json);
                context.Response.End();
            }
        }
コード例 #28
0
 public int Delete(SysCode sc)
 {
     return(db.Delete <SysCode>(sc));
 }
コード例 #29
0
        public void ProcessRequest(HttpContext context)
        {
            this.MyUtility.InitLog("GetPDFBase64");

            context.Response.Clear();
            context.Response.ContentType = "application/json";

            string json = string.Empty, data = string.Empty, message = string.Empty;

            SysCode code = SysCode.B000;

            XmlDocument xmlDoc = null;

            string xPath = string.Empty, strSql = string.Empty;

            List <IDataParameter> para = null;

            DataTable dt = null;

            string USERID = string.Empty;

            string year_and_month = string.Empty;

            string session_key = string.Empty, session_info = string.Empty;

            PDF_BASE64_CLASS.PDF_BASE64_ITEM pdf_info_item = new PDF_BASE64_CLASS.PDF_BASE64_ITEM();
            try
            {
                #region 取得參數

                data = context.GetRequest("data");

                if (String.IsNullOrEmpty(data))
                {
                    throw new Utility.ProcessException(string.Format("參數為空值"), ref code, SysCode.E004);
                }

                this.MyUtility.WriteLog(Mode.LogMode.DEBUG, context, string.Format("DATA.JSON:{0}", data));

                #endregion

                xmlDoc = JsonConvert.DeserializeXmlNode(data);

                XmlNode xmlNodeProcessInfo = xmlDoc.SelectSingleNode(xPath = string.Format("./CHANGINGTEC/PROCESS_INFO"));

                if (xmlNodeProcessInfo == null)
                {
                    throw new Utility.ProcessException(xPath, ref code, SysCode.E003);
                }

                USERID = xmlNodeProcessInfo.SelectSingleNode(string.Format("USERID"), ref code, false);

                session_key = xmlNodeProcessInfo.SelectSingleNode(string.Format("SESSION_KEY"), ref code, false);

                this.MyUtility.WriteLog(context, string.Format("SESSION_KEY:{0}", session_key));

                if (String.IsNullOrEmpty(session_key))
                {
                    year_and_month = xmlNodeProcessInfo.SelectSingleNode(string.Format("YM"), ref code);

                    this.MyUtility.CheckAndCreateTable(context, year_and_month, ref code);

                    string CHANNEL_CODE     = xmlNodeProcessInfo.SelectSingleNode(string.Format("CHANNEL_CODE"), ref code);
                    string TXN_TYPE         = xmlNodeProcessInfo.SelectSingleNode(string.Format("TXN_TYPE"), ref code);
                    string TXN_ID           = xmlNodeProcessInfo.SelectSingleNode(string.Format("TXN_ID"), ref code);
                    string REPORT_SERIAL_NO = xmlNodeProcessInfo.SelectSingleNode(string.Format("REPORT_SERIAL_NO"), ref code);
                    string GUID             = xmlNodeProcessInfo.SelectSingleNode(string.Format("GUID"), ref code);

                    this.MyUtility.DBLog(context, SysCode.B001, "GetPDFBase64", string.Empty, USERID, session_info = string.Format("{0}_{1}_{2}_{3}_{4}_{5}", year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_SERIAL_NO, GUID));

                    strSql = this.MyUtility.Select.FILE_TABLE(year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_SERIAL_NO, GUID, ref para);

                    #region SQL Debug

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    dt = this.MyUtility.DBConn.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                    if (dt.Rows.Count.Equals(0))
                    {
                        year_and_month = year_and_month.GetPreviousYM();

                        this.MyUtility.CheckAndCreateTable(context, year_and_month, ref code);

                        strSql = this.MyUtility.Select.FILE_TABLE(year_and_month, CHANNEL_CODE, TXN_TYPE, TXN_ID, REPORT_SERIAL_NO, GUID, ref para);

                        #region SQL Debug

                        this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                        this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                        #endregion

                        dt = this.MyUtility.DBConn.GeneralSqlCmd.ExecuteToDataTable(strSql, para);
                    }
                }
                else
                {
                    year_and_month = session_key.Split('-')[0];

                    this.MyUtility.CheckAndCreateTable(context, year_and_month, ref code);

                    this.MyUtility.DBLog(context, SysCode.B001, "GetPDFBase64", string.Empty, USERID, session_info = string.Format("{0}_{1}", year_and_month, session_key));

                    strSql = this.MyUtility.Select.FILE_TABLE(year_and_month, session_key, ref para);

                    #region SQL Debug

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, strSql);

                    this.MyUtility.WriteLog(Log.Mode.LogMode.DEBUG, context, para.ToLog());

                    #endregion

                    dt = this.MyUtility.DBConn.GeneralSqlCmd.ExecuteToDataTable(strSql, para);
                }
                if (dt.Rows.Count.Equals(0))
                {
                    throw new Utility.ProcessException(string.Format("查無資料"), ref code, SysCode.E007);
                }

                this.MyUtility.DBLog(context, SysCode.A001, "GetPDFBase64", session_key = dt.Rows[0]["SESSION_KEY"].ToString(), USERID, string.Empty);

                this.MyUtility.WriteLog(context, string.Format("SESSION_KEY:{0}", session_key));

                DataRow[] dr_pdf = dt.Select(string.Format("FILE_TYPE=1"));

                string file_id = string.Empty, file_full_path = string.Empty, file_root = string.Empty, file_path = string.Empty;

                bool exists = false;

                this.MyUtility.WriteLog(context, string.Format("PDF.Count:{0}", dr_pdf.Length));

                if (dr_pdf.Length > 0)
                {
                    file_root      = dr_pdf[0]["FILE_ROOT"].ToString();
                    file_path      = dr_pdf[0]["FILE_PATH"].ToString();
                    file_id        = dr_pdf[0]["FILE_ID"].ToString();
                    file_full_path = file_root.FilePathCombine(file_path);

                    exists = File.Exists(file_full_path);

                    this.MyUtility.WriteLog(context, string.Format("{0},{1},{2}", file_id, file_full_path, exists));
                }

                if (!exists)
                {
                    DataRow[] dr_file = dt.Select(string.Format("FILE_TYPE=3"));

                    this.MyUtility.WriteLog(context, string.Format("File.Count:{0}", dr_file.Length));

                    if (dr_file.Length.Equals(0))
                    {
                        file_root      = dr_file[0]["FILE_ROOT"].ToString();
                        file_path      = dr_file[0]["FILE_PATH"].ToString();
                        file_id        = dr_file[0]["FILE_ID"].ToString();
                        file_full_path = file_root.FilePathCombine(file_path);

                        exists = File.Exists(file_full_path);

                        this.MyUtility.WriteLog(context, string.Format("{0},{1},{2}", file_id, file_full_path, exists));
                    }
                }
                if (!File.Exists(file_full_path))
                {
                    throw new Utility.ProcessException(string.Format("檔案不存在"), ref code, SysCode.E006);
                }

                pdf_info_item.FILE_ID = file_id;

                pdf_info_item.BODY = file_full_path.FileSerialize();

                this.MyUtility.DBLog(context, SysCode.B000, "GetPDFBase64", session_key, USERID, session_info);
            }
            catch (System.Exception ex)
            {
                message = ex.Message;

                this.MyUtility.WriteLog(Mode.LogMode.ERROR, context, ex.ToString());

                code = !code.Equals(SysCode.B000) ? code : SysCode.E999;

                this.MyUtility.DBLog(context, code, "GetPDFBase64", session_key, USERID, ex.Message);

                this.MyUtility.SendEMail(context, "GetPDFBase64", session_key, code);
            }
            finally
            {
                json = JsonConvert.SerializeObject(new PDF_BASE64_RESPOSE()
                {
                    CHANGINGTEC = new PDF_BASE64_SYSTEM_CLASS()
                    {
                        SYSTEM = new PDF_BASE64_SYSTEM_INFO_CLASS()
                        {
                            //CODE = code.Equals(SysCode.B000) ? SysCode.A000.ToString() : code.Equals(SysCode.E007) ? SysCode.A003.ToString() : code.ToString(),
                            CODE      = code.Equals(SysCode.B000) ? SysCode.A000.ToString() : code.ToString(),
                            MESSAGE   = message.EncryptBase64(),
                            CASE_INFO = new PDF_BASE64_CLASS()
                            {
                                PDF_ITEM = pdf_info_item
                            }
                        }
                    }
                });
                dt = null;

                xmlDoc = null;

                para = null;

                this.MyUtility.CloseConn();

                xmlDoc = null;

                GC.Collect(); GC.WaitForPendingFinalizers();

                context.Response.Write(json);
                context.Response.End();
            }
        }
コード例 #30
0
 public int Delete(SysCode sc)
 {
     return(dsc.Delete(sc));
 }