// GET : /Distributor/Add public ActionResult Schedule(string AlertType, string DeviceId, string AlertId) { ScheduleViewModel sVM = new ScheduleViewModel(); sVM.AlertTypes = new AlertData().GetAvailableAlerts(); sVM.Devices = new AlertData().GetAvailableDevices().Select(m=>m.DeviceId).ToList(); if (!string.IsNullOrWhiteSpace(AlertType)) { sVM.SelectedAlertType = (DeviceAlarmType)Enum.Parse(typeof(DeviceAlarmType), AlertType); } if (!string.IsNullOrWhiteSpace(DeviceId)) { sVM.SelectedDevice = DeviceId; } if (!string.IsNullOrWhiteSpace(AlertId)) { sVM.SelectedAlertId = AlertId; } if (!string.IsNullOrWhiteSpace(AlertType) && !string.IsNullOrWhiteSpace(DeviceId)) { sVM = new AlertData().GetAlertData(sVM); } if (Request.IsAjaxRequest()) { return PartialView("_Schedule", sVM); } return View(sVM); }
public ActionResult Ac(int? Id = null) { AcAlert alertModel = new AcAlert(); try { ScheduleViewModel sVM = new ScheduleViewModel(); sVM.SelectedAlertType = DeviceAlarmType.AcAlarm; sVM = new AlertData().GetAlertDetails(sVM, Id); AlertBase alertData = sVM.AlertDatas.FirstOrDefault() as AlertBase; if (alertData == null) { alertData = new AlertBase() { Id = 0, Conditions = new List<Tracker.Common.Condition>(), IsActive = false }; } bool IsOnAc = false; if (alertData.Conditions.Where(m => m.Operand == "OnAc").FirstOrDefault() != null) { IsOnAc = Convert.ToBoolean(Convert.ToInt32(alertData.Conditions.Where(m => m.Operand == "OnAc").FirstOrDefault().Value)); } else { IsOnAc = false; } alertModel = new AcAlert() { Id = alertData.Id, IsActive = alertData.IsActive, IsOnAc = IsOnAc, Devices = new List<DeviceDetailSelection>() }; List<DeviceDetailSelection> availableDevices = new AlertData().GetAvailableDevices(); List<string> activeDevices = new AlertData().GetDevicesForAlert(alertData.Id); if (availableDevices != null && availableDevices.Count > 0) { alertModel.Devices = availableDevices.Select(m => new DeviceDetailSelection { DeviceId = m.DeviceId, VehicleId = m.VehicleId, Checked = activeDevices.Contains(m.DeviceId) }).ToList(); } } catch (Exception ex) { } return View(alertModel); }
public ActionResult Stoppage(int Id = 0) { StoppageAlert alertModel = new StoppageAlert(); try { ScheduleViewModel sVM = new ScheduleViewModel(); sVM.SelectedAlertType = DeviceAlarmType.StopAlarm; sVM = new AlertData().GetAlertDetails(sVM, Id); AlertBase alertData = sVM.AlertDatas.FirstOrDefault() as AlertBase; if (alertData == null) { alertData = new AlertBase() { Id = 0, Conditions = new List<Tracker.Common.Condition>(), IsActive = false }; } int Duration = 5; string SpeedComparer = string.Empty; if (alertData.Conditions.Where(m => m.Operand == "Duration").FirstOrDefault() != null) { Duration = Convert.ToInt32(alertData.Conditions.Where(m => m.Operand == "Duration").FirstOrDefault().Value); } alertModel = new StoppageAlert() { Id = alertData.Id, Name = alertData.Name, Description = alertData.DescriptionText, IsActive = alertData.IsActive, Duration = Duration, Devices = new List<DeviceDetailSelection>() }; List<DeviceDetailSelection> availableDevices = new AlertData().GetAvailableDevices(); List<string> activeDevices = new AlertData().GetDevicesForAlert(alertData.Id); if (availableDevices != null && availableDevices.Count > 0) { alertModel.Devices = availableDevices.Select(m => new DeviceDetailSelection { DeviceId = m.DeviceId, VehicleId = m.VehicleId, Checked = activeDevices.Contains(m.DeviceId) }).ToList(); } } catch (Exception ex) { } return View(alertModel); }
public ActionResult GetStoppageAlertList(string IdToShow) { var list = new AlertData().GetAvilableAlerts(DeviceAlarmType.StopAlarm); return View(list); }
public ActionResult Fence(int Id = 0) { FenceAlert alertModel = new FenceAlert(); try { ScheduleViewModel sVM = new ScheduleViewModel(); sVM.SelectedAlertType = DeviceAlarmType.FenceAlarm; sVM = new AlertData().GetAlertDetails(sVM, Id); AlertBase alertData = sVM.AlertDatas.FirstOrDefault() as AlertBase; if (alertData == null) { alertData = new AlertBase() { Id = 0, Conditions = new List<Tracker.Common.Condition>(), IsActive = false }; } alertModel = new FenceAlert() { Id = alertData.Id, Name = alertData.Name, Description = alertData.DescriptionText, IsActive = alertData.IsActive, FenceType = (Id == 0) ? DeviceAlarmType.FenceInAlarm : sVM.SelectedAlertType, Points = alertData.FenceList, Devices = new List<DeviceDetailSelection>() }; List<DeviceDetailSelection> availableDevices = new AlertData().GetAvailableDevices(); List<string> activeDevices = new AlertData().GetDevicesForAlert(alertData.Id); if (availableDevices != null && availableDevices.Count > 0) { alertModel.Devices = availableDevices.Select(m => new DeviceDetailSelection { DeviceId = m.DeviceId, VehicleId = m.VehicleId, Checked = activeDevices.Contains(m.DeviceId) }).ToList(); } } catch (Exception ex) { } return View(alertModel); }
public ActionResult AlertReceivers(string AlertId) { List<AlertReceiver> AlertReceivers = new List<AlertReceiver>(); AlertReceivers = new AlertData().GetAlertReceivers(AlertId); return View(AlertReceivers); }