Exemple #1
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();
        }
Exemple #2
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();
        }