Ejemplo n.º 1
0
        public void GetExcelNewUser()
        {
            try
            {
                net91com.Stat.Core.PeriodOptions Period = HttpContext.Current.Request["inputzhouqi"].ToEnum <net91com.Stat.Core.PeriodOptions>(net91com.Stat.Core.PeriodOptions.Daily);
                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      channelcate = Convert.ToInt32(HttpContext.Current.Request["channelcate"]);
                int      channeltype = Convert.ToInt32(HttpContext.Current.Request["channeltype"]);
                ///检查权限
                CheckHasRight(excelsoft, "Reports/NewUserReport.aspx");

                int excelplatform = Convert.ToInt32(HttpContext.Current.Request["excelplatform"]);
                SetStandardTime(Period, begintime, endtime);
                List <SoftUser> users;
                if (channelcate == -1)
                {
                    if (Period != net91com.Stat.Core.PeriodOptions.Hours && Period != net91com.Stat.Core.PeriodOptions.TimeOfDay)
                    {
                        users = Sjqd_StatUsersService.GetInstance().GetSoftUserListCache(begintime, endtime, excelsoft, (int)excelplatform, Period, loginService, CacheTimeOption.TenMinutes).OrderByDescending(p => p.StatDate).ToList();
                    }
                    else
                    {
                        //users = StatUsersByHourService.GetInstance().GetHourUserDataCache(excelsoft, excelplatform, begintime, endtime, Period, loginService,CacheTimeOption.TenMinutes).OrderByDescending(p => p.StatDate).ToList();
                        net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService suService = new net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService();
                        List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers>         ssUsers;
                        ssUsers = suService.GetStatUsersByHour(excelsoft, excelplatform, ChannelTypeOptions.Category, 0, (int)Period, begintime, endtime);
                        users   = new List <SoftUser>();
                        foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsers)
                        {
                            SoftUser softuser = new SoftUser();
                            softuser.StatDate  = u.StatDate;
                            softuser.SoftId    = excelsoft;
                            softuser.Platform  = excelplatform;
                            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();
                    }
                }
                else
                {
                    if (Period != net91com.Stat.Core.PeriodOptions.Hours && Period != net91com.Stat.Core.PeriodOptions.TimeOfDay)
                    {
                        users = Sjqd_StatUsersByChannelsService.GetInstance().GetSoftUserChanelListCache(begintime, endtime, excelsoft, excelplatform, Period,
                                                                                                         (ChannelTypeOptions)channeltype, channelcate, "", false, loginService, CacheTimeOption.TenMinutes).OrderBy(p => p.StatDate).ToList();
                    }
                    else
                    {
                        net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService suService = new net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService();
                        List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers>         ssUsers;
                        ssUsers = suService.GetStatUsersByHour(excelsoft, excelplatform, (ChannelTypeOptions)channeltype, channelcate, (int)Period, begintime, endtime);
                        users   = new List <SoftUser>();
                        foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsers)
                        {
                            SoftUser softuser = new SoftUser();
                            softuser.StatDate  = u.StatDate;
                            softuser.SoftId    = excelsoft;
                            softuser.Platform  = excelplatform;
                            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";

                AddHead(filename);

                //是否是内部软件
                bool isInternalSoft = AvailableSofts.FirstOrDefault(a => a.ID == excelsoft) != null;
                resp.Write(TableTemplateHelper.BuildStatUsersTable(excelsoft, (MobileOption)excelplatform, isInternalSoft, channelcate != -1, Period, "new", false, users, true, 0, ""));
                resp.End();
            }
            catch (Exception)
            {
                HttpContext.Current.Response.Write("");
            }
        }
Ejemplo n.º 2
0
        protected void BindData()
        {
            List <SoftUser> users;
            //是否给外部部人看的,自己内部人看,不用乘以系数的结果,给外部要乘
            bool isForOut = (usercate.Value == "11");

            if (isForOut)
            {
                reportTitle = "分渠道统计(外部)";
            }
            else
            {
                reportTitle = "分渠道统计(内部)";
            }
            //不区分渠道
            if (HeadControl1.Channel1.ChannelValues.Count == 0)
            {
                for (int i = 0; i < PlatformsidList.Count; i++)
                {
                    if (IsSuperPeriod)
                    {
                        //users =
                        //    StatUsersByHourService.GetInstance()
                        //                          .GetHourUserDataCache(softsid, PlatformsidList[i], BeginTime, EndTime,
                        //                                                Period, loginService,
                        //                                               CacheTimeOption.TenMinutes)
                        //                          .OrderBy(p => p.StatDate)
                        //                          .ToList();

                        net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService suService = new net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService();
                        List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers>         ssUsers;
                        ssUsers = suService.GetStatUsersByHour(softsid, PlatformsidList[i], ChannelTypeOptions.Category, 0, (int)Period, BeginTime, EndTime);
                        users   = new List <SoftUser>();
                        foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsers)
                        {
                            SoftUser softuser = new SoftUser();
                            softuser.StatDate  = u.StatDate;
                            softuser.SoftId    = softsid;
                            softuser.Platform  = PlatformsidList[i];
                            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();

                        //获取对比曲线
                        if (HeadControl1.CompareTimeType > 0)
                        {
                            //List<SoftUser> usersCompare =
                            //    StatUsersByHourService.GetInstance()
                            //                          .GetHourUserDataCache(softsid, PlatformsidList[i],
                            //                                                BeginCompareTime, EndCompareTime, Period,
                            //                                                loginService,
                            //                                               CacheTimeOption.TenMinutes)
                            //                          .OrderBy(p => p.StatDate).ToList();

                            List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsersComp;
                            ssUsersComp = suService.GetStatUsersByHour(softsid, PlatformsidList[i], ChannelTypeOptions.Category, 0, (int)Period, BeginCompareTime, EndCompareTime);
                            List <SoftUser> usersCompare = new List <SoftUser>();
                            foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsersComp)
                            {
                                SoftUser softuser = new SoftUser();
                                softuser.StatDate  = u.StatDate;
                                softuser.SoftId    = softsid;
                                softuser.Platform  = PlatformsidList[i];
                                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)
                            {
                                ListAllForCompare.Add(usersCompare);
                            }
                        }
                    }
                    else
                    {
                        users =
                            Sjqd_StatUsersService.GetInstance()
                            .GetSoftUserListCache(BeginTime, EndTime, softsid, PlatformsidList[i],
                                                  Period, loginService,
                                                  CacheTimeOption.TenMinutes)
                            .OrderBy(p => p.StatDate)
                            .ToList();

                        //获取计算预测数据
                        ForeCastUserDatas.AddRange(Sjqd_StatUsersService.GetInstance().GetForecastSoftUserCache(
                                                       softsid, PlatformsidList[i], Period, loginService, CacheTimeOption.TenMinutes));


                        //获取对比曲线
                        if (HeadControl1.CompareTimeType > 0)
                        {
                            List <SoftUser> usersCompare =
                                Sjqd_StatUsersService.GetInstance()
                                .GetSoftUserListCache(BeginCompareTime, EndCompareTime, softsid,
                                                      PlatformsidList[i], Period, loginService,
                                                      CacheTimeOption.TenMinutes)
                                .OrderBy(p => p.StatDate)
                                .ToList();

                            if (usersCompare.Count != 0)
                            {
                                ListAllForCompare.Add(usersCompare);
                            }
                        }
                    }
                    if (users.Count != 0)
                    {
                        ListAll.Add(users);
                        //添加里程碑列表集(若ListAll添加了,里程碑也要添加)
                        //mileStoneDate.Add(Sjqd_MileStoneConfigService.GetInstance()
                        //                        .GetMileStoneDatesByCache(softsid, PlatformsidList[i], BeginTime, EndTime));
                    }
                }
            }
            else
            {
                QuDao = true;
                var channels = HeadControl1.Channel1.ChannelValues;
                if (IsSuperPeriod)
                {
                    for (int i = 0; i < channels.Count; i++)
                    {
                        //小时和每小时将其和到一条曲线中去了
                        //users = Sjqd_StatUsersByChannelsService.GetInstance().GetChannelUsersByHoursDataCache(
                        //    BeginTime, EndTime, softsid, channels[i].Platform, Period, channels[i].ChannelType,
                        //    Convert.ToInt32(channels[i].ChannelValue), channels[i].ChannelText, loginService,
                        //   CacheTimeOption.TenMinutes).OrderBy(p => p.StatDate).ToList();

                        net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService suService = new net91com.Reports.Services.CommonServices.SjqdUserStat.StatUsersService();
                        List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers>         ssUsers;
                        ssUsers = suService.GetStatUsersByHour(softsid, channels[i].Platform, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), (int)Period, BeginTime, EndTime);
                        users   = new List <SoftUser>();
                        foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsers)
                        {
                            SoftUser softuser = new SoftUser();
                            softuser.StatDate  = u.StatDate;
                            softuser.SoftId    = softsid;
                            softuser.Platform  = channels[i].Platform;
                            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();

                        if (users.Count != 0)
                        {
                            //记住有数据渠道的编号
                            QuDaoList.Add(i);
                            ListAll.Add(users);
                            //添加里程碑列表集(若ListAll添加了,里程碑也要添加)
                            //mileStoneDate.Add(Sjqd_MileStoneConfigService.GetInstance()
                            //                        .GetMileStoneDatesByCache(softsid, channels[i].Platform, BeginTime, EndTime));
                        }
                        //获取对比曲线
                        if (HeadControl1.CompareTimeType > 0)
                        {
                            //List<SoftUser> usersCompare =
                            //    Sjqd_StatUsersByChannelsService.GetInstance().GetChannelUsersByHoursDataCache(
                            //        BeginCompareTime, EndCompareTime, softsid, channels[i].Platform, Period,
                            //        channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue),
                            //        channels[i].ChannelText, loginService,CacheTimeOption.TenMinutes)
                            //                                   .OrderBy(p => p.StatDate)
                            //                                   .ToList();

                            List <net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers> ssUsersComp;
                            ssUsersComp = suService.GetStatUsersByHour(softsid, channels[i].Platform, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), (int)Period, BeginCompareTime, EndCompareTime);
                            List <SoftUser> usersCompare = new List <SoftUser>();
                            foreach (net91com.Reports.Entities.DataBaseEntity.Sjqd_StatUsers u in ssUsersComp)
                            {
                                SoftUser softuser = new SoftUser();
                                softuser.StatDate  = u.StatDate;
                                softuser.SoftId    = softsid;
                                softuser.Platform  = channels[i].Platform;
                                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)
                            {
                                ListAllForCompare.Add(usersCompare);
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < channels.Count; i++)
                    {
                        users =
                            Sjqd_StatUsersByChannelsService.GetInstance()
                            .GetSoftUserChanelListCache(BeginTime, EndTime, softsid,
                                                        channels[i].Platform
                                                        , Period, channels[i].ChannelType,
                                                        Convert.ToInt32(
                                                            channels[i].ChannelValue),
                                                        channels[i].ChannelText, isForOut,
                                                        loginService,
                                                        CacheTimeOption.TenMinutes)
                            .OrderBy(p => p.StatDate)
                            .ToList();
                        if (users.Count != 0)
                        {
                            //记住有数据渠道的编号
                            QuDaoList.Add(i);
                            ListAll.Add(users);
                            //添加里程碑列表集(若ListAll添加了,里程碑也要添加)
                            //mileStoneDate.Add(Sjqd_MileStoneConfigService.GetInstance()
                            //                        .GetMileStoneDatesByCache(softsid, channels[i].Platform, BeginTime, EndTime));

                            //if (Period == net91com.Stat.Core.PeriodOptions.Daily)
                            //{
                            //    ForecastSoftUser softUser = Sjqd_StatUsersByChannelsService.GetInstance().GetStatUsersForRealTime(softsid,
                            //                                                           channels[i].Platform, channels[i].ChannelType, Convert.ToInt32(channels[i].ChannelValue), loginService, CacheTimeOption.TenMinutes);
                            //    if (softUser != null)
                            //        ForeCastUserDatas.Add(softUser);
                            //}
                        }
                        //获取对比曲线
                        if (HeadControl1.CompareTimeType > 0)
                        {
                            List <SoftUser> usersCompare =
                                Sjqd_StatUsersByChannelsService.GetInstance()
                                .GetSoftUserChanelListCache(BeginCompareTime,
                                                            EndCompareTime, softsid,
                                                            channels[i].Platform, Period,
                                                            channels[i].ChannelType,
                                                            Convert.ToInt32(
                                                                channels[i].ChannelValue),
                                                            channels[i].ChannelText,
                                                            isForOut, loginService,
                                                            CacheTimeOption
                                                            .TenMinutes)
                                .OrderBy(p => p.StatDate)
                                .ToList();

                            if (usersCompare.Count != 0)
                            {
                                ListAllForCompare.Add(usersCompare);
                            }
                        }
                    }
                }
            }

            if (ListAll.Count == 0)
            {
                return;
            }

            GetAllLineJson();
            StringBuilder sb = new StringBuilder();
            //传入的tab 序列值
            int tabindex = 0;

            //形成tablehtml
            for (int j = 0; j < ListAll.Count; j++)
            {
                string plat = ((MobileOption)ListAll[j][0].Platform).GetDescription();
                if ((MobileOption)ListAll[j][0].Platform == MobileOption.None)
                {
                    plat = "不区分平台";
                }
                string channel = ListAll[j][0].ChannelName;
                if (string.IsNullOrEmpty(channel))
                {
                    channel = "不区分渠道";
                }
                tabStr.Add(plat + "_" + channel);
                sb.Append(GetTableString(ListAll[j], tabindex));
                tabindex++;
            }
            tableStr = sb.ToString();
        }