예제 #1
0
        private Result get_page(HttpContext context)
        {
            DataTablesRequest param = new DataTablesRequest(context.Request);
            int    region           = Convert.ToInt32(context.Request["region"]);
            int    restype          = Convert.ToInt32(context.Request["restype"]);
            int    projectsource    = Convert.ToInt32(context.Request["projectsource"]);
            string positionid       = context.Request["position"];
            string positionname     = context.Request["positionname"];
            string pagename         = context.Request["pagename"];
            string pagetype         = context.Server.UrlDecode(context.Request["pagetype"]);
            int    downtype         = Convert.ToInt32(context.Request["downtype"]);
            int    checkistag       = Convert.ToInt32(context.Request["checkistag"]);
            int    pagesize         = param.iDisplayLength;
            int    pageIndex        = (param.iDisplayStart + 1) / param.iDisplayLength + 1;
            int    recordcount      = 0;

            B_BaseTool_DataAccess basetool = new B_BaseTool_DataAccess();
            int softid2 = basetool.getSoftid2byProjectsource(projectsource, region);

            var list = B_BaseDownPositionService.Instance.GetB_DownPositionListByCache((ProjectSourceTypeOptions)region, downtype, checkistag,
                                                                                       restype, projectsource, positionid,
                                                                                       positionname, pagename, pagetype, (pageIndex - 1) * pagesize,
                                                                                       pagesize, softid2, out recordcount);


            JQueryDataTableData dt = new JQueryDataTableData();

            dt.sEcho         = param.sEcho;
            dt.iTotalRecords = dt.iTotalDisplayRecords = recordcount;
            dt.aaData        = GetDataStrList(list);
            return(Result.GetSuccessedResult(dt, false));
        }
예제 #2
0
        private Result addPosition(HttpContext context)
        {
            int    region        = Convert.ToInt32(context.Request["region"]);
            int    restype       = Convert.ToInt32(context.Request["restype"]);
            int    projectsource = Convert.ToInt32(context.Request["projectsource"]);
            int    positionid    = Convert.ToInt32(context.Request["position"]);
            string positionname  = context.Request["positionname"];
            string tag           = context.Request["checkistag"];
            int    downtype      = Convert.ToInt32(context.Request["downtype"]);
            string pagename      = context.Request["pagename"];
            string pagetype      = context.Server.UrlDecode(context.Request["pagetype"]);

            B_BaseTool_DataAccess basedata = new B_BaseTool_DataAccess();
            int softid2 = basedata.getSoftid2byProjectsource(projectsource, region);
            int flag2   = B_BaseDownPositionService.AddPosition2MySql(
                new B_DownPositionEntity
            {
                ByTag4MySql       = tag == "1" ? 1 : 0,
                Name              = positionname,
                PageName          = pagename,
                PageType          = pagetype,
                Position          = positionid,
                ProjectSource     = projectsource,
                ProjectSourceType = region,
                ResType           = restype,
                DownType          = downtype,
                SoftId            = softid2
            });

            if ((flag2) <= 0)
            {
                return(Result.GetFailedResult(string.Format("添加到{0}失败", "新数据库")));
            }
            return(Result.GetSuccessedResult("", "添加成功", true));
        }
        /// <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>");
            }
        }
