public ICollection <Statistics> GetTeamSiteReportsStatistics(Int32 tileId, String userAlias, String teamSiteGuid, Boolean isCurrentSiteAdmin) { bool hasAdminSite = isCurrentSiteAdmin; TileServices tService = new TileServices(_tileRepository, _teamRepository, _reportRepository, _userRepository, _tagRepository, _categoryRepository, _tileQueryRepository); AppTile at = tService.GetTileById(tileId); ParameterProvider pp = new ParameterProvider(); //if (userAlias != "") //{ //pp.AddParameter(ContextVariable.CurrentUser.ToString(), userAlias); //} pp.AddParameter(ContextVariable.CurrentTeamSiteGuid.ToString(), new Guid(teamSiteGuid)); //pp.AddParameter(ContextVariable.CurrentUserGroup.ToString(), appUserGroupList); //if (hasAdminSite) //{ pp.AddParameter(ContextVariable.TeamSiteGuidUnderControl.ToString(), new List <Guid>() { new Guid(teamSiteGuid) }); //} Logic logic = at.GetCombinedLogic(hasAdminSite, tileId).And((new TeamSiteGUID()).Equal(Guid.Parse(teamSiteGuid))); var reports = _reportRepository.GetReportByLogic(logic, pp).ToArray().Select(_ => _.ToAppReport()).ToList(); foreach (var report in reports) { foreach (var cat in report.Categories) { if (cat.ParentId != null) { cat.ParentCategory = _categoryRepository.Get(cat.ParentId.GetValueOrDefault()).ToAppCategory(); //cat.Reports.Add(report); } } } return(GetStatistics(reports)); }
private List <AppReport> GetReportsByTeam(Guid teamSiteGuid, Int32 tileId, ReportFilter filter, Boolean isCurrentUserTeamSiteAdmin, String userAlias, Int32 pageNum, Int32 pageSize, SortField sortField, SortOrder sortOrder) { #region Get the logic TileServices tService = new TileServices(_tileRepository, _teamRepository, _reportRepository, null, null, null, _tileQueryRepository); AppTile ap = null; bool hasAdminTeamSite = isCurrentUserTeamSiteAdmin; ap = tService.GetTileById(tileId); #endregion #region Combine the logic var topLevelLogic = (new TeamSiteGUID()).Equal(teamSiteGuid).And(ap.GetCombinedLogic(hasAdminTeamSite, tileId)); var logic = GenerateLogicByFilter(filter); if (logic != null) { topLevelLogic.AddElement(logic); } #endregion #region Compose the logic parameter ParameterProvider pp = new ParameterProvider(); //if (userAlias != "") //{ //pp.AddParameter(ContextVariable.CurrentUser.ToString(), userAlias); //} pp.AddParameter(ContextVariable.CurrentTeamSiteGuid.ToString(), teamSiteGuid); //if (isCurrentUserTeamSiteAdmin) //{ pp.AddParameter(ContextVariable.TeamSiteGuidUnderControl.ToString(), (new List <Guid>() { teamSiteGuid })); //} #endregion #region generate the result return(GetReportsByLogic(topLevelLogic, sortField, sortOrder, pp, pageNum, pageSize).ToArray().Select(_ => _.ToAppReport()).ToList()); #endregion }
private void UpdateTileInformation() { // Update team site dashboard settings var tileData = Request.Params["TilesData"]; var teamGuid = Request.Params["SiteGUID"].ToString(); // tile data JavaScriptSerializer jss = new JavaScriptSerializer(); List <TileViewModel> paraTileList = jss.Deserialize <List <TileViewModel> >(tileData); // Save the tile data into our database using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { TileRepository repository = new TileRepository(context); // Get the team id by its team guid value TeamRepository tRepository = new TeamRepository(context); TeamAppService teamService = new TeamAppService(tRepository); TileQueryLogicRepository tileQueryRepository = new TileQueryLogicRepository(context); int teamId = teamService.GetAllTeamSites().First(_ => _.TeamGuid == Guid.Parse(teamGuid)).Id.Value; //validate the data if (paraTileList.Count() > 24) { throw new ArgumentException("the count of the tile is more than 24"); } foreach (var item in paraTileList) { if (item.coordinateX < 0 || item.coordinateX > 7) { throw new ArgumentException("coordinateX must be between 0 and 7"); } if (item.coordinateY < 0 || item.coordinateY > 2) { throw new ArgumentException("coordinateY must be between 0 and 2"); } if (item.demensionX < 1 || item.demensionX > 8) { throw new ArgumentException("demensionX must be between 1 and 8"); } if (item.demensionY < 1 || item.demensionY > 3) { throw new ArgumentException("demensionY must be between 1 and 3"); } } TileServices tService = new TileServices(repository, null, null, null, null, null, tileQueryRepository); List <AppTile> tiles = new List <AppTile>(); List <AppTile> orignalTiles = tService.GetTilesByTeamId(teamId).ToList(); //tiles will be remove foreach (var item in orignalTiles) { if (!paraTileList.Any(_ => _.id == item.Id)) { if (item.logicType == LogicType.AllReports) { continue; } AppTile appTile = tService.GetTileById(item.Id.Value); appTile.Status = ChangeStatus.Delete; tiles.Add(appTile); } } foreach (var para in paraTileList) { //tiles will be Added if (para.id < 0) { AppTile appTile = new AppTeamSiteCustomizedTile(); appTile.TileType = TileType.TeamSite; appTile.Status = ChangeStatus.Add; appTile.Title = para.title; appTile.Top = para.coordinateY; appTile.Left = para.coordinateX; appTile.Width = para.demensionX; appTile.Height = para.demensionY; appTile.BackgroundColor = para.backgroundColor; appTile.Icon = para.icon; appTile.BackgroundImage = para.backgroundImage; appTile.ImageOverlayColor = para.overlayColor; appTile.ReportCountStyle = para.shownCount; appTile.OwnerTeamSiteId = teamId; appTile.IsCustomized = true; appTile.logicType = (LogicType)Enum.Parse(typeof(LogicType), para.LogicType); SetAppTitleLogic(para.LogicString, appTile); tiles.Add(appTile); } //tiles will be Updated if (para.id > 0) { AppTile appTile = tService.GetTileById(para.id); if (appTile == null) { continue; } appTile.Status = ChangeStatus.Change; appTile.Top = para.coordinateY; appTile.Left = para.coordinateX; appTile.Width = para.demensionX; appTile.Height = para.demensionY; appTile.BackgroundColor = para.backgroundColor; appTile.Icon = para.icon; appTile.BackgroundImage = para.backgroundImage; appTile.ImageOverlayColor = para.overlayColor; appTile.ReportCountStyle = para.shownCount; appTile.IsCustomized = true; if (appTile.logicType != LogicType.AllReports) { appTile.Title = para.title; appTile.logicType = (LogicType)Enum.Parse(typeof(LogicType), para.LogicType); SetAppTitleLogic(para.LogicString, appTile); } tiles.Add(appTile); } } tService.ModifyTile(tiles); } }
private string GetReports() { string userName = Session["UserName"] == null ? "" : Session["UserName"].ToString(); string output; string siteType = Request["siteType"]; string teamGuid = Request["SiteGuid"]; JavaScriptSerializer jss = new JavaScriptSerializer(); var paramDes = jss.Deserialize <WebApplication1.Models.QueryParameterViewModel>(Request["queryParam"]); int tileId = int.Parse(paramDes.TileId); // Get the reports from the reports list using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { ReportRepository rep = new ReportRepository(context); TileRepository tileRep = new TileRepository(context); TileQueryLogicRepository tileQuery = new TileQueryLogicRepository(context); TileServices tService = new TileServices(tileRep, null, null, null, null, null, tileQuery); var tile = tService.GetTileById(tileId); EditReportService editReport = new EditReportService(rep, null, null, null, null, tileRep, tileQuery); #region Get ReportFilter ReportFilter filer = new ReportFilter(); foreach (WebApplication1.Models.FilterModel vm in paramDes.FilterEntityList) { switch (vm.FilterType) { case "Tag": filer.TagsIdCollection = (from fl in vm.FilterItemList select int.Parse(fl.Value)).ToList(); break; case "Owner": filer.OwnerIdCollection = (from fl in vm.FilterItemList select fl.Value).ToList(); break; case "Sub Category": filer.SubCategoryIdCollection = (from fl in vm.FilterItemList select int.Parse(fl.Value)).ToList(); break; default: break; } } #endregion // TO-DO: Team admin is set to true var reports = editReport.GetReportsByTeamWithReportsRequire(teamGuid, tileId, filer, true, userName, paramDes.CurrentPage, paramDes.PageSize, SortField.ReportTitle, (paramDes.SortAscending ? SortOrder.ASC : SortOrder.DESC)).ToArray(); ReportListModel rptList = GetReportList(reports, Convert.ToInt32(paramDes.TileId)); output = jss.Serialize(rptList); return(output); } }