Exemplo n.º 1
0
        public int GetSummaryQueueCount(QueueType queueType, QueueQuery queueQuery)
        {
            switch (queueType)
            {
            case QueueType.Incident:
                return(IncidentSummaries(queueQuery).Count());

            case QueueType.Arrest:
                return(ArrestSummaries(queueQuery).Count());

            case QueueType.FieldInterview:
                return(FieldInterviewSummaries(queueQuery).Count());

            case QueueType.Case:
                return(CaseSummmaries(queueQuery).Count());

            case QueueType.OtherEvent:
                return(OtherEventSummaries(queueQuery).Count());

            case QueueType.Citation:
                return(CitationSummaries(queueQuery).Count());

            case QueueType.CallForService:
                return(CallForServiceSummaries(queueQuery).Count());
            }
            return(0);
        }
Exemplo n.º 2
0
        public ICollection <IncidentSummaryQueueItem> GetIncidentSummaryQueueItems(QueueQuery queueQuery)
        {
            var summaries = IncidentSummaries(queueQuery);

            if (queueQuery.QueueSort != null)
            {
                try
                {
                    var orderBy = QueueSpecifications.GetOrderBy <IncidentSummary>(queueQuery.QueueSort);
                    summaries = (orderBy != null) ? summaries.OrderBy(orderBy) : summaries.OrderBy(s => s.Number);
                }
                catch (Exception e)
                {
                    Log.Error(string.Format("Failed to apply queue sorting for {0}", queueQuery.QueueType), e);

                    summaries = summaries.OrderBy(s => s.Number); // ensure that a filtering is applying in order for skip take to work
                }
            }
            else
            {
                summaries = summaries.OrderBy(s => s.Number);
            }

            var summaryQueueItems = summaries.Skip(queueQuery.Skip).Take(queueQuery.Take).ToList().AsListOf <IncidentSummaryQueueItem>();

            return(summaryQueueItems);
        }
Exemplo n.º 3
0
        public static DateTime[] GetDateRangeByQueueField(QueueQuery queueQuery, string queueFieldName)
        {
            DateTime[] dateRange = new DateTime[0];

            QueueFilter filter = queueQuery.QueueFilters.Find(f => f.Filter1.FieldName == queueFieldName && f.Filter1.QueueFilterOperator == QueueFilterOperator.DateRange);

            if (filter != null)
            {
                int dateFilterIndex;
                if (int.TryParse(filter.Filter1.Value, out dateFilterIndex) == true)
                {
                    dateRange = GetDateRangeByDateFilterIndex(dateFilterIndex);
                }
                else
                {
                    DateTime startDate       = DateTime.MinValue;
                    DateTime endDate         = DateTime.MaxValue;
                    string[] dateRangeValues = filter.Filter1.Value.Split('|');
                    DateTime.TryParse(dateRangeValues[0], out startDate);
                    DateTime.TryParse(dateRangeValues[1], out endDate);
                    dateRange = new DateTime[] { startDate, endDate };
                }
            }

            return(dateRange);
        }
