コード例 #1
0
ファイル: RapsController.cs プロジェクト: sahvishal/matrix
        public ActionResult Log(RapsUploadListModelFilter filter = null, int pageNumber = 1)
        {
            int totalRecords;

            if (filter != null && filter.Status == 0)
            {
                filter.Status = null;
            }
            if (filter != null && filter.UploadedBy == -1)
            {
                filter.UploadedBy = null;
            }
            var rapsData = _rapsService.GetUploadList(pageNumber, _pageSize, filter, out totalRecords);
            var model    = rapsData == null ? new RapsUploadListModel() : new RapsUploadListModel {
                Collection = rapsData
            };

            model.Filter = filter;
            model.Url    = _mediaRepository.GetRapsUploadMediaFileLocation().Url;
            // Path.GetFileNameWithoutExtension(fileName) + "_FailedRaps.csv"

            var values = RapsUploadStatus.UploadStarted.GetNameValuePairs();
            var status = new List <OrderedPair <long, string> >();

            status.Add(new OrderedPair <long, string>(0, "All"));
            foreach (var source in  values.Where(x => x.FirstValue != (long)RapsUploadStatus.UploadStarted && x.FirstValue != (long)RapsUploadStatus.FileNotFound))
            {
                status.Add(new OrderedPair <long, string>(source.FirstValue, source.SecondValue));
            }
            ViewBag.Status = status;

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

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



            return(View(model));
        }
コード例 #2
0
        public IEnumerable <RapsUploadModel> GetUploadList(int pageNumber, int pageSize, RapsUploadListModelFilter filter, out int totalRecords)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);
                IEnumerable <RapsUploadEntity> entities = (from cu in linqMetaData.RapsUpload where cu.StatusId == (long)RapsUploadStatus.Uploaded select cu).ToList();

                if (filter.IsEmpty())
                {
                    var query = (from cu in linqMetaData.RapsUpload where cu.StatusId != (long)RapsUploadStatus.UploadStarted select cu).OrderByDescending(x => x.UploadTime);

                    totalRecords = query.Count();
                    entities     = query.WithPath(prefetchPath => prefetchPath.Prefetch(e => e.File)).TakePage(pageNumber, pageSize).ToList();
                }
                else
                {
                    var query = (from cu in linqMetaData.RapsUpload
                                 where cu.StatusId != (long)RapsUploadStatus.UploadStarted &&
                                 (filter.FromDate == null || filter.FromDate <= cu.UploadTime.Date) &&
                                 (filter.ToDate == null || filter.ToDate >= cu.UploadTime.Date) &&
                                 (filter.Status == null || (long)filter.Status == cu.StatusId) &&
                                 (filter.Name == null || cu.File.Path.Contains(filter.Name)) &&
                                 (filter.UploadedBy == null || filter.UploadedBy == cu.UploadedBy)
                                 select cu).OrderByDescending(x => x.UploadTime);

                    totalRecords = query.Count();
                    entities     = query.WithPath(prefetchPath => prefetchPath.Prefetch(e => e.File)).TakePage(pageNumber, pageSize).ToList();
                }


                return(AutoMapper.Mapper.Map <IEnumerable <RapsUploadEntity>, IEnumerable <RapsUploadModel> >(entities));
            }
        }
コード例 #3
0
        public IEnumerable <RapsUploadModel> GetUploadList(int pageNumber, int pageSize, RapsUploadListModelFilter filter,
                                                           out int totalRecords)
        {
            var list        = _rapsUploadRepository.GetUploadList(pageNumber, pageSize, filter, out totalRecords).ToArray();
            var uploadByIds = list.Select(c => c.UploadedBy).Distinct().ToArray();

            IEnumerable <OrderedPair <long, string> > uploadedbyAgentNameIdPair = null;

            if (uploadByIds != null && uploadByIds.Any())
            {
                uploadedbyAgentNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(uploadByIds).ToArray();
            }
            foreach (var rapsUploadModel in list)
            {
                if (uploadedbyAgentNameIdPair != null && uploadedbyAgentNameIdPair.Any())
                {
                    rapsUploadModel.UploadedName = uploadedbyAgentNameIdPair.Single(ap => ap.FirstValue == rapsUploadModel.UploadedBy).SecondValue;
                }
            }
            return(list);
        }