Exemple #1
0
        public static ReportWorkloadViewModel Create(IRepositoryFactory repositoryFactory, IQueryRepositoryFactory queryRepositoryFactory, IWorkgroupService workgroupService, string userName, Workgroup workgroup)
        {
            var workgroups = workgroupService.LoadAdminWorkgroups();

            var viewModel = new ReportWorkloadViewModel()
            {
                Workgroups = workgroups,
                Workgroup  = workgroup
            };

            return(viewModel);
        }
Exemple #2
0
        public static ReportPermissionsViewModel Create(IRepositoryFactory repositoryFactory, IWorkgroupService workgroupService)
        {
            var viewModel = new ReportPermissionsViewModel()
            {
                Workgroups = workgroupService.LoadAdminWorkgroups()
            };

            viewModel.Permissions = viewModel.Workgroups.SelectMany(a => a.Permissions);
            viewModel.Users       = viewModel.Permissions.Select(a => a.User).Distinct();

            return(viewModel);
        }
        public static ReportWorkloadViewModel Create(IRepositoryFactory repositoryFactory, IQueryRepositoryFactory queryRepositoryFactory, IWorkgroupService workgroupService, string userName, Workgroup workgroup)
        {
            var workgroups = workgroupService.LoadAdminWorkgroups();

            var viewModel = new ReportWorkloadViewModel()
                                {
                                    Workgroups = workgroups,
                                    Workgroup = workgroup
                                };

            return viewModel;
        }
        public ActionResult PurchaserWorkLoad(DateTime?reportDate)
        {
            reportDate = reportDate ?? DateTime.UtcNow.ToPacificTime();

            var viewModel = new ReportPurchaserWorkLoadViewModel();

            viewModel.Items      = new List <ReportPurchaserWorkLoadItem>();
            viewModel.ReportDate = reportDate;

            var allWorkgroups = _workgroupService.LoadAdminWorkgroups(true).ToList();
            var workgroupIds  = allWorkgroups.Select(x => x.Id).ToArray();

            var users =
                _repositoryFactory.OrderTrackingRepository
                .Queryable.Where(
                    a =>
                    a.DateCreated >= reportDate.Value.Date && a.DateCreated <= reportDate.Value.Date.AddDays(1) &&
                    workgroupIds.Contains(a.Order.Workgroup.Id) && a.Description.Contains("completed"))
                .Select(a => a.User).ToList();
            var distinctUsers = users.Distinct().ToList();

            foreach (var user in distinctUsers)
            {
                var item = new ReportPurchaserWorkLoadItem();
                item.userId         = user.Id;
                item.UserName       = user.FullName;
                item.CompletedCount = users.Count(a => a.Id == user.Id);
                //This will tell me how many orders have been completed by each purchaser.
                viewModel.Items.Add(item);
            }


            var userNamesFromOrderHistory =
                _queryRepositoryFactory.OrderHistoryRepository.Queryable.Where(
                    a => a.StatusId == "PR" && workgroupIds.Contains(a.WorkgroupId)).Select(b => b.Purchaser).ToList();
            var names = userNamesFromOrderHistory.Distinct().ToList();

            foreach (var userName in names)
            {
                var userName1 = userName.Trim();
                var item      = viewModel.Items.SingleOrDefault(a => a.UserName == userName1);
                if (item == null)
                {
                    item              = new ReportPurchaserWorkLoadItem();
                    item.UserName     = userName1;
                    item.PendingCount = userNamesFromOrderHistory.FindAll(a => a.Contains(userName1)).Count;
                    //Find all pending orders in Purchaser state
                    viewModel.Items.Add(item);
                }
                else
                {
                    item.PendingCount = userNamesFromOrderHistory.FindAll(a => a.Contains(userName)).Count;
                    //Find all pending orders in Purchaser state
                }
            }

            return(View(viewModel));
        }
        public static ReportProcessingTimeViewModel Create(IWorkgroupService workgroupService, Workgroup workgroup, bool onlyShowReRouted)
        {
            var workgroups = workgroupService.LoadAdminWorkgroups();

            var viewModel = new ReportProcessingTimeViewModel()
            {
                Workgroups       = workgroups,
                Workgroup        = workgroup,
                OnlyShowReRouted = onlyShowReRouted,
                Columns          = new List <ReportProcessingColumns>()
            };

            return(viewModel);
        }
Exemple #6
0
        public static ReportPermissionsViewModel Create(IRepositoryFactory repositoryFactory, IWorkgroupService workgroupService, bool hideInherited = false)
        {
            var viewModel = new ReportPermissionsViewModel()
            {
                Workgroups = workgroupService.LoadAdminWorkgroups()
            };

            viewModel.Permissions = viewModel.Workgroups.SelectMany(a => a.Permissions);

            if (hideInherited)
            {
                viewModel.Users       = viewModel.Permissions.Where(w => !w.IsAdmin).Select(a => a.User).Distinct();
                viewModel.Permissions = viewModel.Permissions.Where(a => !a.IsAdmin);
            }
            else
            {
                viewModel.Users = viewModel.Permissions.Select(a => a.User).Distinct();
            }

            viewModel.HideInherited = hideInherited;

            return(viewModel);
        }
        public static ReportProcessingTimeViewModel Create(IWorkgroupService workgroupService, Workgroup workgroup, bool onlyShowReRouted)
        {
            var workgroups = workgroupService.LoadAdminWorkgroups();

            var viewModel = new ReportProcessingTimeViewModel()
                                {
                                    Workgroups = workgroups,
                                    Workgroup = workgroup,
                                    OnlyShowReRouted = onlyShowReRouted,
                                    Columns = new List<ReportProcessingColumns>()
                                };

            return viewModel;
        }