/// <summary> /// 生成所有曲线的JSON /// </summary> protected void GetAllLineJson() { LineChart chart = new LineChart(BeginTime, EndTime); chart.Period = Period; chart.NeedForecastPoint = (Period == net91com.Stat.Core.PeriodOptions.Daily || Period == net91com.Stat.Core.PeriodOptions.Weekly || Period == net91com.Stat.Core.PeriodOptions.Monthly); SetChart(chart, ListAll); SetChart(chart, ListAllForCompare, true); AxisJsonStr = string.Format("{{{0},labels:{{align:'left',tickLength:80,tickPixelInterval:140{1},step:{2}}}}}" , chart.GetXJson() , Period == net91com.Stat.Core.PeriodOptions.Hours ? ",rotation:-45,x:-40,y:60" : (Period == net91com.Stat.Core.PeriodOptions.TimeOfDay ? ",x:-5" : ",rotation:-45,x:-30,y:45") , chart.Step); SeriesJsonStr = chart.GetYJson( delegate(LineChartPoint point) { SoftUser user = (SoftUser)point.DataContext; if (point.Type != -1) { return(string.Format(",\"growth\":\"{0}\",\"Denominator\":{1},\"Other\":null", point.Percent, point.Denominator)); } else { return(string.Format(",\"growth\":\"{0}\",\"Denominator\":{1},\"Other\":null", "", "0")); } }); }
public async Task<ActionResult> Index(string returnUrl) { if (string.IsNullOrWhiteSpace(returnUrl)) returnUrl = "~/"; if (User.Identity.IsAuthenticated) return RedirectPermanent(returnUrl); const string identityKey = "identity"; var lastIdentity = GetCookiesVal(identityKey); if ((string.IsNullOrWhiteSpace(lastIdentity?.Value)) && returnUrl.Contains(identityKey)) { lastIdentity = ((Func<HttpCookie>)(() => { var singleOrDefault = returnUrl.Split('&').Where(s => s.Contains(identityKey)).ToList().SingleOrDefault(); if (singleOrDefault != null) { var val = singleOrDefault.Split('=')[1].Decrypt().Split('|'); if (Convert.ToDateTime(val[0]) >= DateTime.Now.AddSeconds(Framework.Instance.GetConfigValue<int>(ApplicationConfiguration.SecureLinkTimeOut) * -1)) { SetCookiesVal(identityKey, val[1].Encrypt()); } else { var msg = new { ContinueLink = "", Message = "Link Expired!", Type = "info" }; ViewData.Add("CommonMessage", msg); } } return GetCookiesVal(identityKey); }))(); } //else if user just typed url on address bar or hit bookmark else if ((string.IsNullOrWhiteSpace(lastIdentity?.Value)) && !returnUrl.Contains(identityKey) && new Framework().GetConfigValue<bool>(ApplicationConfiguration.WindowAuthontication)) { //redirect to windows auth provider site with return url if request is from internal network //if (!Request.HttpMethod...Current.IsInternet()) //{ // returnUrl = $"{Request.Url.Scheme}://{Request.Url.Authority}{returnUrl}"; // var winauthUrl = Framework.Instance.GetConfigValue<string>(ApplicationConfiguration.WinIdentityProviderURL) + "/Security/SecureRedirect?redirectUrl=" + returnUrl; // return RedirectPermanent(winauthUrl); //} } if (!string.IsNullOrWhiteSpace(lastIdentity?.Value)) { var user = new SoftUser(lastIdentity.Value.Decrypt()); if (user.IsValidUser) { var enableSingleSignOn = Framework.Instance.GetConfigValue<bool>(ApplicationConfiguration.EnableSingleSignOn); await SignInManager.SignInAsync(user, enableSingleSignOn, enableSingleSignOn); return RedirectPermanent(returnUrl); } } return RedirectToAction("Login"); }
//获取基础信息统计 public void GetTableJcXx() { //已经按照时间倒叙了 取得范围是80天里面选 _usersfor80Days = Ds.GetUsersWithNoPeriodCache(EndTime.AddDays(-80), EndTime, SoftID, PlatID, CacheTimeOption.HalfDay).OrderByDescending(p => p.StatDate).ToList(); List <SoftUser> users = _usersfor80Days; if (users.Count != 0) { int totalNum = users.Max(p => p.TotalNum); //周用户数据 SoftUser weekUser = users.Where(p => p.Period == (int)net91com.Stat.Core.PeriodOptions.Weekly).OrderByDescending(p => p.StatDate).FirstOrDefault(); int weekActivity = 0; string weekPercent = "--"; if (weekUser != null) { weekActivity = weekUser.ActiveNum; weekPercent = weekUser.ActivityPercent; } SoftUser monthUser = users.Where(p => p.Period == (int)net91com.Stat.Core.PeriodOptions.Monthly).OrderByDescending(p => p.StatDate).FirstOrDefault(); ///获取月留存数据 var list = new RetainedUsersService(true) .GetStatRetainedUsersCache(SoftID, PlatID, -1, net91com.Stat.Core.PeriodOptions.Monthly, EndTime.AddDays(-80), EndTime, CacheTimeOption.TenMinutes, ChannelTypeOptions.Category, loginService); Sjqd_StatChannelRetainedUsers lastretainuser = list.Count == 0? null:list.OrderBy(p => p.OriginalDate).Last(); //数据库还 没有值 int monthActivity = 0; string monthPercent = "--"; int monthnew = 0; if (monthUser != null) { monthActivity = monthUser.ActiveNum; monthPercent = monthUser.ActivityPercent; monthnew = monthUser.NewNum; } string percent = lastretainuser == null ? "--" : (lastretainuser.RetainedUserCount * 100 / (decimal)lastretainuser.OriginalNewUserCount).ToString("0.00") + "%"; StringBuilder sb = new StringBuilder("<table class=\" tablesorter \" cellspacing=\"1\">"); sb.Append(@" <thead><tr> <th>累计用户</th> <th>周活跃用户</th> <th>周跃率</th> <th>月活跃用户</th> <th>月活跃率</th> <th>月新增用户</th> <th>上月留存率</th> </tr></thead>"); sb.Append("<tbody>"); sb.Append("<tr class=\"tableover\">"); sb.AppendFormat(@"<td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td>", Utility.SetNum(totalNum), Utility.SetNum(weekActivity), weekPercent, Utility.SetNum(monthActivity), monthPercent, monthnew, percent); sb.Append("</tr>"); sb.Append("</tbody></table>"); TabStrJcXx = sb.ToString(); } }
//计算预估时间 protected SoftUser GetForeCastSoftUser(List <ForecastSoftUser> softUser) { if (softUser.Count == 0) { return(null); } ///第0个是边缘点,对应最后统计的那个值 SoftUser su = new SoftUser(); if (softUser.Count > 1) { List <double> countDouble = new List <double>(); for (int i = softUser.Count - 1; i >= 0; i--) { double tempdouble; if (i == 0) { break; } if (softUser[i - 1].TotalUserCount == 0) { tempdouble = 0; } else { tempdouble = softUser[i - 1].NewUserCount / (double)softUser[i].TotalUserCount; } countDouble.Add(tempdouble); } double allDouble = 0; foreach (var item in countDouble) { allDouble += item; } su.Growth = (allDouble / countDouble.Count * 100).ToString("0.00") + "%"; su.NewNum = (int)(allDouble / countDouble.Count * softUser[0].TotalUserCount); } else if (softUser.Count == 1) //如果只有一个参考值,则可以认为是实时计算结果 { su.Growth = ""; su.NewNum = softUser[0].NewUserCount; } su.Period = softUser[0].Period; su.Platform = softUser[0].Platform; su.TotalNum = su.NewNum + softUser[0].TotalUserCount; su.StatDate = softUser[0].ForecaseDate; return(su); }
/// <summary> /// 生成所有曲线的JSON /// </summary> protected void GetShowData() { LineChart chart = new LineChart(BeginTime, MaxTime); StringBuilder tablesb = new StringBuilder(); chart.Period = Period; for (int i = 0; i < ListAll.Count; i++) { string softName = GetSoft(ListAll[i][0].SoftId).Name; string platform = "_" + ((MobileOption)ListAll[i][0].Platform).GetDescription(); chart.Y.Add( new LineChartLine { Name = softName + platform + "_流失", Show = true, XIntervalDays = 0, Points = ListAll[i].Where(p => p.LostNum != -1).Select(a => new LineChartPoint { XValue = a.StatDate, YValue = a.LostNum, DataContext = a }).ToList() }); chart.Y.Add( new LineChartLine { Name = softName + platform + "_活跃", Show = true, XIntervalDays = 0, Points = ListAll[i].Where(p => p.LostNum != -1).Select(a => new LineChartPoint { XValue = a.StatDate, YValue = a.UseNum, DataContext = a }).ToList() }); TabStr.Add(softName + platform); tablesb.Append(GetOneTableHtml(ListAll[i], i)); } AxisJsonStr = string.Format("{{{0},labels:{{align:'left',tickLength:80,tickPixelInterval:140{1},step:{2}}}}}" , chart.GetXJson() , "" , chart.Step); SeriesJsonStr = chart.GetYJson( delegate(LineChartPoint point) { SoftUser user = (SoftUser)point.DataContext; return(string.Format(",\"growth\":\"{0}\",\"Denominator\":{1},\"Other\":null", point.Percent, point.Denominator)); }); TableStr = tablesb.ToString(); }
///预估算法(慨况需要的) protected SoftUser GetForeCastSoftUser(List <SoftUser> softUser) { double frontNewGroupth = 0; double activityPercent = 0; foreach (var item in softUser) { //我的growth 加入了百分号 frontNewGroupth += Convert.ToDouble(item.Growth.Substring(0, item.Growth.Length - 1)) / 100; activityPercent += item.ActiveNum / (double)item.TotalNum; } frontNewGroupth = frontNewGroupth / softUser.Count; activityPercent = activityPercent / softUser.Count; SoftUser su = new SoftUser(); su.NewNum = Convert.ToInt32(softUser[0].TotalNum * frontNewGroupth); su.TotalNum = su.NewNum + softUser[0].TotalNum; su.ActiveNum = Convert.ToInt32(activityPercent * su.TotalNum); su.ActivityPercent = activityPercent.ToString("0.00") + "%"; return(su); }
private void GetDownLoadForCustomEn() { DateTime begintime = Convert.ToDateTime(HttpContext.Current.Request["inputtimestart"]); DateTime endtime = Convert.ToDateTime(HttpContext.Current.Request["inputtimeend"]); int excelsoft = Convert.ToInt32(HttpContext.Current.Request["excelsoft"]); int plat = Convert.ToInt32(HttpContext.Current.Request["excelplatform"]); string selectCountryId = ThisRequest["mycountry"] ?? string.Empty; int channelid = Convert.ToInt32(net91com.Common.CryptoHelper.DES_Decrypt(HttpContext.Current.Request["p"], "ndwebweb")); StatUsersService suService = new StatUsersService(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> userList = null; if (selectCountryId == string.Empty) { userList = suService.GetStatUsersByChannel(excelsoft, plat, ChannelTypeOptions.Customer, channelid, (int)net91com.Stat.Core.PeriodOptions.Daily, begintime, endtime, false, true); } else { userList = suService.GetStatUsersByArea(excelsoft, plat, ChannelTypeOptions.Customer, channelid, selectCountryId, (int)net91com.Stat.Core.PeriodOptions.Daily, begintime, endtime, false, true); } List <SoftUser> users = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in userList) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = excelsoft; softuser.Platform = plat; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; users.Add(softuser); } users = users.OrderBy(p => p.StatDate).ToList(); HttpResponse resp; resp = HttpContext.Current.Response; resp.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); string filename = "渠道统计.xls"; //真正算出的时间 DateTime dtrighttime = UtilityService.GetInstance().GetMaxChannelUserTimeCache(excelsoft, MobileOption.None, net91com.Stat.Core.PeriodOptions.Daily, CacheTimeOption.TenMinutes); //下午两点才能开放出去 if (endtime >= dtrighttime && (DateTime.Now < dtrighttime.AddHours(38))) { endtime = dtrighttime.AddDays(-1); } AddHead(filename); //文件标题+内容 string colHeaders = "", ls_item = ""; //列数 int cl = 2; colHeaders += "日期" + "\t" + "新增用户" + "\t\n"; resp.Write(colHeaders); //向HTTP输出流中写入取得的数据信息 int total = users.Sum(p => p.NewNum); //逐行处理数据 foreach (SoftUser row in users) { //当前行数据写入HTTP输出流,并且置空ls_item以便下行数据 for (int i = 0; i < cl; i++) { if (i == 0) { ls_item += row.StatDate.ToString("yyyy-MM-dd") + "\t"; } else if (i == 1) { ls_item += row.NewNum + "\n"; } } resp.Write(ls_item); ls_item = ""; } ls_item += "总计" + "\t"; ls_item += total + "\n"; resp.Write(ls_item); resp.End(); }
public void GetExcelNewUser() { try { net91com.Stat.Core.PeriodOptions Period = HttpContext.Current.Request["inputzhouqi"].ToEnum <net91com.Stat.Core.PeriodOptions>(net91com.Stat.Core.PeriodOptions.Daily); DateTime begintime = Convert.ToDateTime(HttpContext.Current.Request["inputtimestart"]); DateTime endtime = Convert.ToDateTime(HttpContext.Current.Request["inputtimeend"]); int excelsoft = Convert.ToInt32(HttpContext.Current.Request["excelsoft"]); int channelcate = Convert.ToInt32(HttpContext.Current.Request["channelcate"]); int channeltype = Convert.ToInt32(HttpContext.Current.Request["channeltype"]); ///检查权限 CheckHasRight(excelsoft, "Reports/NewUserReport.aspx"); int excelplatform = Convert.ToInt32(HttpContext.Current.Request["excelplatform"]); SetStandardTime(Period, begintime, endtime); List <SoftUser> users; if (channelcate == -1) { if (Period != net91com.Stat.Core.PeriodOptions.Hours && Period != net91com.Stat.Core.PeriodOptions.TimeOfDay) { users = Sjqd_StatUsersService.GetInstance().GetSoftUserListCache(begintime, endtime, excelsoft, (int)excelplatform, Period, loginService, CacheTimeOption.TenMinutes).OrderByDescending(p => p.StatDate).ToList(); } else { //users = StatUsersByHourService.GetInstance().GetHourUserDataCache(excelsoft, excelplatform, begintime, endtime, Period, loginService,CacheTimeOption.TenMinutes).OrderByDescending(p => p.StatDate).ToList(); net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService suService = new net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsers; ssUsers = suService.GetStatUsersByHour(excelsoft, excelplatform, ChannelTypeOptions.Category, 0, (int)Period, begintime, endtime); users = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsers) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = excelsoft; softuser.Platform = excelplatform; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; users.Add(softuser); } users = users.OrderBy(p => p.StatDate).ToList(); } } else { if (Period != net91com.Stat.Core.PeriodOptions.Hours && Period != net91com.Stat.Core.PeriodOptions.TimeOfDay) { users = Sjqd_StatUsersByChannelsService.GetInstance().GetSoftUserChanelListCache(begintime, endtime, excelsoft, excelplatform, Period, (ChannelTypeOptions)channeltype, channelcate, "", false, loginService, CacheTimeOption.TenMinutes).OrderBy(p => p.StatDate).ToList(); } else { net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService suService = new net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsers; ssUsers = suService.GetStatUsersByHour(excelsoft, excelplatform, (ChannelTypeOptions)channeltype, channelcate, (int)Period, begintime, endtime); users = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsers) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = excelsoft; softuser.Platform = excelplatform; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; users.Add(softuser); } users = users.OrderBy(p => p.StatDate).ToList(); } } HttpResponse resp; resp = HttpContext.Current.Response; resp.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); string filename = "新增用户.xls"; AddHead(filename); //是否是内部软件 bool isInternalSoft = AvailableSofts.FirstOrDefault(a => a.ID == excelsoft) != null; resp.Write(TableTemplateHelper.BuildStatUsersTable(excelsoft, (MobileOption)excelplatform, isInternalSoft, channelcate != -1, Period, "new", false, users, true, 0, "")); resp.End(); } catch (Exception) { HttpContext.Current.Response.Write(""); } }
/// <summary> /// 设置曲线 /// </summary> /// <param name="chart"></param> /// <param name="list"></param> /// <param name="iscompare"></param> protected void SetChart(LineChart chart, List <List <SoftUser> > list, bool iscompare = false) { //对比线前后时间差值 int intervalDays = 0; if (iscompare && ListAll[0].Count != 0 && ListAllForCompare.Count != 0 && ListAllForCompare[0].Count != 0) { intervalDays = ListAll[0][0].StatDate.Subtract(ListAllForCompare[0][0].StatDate).Days; } for (int i = 0; i < list.Count; i++) { string softName = GetSoft(list[i][0].SoftId).Name; string platform = "_" + ((MobileOption)list[i][0].Platform).GetDescription(); if (platform == "_None") { platform = "_不区分平台"; } string channelName = QuDao ? "_" + list[i][0].ChannelName : string.Empty; List <LineChartPoint> MyPoints = null; if (reporttype.Value == "0") { MyPoints = list[i].Select( a => new LineChartPoint { XValue = a.StatDate, YValue = a.NewNum, DataContext = a }).ToList(); } else { MyPoints = list[i].Select( a => new LineChartPoint { XValue = a.StatDate, YValue = a.ActiveNum, DataContext = a, Denominator = a.TotalNum, Percent = a.ActivityPercent }).ToList(); } LineChartLine line = new LineChartLine { Name = softName + platform + channelName + (iscompare?"_对比线":""), Show = true, XIntervalDays = intervalDays, Points = MyPoints }; if (ForeCastUserDatas.Count > 0 && reporttype.Value == "0" && !iscompare) { List <ForecastSoftUser> tempMyForecastUser = ForeCastUserDatas.Where(p => p.Period == (int)Period).Where(p => p.SoftId == ListAll[i][0].SoftId && p.Platform == ListAll[i][0].Platform && ListAll[i][0].ChannelID == p.ChannelID).OrderByDescending(p => p.StatDate).ToList(); SoftUser user = GetForeCastSoftUser(tempMyForecastUser); if (user != null) { line.ForecastPoint = new LineChartPoint { YValue = user.NewNum, DataContext = user } } ; } //mileStoneDate[i].ForEach(a => line.AddMarker(a.MileStoneDate, Period, a.Remarks)); chart.Y.Add(line); } }
public virtual async Task Authorize(SoftLicense softLicense, SoftUser softUser) { #region 检查参数是否有效 if (softLicense == null) { throw new UserFriendlyException("卡密数据不存在!"); } if (softUser == null) { throw new UserFriendlyException("用户不存在!"); } if (softLicense.Status != SoftLicenseStatus.Sell) { throw new UserFriendlyException("卡密不存在或已被使用!"); } if (!softUser.IsActive) { throw new UserFriendlyException("用户账号被停用,无法授权!"); } //判断用户是否已经授权本软件至永久 var userLicenseInfo = await _softUserLicenseRepository.FirstOrDefaultAsync(t => t.SoftId == softLicense.SoftId && t.SoftUserId == softUser.Id); if (userLicenseInfo != null && !userLicenseInfo.ExpireTime.HasValue) { throw new UserFriendlyException("软件已经授权到永久,无需授权!"); } #endregion #region 授权 if (userLicenseInfo == null) { userLicenseInfo = new SoftUserLicense(); userLicenseInfo.SoftId = softLicense.SoftId; userLicenseInfo.SoftUserId = softUser.Id; userLicenseInfo.AuthorizeTime = DateTime.Now; userLicenseInfo.IsActive = true; userLicenseInfo.Type = SoftUserLicenseType.Fee; switch (softLicense.LicenseType) { case SoftLicenseType.Day: userLicenseInfo.ExpireTime = DateTime.Now.AddDays(1); break; case SoftLicenseType.Forever: userLicenseInfo.ExpireTime = null; break; case SoftLicenseType.Hour: userLicenseInfo.ExpireTime = DateTime.Now.AddHours(1); break; case SoftLicenseType.Month: userLicenseInfo.ExpireTime = DateTime.Now.AddMonths(1); break; case SoftLicenseType.Week: userLicenseInfo.ExpireTime = DateTime.Now.AddDays(7); break; case SoftLicenseType.Year: userLicenseInfo.ExpireTime = DateTime.Now.AddYears(1); break; } await _softUserLicenseRepository.InsertAsync(userLicenseInfo); } else { userLicenseInfo.Type = SoftUserLicenseType.Fee; switch (softLicense.LicenseType) { case SoftLicenseType.Day: userLicenseInfo.ExpireTime = userLicenseInfo.ExpireTime.Value.AddDays(1); break; case SoftLicenseType.Forever: userLicenseInfo.ExpireTime = null; break; case SoftLicenseType.Hour: userLicenseInfo.ExpireTime = userLicenseInfo.ExpireTime.Value.AddHours(1); break; case SoftLicenseType.Month: userLicenseInfo.ExpireTime = userLicenseInfo.ExpireTime.Value.AddMonths(1); break; case SoftLicenseType.Week: userLicenseInfo.ExpireTime = userLicenseInfo.ExpireTime.Value.AddDays(7); break; case SoftLicenseType.Year: userLicenseInfo.ExpireTime = userLicenseInfo.ExpireTime.Value.AddYears(1); break; } await _softUserLicenseRepository.UpdateAsync(userLicenseInfo); } #endregion softLicense.Status = SoftLicenseStatus.HasUse; softLicense.SoftUserId = softUser.Id; softLicense.UseTime = DateTime.Now; await _softLicenseRepository.UpdateAsync(softLicense); }
/// <summary> /// 生成所有曲线的JSON /// </summary> protected void GetAllLineJson() { LineChart chart = new LineChart(BeginTime, EndTime); chart.Period = Period; int lineType = HeadControl1.isChecked ? 1 : 2; for (int i = 0; i < ListAll.Count; i++) { string softName = GetSoft(ListAll[i][0].SoftId).Name; string platform = "_" + ((MobileOption)ListAll[i][0].Platform).GetDescription(); if (platform == "_None") { platform = "_不区分平台"; } string channelName = QuDao ? "_" + ListAll[i][0].ChannelName : string.Empty; //1 是ActiveNum-ActivityPercent-TotalNum 2 是UseNum-UsePercent-TotalNum,3 是LostNum-LostPercent-UseNum List <LineChartPoint> MyPoints = null; List <LineChartPoint> MyPoints2 = null; if (lineType == 1) { MyPoints = ListAll[i].Select(a => new LineChartPoint { XValue = a.StatDate, YValue = a.ActiveNum, DataContext = a, Denominator = a.TotalNum, Percent = a.ActivityPercent }).ToList(); MyPoints2 = ListAll[i].Select(a => new LineChartPoint { XValue = a.StatDate, YValue = a.FirstActiveUserCount + a.ActiveUserCount_Shanzhai, DataContext = a, Denominator = a.TotalNum }).ToList(); } else { MyPoints = ListAll[i].Select(a => new LineChartPoint { XValue = a.StatDate, YValue = a.UseNum, DataContext = a, Denominator = a.TotalNum, Percent = a.UsePercent }).ToList(); MyPoints2 = ListAll[i].Select(a => new LineChartPoint { XValue = a.StatDate, YValue = a.FirstUseUserCount + a.ActiveUserCount_Shanzhai + a.NewUserCount_Shanzhai, DataContext = a, Denominator = a.TotalNum }).ToList(); } LineChartLine line = new LineChartLine { Name = softName + platform + channelName, Show = true, XIntervalDays = 0, Points = MyPoints }; chart.Y.Add(line); //增加新增用户未修正的线 if (!QuDao && checkForNotUpdated.Checked && Period != net91com.Stat.Core.PeriodOptions.TimeOfDay && Period != net91com.Stat.Core.PeriodOptions.Hours && !QuDao) { LineChartLine line2 = new LineChartLine { Name = softName + platform + channelName + "_未修正数据", Show = true, XIntervalDays = 0, Points = MyPoints2 }; chart.Y.Add(line2); } } //增加对比线 //对比线前后时间差值 int intervalDays = 0; if (ListAll[0].Count != 0 && ListAllForCompare.Count != 0 && ListAllForCompare[0].Count != 0) { intervalDays = ListAll[0][0].StatDate.Subtract(ListAllForCompare[0][0].StatDate).Days; } foreach (var item in ListAllForCompare) { string softName = GetSoft(item[0].SoftId).Name; string platform = "_" + ((MobileOption)item[0].Platform).GetDescription(); if (platform == "_None") { platform = "_不区分平台"; } string channelName = QuDao ? "_" + item[0].ChannelName : string.Empty; List <LineChartPoint> ComparePoints = null; if (lineType == 1) { ComparePoints = item.Select(a => new LineChartPoint { XValue = a.StatDate, YValue = a.ActiveNum, DataContext = a, Denominator = a.TotalNum, Percent = a.ActivityPercent }).ToList(); } else { ComparePoints = item.Select(a => new LineChartPoint { XValue = a.StatDate, YValue = a.UseNum, DataContext = a, Denominator = a.TotalNum, Percent = a.UsePercent }).ToList(); } chart.Y.Add( new LineChartLine { Name = softName + platform + channelName + "_对比线", Show = true, XIntervalDays = intervalDays, Points = ComparePoints }); } AxisJsonStr = string.Format("{{{0},labels:{{align:'left',tickLength:80,tickPixelInterval:140{1},step:{2}}}}}" , chart.GetXJson() , Period == net91com.Stat.Core.PeriodOptions.Hours ? ",rotation:-45,x:-40,y:60" : (Period == net91com.Stat.Core.PeriodOptions.TimeOfDay ? ",x:-5" : ",rotation:-45,x:-30,y:45") , chart.Step); SeriesJsonStr = chart.GetYJson( delegate(LineChartPoint point) { SoftUser user = (SoftUser)point.DataContext; return(string.Format(",\"growth\":\"{0}\",\"Denominator\":{1},\"Other\":null", point.Percent, point.Denominator)); }); }
public SoftUser UserBind(IDataReader dataReader) { SoftUser model = new SoftUser(); object obj; obj = dataReader["period"]; if (obj != null && obj != DBNull.Value) { model.Period = Convert.ToInt32(obj); } obj = dataReader["platform"]; if (obj != null && obj != DBNull.Value) { model.Platform = Convert.ToInt32(obj); } obj = dataReader["softid"]; if (obj != null && obj != DBNull.Value) { model.SoftId = Convert.ToInt32(obj); } obj = dataReader["StatDate"]; if (obj != null && obj != DBNull.Value) { int sDate = Convert.ToInt32(obj); model.StatDate = new DateTime(sDate / 10000, sDate / 100 % 100, sDate % 100, 0, 0, 0); } obj = dataReader["newnum"]; if (obj != null && obj != DBNull.Value) { model.NewNum = Convert.ToInt32(obj); } obj = dataReader["activenum"]; if (obj != null && obj != DBNull.Value) { model.ActiveNum = Convert.ToInt32(obj); } ///默认值是-1,对应数据库是空值 model.LostNum = -1; obj = dataReader["lostnum"]; if (obj != null && obj != DBNull.Value) { model.LostNum = Convert.ToInt32(obj); } obj = dataReader["totalnum"]; if (obj != null && obj != DBNull.Value) { model.TotalNum = Convert.ToInt32(obj); } ///使用量 model.UseNum = model.ActiveNum + model.NewNum; ///增长率 float frontNum = model.TotalNum - model.NewNum; if (frontNum <= 0) { model.Growth = "100%"; } else { model.Growth = (model.NewNum / frontNum * 100).ToString("0.00") + "%"; } ///活跃百分比和使用百分比 if (model.TotalNum != 0) { model.ActivityPercent = (model.ActiveNum / (double)model.TotalNum * 100).ToString("0.00") + "%"; model.UsePercent = (model.UseNum / (double)model.TotalNum * 100).ToString("0.00") + "%"; } else { model.ActivityPercent = "100%"; model.UsePercent = "100%"; } ///流失率 if (model.LostNum == -1) { model.LostPercent = ""; } else { model.LostPercent = (model.LostNum / (double)model.UseNum * 100).ToString("0.00") + "%"; } return(model); }
///获取历史最值 private List <SoftUser> GetMaxNum(DateTime begin, DateTime end, int softid, int platformid, PeriodOptions period) { string sqlstr = ""; if (platformid != (int)MobileOption.None) { sqlstr = @"select StatDate,NewUserCount,ActiveUserCount from ( select * from( select StatDate,NewUserCount+NewUserCountFromCache+NewUserCount_Shanzhai-ifnull(NewUserCount_Shualiang,0) NewUserCount ,ActiveUserCount+ActiveUserCountFromCache+ActiveUserCount_Shanzhai ActiveUserCount from U_StatUsers where SoftID=?softid and Platform=?platform and Period=?periodid order by NewUserCount desc limit 1 ) A union select * from ( select StatDate,NewUserCount+NewUserCountFromCache+NewUserCount_Shanzhai-ifnull(NewUserCount_Shualiang,0) NewUserCount ,ActiveUserCount+ActiveUserCountFromCache+ActiveUserCount_Shanzhai ActiveUserCount from U_StatUsers where SoftID=?softid and Platform=?platform and Period=?periodid order by ActiveUserCount desc limit 1 ) A ) B"; } var parameters = new MySqlParameter[] { new MySqlParameter("?softid", softid), new MySqlParameter("?platform", platformid), new MySqlParameter("?periodid", (int)period) }; List <SoftUser> softs = new List <SoftUser>(); using (MySqlCommand cmd = new MySqlCommand(sqlstr, new MySqlConnection(connString))) { cmd.Connection.Open(); cmd.CommandTimeout = 180; cmd.Parameters.AddRange(parameters); using (IDataReader dataReader = cmd.ExecuteReader()) { while (dataReader.Read()) { SoftUser softuser = new SoftUser(); if (dataReader["statdate"] != DBNull.Value && dataReader["statdate"] != null) { int temp = Convert.ToInt32(dataReader["statdate"]); softuser.StatDate = new DateTime(temp / 10000, temp / 100 % 100, temp % 100, 0, 0, 0); } if (dataReader["newusercount"] != DBNull.Value && dataReader["newusercount"] != null) { softuser.NewNum = Convert.ToInt32(dataReader["newusercount"]); } if (dataReader["activeusercount"] != DBNull.Value && dataReader["activeusercount"] != null) { softuser.ActiveNum = Convert.ToInt32(dataReader["activeusercount"]); } softs.Add(softuser); } } } return(softs); }
/// <summary> /// /// </summary> /// <param name="dataReader"></param> /// <param name="platformid"></param> /// <param name="hasbrokenuser">是否包含有越狱字段数据</param> /// <param name="hasvalueuser">是否包含有价值用户字段</param> /// <param name="hasOldUser">是否包含未处理的新增活跃</param> /// <returns></returns> public SoftUser UserBind(IDataReader dataReader, int platformid, bool hasbrokenuser, bool hasvalueuser, bool hasOldUser) { SoftUser model = new SoftUser(); object obj; obj = dataReader["period"]; if (obj != null && obj != DBNull.Value) { model.Period = Convert.ToInt32(obj); } model.Platform = platformid; obj = dataReader["softid"]; if (obj != null && obj != DBNull.Value) { model.SoftId = Convert.ToInt32(obj); } obj = dataReader["StatDate"]; if (obj != null && obj != DBNull.Value) { int sDate = Convert.ToInt32(obj); model.StatDate = new DateTime(sDate / 10000, sDate / 100 % 100, sDate % 100, 0, 0, 0); } obj = dataReader["newnum"]; if (obj != null && obj != DBNull.Value) { model.NewNum = Convert.ToInt32(obj); } //二次激活 model.NewUserCount_SecAct = Convert.ToInt32(dataReader["NewUserCount_SecAct"]); model.NewUserCount_SecAct2 = Convert.ToInt32(dataReader["NewUserCount_SecAct2"]); if (hasvalueuser) { obj = dataReader["DownValueUsersForNew"]; if (obj != null && obj != DBNull.Value) { model.DownValueUsersForNew = Convert.ToInt32(obj); } obj = dataReader["DownValueUsersForAct"]; if (obj != null && obj != DBNull.Value) { model.DownValueUsersForAct = Convert.ToInt32(obj); } obj = dataReader["FuncValueUsersForNew"]; if (obj != null && obj != DBNull.Value) { model.FuncValueUsersForNew = Convert.ToInt32(obj); } obj = dataReader["FuncValueUsersForAct"]; if (obj != null && obj != DBNull.Value) { model.FuncValueUsersForAct = Convert.ToInt32(obj); } } if (hasbrokenuser) { obj = dataReader["NewUserCount_Broken"]; if (obj != null && obj != DBNull.Value) { model.NewNum_Broken = Convert.ToInt32(obj); } obj = dataReader["NewUserCount_NotBroken"]; if (obj != null && obj != DBNull.Value) { model.NewNum_NotBroken = Convert.ToInt32(obj); } obj = dataReader["ActiveUserCount_Broken"]; if (obj != null && obj != DBNull.Value) { model.ActiveNum_Broken = Convert.ToInt32(obj); } obj = dataReader["ActiveUserCount_NotBroken"]; if (obj != null && obj != DBNull.Value) { model.ActiveNum_NotBroken = Convert.ToInt32(obj); } } obj = dataReader["NewUserCount_ZJS"]; if (obj != null && obj != DBNull.Value) { model.NewNum_ZJS = Convert.ToInt32(obj); } obj = dataReader["ActiveUserCount_ZJS"]; if (obj != null && obj != DBNull.Value) { model.ActiveNum_ZJS = Convert.ToInt32(obj); } if (hasOldUser) { obj = dataReader["FirstNewUserCount"]; if (obj != null && obj != DBNull.Value) { model.FirstNewUserCount = Convert.ToInt32(obj); } obj = dataReader["FirstActiveUserCount"]; if (obj != null && obj != DBNull.Value) { model.FirstActiveUserCount = Convert.ToInt32(obj); } } obj = dataReader["activenum"]; if (obj != null && obj != DBNull.Value) { model.ActiveNum = Convert.ToInt32(obj); } ///默认值是-1,对应数据库是空值 model.LostNum = -1; obj = dataReader["lostnum"]; if (obj != null && obj != DBNull.Value) { model.LostNum = Convert.ToInt32(obj); } obj = dataReader["totalnum"]; if (obj != null && obj != DBNull.Value) { model.TotalNum = Convert.ToInt32(obj); } obj = dataReader["NewUserCount_Shanzhai"]; if (obj != null && obj != DBNull.Value) { model.NewUserCount_Shanzhai = Convert.ToInt32(obj); } obj = dataReader["ActiveUserCount_Shanzhai"]; if (obj != null && obj != DBNull.Value) { model.ActiveUserCount_Shanzhai = Convert.ToInt32(obj); } obj = dataReader["TotalUserCount_Shanzhai"]; if (obj != null && obj != DBNull.Value) { model.TotalUserCount_Shanzhai = Convert.ToInt32(obj); } ///使用量 model.UseNum = model.ActiveNum + model.NewNum; ///第一次计算使用量 model.FirstUseUserCount = model.FirstActiveUserCount + model.FirstNewUserCount; ///增长率 float frontNum = model.TotalNum - model.NewNum; if (frontNum <= 0) { model.Growth = "100%"; } else { model.Growth = (model.NewNum / frontNum * 100).ToString("0.00") + "%"; } ///活跃百分比和使用百分比 if (model.TotalNum != 0) { model.ActivityPercent = (model.ActiveNum / (double)model.TotalNum * 100).ToString("0.00") + "%"; model.UsePercent = (model.UseNum / (double)model.TotalNum * 100).ToString("0.00") + "%"; } else { model.ActivityPercent = "100%"; model.UsePercent = "100%"; } ///流失率 if (model.LostNum == -1) { model.LostPercent = ""; } else { model.LostPercent = (model.LostNum / (double)model.UseNum * 100).ToString("0.00") + "%"; } obj = dataReader["NewUserCountFromCache"]; if (obj != null && obj != DBNull.Value) { model.NewUserCountFromCache = Convert.ToInt32(obj); } obj = dataReader["ActiveUserCountFromCache"]; if (obj != null && obj != DBNull.Value) { model.ActiveUserCountFromCache = Convert.ToInt32(obj); } return(model); }
/// <summary> /// 生成所有曲线的JSON /// </summary> protected void GetAllLineJson() { LineChart chart = new LineChart(BeginTime, EndTime); chart.Period = Period; chart.NeedForecastPoint = (Period == net91com.Stat.Core.PeriodOptions.Daily || Period == net91com.Stat.Core.PeriodOptions.Weekly || Period == net91com.Stat.Core.PeriodOptions.Monthly); for (int i = 0; i < ListAll.Count; i++) { string softName = GetSoft(ListAll[i][0].SoftId).Name; string platform = "_" + ((MobileOption)ListAll[i][0].Platform).GetDescription(); if (platform == "_None") { platform = "_不区分平台"; } string channelName = QuDao ? "_" + ListAll[i][0].ChannelName : string.Empty; LineChartLine line = new LineChartLine { Name = softName + platform + channelName, Show = true, XIntervalDays = 0, Points = ListAll[i].Select(a => new LineChartPoint { XValue = a.StatDate, YValue = a.NewNum, DataContext = a }).ToList() }; if (ForeCastUserDatas.Count > 0) { List <ForecastSoftUser> tempMyForecastUser = ForeCastUserDatas.Where(p => p.Period == (int)Period) .Where( p => p.SoftId == ListAll[i][0].SoftId && p.Platform == ListAll[i][0].Platform && ListAll[i][0].ChannelID == p.ChannelID) .OrderByDescending(p => p.StatDate) .ToList(); SoftUser user = GetForeCastSoftUser(tempMyForecastUser); if (user != null) { line.ForecastPoint = new LineChartPoint { YValue = user.NewNum, DataContext = user } } ; } //mileStoneDate[i].ForEach(a => line.AddMarker(a.MileStoneDate, Period, a.Remarks)); chart.Y.Add(line); ////增加新增用户未修正的线 //if (!QuDao && checkForNotUpdated.Checked && Period != PeriodOptions.TimeOfDay && Period != PeriodOptions.Hours) //{ // LineChartLine line2 = new LineChartLine // { // Name = softName + platform + channelName + "_未修正数据", // Show = true, // XIntervalDays = 0, // Points = ListAll[i].Select(a => new LineChartPoint { XValue = a.StatDate, YValue = a.FirstNewUserCount + a.NewUserCount_Shanzhai, DataContext = a, Type = -1 }).ToList() // }; // chart.Y.Add(line2); //} } //对比线前后时间差值 int intervalDays = 0; if (ListAll[0].Count != 0 && ListAllForCompare.Count != 0 && ListAllForCompare[0].Count != 0) { intervalDays = ListAll[0][0].StatDate.Subtract(ListAllForCompare[0][0].StatDate).Days; } foreach (var item in ListAllForCompare) { string softName = GetSoft(item[0].SoftId).Name; string platform = "_" + ((MobileOption)item[0].Platform).GetDescription(); if (platform == "_None") { platform = "_不区分平台"; } string channelName = QuDao ? "_" + item[0].ChannelName : string.Empty; chart.Y.Add( new LineChartLine { Name = softName + platform + channelName + "_对比线", Show = true, XIntervalDays = intervalDays, Points = item.Select(a => new LineChartPoint { XValue = a.StatDate, YValue = a.NewNum, DataContext = a }).ToList() }); } AxisJsonStr = string.Format("{{{0},labels:{{align:'left',tickLength:80,tickPixelInterval:140{1},step:{2}}}}}" , chart.GetXJson() , Period == net91com.Stat.Core.PeriodOptions.Hours ? ",rotation:-45,x:-40,y:60" : (Period == net91com.Stat.Core.PeriodOptions.TimeOfDay ? ",x:-5" : ",rotation:-45,x:-30,y:45") , chart.Step); SeriesJsonStr = chart.GetYJson( delegate(LineChartPoint point) { SoftUser user = (SoftUser)point.DataContext; if (point.Type != -1) { return(string.Format(",\"growth\":\"{0}\",\"Denominator\":{1},\"Other\":null", user.Growth, user.TotalNum - user.NewNum)); } else { return(string.Format(",\"growth\":\"{0}\",\"Denominator\":{1},\"Other\":null", "", "0")); } }); }
/// <summary> /// 获取数据加上绑定数据 /// </summary> protected void BindData() { ///进入分渠道统计 if (HeadControl1.Channel1.ChannelValues.Count != 0) { var channels = HeadControl1.Channel1.ChannelValues; QuDao = true; if (Period == net91com.Stat.Core.PeriodOptions.TimeOfDay || Period == net91com.Stat.Core.PeriodOptions.Hours) { for (int i = 0; i < channels.Count; i++) { //List<SoftUser> users = // Sjqd_StatUsersByChannelsService.GetInstance().GetChannelUsersByHoursDataCache( // BeginTime, EndTime, SelectedSofts[0].ID, channels[i].Platform, Period, // channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), // channels[i].ChannelText, loginService,CacheTimeOption.TenMinutes) // .OrderBy(p => p.StatDate) // .ToList(); net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService suService = new net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsers; ssUsers = suService.GetStatUsersByHour(SelectedSofts[0].ID, channels[i].Platform, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), (int)Period, BeginTime, EndTime); List <SoftUser> users = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsers) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = SelectedSofts[0].ID; softuser.Platform = channels[i].Platform; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; users.Add(softuser); } users = users.OrderBy(p => p.StatDate).ToList(); if (users.Count != 0) { ListAll.Add(users); //添加里程碑列表集(若ListAll添加了,里程碑也要添加) //mileStoneDate.Add(Sjqd_MileStoneConfigService.GetInstance() // .GetMileStoneDatesByCache(SelectedSofts[0].ID, // channels[i].Platform, // BeginTime, EndTime)); QuDaoList.Add(i); } //获取对比曲线 if (HeadControl1.CompareTimeType > 0) { //List<SoftUser> usersCompare = // Sjqd_StatUsersByChannelsService.GetInstance().GetChannelUsersByHoursDataCache( // BeginCompareTime, EndCompareTime, SelectedSofts[0].ID, channels[i].Platform, Period, // channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), // channels[i].ChannelText, loginService,CacheTimeOption.TenMinutes) // .OrderBy(p => p.StatDate) // .ToList(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsersComp; ssUsersComp = suService.GetStatUsersByHour(SelectedSofts[0].ID, channels[i].Platform, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), (int)Period, BeginCompareTime, EndCompareTime); List <SoftUser> usersCompare = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsersComp) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = SelectedSofts[0].ID; softuser.Platform = channels[i].Platform; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; usersCompare.Add(softuser); } usersCompare = usersCompare.OrderBy(p => p.StatDate).ToList(); if (usersCompare != null && usersCompare.Count != 0) { ListAllForCompare.Add(usersCompare); } } } } else { for (int i = 0; i < channels.Count; i++) { List <SoftUser> users = Sjqd_StatUsersByChannelsService.GetInstance() .GetSoftUserChanelListCache(BeginTime, EndTime, SelectedSofts[0].ID, channels[i].Platform, Period, channels[i].ChannelType, Convert.ToInt32( channels[i].ChannelValue), channels[i].ChannelText, false, loginService, CacheTimeOption.TenMinutes) .OrderBy(p => p.StatDate) .ToList(); if (users != null && users.Count != 0) { ListAll.Add(users); ////添加里程碑列表集(若ListAll添加了,里程碑也要添加) //mileStoneDate.Add(Sjqd_MileStoneConfigService.GetInstance() // .GetMileStoneDatesByCache(SelectedSofts[0].ID, channels[i].Platform, BeginTime, EndTime)); QuDaoList.Add(i); //if (Period == net91com.Stat.Core.PeriodOptions.Daily) //{ // ForecastSoftUser softUser = // Sjqd_StatUsersByChannelsService.GetInstance() // .GetStatUsersForRealTime(SelectedSofts[0].ID, // channels[i].Platform, // channels[i].ChannelType, // Convert.ToInt32( // channels[i].ChannelValue), // loginService, // CacheTimeOption.TenMinutes); // if (softUser != null) // ForeCastUserDatas.Add(softUser); //} } //获取对比曲线 if (HeadControl1.CompareTimeType > 0) { List <SoftUser> usersCompare = Sjqd_StatUsersByChannelsService.GetInstance() .GetSoftUserChanelListCache(BeginCompareTime, EndCompareTime, SelectedSofts[0].ID, channels[i].Platform, Period, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), channels[i].ChannelText, false, loginService, CacheTimeOption.TenMinutes) .OrderBy(p => p.StatDate) .ToList(); if (usersCompare != null && usersCompare.Count != 0) { ListAllForCompare.Add(usersCompare); } } } } } else { //选择所筛选的所有软件 for (int softid = 0; softid < SelectedSofts.Count; softid++) { for (int i = 0; i < SelectedPlatforms.Count; i++) { foreach (MobileOption tempplat in SelectedSofts[softid].Platforms) { //他选出的平台加上和自己支持平台的交集 if (tempplat == SelectedPlatforms[i] || SelectedPlatforms[i] == 0) { List <SoftUser> users = null; if (Period != net91com.Stat.Core.PeriodOptions.TimeOfDay && Period != net91com.Stat.Core.PeriodOptions.Hours) { users = Sjqd_StatUsersService.GetInstance() .GetSoftUserListCache(BeginTime, EndTime, SelectedSofts[softid].ID, (int)SelectedPlatforms[i], Period, loginService, CacheTimeOption.TenMinutes) .OrderBy(p => p.StatDate) .ToList(); if (Period == net91com.Stat.Core.PeriodOptions.Daily) { //ForecastSoftUser softUser = // Sjqd_StatUsersService.GetInstance() // .GetStatUsersForRealTime(SelectedSofts[softid].ID, // (int)SelectedPlatforms[i], // loginService, // CacheTimeOption.TenMinutes); //if (softUser != null) // ForeCastUserDatas.Add(softUser); //else ForeCastUserDatas.AddRange( Sjqd_StatUsersService.GetInstance() .GetForecastSoftUserCache( SelectedSofts[softid].ID, (int)SelectedPlatforms[i], Period, loginService, CacheTimeOption.TenMinutes)); } else { //获取计算预测数据 ForeCastUserDatas.AddRange( Sjqd_StatUsersService.GetInstance() .GetForecastSoftUserCache(SelectedSofts[softid].ID, (int)SelectedPlatforms[i], Period, loginService, CacheTimeOption .TenMinutes)); } } else { //users = // StatUsersByHourService.GetInstance() // .GetHourUserDataCache(SelectedSofts[softid].ID, // (int) SelectedPlatforms[i], // BeginTime, EndTime, Period, // loginService, // CacheTimeOption.TenMinutes) // .OrderBy(p => p.StatDate) // .ToList(); net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService suService = new net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsers; ssUsers = suService.GetStatUsersByHour(SelectedSofts[softid].ID, (int)SelectedPlatforms[i], ChannelTypeOptions.Category, 0, (int)Period, BeginTime, EndTime); users = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsers) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = SelectedSofts[softid].ID; softuser.Platform = (int)SelectedPlatforms[i]; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; users.Add(softuser); } users = users.OrderBy(p => p.StatDate).ToList(); } if (users != null && users.Count != 0) { ListAll.Add(users); //添加里程碑列表集(若ListAll添加了,里程碑也要添加) //mileStoneDate.Add(Sjqd_MileStoneConfigService.GetInstance() // .GetMileStoneDatesByCache( // SelectedSofts[softid].ID, // (int)SelectedPlatforms[i], // BeginTime, EndTime)); RealSoftLine.Add((int)SelectedPlatforms[i]); } //获取对比曲线 if (HeadControl1.CompareTimeType > 0) { List <SoftUser> usersCompare = null; if (Period != net91com.Stat.Core.PeriodOptions.TimeOfDay && Period != net91com.Stat.Core.PeriodOptions.Hours) { usersCompare = Sjqd_StatUsersService.GetInstance() .GetSoftUserListCache(BeginCompareTime, EndCompareTime, SelectedSofts[softid].ID, (int)SelectedPlatforms[i], Period, loginService, CacheTimeOption.TenMinutes) .OrderBy(p => p.StatDate) .ToList(); } else { //usersCompare = // StatUsersByHourService.GetInstance() // .GetHourUserDataCache(SelectedSofts[softid].ID, // (int)SelectedPlatforms[i], // BeginCompareTime, EndCompareTime, // Period, loginService, // CacheTimeOption.TenMinutes) // .OrderBy(p => p.StatDate) // .ToList(); net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService suService = new net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsers; ssUsers = suService.GetStatUsersByHour(SelectedSofts[softid].ID, (int)SelectedPlatforms[i], ChannelTypeOptions.Category, 0, (int)Period, BeginCompareTime, EndCompareTime); usersCompare = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsers) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = SelectedSofts[softid].ID; softuser.Platform = (int)SelectedPlatforms[i]; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; usersCompare.Add(softuser); } usersCompare = usersCompare.OrderBy(p => p.StatDate).ToList(); } if (usersCompare != null && usersCompare.Count != 0) { ListAllForCompare.Add(usersCompare); } } break; } } } } } if (ListAll.Count == 0) { return; } //生成所有曲线的JSON GetAllLineJson(); //生成Table的HTML GetAllTableHtml(); }
/// <summary> /// 获取数据加上绑定数据 /// </summary> protected void BindData() { //进入分渠道统计 if (HeadControl1.Channel1.ChannelValues.Count != 0) { QuDao = true; var channels = HeadControl1.Channel1.ChannelValues; if (Period == net91com.Stat.Core.PeriodOptions.TimeOfDay || Period == net91com.Stat.Core.PeriodOptions.Hours) { for (int i = 0; i < channels.Count; i++) { //小时和每小时将其和到一条曲线中去了 //List<SoftUser> users = Sjqd_StatUsersByChannelsService.GetInstance().GetChannelUsersByHoursDataCache( // BeginTime, EndTime, SelectedSofts[0].ID, channels[i].Platform, Period, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), channels[i].ChannelText, loginService,CacheTimeOption.TenMinutes).OrderBy(p => p.StatDate).ToList(); net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService suService = new net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsers; ssUsers = suService.GetStatUsersByHour(SelectedSofts[0].ID, channels[i].Platform, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), (int)Period, BeginTime, EndTime); List <SoftUser> users = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsers) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = SelectedSofts[0].ID; softuser.Platform = channels[i].Platform; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; users.Add(softuser); } users = users.OrderBy(p => p.StatDate).ToList(); if (users.Count != 0) { ListAll.Add(users); QuDaoList.Add(i); } //获取对比曲线 if (HeadControl1.CompareTimeType > 0) { //List<SoftUser> usersCompare = Sjqd_StatUsersByChannelsService.GetInstance().GetChannelUsersByHoursDataCache( //BeginCompareTime, EndCompareTime, SelectedSofts[0].ID, channels[i].Platform, Period, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), channels[i].ChannelText, loginService,CacheTimeOption.TenMinutes).OrderBy(p => p.StatDate).ToList(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsersComp; ssUsersComp = suService.GetStatUsersByHour(SelectedSofts[0].ID, channels[i].Platform, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), (int)Period, BeginCompareTime, EndCompareTime); List <SoftUser> usersCompare = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsersComp) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = SelectedSofts[0].ID; softuser.Platform = channels[i].Platform; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; usersCompare.Add(softuser); } usersCompare = usersCompare.OrderBy(p => p.StatDate).ToList(); if (usersCompare != null && usersCompare.Count != 0) { ListAllForCompare.Add(usersCompare); } } } } else { for (int i = 0; i < channels.Count; i++) { List <SoftUser> users = Sjqd_StatUsersByChannelsService.GetInstance().GetSoftUserChanelListCache(BeginTime, EndTime, SelectedSofts[0].ID, channels[i].Platform, Period, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), channels[i].ChannelText, false, loginService, CacheTimeOption.TenMinutes).OrderBy(p => p.StatDate).ToList(); if (users != null && users.Count != 0) { ListAll.Add(users); QuDaoList.Add(i); } //获取对比曲线 if (HeadControl1.CompareTimeType > 0) { List <SoftUser> usersCompare = Sjqd_StatUsersByChannelsService.GetInstance().GetSoftUserChanelListCache(BeginCompareTime, EndCompareTime, SelectedSofts[0].ID, channels[i].Platform, Period, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), channels[i].ChannelText, false, loginService, CacheTimeOption.TenMinutes).OrderBy(p => p.StatDate).ToList(); if (usersCompare != null && usersCompare.Count != 0) { ListAllForCompare.Add(usersCompare); } } } } } else { //选择所筛选的所有软件 for (int softid = 0; softid < SelectedSofts.Count; softid++) { Soft SingleSoftInfo = SelectedSofts[softid]; for (int i = 0; i < SelectedPlatforms.Count; i++) { foreach (MobileOption tempplat in SingleSoftInfo.Platforms) { ///他选出的平台加上和自己支持平台的交集 if (tempplat == SelectedPlatforms[i] || SelectedPlatforms[i] == 0) { List <SoftUser> users = null; if (!SuperPeriod) { users = Sjqd_StatUsersService.GetInstance().GetSoftUserListCache(BeginTime, EndTime, SingleSoftInfo.ID, (int)SelectedPlatforms[i], Period, loginService, CacheTimeOption.TenMinutes).OrderBy(p => p.StatDate).ToList(); } else { //users = StatUsersByHourService.GetInstance().GetHourUserDataCache(SingleSoftInfo.ID, (int)SelectedPlatforms[i], BeginTime, EndTime, Period, loginService,CacheTimeOption.TenMinutes).OrderBy(p => p.StatDate).ToList(); net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService suService = new net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsers; ssUsers = suService.GetStatUsersByHour(SingleSoftInfo.ID, (int)SelectedPlatforms[i], ChannelTypeOptions.Category, 0, (int)Period, BeginTime, EndTime); users = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsers) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = SingleSoftInfo.ID; softuser.Platform = (int)SelectedPlatforms[i]; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; users.Add(softuser); } users = users.OrderBy(p => p.StatDate).ToList(); } if (users != null && users.Count != 0) { ListAll.Add(users); RealSoftLine.Add((int)SelectedPlatforms[i]); } //获取对比曲线 if (HeadControl1.CompareTimeType > 0) { List <SoftUser> usersCompare = null; if (!SuperPeriod) { usersCompare = Sjqd_StatUsersService.GetInstance().GetSoftUserListCache(BeginCompareTime, EndCompareTime, SingleSoftInfo.ID, (int)SelectedPlatforms[i], Period, loginService, CacheTimeOption.TenMinutes).OrderBy(p => p.StatDate).ToList(); } else { //usersCompare = StatUsersByHourService.GetInstance().GetHourUserDataCache(SingleSoftInfo.ID, (int)SelectedPlatforms[i], BeginCompareTime, EndCompareTime, Period, loginService,CacheTimeOption.TenMinutes).OrderBy(p => p.StatDate).ToList(); net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService suService = new net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsers; ssUsers = suService.GetStatUsersByHour(SingleSoftInfo.ID, (int)SelectedPlatforms[i], ChannelTypeOptions.Category, 0, (int)Period, BeginCompareTime, EndCompareTime); usersCompare = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsers) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = SingleSoftInfo.ID; softuser.Platform = (int)SelectedPlatforms[i]; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; usersCompare.Add(softuser); } usersCompare = usersCompare.OrderBy(p => p.StatDate).ToList(); } if (usersCompare != null && usersCompare.Count != 0) { ListAllForCompare.Add(usersCompare); } } break; } } } } HeadControl1.Channel1.SelectedText = "选择渠道"; HeadControl1.Channel1.SelectedValue = ""; } //一条线数据都没有 if (ListAll.Count == 0) { return; } //生成所有的Table GetAllTableHtml(); //生成所有曲线的JSON GetAllLineJson(); }
protected void BindData() { StatUsersService suService = new StatUsersService(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> users = null; if (selectCountryId == string.Empty) { users = suService.GetStatUsersByChannel(softsid, (int)platformsid, ChannelTypeOptions.Customer, channelId, (int)net91com.Stat.Core.PeriodOptions.Daily, begintime, endtime, false, true); } else { users = suService.GetStatUsersByArea(softsid, (int)platformsid, ChannelTypeOptions.Customer, channelId, selectCountryId, (int)net91com.Stat.Core.PeriodOptions.Daily, begintime, endtime, false, true); } List <SoftUser> usersCompare = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in users) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = softsid; softuser.Platform = (int)platformsid; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; usersCompare.Add(softuser); } usersCompare = usersCompare.OrderBy(p => p.StatDate).ToList(); if (usersCompare.Count != 0) { listAll.Add(usersCompare); } if (listAll.Count == 0) { return; } reportTitle = "渠道统计"; //获取时间上的并集 foreach (var item in listAll) { for (int tempindex = 0; tempindex < item.Count; tempindex++) { if (!X_DateTime.Contains(item[tempindex].StatDate)) { X_DateTime.Add(item[tempindex].StatDate); } } } MaxNumCoef = X_DateTime.Count / 16 + 1; //设置x轴上的日期 X_DateTime = X_DateTime.OrderBy(p => p).ToList(); SetxAxisJson(X_DateTime); SeriesJsonStr = JsonConvert.SerializeObject(GetDataJsonList(listAll)); StringBuilder sb = new StringBuilder(); ///传入的tab 序列值 int tabindex = 0; ///形成tablehtml for (int j = 0; j < listAll.Count; j++) { int plat = Convert.ToInt32(listAll[j][0].Platform); if (plat == 0) { tabStr.Add("不区分平台"); } else { tabStr.Add(((MobileOption)plat).GetDescription()); } sb.Append(GetTableString(listAll[j], tabindex)); tabindex++; } tableStr = sb.ToString(); }
public virtual async Task <SoftAuthorizeResult> Register(string appId, string loginName, string password, string mobile = "", string qq = "") { #region 检查参数 if (string.IsNullOrEmpty(appId)) { return(new SoftAuthorizeResult() { errormsg = "appId不允许为空!" }); } if (string.IsNullOrEmpty(loginName)) { return(new SoftAuthorizeResult() { errormsg = "用户名不允许为空!" }); } if (string.IsNullOrEmpty(password)) { return(new SoftAuthorizeResult() { errormsg = "密码不允许为空!" }); } if (loginName.Length < 4) { return(new SoftAuthorizeResult() { errormsg = "用户名长度必须在4位以上!" }); } if (password.Length < 6) { return(new SoftAuthorizeResult() { errormsg = "密码长度必须在6位以上!" }); } var soft = await _softRepository.FirstOrDefaultAsync(t => t.AppId == appId); if (soft == null) { return(new SoftAuthorizeResult() { errormsg = "软件不存在!" }); } if (!soft.IsActive) { return(new SoftAuthorizeResult() { errormsg = "软件已停用,有问题请联系客服!" }); } #endregion #region 用户注册 var softRegisterOption = soft.SoftRegisterOption; if (softRegisterOption != null) { if (!softRegisterOption.AllowRegister) { return(new SoftAuthorizeResult() { errormsg = "软件不允许注册,有需要请联系客服!" }); } } SoftUser softUser = await _softUserRepository.FirstOrDefaultAsync(t => t.LoginName == loginName); if (softUser != null) { if (new PasswordHasher().VerifyHashedPassword(softUser.Password, password) == PasswordVerificationResult.Success && softUser.IsActive) { //如果,注册的账号已经存在,则直接返回成功 softUser.Mobile = mobile; softUser.QQ = qq; await _softUserRepository.UpdateAsync(softUser); } else { return(new SoftAuthorizeResult() { errormsg = "用户名已存在!" }); } } else { softUser = new SoftUser(); softUser.IsActive = true;//默认启用 softUser.LoginName = loginName; softUser.Source = SoftUserSource.Register; softUser.Password = new PasswordHasher().HashPassword(password); var entity = await _softUserRepository.InsertAsync(softUser); } #endregion #region 写入免费和试用授权 if (await _softUserLicenseRepository.CountAsync(t => t.SoftId == soft.Id && t.SoftUserId == softUser.Id) == 0) { if (soft.RunMode == SoftRunMode.Free) { //免费用户,直接写入授权到永久 SoftUserLicense softUserLicense = new SoftUserLicense(); softUserLicense.SoftId = soft.Id; softUserLicense.SoftUserId = softUser.Id; softUserLicense.AuthorizeTime = DateTime.Now; softUserLicense.IsActive = true; softUserLicense.ExpireTime = null; softUserLicense.Type = SoftUserLicenseType.Free; await _softUserLicenseRepository.InsertAsync(softUserLicense); } else { if (softRegisterOption != null && softRegisterOption.TrialTime > 0) { //试用用户,直接写入授权到 系统时间+试用分钟 SoftUserLicense softUserLicense = new SoftUserLicense(); softUserLicense.SoftId = soft.Id; softUserLicense.SoftUserId = softUser.Id; softUserLicense.AuthorizeTime = DateTime.Now; softUserLicense.IsActive = true; softUserLicense.ExpireTime = softUserLicense.AuthorizeTime.AddMinutes(softRegisterOption.TrialTime); softUserLicense.Type = SoftUserLicenseType.Trial; await _softUserLicenseRepository.InsertAsync(softUserLicense); } } } #endregion return(new SoftAuthorizeResult() { success = true }); }
protected void BindData() { List <SoftUser> users; //是否给外部部人看的,自己内部人看,不用乘以系数的结果,给外部要乘 bool isForOut = (usercate.Value == "11"); if (isForOut) { reportTitle = "分渠道统计(外部)"; } else { reportTitle = "分渠道统计(内部)"; } //不区分渠道 if (HeadControl1.Channel1.ChannelValues.Count == 0) { for (int i = 0; i < PlatformsidList.Count; i++) { if (IsSuperPeriod) { //users = // StatUsersByHourService.GetInstance() // .GetHourUserDataCache(softsid, PlatformsidList[i], BeginTime, EndTime, // Period, loginService, // CacheTimeOption.TenMinutes) // .OrderBy(p => p.StatDate) // .ToList(); net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService suService = new net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsers; ssUsers = suService.GetStatUsersByHour(softsid, PlatformsidList[i], ChannelTypeOptions.Category, 0, (int)Period, BeginTime, EndTime); users = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsers) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = softsid; softuser.Platform = PlatformsidList[i]; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; users.Add(softuser); } users = users.OrderBy(p => p.StatDate).ToList(); //获取对比曲线 if (HeadControl1.CompareTimeType > 0) { //List<SoftUser> usersCompare = // StatUsersByHourService.GetInstance() // .GetHourUserDataCache(softsid, PlatformsidList[i], // BeginCompareTime, EndCompareTime, Period, // loginService, // CacheTimeOption.TenMinutes) // .OrderBy(p => p.StatDate).ToList(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsersComp; ssUsersComp = suService.GetStatUsersByHour(softsid, PlatformsidList[i], ChannelTypeOptions.Category, 0, (int)Period, BeginCompareTime, EndCompareTime); List <SoftUser> usersCompare = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsersComp) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = softsid; softuser.Platform = PlatformsidList[i]; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; usersCompare.Add(softuser); } usersCompare = usersCompare.OrderBy(p => p.StatDate).ToList(); if (usersCompare.Count != 0) { ListAllForCompare.Add(usersCompare); } } } else { users = Sjqd_StatUsersService.GetInstance() .GetSoftUserListCache(BeginTime, EndTime, softsid, PlatformsidList[i], Period, loginService, CacheTimeOption.TenMinutes) .OrderBy(p => p.StatDate) .ToList(); //获取计算预测数据 ForeCastUserDatas.AddRange(Sjqd_StatUsersService.GetInstance().GetForecastSoftUserCache( softsid, PlatformsidList[i], Period, loginService, CacheTimeOption.TenMinutes)); //获取对比曲线 if (HeadControl1.CompareTimeType > 0) { List <SoftUser> usersCompare = Sjqd_StatUsersService.GetInstance() .GetSoftUserListCache(BeginCompareTime, EndCompareTime, softsid, PlatformsidList[i], Period, loginService, CacheTimeOption.TenMinutes) .OrderBy(p => p.StatDate) .ToList(); if (usersCompare.Count != 0) { ListAllForCompare.Add(usersCompare); } } } if (users.Count != 0) { ListAll.Add(users); //添加里程碑列表集(若ListAll添加了,里程碑也要添加) //mileStoneDate.Add(Sjqd_MileStoneConfigService.GetInstance() // .GetMileStoneDatesByCache(softsid, PlatformsidList[i], BeginTime, EndTime)); } } } else { QuDao = true; var channels = HeadControl1.Channel1.ChannelValues; if (IsSuperPeriod) { for (int i = 0; i < channels.Count; i++) { //小时和每小时将其和到一条曲线中去了 //users = Sjqd_StatUsersByChannelsService.GetInstance().GetChannelUsersByHoursDataCache( // BeginTime, EndTime, softsid, channels[i].Platform, Period, channels[i].ChannelType, // Convert.ToInt32(channels[i].ChannelValue), channels[i].ChannelText, loginService, // CacheTimeOption.TenMinutes).OrderBy(p => p.StatDate).ToList(); net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService suService = new net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsers; ssUsers = suService.GetStatUsersByHour(softsid, channels[i].Platform, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), (int)Period, BeginTime, EndTime); users = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsers) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = softsid; softuser.Platform = channels[i].Platform; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; users.Add(softuser); } users = users.OrderBy(p => p.StatDate).ToList(); if (users.Count != 0) { //记住有数据渠道的编号 QuDaoList.Add(i); ListAll.Add(users); //添加里程碑列表集(若ListAll添加了,里程碑也要添加) //mileStoneDate.Add(Sjqd_MileStoneConfigService.GetInstance() // .GetMileStoneDatesByCache(softsid, channels[i].Platform, BeginTime, EndTime)); } //获取对比曲线 if (HeadControl1.CompareTimeType > 0) { //List<SoftUser> usersCompare = // Sjqd_StatUsersByChannelsService.GetInstance().GetChannelUsersByHoursDataCache( // BeginCompareTime, EndCompareTime, softsid, channels[i].Platform, Period, // channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), // channels[i].ChannelText, loginService,CacheTimeOption.TenMinutes) // .OrderBy(p => p.StatDate) // .ToList(); List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsersComp; ssUsersComp = suService.GetStatUsersByHour(softsid, channels[i].Platform, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), (int)Period, BeginCompareTime, EndCompareTime); List <SoftUser> usersCompare = new List <SoftUser>(); foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsersComp) { SoftUser softuser = new SoftUser(); softuser.StatDate = u.StatDate; softuser.SoftId = softsid; softuser.Platform = channels[i].Platform; softuser.ActiveNum = u.ActiveUserCount - u.NewUserCount; softuser.Hour = u.StatHour; softuser.NewNum = u.NewUserCount; softuser.UseNum = u.ActiveUserCount; usersCompare.Add(softuser); } usersCompare = usersCompare.OrderBy(p => p.StatDate).ToList(); if (usersCompare.Count != 0) { ListAllForCompare.Add(usersCompare); } } } } else { for (int i = 0; i < channels.Count; i++) { users = Sjqd_StatUsersByChannelsService.GetInstance() .GetSoftUserChanelListCache(BeginTime, EndTime, softsid, channels[i].Platform , Period, channels[i].ChannelType, Convert.ToInt32( channels[i].ChannelValue), channels[i].ChannelText, isForOut, loginService, CacheTimeOption.TenMinutes) .OrderBy(p => p.StatDate) .ToList(); if (users.Count != 0) { //记住有数据渠道的编号 QuDaoList.Add(i); ListAll.Add(users); //添加里程碑列表集(若ListAll添加了,里程碑也要添加) //mileStoneDate.Add(Sjqd_MileStoneConfigService.GetInstance() // .GetMileStoneDatesByCache(softsid, channels[i].Platform, BeginTime, EndTime)); //if (Period == net91com.Stat.Core.PeriodOptions.Daily) //{ // ForecastSoftUser softUser = Sjqd_StatUsersByChannelsService.GetInstance().GetStatUsersForRealTime(softsid, // channels[i].Platform, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), loginService, CacheTimeOption.TenMinutes); // if (softUser != null) // ForeCastUserDatas.Add(softUser); //} } //获取对比曲线 if (HeadControl1.CompareTimeType > 0) { List <SoftUser> usersCompare = Sjqd_StatUsersByChannelsService.GetInstance() .GetSoftUserChanelListCache(BeginCompareTime, EndCompareTime, softsid, channels[i].Platform, Period, channels[i].ChannelType, Convert.ToInt32( channels[i].ChannelValue), channels[i].ChannelText, isForOut, loginService, CacheTimeOption .TenMinutes) .OrderBy(p => p.StatDate) .ToList(); if (usersCompare.Count != 0) { ListAllForCompare.Add(usersCompare); } } } } } if (ListAll.Count == 0) { return; } GetAllLineJson(); StringBuilder sb = new StringBuilder(); //传入的tab 序列值 int tabindex = 0; //形成tablehtml for (int j = 0; j < ListAll.Count; j++) { string plat = ((MobileOption)ListAll[j][0].Platform).GetDescription(); if ((MobileOption)ListAll[j][0].Platform == MobileOption.None) { plat = "不区分平台"; } string channel = ListAll[j][0].ChannelName; if (string.IsNullOrEmpty(channel)) { channel = "不区分渠道"; } tabStr.Add(plat + "_" + channel); sb.Append(GetTableString(ListAll[j], tabindex)); tabindex++; } tableStr = sb.ToString(); }
///绑定softuser 类对象这个是统一渠道那边的 public SoftUser UserBindSjQd(IDataReader dataReader, int platformid, bool hasvalueuser) { SoftUser model = new SoftUser(); object obj; obj = dataReader["period"]; if (obj != null && obj != DBNull.Value) { model.Period = Convert.ToInt32(obj); } model.Platform = platformid; obj = dataReader["softid"]; if (obj != null && obj != DBNull.Value) { model.SoftId = Convert.ToInt32(obj); } obj = dataReader["StatDate"]; if (obj != null && obj != DBNull.Value) { int sDate = Convert.ToInt32(obj); model.StatDate = new DateTime(sDate / 10000, sDate / 100 % 100, sDate % 100, 0, 0, 0); } obj = dataReader["newnum"]; if (obj != null && obj != DBNull.Value) { model.NewNum = Convert.ToInt32(obj); } //二次激活 model.NewUserCount_SecAct = Convert.ToInt32(dataReader["NewUserCount_SecAct"]); model.NewUserCount_SecAct2 = Convert.ToInt32(dataReader["NewUserCount_SecAct2"]); obj = dataReader["activenum"]; if (obj != null && obj != DBNull.Value) { model.ActiveNum = Convert.ToInt32(obj); } //默认值是-1,对应数据库是空值 model.LostNum = -1; obj = dataReader["lostnum"]; if (obj != null && obj != DBNull.Value) { model.LostNum = Convert.ToInt32(obj); } obj = dataReader["totalnum"]; if (obj != null && obj != DBNull.Value) { model.TotalNum = Convert.ToInt32(obj); } //增加channelid 和channelname 字段 obj = dataReader["ChannelID"]; if (obj != null && obj != DBNull.Value) { model.ChannelID = Convert.ToInt32(obj); } obj = dataReader["ChannelName"]; if (obj != null && obj != DBNull.Value) { model.ChannelName = obj.ToString(); } if (hasvalueuser) { obj = dataReader["DownValueUsersForNew"]; if (obj != null && obj != DBNull.Value) { model.DownValueUsersForNew = Convert.ToInt32(obj); } obj = dataReader["DownValueUsersForAct"]; if (obj != null && obj != DBNull.Value) { model.DownValueUsersForAct = Convert.ToInt32(obj); } obj = dataReader["FuncValueUsersForNew"]; if (obj != null && obj != DBNull.Value) { model.FuncValueUsersForNew = Convert.ToInt32(obj); } obj = dataReader["FuncValueUsersForAct"]; if (obj != null && obj != DBNull.Value) { model.FuncValueUsersForAct = Convert.ToInt32(obj); } } //使用量 model.UseNum = model.ActiveNum + model.NewNum; //增长率 float frontNum = model.TotalNum - model.NewNum; if (frontNum <= 0) { model.Growth = "100%"; } else { model.Growth = (model.NewNum / frontNum * 100).ToString("0.00") + "%"; } //活跃百分比和使用百分比 if (model.TotalNum != 0) { model.ActivityPercent = (model.ActiveNum / (double)model.TotalNum * 100).ToString("0.00") + "%"; model.UsePercent = (model.UseNum / (double)model.TotalNum * 100).ToString("0.00") + "%"; } else { model.ActivityPercent = "100%"; model.UsePercent = "100%"; } //流失率 if (model.LostNum == -1) { model.LostPercent = ""; } else { model.LostPercent = (model.LostNum / (double)model.UseNum * 100).ToString("0.00") + "%"; } return(model); }
///获取统计慨况 public void GetTableGaiKuang() { DateTime hourendtime = EndTimeForHour.Date; //预计今日使用的数据,昨天之前的5天数据 List <SoftUser> users = _usersfor80Days.Where(p => p.StatDate >= EndTime.AddDays(-5) && p.Period == (int)net91com.Stat.Core.PeriodOptions.Daily).ToList(); if (users.Count != 0) { StringBuilder sb = new StringBuilder("<table class=\" tablesorter \" cellspacing=\"1\">"); sb.Append(@" <thead><tr> <th>指标</th> <th>新增用户</th> <th>活跃用户</th> <th>新用户占比</th> <th>日活跃度</th> </tr></thead>"); sb.Append("<tbody>"); sb.Append("<tr class=\"tableover\">"); int totalNumyes = users[0].NewNum + users[0].ActiveNum; sb.Append(string.Format(@"<td>昨日</td><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td> ", Utility.SetNum(users[0].NewNum), Utility.SetNum(totalNumyes), (users[0].NewNum / (double)totalNumyes * 100).ToString("0.00") + "%", (totalNumyes / (double)users[0].TotalNum * 100).ToString("0.00") + "%")); sb.Append("</tr>"); SoftUser forecast = GetForeCastSoftUser(users.ToList()); sb.Append("<tr class=\"tableover\">"); int totalNumforeLast = forecast.NewNum + forecast.ActiveNum; sb.Append(string.Format(@"<td>预计今日</td><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td> ", Utility.SetNum(forecast.NewNum), Utility.SetNum(forecast.ActiveNum), (forecast.NewNum / (double)totalNumforeLast * 100).ToString("0.00") + "%", ((forecast.ActiveNum + forecast.NewNum) / (double)forecast.TotalNum * 100).ToString("0.00") + "%")); sb.Append("</tr>"); //历史最高 List <SoftUser> tempHigh = Sjqd_StatUsersService.GetInstance().GetMaxNumCache(EndTime.AddDays(-1000), EndTime, SoftID, PlatID, net91com.Stat.Core.PeriodOptions.Daily, CacheTimeOption.OneHour); sb.Append("<tr class=\"tableover\">"); if (tempHigh.Count == 1) { sb.Append(string.Format(@"<td>历史最高</td><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td> ", Utility.SetNum(tempHigh[0].NewNum) + "(" + tempHigh[0].StatDate.ToShortDateString() + ")", Utility.SetNum(tempHigh[0].ActiveNum + tempHigh[0].NewNum) + "(" + tempHigh[0].StatDate.ToShortDateString() + ")", "--", "--")); sb.Append("</tr>"); } else if (tempHigh.Count == 2) { sb.Append(string.Format(@"<td>历史最高</td><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td> ", Utility.SetNum(tempHigh[0].NewNum) + "(" + tempHigh[0].StatDate.ToShortDateString() + ")", Utility.SetNum(tempHigh[1].ActiveNum + tempHigh[1].NewNum) + "(" + tempHigh[1].StatDate.ToShortDateString() + ")", "--", "--")); sb.Append("</tr>"); } else { sb.Append(string.Format(@"<td>历史最高</td><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td> ", "--", "--", "--", "--")); sb.Append("</tr>"); } sb.Append("</tbody></table>"); TabStrGaiKuang = sb.ToString(); } _usersfor80Days.Clear(); _usersfor80Days = null; }