protected virtual void OnMessageDataExchange(DispatchVehicleDataResp message) { var handler = DispatchVehicleDataRespExchange; if (handler != null) { handler(this, new DataExchangeRespEventArgs(message)); } }
public DataExchangeRespEventArgs(DispatchVehicleDataResp message) { DispatchVehicleDataRespMessage = message; }
/// <summary> /// 同步出车信息数据 /// </summary> public void SyncDispatchVehicleData(DispatchVehicleData DispatchVehicle, string UnitCode) { try { string strLcoalLSH = ""; string strTargetLSH = DispatchVehicle.DealRecordID; string strTargetCS = DispatchVehicle.Times; string strTargetCLBH = DispatchVehicle.VehicleCode; if (IsLWDD(DispatchVehicle.DealRecordID, UnitCode, ref strLcoalLSH)) { LogHelper.WriteLog("联网单需要更新CCXX,LSH:" + strLcoalLSH); CheckDispatchRecord(strLcoalLSH, DispatchVehicle.DispatchVehicleTime, UnitCode); CheckHJQY(strLcoalLSH, UnitCode); string strLocalCS = ""; string strLocalCLBH = ""; if (HasVehicleMatchRecord(DispatchVehicle.DealRecordID, DispatchVehicle.VehicleCode, DispatchVehicle.Times, UnitCode, ref strLocalCS, ref strLocalCLBH)) { LogHelper.WriteLog("进入HasVehicleMatchRecord=true,LSH:" + strLcoalLSH); string sql = "select * from ccxxb where lsh = '" + strLcoalLSH + "' and cs = '" + strLocalCS + "' and clbh = '" + strLocalCLBH + "'"; object obj = DB120Help.GetSingle(sql); //如果已经存在记录更新当前出车信息 if (obj != null) { DispatchVehicle.VehicleCode = strLocalCLBH; DispatchVehicle.DealRecordID = strLcoalLSH; DispatchVehicle.Times = strLocalCS; LogHelper.WriteLog("更新CCXXB,LSH:" + strLcoalLSH + ",CLBH:" + strLocalCLBH + ",CS:" + strLocalCS); ParameterSql parSql = SyncDataSql.GetUpadateCCXXBSql(DispatchVehicle); int i = DB120Help.ExecuteSql(parSql.StrSql, parSql.OrclPar); if (i == 0) { LogHelper.WriteLog("车辆信息数据更新本地库失败本地流水号:" + strLcoalLSH + " 车次:" + strLocalCS + " 车辆编号:" + strLocalCLBH); } else //成功更新车辆信息表中的车辆状态 { sql = "update clxxb set clzt ='" + DispatchVehicle.VehicleZT + "' where clbh= '" + strLocalCLBH + "'"; i = DB120Help.ExecuteSql(sql); if (i != 0) { LogHelper.WriteLog("车辆状态更新成功 车辆编号:" + strLocalCLBH); } DispatchVehicleDataResp Data = new DispatchVehicleDataResp(); Data.CommandID = DispatchVehicle.CommandID + "Resp"; Data.DealRecordID = strTargetLSH; Data.VehicleCode = strTargetCLBH; Data.Times = strTargetCS; Data.Result = 1; ExchangeDataResp(Data); } } } //未在联网信息关联表关联主键 需要插入记录,同时虚拟该车的车辆 else { LogHelper.WriteLog("进入HasVehicleMatchRecord=false,LSH:" + strLcoalLSH); strTargetLSH = DispatchVehicle.DealRecordID; strTargetCS = DispatchVehicle.Times; strTargetCLBH = DispatchVehicle.VehicleCode; if (hasInsertedDispatchVehicleRecord(DispatchVehicle, UnitCode, strLcoalLSH, ref strLocalCLBH, ref strLocalCS)) { //成功更新车辆信息表中的车辆状态 string sql = "update clxxb set clzt ='" + DispatchVehicle.VehicleZT + "' where clbh= '" + strLocalCLBH + "'"; int i = DB120Help.ExecuteSql(sql); if (i != 0) { LogHelper.WriteLog("车辆状态更新成功 车辆编号:" + strLocalCLBH); } //主键关联 sql = "insert into LWCLTBDYB (locallsh,localCS,localCLBH,TargetLSH,TargetCS,TargetCLBH,TargetDWBH) values ('" + strLcoalLSH + "','" + strLocalCS + "','" + strLocalCLBH + "','" + strTargetLSH + "','" + strTargetCS + "','" + strTargetCLBH + "','" + UnitCode + "')"; i = DB120Help.ExecuteSql(sql); if (i > 0) { LogHelper.WriteLog("车辆信息表主键关联成功本地流水号:" + strLcoalLSH + " 车次:" + strLocalCS + " 车辆编号:" + strLocalCLBH + " 关联的流水号:" + strTargetLSH + " 车次:" + strTargetCS + " 车辆编号:" + strTargetCLBH); } else { LogHelper.WriteLog("车辆信息表主键关联失败本地流水号:" + strLcoalLSH + " 车次:" + strLocalCS + " 车辆编号:" + strLocalCLBH + " 关联的流水号:" + strTargetLSH + " 车次:" + strTargetCS + " 车辆编号:" + strTargetCLBH); } DispatchVehicleDataResp Data = new DispatchVehicleDataResp(); Data.CommandID = DispatchVehicle.CommandID + "Resp"; Data.DealRecordID = strTargetLSH; Data.VehicleCode = strTargetCLBH; Data.Times = strTargetCS; Data.Result = 1; ExchangeDataResp(Data); } } } //非联网单直接更新不需要重发消息 else { DispatchVehicleDataResp Data = new DispatchVehicleDataResp(); Data.CommandID = DispatchVehicle.CommandID + "Resp"; Data.DealRecordID = strTargetLSH; Data.VehicleCode = strTargetCLBH; Data.Times = strTargetCS; Data.Result = 1; ExchangeDataResp(Data); } } catch (Exception ex) { DispatchVehicleDataResp Data = new DispatchVehicleDataResp(); Data.CommandID = DispatchVehicle.CommandID + "Resp"; Data.DealRecordID = DispatchVehicle.DealRecordID; Data.VehicleCode = DispatchVehicle.VehicleCode; Data.Times = DispatchVehicle.Times; Data.Result = 0; Data.FailtureReason = ex.Message; ExchangeDataResp(Data); LogHelper.WriteLog("", ex); } }
public SyncDataRespEventArgs(DispatchVehicleDataResp message) { DispatchVehicleDataRespMessage = message; }
private void ExchangeDataResp(DispatchVehicleDataResp message) { OnMessageDataExchange(message); }