示例#1
0
        public string GetDivisions()
        {
            JavaScriptSerializer jss = new JavaScriptSerializer();

            using (MainDBUnitWorkContext context = new MainDBUnitWorkContext())
            {
                IDivisionRepository divisionRepository = new DivisionRepository(context);

                AppDivisionSegmentsService service   = new AppDivisionSegmentsService(divisionRepository);
                IEnumerable <AppDivision>  divisions = service.GetAllDivisions();
                AppDivisions results = new AppDivisions()
                {
                    title = "所有分类", tooltip = "divisions", key = "root", isFolder = true, children = divisions
                };
                var str = jss.Serialize(results);
                return(jss.Serialize(results));
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (MainDBUnitWorkContext context = new MainDBUnitWorkContext())
            {
                up = new UserRepository(context);

                service = new UserService(up);

                SegmentRepository  segRe = new SegmentRepository(context);
                DivisionRepository dvRe  = new DivisionRepository(context);
                TeamRepository     tRe   = new TeamRepository(context);

                AppDivisionSegmentsService appService = new AppDivisionSegmentsService(tRe, segRe, dvRe);

                if (Request["requestType"] == "getdivisions")
                {
                    var divisions = appService.GetAllDivisions().ToList <AppDivision>();
                    Response.Write(jss.Serialize(divisions));
                }
                if (Request["requestType"] == "getdivisionbyid")
                {
                    int divisionId = int.Parse(Request["divisionid"]);

                    var division = appService.GetAllDivisions().FirstOrDefault(_ => _.Id == divisionId);
                    Response.Write(jss.Serialize(division));
                }

                if (Request["requestType"] == "getsegmentandteams")
                {
                    int divisionId = Int16.Parse(Request["divisionid"]);
                    var segments   = appService.GetSegmentAndTeamsInDivsion(divisionId);
                    List <SegmentTeamModel> segmentTeamSites    = new List <SegmentTeamModel>();
                    List <SegmentTeamModel> subSegmentTeamSites = new List <SegmentTeamModel>();

                    foreach (var segment in segments)
                    {
                        var teamSites = new List <TeamSiteModel>();
                        foreach (var t in segment.Teamsites)
                        {
                            teamSites.Add(new TeamSiteModel()
                            {
                                TeamId = t.Id, TeamGuid = t.TeamGuid.ToString(), TeamName = t.TeamName, TeamLogo = t.TeamLogo
                            });
                        }

                        foreach (var t in segment.ChildSegements)
                        {
                            var teamSites2 = new List <TeamSiteModel>();
                            foreach (var t2 in t.Teamsites)
                            {
                                teamSites2.Add(new TeamSiteModel()
                                {
                                    TeamId = t2.Id, TeamGuid = t2.TeamGuid.ToString(), TeamName = t2.TeamName, TeamLogo = t2.TeamLogo
                                });
                            }


                            subSegmentTeamSites.Add(new SegmentTeamModel()
                            {
                                SegmentName = t.Name,
                                SegmentId   = t.Id,
                                TeamSites   = teamSites2
                            });
                        }
                        segmentTeamSites.Add(new SegmentTeamModel()
                        {
                            SegmentId     = segment.Id,
                            SegmentName   = segment.Name,
                            TeamSites     = teamSites,
                            ChildSegments = subSegmentTeamSites
                        });
                    }

                    string test = jss.Serialize(segmentTeamSites);
                    Response.Write(jss.Serialize(segmentTeamSites));
                }

                if (Request["requestType"] == "searchteams")
                {
                    string teamname = Request["teamname"].ToString();
                    var    tem      = jss.Serialize(appService.GetTeamsWithTitle(teamname));
                    Response.Write(tem);
                }

                if (Request.Params["queryType"] == "getadmintilereport")
                {
                    // get all the report
                    Response.Write(GetAdminReportFromCurrentTeamSite());
                }
                if (Request.Params["queryType"] == "gettilefilterlist")
                {
                    string userName = Session["UserName"].ToString();
                    string teamGuid = Request["SiteGUID"];
                    bool   isAdmin  = Request["IsAdmin"] == "1" ? true : false;

                    Response.Write(GetAdminTileFilterInfo(userName, teamGuid, isAdmin));
                }
                if (Request.Params["queryType"] == "GetTempTileReportCount")
                {
                    string userName = Session["UserName"] == null ? "" : Session["UserName"].ToString();
                    string teamGuid = Request["SiteGUID"];

                    Response.Write(GetTempTileReportCount(teamGuid, userName));
                }

                if (Request["queryType"] == "reportsList")
                {
                    Response.Write(GetReports());
                }

                if (Request["queryType"] == "reportDetail")
                {
                    Response.Write(GetReportDetal());
                }
                else if (Request["queryType"] == "reportfilter")
                {
                    Response.Write(GetFilter());
                }
            }
        }