public void EmptyNode()
        {
            string xml = @"<?xml version=""1.0"" standalone=""no""?>
			<root>
			  <person id=""1"">
				<name>Alan</name>
				<url />
			  </person>
			  <person id=""2"">
				<name>Louis</name>
				<url>http://www.yahoo.com</url>
			  </person>
			</root>"            ;

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            string jsonText = JavaScriptConvert.SerializeXmlNode(doc);

            Console.WriteLine(jsonText);

            XmlDocument newDoc = (XmlDocument)JavaScriptConvert.DeerializeXmlNode(jsonText);

            Assert.AreEqual(doc.InnerXml, newDoc.InnerXml);
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                this.modeId = context.Request.Form["ModelId"];
                string format = "{{\"success\":{0},\"Result\":{1}}}";
                string modeId = this.modeId;
                if (modeId != null)
                {
                    if (!(modeId == "Load"))
                    {
                        if (modeId == "editedialog")
                        {
                            goto Label_009F;
                        }
                    }
                    else
                    {
                        this.pagename           = context.Request.Form["PageName"];
                        DesigAttribute.PageName = this.pagename;
                        string str2 = this.LoadFirstHtml();
                        if (!string.IsNullOrEmpty(str2))
                        {
                            this.message = string.Format(format, "true", str2);
                        }
                    }
                }
                goto Label_0251;
Label_009F:
                this.desigtype = context.Request.Form["Type"];
                if (this.desigtype != "logo")
                {
                    string str3 = context.Request.Form["Elementid"];
                    if ((this.desigtype != "") && (str3.Split(new char[] { '_' }).Length == 2))
                    {
                        this.elementId  = str3.Split(new char[] { '_' })[1];
                        this.configurl  = Globals.PhysicalPath(HiContext.Current.GetSkinPath() + "/config/" + str3.Split(new char[] { '_' })[0] + ".xml");
                        this.currennode = this.FindNode(str3.Split(new char[] { '_' })[0]);
                        if (this.currennode != null)
                        {
                            string str4 = JavaScriptConvert.SerializeXmlNode(this.currennode);
                            str4         = str4.Remove(0, str4.IndexOf(":") + 1).Remove((str4.Length - (str4.IndexOf(":") + 1)) - 1).Replace("@", "");
                            this.message = string.Format(format, "true", str4);
                        }
                    }
                }
                else
                {
                    this.message = string.Format(format, "true", "{\"LogoUrl\":\"" + HiContext.Current.SiteSettings.LogoUrl + "\",\"DialogName\":\"DialogTemplates/advert_logo.html\"}");
                }
            }
            catch (Exception exception)
            {
                this.message = "{\"success\":false,\"Result\":\"未知错误:" + exception.Message + "\"}";
            }
Label_0251:
            context.Response.ContentType = "text/json";
            context.Response.Write(this.message);
        }
