private static ATAlert SubstituteDurationOperandWCValues(ATAlert alert) { for (int i = 0; i < alert.Conditions.Count; i++) { if (alert.Conditions[i].Operand.ToLower() == "Duration".ToLower()) { alert.Conditions[i].Operand = GetValuesFromData(alert.Conditions[i].Operand, alert.CurrentData); } } return(alert); }
// Not used public static bool IsPrevNCurrValuesChanged(ATAlert alert) { bool valueChanged = false; switch (alert.AlarmType) { case Tracker.Common.Model.DeviceAlarmType.NormalAlarm: break; case Tracker.Common.Model.DeviceAlarmType.PowerCutAlarm: break; case Tracker.Common.Model.DeviceAlarmType.SOSAlarm: break; case Tracker.Common.Model.DeviceAlarmType.SpeedAlarm: { if (alert.CurrentData.VariableNVales["Speed"] != alert.PreviousData.VariableNVales["Speed"]) { valueChanged = true; } } break; case Tracker.Common.Model.DeviceAlarmType.BreakAlarm: break; case Tracker.Common.Model.DeviceAlarmType.VibrationAlarm: break; case Tracker.Common.Model.DeviceAlarmType.FenceAlarm: break; case Tracker.Common.Model.DeviceAlarmType.MovingAlarm: break; case Tracker.Common.Model.DeviceAlarmType.AccAlarm: break; case Tracker.Common.Model.DeviceAlarmType.StopAlarm: break; case Tracker.Common.Model.DeviceAlarmType.AcAlarm: break; default: break; } return(valueChanged); }
public static bool ProcessFenceConditionWithOutDuration(ATAlert alert) { var FencePositionLs = alert.FencePosition.Select(m => new GeoPoint() { X = Double.Parse(m.Lat), Y = Double.Parse(m.Lang) }).ToList(); if (alert.AlarmType == DeviceAlarmType.FenceInAlarm) { // Check inside return GeoPolygon.IsInside(FencePositionLs, Double.Parse(alert.CurrentData.VariableNVales["Latitude"]), Double.Parse(alert.CurrentData.VariableNVales["Longitude"])); } else if (alert.AlarmType == DeviceAlarmType.FenceOutAlarm) { // Check outside return !GeoPolygon.IsInside(FencePositionLs, Double.Parse(alert.CurrentData.VariableNVales["Latitude"]), Double.Parse(alert.CurrentData.VariableNVales["Longitude"])); } return true; }
public static bool ProcessFenceConditionWithOutDuration(ATAlert alert) { var FencePositionLs = alert.FencePosition.Select(m => new GeoPoint() { X = Double.Parse(m.Lat), Y = Double.Parse(m.Lang) }).ToList(); if (alert.AlarmType == DeviceAlarmType.FenceInAlarm) { // Check inside return(GeoPolygon.IsInside(FencePositionLs, Double.Parse(alert.CurrentData.VariableNVales["Latitude"]), Double.Parse(alert.CurrentData.VariableNVales["Longitude"]))); } else if (alert.AlarmType == DeviceAlarmType.FenceOutAlarm) { // Check outside return(!GeoPolygon.IsInside(FencePositionLs, Double.Parse(alert.CurrentData.VariableNVales["Latitude"]), Double.Parse(alert.CurrentData.VariableNVales["Longitude"]))); } return(true); }
// Not used public static bool IsPrevNCurrValuesChanged(ATAlert alert) { bool valueChanged = false; switch (alert.AlarmType) { case Tracker.Common.Model.DeviceAlarmType.NormalAlarm: break; case Tracker.Common.Model.DeviceAlarmType.PowerCutAlarm: break; case Tracker.Common.Model.DeviceAlarmType.SOSAlarm: break; case Tracker.Common.Model.DeviceAlarmType.SpeedAlarm: { if (alert.CurrentData.VariableNVales["Speed"] != alert.PreviousData.VariableNVales["Speed"]) { valueChanged = true; } } break; case Tracker.Common.Model.DeviceAlarmType.BreakAlarm: break; case Tracker.Common.Model.DeviceAlarmType.VibrationAlarm: break; case Tracker.Common.Model.DeviceAlarmType.FenceAlarm: break; case Tracker.Common.Model.DeviceAlarmType.MovingAlarm: break; case Tracker.Common.Model.DeviceAlarmType.AccAlarm: break; case Tracker.Common.Model.DeviceAlarmType.StopAlarm: break; case Tracker.Common.Model.DeviceAlarmType.AcAlarm: break; default: break; } return valueChanged; }
private void FireAlertWData(string DeviceId, ATAlert alert) { { DataTable AlertDataFromService = new DataTable(); try { #region Column Definition AlertDataFromService.Columns.Add("DeviceId", typeof(string)); AlertDataFromService.Columns.Add("IMEI", typeof(string)); AlertDataFromService.Columns.Add("CommandType", typeof(string)); AlertDataFromService.Columns.Add("StatusCode", typeof(string)); AlertDataFromService.Columns.Add("Latitude", typeof(string)); AlertDataFromService.Columns.Add("Longitude", typeof(string)); AlertDataFromService.Columns.Add("Speed", typeof(string)); AlertDataFromService.Columns.Add("Direction", typeof(string)); AlertDataFromService.Columns.Add("Altitude", typeof(string)); AlertDataFromService.Columns.Add("Mileage", typeof(string)); AlertDataFromService.Columns.Add("Odometer", typeof(int)); AlertDataFromService.Columns.Add("OnBattery", typeof(int)); AlertDataFromService.Columns.Add("OnIgnition", typeof(int)); AlertDataFromService.Columns.Add("OnAc", typeof(int)); AlertDataFromService.Columns.Add("OnGps", typeof(int)); AlertDataFromService.Columns.Add("OnAcc", typeof(int)); AlertDataFromService.Columns.Add("OilNElectricConected", typeof(int)); AlertDataFromService.Columns.Add("OnSOS", typeof(int)); AlertDataFromService.Columns.Add("OnLowBattery", typeof(int)); AlertDataFromService.Columns.Add("OnPowerCut", typeof(int)); AlertDataFromService.Columns.Add("OnShock", typeof(int)); AlertDataFromService.Columns.Add("OnCharge", typeof(int)); AlertDataFromService.Columns.Add("OnDefence", typeof(int)); AlertDataFromService.Columns.Add("VoltageLevel", typeof(int)); AlertDataFromService.Columns.Add("SignalStrengthLevel", typeof(int)); AlertDataFromService.Columns.Add("AlarmType", typeof(string)); AlertDataFromService.Columns.Add("TrackerIp", typeof(string)); AlertDataFromService.Columns.Add("DeviceDataTime", typeof(DateTime)); AlertDataFromService.Columns.Add("TrackerConnectedTime", typeof(DateTime)); AlertDataFromService.Columns.Add("TrackerDataActionTime", typeof(DateTime)); AlertDataFromService.Columns.Add("TrackerDataParsedTime", typeof(DateTime)); AlertDataFromService.Columns.Add("ActionTime", typeof(DateTime)); AlertDataFromService.Columns.Add("DeviceAlertId", typeof(int)); AlertDataFromService.Columns.Add("IsSent", typeof(bool)); AlertDataFromService.Columns.Add("SentTime", typeof(DateTime)); AlertDataFromService.Columns.Add("ConditionState", typeof(bool)); AlertDataFromService.Columns.Add("ConditionStateTime", typeof(DateTime)); #endregion { DataRow dr = AlertDataFromService.Rows.Add( DeviceId, null, alert.CurrentData.VariableNVales["CommandType"], alert.CurrentData.VariableNVales["StatusCode"], alert.CurrentData.VariableNVales["Latitude"], alert.CurrentData.VariableNVales["Longitude"], alert.CurrentData.VariableNVales["Speed"], alert.CurrentData.VariableNVales["Direction"], null, null, null, alert.CurrentData.VariableNVales["OnBattery"], alert.CurrentData.VariableNVales["OnIgnition"], alert.CurrentData.VariableNVales["OnAc"], alert.CurrentData.VariableNVales["OnGps"], alert.CurrentData.VariableNVales["OnAcc"], alert.CurrentData.VariableNVales["OilNElectricConected"], alert.CurrentData.VariableNVales["OnSOS"], alert.CurrentData.VariableNVales["OnLowBattery"], alert.CurrentData.VariableNVales["OnPowerCut"], alert.CurrentData.VariableNVales["OnShock"], alert.CurrentData.VariableNVales["OnCharge"], alert.CurrentData.VariableNVales["OnDefence"], null, null, alert.CurrentData.VariableNVales["AlarmType"], null, alert.CurrentData.VariableNVales["DeviceDataTime"], (string.IsNullOrWhiteSpace(alert.CurrentData.VariableNVales["TrackerConnectedTime"]) ? (DateTime?)null : Convert.ToDateTime(alert.CurrentData.VariableNVales["TrackerConnectedTime"])), alert.CurrentData.VariableNVales["TrackerDataActionTime"], alert.CurrentData.VariableNVales["TrackerDataParsedTime"], alert.CurrentData.VariableNVales["ActionTime"], alert.Id, alert.IsSent, alert.SentTime, alert.ConditionState, alert.ConditionStateTime ); } List<TVParameter> TVParameters = new List<TVParameter>(); TVParameters.Add(new TVParameter() { ParameterName = "@AlertDataFromService", ParameterValue = AlertDataFromService, ParameterTypeName = "DeviceAlertDataType_V1", SqlDbType = SqlDbType.Structured }); Data.StoreData_ExecuteNonQuery(DataBase.Alert, CommandType.StoredProcedure, "A_StoreDeviceFiredAlerts", new SqlParameter[] { new SqlParameter("DeviceAlertId", alert.Id), new SqlParameter("AlertType", alert.AlarmType), new SqlParameter("Eval", alert.Eval), new SqlParameter("Status", alert.IsSent), new SqlParameter("ProcessorId", this.ProcessorId) }, TVParameters); } catch (Exception ex) { Console.WriteLine(ex); } finally { AlertDataFromService = null; } } }
public static bool ProcessDurationOnCondition(ATAlert alert) { alert = SubstituteDurationOperandWCValues(alert); return Eval(alert.Conditions); }
public static bool ProcessConditionWithOutDuration(ATAlert alert) { alert = SubstituteOperandWCValues(alert); return Eval(alert.Conditions.Where(m => m.Operand.ToLower() != "Duration".ToLower()).ToList()); }
private static ATAlert SubstituteOperandWCValues(ATAlert alert) { for (int i = 0; i < alert.Conditions.Count; i++) { if (alert.Conditions[i].Operand.ToLower() != "Duration".ToLower()) { alert.Conditions[i].Operand = GetValuesFromData(alert.Conditions[i].Operand, alert.CurrentData); } } return alert; }
public static bool ProcessDurationOnCondition(ATAlert alert) { alert = SubstituteDurationOperandWCValues(alert); return(Eval(alert.Conditions)); }
public static bool ProcessConditionWithOutDuration(ATAlert alert) { alert = SubstituteOperandWCValues(alert); return(Eval(alert.Conditions.Where(m => m.Operand.ToLower() != "Duration".ToLower()).ToList())); }
private void FireAlertWData(string DeviceId, ATAlert alert) { { DataTable AlertDataFromService = new DataTable(); try { #region Column Definition AlertDataFromService.Columns.Add("DeviceId", typeof(string)); AlertDataFromService.Columns.Add("IMEI", typeof(string)); AlertDataFromService.Columns.Add("CommandType", typeof(string)); AlertDataFromService.Columns.Add("StatusCode", typeof(string)); AlertDataFromService.Columns.Add("Latitude", typeof(string)); AlertDataFromService.Columns.Add("Longitude", typeof(string)); AlertDataFromService.Columns.Add("Speed", typeof(string)); AlertDataFromService.Columns.Add("Direction", typeof(string)); AlertDataFromService.Columns.Add("Altitude", typeof(string)); AlertDataFromService.Columns.Add("Mileage", typeof(string)); AlertDataFromService.Columns.Add("Odometer", typeof(int)); AlertDataFromService.Columns.Add("OnBattery", typeof(int)); AlertDataFromService.Columns.Add("OnIgnition", typeof(int)); AlertDataFromService.Columns.Add("OnAc", typeof(int)); AlertDataFromService.Columns.Add("OnGps", typeof(int)); AlertDataFromService.Columns.Add("OnAcc", typeof(int)); AlertDataFromService.Columns.Add("OilNElectricConected", typeof(int)); AlertDataFromService.Columns.Add("OnSOS", typeof(int)); AlertDataFromService.Columns.Add("OnLowBattery", typeof(int)); AlertDataFromService.Columns.Add("OnPowerCut", typeof(int)); AlertDataFromService.Columns.Add("OnShock", typeof(int)); AlertDataFromService.Columns.Add("OnCharge", typeof(int)); AlertDataFromService.Columns.Add("OnDefence", typeof(int)); AlertDataFromService.Columns.Add("VoltageLevel", typeof(int)); AlertDataFromService.Columns.Add("SignalStrengthLevel", typeof(int)); AlertDataFromService.Columns.Add("AlarmType", typeof(string)); AlertDataFromService.Columns.Add("TrackerIp", typeof(string)); AlertDataFromService.Columns.Add("DeviceDataTime", typeof(DateTime)); AlertDataFromService.Columns.Add("TrackerConnectedTime", typeof(DateTime)); AlertDataFromService.Columns.Add("TrackerDataActionTime", typeof(DateTime)); AlertDataFromService.Columns.Add("TrackerDataParsedTime", typeof(DateTime)); AlertDataFromService.Columns.Add("ActionTime", typeof(DateTime)); AlertDataFromService.Columns.Add("DeviceAlertId", typeof(int)); AlertDataFromService.Columns.Add("IsSent", typeof(bool)); AlertDataFromService.Columns.Add("SentTime", typeof(DateTime)); AlertDataFromService.Columns.Add("ConditionState", typeof(bool)); AlertDataFromService.Columns.Add("ConditionStateTime", typeof(DateTime)); #endregion { DataRow dr = AlertDataFromService.Rows.Add( DeviceId, null, alert.CurrentData.VariableNVales["CommandType"], alert.CurrentData.VariableNVales["StatusCode"], alert.CurrentData.VariableNVales["Latitude"], alert.CurrentData.VariableNVales["Longitude"], alert.CurrentData.VariableNVales["Speed"], alert.CurrentData.VariableNVales["Direction"], null, null, null, alert.CurrentData.VariableNVales["OnBattery"], alert.CurrentData.VariableNVales["OnIgnition"], alert.CurrentData.VariableNVales["OnAc"], alert.CurrentData.VariableNVales["OnGps"], alert.CurrentData.VariableNVales["OnAcc"], alert.CurrentData.VariableNVales["OilNElectricConected"], alert.CurrentData.VariableNVales["OnSOS"], alert.CurrentData.VariableNVales["OnLowBattery"], alert.CurrentData.VariableNVales["OnPowerCut"], alert.CurrentData.VariableNVales["OnShock"], alert.CurrentData.VariableNVales["OnCharge"], alert.CurrentData.VariableNVales["OnDefence"], null, null, alert.CurrentData.VariableNVales["AlarmType"], null, alert.CurrentData.VariableNVales["DeviceDataTime"], (string.IsNullOrWhiteSpace(alert.CurrentData.VariableNVales["TrackerConnectedTime"]) ? (DateTime?)null : Convert.ToDateTime(alert.CurrentData.VariableNVales["TrackerConnectedTime"])), alert.CurrentData.VariableNVales["TrackerDataActionTime"], alert.CurrentData.VariableNVales["TrackerDataParsedTime"], alert.CurrentData.VariableNVales["ActionTime"], alert.Id, alert.IsSent, alert.SentTime, alert.ConditionState, alert.ConditionStateTime ); } List <TVParameter> TVParameters = new List <TVParameter>(); TVParameters.Add(new TVParameter() { ParameterName = "@AlertDataFromService", ParameterValue = AlertDataFromService, ParameterTypeName = "DeviceAlertDataType_V1", SqlDbType = SqlDbType.Structured }); Data.StoreData_ExecuteNonQuery(DataBase.Alert, CommandType.StoredProcedure, "A_StoreDeviceFiredAlerts", new SqlParameter[] { new SqlParameter("DeviceAlertId", alert.Id), new SqlParameter("AlertType", alert.AlarmType), new SqlParameter("Eval", alert.Eval), new SqlParameter("Status", alert.IsSent), new SqlParameter("ProcessorId", this.ProcessorId) }, TVParameters); } catch (Exception ex) { Console.WriteLine(ex); } finally { AlertDataFromService = null; } } }