/// <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));
        }
        /// <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 GetStatUsersByAreaTransverse(int softId, int platform, int period, DateTime startDate, DateTime endDate, int[] channelIds, ChannelTypeOptions[] channelTypes)
        {
            //权限验证
            CheckHasRight(softId, "Reports/StatUsersByAreaTransverse.aspx");

            AddHead("地区分布.xls");

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

            switch (areaType)
            {
            case 2:
                users = suService.GetRankOfProvinces(softId, platform, channelTypes[0], channelIds[0], period, ref startDate, ref endDate);
                break;

            case 3:
                users = suService.GetRankOfCities(softId, platform, channelTypes[0], channelIds[0], period, ref startDate, ref endDate);
                break;

            default:
                users = suService.GetRankOfCountries(softId, platform, channelTypes[0], channelIds[0], period, ref startDate, ref endDate);
                break;
            }
            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>
        /// 获取数据加上绑定数据
        /// </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);
        }