接口json转化为datatable

   #region ------获取实验桩基数据信息------
        /// <summary>
        /// 获取实验桩基数据信息
        /// </summary>
        /// <param name="_StrCompactpid">项目ID</param>
        /// <param name="_StrPileid">桩号</param>
        /// <param name="CurPageIndex">当前页</param>
        /// <param name="PageCount">总页数</param>
        /// <param name="DataCount">数据总数</param>
        /// <param name="PageSize">每页显示数</param>
        /// <returns></returns>
        public static DataTable GetZjData(string _StrCompactpid, string _StrPileid, int CurPageIndex, ref int PageCount, ref int DataCount, ref int PageSize)
        {
            try
            {
                string StrUrl = ConfigurationManager.AppSettings["DjProJectPileUrl"];//getCreditFinallAccount  http://116.26.134.7:8082/sospweb/com/zr/pileCRating/quarterPile!query_pileby_cpid.do?key=zr88230232&compactpid=4BA855FBDBDC4049B73808B109049FA4&curPage=1
                string strWhere = "key=zr88230232" + "&compactpid=" + _StrCompactpid;
                strWhere += _StrPileid == "" ? "" : "&pileid=" + _StrPileid;
                strWhere += CurPageIndex == 0 ? "" : "&curPage=" + CurPageIndex.ToString();
                string strJson = PostGetData(StrUrl, strWhere);

                DataTable dt = new DataTable();
                #region --解析Jason结果--
                Root root = JSonUtil.Deserialize<Root>(strJson);
                PageCount = root.总页数;
                DataCount = root.总条数;
                PageSize = root.每页条数;
                foreach (Dictionary<string, string> item in root.data)
                {
                    DataRow dr = dt.NewRow();
                    foreach (KeyValuePair<string, string> it in item)
                    {
                        if (!dt.Columns.Contains(it.Key))
                        {
                            var dc = new DataColumn();
                            dc.ColumnName = it.Key;
                            dt.Columns.Add(dc);
                        }
                        dr[it.Key] = it.Value;
                    }
                    dt.Rows.Add(dr);
                }
                #endregion ----
                return dt;
            }
            catch (Exception ex)
            {
                WebHelp.WriteLog(ex.Message);
                return null;
            }
        }
        #endregion ------------
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值