/// <summary> /// json转换函数 /// </summary> /// <param name="softs"></param> /// <returns></returns> protected List <SeriesJsonModel> GetDataJsonList(List <Sjqd_StatLifecycle> softs) { ///构造一个json模型 SeriesJsonModel sjModel2 = new SeriesJsonModel(); sjModel2.data = new List <object>(); for (int i = 0; i < softs.Count; i++) { string plat = softs[0].Platform.ToString().ToEnum <MobileOption>(MobileOption.None).ToString(); if (plat == "None") { plat = "不区分平台"; } sjModel2.name = GetSoft(softs[0].SoftID).Name + "_" + plat + "(" + softs[0].StatDate.ToShortDateString() + ")"; DataLabels dl = new DataLabels(); SmallDataLabels smalldata = new SmallDataLabels(); dl.y = Math.Round((softs[i].RetainedUserCount / (double)softs[i].NewUserCount) * 100, 2); dl.growth = dl.y + "%"; dl.Denominator = softs[i].NewUserCount; smalldata.enabled = true; dl.dataLabels = smalldata; sjModel2.data.Add(dl); } seriesJsonStr.Add(sjModel2); return(seriesJsonStr); }
//固件明细数据 protected List <SeriesJsonModel> GetDataJsonListByGjbb(List <DateTime> x_date, List <Sjqd_StatUsersByGjbb> gjbb) { List <SeriesJsonModel> result = new List <SeriesJsonModel>(); SeriesJsonModel sjModel2 = new SeriesJsonModel(); int spanInt = -(x_date.Count / 25 + 1); for (int ii = 0; ii < x_date.Count; ii++) { DataLabels dl = null; sjModel2.data.Add(dl); } sjModel2.name = "固件版本分布"; for (int i = 0; i < gjbb.Count; i++) { for (int j = 0; j < x_date.Count; j++) { if (x_date[j] == gjbb[i].StatDate) { DataLabels dl = new DataLabels(); SmallDataLabels smalldata = new SmallDataLabels(); dl.y = gjbb[i].UseCount; dl.dataLabels = smalldata; if (j % spanInt == 0)//这个间隔和x轴设置是一样的 { smalldata.enabled = true; } ///替换掉以前的null sjModel2.data[j] = dl; } } } result.Add(sjModel2); return(result); }
/// <summary> /// 获取y轴数据 /// </summary> /// <param name="temp"></param> protected void GetDataJsonList(List <List <Monitor_DataLogs> > temp) { foreach (var item in temp) { ///构造一个json模型 SeriesJsonModel sjModel2 = new SeriesJsonModel(); for (int ii = 0; ii < X_DateTime.Count; ii++) { sjModel2.data.Add(null); } sjModel2.name = item[0].DataLogName + "_" + item[0].ServerIp; if (X_DateTime.Count <= LineMaxNum) { for (int j = 0; j < X_DateTime.Count; j++) { for (int i = 0; i < item.Count; i++) { if (item[i].LogDate == X_DateTime[j]) { DataLabels dl = new DataLabels(); SmallDataLabels smalldata = new SmallDataLabels(); dl.y = item[i].LogFileSize; smalldata.enabled = true; dl.dataLabels = smalldata; ///替换掉以前的null sjModel2.data[j] = dl; break; } } } SeriesJsonModels.Add(sjModel2); } else { for (int j = 0; j < X_DateTime.Count; j++) { for (int i = 0; i < item.Count; i++) { if (item[i].LogDate == X_DateTime[j]) { DataLabels dl = new DataLabels(); SmallDataLabels smalldata = new SmallDataLabels(); dl.y = item[i].LogFileSize; if (j % (LineMaxNumCoef) == 0) { smalldata.enabled = true; } dl.dataLabels = smalldata; ///替换掉以前的null sjModel2.data[j] = dl; break; } } } SeriesJsonModels.Add(sjModel2); } } }
/// <summary> /// 获取y轴数据 /// </summary> /// <param name="serverIp"></param> /// <param name="yData"></param> protected void GetDataJsonList(string serverIp, List <int> yData) { ///构造一个json模型 SeriesJsonModel sjModel2 = new SeriesJsonModel(); for (int ii = 0; ii < yData.Count; ii++) { sjModel2.data.Add(null); } sjModel2.name = serverIp; if (yData.Count <= LineMaxNum) { for (int j = 0; j < yData.Count; j++) { DataLabels dl = new DataLabels(); SmallDataLabels smalldata = new SmallDataLabels(); dl.y = yData[j]; smalldata.enabled = true; dl.dataLabels = smalldata; ///替换掉以前的null sjModel2.data[j] = dl; } SeriesJsonModels.Add(sjModel2); } else { for (int j = 0; j < yData.Count; j++) { DataLabels dl = new DataLabels(); SmallDataLabels smalldata = new SmallDataLabels(); dl.y = yData[j]; if (j % (LineMaxNumCoef) == 0) { smalldata.enabled = true; } dl.dataLabels = smalldata; ///替换掉以前的null sjModel2.data[j] = dl; } SeriesJsonModels.Add(sjModel2); } }
//操作系统明细数据 protected List <SeriesJsonModel> GetDataJsonListByOsVersion(List <DateTime> x_date, List <Sjqd_StatUsersByOsVersion> osVersions) { List <SeriesJsonModel> result = new List <SeriesJsonModel>(); ///构造一个json模型 SeriesJsonModel sjModel2 = new SeriesJsonModel(); ///构造对应x轴上对应各个坐标点,一开始就是null ,先填充好 int spanInt = -(x_date.Count / 25 + 1); for (int ii = 0; ii < x_date.Count; ii++) { DataLabels dl = null; sjModel2.data.Add(dl); } sjModel2.name = "操作系统分布"; for (int i = 0; i < osVersions.Count; i++) { for (int j = 0; j < x_date.Count; j++) { if (x_date[j] == osVersions[i].StatDate) { DataLabels dl = new DataLabels(); SmallDataLabels smalldata = new SmallDataLabels(); dl.y = osVersions[i].UseCount; dl.dataLabels = smalldata; if (j % spanInt == 0)//这个间隔和x轴设置是一样的 { smalldata.enabled = true; } ///替换掉以前的null sjModel2.data[j] = dl; } } } result.Add(sjModel2); return(result); }
protected List <SeriesJsonModel> GetDataJsonList(List <List <SoftUser> > temp) { foreach (List <SoftUser> item in temp) { //构造一个json模型 SeriesJsonModel sjModel2 = new SeriesJsonModel(); //构造对应x轴上对应各个坐标点,一开始就是null ,先填充好 for (int ii = 0; ii < X_DateTime.Count; ii++) { DataLabels dl = new DataLabels(); dl.y = 0; sjModel2.data.Add(dl); } if (item.Count > 0 && X_DateTime.Count <= MaxNum) { sjModel2.name = ((MobileOption)item[0].Platform).GetDescription(); for (int j = 0; j < X_DateTime.Count; j++) { for (int i = 0; i < item.Count; i++) { if (item[i].StatDate == X_DateTime[j]) { DataLabels dl = new DataLabels(); SmallDataLabels smalldata = new SmallDataLabels(); dl.y = item[i].NewNum; smalldata.enabled = true; dl.dataLabels = smalldata; //替换掉以前的null sjModel2.data[j] = dl; } } } seriesJsonStr.Add(sjModel2); } //当大于20个的时候线上的点要格一定数目显示 else if (X_DateTime.Count > MaxNum) { sjModel2.name = ((MobileOption)item[0].Platform).GetDescription(); for (int j = 0; j < X_DateTime.Count; j++) { for (int i = 0; i < item.Count; i++) { if (item[i].StatDate == X_DateTime[j]) { DataLabels dl = new DataLabels(); SmallDataLabels smalldata = new SmallDataLabels(); dl.y = item[i].NewNum; if (j % (MaxNumCoef) == 0) { smalldata.enabled = true; } dl.dataLabels = smalldata; //替换掉以前的null sjModel2.data[j] = dl; } } } seriesJsonStr.Add(sjModel2); } } return(seriesJsonStr); }
//最近三十天数据 private List <SeriesJsonModel> GetDataJsonList(List <DateTime> x_date, List <SoftUser> softs, int type) { List <SeriesJsonModel> result = new List <SeriesJsonModel>(); ///构造一个json模型 SeriesJsonModel sjModel2 = new SeriesJsonModel(); ///构造对应x轴上对应各个坐标点,一开始就是null ,先填充好 for (int ii = 0; ii < x_date.Count; ii++) { DataLabels dl = null; sjModel2.data.Add(dl); } if (type == 2) { for (int i = 0; i < softs.Count; i++) { sjModel2.name = "活跃"; for (int j = 0; j < x_date.Count; j++) { if (x_date[j] == softs[i].StatDate) { DataLabels dl = new DataLabels(); SmallDataLabels smalldata = new SmallDataLabels(); dl.y = softs[i].ActiveNum; dl.dataLabels = smalldata; if (j % (-3) == 0)//这个间隔和x轴设置是一样的 { smalldata.enabled = true; } ///替换掉以前的null sjModel2.data[j] = dl; } } } } else { for (int i = 0; i < softs.Count; i++) { sjModel2.name = "新增"; for (int j = 0; j < x_date.Count; j++) { if (x_date[j] == softs[i].StatDate) { DataLabels dl = new DataLabels(); SmallDataLabels smalldata = new SmallDataLabels(); dl.y = softs[i].NewNum; dl.dataLabels = smalldata; if (j % (-3) == 0)//这个间隔和x轴设置是一样的 { smalldata.enabled = true; } ///替换掉以前的null sjModel2.data[j] = dl; } } } } result.Add(sjModel2); return(result); }
protected string GetDataJsonList(List <Sjqd_ULSessionAvgUsers> users, List <DateTime> X_DateTime, bool isSessionLength) { List <SeriesJsonModel> seriesJsonStr = new List <SeriesJsonModel>(); ///构造一个json模型 SeriesJsonModel sjModel2 = new SeriesJsonModel(); if (isSessionLength) { sjModel2.name = "人均日使用时长"; } else { sjModel2.name = "人均启动次数(不区分版本)"; } if (X_DateTime.Count <= MaxNum) { for (int ii = 0; ii < X_DateTime.Count; ii++) { DataLabels dl = null; sjModel2.data.Add(dl); } for (int j = 0; j < X_DateTime.Count; j++) { foreach (Sjqd_ULSessionAvgUsers item in users) { if (item.StatDate == X_DateTime[j]) { DataLabels dl = new DataLabels(); SmallDataLabels smalldata = new SmallDataLabels(); if (isSessionLength) { dl.y = (double)item.AvgSessionLength; } else { dl.y = (double)item.AvgSessions; } smalldata.enabled = true; dl.dataLabels = smalldata; ///替换掉以前的null sjModel2.data[j] = dl; break; } } } } else { for (int ii = 0; ii < X_DateTime.Count; ii++) { DataLabels dl = null; sjModel2.data.Add(dl); } for (int j = 0; j < X_DateTime.Count; j++) { foreach (Sjqd_ULSessionAvgUsers item in users) { if (item.StatDate == X_DateTime[j]) { DataLabels dl = new DataLabels(); SmallDataLabels smalldata = new SmallDataLabels(); if (isSessionLength) { dl.y = (double)item.AvgSessionLength; } else { dl.y = (double)item.AvgSessions; } if (j % (MaxNumCoef) == 0) { smalldata.enabled = true; } dl.dataLabels = smalldata; ///替换掉以前的null sjModel2.data[j] = dl; break; } } } } seriesJsonStr.Add(sjModel2); return(JsonConvert.SerializeObject(seriesJsonStr)); }