• Android客户端发送Post/Get请求到Asp.Net服务端一般处理程序Asp.Net进行参数解析


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using DTK.MIS.Entities;
    using System.Data;
    using DTK.MIS.DAL;
    using Newtonsoft.Json;
    using DTK.MIS.Common;
    using System.IO;
    
    namespace DTKMIS.api
    {
        /// <summary>
        /// GetCompanyInfoSearch 企业信息查询
        /// </summary>
        public class GetCompanyInfoSearch : IHttpHandler
        {
    
            PageBaseParent p = new PageBaseParent();
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "application/json";
                CpyCompanyInfoEntity model = new CpyCompanyInfoEntity();
                CompanyInfoEntity entity = null;
                context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                using (var reader = new StreamReader(context.Request.InputStream))
                {
                    String postJson = reader.ReadToEnd();
                    entity = (CompanyInfoEntity)JsonConvert.DeserializeObject(postJson, typeof(CompanyInfoEntity));
                }
                int pagesize = 10;
                int pageindex = 1;
                int recordCount = -1;
                string SSFWD = "";
                string SSSQ = "";
                if (context.Request.RequestType.ToLower() == "post")
                {
                    pagesize = entity.pagesize;
                    pageindex = entity.pageindex;
                    recordCount = entity.recordCount;
                    model.QYMC = entity.QYMC;
                    model.SSHY = entity.SSHY;
                    SSFWD = entity.SSFWD;
                    SSSQ = entity.SSSQ;
                    model.ZZJGDM = entity.ZZJGDM;
                    model.LXRXM = entity.LXRXM;
                    model.Status = entity.Status;
                }
                DataTable dt = new DataTable();
                DataSet dsInfo = CpyCompanyInfoDalProvider.GetInstance().GetPagedWsysAPP(pagesize, pageindex, ref recordCount, model, SSFWD, SSSQ);
                dt = dsInfo.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    dr["SSHY"] = p.GetBaseDateName(dr["SSHY"].ToString());
                    dr["SSFWD"] = p.GetBSNameByID(dr["SSFWD"].ToString());
                    dr["SSSQ"] = p.GetBSNameByID(dr["SSSQ"].ToString());
                }
                SetParameter para = new SetParameter();
                para.data.CompanyInfo = dt;
                para.recordCount = recordCount;
                para.state = 1;
                para.msg = "操作成功";
                string strJson = JsonConvert.SerializeObject(para);
                context.Response.Write(strJson);
            }
            public class SetParameter
            {
                public int recordCount;
                public int state;
                public string msg;
                public DataStatus data = new DataStatus();
            }
            public class DataStatus
            {
                public DataTable CompanyInfo { get; set; }
            }
            /// <summary>
            /// POST:参数实体类
            /// </summary>
            public class CompanyInfoEntity
            {
                public int pagesize { get; set; }
                public int pageindex { get; set; }
                public int recordCount { get; set; }
                public string QYMC { get; set; }
                public int SSHY { get; set; }
                public string SSFWD { get; set; }
                public string SSSQ { get; set; }
                public string ZZJGDM { get; set; }
                public string LXRXM { get; set; }
                public string Status { get; set; }
            }
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }
    

      

  • 相关阅读:
    centos和ubuntu配置路由的三种方式
    程序包编译安装
    逻辑卷磁盘管理和dd命令
    linux磁盘管理
    CDOJ 1269 ZhangYu Speech 数组处理
    poj 2236 Wireless Network 并查集
    poj 1182 食物链 并查集
    POJ 2109 Power of Cryptography 数学题 double和float精度和范围
    CDOJ 1264 人民币的构造 区间问题+数论
    CDOJ 1263 The Desire of Asuna 贪心
  • 原文地址:https://www.cnblogs.com/xiaoyao095/p/4350710.html
Copyright © 2020-2023  润新知