public static AlarmCarInfo getAlarmCar(int carid, int pathid, DateTime StartTime, DateTime EndTime) { AlarmCarInfo alarmCarInfo = new AlarmCarInfo() { carid = carid }; alarmCarInfo.StartTime.Add(StartTime); alarmCarInfo.EndTime.Add(EndTime); alarmCarInfo.pathid.Add(pathid); return alarmCarInfo; }
public static AlarmCarInfo getAlarmCar(int carid, int pathid, DateTime StartTime, DateTime EndTime) { AlarmCarInfo alarmCarInfo = new AlarmCarInfo() { carid = carid }; alarmCarInfo.StartTime.Add(StartTime); alarmCarInfo.EndTime.Add(EndTime); alarmCarInfo.pathid.Add(pathid); return(alarmCarInfo); }
private void tCheckPathAlarm_Elapsed(object sender, ElapsedEventArgs e) { this.tCheckPathAlarm.Enabled = false; try { try { PlatformAlarmRegionAlarm platformAlarmRegionAlarm = new PlatformAlarmRegionAlarm(); this.clearAlarmCar(); this.dtConfigInfo = this.getConfigInfo(); if (this.dtConfigInfo != null && this.dtConfigInfo.Rows.Count > 0) { foreach (DataRow row in this.dtConfigInfo.Rows) { DateTime dateTime = Convert.ToDateTime(row["BeginTime"]); DateTime dateTime1 = Convert.ToDateTime(row["EndTime"]); DateTime dateTime2 = Convert.ToDateTime(row["gpsTime"]); if (!platformAlarmRegionAlarm.IsInConfigTime(dateTime, dateTime1, this.dtNow) || !platformAlarmRegionAlarm.IsInConfigTime(dateTime, dateTime1, dateTime2) || dateTime2.Date != this.dtNow.Date) { continue; } int num = Convert.ToInt32(row["carid"]); int num1 = Convert.ToInt32(row["PathID"]); if (this.htCarPathInfo[num] == null) { this.htCarPathInfo[num] = ""; } try { if (this.htAlarmList[num] != null) { this.htAlarmList[num] = (this.htAlarmList[num] as AlarmCarInfo).updateAlarmCar(num, num1, dateTime, dateTime1); } else { this.htAlarmList[num] = AlarmCarInfo.getAlarmCar(num, num1, dateTime, dateTime1); } } catch (Exception exception1) { Exception exception = exception1; ErrorMsg errorMsg = new ErrorMsg("PlatformAlarmPathAlarm", "tCheckPathAlarm_Elapsed", string.Concat("保存报警车辆信息,", exception.Message)); this.logHelper.WriteError(errorMsg); } if (row["Longitude"] == DBNull.Value || row["Latitude"] == DBNull.Value || double.Parse(row["Longitude"].ToString()) < 0.001 || double.Parse(row["Latitude"].ToString()) < 0.001) { if (this.htCarPathInfo.Contains(num)) { this.htCarPathInfo.Remove(num); } LogMsg logMsg = new LogMsg("PlatformAlarmPathAlarm", "tCheckPathAlarm_Elapsed", ""); object[] str = new object[] { "carid:", num, ",pathId:", num1.ToString(), ",simnum:", row["simnum"].ToString(), ",轨迹不存在或为0" }; logMsg.Msg = string.Concat(str); this.logHelper.WriteLog(logMsg); } else if (row["alarmpathdot"] == DBNull.Value || string.IsNullOrEmpty(row["alarmpathdot"].ToString())) { if (this.htCarPathInfo.Contains(num)) { this.htCarPathInfo.Remove(num); } LogMsg logMsg1 = new LogMsg("PlatformAlarmPathAlarm", "tCheckPathAlarm_Elapsed", ""); object[] objArray = new object[] { "carid:", num, ",pathId:", num1.ToString(), ",simnum:", row["simnum"].ToString(), ",路线不存在" }; logMsg1.Msg = string.Concat(objArray); this.logHelper.WriteLog(logMsg1); } else { Hashtable hashtables = this.htCarPathInfo; Hashtable hashtables1 = hashtables; object obj = num; object item = hashtables1[obj]; object[] str1 = new object[] { item, num1, ":", row["alarmpathdot"].ToString(), ";" }; hashtables[obj] = string.Concat(str1); this.htCarPosInfo[num] = string.Concat(row["Longitude"].ToString(), "*", row["Latitude"].ToString()); } } this.setInputXML(); this.CheckAndAnalysis(); } } catch (Exception exception3) { Exception exception2 = exception3; ErrorMsg errorMsg1 = new ErrorMsg("PlatformAlarmPathAlarm", "tCheckPathAlarm_Elapsed", string.Concat("检测偏移路线报警错误,", exception2.Message)); this.logHelper.WriteError(errorMsg1); } } finally { this.htCarPathInfo.Clear(); this.htCarPosInfo.Clear(); this.xDoc = null; this.tCheckPathAlarm.Enabled = true; } }
private void clearAlarmCar() { try { DataTable dataBySql = SqlDataAccess.getDataBySql(" select * from GpsJtbCarPathAlarm_Platform "); if (dataBySql == null || dataBySql.Rows.Count <= 0) { this.htAlarmList.Clear(); } List <int> nums = new List <int>(); Hashtable hashtables = new Hashtable(); foreach (int key in this.htAlarmList.Keys) { if (hashtables[key] == null) { hashtables[key] = ""; } List <DateTime> startTime = (this.htAlarmList[key] as AlarmCarInfo).StartTime; List <DateTime> endTime = (this.htAlarmList[key] as AlarmCarInfo).EndTime; if ((int)dataBySql.Select(string.Concat("carid = ", key)).Length <= 0 || !this.getIsInTime(startTime, endTime)) { nums.Add(key); } else { foreach (int item in (this.htAlarmList[key] as AlarmCarInfo).pathid) { object[] objArray = new object[] { "pathid = ", item, " and carid = ", key }; if ((int)dataBySql.Select(string.Concat(objArray)).Length > 0) { continue; } Hashtable hashtables1 = hashtables; Hashtable hashtables2 = hashtables1; object obj = key; object obj1 = obj; hashtables1[obj] = string.Concat(hashtables2[obj1], item.ToString(), ","); } if (hashtables[key] == null) { continue; } object obj2 = key; string str = hashtables[key].ToString(); char[] chrArray = new char[] { ',' }; hashtables[obj2] = str.Trim(chrArray); } } foreach (int num in nums) { if (!this.htAlarmList.Contains(num)) { continue; } this.htAlarmList.Remove(num); } foreach (int key1 in hashtables.Keys) { string str1 = hashtables[key1].ToString(); char[] chrArray1 = new char[] { ',' }; string[] strArrays = str1.Split(chrArray1, StringSplitOptions.RemoveEmptyEntries); AlarmCarInfo alarmCarInfo = this.htAlarmList[key1] as AlarmCarInfo; if (alarmCarInfo == null) { continue; } string[] strArrays1 = strArrays; for (int i = 0; i < (int)strArrays1.Length; i++) { int num1 = Convert.ToInt32(strArrays1[i]); if (alarmCarInfo.pathid.Contains(num1)) { alarmCarInfo.pathid.Remove(num1); } } } } catch (Exception exception1) { Exception exception = exception1; ErrorMsg errorMsg = new ErrorMsg("PlatformAlarmPathAlarm", "clearAlarmCar", string.Concat("清除内存数据,", exception.Message)); this.logHelper.WriteError(errorMsg); } }