/// <summary> /// 获取子渠道排行 /// </summary> /// <param name="softId"></param> /// <param name="platform"></param> /// <param name="period"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="channelId"></param> private void GetRankOfSubChannels(int softId, int platform, int period, DateTime startDate, DateTime endDate, int channelId) { //权限验证 CheckHasRight(softId, "Reports/RankOfChannels.aspx"); int orderby = Convert.ToInt32(ThisRequest["OrderBy"]); bool desc = Convert.ToBoolean(ThisRequest["Desc"]); List <Sjqd_StatUsers> users = new StatUsersService().GetRankOfChannels(softId, platform, channelId, period, ref startDate, ref endDate); if (desc) { users = (orderby == 0 ? users.OrderByDescending(a => a.NewUserCount) : users.OrderByDescending(a => a.NewUserCount - a.LastNewUserCount)).ToList(); } else { users = (orderby == 0 ? users.OrderBy(a => a.NewUserCount) : users.OrderBy(a => a.NewUserCount - a.LastNewUserCount)).ToList(); } StringBuilder sb = new StringBuilder(); sb.AppendFormat("<table id=\"tbl{0}\" class=\"tablesorter\" cellspacing=\"1\"><thead><tr style=\"text-align:center;\">", channelId); sb.Append("<th>排名</th><th>子渠道</th><th>新增用户</th><th>涨跌量</th><th>累计用户</th><th>活跃用户</th><th>活跃度</th><th>留存率(上周期)</th><th>操作</th></tr></thead><tbody>"); for (int i = 0; i < users.Count; i++) { sb.Append("<tr style=\"text-align:right;\">"); sb.AppendFormat("<td>{0}</td>", i + 1); sb.AppendFormat("<td style=\"text-align:left;\"><a href=\"javascript:linkDetail({1},2)\">{0}</a></td>", users[i].Name, users[i].ID); sb.AppendFormat("<td>{0:N0}</td>", users[i].NewUserCount); sb.AppendFormat("<td>{0:N0}</td>", users[i].NewUserCount - users[i].LastNewUserCount); sb.AppendFormat("<td>{0:N0}</td>", users[i].TotalUserCount); sb.AppendFormat("<td>{0:N0}</td>", users[i].ActiveUserCount); sb.AppendFormat("<td>{0}</td>", users[i].TotalUserCount == 0 ? "" : ((decimal)users[i].ActiveUserCount / users[i].TotalUserCount * 100).ToString("0.00") + "%"); sb.AppendFormat("<td>{0}</td>", users[i].LastNewUserCount == 0 ? "" : ((decimal)users[i].RetainedUserCount / users[i].LastNewUserCount * 100).ToString("0.00") + "%"); sb.AppendFormat(@"<td style=""text-align:left;""><span class=""caozuo"" onclick=""getRankOfSubChannels(this,{0});"">子渠道</span> <span class=""caozuo"" onclick=""getRankOfVersions(this,{0});"">版本</span> <span class=""caozuo"" onclick=""getRankOfCountries(this,{0});"">国家</span></td></tr>", users[i].ID); sb.AppendFormat(@"<tr style=""display:none;"" id=""tr_{0}""><td colspan=""10""><div id=""div_{0}""></div></td></tr>", users[i].ID); } sb.Append("</tbody></table>"); object b; if (users.Count == 0) { b = new { code = -1, data = "无数据" }; } else { b = new { code = 1, data = sb.ToString() }; } HttpContext.Current.Response.Write(JsonConvert.SerializeObject(b)); }
/// <summary> /// 获取版本排行 /// </summary> /// <param name="softId"></param> /// <param name="platform"></param> /// <param name="period"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="channelId"></param> /// <param name="channelType"></param> private void GetRankOfVersions(int softId, int platform, int period, DateTime startDate, DateTime endDate, int channelId, ChannelTypeOptions channelType) { //权限验证 CheckHasRight(softId, "Reports/RankOfChannels.aspx"); int orderby = Convert.ToInt32(ThisRequest["OrderBy"]); List <Sjqd_StatUsers> users = new StatUsersService().GetRankOfVersions(softId, platform, channelId, channelType, period, ref startDate, ref endDate); users = (orderby == 0 ? users.OrderByDescending(a => a.NewUserCount) : users.OrderByDescending(a => a.NewUserCount - a.LastNewUserCount)).ToList(); StringBuilder sb = new StringBuilder(); sb.AppendFormat("<table id=\"tbl{0}\" class=\"tablesorter\" cellspacing=\"1\"><thead><tr style=\"text-align:center;\">", channelId); sb.Append("<th>排名</th><th>版本</th><th>新增用户</th><th>涨跌量</th><th>活跃用户</th><th>留存率(上周期)</th></tr></thead><tbody>"); for (int i = 0; i < users.Count; i++) { sb.Append("<tr style=\"text-align:right;\">"); sb.AppendFormat("<td>{0}</td>", i + 1); sb.AppendFormat("<td style=\"text-align:left;\">{0}</td>", users[i].Name); sb.AppendFormat("<td>{0:N0}</td>", users[i].NewUserCount); sb.AppendFormat("<td>{0:N0}</td>", users[i].NewUserCount - users[i].LastNewUserCount); sb.AppendFormat("<td>{0:N0}</td>", users[i].ActiveUserCount); sb.AppendFormat("<td>{0}</td></tr>", users[i].LastNewUserCount == 0 ? "" : ((decimal)users[i].RetainedUserCount / users[i].LastNewUserCount * 100).ToString("0.00") + "%"); } sb.Append("</tbody></table>"); object b; if (users.Count == 0) { b = new { code = -1, data = "无数据" }; } else { b = new { code = 1, data = sb.ToString() }; } HttpContext.Current.Response.Write(JsonConvert.SerializeObject(b)); }
protected void GetQueryString() { OrderBy = string.IsNullOrEmpty(Request["orderby"]) ? (string.IsNullOrEmpty(Request["hOrderBy"]) ? 0 : Convert.ToInt32(Request["hOrderBy"])) : Convert.ToInt32(Request["orderby"]); Desc = string.IsNullOrEmpty(Request["Desc"]) ? (string.IsNullOrEmpty(Request["hDesc"]) ? true : Convert.ToBoolean(Request["hDesc"])) : Convert.ToBoolean(Request["desc"]); HeadControl1.IsHasNoPlat = true; //默认模式 if (HeadControl1.IsFirstLoad) { SoftID = CookieSoftid; Platform = CookiePlatid; EndTime = DateTime.Now.Date.AddDays(-1); BeginTime = EndTime.AddDays(-30); HeadControl1.SoftID = SoftID.ToString(); HeadControl1.PlatID = Platform.ToString(); } else { SoftID = Convert.ToInt32(HeadControl1.SoftID); Platform = Convert.ToInt32(HeadControl1.PlatID); BeginTime = HeadControl1.BeginTime; EndTime = HeadControl1.EndTime; SetRequestCookie(SoftID, Platform); } List <Sjqd_StatUsers> ranks = new StatUsersService().GetRankOfCountries(SoftID, Platform, ChannelTypeOptions.Category, 0, (int)PeriodSelector1.SelectedPeriod, ref BeginTime, ref EndTime); HeadControl1.BeginTime = BeginTime; HeadControl1.EndTime = EndTime; switch (OrderBy) { case 0: ranks = (Desc ? ranks.OrderByDescending(a => a.NewUserCount) : ranks.OrderBy(a => a.NewUserCount)).ToList(); break; case 1: ranks = (Desc ? ranks.OrderByDescending(a => a.NewUserCount - a.LastNewUserCount) : ranks.OrderBy(a => a.NewUserCount - a.LastNewUserCount)).ToList(); break; default: ranks = (Desc ? ranks.OrderByDescending(a => (double)a.RetainedUserCount / a.OriginalNewUserCount) : ranks.OrderBy(a => (double)a.RetainedUserCount / a.OriginalNewUserCount)).ToList(); break; } days = (EndTime - BeginTime).Days + 1; List <object> list = new List <object>(); for (int i = 0; i < ranks.Count; i++) { list.Add(new { RankIndex = i + 1, ID = ranks[i].ID, Name = ranks[i].Name, NewUserCount = Utility.SetNum(ranks[i].NewUserCount), NewUserCountDiff = Utility.SetNum(ranks[i].NewUserCount - ranks[i].LastNewUserCount), ActiveUserCount = Utility.SetNum(ranks[i].ActiveUserCount), RetainedUserRate = ranks[i].LastNewUserCount == 0 ? "" : ((decimal)ranks[i].RetainedUserCount / ranks[i].LastNewUserCount * 100).ToString("0.00") + "%", RetainedUserAvgRate = (ranks[i].RetainedUserCountDailyRate * 100).ToString("0.00") + "%", AvgDownCount = (ranks[i].DownUserCount == 0 ? 0.00 : (ranks[i].DownCount * 1.0 / ranks[i].DownUserCount)).ToString("0.00"), AvgDownCount_One = (ranks[i].DownCountNotUpdate == 0 ? 0.00 : (ranks[i].DownCountNotUpdate * 1.0 / ranks[i].DownUserCountNotUpdate)).ToString("0.00") }); } Repeater1.DataSource = list; Repeater1.DataBind(); }
protected void GetQueryString() { //默认模式 if (HeadControl1.IsFirstLoad) { SoftID = CookieSoftid; Platform = CookiePlatid; //StatDate = UtilityService.GetInstance().GetMaxTimeCache(PeriodSelector1.SelectedPeriod, ReportType.UserUseNewActivity,CacheTimeOption.TenMinutes); //StatDate = StatDate.Date; EndTime = DateTime.Now.Date.AddDays(-1); BeginTime = EndTime.AddDays(-30); //HeadControl1.SingleTime = StatDate; HeadControl1.SoftID = SoftID.ToString(); HeadControl1.PlatID = Platform.ToString(); } else { SoftID = Convert.ToInt32(HeadControl1.SoftID); Platform = Convert.ToInt32(HeadControl1.PlatID); //StatDate =HeadControl1.SingleTime; BeginTime = HeadControl1.BeginTime; EndTime = HeadControl1.EndTime; //UtilityHelp.SpecificateSingleTime(ref StatDate, (Report_Period)Convert.ToInt32(PeriodSelector1.SelectedPeriod)); SetRequestCookie(SoftID, Platform); } int period = Convert.ToInt32(PeriodSelector1.SelectedPeriod); OrderBy = string.IsNullOrEmpty(Request["orderby"]) ? (string.IsNullOrEmpty(Request["hOrderBy"]) ? 0 : Convert.ToInt32(Request["hOrderBy"])) : Convert.ToInt32(Request["orderby"]); Desc = string.IsNullOrEmpty(Request["Desc"]) ? (string.IsNullOrEmpty(Request["hDesc"]) ? true : Convert.ToBoolean(Request["hDesc"])) : Convert.ToBoolean(Request["desc"]); List <Sjqd_StatUsers> users = new StatUsersService().GetRankOfChannels(SoftID, Platform, 0, (int)PeriodSelector1.SelectedPeriod, ref BeginTime, ref EndTime); HeadControl1.BeginTime = BeginTime; HeadControl1.EndTime = EndTime; //SetDescriptDate(EndTime, (Report_Period)period); GetRankOfCitiesUrl = string.Format("/Services/GetMore.ashx?Action=GetRankOfAreas&AreaType=3&SoftIds={0}&Platforms={1}&Period={2}&StartDate={3:yyyy-MM-dd}&EndDate={4:yyyy-MM-dd}&OrderBy={5}&Desc={6}&v={7}&ChannelTypes={8}", SoftID, Platform, period, BeginTime, EndTime, OrderBy, Desc, DateTime.Now.Ticks, (int)ChannelTypeOptions.Customer); GetRankOfProvincesUrl = string.Format("/Services/GetMore.ashx?Action=GetRankOfAreas&AreaType=2&SoftIds={0}&Platforms={1}&Period={2}&StartDate={3:yyyy-MM-dd}&EndDate={4:yyyy-MM-dd}&OrderBy={5}&Desc={6}&v={7}&ChannelTypes={8}", SoftID, Platform, period, BeginTime, EndTime, OrderBy, Desc, DateTime.Now.Ticks, (int)ChannelTypeOptions.Customer); GetRankOfCountriesUrl = string.Format("/Services/GetMore.ashx?Action=GetRankOfAreas&AreaType=1&SoftIds={0}&Platforms={1}&Period={2}&StartDate={3:yyyy-MM-dd}&EndDate={4:yyyy-MM-dd}&OrderBy={5}&Desc={6}&v={7}&ChannelTypes={8}", SoftID, Platform, period, BeginTime, EndTime, OrderBy, Desc, DateTime.Now.Ticks, (int)ChannelTypeOptions.Customer); GetRankOfVersionsUrl = string.Format("/Services/GetMore.ashx?Action=GetRankOfVersions&SoftIds={0}&Platforms={1}&Period={2}&StartDate={3:yyyy-MM-dd}&EndDate={4:yyyy-MM-dd}&OrderBy={5}&Desc={6}&v={7}&ChannelTypes={8}", SoftID, Platform, period, BeginTime, EndTime, OrderBy, Desc, DateTime.Now.Ticks, (int)ChannelTypeOptions.Customer); GetRankOfSubChannelsUrl = string.Format("/Services/GetMore.ashx?Action=GetRankOfSubChannels&SoftIds={0}&Platforms={1}&Period={2}&StartDate={3:yyyy-MM-dd}&EndDate={4:yyyy-MM-dd}&OrderBy={5}&Desc={6}&v={7}&ChannelTypes={8}", SoftID, Platform, period, BeginTime, EndTime, OrderBy, Desc, DateTime.Now.Ticks, (int)ChannelTypeOptions.Customer); if (Desc) { users = (OrderBy == 0 ? users.OrderByDescending(a => a.NewUserCount) : users.OrderByDescending(a => a.NewUserCount - a.LastNewUserCount)).ToList(); } else { users = (OrderBy == 0 ? users.OrderBy(a => a.NewUserCount) : users.OrderBy(a => a.NewUserCount - a.LastNewUserCount)).ToList(); } List <object> list = new List <object>(); for (int i = 0; i < users.Count; i++) { list.Add(new { RankIndex = i + 1, ChannelID = users[i].ID, ChannelName = users[i].Name, NewUserCount = Utility.SetNum(users[i].NewUserCount), NewUserCountDiff = Utility.SetNum(users[i].NewUserCount - users[i].LastNewUserCount), ActiveUserCount = Utility.SetNum(users[i].ActiveUserCount), ActiveUserRate = users[i].TotalUserCount == 0 ? "" : ((decimal)users[i].ActiveUserCount / users[i].TotalUserCount * 100).ToString("0.00") + "%", OneTimeUserCount = users[i].TotalUserCount == 0 ? "" : Utility.SetNum(users[i].OneTimeUserCount) + (users[i].TotalUserCount == 0 ? "(--)" : ("(" + ((decimal)users[i].OneTimeUserCount / users[i].TotalUserCount * 100).ToString("0.00") + "%)")), RetainedUserRate = users[i].OriginalNewUserCount == 0 ? "" : ((decimal)users[i].RetainedUserCount / users[i].OriginalNewUserCount * 100).ToString("0.00") + "%", TotalUserCount = Utility.SetNum(users[i].TotalUserCount) }); } Repeater1.DataSource = list; Repeater1.DataBind(); }