/// <summary>
        /// 版本分布数据EXCEL文件下载
        /// </summary>
        /// <param name="softId"></param>
        /// <param name="platform"></param>
        /// <param name="period"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="channelIds"></param>
        /// <param name="channelTypes"></param>
        private void GetStatUsersByVersionTransverse(int softId, int platform, int period, DateTime startDate, DateTime endDate, int[] channelIds, ChannelTypeOptions[] channelTypes)
        {
            //权限验证
            CheckHasRight(softId, "Reports/StatUsersByVersionTransverse.aspx");

            AddHead("版本分布.xls");

            StatUsersService      suService = new StatUsersService();
            List <Sjqd_StatUsers> users     = suService.GetRankOfVersions(softId, platform, channelIds[0], channelTypes[0], period, ref startDate, ref endDate);

            users = users.OrderByDescending(a => a.NewUserCount).ToList();
            StringBuilder sb = new StringBuilder();

            sb.Append("<table border=\"1\">");
            sb.Append(@"<thead><tr style=""text-align:center;""><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.AppendFormat(@"<tr style=""text-align:right;""><td>{0}</td><td style=""text-align:left;"">{1}</td><td>{2:N0}</td>
                                  <td>{3:0.00}%</td><td>{4:N0}</td><td>{5:N0}</td><td>{6:0.00}%</td><td>{7:0.00}</td></tr>", i + 1
                                , users[i].Name
                                , users[i].NewUserCount
                                , users[i].NewUserPercent * 100
                                , users[i].NewUserCount - users[i].LastNewUserCount
                                , users[i].ActiveUserCount
                                , users[i].ActiveUserPercent * 100
                                , users[i].OriginalNewUserCount > 0 ? (((double)users[i].RetainedUserCount) / users[i].OriginalNewUserCount).ToString("0.00") + "%" : "");
            }
            sb.Append("</tbody></table>");
            ThisResponse.Write(sb.ToString());
        }
 /// <summary>
 /// 活跃用户留存率数据EXCEL文件下载
 /// </summary>
 /// <param name="softId"></param>
 /// <param name="platform"></param>
 /// <param name="startDate"></param>
 /// <param name="endDate"></param>
 /// <param name="channelIds"></param>
 /// <param name="channelTypes"></param>
 /// <param name="channelTexts"></param>
 private void GetStatRetainedActiveUsers(int softId, int platform, DateTime startDate, DateTime endDate, int[] channelIds, ChannelTypeOptions[] channelTypes, string[] channelTexts)
 {
     //权限验证
     CheckHasRight(softId, "Reports/StatRetainedActiveUsers.aspx");
     if (channelIds.Length == 1)
     {
         string fileName = string.Format("活跃用户留存率{0}.xls", channelIds[0] > 0 ? "(" + channelTexts[0] + ")" : string.Empty);
         AddHead(fileName);
         List <Sjqd_StatRetainedUsers> users = new StatUsersService().GetStatRetainedActiveUsers(softId, platform, channelIds[0], channelTypes[0], startDate, endDate);
         ThisResponse.Write(TableTemplateHelper.BuildStatRetainedUsersTable((int)net91com.Stat.Core.PeriodOptions.Daily, users, true, string.Empty, true));
     }
 }
