public void ProcessRequest(System.Web.HttpContext context) { string text = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><trade_get_response>{0}</trade_get_response>"; string str = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; this.fomat = "json"; SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); this.jsonformat = "{{\"Oid\": \"{0}\",\"SellerUid\": \"{1}\",\"BuyerNick\": \"{2}\",\"BuyerEmail\": \"{3}\",\"ReceiverName\": \"{4}\",\"ReceiverState\": \"{5}\",\"ReceiverCity\": \"{6}\",\"ReceiverDistrict\":\"{7}\",\"ReceiverAddress\":\"{8}\",\"ReceiverZip\": \"{9}\",\"ReceiverMobile\": \"{10}\",\"ReceiverPhone\":\"{11}\",\"BuyerMemo\": \"{12}\",\"OrderMark\":\"{13}\",\"SellerMemo\":\"{14}\",\"Nums\":\"{15}\",\"Price\": \"{16}\",\"Payment\":\"{17}\",\"PaymentType\": \"{18}\",\"PaymentTypeId\":\"{19}\",\"PaymentName\":\"{20}\",\"PostFee\": \"{21}\",\"DiscountFee\": \"{22}\",\"AdjustFee\": \"{23}\",\"PaymentTs\": \"{24}\",\"SentTs\":\"{25}\",\"RefundStatus\":\"{26}\",\"RefundAmount\":\"{27}\",\"RefundRemark\":\"{28}\",\"Status\": \"{29}\",\"ModeName\": \"{30}\",\"CreateTs\":\"{31}\",\"orders\": [{32}]}},"; string field = "action"; string orderitemfomat = "{{\"Tid\": \"{0}\",\"Oid\": \"{1}\",\"GoodsIid\": \"{2}\",\"Title\": \"{3}\",\"OuterId\": \"{4}\",\"SkuId\":\"{5}\",\"SKUContent\": \"{6}\",\"Nums\": \"{7}\",\"Price\": \"{8}\",\"Payment\":\"{9}\",\"ThumUrl\":\"{10}\"}},"; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); this.ModelId = context.Request.Form["action"].ToString(); field = "sign"; this.key = context.Request.Form["sign"]; this.localcode = masterSettings.CheckCode; new System.Collections.Generic.Dictionary <string, string>(); System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument(); try { if (!string.IsNullOrEmpty(this.ModelId)) { string modelId; if ((modelId = this.ModelId) != null) { if (!(modelId == "tradelist")) { if (!(modelId == "tradedetails")) { if (!(modelId == "send")) { if (modelId == "mark") { string value = context.Request.Form["order_mark"].Trim(); string text2 = context.Request.Form["seller_memo"].Trim(); if (string.IsNullOrEmpty(context.Request.Form["tid"].Trim()) || string.IsNullOrEmpty(value) || string.IsNullOrEmpty(text2)) { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid or order_mark or seller_memo"); goto IL_9F1; } if (System.Convert.ToInt32(value) <= 0 || System.Convert.ToInt32(value) >= 7) { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "order_mark"); goto IL_9F1; } string text3 = context.Request.Form["tid"].Trim(); this.tmpParas.Add("tid", text3); this.tmpParas.Add("order_mark", value); this.tmpParas.Add("seller_memo", text2); this.tmpParas.Add("format", this.fomat); this.tmpParas.Add("action", this.ModelId); if (!APIHelper.CheckSign(this.tmpParas, this.localcode, this.key)) { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign"); goto IL_9F1; } OrderInfo orderInfo = OrderHelper.GetOrderInfo(text3); orderInfo.ManagerMark = new OrderMark?((OrderMark)System.Enum.Parse(typeof(OrderMark), value, true)); orderInfo.ManagerRemark = Globals.HtmlEncode(text2); if (!OrderHelper.SaveRemark(orderInfo)) { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "save is failure "); goto IL_9F1; } if (this.fomat == "json") { text = string.Format("{{\"trade_get_response\":{{\"trade\":{0}}}}}", this.GetOrderDetails(this.jsonformat, orderitemfomat, orderInfo)); goto IL_9F1; } goto IL_9F1; } } else { string text4 = context.Request.Form["tid"].Trim(); string text5 = context.Request.Form["out_sid"].Trim(); string text6 = context.Request.Form["company_code"].Trim(); if (string.IsNullOrEmpty(text4) || string.IsNullOrEmpty(text6) || string.IsNullOrEmpty(text5)) { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramters"); goto IL_9F1; } this.tmpParas.Add("tid", text4); this.tmpParas.Add("out_sid", text5); this.tmpParas.Add("company_code", text6); this.tmpParas.Add("format", this.fomat); this.tmpParas.Add("action", this.ModelId); if (!APIHelper.CheckSign(this.tmpParas, this.localcode, this.key)) { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign"); goto IL_9F1; } ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNodeByCode(text6); if (string.IsNullOrEmpty(expressCompanyInfo.Name)) { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "company_code"); goto IL_9F1; } ShippingModeInfo shippingModeByCompany = SalesHelper.GetShippingModeByCompany(expressCompanyInfo.Name); OrderInfo orderInfo2 = OrderHelper.GetOrderInfo(text4); if (orderInfo2 == null) { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "tid"); goto IL_9F1; } ApiErrorCode apiErrorCode = this.SendOrders(orderInfo2, shippingModeByCompany, text5, expressCompanyInfo); if (apiErrorCode != ApiErrorCode.Success) { this.erromsg = MessageInfo.ShowMessageInfo(apiErrorCode, "It"); goto IL_9F1; } orderInfo2 = OrderHelper.GetOrderInfo(text4); if (this.fomat == "json") { text = string.Format("{{\"trade_get_response\":{{\"trade\":{0}}}}}", this.GetOrderDetails(this.jsonformat, orderitemfomat, orderInfo2)); goto IL_9F1; } goto IL_9F1; } } else { if (string.IsNullOrEmpty(context.Request.Form["tid"].Trim())) { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid"); goto IL_9F1; } string text3 = context.Request.Form["tid"].Trim(); this.tmpParas = new System.Collections.Generic.SortedDictionary <string, string>(); this.tmpParas.Add("tid", context.Request.Form["tid"]); this.tmpParas.Add("format", this.fomat); this.tmpParas.Add("action", this.ModelId); if (!APIHelper.CheckSign(this.tmpParas, this.localcode, this.key)) { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "signature"); goto IL_9F1; } string text7 = context.Request.Form["tid"].Replace("\r\n", "\n"); if (string.IsNullOrEmpty(text7)) { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "tid"); goto IL_9F1; } text3 = text7; OrderInfo orderInfo3 = TradeHelper.GetOrderInfo(text3); if (this.fomat == "json") { text = string.Format("{{\"trade_get_response\":{{\"trade\":{0}}}}}", this.GetOrderDetails(this.jsonformat, orderitemfomat, orderInfo3)); goto IL_9F1; } goto IL_9F1; } } else { OrderQuery orderQuery = new OrderQuery { PageSize = 100 }; int num = 0; string text8 = context.Request.Form["status"].Trim(); string value2 = context.Request.Form["pagesize"].Trim(); string text9 = context.Request.Form["datatype"].Trim(); string text10 = context.Request.Form["buyernick"].Trim(); string value3 = context.Request.Form["pageindex"].Trim(); string value4 = context.Request.Form["starttime"].Trim(); string value5 = context.Request.Form["endtime"].Trim(); if (!string.IsNullOrEmpty(text8) && System.Convert.ToInt32(text8) >= 0 && text8 != "6") { orderQuery.Status = (OrderStatus)System.Enum.Parse(typeof(OrderStatus), text8, true); } else { if (text8 == "6") { orderQuery.Status = OrderStatus.All; orderQuery.RefundState = (RefundStatus)System.Enum.Parse(typeof(RefundStatus), text8, true); } else { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "status"); } } if (!string.IsNullOrEmpty(value3) && System.Convert.ToInt32(value3) > 0) { orderQuery.PageIndex = System.Convert.ToInt32(value3); } else { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "pageindex"); } if (!string.IsNullOrEmpty(value2) && System.Convert.ToInt32(value2) > 0) { orderQuery.PageSize = (int)System.Convert.ToInt16(value2); } if (!string.IsNullOrEmpty(text9) && System.Convert.ToInt32(text9) > 0) { orderQuery.DataType = int.Parse(text9); } if (!string.IsNullOrEmpty(this.erromsg)) { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramter"); goto IL_9F1; } this.tmpParas.Add("status", text8); this.tmpParas.Add("datatype", text9); this.tmpParas.Add("buyernick", text10); this.tmpParas.Add("pageindex", value3); this.tmpParas.Add("pagesize", value2); this.tmpParas.Add("starttime", value4); this.tmpParas.Add("endtime", value5); this.tmpParas.Add("format", this.fomat); this.tmpParas.Add("action", this.ModelId); if (!APIHelper.CheckSign(this.tmpParas, this.localcode, this.key)) { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign"); goto IL_9F1; } if (!string.IsNullOrEmpty(text10)) { orderQuery.UserName = text10; } if (!string.IsNullOrEmpty(value4)) { orderQuery.StartDate = new System.DateTime?(System.Convert.ToDateTime(value4)); } if (!string.IsNullOrEmpty(value5)) { orderQuery.EndDate = new System.DateTime?(System.Convert.ToDateTime(value5)); } string arg = stringBuilder.Append(this.GetOrderList(orderQuery, this.jsonformat, orderitemfomat, out num).ToString()).ToString(); if (this.fomat == "json") { text = string.Format("{{\"trade_get_response\":{{\"trade\":[{0}],\"total\":{1}}}}}", arg, num); goto IL_9F1; } goto IL_9F1; } } this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "paramters"); } else { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "sign"); } IL_9F1 :; } catch (System.Exception) { this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Unknown_Error, field); } if (!string.IsNullOrEmpty(this.erromsg)) { text = str + this.erromsg; if (this.fomat == "json") { text = text.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>", ""); xmlDocument.Load(new System.IO.MemoryStream(System.Text.Encoding.GetEncoding("UTF-8").GetBytes(text))); text = JsonConvert.SerializeXmlNode(xmlDocument); } } context.Response.ContentType = "text/json"; context.Response.Write(text); }
public System.Text.StringBuilder GetOrderDetails(string format, string orderitemfomat, OrderInfo order) { System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); string text = string.Empty; if (order != null) { System.Text.StringBuilder stringBuilder2 = new System.Text.StringBuilder(); long num = 0L; System.Collections.Generic.Dictionary <string, LineItemInfo> lineItems = order.LineItems; foreach (LineItemInfo current in lineItems.Values) { stringBuilder2.AppendFormat(orderitemfomat, new object[] { "0", order.OrderId, current.ProductId.ToString(), current.ItemDescription, current.SKU, current.SkuId, Globals.HtmlEncode(current.SKUContent), current.Quantity.ToString(), current.ItemListPrice.ToString("F2"), current.ItemAdjustedPrice.ToString("F2"), current.ThumbnailsUrl }); num += (long)current.Quantity; } if (this.fomat == "json" && stringBuilder2.Length > 0) { stringBuilder2 = stringBuilder2.Remove(stringBuilder2.ToString().LastIndexOf(','), 1); } System.Collections.Generic.Dictionary <string, string> shippingRegion = MessageInfo.GetShippingRegion(order.ShippingRegion); string text2 = order.ModeName; if (!string.IsNullOrEmpty(order.RealModeName)) { text2 = order.RealModeName; } if (string.IsNullOrEmpty(text)) { text = order.ModeName; } string text3 = ""; string text4 = ""; string text5 = ""; if (order.PayDate.Year != 1) { text3 = order.PayDate.ToString("yyyy-MM-dd"); } if (order.ShippingDate.Year != 1) { text4 = order.ShippingDate.ToString("yyyy-MM-dd"); } if (order.OrderDate.Year != 1) { text5 = order.OrderDate.ToString("yyyy-MM-dd"); } stringBuilder.AppendFormat(format, new object[] { order.OrderId, "0", order.Username, order.EmailAddress, order.ShipTo, shippingRegion["Province"], shippingRegion["City"].ToString(), shippingRegion["District"], order.Address, order.ZipCode, order.CellPhone, order.TelPhone, Globals.HtmlEncode(order.Remark), order.ManagerMark, order.ManagerRemark, num.ToString(), order.GetTotal().ToString("F2"), order.GetTotal().ToString("F2"), order.Gateway, order.PaymentTypeId.ToString(), order.PaymentType, order.AdjustedFreight.ToString("F2"), order.ReducedPromotionAmount.ToString("F2"), order.AdjustedDiscount.ToString("F2"), text3, text4, ((int)order.RefundStatus).ToString(), order.RefundAmount.ToString("F2"), order.RefundRemark, ((int)order.OrderStatus).ToString(), text2, text5, stringBuilder2 }); if (!string.IsNullOrEmpty(order.ShippingRegion)) { text = order.ShippingRegion; } if (!string.IsNullOrEmpty(order.Address)) { text += order.Address; } if (!string.IsNullOrEmpty(order.ShipTo)) { text = text + " " + order.ShipTo; } if (!string.IsNullOrEmpty(order.ZipCode)) { text = text + " " + order.ZipCode; } if (!string.IsNullOrEmpty(order.TelPhone)) { text = text + " " + order.TelPhone; } if (!string.IsNullOrEmpty(order.CellPhone)) { text = text + " " + order.CellPhone; } string text6 = "<ShipAddress>{0}</ShipAddress><ShipOrderNumber>{1}</ShipOrderNumber><ExpressCompanyName>{2}</ExpressCompanyName>"; if (this.fomat == "json") { text6 = "\"ShipAddress\":\"{0}\",\"ShipOrderNumber\":\"{1}\",\"ExpressCompanyName\":\"{2}\""; } text6 = string.Format(text6, text, order.ShipOrderNumber, order.ExpressCompanyName); if (this.fomat == "json") { stringBuilder = stringBuilder.Replace(",\"ModeName", "," + text6 + ",\"ModeName"); stringBuilder = stringBuilder.Remove(stringBuilder.ToString().LastIndexOf(','), 1); } else { stringBuilder = stringBuilder.Replace("</Status>", "</Status>" + text6); } } return(stringBuilder); }
public System.Text.StringBuilder GetOrderList(OrderQuery query, string format, string orderitemfomat, out int totalrecords) { int num = 0; Globals.EntityCoding(query, true); System.Data.DataSet tradeOrders = OrderHelper.GetTradeOrders(query, out num); System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); foreach (System.Data.DataRow dataRow in tradeOrders.Tables[0].Rows) { System.Text.StringBuilder stringBuilder2 = new System.Text.StringBuilder(); System.Data.DataRow[] childRows = dataRow.GetChildRows("OrderRelation"); for (int i = 0; i < childRows.Length; i++) { System.Data.DataRow dataRow2 = childRows[i]; string text = Globals.HtmlEncode(dataRow2["SKUContent"].ToString()); string text2 = dataRow2["ThumbnailsUrl"].ToString(); stringBuilder2.AppendFormat(orderitemfomat, new object[] { dataRow2["Tid"].ToString(), dataRow2["OrderId"].ToString(), dataRow2["ProductId"].ToString(), dataRow2["ItemDescription"].ToString(), dataRow2["SKU"].ToString(), dataRow2["SkuId"].ToString(), text, dataRow2["Quantity"].ToString(), decimal.Parse(dataRow2["ItemListPrice"].ToString()).ToString("F2"), decimal.Parse(dataRow2["ItemAdjustedPrice"].ToString()).ToString("F2"), text2 }); } if (this.fomat == "json" && stringBuilder2.ToString().Length > 0) { stringBuilder2 = stringBuilder2.Remove(stringBuilder2.ToString().LastIndexOf(','), 1); } System.Collections.Generic.Dictionary <string, string> shippingRegion = MessageInfo.GetShippingRegion(dataRow["ShippingRegion"].ToString()); stringBuilder.AppendFormat(this.jsonformat, new object[] { dataRow["OrderId"].ToString(), dataRow["SellerUid"].ToString(), dataRow["Username"].ToString(), dataRow["EmailAddress"].ToString(), dataRow["ShipTo"].ToString(), shippingRegion["Province"], shippingRegion["City"].ToString(), shippingRegion["District"], dataRow["Address"].ToString(), dataRow["ZipCode"].ToString(), dataRow["CellPhone"].ToString(), dataRow["TelPhone"].ToString(), Globals.HtmlEncode(dataRow["Remark"].ToString()), dataRow["ManagerMark"].ToString(), dataRow["ManagerRemark"].ToString(), dataRow["Nums"].ToString(), decimal.Parse(dataRow["OrderTotal"].ToString()).ToString("F2"), decimal.Parse(dataRow["OrderTotal"].ToString()).ToString("F2"), dataRow["Gateway"].ToString(), dataRow["PaymentTypeId"].ToString(), dataRow["PaymentType"].ToString(), decimal.Parse(dataRow["AdjustedFreight"].ToString()).ToString("F2"), "0.00", decimal.Parse(dataRow["AdjustedDiscount"].ToString()).ToString("F2"), dataRow["PayDate"].ToString(), dataRow["ShippingDate"].ToString(), dataRow["ReFundStatus"].ToString(), dataRow["RefundAmount"].ToString(), dataRow["RefundRemark"].ToString(), dataRow["OrderStatus"].ToString(), dataRow["ModeName"].ToString(), dataRow["OrderDate"].ToString(), stringBuilder2 }); } if (this.fomat == "json" && stringBuilder.Length > 0) { stringBuilder = stringBuilder.Remove(stringBuilder.ToString().LastIndexOf(','), 1); } totalrecords = num; return(stringBuilder); }
public StringBuilder GetProductDetailsView(int pid, int gradeId, string host, string format, string skuContentFormat) { StringBuilder sbProduct = new StringBuilder(); string existSkuDetials = "false"; string skuList = ""; DataSet productSkuDetials = ProductHelper.GetProductSkuDetials(pid, gradeId); foreach (DataRow skuRow in productSkuDetials.Tables[1].Rows) { existSkuDetials = "true"; string skuContent = MessageInfo.GetSkuContent(skuRow["SkuId"].ToString()); string skuSalePrice = ""; string skuCostPrice = ""; if (skuRow["SalePrice"] != null && skuRow["SalePrice"].ToString() != "") { skuSalePrice = decimal.Parse(skuRow["SalePrice"].ToString()).ToString("F2"); } if (skuRow["CostPrice"] != null && skuRow["CostPrice"].ToString() != "") { skuCostPrice = decimal.Parse(skuRow["CostPrice"].ToString()).ToString("F2"); } skuList = skuList + string.Format(skuContentFormat, new object[] { skuRow["ProductId"].ToString(), skuRow["SKU"].ToString(), skuRow["SkuId"], skuContent, skuRow["Stock"], skuSalePrice, skuCostPrice }) + ","; } if (skuList.Length > 0) { skuList = skuList.Substring(0, skuList.Length - 1); } JsonConvert.SerializeObject(productSkuDetials.Tables[0]); foreach (DataRow productRow in productSkuDetials.Tables[0].Rows) { string productDetailsUrl = host + Globals.GetSiteUrls().UrlData.FormatUrl("productDetails", new object[] { productRow["ProductId"].ToString() }); string[] strimg = new string[] { productRow["ImageUrl1"].ToString(), productRow["ImageUrl2"].ToString(), productRow["ImageUrl3"].ToString(), productRow["ImageUrl4"].ToString(), productRow["ImageUrl5"].ToString() }; string desciption = MessageInfo.GetDesciption(productRow["Description"].ToString(), host); string shortDescription = System.Convert.ToBase64String(Encoding.UTF8.GetBytes(productRow["ShortDescription"].ToString())); string imageUrl = this.ImageUrl(host, strimg); string salePrice = ""; string marketPrice = ""; string costPrice = ""; if (productRow["SalePrice"] != null && productRow["SalePrice"].ToString() != "") { salePrice = decimal.Parse(productRow["SalePrice"].ToString()).ToString("F2"); } if (productRow["CostPrice"] != null && productRow["CostPrice"].ToString() != "") { costPrice = decimal.Parse(productRow["SalePrice"].ToString()).ToString("F2"); } if (productRow["MarketPrice"] != null && productRow["MarketPrice"].ToString() != "") { marketPrice = decimal.Parse(productRow["MarketPrice"].ToString()).ToString("F2"); } format = format.Replace("{{", "").Replace("}}", ""); sbProduct.AppendFormat(format, new object[] { productRow["ProductId"].ToString(), productRow["ProductCode"].ToString(), productRow["ProductName"].ToString(), imageUrl, productDetailsUrl, marketPrice, salePrice, costPrice, productRow["Weight"].ToString(), productRow["SaleStatus"].ToString(), productRow["SaleCounts"].ToString(), shortDescription, productRow["Stock"].ToString(), productRow["AddedDate"].ToString(), desciption, salePrice, existSkuDetials, productRow["BrandId"].ToString(), skuList, productRow["Unit"].ToString() }); } return(sbProduct); }
public void ProcessRequest(System.Web.HttpContext context) { string content = ""; string message = ""; string action = context.Request.Form["action"].Trim(); string sign = context.Request.Form["sign"].Trim(); this.siteSettings = SettingsManager.GetMasterSettings(false); string checkCode = this.siteSettings.CheckCode; SortedDictionary <string, string> sortedDictionary = new SortedDictionary <string, string>(); string skuContentFormat = "{{\"lid\":\"{0}\",\"OuterId\":\"{1}\",\"SkuId\":\"{2}\",\"SKUContent\":\"{3}\",\"Nums\":\"{4}\",\"Price\":{5},\"CostPrice\":{6}}}"; string productFormat = "{{\"lid\":\"{0}\",\"OuterId\":\"{1}\",\"Title\":\"{2}\",\"PicUrl\":\"{3}\",\"Url\":\"{4}\",\"MarketPrice\":{5},\"Price\":{6},\"CostPrice\":{7},\"Weight\":{8},\"Status\":{9},\"SaleCounts\":{10},\"ShortDescription:\":\"{11}\",\"Stock\":{12},\"AddedDate\":\"{13}\",\"Description\":\"{14}\",\"RankPrice\":{15},\"List\":\"{16}\",\"BrandId\":\"{17}\",\"SkuItems\":[{18}],\"Unit\":\"{19}\"}}"; string arg_A3_0 = context.Request.Form["format"]; System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument(); try { if (!string.IsNullOrEmpty(action)) { string hostPath = HiContext.Current.HostPath; string a; if ((a = action) != null) { if (!(a == "productview")) { if (!(a == "stockview")) { if (!(a == "quantity")) { if (a == "statue") { string state = context.Request.Form["state"].Trim(); string productId = context.Request.Form["productId"].Trim(); if (string.IsNullOrEmpty(state) || string.IsNullOrEmpty(productId)) { message = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "state or productId"); goto IL_78C; } ProductSaleStatus productSaleStatus = (ProductSaleStatus)System.Enum.Parse(typeof(ProductSaleStatus), state, true); int num = System.Convert.ToInt32(productId); if (num <= 0) { message = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "productId"); goto IL_78C; } sortedDictionary.Add("productid", productId); sortedDictionary.Add("state", state); sortedDictionary.Add("format", "json"); if (!APIHelper.CheckSign(sortedDictionary, checkCode, sign)) { message = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign"); goto IL_78C; } bool flag = false; if (productSaleStatus == ProductSaleStatus.OnSale) { if (ProductHelper.UpShelfAPI(num.ToString()) > 0) { flag = true; } else { message = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "productId"); } } else { if (productSaleStatus == ProductSaleStatus.UnSale) { if (ProductHelper.OffShelfAPI(num.ToString()) > 0) { flag = true; } else { message = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "productId"); } } } if (flag) { content = string.Concat(new string[] { "{\"item_update_statue_response\":\"item\":{\"num_iid\":\"", productId, "\",\"modified\":\"", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "\"}}" }); goto IL_78C; } message = MessageInfo.ShowMessageInfo(ApiErrorCode.Unknown_Error, "update"); goto IL_78C; } } else { if (string.IsNullOrEmpty(context.Request.Form["productId"].Trim()) || string.IsNullOrEmpty(context.Request.Form["quantity"].Trim())) { message = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramters"); goto IL_78C; } string text6 = context.Request.Form["productId"]; string text7 = ""; string text8 = ""; int type = 1; int stock = System.Convert.ToInt32(context.Request.Form["quantity"].Trim()); if (!string.IsNullOrEmpty(context.Request.Form["sku_id"].Trim())) { text7 = context.Request.Form["sku_id"]; } if (!string.IsNullOrEmpty(context.Request.Form["outer_id"].Trim())) { text8 = context.Request.Form["outer_id"]; } if (!string.IsNullOrEmpty(context.Request.Form["type"])) { type = System.Convert.ToInt32(context.Request.Form["type"]); } sortedDictionary.Add("productId", text6.ToString()); sortedDictionary.Add("quantity", stock.ToString()); sortedDictionary.Add("sku_id", text7); sortedDictionary.Add("outer_id", text8); sortedDictionary.Add("type", type.ToString()); sortedDictionary.Add("format", "json"); sortedDictionary.Add("action", action); if (!APIHelper.CheckSign(sortedDictionary, checkCode, sign)) { message = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign"); goto IL_78C; } ApiErrorCode apiErrorCode = ProductHelper.UpdateProductStock(System.Convert.ToInt32(text6), text7, text8, type, stock); if (ApiErrorCode.Success == apiErrorCode) { string format = "{{\"trade_get_response\":{{\"product\":{{{0}}}}}}}"; content = string.Format(format, this.GetProductDetailsView(System.Convert.ToInt32(text6), 0, hostPath, productFormat, skuContentFormat).ToString()); goto IL_78C; } message = MessageInfo.ShowMessageInfo(apiErrorCode, "paramters"); goto IL_78C; } } else { if (string.IsNullOrEmpty(context.Request.Form["productId"].Trim()) || System.Convert.ToInt32(context.Request.Form["productId"].Trim()) <= 0) { message = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "productId"); goto IL_78C; } int num = System.Convert.ToInt32(context.Request.Form["productId"].Trim()); string text9 = "0"; if (!string.IsNullOrEmpty(context.Request.Form["gradeId"].Trim()) && System.Convert.ToInt16(context.Request.Form["gradeId"].Trim()) > 0) { text9 = context.Request.Form["gradeId"].Trim(); } sortedDictionary.Add("productid", num.ToString()); sortedDictionary.Add("action", "stockview"); sortedDictionary.Add("format", "json"); sortedDictionary.Add("gradeId", text9); if (APIHelper.CheckSign(sortedDictionary, checkCode, sign)) { string format2 = "{{\"trade_get_response\":{{\"product\":{{{0}}}}}}}"; content = string.Format(format2, this.GetProductDetailsView(num, int.Parse(text9), hostPath, productFormat, skuContentFormat).ToString()); goto IL_78C; } message = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign"); goto IL_78C; } } else { string value2 = context.Request.Form["parma"].Trim(); string text9 = context.Request.Form["gradeId"].Trim(); ProductQuery productQuery = new ProductQuery(); if (!string.IsNullOrEmpty(value2)) { productQuery = JsonConvert.DeserializeObject <ProductQuery>(value2); } message = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "sign"); if (string.IsNullOrEmpty(sign)) { goto IL_78C; } sortedDictionary.Add("parma", context.Request.Form["parma"]); sortedDictionary.Add("format", "json"); sortedDictionary.Add("action", "productview"); sortedDictionary.Add("gradeId", text9.ToString()); message = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign"); if (APIHelper.CheckSign(sortedDictionary, checkCode, sign)) { Globals.EntityCoding(productQuery, true); int num2 = 0; string format3 = "{{\"trade_get_response\":{{\"product\":[{0}],\"totalrecord\":\"{1}\"}}}}"; content = string.Format(format3, this.GetProductView(productQuery, int.Parse(text9), hostPath, productFormat, skuContentFormat, out num2).ToString(), num2.ToString()); goto IL_78C; } goto IL_78C; } } message = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "paramters"); } else { message = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "modeId"); } IL_78C :; } catch (System.Exception ex) { message = MessageInfo.ShowMessageInfo(ApiErrorCode.Unknown_Error, ex.Message); } if (string.IsNullOrEmpty(content)) { content = message; xmlDocument.Load(new System.IO.MemoryStream(Encoding.GetEncoding("UTF-8").GetBytes(content))); content = JsonConvert.SerializeXmlNode(xmlDocument); } context.Response.ContentType = "text/json"; context.Response.Write(content); }
public StringBuilder GetProductView(ProductQuery query, int gradeId, string host, string strformat, string skuContentFormat, out int recordes) { if (query.CategoryId.HasValue) { query.MaiCategoryPath = CatalogHelper.GetCategory(query.CategoryId.Value).Path; } StringBuilder sbProducts = new StringBuilder(); int recordCount = 0; DataSet productsByQuery = ProductHelper.GetProductsByQuery(query, gradeId, out recordCount); foreach (DataRow rowProduct in productsByQuery.Tables[0].Rows) { StringBuilder sbProductRel = new StringBuilder(); string existRelationProduct = "false"; DataRow[] childRows = rowProduct.GetChildRows("ProductRealation"); DataRow[] array = childRows; for (int i = 0; i < array.Length; i++) { DataRow rowProductRel = array[i]; existRelationProduct = "true"; string skuContent = MessageInfo.GetSkuContent(rowProductRel["SkuId"].ToString()); string salePriceRel = ""; string costPriceRel = ""; if (rowProductRel["SalePrice"] != null && rowProductRel["SalePrice"].ToString() != "") { salePriceRel = decimal.Parse(rowProductRel["SalePrice"].ToString()).ToString("F2"); } if (rowProductRel["CostPrice"] != null && rowProductRel["CostPrice"].ToString() != "") { costPriceRel = decimal.Parse(rowProductRel["CostPrice"].ToString()).ToString("F2"); } sbProductRel.AppendFormat(skuContentFormat, new object[] { rowProductRel["ProductId"].ToString(), rowProductRel["SKU"].ToString(), rowProductRel["SKuId"].ToString(), skuContent, rowProductRel["Stock"].ToString(), salePriceRel, costPriceRel }); sbProductRel.Append(","); } if (sbProductRel.Length > 0) { sbProductRel = sbProductRel.Remove(sbProductRel.Length - 1, 1); } string detailsUrl = host + "/AppShop/ProductDetails.aspx?productId=" + rowProduct["ProductId"]; string imageUrl60 = host + rowProduct["ThumbnailUrl60"]; if (string.IsNullOrEmpty(rowProduct["ThumbnailUrl60"].ToString())) { imageUrl60 = host + this.siteSettings.DefaultProductThumbnail2; } if (rowProduct["ThumbnailUrl60"].ToString().IndexOf("http://image58.kuaidiantong.cn/Storage/master/product/") >= 0) { imageUrl60 = rowProduct["ThumbnailUrl60"].ToString(); } string marketPrice = ""; string salePrice = ""; string rankPrice = ""; string costPrice = ""; string shotDescription = System.Convert.ToBase64String(Encoding.UTF8.GetBytes(rowProduct["ShortDescription"].ToString())); if (rowProduct["MarketPrice"] != null && rowProduct["MarketPrice"].ToString() != "") { marketPrice = decimal.Parse(rowProduct["MarketPrice"].ToString()).ToString("F2"); } if (rowProduct["SalePrice"] != null && rowProduct["SalePrice"].ToString() != "") { salePrice = decimal.Parse(rowProduct["SalePrice"].ToString()).ToString("F2"); } if (rowProduct["CostPrice"] != null && rowProduct["CostPrice"].ToString() != "") { costPrice = decimal.Parse(rowProduct["CostPrice"].ToString()).ToString("F2"); } if (rowProduct["RankPrice"] != null && rowProduct["RankPrice"].ToString() != "") { rankPrice = decimal.Parse(rowProduct["RankPrice"].ToString()).ToString("F2"); } sbProducts.AppendFormat(strformat, new object[] { rowProduct["ProductId"].ToString(), rowProduct["ProductCode"].ToString(), rowProduct["ProductName"].ToString(), imageUrl60, detailsUrl, marketPrice, salePrice, costPrice, rowProduct["Weight"].ToString(), rowProduct["SaleStatus"].ToString(), rowProduct["SaleCounts"].ToString(), shotDescription, rowProduct["Stock"].ToString(), rowProduct["AddedDate"].ToString(), MessageInfo.GetDesciption(rowProduct["Description"].ToString(), host), rankPrice, existRelationProduct, rowProduct["BrandId"].ToString(), sbProductRel, rowProduct["Unit"].ToString() }); sbProducts.Append(","); } recordes = recordCount; if (sbProducts.Length > 0) { sbProducts = sbProducts.Remove(sbProducts.Length - 1, 1); } return(sbProducts); }