예제 #1
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();
            }
        }
예제 #2
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>
        /// 分版本用户数据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 GetStatUsersByVersion(int softId, int platform, int period, DateTime startDate, DateTime endDate, int[] channelIds, ChannelTypeOptions[] channelTypes, string[] channelTexts)
        {
            //权限验证
            CheckHasRight(softId, "Reports/StatUsersByVersion.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 > 0 && versionIds.Length == versionNames.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 < versionIds.Length; j++)
                    {
                        firstRowBuilder.AppendFormat("<th colspan=\"2\">{0}{1}</th>", string.IsNullOrEmpty(channelTexts[i]) ? "" : channelTexts[i] + "-", versionNames[j]);
                        secondRowBuilder.Append("<th>新增用户</th><th>活跃用户</th>");
                        List <Sjqd_StatUsers> statUsersList = suService.GetStatUsersByVersion(softId, platform, channelTypes[i], channelIds[i], versionIds[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>", 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>");
            }
        }
예제 #4
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());
            }
        }