예제 #3
0
        protected void BindData()
        {
            StatUsersService suService = new StatUsersService();

            reportTitle = "分版本统计";
            var           channels   = HeadControl1.Channel1.ChannelValues;
            List <string> versionIds = HeadControl1.VersionID.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();



            //不区分渠道
            if (HeadControl1.Channel1.ChannelValues.Count == 0)
            {
                foreach (string versionId in versionIds)
                {
                    ListAll.Add(suService.GetStatUsersByVersion(SoftID, PlatformID, ChannelTypeOptions.Category, 0, versionId, (int)Period, BeginTime, EndTime));
                    DataNames.Add(versionId);
                }
            }
            else
            {
                for (int i = 0; i < channels.Count; i++)
                {
                    foreach (string versionId in versionIds)
                    {
                        List <Sjqd_StatUsers> users = suService.GetStatUsersByVersion(SoftID, PlatformID, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), versionId, (int)Period, BeginTime, EndTime);
                        ListAll.Add(users);
                        DataNames.Add(string.Format("{0}-{1}", channels[i].ChannelText, versionId));
                    }
                }
            }

            string versionNames = string.Join(",", versionIds.ToArray());

            ExcelDownUrl = string.Format("/Services/ExcelDownloader.ashx?Action=GetStatUsersByVersion&SoftID={0}&Platform={1}&Period={2}&StartDate={3:yyyy-MM-dd}&EndDate={4:yyyy-MM-dd}&VersionIds={5}&VersionNames={6}&ChannelIds={7}&ChannelTypes={8}&ChannelTexts={9}&v={10}", SoftID, PlatformID, (int)Period, BeginTime, EndTime, HeadControl1.VersionID, HttpUtility.UrlEncode(versionNames), HeadControl1.Channel1.SelectedValue, HeadControl1.Channel1.SelectedCate, HttpUtility.UrlEncode(HeadControl1.Channel1.SelectedText), DateTime.Now.Ticks);

            if (ListAll.Count > 0)
            {
                GetAllLineJson();
                StringBuilder tablesBuilder = new StringBuilder();
                //形成tablehtml
                for (int i = 0; i < ListAll.Count; i++)
                {
                    tablesBuilder.Append(
                        TableHelper.BuildStatUsersByVersionTable(
                            ListAll[i].OrderByDescending(p => p.StatDate).ToList()
                            , (int)Period
                            , false
                            , i));
                }
                TablesHtml = tablesBuilder.ToString();
            }
        }
예제 #4
0
        /// <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 GetRankOfAreas(int softId, int platform, int period, DateTime startDate, DateTime endDate, int channelId, ChannelTypeOptions channelType)
        {
            //权限验证
            CheckHasRight(softId, "Reports/RankOfChannels.aspx");

            int areaType = string.IsNullOrEmpty(ThisRequest["AreaType"]) ? 1 : Convert.ToInt32(ThisRequest["AreaType"]);
            int orderby  = Convert.ToInt32(ThisRequest["OrderBy"]);
            StatUsersService      suService = new StatUsersService();
            List <Sjqd_StatUsers> users;

            switch (areaType)
            {
            case 2:
                users = suService.GetRankOfProvinces(softId, platform, channelType, channelId, period, ref startDate, ref endDate);
                break;

            case 3:
                users = suService.GetRankOfCities(softId, platform, channelType, channelId, period, ref startDate, ref endDate);
                break;

            default:
                users = suService.GetRankOfCountries(softId, platform, channelType, channelId, period, ref startDate, ref endDate);
                break;
            }
            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));
        }