예제 #4
0
        protected override List <List <T> > GetData <T>(HttpContext context, bool flag = false)
        {
            DateTime restime           = Convert.ToDateTime(context.Request["begintime"]);
            DateTime comparebeforetime = restime.AddDays(-1);
            int      softs             = Convert.ToInt32(context.Request["softs"]);
            int      platform          = Convert.ToInt32(context.Request["plat"]);
            int      restype           = Convert.ToInt32(context.Request["restype"]);
            int      period            = Convert.ToInt32(context.Request["period"]);
            int      pcid = Convert.ToInt32(context.Request["pcid"]);
            int      cid  = Convert.ToInt32(context.Request["cid"]);

            int downtype = Convert.ToInt32(context.Request["downtype"]);

            if (3 == period)
            {
                comparebeforetime = B_BaseToolService.GetWeekUpOfDate(restime, DayOfWeek.Sunday, -1);
                restime           = B_BaseToolService.GetWeekUpOfDate(restime, DayOfWeek.Sunday, 0);
            }
            if (12 == period)
            {
                comparebeforetime = restime.AddDays(-1 * (restime.Day)).AddMonths(-1);
                restime           = restime.AddDays(-1 * (restime.Day));
            }
            List <List <D_StatDownRank_SUM> > lists = new List <List <D_StatDownRank_SUM> >();



            List <D_StatDownRank_SUM> resultbefore = D_StatDownRank_Service.Instance.GetD_StatDownRankByClassByCache(restype, softs, platform,
                                                                                                                     comparebeforetime, period, pcid, cid, downtype);

            List <D_StatDownRank_SUM> resultrestime = D_StatDownRank_Service.Instance.GetD_StatDownRankByClassByCache(restype, softs, platform,
                                                                                                                      restime, period, pcid, cid, downtype);

            var resulttemp = (from itrestime in resultrestime
                              join itbefore in resultbefore on itrestime.ResIdentifier equals itbefore.ResIdentifier into os
                              from t in os.DefaultIfEmpty()
                              select new D_StatDownRank_SUM
            {
                StatDate = itrestime.StatDate,
                SoftID = itrestime.SoftID,
                Platform = itrestime.Platform,
                ResType = itrestime.ResType,
                DownCount = itrestime.DownCount,
                ResIdentifier = itrestime.ResIdentifier,
                Rank = itrestime.Rank,
                LastRank = t == null?"--":t.Rank.ToString()
            }).OrderBy(p => p.Rank).ToList();

            var reslst = resulttemp.Select(p => p.ResIdentifier).ToList();

            int projectsourcetype       = new B_BaseTool_DataAccess().GetProjectSourceTypeBySoftId2(softs);
            List <B_ResInfo> lstresinfo = new B_BaseToolService().GetResInfo(restype, projectsourcetype, reslst);
            var result = (from item in resulttemp
                          join itemresinfo in lstresinfo on item.ResIdentifier equals itemresinfo.ResIdentifier into os
                          from t in os.DefaultIfEmpty()
                          select new D_StatDownRank_SUM
            {
                StatDate = item.StatDate,
                SoftID = item.SoftID,
                Platform = item.Platform,
                ResType = item.ResType,
                ResIdentifier = item.ResIdentifier,
                Rank = item.Rank,
                DownCount = item.DownCount,
                LastRank = item.LastRank,
                ResName = t == null ? "" : t.ResName
            }).ToList();

            if (result.Count == 0)
            {
                return(new List <List <D_StatDownRank_SUM> >() as List <List <T> >);
            }
            lists.Add(result);

            return(lists as List <List <T> >);
        }
