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; } } } }
[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; } } } }
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; } } }