Exemplo n.º 4
0
        public HttpResponseMessage GetInProgressCount(QueueType queueType, QueueQuery queueQuery)
        {
            var r = new
            {
                Count = _reportQueueService.GetReportsQueueRecordCount(queueType, queueQuery)
            };

            return(Request.CreateResponse(r));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Retrieve Queue Record Count By QueueType and Filter.
        /// </summary>
        public int GetReportsQueueRecordCount(QueueType queueType, QueueQuery queueQuery)
        {
            var reports = GetReportsByQueueType(queueType);

            // apply filter(s)
            reports = ApplyQueueFilter(queueQuery, reports);

            return(reports.ToList().Count);
        }
Exemplo n.º 6
0
        public HttpResponseMessage GetIncidentsCount(QueueType queueType, QueueQuery queueQuery)
        {
            var r = new
            {
                Count = _summaryQueueService.GetSummaryQueueCount(queueType, queueQuery)
            };

            return(Request.CreateResponse(r));
        }
Exemplo n.º 7
0
        private IQueryable <Report> ApplyQueueFilter(QueueQuery queueQuery, IQueryable <Report> reports)
        {
            if (queueQuery.QueueFilters == null || queueQuery.QueueFilters.Count == 0)
            {
                return(reports);
            }

            try
            {
                reports =
                    queueQuery.QueueFilters.Select(QueueSpecifications.GetQueuePredicate <Report>)
                    .Where(predicate => predicate != null)
                    .Aggregate(reports,
                               (current, predicate) => current.Where(predicate.Predicate, predicate.PredicateParms));

                #region Apply Date Filters
                string     queueFieldName = "eventStartDate";
                DateTime[] dateRange      = QueueSpecifications.GetDateRangeByQueueField(queueQuery, queueFieldName);
                if (dateRange.Length == 2)
                {
                    DateTime startDate = dateRange[0];
                    DateTime endDate   = dateRange[1];

                    queueQuery.QueueFilters.RemoveAll(f => f.Filter1.QueueFilterOperator == QueueFilterOperator.DateRange && f.Filter1.FieldName == queueFieldName);

                    reports = reports.Where(r => r.Event.StartDate >= startDate && r.Event.StartDate <= endDate);
                }

                queueFieldName = "createdOn";
                dateRange      = QueueSpecifications.GetDateRangeByQueueField(queueQuery, queueFieldName);
                if (dateRange.Length == 2)
                {
                    DateTime startDate = dateRange[0];
                    DateTime endDate   = dateRange[1];

                    queueQuery.QueueFilters.RemoveAll(f => f.Filter1.QueueFilterOperator == QueueFilterOperator.DateRange && f.Filter1.FieldName == queueFieldName);

                    reports = reports.Where(r => r.Event.CreatedOn >= startDate && r.Event.CreatedOn <= endDate);
                }
                #endregion

                // Apply Custom Filters
                if (queueQuery.QueueFilters != null)
                {
                    reports = queueQuery.QueueFilters.Aggregate(reports, (current, filter) => current.Where(QueueSpecifications.ReportCustomFilterExpression(filter)));
                }
            }
            catch (Exception e)
            {
                Log.Error(string.Format("Failed to apply queue filter(s) for {0}", queueQuery.QueueType), e);
            }

            return(reports);
        }
Exemplo n.º 8
0
        private IQueryable <CitationSummary> CitationSummaries(QueueQuery queueQuery)
        {
            var summaries = UnitOfWork.GetEntityQuery <CitationSummary>();

            var agencies = GetAgenciesWithViewGranted(ModuleType.Citation);

            summaries = ApplyQueueFilter(queueQuery, summaries.Where(x => agencies.Contains(x.AgencyId)));

            #region Apply Date Filters
            try
            {
                string     queueFieldName = "eventStartDate";
                DateTime[] dateRange      = QueueSpecifications.GetDateRangeByQueueField(queueQuery, queueFieldName);
                if (dateRange.Length == 2)
                {
                    DateTime startDate = dateRange[0];
                    DateTime endDate   = dateRange[1];

                    queueQuery.QueueFilters.RemoveAll(f => f.Filter1.QueueFilterOperator == QueueFilterOperator.DateRange && f.Filter1.FieldName == queueFieldName);

                    summaries = summaries.Where(s => s.Event.StartDate >= startDate && s.Event.StartDate <= endDate);
                }

                queueFieldName = "eventDateReported";
                dateRange      = QueueSpecifications.GetDateRangeByQueueField(queueQuery, queueFieldName);
                if (dateRange.Length == 2)
                {
                    DateTime startDate = dateRange[0];
                    DateTime endDate   = dateRange[1];

                    queueQuery.QueueFilters.RemoveAll(f => f.Filter1.QueueFilterOperator == QueueFilterOperator.DateRange && f.Filter1.FieldName == queueFieldName);

                    summaries = summaries.Where(s => s.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Reporting.Code).InvolvementDate >= startDate && s.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Reporting.Code).InvolvementDate <= endDate);
                }
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("Failed to apply queue date filter(s) for {0}", queueQuery.QueueType), ex);
            }
            #endregion

            // Apply Custom Filters
            if (queueQuery.QueueFilters != null)
            {
                summaries = queueQuery.QueueFilters.Aggregate(summaries,
                                                              (current, filter) => current.Where(QueueSpecifications.CitationQueueCustomFilterExpression(filter)));
            }

            return(summaries);
        }
Exemplo n.º 9
0
        private IQueryable <Case> CaseSummmaries(QueueQuery queueQuery)
        {
            var summaries = UnitOfWork.GetEntityQuery <Case>();

            var agencies = GetAgenciesWithViewGranted(ModuleType.Case);

            summaries = ApplyQueueFilter(queueQuery, summaries.Where(x => agencies.Contains(x.AgencyId)));

            // Apply Custom Filters
            if (queueQuery.QueueFilters != null)
            {
                summaries = queueQuery.QueueFilters.Aggregate(summaries, (current, filter) => current.Where(QueueSpecifications.CaseQueueCustomFilterExpression(filter)));
            }

            return(summaries);
        }
