Esempio n. 1
0
        public void ProcessRequest(HttpContext context)
        {
            string        oldValue       = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
            string        str2           = "";
            string        str3           = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
            string        str4           = "";
            SiteSettings  masterSettings = 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>";
            StringBuilder builder        = new StringBuilder();

            str2 = context.Request.QueryString["action"].ToString();
            string      sign      = context.Request.Form["sign"];
            string      checkCode = masterSettings.CheckCode;
            string      str9      = context.Request.Form["format"];
            XmlDocument node      = new XmlDocument();
            SortedDictionary <string, string> tmpParas = new SortedDictionary <string, string>();
            string str22 = str2;

            if (str22 != null)
            {
                if (!(str22 == "tradelist"))
                {
                    string str15;
                    if (str22 == "tradedetails")
                    {
                        str15 = "";
                        if (!string.IsNullOrEmpty(context.Request.Form["tid"].Trim()))
                        {
                            str15    = context.Request.Form["tid"].Trim();
                            tmpParas = new SortedDictionary <string, string>();
                            tmpParas.Add("tid", context.Request.Form["tid"]);
                            tmpParas.Add("format", str9);
                            if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                            {
                                string str16 = context.Request.Form["tid"].Replace("\r\n", "\n");
                                if (!string.IsNullOrEmpty(str16))
                                {
                                    str15 = str16;
                                    PurchaseOrderInfo purchaseOrder = SalesHelper.GetPurchaseOrder(str15);
                                    builder.Append("<trade_get_response>");
                                    builder.Append(this.GetOrderDetails(format, orderitemfomat, purchaseOrder).ToString());
                                    builder.Append("</trade_get_response>");
                                    this.message = oldValue + builder.ToString();
                                }
                                else
                                {
                                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "tid");
                                }
                            }
                            else
                            {
                                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "signature");
                            }
                        }
                        else
                        {
                            str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid");
                        }
                    }
                    else if (str22 == "send")
                    {
                        string str17 = context.Request.Form["tid"].Trim();
                        string str18 = context.Request.Form["out_sid"].Trim();
                        string str19 = context.Request.Form["company_code"].Trim();
                        if ((!string.IsNullOrEmpty(str17) && !string.IsNullOrEmpty(str19)) && !string.IsNullOrEmpty(str18))
                        {
                            tmpParas.Add("tid", str17);
                            tmpParas.Add("out_sid", str18);
                            tmpParas.Add("company_code", str19);
                            tmpParas.Add("format", str9);
                            if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                            {
                                ExpressCompanyInfo express = ExpressHelper.FindNodeByCode(str19);
                                if (!string.IsNullOrEmpty(express.Name))
                                {
                                    ShippingModeInfo  shippingModeByCompany = SalesHelper.GetShippingModeByCompany(express.Name);
                                    PurchaseOrderInfo purchaseorder         = SalesHelper.GetPurchaseOrder(str17);
                                    if (purchaseorder != null)
                                    {
                                        ApiErrorCode messageenum = this.SendOrders(purchaseorder, shippingModeByCompany, str18, express);
                                        if (messageenum == ApiErrorCode.Success)
                                        {
                                            builder.Append("<trade_get_response>");
                                            purchaseorder = SalesHelper.GetPurchaseOrder(str17);
                                            builder.Append(this.GetOrderDetails(format, orderitemfomat, purchaseorder).ToString());
                                            builder.Append("</trade_get_response>");
                                            this.message = oldValue + builder.ToString();
                                        }
                                        else
                                        {
                                            str4 = MessageInfo.ShowMessageInfo(messageenum, "It");
                                        }
                                    }
                                    else
                                    {
                                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "tid");
                                    }
                                }
                                else
                                {
                                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "company_code");
                                }
                            }
                            else
                            {
                                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                            }
                        }
                        else
                        {
                            str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramters");
                        }
                    }
                    else if (str22 == "mark")
                    {
                        string str20 = context.Request.Form["order_mark"].Trim();
                        string str21 = context.Request.Form["seller_memo"].Trim();
                        if ((!string.IsNullOrEmpty(context.Request.Form["tid"].Trim()) && !string.IsNullOrEmpty(str20)) && !string.IsNullOrEmpty(str21))
                        {
                            if ((Convert.ToInt32(str20) > 0) && (Convert.ToInt32(str20) < 7))
                            {
                                str15 = context.Request.Form["tid"].Trim();
                                tmpParas.Add("tid", str15);
                                tmpParas.Add("order_mark", str20);
                                tmpParas.Add("seller_memo", str21);
                                tmpParas.Add("format", str9);
                                if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                                {
                                    PurchaseOrderInfo info5 = SalesHelper.GetPurchaseOrder(str15);
                                    info5.ManagerMark   = new OrderMark?((OrderMark)Enum.Parse(typeof(OrderMark), str20, true));
                                    info5.ManagerRemark = Globals.HtmlEncode(str21);
                                    if (SalesHelper.SaveAPIPurchaseOrderRemark(info5))
                                    {
                                        builder.Append("<trade_get_response>");
                                        builder.Append(this.GetOrderDetails(format, orderitemfomat, info5).ToString());
                                        builder.Append("</trade_get_response>");
                                        this.message = oldValue + builder.ToString();
                                    }
                                    else
                                    {
                                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "save is failure ");
                                    }
                                }
                                else
                                {
                                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                                }
                            }
                            else
                            {
                                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "order_mark");
                            }
                        }
                        else
                        {
                            str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid or order_mark or seller_memo");
                        }
                    }
                }
                else
                {
                    PurchaseOrderQuery query2 = new PurchaseOrderQuery();
                    query2.PageSize = 100;
                    PurchaseOrderQuery query = query2;
                    int    totalrecords      = 0;
                    string str10             = context.Request.Form["status"].Trim();
                    string str11             = context.Request.Form["buynick"].Trim();
                    string str12             = context.Request.Form["pageindex"].Trim();
                    string str13             = context.Request.Form["starttime"].Trim();
                    string str14             = context.Request.Form["endtime"].Trim();
                    if (!string.IsNullOrEmpty(str10) && (Convert.ToInt32(str10) >= 0))
                    {
                        query.PurchaseStatus = (OrderStatus)Enum.Parse(typeof(OrderStatus), str10, true);
                    }
                    else
                    {
                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "status");
                    }
                    if (!string.IsNullOrEmpty(str12) && (Convert.ToInt32(str12) > 0))
                    {
                        query.PageIndex = Convert.ToInt32(str12);
                    }
                    else
                    {
                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "pageindex");
                    }
                    if (string.IsNullOrEmpty(str4))
                    {
                        tmpParas.Add("status", str10);
                        tmpParas.Add("buynick", str11);
                        tmpParas.Add("pageindex", str12);
                        tmpParas.Add("starttime", str13);
                        tmpParas.Add("endtime", str14);
                        tmpParas.Add("format", str9);
                        if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                        {
                            if (!string.IsNullOrEmpty(str11))
                            {
                                query.DistributorName = str11;
                            }
                            if (!string.IsNullOrEmpty(str13))
                            {
                                query.StartDate = new DateTime?(Convert.ToDateTime(str13));
                            }
                            if (!string.IsNullOrEmpty(str14))
                            {
                                query.EndDate = new DateTime?(Convert.ToDateTime(str14));
                            }
                            query.SortOrder = SortAction.Desc;
                            query.SortBy    = "PurchaseDate";
                            builder.Append("<trade_get_response>");
                            builder.Append(this.GetOrderList(query, format, orderitemfomat, out totalrecords));
                            builder.Append("<totalrecord>" + totalrecords + "</totalrecord>");
                            builder.Append("</trade_get_response>");
                            this.message = oldValue + builder.ToString();
                        }
                        else
                        {
                            str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                        }
                    }
                    else
                    {
                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramter");
                    }
                }
            }
            if (this.message == "")
            {
                this.message = this.message + str3 + str4;
            }
            context.Response.ContentType = "text/xml";
            if (str9 == "json")
            {
                this.message = this.message.Replace(oldValue, "");
                node.Load(new MemoryStream(Encoding.GetEncoding("UTF-8").GetBytes(this.message)));
                this.message = JavaScriptConvert.SerializeXmlNode(node);
                context.Response.ContentType = "text/json";
            }
            context.Response.Write(this.message);
        }
        public void ProcessRequest(HttpContext context)
        {
            string        s              = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
            string        str2           = "";
            string        str3           = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
            string        str4           = "";
            SiteSettings  masterSettings = 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>";
            StringBuilder builder        = new StringBuilder();

            str2 = context.Request.QueryString["action"].ToString();
            string sign      = context.Request.Form["sign"];
            string checkCode = masterSettings.CheckCode;
            string str9      = context.Request.Form["format"];

            new Dictionary <string, string>();
            SortedDictionary <string, string> tmpParas = new SortedDictionary <string, string>();

            try
            {
                string str15;
                string str17;
                string str20;
                if (string.IsNullOrEmpty(str2))
                {
                    goto Label_07D6;
                }
                string str22 = str2;
                if (str22 == null)
                {
                    goto Label_07B9;
                }
                if (!(str22 == "tradelist"))
                {
                    if (str22 == "tradedetails")
                    {
                        goto Label_0336;
                    }
                    if (str22 == "send")
                    {
                        goto Label_046D;
                    }
                    if (str22 == "mark")
                    {
                        goto Label_0613;
                    }
                    goto Label_07B9;
                }
                OrderQuery query2 = new OrderQuery();
                query2.PageSize = 100;
                OrderQuery query        = query2;
                int        totalrecords = 0;
                string     str10        = context.Request.Form["status"].Trim();
                string     str11        = context.Request.Form["buyernick"].Trim();
                string     str12        = context.Request.Form["pageindex"].Trim();
                string     str13        = context.Request.Form["starttime"].Trim();
                string     str14        = context.Request.Form["endtime"].Trim();
                if (!string.IsNullOrEmpty(str10) && (Convert.ToInt32(str10) >= 0))
                {
                    query.Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), str10, true);
                }
                else
                {
                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "status");
                }
                if (!string.IsNullOrEmpty(str12) && (Convert.ToInt32(str12) > 0))
                {
                    query.PageIndex = Convert.ToInt32(str12);
                }
                else
                {
                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "pageindex");
                }
                if (string.IsNullOrEmpty(str4))
                {
                    tmpParas.Add("status", str10);
                    tmpParas.Add("buyernick", str11);
                    tmpParas.Add("pageindex", str12);
                    tmpParas.Add("starttime", str13);
                    tmpParas.Add("endtime", str14);
                    tmpParas.Add("format", str9);
                    if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                    {
                        if (!string.IsNullOrEmpty(str11))
                        {
                            query.UserName = str11;
                        }
                        if (!string.IsNullOrEmpty(str13))
                        {
                            query.StartDate = new DateTime?(Convert.ToDateTime(str13));
                        }
                        if (!string.IsNullOrEmpty(str14))
                        {
                            query.EndDate = new DateTime?(Convert.ToDateTime(str14));
                        }
                        builder.Append("<trade_get_response>");
                        builder.Append(this.GetOrderList(query, format, orderitemfomat, out totalrecords).ToString());
                        builder.Append("<totalrecord>" + totalrecords + "</totalrecord>");
                        builder.Append("</trade_get_response>");
                    }
                    else
                    {
                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                    }
                }
                else
                {
                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramter");
                }
                goto Label_07C6;