Example #3
0
        public void SerializeNodeTypes()
        {
            XmlDocument doc = new XmlDocument();
            string      jsonText;

            Console.WriteLine("SerializeNodeTypes");

            // XmlAttribute
            XmlAttribute attribute = doc.CreateAttribute("msdata:IsDataSet");

            attribute.Value = "true";

            jsonText = JavaScriptConvert.SerializeXmlNode(attribute);

            Console.WriteLine(jsonText);
            Assert.AreEqual(@"{""@msdata:IsDataSet"":""true""}", jsonText);


            // XmlProcessingInstruction
            XmlProcessingInstruction instruction = doc.CreateProcessingInstruction(
                "xml-stylesheet",
                @"href=""classic.xsl"" type=""text/xml""");

            jsonText = JavaScriptConvert.SerializeXmlNode(instruction);

            Console.WriteLine(jsonText);
            Assert.AreEqual(@"{""?xml-stylesheet"":""href=\""classic.xsl\"" type=\""text/xml\""""}", jsonText);


            // XmlProcessingInstruction
            XmlCDataSection cDataSection = doc.CreateCDataSection("<Kiwi>true</Kiwi>");

            jsonText = JavaScriptConvert.SerializeXmlNode(cDataSection);

            Console.WriteLine(jsonText);
            Assert.AreEqual(@"{""#cdata-section"":""<Kiwi>true</Kiwi>""}", jsonText);


            // XmlElement
            XmlElement element = doc.CreateElement("xs:Choice");

            element.SetAttributeNode(attribute);

            element.AppendChild(instruction);
            element.AppendChild(cDataSection);

            jsonText = JavaScriptConvert.SerializeXmlNode(element);

            Console.WriteLine(jsonText);
            Assert.AreEqual(
                @"{""xs:Choice"":{""@msdata:IsDataSet"":""true"",""?xml-stylesheet"":""href=\""classic.xsl\"" type=\""text/xml\"""",""#cdata-section"":""<Kiwi>true</Kiwi>""}}",
                jsonText);
        }
        public void DocumentFragmentSerialize()
        {
            XmlDocument doc = new XmlDocument();

            XmlDocumentFragment fragement = doc.CreateDocumentFragment();

            fragement.InnerXml = "<Item>widget</Item><Item>widget</Item>";

            string jsonText = JavaScriptConvert.SerializeXmlNode(fragement);

            string expected = @"{""Item"":[""widget"",""widget""]}";

            Assert.AreEqual(expected, jsonText);

            Console.WriteLine("DocumentFragmentSerialize");
            Console.WriteLine(jsonText);
            Console.WriteLine();
        }
        public void NamespaceSerializeDeserialize()
        {
            string xml = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<xs:schema xs:id=""SomeID"" 
	xmlns="""" 
	xmlns:xs=""http://www.w3.org/2001/XMLSchema"" 
	xmlns:msdata=""urn:schemas-microsoft-com:xml-msdata"">
	<xs:element name=""MyDataSet"" msdata:IsDataSet=""true"">
		<xs:complexType>
			<xs:choice maxOccurs=""unbounded"">
				<xs:element name=""customers"" >
					<xs:complexType >
						<xs:sequence>
							<xs:element name=""CustomerID"" type=""xs:integer"" 
										 minOccurs=""0"" />
							<xs:element name=""CompanyName"" type=""xs:string"" 
										 minOccurs=""0"" />
							<xs:element name=""Phone"" type=""xs:string"" />
						</xs:sequence>
					</xs:complexType>
				</xs:element>
			</xs:choice>
		</xs:complexType>
	</xs:element>
</xs:schema>";

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            string jsonText = JavaScriptConvert.SerializeXmlNode(doc);

            XmlDocument deserializedDoc = (XmlDocument)JavaScriptConvert.DeerializeXmlNode(jsonText);

            Assert.AreEqual(doc.InnerXml, deserializedDoc.InnerXml);

            Console.WriteLine("NamespaceSerializeDeserialize");
            Console.WriteLine(jsonText);
            Console.WriteLine(deserializedDoc.InnerXml);
            Console.WriteLine();
        }
Example #6
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       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)
        {
            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);
        }
Example #9
0
        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);
        }
Example #10
0
 public new void ProcessRequest(System.Web.HttpContext context)
 {
     try
     {
         this.modeId = context.Request.Form["ModelId"];
         string format = "{{\"success\":{0},\"Result\":{1}}}";
         string a;
         if ((a = this.modeId) != null)
         {
             if (!(a == "Load"))
             {
                 if (a == "editedialog")
                 {
                     this.desigtype = context.Request.Form["Type"];
                     if (this.desigtype != "logo")
                     {
                         string text = context.Request.Form["Elementid"];
                         if (this.desigtype != "" && text.Split(new char[]
                         {
                             '_'
                         }).Length == 2)
                         {
                             this.elementId = text.Split(new char[]
                             {
                                 '_'
                             })[1];
                             this.configurl = Globals.PhysicalPath(Hidistro.Membership.Context.HiContext.Current.GetSkinPath() + "/config/" + text.Split(new char[]
                             {
                                 '_'
                             })[0] + ".xml");
                             this.currennode = this.FindNode(text.Split(new char[]
                             {
                                 '_'
                             })[0]);
                             if (this.currennode != null)
                             {
                                 string text2 = JavaScriptConvert.SerializeXmlNode(this.currennode);
                                 text2        = text2.Remove(0, text2.IndexOf(":") + 1).Remove(text2.Length - (text2.IndexOf(":") + 1) - 1).Replace("@", "");
                                 this.message = string.Format(format, "true", text2);
                             }
                         }
                     }
                     else
                     {
                         this.message = string.Format(format, "true", "{\"LogoUrl\":\"" + Hidistro.Membership.Context.HiContext.Current.SiteSettings.LogoUrl + "\",\"DialogName\":\"DialogTemplates/advert_logo.html\"}");
                     }
                 }
             }
             else
             {
                 this.pagename           = context.Request.Form["PageName"];
                 DesigAttribute.PageName = this.pagename;
                 string text3 = this.LoadFirstHtml();
                 if (!string.IsNullOrEmpty(text3))
                 {
                     this.message = string.Format(format, "true", text3);
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         this.message = "{\"success\":false,\"Result\":\"未知错误:" + ex.Message + "\"}";
     }
     context.Response.ContentType = "text/json";
     context.Response.Write(this.message);
 }