예제 #5
0
        protected override List <List <T> > GetData <T>(HttpContext context, bool isfortable = false)
        {
            DateTime begintime     = Convert.ToDateTime(context.Request["begintime"]);
            DateTime endtime       = Convert.ToDateTime(context.Request["endtime"]);
            int      softs         = Convert.ToInt32(context.Request["softs"]);
            int      platform      = Convert.ToInt32(context.Request["plat"]);
            int      restype       = Convert.ToInt32(context.Request["restype"]);
            int      version       = Convert.ToInt32(context.Request["version"]);
            int      areaid        = int.Parse(context.Request["areaid"]);
            int      projectsource = Convert.ToInt32(context.Request["projectsource"]);
            int      areatype      = Convert.ToInt32(context.Request["areatype"]);
            int      resselecttype = Convert.ToInt32(context.Request["resselecttype"]);
            string   rescontext    = context.Request["rescontext"];


            isbrowsecount = 0;
            if (projectsource == (int)ProjectOption.OP_REDIRECT_STAT)
            {
                isbrowsecount = 1;
            }

            List <List <D_StatDownPositionDistribution> > lists = new List <List <D_StatDownPositionDistribution> >();

            List <D_StatDownPositionDistribution> result;

            List <int> lstresid;

            if (resselecttype != 3)
            {
                lstresid = new List <int>()
                {
                    int.Parse(rescontext)
                };
            }
            else
            {
                List <B_ResInfo> resInfos = new B_BaseTool_DataAccess().GetResInfo(rescontext, restype, areatype);
                lstresid = resInfos.Select(p => p.ResId).ToList();
            }

            result = D_StatDownPositionDistribution_Service.Instance.GetD_StatDownPositionByResIDCacheDetailCache(restype, softs,
                                                                                                                  platform, projectsource,
                                                                                                                  version, begintime, endtime,
                                                                                                                  areatype, areaid, lstresid);

            var result2 =
                B_BaseDownPositionService.Instance.GetB_DownPositionListByCache((ProjectSourceTypeOptions)areatype,
                                                                                restype, projectsource);

            var res = (from r1 in result
                       join r2 in result2 on new { Position = r1.PositionId }
                       equals new { Position = r2.Position }
                       into tt
                       from t in tt.DefaultIfEmpty()
                       select new D_StatDownPositionDistribution
            {
                PositionId = r1.PositionId,
                PositionName = t != null ? t.Name : "",
                PageName = t != null ? t.PageName : "",
                DownCount = r1.DownCount,
                BrowseCount = r1.BrowseCount
            }).ToList();


            if (res.Count != 0)
            {
                lists.Add(res);
            }

            return(lists as List <List <T> >);
        }
        protected override List <List <T> > GetData <T>(System.Web.HttpContext context, bool flag = false)
        {
            supdetaileqchart = false;

            DateTime   begintime  = Convert.ToDateTime(context.Request["begintime"]);
            DateTime   endtime    = Convert.ToDateTime(context.Request["endtime"]);
            int        sourceid   = Convert.ToInt32(context.Request["projectsource"]);
            string     versions   = context.Request["version"];
            List <int> lstversion = versions.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(p => Convert.ToInt32(p)).ToList();
            int        softid     = Convert.ToInt32(context.Request["softid"]);
            int        platform   = Convert.ToInt32(context.Request["platform"]);
            int        restype    = Convert.ToInt32(context.Request["restype"]);
            int        resid      = Convert.ToInt32(context.Request["resid"]);
            int        areaid     = Convert.ToInt32(context.Request["areaid"]);
            string     position   = context.Request["position"] == "" ? "0" : context.Request["position"];

            position = Regex.Replace(position, "[\r\n ]", "");
            string[]   sts        = position.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            List <int> lstpositon = GetPositionList(sts);

            //下面三个字段主要是为了获取明细位置提供参数
            resselecttype = context.Request["resselecttype"];
            string resname = context.Request["resname"];

            areatype = Convert.ToInt32(context.Request["areatype"]);


            if (sourceid == -1 || sourceid == 2)
            {
                showdetailposition = 0;
            }
            else
            {
                showdetailposition = 1;
            }
            var        list = new List <List <ResourceDownLoad> >();
            List <int> lstresid;

            if (resid > 0)
            {
                lstresid = new List <int>()
                {
                    resid
                };
                rescontext = resid + "";
            }
            else
            {
                List <B_ResInfo> resInfos = new B_BaseTool_DataAccess().GetResInfo(resname, restype, areatype);
                lstresid   = resInfos.Select(p => p.ResId).ToList();
                rescontext = resname;
            }

            List <List <D_StatDownCountsBySoft_SUM> > lists = new List <List <D_StatDownCountsBySoft_SUM> >();

            foreach (int version in lstversion)
            {
                var result = D_StatDownCountSum_Service.Instance.GetD_StatDownCountSumByResIDCache(softid, platform, lstresid, restype,
                                                                                                   begintime, endtime, lstpositon, version,
                                                                                                   sourceid, areaid, areatype);
                if (result.Count != 0)
                {
                    lists.Add(result);
                }
                LogHelper.WriteInfo("result.count:" + result.Count);
            }

            return(lists as List <List <T> >);
        }