Exemplo n.º 10
0
        private IQueryable <T> ApplyQueueFilter <T>(QueueQuery queueQuery, IQueryable <T> summaries)
        {
            if (queueQuery == null || queueQuery.QueueFilters == null)
            {
                return(summaries);
            }

            try
            {
                summaries =
                    queueQuery.QueueFilters.Select(QueueSpecifications.GetQueuePredicate <T>)
                    .Where(predicate => predicate != null)
                    .Aggregate(summaries,
                               (current, predicate) => current.Where(predicate.Predicate, predicate.PredicateParms));
            }
            catch (Exception e)
            {
                Log.Error(string.Format("Failed to apply queue filter(s) for {0}", queueQuery.QueueType), e);
            }

            return(summaries);
        }
Exemplo n.º 11
0
        private IQueryable <Report> ApplyQueueSorting(QueueQuery queueQuery, IQueryable <Report> reports)
        {
            if (queueQuery != null && queueQuery.QueueSort != null)
            {
                try
                {
                    var orderBy = QueueSpecifications.GetOrderBy <Report>(queueQuery.QueueSort);
                    reports = (orderBy != null) ? reports.OrderBy(orderBy) : reports.OrderBy(r => r.ModifiedOn);
                }
                catch (Exception e)
                {
                    Log.Error(string.Format("Failed to apply queue sorting for {0}", queueQuery.QueueType), e);

                    reports = reports.OrderBy(r => r.Event.StartDate);
                }
            }
            else
            {
                reports = reports.OrderBy(r => r.Event.StartDate);
            }

            return(reports);
        }
Exemplo n.º 12
0
 public ICollection <CallForServiceSummaryQueueItem> GetCallsForService(QueueQuery queueQuery)
 {
     return(_summaryQueueService.GetCallForServiceSummaryQueueItems(queueQuery));
 }
Exemplo n.º 13
0
 public virtual void QueueQuery(C context, QueueQuery mystruct)
 {
 }
Exemplo n.º 14
0
        /// <summary>
        /// Return Queue Records by QueueType and Filter
        /// </summary>
        public ICollection <ReportQueueItem> GetReportQueueItems(QueueType queueType, QueueQuery queueQuery)
        {
            var reports = GetReportsByQueueType(queueType);

            // apply filter(s)
            reports = ApplyQueueFilter(queueQuery, reports);

            // apply sorting
            reports = ApplyQueueSorting(queueQuery, reports);

            // apply skip, take and map into ReportQueueItem
            var reportQueueItems = queueQuery != null
                ? reports.Skip(queueQuery.Skip).Take(queueQuery.Take).ToList().AsListOf <ReportQueueItem>()
                : reports.ToList().AsListOf <ReportQueueItem>();

            // map the creators
            MapCreators(reportQueueItems);

            return(reportQueueItems);
        }
Exemplo n.º 15
0
 public ICollection <IncidentSummaryQueueItem> GetIncidents(QueueQuery queueQuery)
 {
     return(_summaryQueueService.GetIncidentSummaryQueueItems(queueQuery));
 }
Exemplo n.º 16
0
 public ICollection <CaseQueueItem> GetCases(QueueQuery queueQuery)
 {
     return(_summaryQueueService.CaseQueueItems(queueQuery));
 }
Exemplo n.º 17
0
 public ICollection <ArrestSummaryQueueItem> GetArrests(QueueQuery queueQuery)
 {
     return(_summaryQueueService.GetArrestSummaryQueueItems(queueQuery));
 }
Exemplo n.º 18
0
 public ICollection <CitationSummaryQueueItem> GetCitations(QueueQuery queueQuery)
 {
     return(_summaryQueueService.GetCitationSummaryQueueItems(queueQuery));
 }
Exemplo n.º 19
0
 public ICollection <FieldInterviewSummaryQueueItem> GetFieldInterviews(QueueQuery queueQuery)
 {
     return(_summaryQueueService.GetFieldInterviewSummaryQueueItems(queueQuery));
 }
Exemplo n.º 20
0
 public ICollection <OtherEventSummaryQueueItem> GetOtherEvents(QueueQuery queueQuery)
 {
     return(_summaryQueueService.GetOtherEventSummaryQueueItems(queueQuery));
 }
Exemplo n.º 21
0
 public ICollection <ReportQueueItem> GetReportQueueItems(QueueType queueType, QueueQuery queueQuery)
 {
     return(_reportQueueService.GetReportQueueItems(queueType, queueQuery));
 }