Exemplo n.º 1
0
        //
        // GET: /Operations/Download/
        public ActionResult Index(ExportableReportsQueueFilter filter, int pageNumber = 1)
        {
            int totalRecords = 0;

            filter.RequestedBy = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId;

            var model = _exportableReportsQueueService.GetExportableReportQueue(pageNumber, _pageSize, filter, out totalRecords);

            if (model == null)
            {
                model = new ExportableReportsQueueListModel();
            }

            model.Filter = filter;


            var currentAction          = ControllerContext.RouteData.Values["action"].ToString();
            Func <int, string> urlFunc = pn => Url.Action(currentAction, new
            {
                pageNumber = pn,
                filter.ReportId,
                filter.FromDate,
                filter.ToDate,
                filter.RequestedBy
            });

            model.PagingModel = new PagingModel(pageNumber, _pageSize, totalRecords, urlFunc);

            return(View(model));
        }
        public ExportableReportsQueueListModel Create(IEnumerable <ExportableReportsQueue> exportableReports, MediaLocation mediaLocation, IEnumerable <File> files)
        {
            var model = new ExportableReportsQueueListModel();
            var list  = new List <ExportableReportsQueueViewModel>();

            foreach (var exportableReportQueue in exportableReports)
            {
                var file      = files.SingleOrDefault(f => f.Id == exportableReportQueue.FileId);
                var viewModel = new ExportableReportsQueueViewModel()
                {
                    Name          = ((ExportableReportType)exportableReportQueue.ReportId).GetDescription(),
                    Status        = ((ExportableReportStatus)exportableReportQueue.StatusId).GetDescription(),
                    RequestedDate = exportableReportQueue.RequestedOn,
                    DownloadUrl   = file != null ? mediaLocation.Url + file.Path : string.Empty
                };
                list.Add(viewModel);
            }

            model.Collection = list;
            return(model);
        }