//获取基础信息统计 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(); } }
private List <Sjqd_StatChannelRetainedUsers> GetYesterdayRetainGetData(HttpContext context) { DateTime begintime = Convert.ToDateTime(context.Request["begintime"]); DateTime endtime = Convert.ToDateTime(context.Request["endtime"]); int soft = Convert.ToInt32(context.Request["soft"]); int plat = Convert.ToInt32(context.Request["platform"]); string channelNames = context.Request["channelnames"]; string channelids = context.Request["channelids"]; //默认加一项进去 var list = new List <ChannelRight>(); string[] channels = channelids.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] channelarray = channelNames.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (channels.Length == 0) { channels = new[] { "Customer_0" }; channelarray = new[] { "不区分渠道" }; } //非渠道选项 if (channels.Length != channelarray.Length) { return(new List <Sjqd_StatChannelRetainedUsers>()); } var channelDic = new Dictionary <string, string>(); for (int i = 0; i < channels.Count(); i++) { string[] strs = channels[i].Split(new[] { '_' }, StringSplitOptions.RemoveEmptyEntries); if (strs.Length == 2) { list.Add(new ChannelRight { ChannelType = (ChannelTypeOptions)Enum.Parse(typeof(ChannelTypeOptions), strs[0]), ChannelID = Convert.ToInt32(strs[1]) }); channelDic.Add(channels[i], channelarray[i]); } } var service = new RetainedUsersService(true); var lists = new List <Sjqd_StatChannelRetainedUsers>(); for (int i = 0; i < list.Count; i++) { IEnumerable <Sjqd_StatChannelRetainedUsers> result = service.GetStatRetainedUsersCache(soft, plat, list[i].ChannelID, PeriodOptions .Daily, begintime, endtime, CacheTimeOption .TenMinutes, list[i] .ChannelType, new URLoginService ()) .Where( p => (p.StatDate - p.OriginalDate).Days == 1) .Select( l => new Sjqd_StatChannelRetainedUsers { ChannelName = channelDic[channels[i]], ChannelID = l.ChannelID, StatDate = l.StatDate, OriginalDate = l.OriginalDate, RetainedUserCount = l.RetainedUserCount, OriginalNewUserCount = l.OriginalNewUserCount, }); if (result.Count() != 0) { lists.AddRange(result); } } return(lists); }