Example #1
0
        public DWHDashboard.ProfileManagement.Core.Model.User GetUser()
        {
            var user = new DWHDashboard.ProfileManagement.Core.Model.User();

            user.Id          = Id.ToString();
            user.FullName    = FullName;
            user.PhoneNumber = PhoneNumber;
            return(user);
        }
Example #2
0
        public async Task <List <Workbook> > GetAllViewsByOrg(AuthTicket ticket, string orgId, User user)
        {
            List <string> orgViewTabids = new List <string>();

            if (!string.IsNullOrWhiteSpace(orgId))
            {
                Guid id = new Guid(orgId);
                if (!id.IsNullOrEmpty())
                {
                    var orgViews = _orgRepository.GetOrgViews(id, true).ToList();
                    orgViewTabids = orgViews.Select(x => x.TableauId).ToList();
                }
            }

            List <Workbook> workbooksList = new List <Workbook>();

            var workbooks = await GetAllWorkbooks();

            foreach (var w in workbooks)
            {
                var views = await GetAllWorkbookViews(w.Id);

                foreach (var v in views)
                {
                    v.AuthTicket     = ticket ?? new AuthTicket("-1");
                    v.InteractiveUrl = v.AuthTicket.GetViewBasePath(v.AuthSession.SiteName, v.ContentUrl.Replace("sheets/", ""));
                }
                w.AddViews(views);

                if (w.Views.Count > 0)
                {
                    workbooksList.Add(w);
                }
            }

            //check if admin showAll

            if (user.IsTableau || user.UserType == UserType.Admin)
            {
                return(workbooksList);
            }

            //filter by org access

            List <Workbook> filteredWorkbooksList = new List <Workbook>();

            if (orgViewTabids.Count > 0)
            {
                foreach (var w in workbooksList)
                {
                    var views = w.Views;
                    w.Views = views.Where(x => orgViewTabids.Contains(x.Id) || (x.IsChart || x.IsPublic)).ToList();
                    if (w.Views.Count > 0)
                    {
                        filteredWorkbooksList.Add(w);
                    }
                }
            }
            else
            {
                foreach (var w in workbooksList)
                {
                    var views = w.Views;
                    w.Views = views.Where(x => x.IsChart || x.IsPublic).ToList();
                    if (w.Views.Count > 0)
                    {
                        filteredWorkbooksList.Add(w);
                    }
                }
            }
            return(filteredWorkbooksList);
        }