Label_0336:
                str15 = "";
                if (!string.IsNullOrEmpty(context.Request.Form["tid"].Trim()))
                {
                    str15    = context.Request.Form["tid"].Trim();
                    tmpParas = new SortedDictionary <string, string>();
                    tmpParas.Add("tid", context.Request.Form["tid"]);
                    tmpParas.Add("format", str9);
                    if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                    {
                        string str16 = context.Request.Form["tid"].Replace("\r\n", "\n");
                        if (!string.IsNullOrEmpty(str16))
                        {
                            str15 = str16;
                            OrderInfo orderInfo = OrderHelper.GetOrderInfo(str15);
                            builder.Append("<trade_get_response>");
                            builder.Append(this.GetOrderDetails(format, orderitemfomat, orderInfo).ToString());
                            builder.Append("</trade_get_response>");
                        }
                        else
                        {
                            str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "tid");
                        }
                    }
                    else
                    {
                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "signature");
                    }
                }
                else
                {
                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid");
                }
                goto Label_07C6;
Label_046D:
                str17 = context.Request.Form["tid"].Trim();
                string str18 = context.Request.Form["out_sid"].Trim();
                string str19 = context.Request.Form["company_code"].Trim();
                if ((!string.IsNullOrEmpty(str17) && !string.IsNullOrEmpty(str19)) && !string.IsNullOrEmpty(str18))
                {
                    tmpParas.Add("tid", str17);
                    tmpParas.Add("out_sid", str18);
                    tmpParas.Add("company_code", str19);
                    tmpParas.Add("format", str9);
                    if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                    {
                        ExpressCompanyInfo express = ExpressHelper.FindNodeByCode(str19);
                        if (!string.IsNullOrEmpty(express.Name))
                        {
                            ShippingModeInfo shippingModeByCompany = SalesHelper.GetShippingModeByCompany(express.Name);
                            OrderInfo        order = OrderHelper.GetOrderInfo(str17);
                            if (order != null)
                            {
                                ApiErrorCode messageenum = this.SendOrders(order, shippingModeByCompany, str18, express);
                                if (messageenum == ApiErrorCode.Success)
                                {
                                    builder.Append("<trade_get_response>");
                                    order = OrderHelper.GetOrderInfo(str17);
                                    builder.Append(this.GetOrderDetails(format, orderitemfomat, order).ToString());
                                    builder.Append("</trade_get_response>");
                                }
                                else
                                {
                                    str4 = MessageInfo.ShowMessageInfo(messageenum, "It");
                                }
                            }
                            else
                            {
                                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "tid");
                            }
                        }
                        else
                        {
                            str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "company_code");
                        }
                    }
                    else
                    {
                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                    }
                }
                else
                {
                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramters");
                }
                goto Label_07C6;