예제 #5
0
        /// <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>&nbsp;&nbsp;&nbsp;&nbsp;
                                  <span class=""caozuo"" onclick=""getRankOfVersions(this,{0});"">版本</span>&nbsp;&nbsp;&nbsp;&nbsp;
                                  <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>
 /// 活跃用户留存率分地区数据EXCEL文件下载
 /// </summary>
 /// <param name="softId"></param>
 /// <param name="platform"></param>
 /// <param name="startDate"></param>
 /// <param name="endDate"></param>
 /// <param name="channelIds"></param>
 /// <param name="channelTypes"></param>
 /// <param name="channelTexts"></param>
 private void GetStatRetainedActiveUsersByArea(int softId, int platform, DateTime startDate, DateTime endDate, int[] channelIds, ChannelTypeOptions[] channelTypes, string[] channelTexts)
 {
     //权限验证
     CheckHasRight(softId, "Reports/StatRetainedActiveUsersByArea.aspx");
     //地区ID
     string[] areaIds   = string.IsNullOrEmpty(ThisRequest["AreaIds"]) ? new string[0] : ThisRequest["AreaIds"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToArray();
     string[] areaNames = string.IsNullOrEmpty(ThisRequest["AreaNames"]) ? new string[0] : ThisRequest["AreaNames"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToArray();
     if (areaIds.Length == 1 && areaIds.Length == areaNames.Length && channelIds.Length == 1)
     {
         string fileName = string.Format("活跃用户留存率({0}{1}).xls", channelIds[0] > 0 ? channelTexts[0] + "-" : string.Empty, areaNames[0]);
         AddHead(fileName);
         List <Sjqd_StatRetainedUsers> users = new StatUsersService().GetStatRetainedActiveUsersByArea(softId, platform, areaIds[0], channelIds[0], channelTypes[0], startDate, endDate);
         ThisResponse.Write(TableTemplateHelper.BuildStatRetainedUsersTable((int)net91com.Stat.Core.PeriodOptions.Daily, users, true, string.Empty, true));
     }
 }
 /// <summary>
 /// 新增用户留存率分版本数据EXCEL文件下载
 /// </summary>
 /// <param name="softId"></param>
 /// <param name="platform"></param>
 /// <param name="period"></param>
 /// <param name="startDate"></param>
 /// <param name="endDate"></param>
 /// <param name="channelIds"></param>
 /// <param name="channelTypes"></param>
 /// <param name="channelTexts"></param>
 private void GetStatRetainedUsersByVersion(int softId, int platform, int period, DateTime startDate, DateTime endDate, int[] channelIds, ChannelTypeOptions[] channelTypes, string[] channelTexts)
 {
     //权限验证
     CheckHasRight(softId, "Reports/StatRetainedUsersByVersion.aspx");
     //版本ID
     string[] versionIds   = string.IsNullOrEmpty(ThisRequest["VersionIds"]) ? new string[0] : ThisRequest["VersionIds"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToArray();
     string[] versionNames = string.IsNullOrEmpty(ThisRequest["VersionNames"]) ? new string[0] : ThisRequest["VersionNames"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToArray();
     if (versionIds.Length == 1 && versionIds.Length == versionNames.Length && channelIds.Length == 1)
     {
         string fileName = string.Format("新增用户留存率({0}{1}).xls", channelIds[0] > 0 ? channelTexts[0] + "-" : string.Empty, versionNames[0]);
         AddHead(fileName);
         List <Sjqd_StatRetainedUsers> users = new StatUsersService().GetStatRetainedUsersByVersion(softId, platform, versionIds[0], channelIds[0], channelTypes[0], period, startDate, endDate);
         ThisResponse.Write(TableTemplateHelper.BuildStatRetainedUsersTable(period, users, true, string.Empty));
     }
 }
예제 #8
0
        /// <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>
        public void GetStatUsersByVersionLine(int softId, int platform, int period, DateTime startDate, DateTime endDate, int channelId, ChannelTypeOptions channelType)
        {
            //权限验证
            CheckHasRight(softId, "Reports/StatUsersByVersionTransverse.aspx");

            //版本ID
            string[] versionIds = string.IsNullOrEmpty(ThisRequest["VersionIds"]) ? new string[0] : ThisRequest["VersionIds"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToArray();
            if (versionIds.Length > 0)
            {
                StatUsersService      suService     = new StatUsersService();
                List <Sjqd_StatUsers> statUsersList = suService.GetStatUsersByVersion(softId, platform, channelType, channelId, versionIds[0], period, startDate, endDate);
                LineChart             chart         = new LineChart(startDate, endDate);
                chart.Period = (net91com.Stat.Core.PeriodOptions)period;
                LineChartLine newUserLine = new LineChartLine
                {
                    Name          = "新增",
                    Show          = true,
                    XIntervalDays = 0,
                    Points        = statUsersList.Select(a => new LineChartPoint {
                        XValue = a.StatDate, YValue = a.NewUserCount, DataContext = a
                    }).ToList()
                };
                chart.Y.Add(newUserLine);
                LineChartLine activeUserLine = new LineChartLine
                {
                    Name          = "活跃",
                    Show          = true,
                    XIntervalDays = 0,
                    Points        = statUsersList.Select(a => new LineChartPoint {
                        XValue = a.StatDate, YValue = a.ActiveUserCount, DataContext = a
                    }).ToList()
                };
                chart.Y.Add(activeUserLine);
                string axisJsonStr = string.Format("{{{0},labels:{{align:'left',tickLength:80,tickPixelInterval:140,rotation:-45,x:-30,y:45,step:{1}}}}}"
                                                   , chart.GetXJson()
                                                   , chart.Step);

                string seriesJsonStr = chart.GetYJson(
                    delegate(LineChartPoint point)
                {
                    return(string.Format(",\"growth\":\"{0}\",\"Denominator\":{1},\"Other\":null", "", "0"));
                });
                string result = "{ x:" + axisJsonStr + "," + "y:" + seriesJsonStr + "}";
                HttpContext.Current.Response.Write(result);
            }
        }
        /// <summary>
        /// 获取数据加上绑定数据
        /// </summary>
        protected void BindData()
        {
            int channelId = 0;
            ChannelTypeOptions channelType = ChannelTypeOptions.Category;

            if (HeadControl1.Channel1.ChannelValues.Count > 0)
            {
                channelId   = HeadControl1.Channel1.ChannelValues[0].ChannelValue;
                channelType = HeadControl1.Channel1.ChannelValues[0].ChannelType;
            }
            StatUsersService suService = new StatUsersService();
            List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatRetainedUsers> users = suService.GetStatRetainedUsersByVersion(SoftID, PlatformID, HeadControl1.VersionID, channelId, channelType, (int)Period, BeginTime, EndTime);

            ExcelDownUrl = string.Format("/Services/ExcelDownloader.ashx?Action=GetStatRetainedUsersByVersion&SoftID={0}&Platform={1}&Period={2}&StartDate={3:yyyy-MM-dd}&EndDate={4:yyyy-MM-dd}&VersionIds={5}&VersionNames={6}&ChannelIds={7}&ChannelTypes={8}&ChannelTexts={9}&v={10}", SoftID, PlatformID, (int)Period, BeginTime, EndTime, HeadControl1.VersionID, HeadControl1.VersionID, HeadControl1.Channel1.SelectedValue, HeadControl1.Channel1.SelectedCate, HttpUtility.UrlEncode(HeadControl1.Channel1.SelectedText), DateTime.Now.Ticks);

            SeriesJsonStr = LineChartHelper.BuildStatRetainedUsersLine(users, Period, BeginTime, EndTime, out AxisJsonStr);

            TablesHtml = TableTemplateHelper.BuildStatRetainedUsersTable((int)Period, users, false, string.Empty);
        }
        /// <summary>
        /// 获取数据加上绑定数据
        /// </summary>
        protected void BindData()
        {
            int channelId = 0;
            ChannelTypeOptions channelType = ChannelTypeOptions.Category;

            if (HeadControl1.Channel1.ChannelValues.Count > 0)
            {
                channelId   = HeadControl1.Channel1.ChannelValues[0].ChannelValue;
                channelType = HeadControl1.Channel1.ChannelValues[0].ChannelType;
            }
            StatUsersService suService = new StatUsersService();
            List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> users = AreaType == 1
                ? suService.GetRankOfCountries(softsid, platformsid, channelType, channelId, (int)Period, ref BeginTime, ref EndTime)
                : (AreaType == 2 ? suService.GetRankOfProvinces(softsid, platformsid, channelType, channelId, (int)Period, ref BeginTime, ref EndTime)
                : suService.GetRankOfCities(softsid, platformsid, channelType, channelId, (int)Period, ref BeginTime, ref EndTime));

            if (reporttype.Value == "0")
            {
                users = users.OrderByDescending(a => a.NewUserCount).ToList();
            }
            else
            {
                users = users.OrderByDescending(a => a.ActiveUserCount).ToList();
            }

            HeadControl1.BeginTime = BeginTime;
            HeadControl1.EndTime   = EndTime;
            reportTitle            = string.Format("地区分布({0:yyyy-MM-dd}至{1:yyyy-MM-dd})", BeginTime, EndTime);

            ExcelDownUrl = string.Format("/Services/ExcelDownloader.ashx?Action=GetStatUsersByAreaTransverse&SoftID={0}&Platform={1}&Period={2}&StartDate={3:yyyy-MM-dd}&EndDate={4:yyyy-MM-dd}&ChannelIds={5}&ChannelTypes={6}&ChannelTexts={7}&v={8}&AreaType={9}", softsid, platformsid, (int)Period, BeginTime, EndTime, HeadControl1.Channel1.SelectedValue, HeadControl1.Channel1.SelectedCate, HttpUtility.UrlEncode(HeadControl1.Channel1.SelectedText), DateTime.Now.Ticks, AreaType);
            GetStatUsersByAreaLineUrl = string.Format("/Services/GetMore.ashx?Action=GetStatUsersByAreaLine&SoftIds={0}&Platforms={1}&Period={2}&StartDate={3:yyyy-MM-dd}&EndDate={4:yyyy-MM-dd}&ChannelIds={5}&ChannelTypes={6}&ChannelTexts={7}&v={8}", softsid, platformsid, (int)net91com.Stat.Core.PeriodOptions.Daily, BeginTime, EndTime, HeadControl1.Channel1.SelectedValue, HeadControl1.Channel1.SelectedCate, HttpUtility.UrlEncode(HeadControl1.Channel1.SelectedText), DateTime.Now.Ticks);

            if (users.Count == 0)
            {
                SeriesJsonStr = "[]";
                reportTitle   = "无数据";
            }
            else
            {
                SeriesJsonStr = GetYlineJson(users);
            }
            tableStr = GetTableString(users);
        }
        protected void BindData()
        {
            reportTitle = "分国家分版本统计(海外)";

            List <string>    versionIds = HeadControl1.VersionID.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
            List <string>    countryIds = HeadControl1.CustomType.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
            StatUsersService suService  = new StatUsersService();
            Dictionary <string, List <Sjqd_StatUsers> > users = suService.GetStatUsersByCountryByVersionEn(SoftID, PlatformID, versionIds, countryIds, BeginTime, EndTime);

            foreach (string ver in versionIds)
            {
                foreach (var area in countryIds)
                {
                    string key = string.Format("{0}-{1}", ver, area);
                    ListAll.Add(users.ContainsKey(key) ? users[key] : new List <Sjqd_StatUsers>());
                    DataNames.Add(string.Format("{0}-{1}", ver, GetAreaDict()[area]));
                }
            }

            string versionIdsString = string.Join(",", versionIds.Select(a => a.ToString()).ToArray());
            string countryIdsString = string.Join(",", countryIds.Select(a => a.ToString()).ToArray());
            string versionNames     = versionIdsString;
            string countries        = string.Join(",", countryIds.Select(a => GetAreaDict()[a.ToString()]).ToArray());

            ExcelDownUrl = string.Format("/Services/ExcelDownloader.ashx?Action=GetStatUsersByCountryByVersionEn&SoftID={0}&Platform={1}&StartDate={2:yyyy-MM-dd}&EndDate={3:yyyy-MM-dd}&VersionIds={4}&VersionNames={5}&CountryIds={6}&Countries={7}&v={8}", SoftID, PlatformID, BeginTime, EndTime, versionIdsString, HttpUtility.UrlEncode(versionNames), countryIdsString, HttpUtility.UrlEncode(countries), DateTime.Now.Ticks);

            if (ListAll.Count > 0)
            {
                GetAllLineJson();
                StringBuilder tablesBuilder = new StringBuilder();
                //形成tablehtml
                for (int i = 0; i < ListAll.Count; i++)
                {
                    tablesBuilder.Append(
                        TableHelper.BuildStatUsersByCountryByVersionEnTable(
                            ListAll[i].OrderByDescending(p => p.StatDate).ToList()
                            , false
                            , i));
                }
                TablesHtml = tablesBuilder.ToString();
            }
        }
        /// <summary>
        /// 分地区用户数据EXCEL文件下载
        /// </summary>
        /// <param name="softId"></param>
        /// <param name="platform"></param>
        /// <param name="period"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="channelIds"></param>
        /// <param name="channelTypes"></param>
        /// <param name="channelTexts"></param>
        private void GetStatUsersByArea(int softId, int platform, int period, DateTime startDate, DateTime endDate, int[] channelIds, ChannelTypeOptions[] channelTypes, string[] channelTexts)
        {
            //权限验证
            CheckHasRight(softId, "Reports/StatUsersByArea.aspx");
            //地区ID
            string[] areaIds   = string.IsNullOrEmpty(ThisRequest["AreaIds"]) ? new string[0] : ThisRequest["AreaIds"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToArray();
            string[] areaNames = string.IsNullOrEmpty(ThisRequest["AreaNames"]) ? new string[0] : ThisRequest["AreaNames"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToArray();
            if (areaIds.Length > 0 && areaIds.Length == areaNames.Length)
            {
                AddHead("分地区统计.xls");

                StringBuilder firstRowBuilder  = new StringBuilder("<tr style=\"text-align:center\"><th rowspan=\"2\">日期</th>");
                StringBuilder secondRowBuilder = new StringBuilder("<tr style=\"text-align:center\">");
                Dictionary <string, StringBuilder> dataRowBuilders = new Dictionary <string, StringBuilder>();
                List <DateTime> dates = GetDateList((net91com.Stat.Core.PeriodOptions)period, startDate, endDate);
                for (int i = 0; i < dates.Count; i++)
                {
                    dataRowBuilders.Add(dates[i].ToString("yyyy-MM-dd"), new StringBuilder("<tr style=\"text-align:right\"><td>" + dates[i].ToString("yyyy-MM-dd") + "</td>"));
                }
                StringBuilder totalRowBuilder = new StringBuilder("<tr style=\"text-align:right\"><td>总计</td>");
                StringBuilder avgRowBuilder   = new StringBuilder("<tr style=\"text-align:right\"><td>平均</td>");
                //获取分地区用户数据并输出结果
                StatUsersService suService = new StatUsersService();
                for (int i = 0; i < channelIds.Length; i++)
                {
                    for (int j = 0; j < areaIds.Length; j++)
                    {
                        firstRowBuilder.AppendFormat("<th colspan=\"4\">{0}{1}</th>", string.IsNullOrEmpty(channelTexts[i]) ? "" : channelTexts[i] + "-", areaNames[j]);
                        secondRowBuilder.Append("<th>新增用户</th><th>新增价值用户</th><th>活跃用户</th><th>活跃价值用户</th>");
                        List <Sjqd_StatUsers> statUsersList = suService.GetStatUsersByArea(softId, platform, channelTypes[i], channelIds[i], areaIds[j], period, startDate, endDate).OrderByDescending(a => a.StatDate).ToList();
                        for (int k = 0, l = 0; l < dates.Count; l++)
                        {
                            if (k < statUsersList.Count && dates[l] == statUsersList[k].StatDate)
                            {
                                dataRowBuilders[dates[l].ToString("yyyy-MM-dd")].AppendFormat("<td>{0:N0}</td><td>{1:N0}</td><td>{2:N0}</td><td>{3:N0}</td>", statUsersList[k].NewUserCount, statUsersList[k].DownNewUserCount, statUsersList[k].ActiveUserCount, statUsersList[k].DownActiveUserCount);
                                k++;
                            }
                            else
                            {
                                dataRowBuilders[dates[l].ToString("yyyy-MM-dd")].Append("<td></td><td></td><td></td><td></td>");
                            }
                        }
                        totalRowBuilder.AppendFormat("<td>{0:N0}</td><td>{1:N0}</td><td></td><td></td>", statUsersList.Sum(a => a.NewUserCount), statUsersList.Sum(a => a.DownNewUserCount));
                        avgRowBuilder.AppendFormat("<td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td>"
                                                   , statUsersList.Count == 0 ? "" : ((int)statUsersList.Average(a => a.NewUserCount)).ToString("N0")
                                                   , statUsersList.Count == 0 ? "" : ((int)statUsersList.Average(a => a.DownNewUserCount)).ToString("N0")
                                                   , statUsersList.Count == 0 ? "" : ((int)statUsersList.Average(a => a.ActiveUserCount)).ToString("N0")
                                                   , statUsersList.Count == 0 ? "" : ((int)statUsersList.Average(a => a.DownActiveUserCount)).ToString("N0"));
                    }
                }
                ThisResponse.Write("<table border=\"1\">");
                ThisResponse.Write(firstRowBuilder.ToString());
                ThisResponse.Write("</tr>");
                ThisResponse.Write(secondRowBuilder.ToString());
                ThisResponse.Write("</tr>");
                for (int i = 0; i < dates.Count; i++)
                {
                    ThisResponse.Write(dataRowBuilders[dates[i].ToString("yyyy-MM-dd")].ToString());
                    ThisResponse.Write("</tr>");
                }
                ThisResponse.Write(totalRowBuilder.ToString());
                ThisResponse.Write("</tr>");
                ThisResponse.Write(avgRowBuilder.ToString());
                ThisResponse.Write("</tr></table>");
            }
        }
        /// <summary>
        /// 分版本用户数据EXCEL文件下载
        /// </summary>
        /// <param name="softId"></param>
        /// <param name="platform"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        private void GetStatUsersByCountryByVersionEn(int softId, int platform, DateTime startDate, DateTime endDate)
        {
            //权限验证
            CheckHasRight(softId, "Reports/StatUsersByCountryByVersion.aspx");
            //版本
            string[] versionIds   = string.IsNullOrEmpty(ThisRequest["VersionIds"]) ? new string[0] : ThisRequest["VersionIds"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToArray();
            string[] versionNames = string.IsNullOrEmpty(ThisRequest["VersionNames"]) ? new string[0] : ThisRequest["VersionNames"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToArray();
            //国家
            string[] countryIds = string.IsNullOrEmpty(ThisRequest["CountryIds"]) ? new string[0] : ThisRequest["CountryIds"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToArray();
            string[] countries  = string.IsNullOrEmpty(ThisRequest["Countries"]) ? new string[0] : ThisRequest["Countries"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToArray();
            if (versionIds.Length > 0 && countryIds.Length > 0 &&
                versionIds.Length == versionNames.Length &&
                countryIds.Length == countries.Length)
            {
                AddHead("分国家分版本(海外)统计.xls");

                StringBuilder firstRowBuilder  = new StringBuilder("<tr style=\"text-align:center\"><th rowspan=\"2\">日期</th>");
                StringBuilder secondRowBuilder = new StringBuilder("<tr style=\"text-align:center\">");
                Dictionary <string, StringBuilder> dataRowBuilders = new Dictionary <string, StringBuilder>();
                List <DateTime> dates = GetDateList(net91com.Stat.Core.PeriodOptions.Daily, startDate, endDate);
                for (int i = 0; i < dates.Count; i++)
                {
                    dataRowBuilders.Add(dates[i].ToString("yyyy-MM-dd"), new StringBuilder("<tr style=\"text-align:right\"><td>" + dates[i].ToString("yyyy-MM-dd") + "</td>"));
                }
                StringBuilder totalRowBuilder = new StringBuilder("<tr style=\"text-align:right\"><td>总计</td>");
                StringBuilder avgRowBuilder   = new StringBuilder("<tr style=\"text-align:right\"><td>平均</td>");
                //获取分地区用户数据并输出结果
                StatUsersService suService = new StatUsersService();
                Dictionary <string, List <Sjqd_StatUsers> > users = suService.GetStatUsersByCountryByVersionEn(softId, platform, versionIds.ToList(), countryIds.ToList(), startDate, endDate);
                for (int i = 0; i < versionIds.Length; i++)
                {
                    for (int j = 0; j < countryIds.Length; j++)
                    {
                        firstRowBuilder.AppendFormat("<th colspan=\"2\">{0}-{1}</th>", versionNames[i], countries[j]);
                        secondRowBuilder.Append("<th>新增用户</th><th>活跃用户</th>");
                        B_BaseTool_DataAccess bt = new B_BaseTool_DataAccess();
                        string key = string.Format("{0}-{1}", versionIds[i], countryIds[j]);
                        List <Sjqd_StatUsers> statUsersList = users.ContainsKey(key) ? users[key].OrderByDescending(a => a.StatDate).ToList() : new List <Sjqd_StatUsers>();
                        for (int k = 0, l = 0; l < dates.Count; l++)
                        {
                            if (k < statUsersList.Count && dates[l] == statUsersList[k].StatDate)
                            {
                                dataRowBuilders[dates[l].ToString("yyyy-MM-dd")].AppendFormat("<td>{0:N0}</td><td>{1:N0}</td>", statUsersList[k].NewUserCount, statUsersList[k].ActiveUserCount);
                                k++;
                            }
                            else
                            {
                                dataRowBuilders[dates[l].ToString("yyyy-MM-dd")].Append("<td></td><td></td>");
                            }
                        }
                        totalRowBuilder.AppendFormat("<td>{0:N0}</td><td></td>", statUsersList.Sum(a => a.NewUserCount));
                        avgRowBuilder.AppendFormat("<td>{0}</td><td>{1}</td>", statUsersList.Count == 0 ? "" : ((int)statUsersList.Average(a => a.NewUserCount)).ToString("N0"), statUsersList.Count == 0 ? "" : ((int)statUsersList.Average(a => a.ActiveUserCount)).ToString("N0"));
                    }
                }
                ThisResponse.Write("   <table name=\"分国家分版本(海外)统计\" border=\"1\">");
                ThisResponse.Write(firstRowBuilder.ToString());
                ThisResponse.Write("</tr>");
                ThisResponse.Write(secondRowBuilder.ToString());
                ThisResponse.Write("</tr>");
                for (int i = 0; i < dates.Count; i++)
                {
                    ThisResponse.Write(dataRowBuilders[dates[i].ToString("yyyy-MM-dd")].ToString());
                    ThisResponse.Write("</tr>");
                }
                ThisResponse.Write(totalRowBuilder.ToString());
                ThisResponse.Write("</tr>");
                ThisResponse.Write(avgRowBuilder.ToString());
                ThisResponse.Write("</tr></table>");
            }
        }
예제 #14
0
        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();
        }
        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();
        }
예제 #16
0
        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();
        }
예제 #17
0
        private List <SoftUser> GetComplexPlatUserData_GetData(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"]);
            int      modetype  = Convert.ToInt32(context.Request["modetype"]);
            string   version   = context.Request["version"];
            int      realplat1 = 1;
            int      realplat2 = 7;

            if (plat == 4)
            {
                realplat1 = 4;
                realplat2 = 9;
            }
            if (1 == modetype)
            {
                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 <SoftUser>());
                }
                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]);
                    }
                }
                Sjqd_StatUsersByChannelsService service = Sjqd_StatUsersByChannelsService.GetInstance();

                var lists = new List <SoftUser>();

                if (list.Count == 1 && list[0].ChannelID == 0)
                {
                    List <SoftUser> result = Sjqd_StatUsersService.GetInstance()
                                             .GetSoftUserListCache(begintime, endtime,
                                                                   soft, realplat1
                                                                   , PeriodOptions.Daily,
                                                                   new URLoginService(),
                                                                   CacheTimeOption.TenMinutes)
                                             .OrderBy(p => p.StatDate)
                                             .ToList();
                    List <SoftUser> result2 = Sjqd_StatUsersService.GetInstance()
                                              .GetSoftUserListCache(begintime, endtime,
                                                                    soft, realplat2,
                                                                    PeriodOptions.Daily,
                                                                    new URLoginService(),
                                                                    CacheTimeOption.TenMinutes)
                                              .OrderBy(p => p.StatDate)
                                              .ToList();
                    if (result.Count() != 0)
                    {
                        lists.AddRange(result);
                    }
                    if (result2.Count() != 0)
                    {
                        lists.AddRange(result2);
                    }
                }
                else
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        List <SoftUser> result = service.GetSoftUserChanelListCache(begintime, endtime, soft, realplat1,
                                                                                    PeriodOptions.Daily,
                                                                                    list[i].ChannelType,
                                                                                    list[i].ChannelID, channelDic[
                                                                                        list[i]
                                                                                        .ChannelType +
                                                                                        "_" +
                                                                                        list[i].ChannelID], false,
                                                                                    new URLoginService(),
                                                                                    CacheTimeOption.TenMinutes);
                        List <SoftUser> result2 = service.GetSoftUserChanelListCache(begintime, endtime, soft, realplat2,
                                                                                     PeriodOptions.Daily,
                                                                                     list[i].ChannelType,
                                                                                     list[i].ChannelID, channelDic[
                                                                                         list[i]
                                                                                         .ChannelType +
                                                                                         "_" +
                                                                                         list[i].ChannelID], false,
                                                                                     new URLoginService(),
                                                                                     CacheTimeOption.TenMinutes);
                        if (result.Count() != 0)
                        {
                            lists.AddRange(result);
                        }
                        if (result2.Count() != 0)
                        {
                            lists.AddRange(result2);
                        }
                    }
                }

                return
                    (lists.GroupBy(p => p.StatDate)
                     .Select(
                         p =>
                         new SoftUser
                {
                    StatDate = p.Key,
                    NewNum = p.Sum(l => l.NewNum),
                    ActiveNum = p.Sum(l => l.NewNum) + p.Sum(l => l.ActiveNum)
                })
                     .ToList());
            }
            else
            {
                List <string> lstver = version.Split(',').ToList();
                var           lst    =
                    new List <Sjqd_StatUsers>();

                var suService = new StatUsersService();
                for (int i = 0; i < lstver.Count; i++)
                {
                    List <Sjqd_StatUsers> lstverdata1 = suService.GetStatUsersByVersion(soft, realplat1,
                                                                                        ChannelTypeOptions.Category, 0,
                                                                                        lstver[i],
                                                                                        (int)PeriodOptions.Daily,
                                                                                        begintime, endtime);
                    if (lstverdata1.Count != 0)
                    {
                        lst.AddRange(lstverdata1);
                    }
                }


                //var lstverdata2 = sbv.GetUsersByVersionCache(soft, realplat1, begintime, endtime, PeriodOptions.Daily, lstver,
                //           CacheTimeOption.TenMinutes);

                for (int i = 0; i < lstver.Count; i++)
                {
                    List <Sjqd_StatUsers> lstverdata2 = suService.GetStatUsersByVersion(soft, realplat1,
                                                                                        ChannelTypeOptions.Category, 0,
                                                                                        lstver[i],
                                                                                        (int)PeriodOptions.Daily,
                                                                                        begintime, endtime);
                    if (lstverdata2.Count != 0)
                    {
                        lst.AddRange(lstverdata2);
                    }
                }
                return
                    (lst.GroupBy(p => p.StatDate)
                     .Select(
                         p =>
                         new SoftUser
                {
                    StatDate = p.Key,
                    NewNum = p.Sum(l => l.NewUserCount),
                    ActiveNum = p.Sum(l => l.ActiveUserCount)
                })
                     .ToList());
            }
        }
예제 #18
0
        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();
        }