public HttpResponseBase ProductUp() { string json = "{success:true}"; BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor; _prodVdReq = new ProdVdReqMgr(connectionString); _productMgr = new ProductMgr(connectionString); try { if (!string.IsNullOrEmpty(Request.Form["Product_Id"])) { string[] pro_Ids = Request.Form["Product_Id"].Split('|'); foreach (string str in pro_Ids.Distinct()) { if (!string.IsNullOrEmpty(str)) { uint product_id = uint.Parse(str); Product pro = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault(); if (pro != null && pro.Product_Status != 5) { ProdVdReqQuery prodQuery = new ProdVdReqQuery(); prodQuery.vendor_id = Convert.ToInt32(vendor.vendor_id); prodQuery.product_id = Convert.ToInt32(product_id); prodQuery.req_status = 1; int totalCount = 0; ProdVdReq prodRquery = _prodVdReq.QueryProdVdReqList(prodQuery, out totalCount).FirstOrDefault(); if (prodRquery == null) { prodRquery = new ProdVdReq(); prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id); prodRquery.product_id = Convert.ToInt32(product_id); prodRquery.req_status = 1; prodRquery.req_datatime = DateTime.Now; prodRquery.req_type = 1; if (_prodVdReq.Insert(prodRquery) < 0) { json = "{success:false,msg:0}";//返回json數據 } } else { prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id); prodRquery.product_id = Convert.ToInt32(product_id); prodRquery.req_status = 1; prodRquery.req_datatime = DateTime.Now; prodRquery.req_type = 1; if (_prodVdReq.Update(prodRquery) < 0) { json = "{success:false,msg:0}";//返回json數據 } } } } } } //json = "{success:true}"; } 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 = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase ProductDown() { string json = "{success:true}"; _prodVdReq = new ProdVdReqMgr(connectionString); _productMgr = new ProductMgr(connectionString); try { if (!string.IsNullOrEmpty(Request.Form["Product_Id"])) { string[] pro_Ids = Request.Form["Product_Id"].Split('|'); BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor; uint product_end = 0; string dtime = CommonFunction.DateTimeToString(Convert.ToDateTime(DateTime.Now.ToString())); var explain = Request.Form["explain"] ?? ""; if (!string.IsNullOrEmpty(Request.Form["Product_End"])) { dtime = CommonFunction.DateTimeToString(Convert.ToDateTime(Request.Form["Product_End"].ToString())); product_end = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Form["Product_End"])); } foreach (string str in pro_Ids.Distinct()) { if (!string.IsNullOrEmpty(str)) { uint product_id = uint.Parse(str); Product pro = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault(); if (product_end == 0)//說明是立即下架,就用原來的時間 { product_end = pro.Product_End; } if (pro != null && pro.Product_Status == 5)// && pro.user_id == (Session["caller"] as Caller).user_id { ProdVdReqQuery prodQuery = new ProdVdReqQuery(); prodQuery.vendor_id = Convert.ToInt32(vendor.vendor_id); prodQuery.product_id = Convert.ToInt32(product_id); prodQuery.req_status = 1; int totalCount = 0; ProdVdReq prodRquery = _prodVdReq.QueryProdVdReqList(prodQuery, out totalCount).FirstOrDefault(); if (prodRquery == null) { prodRquery = new ProdVdReq(); prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id); prodRquery.product_id = Convert.ToInt32(product_id); prodRquery.req_status = 1; prodRquery.req_datatime = Convert.ToDateTime(dtime); prodRquery.req_type = 2; prodRquery.explain = explain + dtime; if (_prodVdReq.Insert(prodRquery) < 0) { json = "{success:false,msg:0}";//返回json數據 } } else { prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id); prodRquery.product_id = Convert.ToInt32(product_id); prodRquery.req_status = 1; prodRquery.req_datatime = Convert.ToDateTime(dtime); prodRquery.req_type = 2; prodRquery.explain = explain + dtime; if (_prodVdReq.Update(prodRquery) < 0) { json = "{success:false,msg:0}";//返回json數據 } } } } } } //json = "{success:true}"; } 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 = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase ProdVdReqListQuery() { string json = string.Empty; try { ProdVdReqQuery query = new ProdVdReqQuery(); #region 查询条件填充 query.IsPage = true; query.Start = int.Parse(Request.Form["start"] ?? "0"); if (!string.IsNullOrEmpty(Request.Form["limit"])) { query.Limit = Convert.ToInt32(Request.Form["limit"]); } if (!string.IsNullOrEmpty(Request.Form["brand_id"])) { query.brand_id = Convert.ToUInt32(Request.Form["brand_id"]); } if (!string.IsNullOrEmpty(Request.Form["product_id"])) { query.product_id = int.Parse(Request.Form["product_id"]); } if (!string.IsNullOrEmpty(Request.Form["req_status"])) { query.req_status = int.Parse(Request.Form["req_status"]); } if (!string.IsNullOrEmpty(Request.Form["time_start"])) { query.time_start = Convert.ToDateTime(Convert.ToDateTime(Request.Form["time_start"]).ToString("yyyy/MM/dd HH:mm:ss")); } if (!string.IsNullOrEmpty(Request.Form["time_end"])) { query.time_end = Convert.ToDateTime(Convert.ToDateTime(Request.Form["time_end"]).ToString("yyyy/MM/dd HH:mm:ss")); } if (!string.IsNullOrEmpty(Request.Form["req_type"])) { query.req_type = int.Parse(Request.Form["req_type"]); } #endregion _prodVdReq = new ProdVdReqMgr(connectionString); int totalCount = 0; List<ProdVdReqQuery> pros = _prodVdReq.QueryProdVdReqList(query, out totalCount); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; json = "{succes:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(pros, Formatting.Indented, timeConverter) + "}"; } 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 = "{succes:true,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }