public void ProcessRequest(HttpContext context) { string str = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; string str2 = ""; string str3 = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; string str4 = ""; string s = ""; SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); new StringBuilder(); str2 = context.Request.QueryString["action"].ToString(); string sign = context.Request.Form["sign"]; string str7 = context.Request.Form["format"]; string checkCode = masterSettings.CheckCode; XmlDocument node = new XmlDocument(); new Dictionary <string, string>(); SortedDictionary <string, string> tmpParas = new SortedDictionary <string, string>(); try { string str11; if (((str11 = str2) != null) && (str11 == "distribution_list")) { string str9 = context.Request.Form["parma"].Trim(); str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "parma"); if (!string.IsNullOrEmpty(str9)) { str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign"); DistributorQuery query = new DistributorQuery(); query = (DistributorQuery)JavaScriptConvert.DeserializeObject(str9, typeof(DistributorQuery)); tmpParas = this.GetDistriubots(query); tmpParas.Add("action", "distribution_list"); tmpParas.Add("format", str7); if (APIHelper.CheckSign(tmpParas, checkCode, sign)) { DbQueryResult distributors = DistributorHelper.GetDistributors(query); string format = str + "<response_distributors>{0}<totalcount>{1}</totalcount></response_distributors>"; if (distributors.Data != null) { s = string.Format(format, this.ConvertTableToXml((DataTable)distributors.Data), distributors.TotalRecords.ToString()); } else { s = string.Format(format, "", "0"); } } } } } catch (Exception exception) { str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Unknown_Error, exception.Message); } if (s == "") { s = s + str3 + str4; } context.Response.ContentType = "text/xml"; if (str7 == "json") { s = s.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>", ""); node.Load(new MemoryStream(Encoding.GetEncoding("UTF-8").GetBytes(s))); s = JavaScriptConvert.SerializeXmlNode(node); context.Response.ContentType = "text/json"; } context.Response.Write(s); }
public void ProcessRequest(System.Web.HttpContext context) { System.Web.HttpRequest request = context.Request; this.app_secret = SettingsManager.GetMasterSettings(false).App_Secret; string signature = request["signature"]; string nonce = request["nonce"]; string timestamp = request["timestamp"]; string s = request["echostr"]; if (request.HttpMethod == "GET") { bool flag = this.ValidateSHA(signature, nonce, timestamp); if (flag) { context.Response.Write(s); } else { context.Response.Write(""); } context.Response.End(); return; } try { System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); string s2 = ""; byte[] array = new byte[request.InputStream.Length]; request.InputStream.Read(array, 0, array.Length); string text = System.Text.Encoding.UTF8.GetString(array); text = System.Web.HttpContext.Current.Server.UrlDecode(text); stringBuilder.Append(text); int messageId = 0; JObject jObject = JObject.Parse(text); if ((jObject["type"] != null && jObject["type"].ToString() == wb.MessageType.text.ToString()) || (jObject["type"] != null && jObject["type"].ToString() == wb.MessageType.image.ToString()) || (jObject["type"] != null && jObject["type"].ToString() == wb.MessageType.voice.ToString())) { MessageInfo messageInfo = new MessageInfo(); messageInfo.Created_at = System.DateTime.Now.ToString(); messageInfo.Receiver_id = jObject["receiver_id"].ToString(); messageInfo.Sender_id = jObject["sender_id"].ToString(); messageInfo.Text = jObject["text"].ToString(); messageInfo.Type = jObject["type"].ToString(); messageInfo.Status = 0; if (jObject["data"] != null) { JObject jObject2 = JObject.Parse(jObject["data"].ToString()); if (jObject2["tovfid"] != null) { messageInfo.Tovfid = jObject2["tovfid"].ToString(); } if (jObject2["vfid"] != null) { messageInfo.Vfid = jObject2["vfid"].ToString(); } } messageInfo.Access_Token = SettingsManager.GetMasterSettings(false).Access_Token; messageId = WeiboHelper.SaveMessage(messageInfo); } if (jObject["type"] != null && jObject["type"].ToString() == wb.MessageType.text.ToString()) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); if (masterSettings.CustomReply) { string senderId = jObject["receiver_id"].ToString(); string receiverId = jObject["sender_id"].ToString(); System.Data.DataView defaultView = WeiboHelper.GetReplyAll(1).DefaultView; if (defaultView.Count > 0) { defaultView.RowFilter = "Keys='" + jObject["text"].ToString() + "'"; if (defaultView.Count > 0) { System.Random random = new System.Random(); int recordIndex = random.Next(0, defaultView.Count); if (defaultView[recordIndex]["ReceiverType"].ToString() == "text") { s2 = wb.generateReplyMsg(wb.textMsg(defaultView[recordIndex]["Content"].ToString(), messageId), "text", senderId, receiverId); } else { s2 = wb.generateReplyMsg(wb.articleMsg(defaultView[recordIndex]["Display_name"].ToString(), defaultView[recordIndex]["Summary"].ToString(), defaultView[recordIndex]["Image"].ToString(), defaultView[recordIndex]["Url"].ToString(), defaultView[recordIndex]["ArticleId"].ToString(), messageId), "articles", senderId, receiverId); } } else { defaultView.RowFilter = "Keys like '%" + jObject["text"].ToString() + "%'"; if (defaultView.Count > 0) { System.Random random2 = new System.Random(); int recordIndex2 = random2.Next(0, defaultView.Count); if (defaultView[recordIndex2]["ReceiverType"].ToString() == "text") { s2 = wb.generateReplyMsg(wb.textMsg(defaultView[recordIndex2]["Content"].ToString(), messageId), "text", senderId, receiverId); } else { s2 = wb.generateReplyMsg(wb.articleMsg(defaultView[recordIndex2]["Display_name"].ToString(), defaultView[recordIndex2]["Summary"].ToString(), defaultView[recordIndex2]["Image"].ToString(), defaultView[recordIndex2]["Url"].ToString(), defaultView[recordIndex2]["ArticleId"].ToString(), messageId), "articles", senderId, receiverId); } } } } } } if (jObject["type"] != null && jObject["type"].ToString() == "event") { SiteSettings masterSettings2 = SettingsManager.GetMasterSettings(false); JObject jObject3 = JObject.Parse(jObject["data"].ToString()); if (!(jObject3["subtype"].ToString().Trim() == "click") && masterSettings2.SubscribeReply && jObject3["subtype"].ToString().Trim() == "subscribe") { string senderId = jObject["receiver_id"].ToString(); string receiverId = jObject["sender_id"].ToString(); System.Data.DataView defaultView2 = WeiboHelper.GetWeibo_Reply(2).DefaultView; if (defaultView2.Count > 0) { System.Random random3 = new System.Random(); int recordIndex3 = random3.Next(0, defaultView2.Count); if (defaultView2[recordIndex3]["ReceiverType"].ToString() == "text") { s2 = wb.generateReplyMsg(wb.textMsg(defaultView2[recordIndex3]["Content"].ToString(), messageId), "text", senderId, receiverId); } else { s2 = wb.generateReplyMsg(wb.articleMsg(defaultView2[recordIndex3]["Display_name"].ToString(), defaultView2[recordIndex3]["Summary"].ToString(), defaultView2[recordIndex3]["Image"].ToString(), defaultView2[recordIndex3]["Url"].ToString(), defaultView2[recordIndex3]["ArticleId"].ToString(), messageId), "articles", senderId, receiverId); } } } } if (jObject["type"] != null && jObject["type"].ToString() == "mention") { SiteSettings masterSettings3 = SettingsManager.GetMasterSettings(false); if (masterSettings3.ByRemind) { JObject.Parse(jObject["data"].ToString()); string senderId = jObject["receiver_id"].ToString(); string receiverId = jObject["sender_id"].ToString(); System.Data.DataView defaultView3 = WeiboHelper.GetWeibo_Reply(3).DefaultView; if (defaultView3.Count > 0) { System.Random random4 = new System.Random(); int recordIndex4 = random4.Next(0, defaultView3.Count); if (defaultView3[recordIndex4]["ReceiverType"].ToString() == "text") { s2 = wb.generateReplyMsg(wb.textMsg(defaultView3[recordIndex4]["Content"].ToString(), messageId), "text", senderId, receiverId); } else { s2 = wb.generateReplyMsg(wb.articleMsg(defaultView3[recordIndex4]["Display_name"].ToString(), defaultView3[recordIndex4]["Summary"].ToString(), defaultView3[recordIndex4]["Image"].ToString(), defaultView3[recordIndex4]["Url"].ToString(), defaultView3[recordIndex4]["ArticleId"].ToString(), messageId), "articles", senderId, receiverId); } } } } context.Response.Write(s2); } catch (System.Exception ex) { Globals.Debuglog(ex.Message, "_DebugLogWB.txt"); } }
public void ProcessRequest(HttpContext context) { HttpRequest request = context.Request; this.app_secret = SettingsManager.GetMasterSettings(false).App_Secret; string signature = request["signature"]; string nonce = request["nonce"]; string timestamp = request["timestamp"]; string s = request["echostr"]; if (request.HttpMethod == "GET") { if (this.ValidateSHA(signature, nonce, timestamp)) { context.Response.Write(s); } else { context.Response.Write(""); } context.Response.End(); } else { try { StringBuilder builder = new StringBuilder(); string str5 = ""; byte[] buffer = new byte[request.InputStream.Length]; request.InputStream.Read(buffer, 0, buffer.Length); string str6 = Encoding.UTF8.GetString(buffer); str6 = HttpContext.Current.Server.UrlDecode(str6); builder.Append(str6); string senderId = ""; string receiverId = ""; int messageId = 0; JObject obj2 = JObject.Parse(str6); if ((((obj2["type"] != null) && (obj2["type"].ToString() == MessageType.text.ToString())) || ((obj2["type"] != null) && (obj2["type"].ToString() == MessageType.image.ToString()))) || ((obj2["type"] != null) && (obj2["type"].ToString() == MessageType.voice.ToString()))) { MessageInfo messageInfo = new MessageInfo { Created_at = DateTime.Now.ToString(), Receiver_id = obj2["receiver_id"].ToString(), Sender_id = obj2["sender_id"].ToString(), Text = obj2["text"].ToString(), Type = obj2["type"].ToString(), Status = 0 }; if (obj2["data"] != null) { JObject obj3 = JObject.Parse(obj2["data"].ToString()); if (obj3["tovfid"] != null) { messageInfo.Tovfid = obj3["tovfid"].ToString(); } if (obj3["vfid"] != null) { messageInfo.Vfid = obj3["vfid"].ToString(); } } messageInfo.Access_Token = SettingsManager.GetMasterSettings(false).Access_Token; messageId = WeiboHelper.SaveMessage(messageInfo); } if (((obj2["type"] != null) && (obj2["type"].ToString() == MessageType.text.ToString())) && SettingsManager.GetMasterSettings(false).CustomReply) { senderId = obj2["receiver_id"].ToString(); receiverId = obj2["sender_id"].ToString(); DataView defaultView = WeiboHelper.GetReplyAll(1).DefaultView; if (defaultView.Count > 0) { defaultView.RowFilter = "Keys='" + obj2["text"].ToString() + "'"; if (defaultView.Count > 0) { int num2 = new Random().Next(0, defaultView.Count); if (defaultView[num2]["ReceiverType"].ToString() == "text") { str5 = generateReplyMsg(textMsg(defaultView[num2]["Content"].ToString(), messageId), "text", senderId, receiverId); } else { str5 = generateReplyMsg(articleMsg(defaultView[num2]["Display_name"].ToString(), defaultView[num2]["Summary"].ToString(), defaultView[num2]["Image"].ToString(), defaultView[num2]["Url"].ToString(), defaultView[num2]["ArticleId"].ToString(), messageId), "articles", senderId, receiverId); } } else { defaultView.RowFilter = "Keys like '%" + obj2["text"].ToString() + "%'"; if (defaultView.Count > 0) { int num3 = new Random().Next(0, defaultView.Count); if (defaultView[num3]["ReceiverType"].ToString() == "text") { str5 = generateReplyMsg(textMsg(defaultView[num3]["Content"].ToString(), messageId), "text", senderId, receiverId); } else { str5 = generateReplyMsg(articleMsg(defaultView[num3]["Display_name"].ToString(), defaultView[num3]["Summary"].ToString(), defaultView[num3]["Image"].ToString(), defaultView[num3]["Url"].ToString(), defaultView[num3]["ArticleId"].ToString(), messageId), "articles", senderId, receiverId); } } } } } if ((obj2["type"] != null) && (obj2["type"].ToString() == "event")) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); JObject obj4 = JObject.Parse(obj2["data"].ToString()); if (((obj4["subtype"].ToString().Trim() != "click") && masterSettings.SubscribeReply) && (obj4["subtype"].ToString().Trim() == "subscribe")) { senderId = obj2["receiver_id"].ToString(); receiverId = obj2["sender_id"].ToString(); DataView view2 = WeiboHelper.GetWeibo_Reply(2).DefaultView; if (view2.Count > 0) { int num4 = new Random().Next(0, view2.Count); if (view2[num4]["ReceiverType"].ToString() == "text") { str5 = generateReplyMsg(textMsg(view2[num4]["Content"].ToString(), messageId), "text", senderId, receiverId); } else { str5 = generateReplyMsg(articleMsg(view2[num4]["Display_name"].ToString(), view2[num4]["Summary"].ToString(), view2[num4]["Image"].ToString(), view2[num4]["Url"].ToString(), view2[num4]["ArticleId"].ToString(), messageId), "articles", senderId, receiverId); } } } } if (((obj2["type"] != null) && (obj2["type"].ToString() == "mention")) && SettingsManager.GetMasterSettings(false).ByRemind) { JObject.Parse(obj2["data"].ToString()); senderId = obj2["receiver_id"].ToString(); receiverId = obj2["sender_id"].ToString(); DataView view3 = WeiboHelper.GetWeibo_Reply(3).DefaultView; if (view3.Count > 0) { int num5 = new Random().Next(0, view3.Count); if (view3[num5]["ReceiverType"].ToString() == "text") { str5 = generateReplyMsg(textMsg(view3[num5]["Content"].ToString(), messageId), "text", senderId, receiverId); } else { str5 = generateReplyMsg(articleMsg(view3[num5]["Display_name"].ToString(), view3[num5]["Summary"].ToString(), view3[num5]["Image"].ToString(), view3[num5]["Url"].ToString(), view3[num5]["ArticleId"].ToString(), messageId), "articles", senderId, receiverId); } } } context.Response.Write(str5); } catch (Exception exception) { Globals.Debuglog(exception.Message, "_DebugLogWB.txt"); } } }
public System.Text.StringBuilder GetOrderDetails(string format, string orderitemfomat, PurchaseOrderInfo order) { System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); string text = string.Empty; if (order != null) { string text2 = "false"; System.Text.StringBuilder stringBuilder2 = new System.Text.StringBuilder(); long num = 0L; System.Collections.Generic.IList <PurchaseOrderItemInfo> purchaseOrderItems = order.PurchaseOrderItems; foreach (PurchaseOrderItemInfo current in purchaseOrderItems) { text2 = "true"; stringBuilder2.AppendFormat(orderitemfomat, new object[] { "0", order.OrderId, current.ProductId.ToString(), current.ItemDescription, current.SKU, current.SKUContent, current.Quantity.ToString(), current.ItemListPrice.ToString("F2"), current.ItemPurchasePrice.ToString("F2"), current.ItemCostPrice.ToString("F2") }); num += (long)current.Quantity; } System.Collections.Generic.Dictionary <string, string> shippingRegion = MessageInfo.GetShippingRegion(order.ShippingRegion); stringBuilder.AppendFormat(format, new object[] { order.OrderId, "0", order.Distributorname, order.DistributorEmail, order.ShipTo, shippingRegion["Province"], shippingRegion["City"].ToString(), shippingRegion["District"], order.Address, order.ZipCode, order.CellPhone, order.TelPhone, order.Remark, order.ManagerMark, order.ManagerRemark, num.ToString(), order.OrderTotal.ToString("F2"), order.OrderTotal.ToString("F2"), order.AdjustedFreight.ToString("F2"), order.GetPurchaseProfit().ToString("F2"), order.GetPurchaseTotal().ToString("F2"), order.PayDate.ToString(), order.ShippingDate.ToString(), ((int)order.RefundStatus).ToString(), order.RefundAmount.ToString("F2"), order.RefundRemark, ((int)order.PurchaseStatus).ToString(), text2, 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 text3 = "<ShipAddress>{0}</ShipAddress><ModeName>{1}</ModeName><ShipOrderNumber>{2}</ShipOrderNumber><ExpressCompanyName>{3}</ExpressCompanyName>"; text3 = string.Format(text3, new object[] { text, order.RealModeName, order.ShipOrderNumber, order.ExpressCompanyName }); stringBuilder = stringBuilder.Replace("</Status>", "</Status>" + text3); } return(stringBuilder); }
public void ProcessRequest(System.Web.HttpContext context) { string text = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; string str = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; string text2 = ""; Hidistro.Membership.Context.SiteSettings masterSettings = Hidistro.Membership.Context.SettingsManager.GetMasterSettings(false); string format = "<trade><Oid>{0}</Oid><SellerUid>{1}</SellerUid><BuyerNick>{2}</BuyerNick><BuyerEmail>{3}</BuyerEmail><ReceiverName>{4}</ReceiverName><ReceiverState>{5}</ReceiverState><ReceiverCity>{6}</ReceiverCity><ReceiverDistrict>{7}</ReceiverDistrict><ReceiverAddress>{8}</ReceiverAddress><ReceiverZip>{9}</ReceiverZip><ReceiverMobile>{10}</ReceiverMobile><ReceiverPhone>{11}</ReceiverPhone><BuyerMemo>{12}</BuyerMemo><OrderMark>{13}</OrderMark><SellerMemo>{14}</SellerMemo><Nums>{15}</Nums><Price>{16}</Price><Payment>{17}</Payment><PostFee>{18}</PostFee><Profit>{19}</Profit><PurchaseTotal>{20}</PurchaseTotal><PaymentTs>{21}</PaymentTs><SentTs>{22}</SentTs><RefundStatus>{23}</RefundStatus><RefundAmount>{24}</RefundAmount><RefundRemark>{25}</RefundRemark><Status>{26}</Status><orders list=\"{27}\">{28}</orders></trade>"; string orderitemfomat = "<order><Tid>{0}</Tid><Oid>{1}</Oid><GoodsIid>{2}</GoodsIid><Title>{3}</Title><OuterId>{4}</OuterId><SKUContent>{5}</SKUContent><Nums>{6}</Nums><Price>{7}</Price><Payment>{8}</Payment><CostPrice>{9}</CostPrice></order>"; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); string text3 = context.Request.QueryString["action"].ToString(); string sign = context.Request.Form["sign"]; string checkCode = masterSettings.CheckCode; string text4 = context.Request.Form["format"]; System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument(); System.Collections.Generic.SortedDictionary <string, string> sortedDictionary = new System.Collections.Generic.SortedDictionary <string, string>(); string a; if ((a = text3) != null) { if (!(a == "tradelist")) { if (!(a == "tradedetails")) { if (!(a == "send")) { if (a == "mark") { string value = context.Request.Form["order_mark"].Trim(); string text5 = context.Request.Form["seller_memo"].Trim(); if (!string.IsNullOrEmpty(context.Request.Form["tid"].Trim()) && !string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(text5)) { if (System.Convert.ToInt32(value) > 0 && System.Convert.ToInt32(value) < 7) { string text6 = context.Request.Form["tid"].Trim(); sortedDictionary.Add("tid", text6); sortedDictionary.Add("order_mark", value); sortedDictionary.Add("seller_memo", text5); sortedDictionary.Add("format", text4); if (APIHelper.CheckSign(sortedDictionary, checkCode, sign)) { PurchaseOrderInfo purchaseOrder = SalesHelper.GetPurchaseOrder(text6); purchaseOrder.ManagerMark = new OrderMark?((OrderMark)System.Enum.Parse(typeof(OrderMark), value, true)); purchaseOrder.ManagerRemark = Globals.HtmlEncode(text5); if (SalesHelper.SaveAPIPurchaseOrderRemark(purchaseOrder)) { stringBuilder.Append("<trade_get_response>"); stringBuilder.Append(this.GetOrderDetails(format, orderitemfomat, purchaseOrder).ToString()); stringBuilder.Append("</trade_get_response>"); this.message = text + stringBuilder.ToString(); } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "save is failure "); } } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign"); } } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "order_mark"); } } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid or order_mark or seller_memo"); } } } else { string text7 = context.Request.Form["tid"].Trim(); string text8 = context.Request.Form["out_sid"].Trim(); string text9 = context.Request.Form["company_code"].Trim(); if (!string.IsNullOrEmpty(text7) && !string.IsNullOrEmpty(text9) && !string.IsNullOrEmpty(text8)) { sortedDictionary.Add("tid", text7); sortedDictionary.Add("out_sid", text8); sortedDictionary.Add("company_code", text9); sortedDictionary.Add("format", text4); if (APIHelper.CheckSign(sortedDictionary, checkCode, sign)) { ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNodeByCode(text9); if (!string.IsNullOrEmpty(expressCompanyInfo.Name)) { ShippingModeInfo shippingModeByCompany = SalesHelper.GetShippingModeByCompany(expressCompanyInfo.Name); PurchaseOrderInfo purchaseOrder2 = SalesHelper.GetPurchaseOrder(text7); if (purchaseOrder2 != null) { ApiErrorCode apiErrorCode = this.SendOrders(purchaseOrder2, shippingModeByCompany, text8, expressCompanyInfo); if (apiErrorCode == ApiErrorCode.Success) { stringBuilder.Append("<trade_get_response>"); purchaseOrder2 = SalesHelper.GetPurchaseOrder(text7); stringBuilder.Append(this.GetOrderDetails(format, orderitemfomat, purchaseOrder2).ToString()); stringBuilder.Append("</trade_get_response>"); this.message = text + stringBuilder.ToString(); } else { text2 = MessageInfo.ShowMessageInfo(apiErrorCode, "It"); } } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "tid"); } } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "company_code"); } } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign"); } } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramters"); } } } else { if (!string.IsNullOrEmpty(context.Request.Form["tid"].Trim())) { string text6 = context.Request.Form["tid"].Trim(); if (APIHelper.CheckSign(new System.Collections.Generic.SortedDictionary <string, string> { { "tid", context.Request.Form["tid"] }, { "format", text4 } }, checkCode, sign)) { string text10 = context.Request.Form["tid"].Replace("\r\n", "\n"); if (!string.IsNullOrEmpty(text10)) { text6 = text10; PurchaseOrderInfo purchaseOrder3 = SalesHelper.GetPurchaseOrder(text6); stringBuilder.Append("<trade_get_response>"); stringBuilder.Append(this.GetOrderDetails(format, orderitemfomat, purchaseOrder3).ToString()); stringBuilder.Append("</trade_get_response>"); this.message = text + stringBuilder.ToString(); } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "tid"); } } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "signature"); } } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid"); } } } else { PurchaseOrderQuery purchaseOrderQuery = new PurchaseOrderQuery { PageSize = 100 }; int num = 0; string value2 = context.Request.Form["status"].Trim(); string text11 = context.Request.Form["buynick"].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(value2) && System.Convert.ToInt32(value2) >= 0) { purchaseOrderQuery.PurchaseStatus = (OrderStatus)System.Enum.Parse(typeof(OrderStatus), value2, true); } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "status"); } if (!string.IsNullOrEmpty(value3) && System.Convert.ToInt32(value3) > 0) { purchaseOrderQuery.PageIndex = System.Convert.ToInt32(value3); } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "pageindex"); } if (string.IsNullOrEmpty(text2)) { sortedDictionary.Add("status", value2); sortedDictionary.Add("buynick", text11); sortedDictionary.Add("pageindex", value3); sortedDictionary.Add("starttime", value4); sortedDictionary.Add("endtime", value5); sortedDictionary.Add("format", text4); if (APIHelper.CheckSign(sortedDictionary, checkCode, sign)) { if (!string.IsNullOrEmpty(text11)) { purchaseOrderQuery.DistributorName = text11; } if (!string.IsNullOrEmpty(value4)) { purchaseOrderQuery.StartDate = new System.DateTime?(System.Convert.ToDateTime(value4)); } if (!string.IsNullOrEmpty(value5)) { purchaseOrderQuery.EndDate = new System.DateTime?(System.Convert.ToDateTime(value5)); } purchaseOrderQuery.SortOrder = SortAction.Desc; purchaseOrderQuery.SortBy = "PurchaseDate"; stringBuilder.Append("<trade_get_response>"); stringBuilder.Append(this.GetOrderList(purchaseOrderQuery, format, orderitemfomat, out num)); stringBuilder.Append("<totalrecord>" + num + "</totalrecord>"); stringBuilder.Append("</trade_get_response>"); this.message = text + stringBuilder.ToString(); } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign"); } } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramter"); } } } if (this.message == "") { this.message = this.message + str + text2; } context.Response.ContentType = "text/xml"; if (text4 == "json") { this.message = this.message.Replace(text, ""); xmlDocument.Load(new System.IO.MemoryStream(System.Text.Encoding.GetEncoding("UTF-8").GetBytes(this.message))); this.message = JavaScriptConvert.SerializeXmlNode(xmlDocument); context.Response.ContentType = "text/json"; } context.Response.Write(this.message); }
public System.Text.StringBuilder GetOrderList(PurchaseOrderQuery query, string format, string orderitemfomat, out int totalrecords) { int num = 0; Globals.EntityCoding(query, true); System.Data.DataSet aPIPurchaseOrders = SalesHelper.GetAPIPurchaseOrders(query, out num); System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); foreach (System.Data.DataRow dataRow in aPIPurchaseOrders.Tables[0].Rows) { string text = "false"; System.Text.StringBuilder stringBuilder2 = new System.Text.StringBuilder(); System.Data.DataRow[] childRows = dataRow.GetChildRows("PurchaseOrderRelation"); for (int i = 0; i < childRows.Length; i++) { System.Data.DataRow dataRow2 = childRows[i]; string text2 = dataRow2["SKUContent"].ToString(); text = "true"; stringBuilder2.AppendFormat(orderitemfomat, new object[] { dataRow2["Tid"].ToString(), dataRow2["PurchaseOrderId"].ToString(), dataRow2["ProductId"].ToString(), dataRow2["ItemDescription"].ToString(), dataRow2["SKU"].ToString(), text2, dataRow2["Quantity"].ToString(), decimal.Parse(dataRow2["ItemListPrice"].ToString()).ToString("F2"), decimal.Parse(dataRow2["ItemPurchasePrice"].ToString()).ToString("F2"), decimal.Parse(dataRow2["CostPrice"].ToString()).ToString("F2") }); } System.Collections.Generic.Dictionary <string, string> shippingRegion = MessageInfo.GetShippingRegion(dataRow["ShippingRegion"].ToString()); stringBuilder.AppendFormat(format, new object[] { dataRow["PurchaseOrderId"].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(), 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"), decimal.Parse(dataRow["AdjustedFreight"].ToString()).ToString("F2"), decimal.Parse(dataRow["Profit"].ToString()).ToString("F2"), decimal.Parse(dataRow["PurchaseTotal"].ToString()).ToString("F2"), dataRow["PayDate"].ToString(), dataRow["ShippingDate"].ToString(), dataRow["ReFundStatus"].ToString(), decimal.Parse(dataRow["RefundAmount"].ToString()).ToString("F2"), dataRow["RefundRemark"].ToString(), dataRow["OrderStatus"].ToString(), text, stringBuilder2 }); } totalrecords = num; return(stringBuilder); }
public void ProcessRequest(System.Web.HttpContext context) { string str = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; string str2 = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; string str3 = ""; string text = ""; Hidistro.Membership.Context.SiteSettings masterSettings = Hidistro.Membership.Context.SettingsManager.GetMasterSettings(false); new System.Text.StringBuilder(); string text2 = context.Request.QueryString["action"].ToString(); string sign = context.Request.Form["sign"]; string text3 = context.Request.Form["format"]; string checkCode = masterSettings.CheckCode; System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument(); new System.Collections.Generic.Dictionary <string, string>(); System.Collections.Generic.SortedDictionary <string, string> sortedDictionary = new System.Collections.Generic.SortedDictionary <string, string>(); try { string a; if ((a = text2) != null && a == "distribution_list") { string text4 = context.Request.Form["parma"].Trim(); str3 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "parma"); if (!string.IsNullOrEmpty(text4)) { str3 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign"); DistributorQuery query = new DistributorQuery(); query = (DistributorQuery)JavaScriptConvert.DeserializeObject(text4, typeof(DistributorQuery)); sortedDictionary = this.GetDistriubots(query); sortedDictionary.Add("action", "distribution_list"); sortedDictionary.Add("format", text3); if (APIHelper.CheckSign(sortedDictionary, checkCode, sign)) { DbQueryResult distributors = DistributorHelper.GetDistributors(query); string format = str + "<response_distributors>{0}<totalcount>{1}</totalcount></response_distributors>"; if (distributors.Data != null) { text = string.Format(format, this.ConvertTableToXml((System.Data.DataTable)distributors.Data), distributors.TotalRecords.ToString()); } else { text = string.Format(format, "", "0"); } } } } } catch (System.Exception ex) { str3 = MessageInfo.ShowMessageInfo(ApiErrorCode.Unknown_Error, ex.Message); } if (text == "") { text = text + str2 + str3; } context.Response.ContentType = "text/xml"; if (text3 == "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 = JavaScriptConvert.SerializeXmlNode(xmlDocument); context.Response.ContentType = "text/json"; } context.Response.Write(text); }
public void ProcessRequest(System.Web.HttpContext context) { string text = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; string str = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; string text2 = ""; Hidistro.Membership.Context.SiteSettings masterSettings = Hidistro.Membership.Context.SettingsManager.GetMasterSettings(false); string format = "<trade><Oid>{0}</Oid><SellerUid>{1}</SellerUid><BuyerNick>{2}</BuyerNick><BuyerEmail>{3}</BuyerEmail><ReceiverName>{4}</ReceiverName><ReceiverState>{5}</ReceiverState><ReceiverCity>{6}</ReceiverCity><ReceiverDistrict>{7}</ReceiverDistrict><ReceiverAddress>{8}</ReceiverAddress><ReceiverZip>{9}</ReceiverZip><ReceiverMobile>{10}</ReceiverMobile><ReceiverPhone>{11}</ReceiverPhone><BuyerMemo>{12}</BuyerMemo><OrderMark>{13}</OrderMark><SellerMemo>{14}</SellerMemo><Nums>{15}</Nums><Price>{16}</Price><Payment>{17}</Payment><PostFee>{18}</PostFee><DiscountFee>{19}</DiscountFee><AdjustFee>{20}</AdjustFee><PaymentTs>{21}</PaymentTs><SentTs>{22}</SentTs><RefundStatus>{23}</RefundStatus><RefundAmount>{24}</RefundAmount><RefundRemark>{25}</RefundRemark><Status>{26}</Status><orders list=\"{27}\">{28}</orders></trade>"; string orderitemfomat = "<order><Tid>{0}</Tid><Oid>{1}</Oid><GoodsIid>{2}</GoodsIid><Title>{3}</Title><OuterId>{4}</OuterId><SKUContent>{5}</SKUContent><Nums>{6}</Nums><Price>{7}</Price><Payment>{8}</Payment></order>"; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); string text3 = context.Request.QueryString["action"].ToString(); string sign = context.Request.Form["sign"]; string checkCode = masterSettings.CheckCode; string value = context.Request.Form["format"]; new System.Collections.Generic.Dictionary <string, string>(); System.Collections.Generic.SortedDictionary <string, string> sortedDictionary = new System.Collections.Generic.SortedDictionary <string, string>(); try { if (!string.IsNullOrEmpty(text3)) { string a; if ((a = text3) != null) { if (!(a == "tradelist")) { if (!(a == "tradedetails")) { if (!(a == "send")) { if (a == "mark") { string value2 = context.Request.Form["order_mark"].Trim(); string text4 = context.Request.Form["seller_memo"].Trim(); if (string.IsNullOrEmpty(context.Request.Form["tid"].Trim()) || string.IsNullOrEmpty(value2) || string.IsNullOrEmpty(text4)) { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid or order_mark or seller_memo"); goto IL_7CA; } if (System.Convert.ToInt32(value2) <= 0 || System.Convert.ToInt32(value2) >= 7) { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "order_mark"); goto IL_7CA; } string text5 = context.Request.Form["tid"].Trim(); sortedDictionary.Add("tid", text5); sortedDictionary.Add("order_mark", value2); sortedDictionary.Add("seller_memo", text4); sortedDictionary.Add("format", value); if (!APIHelper.CheckSign(sortedDictionary, checkCode, sign)) { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign"); goto IL_7CA; } OrderInfo orderInfo = OrderHelper.GetOrderInfo(text5); orderInfo.ManagerMark = new OrderMark?((OrderMark)System.Enum.Parse(typeof(OrderMark), value2, true)); orderInfo.ManagerRemark = Globals.HtmlEncode(text4); if (OrderHelper.SaveRemarkAPI(orderInfo)) { stringBuilder.Append("<trade_get_response>"); stringBuilder.Append(this.GetOrderDetails(format, orderitemfomat, orderInfo).ToString()); stringBuilder.Append("</trade_get_response>"); goto IL_7CA; } text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "save is failure "); goto IL_7CA; } } else { string text6 = context.Request.Form["tid"].Trim(); string text7 = context.Request.Form["out_sid"].Trim(); string text8 = context.Request.Form["company_code"].Trim(); if (string.IsNullOrEmpty(text6) || string.IsNullOrEmpty(text8) || string.IsNullOrEmpty(text7)) { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramters"); goto IL_7CA; } sortedDictionary.Add("tid", text6); sortedDictionary.Add("out_sid", text7); sortedDictionary.Add("company_code", text8); sortedDictionary.Add("format", value); if (!APIHelper.CheckSign(sortedDictionary, checkCode, sign)) { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign"); goto IL_7CA; } ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNodeByCode(text8); if (string.IsNullOrEmpty(expressCompanyInfo.Name)) { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "company_code"); goto IL_7CA; } ShippingModeInfo shippingModeByCompany = SalesHelper.GetShippingModeByCompany(expressCompanyInfo.Name); OrderInfo orderInfo2 = OrderHelper.GetOrderInfo(text6); if (orderInfo2 == null) { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "tid"); goto IL_7CA; } ApiErrorCode apiErrorCode = this.SendOrders(orderInfo2, shippingModeByCompany, text7, expressCompanyInfo); if (apiErrorCode == ApiErrorCode.Success) { stringBuilder.Append("<trade_get_response>"); orderInfo2 = OrderHelper.GetOrderInfo(text6); stringBuilder.Append(this.GetOrderDetails(format, orderitemfomat, orderInfo2).ToString()); stringBuilder.Append("</trade_get_response>"); goto IL_7CA; } text2 = MessageInfo.ShowMessageInfo(apiErrorCode, "It"); goto IL_7CA; } } else { if (string.IsNullOrEmpty(context.Request.Form["tid"].Trim())) { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid"); goto IL_7CA; } string text5 = context.Request.Form["tid"].Trim(); if (!APIHelper.CheckSign(new System.Collections.Generic.SortedDictionary <string, string> { { "tid", context.Request.Form["tid"] }, { "format", value } }, checkCode, sign)) { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "signature"); goto IL_7CA; } string text9 = context.Request.Form["tid"].Replace("\r\n", "\n"); if (!string.IsNullOrEmpty(text9)) { text5 = text9; OrderInfo orderInfo3 = OrderHelper.GetOrderInfo(text5); stringBuilder.Append("<trade_get_response>"); stringBuilder.Append(this.GetOrderDetails(format, orderitemfomat, orderInfo3).ToString()); stringBuilder.Append("</trade_get_response>"); goto IL_7CA; } text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "tid"); goto IL_7CA; } } else { OrderQuery orderQuery = new OrderQuery { PageSize = 100 }; int num = 0; string value3 = context.Request.Form["status"].Trim(); string text10 = context.Request.Form["buyernick"].Trim(); string value4 = context.Request.Form["pageindex"].Trim(); string value5 = context.Request.Form["starttime"].Trim(); string value6 = context.Request.Form["endtime"].Trim(); if (!string.IsNullOrEmpty(value3) && System.Convert.ToInt32(value3) >= 0) { orderQuery.Status = (OrderStatus)System.Enum.Parse(typeof(OrderStatus), value3, true); } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "status"); } if (!string.IsNullOrEmpty(value4) && System.Convert.ToInt32(value4) > 0) { orderQuery.PageIndex = System.Convert.ToInt32(value4); } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "pageindex"); } if (!string.IsNullOrEmpty(text2)) { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramter"); goto IL_7CA; } sortedDictionary.Add("status", value3); sortedDictionary.Add("buyernick", text10); sortedDictionary.Add("pageindex", value4); sortedDictionary.Add("starttime", value5); sortedDictionary.Add("endtime", value6); sortedDictionary.Add("format", value); if (APIHelper.CheckSign(sortedDictionary, checkCode, sign)) { if (!string.IsNullOrEmpty(text10)) { orderQuery.UserName = text10; } if (!string.IsNullOrEmpty(value5)) { orderQuery.StartDate = new System.DateTime?(System.Convert.ToDateTime(value5)); } if (!string.IsNullOrEmpty(value6)) { orderQuery.EndDate = new System.DateTime?(System.Convert.ToDateTime(value6)); } stringBuilder.Append("<trade_get_response>"); stringBuilder.Append(this.GetOrderList(orderQuery, format, orderitemfomat, out num).ToString()); stringBuilder.Append("<totalrecord>" + num + "</totalrecord>"); stringBuilder.Append("</trade_get_response>"); goto IL_7CA; } text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign"); goto IL_7CA; } } text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "paramters"); IL_7CA: text += stringBuilder.ToString(); } else { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "sign"); } } catch (System.Exception ex) { text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Unknown_Error, ex.Message); } if (!string.IsNullOrEmpty(text2)) { text = str + text2; } context.Response.ContentType = "text/xml"; context.Response.Write(text); }