Label_0613:
                str20 = context.Request.Form["order_mark"].Trim();
                string str21 = context.Request.Form["seller_memo"].Trim();
                if ((!string.IsNullOrEmpty(context.Request.Form["tid"].Trim()) && !string.IsNullOrEmpty(str20)) && !string.IsNullOrEmpty(str21))
                {
                    if ((Convert.ToInt32(str20) > 0) && (Convert.ToInt32(str20) < 7))
                    {
                        str15 = context.Request.Form["tid"].Trim();
                        tmpParas.Add("tid", str15);
                        tmpParas.Add("order_mark", str20);
                        tmpParas.Add("seller_memo", str21);
                        tmpParas.Add("format", str9);
                        if (APIHelper.CheckSign(tmpParas, checkCode, sign))
                        {
                            OrderInfo info5 = OrderHelper.GetOrderInfo(str15);
                            info5.ManagerMark   = new OrderMark?((OrderMark)Enum.Parse(typeof(OrderMark), str20, true));
                            info5.ManagerRemark = Globals.HtmlEncode(str21);
                            if (OrderHelper.SaveRemarkAPI(info5))
                            {
                                builder.Append("<trade_get_response>");
                                builder.Append(this.GetOrderDetails(format, orderitemfomat, info5).ToString());
                                builder.Append("</trade_get_response>");
                            }
                            else
                            {
                                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "save is failure ");
                            }
                        }
                        else
                        {
                            str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                        }
                    }
                    else
                    {
                        str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "order_mark");
                    }
                }
                else
                {
                    str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid or order_mark or seller_memo");
                }
                goto Label_07C6;
Label_07B9:
                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "paramters");
Label_07C6:
                s = s + builder.ToString();
                goto Label_07FB;
Label_07D6:
                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "sign");
            }
            catch (Exception exception)
            {
                str4 = MessageInfo.ShowMessageInfo(ApiErrorCode.Unknown_Error, exception.Message);
            }
Label_07FB:
            if (!string.IsNullOrEmpty(str4))
            {
                s = str3 + str4;
            }
            context.Response.ContentType = "text/xml";
            context.Response.Write(s);
        }
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }