zoukankan      html  css  js  c++  java
  • ResultJsonInfo<T>

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    namespace QY.WebAPI.Models
    {
        [Serializable]
        public class ResultJsonInfo<T> where T : class
        {
            private string status;
            private T data;
            private string info;
    
            public string Status
            {
                get { return status; }
                set { status = value; }
            }
    
    
            public T Data
            {
                get
                {
                    return data;
                }
                set { data = value; }
            }
    
    
            public string Info
            {
                get { return info; }
                set { info = value; }
            }
        }
    }
    ResultJsonInfo
       [HttpGet]
            public object GetCompanyCountToTypeSummary(DateTime? startTime = null, DateTime? endTime = null)
            {
                RequestWebApi api = new RequestWebApi();
                ResultJsonInfo<ReCompanySummary> redata = new ResultJsonInfo<ReCompanySummary>();
                try
                {
                    string resultapi = api.RequestAPI("http:****//80:/Api/BigData/GetCompanyCountToTypeSummary?startTime=" + endTime + "&endTime=" + endTime);
                    JavaScriptSerializer jsonSerializeprovincee = new JavaScriptSerializer();
                    List<CompanySummary> comsummary = jsonSerializeprovincee.Deserialize<List<CompanySummary>>(resultapi);
                    List<ReCompanySummary.ReCompany> data = new List<ReCompanySummary.ReCompany>();
                    foreach (var item in comsummary)
                    {
                        ReCompanySummary.ReCompany res = new ReCompanySummary.ReCompany();
                        res.DataName = item.TypeName;
                        res.Data = item.TotalCount;
                        res.NewData = item.CountToMonth;          
                        data.Add(res);
                    }
                    
                    redata.Data.recompany = data;
                    redata.Status = "Y";
                    redata.Info = "成功";
                }
                catch (Exception ex)
                {
                    redata.Data = null;
                    redata.Status = "N";
                    redata.Info = ex.ToString();
    
                }
                return Json(redata);
            }
    调用方法
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    namespace QY.WebApi.Models
    {
        public class ReCompanySummary
        {
            public List<ReCompany> recompany { get; set; }
    
            public class ReCompany
            {
                /// <summary>
                /// 数据名称
                /// </summary>
                public string DataName { get; set; }
    
                /// <summary>
                /// 数据
                /// </summary>
                public string Data { get; set; }
    
                /// <summary>
                /// 新增数据
                /// </summary>
                public string NewData { get; set; }
            }
    
        }
    }
    ReCompanySummary
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    namespace QY.WebApi.Models
    {
        public class CompanySummary
        {
            public string TypeName { get; set; }
            public string TotalCount { get; set; }
            public string CountToMonth { get; set; }
        }
    }
    CompanySummary
  • 相关阅读:
    简易温控器的开发
    信号处理电路1:差动转单端输出电路计算于分析
    电容触摸屏资料适合7寸30PINS
    TI Motor Control
    AD规则实例1元件keepout层与覆铜间距
    Python基础语法
    Python基本运算符
    Python 字符串
    javascript>getElementsByClass
    thrift多平台安装
  • 原文地址:https://www.cnblogs.com/yangwujun/p/7404832.html
Copyright © 2011-2022 走看看