Ejemplo n.º 1
0
        private List <IncidentHistory> GetIncidentHistories(int itemsPerPage, int pageNumber, out int dataCount)
        {
            try
            {
                var incidentHistoryList = new IncidentHistoryServices().GetAllOrderedIncidentHistories(itemsPerPage, pageNumber, out dataCount);

                ViewBag.PrDataCount = dataCount.ToString(CultureInfo.InvariantCulture);

                var totalPages = dataCount / itemsPerPage;

                // Counting the last page
                if (dataCount % itemsPerPage != 0)
                {
                    totalPages++;
                }

                ViewBag.PrTotalPages = totalPages;
                ViewBag.PrPage       = pageNumber;
                if (!incidentHistoryList.Any())
                {
                    return(new List <IncidentHistory>());
                }

                return(incidentHistoryList);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                dataCount = 0;
                return(new List <IncidentHistory>());
            }
        }
        public ActionResult GetIncidents2(int queryId)
        {
            if (queryId < 1)
            {
                return(Json(new List <IncidentReportObject>(), JsonRequestBehavior.AllowGet));
            }

            var query = new IncidentQueryBuilderServices().GetIncidentQuery(queryId);

            if (query == null || query.IncidentQueryId < 1)
            {
                return(Json(new List <IncidentReportObject>(), JsonRequestBehavior.AllowGet));
            }

            var incidentList = new IncidentHistoryServices().GetOrderedIncidentReportObjects(query) ?? new List <IncidentReportObject>();

            if (!incidentList.Any())
            {
                return(Json(new List <IncidentReportObject>(), JsonRequestBehavior.AllowGet));
            }

            var jsonResult = Json(incidentList, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
        public ActionResult GetIncidents(IncidentQuery queryBuilder)
        {
            if (queryBuilder == null)
            {
                return(Json(new List <IncidentReportObject>(), JsonRequestBehavior.AllowGet));
            }


            if (queryBuilder.CompanyId < 1 && queryBuilder.CompanyId < 1 && queryBuilder.IncidentTypeId < 1 && ((queryBuilder.StartDate != null && queryBuilder.StartDate.Value.Year == 0001) || (queryBuilder.StartDate == null)) && ((queryBuilder.EndDate != null && queryBuilder.EndDate.Value.Year == 0001) || (queryBuilder.EndDate == null)))
            {
                return(Json(new List <IncidentReportObject>(), JsonRequestBehavior.AllowGet));
            }

            var incidentList = new IncidentHistoryServices().GetOrderedIncidentReportObjects(queryBuilder) ?? new List <IncidentReportObject>();

            if (!incidentList.Any())
            {
                return(Json(new List <IncidentReportObject>(), JsonRequestBehavior.AllowGet));
            }
            Session["_successfulIncidentQuery"] = queryBuilder;
            var jsonResult = Json(incidentList, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
Ejemplo n.º 4
0
        private List <IncidentHistory> GetIncidentHistories()
        {
            try
            {
                var incidentHistoryList = new IncidentHistoryServices().GetAllOrderedIncidentHistories();
                if (!incidentHistoryList.Any())
                {
                    return(new List <IncidentHistory>());
                }

                return(incidentHistoryList);
            }
            catch (Exception ex)
            {
                return(new List <IncidentHistory>());
            }
        }
Ejemplo n.º 5
0
        public ActionResult GetIncdentsByType(int incidentTypeId)
        {
            try
            {
                if (incidentTypeId < 1)
                {
                    return(Json(new List <IncidentHistory>(), JsonRequestBehavior.AllowGet));
                }

                var incidentHistoryList = new IncidentHistoryServices().GetIncidentHistoriesByType(incidentTypeId);

                if (!incidentHistoryList.Any())
                {
                    return(Json(new List <IncidentHistory>(), JsonRequestBehavior.AllowGet));
                }

                return(Json(incidentHistoryList, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new List <IncidentHistory>(), JsonRequestBehavior.AllowGet));
            }
        }
        private List <DocObject> GetYears()
        {
            var jxs = new IncidentHistoryServices().GetIncidentYears();

            if (!jxs.Any())
            {
                return(new List <DocObject>());
            }
            var tdv = new List <DocObject>();

            jxs.ForEach(m =>
            {
                var ts = int.Parse(m);

                if (!tdv.Exists(t => t.DocId == ts))
                {
                    tdv.Add(new DocObject {
                        DocName = m, DocId = ts
                    });
                }
            });
            return(tdv.OrderByDescending(m => m.DocName).ToList());
        }