JavaScriptSerializer C# 3.5 自带生成Json,不用在去引用Newtonsoft.Json.dll

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Travel.Payment.BackUI.AppCode.OrderAPI;
using Travel.Payment.Proxy.PaymentService;
using System.Runtime.Serialization;

 

namespace Travel.Payment.BackUI.CommenPage
{
    /// <summary>
    /// Summary description for $codebehindclassname$
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class ajax : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            Post(context.Request, context.Response, context);
        }

        private void Post(HttpRequest Request, HttpResponse Response, HttpContext context)
        {
            string operType = Request.Params["OperType"] ?? "";
            switch (operType)
            {
                //得到订单详细,返回数据Json形式
                case "GetOrderDetails":
                    OrderAPI apiOrder = new OrderAPI();
                    long OrderId = long.Parse(Request.Params["OrderId"] ?? "0");
                    apiOrder.Reply =
                        OrderAPI.IPS.QueryOrderPayInfo(new QueryOrderPayInfoRequest
                        {
                            Operator = apiOrder.Request.Operator,
                            OperatorRole = apiOrder.Request.OperatorRole,
                            ValidChargeResult = apiOrder.Request.ValidChargeResult,
                            IncludeDetail = apiOrder.Request.IncludeDetail,
                            OrderId = OrderId
                        });
                    //string stmp = JsonConvert.SerializeObject(apiOrder.Reply.OrderPayInfo);
                    System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                    string stmp = serializer.Serialize(apiOrder.Reply.OrderPayInfo);
                    //DataContractJsonSerializer()
                    Response.Write(stmp);
                    //Travel.Payment.Proxy.PaymentService.PayOrderInfo payOrderInfo = queryOrderPayInfoReply.OrderPayInfo;
                    //Travel.Payment.Proxy.PaymentService.PayOrderItem payOrderItem = payOrderInfo.PayItems.FirstOrDefault();
                    //this.Label1.Text = payOrderInfo.OrderId.ToString();
                    //////国际票还是国内票
                    ////Label7.Text = " ";
                    //this.Label2.Text = payOrderInfo.OrderPrice.ToString();
                    //Label8.Text = payOrderInfo.OrderPriceDue.ToString();
                    //Label3.Text = payOrderInfo.HadPayAmount.ToString();
                    //Label9.Text = payOrderInfo.OldBankCode.ToString();
                    //Label4.Text = payOrderInfo.OrderTime.ToString();
                    break;
            }
        }

 

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

 

你可能感兴趣的:(JavaScript)