Exemplo n.º 1
0
        private ActivityLogListModel GetRecords(ActivityLogListFilter filter, int pageNumber)
        {
            int totalCount = 0;
            var model      = new ActivityLogListModel();

            try
            {
                filter.EndDate = filter.EndDate.AddHours(23).AddMinutes(59);
                model          = _activityLogViewService.GetList(filter, pageNumber, _settings.DefaultPageSizeForReports,
                                                                 out totalCount);
            }
            catch (Exception e)
            {
                _logger.Error(e);
                model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("Some Error Occured");
            }

            model.PagingModel = new PagingModel(pageNumber, _settings.DefaultPageSizeForReports, totalCount,
                                                p =>
                                                Server.UrlDecode(Url.Action("Index",
                                                                            new
            {
                StartDate  = filter.StartDate.Date,
                EndDate    = filter.EndDate.Date,
                pageNumber = p,
                filter.AccessedBy,
                filter.CustomerName,
                filter.AccessedByName,
                filter.CustomerId
            })));

            return(model);
        }
Exemplo n.º 2
0
        //
        // GET: /Activity/

        public virtual ActionResult Index(ActivityLogListFilter filter = null, int pageNumber = 1)
        {
            if (filter == null)
            {
                filter = new ActivityLogListFilter
                {
                    StartDate = DateTime.Today.AddDays(-1),
                    EndDate   = DateTime.Today
                };
            }
            else
            {
                if (filter.StartDate == DateTime.MinValue)
                {
                    filter.StartDate = DateTime.Today.AddDays(-1);
                    filter.EndDate   = DateTime.Today;
                }
            }

            var model = GetRecords(filter, pageNumber);

            return(View(model));
        }
Exemplo n.º 3
0
        public virtual ActionResult List(ActivityLogListFilter filter, int pageNumber = 1)
        {
            var model = GetRecords(filter, pageNumber);

            return(PartialView(model));
        }
Exemplo n.º 4
0
        public ActivityLogListModel GetList(ActivityLogListFilter filter, int pageNumber, int pageSize, out int total)
        {
            Expression <Func <ActivityLog, bool> > query = x => x.Timestamp >= filter.StartDate && x.Timestamp <= filter.EndDate;

            if (filter.AccessType != Core.Audit.Enum.Type.All)
            {
                query = x => x.Timestamp >= filter.StartDate && x.Timestamp <= filter.EndDate && x.Action == filter.AccessType.ToString();
            }

            if (filter.AccessedBy > 0)
            {
                if (filter.AccessType != Core.Audit.Enum.Type.All)
                {
                    query = x =>
                            x.Timestamp >= filter.StartDate && x.Timestamp <= filter.EndDate &&
                            x.Action == filter.AccessType.ToString() &&
                            x.AccessById == filter.AccessedBy;
                }
                else
                {
                    query =
                        x =>
                        x.Timestamp >= filter.StartDate && x.Timestamp <= filter.EndDate &&
                        x.AccessById == filter.AccessedBy;
                }
            }

            if (filter.CustomerId > 0)
            {
                if (filter.AccessedBy > 0)
                {
                    if (filter.AccessType != Core.Audit.Enum.Type.All)
                    {
                        query = x =>
                                x.Timestamp >= filter.StartDate && x.Timestamp <= filter.EndDate &&
                                x.Action == filter.AccessType.ToString() &&
                                x.AccessById == filter.AccessedBy &&
                                x.CustomerId == filter.CustomerId;
                    }
                    else
                    {
                        query =
                            x =>
                            x.Timestamp >= filter.StartDate && x.Timestamp <= filter.EndDate &&
                            x.AccessById == filter.AccessedBy &&
                            x.CustomerId == filter.CustomerId;
                    }
                }
                else
                {
                    if (filter.AccessType != Core.Audit.Enum.Type.All)
                    {
                        query = x =>
                                x.Timestamp >= filter.StartDate && x.Timestamp <= filter.EndDate &&
                                x.Action == filter.AccessType.ToString() &&
                                x.CustomerId == filter.CustomerId;
                    }
                    else
                    {
                        query =
                            x =>
                            x.Timestamp >= filter.StartDate && x.Timestamp <= filter.EndDate &&
                            x.CustomerId == filter.CustomerId;
                    }
                }
            }

            var result = _repositoryActivityLog.Find(query, pageNumber, pageSize, out total).ToList();

            return(new ActivityLogListModel {
                Filter = filter, Collection = result.Select(x => _activityLogFactory.CreateViewModel(x)).ToList()
            });
        }