Esempio n. 1
0
        public JsonResult GetTaxisInPolygon(DateTime start, DateTime stop, string filterSelection, GeoCoordinate[] points)
        {
            List<string> errors = new List<string>();
            Models.JsonResponse<List<Models.Data.Trip>> response;

            if (!validateStartStopTime(start, stop, ref errors))
            {
                response = new Models.JsonResponse<List<Models.Data.Trip>>(errors, null, false);
                return Json(response, JsonRequestBehavior.AllowGet);
            }

            var data = new BLL.Queries.Trip().TaxiInPolygon(start, stop, points, ref errors, filterSelection);
            response = new Models.JsonResponse<List<Models.Data.Trip>>(errors, data, true);
            response.Count = data.Count;
            return Json(response, JsonRequestBehavior.AllowGet);
        }
Esempio n. 2
0
        public JsonResult GetVersionStatus()
        {
            JsonResponse response = new Models.JsonResponse();

            try
            {
                int userId = HttpContext.User.Identity.GetUserId <int>();
                var data   = this._userService.GetVersionStatus(userId);
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                string exceptionMsg = base.ProcessException(e);
                response.Status = JsonResponseStatus.Error;
            }
            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public JsonNetResult UpdateVersionStatus()
        {
            JsonResponse response = new Models.JsonResponse();

            try
            {
                int userId = HttpContext.User.Identity.GetUserId <int>();
                this._userService.IsVersionUpdated(userId, false);
                response.Status = JsonResponseStatus.Success;
            }
            catch (Exception e)
            {
                string exceptionMsg = base.ProcessException(e);
                response.Status = JsonResponseStatus.Error;
            }
            return(JsonNet(response, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public JsonNetResult UpdateIsObservation(int PMId, bool IsObservation)
        {
            JsonResponse response = new Models.JsonResponse();

            try
            {
                this._pmServices.UpdateIsObservation(PMId, IsObservation);
                response.Status = JsonResponseStatus.Success;
            }
            catch (Exception ex)
            {
                response = new JsonResponse {
                    Status = JsonResponseStatus.Error, Message = ProcessException(ex)
                };
            }

            return(JsonNet(response, JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
        public JsonResult GetTaxisAtLocation(DateTime start, DateTime stop, string filterSelection, float latitude1, float longitude1, float latitude2, float longitude2)
        {
            List<string> errors = new List<string>();
            Models.JsonResponse<List<Models.Data.Trip>> response;

            if (!validateStartStopTime(start, stop, ref errors))
            {
                response = new Models.JsonResponse<List<Models.Data.Trip>>(errors, null, false);
                return Json(response, JsonRequestBehavior.AllowGet);
            }

            GeoCoordinate coords1 = new GeoCoordinate(latitude1, longitude1);
            GeoCoordinate coords2 = new GeoCoordinate(latitude2, longitude2);
            var data = new BLL.Queries.Trip().TaxiInSector(start, stop, coords1, coords2, ref errors, filterSelection);
            response = new Models.JsonResponse<List<Models.Data.Trip>>(errors, data, true);
            response.Count = data.Count;
            return Json(response, JsonRequestBehavior.AllowGet);
        }
Esempio n. 6
0
        public JsonNetResult DeleteDocument(int[] Ids)
        {
            JsonResponse response = new Models.JsonResponse();

            try
            {
                int userId = HttpContext.User.Identity.GetUserId <int>();
                this._documentService.DeleteDocuments(Ids, userId);
                response.Status  = JsonResponseStatus.Success;
                response.Message = "Record successfully Deleted";
            }
            catch (Exception ex)
            {
                response = new JsonResponse {
                    Status = JsonResponseStatus.Error, Message = ProcessException(ex)
                };
            }
            return(JsonNet(response, JsonRequestBehavior.AllowGet));
        }
Esempio n. 7
0
        public JsonNetResult UpdateIsShutdown(int lineId, bool IsShutdown)
        {
            JsonResponse response = new Models.JsonResponse();

            int userId  = HttpContext.User.Identity.GetUserId <int>();
            var line    = this._lineService.GetLineById(lineId);
            var plantid = line.PlantId;

            try
            {
                if (IsShutdown)
                {
                    DateTime lastShutDownDate = this._preventiveReviewHistoryService.GetLastShutDownDate(lineId);
                    if ((DateTime.UtcNow.Date - lastShutDownDate).Days <= 5)
                    {
                        return(JsonNet(new JsonResponse {
                            Status = JsonResponseStatus.Warning, Message = "Last shutdown for this line is whthin last 5 days. Can not shutdown today."
                        }, JsonRequestBehavior.AllowGet));
                    }


                    this._lineService.UpdateIsShutdown(lineId, true);
                    var shutdownId = this._dashboardService.Add(new ShutdownHistory
                    {
                        PlantId      = plantid,
                        LineId       = lineId,
                        MachineId    = null,
                        ShutdownDate = DateTime.UtcNow,
                        ShutdownBy   = userId,
                        StartDate    = null,
                        StartBy      = null
                    });

                    this._preventiveMaintenanceService.UpdateShutdownNextReviewDateForLine(lineId);

                    var preventiveIds = this._preventiveMaintenanceService.GetPreventiveIdsForLine(lineId);
                    for (int i = 0; i < preventiveIds.Length; i++)
                    {
                        var isLineActive      = this._preventiveMaintenanceService.GetLineIsActive(preventiveIds[i]);
                        var isMachineIsActive = this._preventiveMaintenanceService.GetMachineIsActive(preventiveIds[i]);
                        this._preventiveReviewHistoryService.Add(new PreventiveReviewHistory
                        {
                            PreventiveId        = preventiveIds[i],
                            ReviewDate          = null,
                            ReviewBy            = null,
                            Notes               = null,
                            ScheduledReviewDate = DateTime.UtcNow.Date,
                            HoldId              = null,
                            ShutdownId          = shutdownId,
                            IsLaps              = false,
                            IsOverdue           = false,
                            IsLineActive        = isLineActive,
                            IsMachineActive     = isMachineIsActive
                        });
                    }
                }
                else
                {
                    if (this._preventiveReviewHistoryService.AnyMachineShutdown(lineId))
                    {
                        return(JsonNet(new JsonResponse {
                            Status = JsonResponseStatus.Warning, Message = "One or more machine for this line is in shutdown mode. Can't update this record."
                        }, JsonRequestBehavior.AllowGet));
                    }

                    if (this._preventiveReviewHistoryService.AnyShutdownReviewRemain(lineId))
                    {
                        return(JsonNet(new JsonResponse {
                            Status = JsonResponseStatus.Warning, Message = "One or more shutdown activity for this line is not done. Can't update this record."
                        }, JsonRequestBehavior.AllowGet));
                    }

                    this._lineService.UpdateIsShutdown(lineId, false);
                    int shutdownId = _dashboardService.GetShutdownIdForLine(lineId);
                    this._dashboardService.UpdateShutdownHistoryForLine(shutdownId, userId);
                }
                response.Status = JsonResponseStatus.Success;
            }
            catch (Exception ex)
            {
                response = new JsonResponse {
                    Status = JsonResponseStatus.Error, Message = ProcessException(ex)
                };
            }

            return(JsonNet(response, JsonRequestBehavior.AllowGet));
        }