Пример #1
0
        /// <summary>
        /// 修改記錄詳情
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase VendorChangeDetailList()
        {
            string json = "{success:false,data:0}";
            try
            {
                TableChangeLogQuery query = new TableChangeLogQuery();
                query.change_table = "vendor";

                if (!string.IsNullOrEmpty(Request.Params["vendor_id"]))
                {
                    query.pk_id = Convert.ToInt32(Request.Params["vendor_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["muser"]))
                {
                    query.create_user = Convert.ToInt32(Request.Params["muser"]);
                }

                if (!string.IsNullOrEmpty(Request.Params["mdate"]))
                {
                    query.create_time = Convert.ToDateTime(Request.Params["mdate"]);
                }
                TableChangeLogMgr _tclMgr = new TableChangeLogMgr(connectionString);
                BLL.gigade.Model.Custom.TableChangeLogCustom store = _tclMgr.GetVendorChangeDetail(query);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據
            }
            catch (Exception ex)
            {

                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);

            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Пример #2
0
        /// <summary>
        /// 異動記錄匯出
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase VendorLogExport()
        {
            string newCsvName = string.Empty;
            string json = string.Empty;

            TableChangeLogQuery query = new TableChangeLogQuery();
            query.change_table = "vendor";


            if (!string.IsNullOrEmpty(Request.Params["ven_type"]))
            {
                query.key_type = Convert.ToInt32(Request.Params["ven_type"]);
            }
            if (!string.IsNullOrEmpty(Request.Params["d_type"]))
            {
                query.d_type = Convert.ToInt32(Request.Params["d_type"]);
            }
            if (!string.IsNullOrEmpty(Request.Params["search_con"]))
            {
                query.key = Request.Params["search_con"].ToString();
            }
            if (!string.IsNullOrEmpty(Request.Params["date_one"]))
            {
                query.date_one = Convert.ToDateTime(Request.Params["date_one"]);
                // query.date_one = Convert.ToDateTime(query.date_one.ToString("yyyy-MM-dd 00:00:00"));
            }
            if (!string.IsNullOrEmpty(Request.Params["date_two"]))
            {
                query.date_two = Convert.ToDateTime(Request.Params["date_two"]);
                // query.date_two = Convert.ToDateTime(query.date_two.ToString("yyyy-MM-dd 23:59:59"));
            }
            TableChangeLogMgr _tclMgr = new TableChangeLogMgr(connectionString);
            DataTable dt = _tclMgr.VendorLogExport(query);

            try
            {

                string filename = "供應商資料異動記錄_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv";
                if (!System.IO.Directory.Exists(Server.MapPath(excelPath)))
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath(excelPath));
                }
                newCsvName = Server.MapPath(excelPath) + filename;

                if (System.IO.File.Exists(newCsvName))
                {
                    //設置文件的屬性,以防刪除文件的時候因為文件的屬性造成無法刪除
                    System.IO.File.SetAttributes(newCsvName, FileAttributes.Normal);
                    System.IO.File.Delete(newCsvName);
                }
                string[] colname = { "供應商編號", "供應商編碼", "供應商名稱", "建立人", "建立時間", "修改人", "修改時間", "變動欄位", "欄位中文名", "修改前值", "修改后值" };
                CsvHelper.ExportDataTableToCsv(dt, newCsvName, colname, true);
                json = "true," + filename + "," + excelPath;

            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "false, ";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Пример #3
0
        /// <summary>
        /// 修改記錄
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase VendorChangeList()
        {
            string json = "{success:false,data:0}";
            try
            {
                TableChangeLogQuery query = new TableChangeLogQuery();
                query.change_table = "vendor";
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量

                if (!string.IsNullOrEmpty(Request.Params["ven_type"]))
                {
                    query.key_type = Convert.ToInt32(Request.Params["ven_type"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["d_type"]))
                {
                    query.d_type = Convert.ToInt32(Request.Params["d_type"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["search_con"]))
                {
                    query.key = Request.Params["search_con"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["date_one"]))
                {
                    query.date_one = Convert.ToDateTime(Request.Params["date_one"]);
                    // query.date_one = Convert.ToDateTime(query.date_one.ToString("yyyy-MM-dd 00:00:00"));
                }
                if (!string.IsNullOrEmpty(Request.Params["date_two"]))
                {
                    query.date_two = Convert.ToDateTime(Request.Params["date_two"]);
                    //query.date_two = Convert.ToDateTime(query.date_two.ToString("yyyy-MM-dd 23:59:59"));

                }
                // query.IsPage = false;
                TableChangeLogMgr _tclMgr = new TableChangeLogMgr(connectionString);
                int totalCount = 0;
                DataTable store = _tclMgr.GetVendorChangeLog(query, out totalCount);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據
            }
            catch (Exception ex)
            {

                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);

            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }