Ejemplo n.º 1
0
        private string LoadTeamTiles()
        {
            var    teamGuid  = Request.Params["SiteGUID"].ToString();
            string userAlias = Session["UserName"].ToString();
            // tile data
            JavaScriptSerializer jss = new JavaScriptSerializer();

            // 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);
                ReportRepository         reportRepository    = new ReportRepository(context);

                int                  teamId   = teamService.GetAllTeamSites().First(_ => _.TeamGuid == Guid.Parse(teamGuid)).Id.Value;
                TileServices         tService = new TileServices(repository, tRepository, reportRepository, null, null, null, tileQueryRepository);
                List <TileViewModel> tiles    = tService.GetCustomerizeTilesWithCountByTeamId(teamId, userAlias, true, teamGuid).Select(_ => _.ToTileViewModel()).ToList <TileViewModel>();

                return(jss.Serialize(tiles));
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        private string GetFilter()
        {
            string sitetype = Request["sitetype"];

            string siteGUID = Request["SiteGuid"];

            string searchWords = Request["SearchWords"];


            int tileId = int.Parse(Request["tileId"]);

            //if (tileId == 0)
            //{
            //    TileManager tm = new TileManager();
            //    if (sitetype.ToLower() == "selfservice")
            //    {
            //        tileId = SystemDefinedTile.SelfService_AllBIModels.SystemDefinedTileId;
            //    }
            //    else
            //    {
            //        tileId = SystemDefinedTile.MyReports_AllReports.SystemDefinedTileId;
            //    }
            //}


            string logonUser = Session["UserName"] == null ? "" : Session["UserName"].ToString();

            bool isCurrentSiteAdmin = logonUser == "" ? false : service.GetUserAdminTeams(logonUser).Count() > 0;

            using (MainDBUnitWorkContext context = new MainDBUnitWorkContext())
            {
                IReportRepository         report_repository     = new ReportRepository(context);
                IUserRepository           user_repository       = new UserRepository(context);
                ITeamRepository           team_repository       = new TeamRepository(context);
                ICategoryRepository       category_repository   = new CategoryRepository(context);
                ITagRepository            tag_repository        = new TeamTagRepository(context);
                ITileRepository           tile_repository       = new TileRepository(context);
                ITileQueryLogicRepository tile_query_repository = new TileQueryLogicRepository(context);

                EditReportService sa = new EditReportService(report_repository, user_repository, team_repository, category_repository, tag_repository, tile_repository, tile_query_repository);

                FilterListViewModel filterList = new FilterListViewModel();

                #region query filter data
                int DataCount = 0;
                ICollection <Statistics> ls = null;
                switch (sitetype.ToLower())
                {
                case "teamsite":
                    ls = sa.GetTeamSiteReportsStatistics(tileId, logonUser, siteGUID, isCurrentSiteAdmin);
                    break;

                case "reportcatalog":
                    break;

                //case "myreport":
                //    ls = sa.GetMyReportsStatistics(tileId, logonUser, teamSiteGuidUnderControl);
                //    break;
                //case "selfservice":
                //    ls = sa.GetSelfServiceStatistics(tileId, logonUser, teamSiteGuidUnderControl);
                //    break;
                //case "searchreport":
                //    ls = sa.GetSearchReportsStatistics(logonUser, teamSiteGuidUnderControl, searchWords, out DataCount);
                //    break;
                default:
                    break;
                }
                #endregion

                filterList.DataCount = DataCount;

                #region Get Statistics business moel
                foreach (Statistics l in ls)
                {
                    FilterEntityViewModel filterEty = new FilterEntityViewModel();
                    filterEty.FilterType = l.Name;

                    foreach (AttributeValue attr in l.Values)
                    {
                        Application.MainBoundedContect.ViewModel.Filters.FilterItem item = new Application.MainBoundedContect.ViewModel.Filters.FilterItem();
                        item.Name = attr.Name;
                        if (l.Name == "Owner")
                        {
                            item.Value = attr.GUID.ToString();
                        }
                        else
                        {
                            item.Value = attr.Value.ToString();
                        }
                        item.Count       = attr.Count;
                        item.ParentValue = attr.ParentValue;
                        filterEty.FilterItemList.Add(item);
                    }

                    if (!filterEty.FilterType.Equals("Category"))
                    {
                        filterEty.FilterItemList.OrderByDescending(c => c.Count).ThenBy(n => n.Value);
                    }

                    filterList.FilterList.Add(filterEty);
                }

                JavaScriptSerializer jss = new JavaScriptSerializer();
                #endregion

                return(jss.Serialize(filterList));
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }