public static AlarmBus getAlarmBus(string routeId, string simnum, int fat, int bat, string lineId) { AlarmBus alarmBu = new AlarmBus() { RouteId = routeId, SimNum = simnum, FrontAlarmType = fat, BackAlarmType = bat, LineId = lineId }; return(alarmBu); }
public static AlarmBus getAlarmBus(string routeId, string simnum, int fat, int bat, string lineId) { AlarmBus alarmBu = new AlarmBus() { RouteId = routeId, SimNum = simnum, FrontAlarmType = fat, BackAlarmType = bat, LineId = lineId }; return alarmBu; }
private void AnalysisOutputXML(string outXML) { try { DateTime now = DateTime.Now; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(outXML); XmlNode xmlNodes = xmlDocument.SelectSingleNode("//BusRoutes"); if (xmlNodes == null) { ErrorMsg errorMsg = new ErrorMsg("SeparateAndSticky", "AnalysisOutputXML", "") { ErrorText = "返回的xml错误,不包含BusRoutes节点" }; this.logHelper.WriteError(errorMsg); } else { bool flag = false; string value = ""; string str = ""; int num = 0; int num1 = 0; string value1 = ""; foreach (XmlElement childNode in xmlNodes.ChildNodes) { value = childNode.Attributes["id"].Value; XmlElement itemOf = (XmlElement)childNode.GetElementsByTagName("Buses")[0]; if (itemOf == null) { continue; } foreach (XmlElement xmlElement in itemOf.ChildNodes) { str = xmlElement.Attributes["simNum"].Value; value1 = xmlElement.Attributes["lineId"].Value; if (xmlElement.Attributes["frontAlarmType"].Value != "0" && (this.htAlarmList[string.Concat(str, "-0")] == null || now.Subtract(Convert.ToDateTime(this.htAlarmList[string.Concat(str, "-0")])).TotalSeconds >= (double)this.AlarmInterval)) { flag = true; num = Convert.ToInt32(xmlElement.Attributes["frontAlarmType"].Value); this.htAlarmList[string.Concat(str, "-0")] = now; } if (xmlElement.Attributes["backAlarmType"].Value != "0" && (this.htAlarmList[string.Concat(str, "-1")] == null || now.Subtract(Convert.ToDateTime(this.htAlarmList[string.Concat(str, "-1")])).TotalSeconds >= (double)this.AlarmInterval)) { flag = true; num1 = Convert.ToInt32(xmlElement.Attributes["backAlarmType"].Value); this.htAlarmList[string.Concat(str, "-1")] = now; } if (!flag) { continue; } flag = false; this.ltAlarmBus.Add(AlarmBus.getAlarmBus(value, str, num, num1, value1)); } } } } catch (Exception exception1) { Exception exception = exception1; ErrorMsg errorMsg1 = new ErrorMsg("SeparateAndSticky", "AnalysisOutputXML", string.Concat("解析返回的xml错误,", exception.Message)); this.logHelper.WriteError(errorMsg1); } }
private void InsertAlarmInfo(DataRow dr, AlarmBus ab) { try { int num = 0; string empty = string.Empty; int num1 = Convert.ToInt32(dr["carstatu"]); long num2 = (long)0; num2 = (dr["carstatuex"] == DBNull.Value || dr["carstatuex"].ToString().Equals("") ? 18014398509481984L : 18014398509481984L | Convert.ToInt64(dr["carstatuex"])); int num3 = 1154; int num4 = 65; string str = string.Empty; string str1 = "M13"; string str2 = ""; if (ab.FrontAlarmType == 1 || ab.BackAlarmType == 1) { str2 = string.Concat(str2, "脱车、"); } if (ab.FrontAlarmType == 2 || ab.BackAlarmType == 2) { str2 = string.Concat(str2, "粘车"); } string str3 = ""; string[] strArrays = new string[5]; char[] chrArray = new char[] { '、' }; strArrays[0] = str2.Trim(chrArray); strArrays[1] = ",路线: "; strArrays[2] = this.htRouteList[ab.RouteId].ToString(); strArrays[3] = (ab.LineId.Equals("0") ? " 上行" : " 下行"); strArrays[4] = "方向"; str2 = string.Concat(strArrays); byte[] bytes = Encoding.GetEncoding("gb2312").GetBytes(str2); for (int i = 0; i < (int)bytes.Length; i++) { str3 = string.Concat(str3, bytes[i].ToString("X2")); } str1 = string.Concat(str1, str3); string str4 = null; bool flag = false; string str5 = null; int num5 = 0; try { SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("@wrkid", (object)num), new SqlParameter("@orderid", dr["OrderId"]), new SqlParameter("@userid", empty), new SqlParameter("@telephone", dr["telephone"]), new SqlParameter("@msgType", (object)num4), new SqlParameter("@recetime", dr["ReceTime"]), new SqlParameter("@gpstime", dr["GpsTime"]), new SqlParameter("@starCondition", dr["StarCondition"]), new SqlParameter("@starNum", dr["StarNum"]), new SqlParameter("@carStatu", (object)num1), new SqlParameter("@carStatuEx", (object)num2), new SqlParameter("@carCondition", dr["CarCondition"]), new SqlParameter("@Longitude", dr["Longitude"]), new SqlParameter("@Latitude", dr["Latitude"]), new SqlParameter("@direct", dr["Direct"]), new SqlParameter("@speed", dr["Speed"]), new SqlParameter("@Reserved", (object)num3), new SqlParameter("@TransportStatus", dr["TransportStatus"]), new SqlParameter("@Accelerration", dr["Accelerration"]), new SqlParameter("@Altitude", dr["Altitude"]), new SqlParameter("@DistanceDiff", dr["DistanceDiff"]), new SqlParameter("@commflag", dr["CommFlag"]), new SqlParameter("@addType", dr["AddMsgType"]), new SqlParameter("@addTxt", str1), new SqlParameter("@DutyStr", str4), new SqlParameter("@isPic", (object)flag), new SqlParameter("@pic", str5), new SqlParameter("@alarmInfo", str), new SqlParameter("@cameraID", (object)num5) }; string str6 = "GpsPicServer_ReceBuffer_Insert"; string str7 = "GpsPicServer_RealTime_Insert"; int num6 = SqlDataAccess.insertBySp(str6, sqlParameter); if (num6 > 0) { LogMsg logMsg = new LogMsg("SeparateAndSticky", "InsertAlarmInfo", "") { Msg = string.Concat("车载电话为:", dr["telephone"].ToString(), "的报警报文已插入gpsrecebuffer") }; this.logHelper.WriteLog(logMsg); } else { ErrorMsg errorMsg = new ErrorMsg("SeparateAndSticky", "InsertAlarmInfo", string.Concat("将报警报文插入gpsrecbuffer表错误,返回值!", num6.ToString())); this.logHelper.WriteError(errorMsg); } int num7 = SqlDataAccess.insertBySp(str7, sqlParameter); if (num7 > 0) { LogMsg logMsg1 = new LogMsg("PlatformAlarmPathAlarm", "InsertAlarmInfo", string.Concat("车载电话为:", dr["telephone"].ToString(), "的脱车粘车报警报文已插入gpsrecerealtime")) { Msg = string.Concat("车载电话为:", dr["telephone"].ToString(), "的脱车粘车报警报文已插入gpsrecerealtime") }; this.logHelper.WriteLog(logMsg1); } else { ErrorMsg errorMsg1 = new ErrorMsg("PlatformAlarmPathAlarm", "InsertAlarmInfo", string.Concat("将脱车粘车报警报文插入gpsrecerealtime_buffer表发生错误,返回值!", num7.ToString())); this.logHelper.WriteError(errorMsg1); } } catch (Exception exception1) { Exception exception = exception1; ErrorMsg errorMsg2 = new ErrorMsg("SeparateAndSticky", "InsertAlarmInfo", string.Concat("车载电话为:", dr["telephone"].ToString(), "的报警报文插入数据库发生错误! 信息:", exception.Message)); this.logHelper.WriteError(errorMsg2); } } catch (Exception exception3) { Exception exception2 = exception3; LogHelper logHelper = new LogHelper(); ErrorMsg errorMsg3 = new ErrorMsg("SeparateAndSticky", "InsertAlarmInfo", string.Concat("将报警报文插入gpsrecbuffer表 、gpsrecerealtime_buffer表发生错误!", exception2.Message)); logHelper.WriteError(errorMsg3); } }
private void InsertAlarmInfo(DataRow dr, AlarmBus ab) { try { int num = 0; string empty = string.Empty; int num1 = Convert.ToInt32(dr["carstatu"]); long num2 = (long)0; num2 = (dr["carstatuex"] == DBNull.Value || dr["carstatuex"].ToString().Equals("") ? 18014398509481984L : 18014398509481984L | Convert.ToInt64(dr["carstatuex"])); int num3 = 1154; int num4 = 65; string str = string.Empty; string str1 = "M13"; string str2 = ""; if (ab.FrontAlarmType == 1 || ab.BackAlarmType == 1) { str2 = string.Concat(str2, "脱车、"); } if (ab.FrontAlarmType == 2 || ab.BackAlarmType == 2) { str2 = string.Concat(str2, "粘车"); } string str3 = ""; string[] strArrays = new string[5]; char[] chrArray = new char[] { '、' }; strArrays[0] = str2.Trim(chrArray); strArrays[1] = ",路线: "; strArrays[2] = this.htRouteList[ab.RouteId].ToString(); strArrays[3] = (ab.LineId.Equals("0") ? " 上行" : " 下行"); strArrays[4] = "方向"; str2 = string.Concat(strArrays); byte[] bytes = Encoding.GetEncoding("gb2312").GetBytes(str2); for (int i = 0; i < (int)bytes.Length; i++) { str3 = string.Concat(str3, bytes[i].ToString("X2")); } str1 = string.Concat(str1, str3); string str4 = null; bool flag = false; string str5 = null; int num5 = 0; try { SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("@wrkid", (object)num), new SqlParameter("@orderid", dr["OrderId"]), new SqlParameter("@userid", empty), new SqlParameter("@telephone", dr["telephone"]), new SqlParameter("@msgType", (object)num4), new SqlParameter("@recetime", dr["ReceTime"]), new SqlParameter("@gpstime", dr["GpsTime"]), new SqlParameter("@starCondition", dr["StarCondition"]), new SqlParameter("@starNum", dr["StarNum"]), new SqlParameter("@carStatu", (object)num1), new SqlParameter("@carStatuEx", (object)num2), new SqlParameter("@carCondition", dr["CarCondition"]), new SqlParameter("@Longitude", dr["Longitude"]), new SqlParameter("@Latitude", dr["Latitude"]), new SqlParameter("@direct", dr["Direct"]), new SqlParameter("@speed", dr["Speed"]), new SqlParameter("@Reserved", (object)num3), new SqlParameter("@TransportStatus", dr["TransportStatus"]), new SqlParameter("@Accelerration", dr["Accelerration"]), new SqlParameter("@Altitude", dr["Altitude"]), new SqlParameter("@DistanceDiff", dr["DistanceDiff"]), new SqlParameter("@commflag", dr["CommFlag"]), new SqlParameter("@addType", dr["AddMsgType"]), new SqlParameter("@addTxt", str1), new SqlParameter("@DutyStr", str4), new SqlParameter("@isPic", (object)flag), new SqlParameter("@pic", str5), new SqlParameter("@alarmInfo", str), new SqlParameter("@cameraID", (object)num5) }; string str6 = "GpsPicServer_ReceBuffer_Insert"; string str7 = "GpsPicServer_RealTime_Insert"; int num6 = SqlDataAccess.insertBySp(str6, sqlParameter); if (num6 > 0) { LogMsg logMsg = new LogMsg("SeparateAndSticky", "InsertAlarmInfo", "") { Msg = string.Concat("车载电话为:", dr["telephone"].ToString(), "的报警报文已插入gpsrecebuffer") }; this.logHelper.WriteLog(logMsg); } else { ErrorMsg errorMsg = new ErrorMsg("SeparateAndSticky", "InsertAlarmInfo", string.Concat("将报警报文插入gpsrecbuffer表错误,返回值!", num6.ToString())); this.logHelper.WriteError(errorMsg); } int num7 = SqlDataAccess.insertBySp(str7, sqlParameter); if (num7 > 0) { LogMsg logMsg1 = new LogMsg("PlatformAlarmPathAlarm", "InsertAlarmInfo", string.Concat("车载电话为:", dr["telephone"].ToString(), "的脱车粘车报警报文已插入gpsrecerealtime")) { Msg = string.Concat("车载电话为:", dr["telephone"].ToString(), "的脱车粘车报警报文已插入gpsrecerealtime") }; this.logHelper.WriteLog(logMsg1); } else { ErrorMsg errorMsg1 = new ErrorMsg("PlatformAlarmPathAlarm", "InsertAlarmInfo", string.Concat("将脱车粘车报警报文插入gpsrecerealtime_buffer表发生错误,返回值!", num7.ToString())); this.logHelper.WriteError(errorMsg1); } } catch (Exception exception1) { Exception exception = exception1; ErrorMsg errorMsg2 = new ErrorMsg("SeparateAndSticky", "InsertAlarmInfo", string.Concat("车载电话为:", dr["telephone"].ToString(), "的报警报文插入数据库发生错误! 信息:", exception.Message)); this.logHelper.WriteError(errorMsg2); } } catch (Exception exception3) { Exception exception2 = exception3; LogHelper logHelper = new LogHelper(); ErrorMsg errorMsg3 = new ErrorMsg("SeparateAndSticky", "InsertAlarmInfo", string.Concat("将报警报文插入gpsrecbuffer表 、gpsrecerealtime_buffer表发生错误!", exception2.Message)); logHelper.WriteError(errorMsg3); } }