public Response icar_SetCommArg(CmdParam.ParamType paramType_0, string string_1, string string_2, CmdParam.CommMode commMode_0, CommArgs commArgs_0) { Response response = new Response(); base.logMsg.FunctionName = "icar_SetCommArg"; base.logMsg.Msg = "发送:类型-" + paramType_0.ToString() + ",车辆-" + string_1; string str = string.Concat(new object[] { "通讯方式-", commArgs_0.CommMode.ToString(), ",TCPIP-", commArgs_0.strTCPIP, ",TCP端口-", commArgs_0.TCPPort, ",UDPIP-", commArgs_0.strUDPIP, ",UDP端口-", commArgs_0.UDPPort, ",拨号用户名-", commArgs_0.strUser, ",是否使用代理-", commArgs_0.IsUseProxy.ToString(), ",代理IP-", commArgs_0.strProxyIP, ",代理端口-", commArgs_0.TCPPort, ",服务器类型-", commArgs_0.ServerType }); base.logMsg.Msg = base.logMsg.Msg + "," + str; base.log.WriteLog(base.logMsg); if (!base.CheckCar(paramType_0, string_1, string_2)) { response.ErrorMsg = base.alarmMsg.AlarmText = base.ErrorMsg; base.log.WriteAlarm(base.alarmMsg); return response; } string strErrorMsg = string.Empty; if (commArgs_0.CheckData(out strErrorMsg) != 0) { response.ErrorMsg = strErrorMsg; return response; } if (base.isStartCommon()) { foreach (Bussiness.CarInfo info in base.carInfoList) { try { int newOrderId = SendBase.CarCmdSend.GetNewOrderId(); base.SaveCmdParm(newOrderId.ToString() + "|" + info.CarId.ToString() + ";"); string orderIDParam = response.OrderIDParam; response.OrderIDParam = orderIDParam + newOrderId.ToString() + "|" + info.CarId.ToString() + ";"; base.userInfo.DownCommd.AddCarNewLogData(newOrderId, info.CarNum, "发送", commArgs_0.OrderCode.ToString(), "等待", "", str); new Car().InsertComArsgIntoGisCar(info.CarId, base.WorkId.ToString(), newOrderId, (int) commArgs_0.CommMode, commArgs_0.strAPNAddr, commArgs_0.strUser, commArgs_0.strPassword, commArgs_0.strTCPIP, commArgs_0.TCPPort.ToString(), commArgs_0.strUDPIP, commArgs_0.UDPPort.ToString(), (int) commArgs_0.IsUseProxy, commArgs_0.strProxyIP, commArgs_0.ProxyPort.ToString(), commArgs_0.ServerType.ToString()); if (info.ProtocolName == SendBase.m_ProtocolName) { commArgs_0.TransformCode = CmdParam.TrafficProtocolCodeExchange((int) commArgs_0.OrderCode); string conntent = ""; string str4 = commArgs_0.ToXmlString(base.CalOrderId(base.WorkId, newOrderId), info.SimNum, SendBase.m_ProtocolName, (int) commMode_0, "SetCommArg", ref conntent); response.ResultCode = SendBase.CarCmdSend.icar_SendCmdXML(base.WorkId, newOrderId, info.SimNum, SendBase.m_ProtocolName, commArgs_0.TransformCode, (int) commMode_0, str4); } else { response.ResultCode = SendBase.CarCmdSend.icar_SetCommArg(base.WorkId, newOrderId, info.SimNum, commArgs_0.CommMode, commArgs_0.strAPNAddr, commArgs_0.strUser, commArgs_0.strPassword, commArgs_0.strTCPIP, commArgs_0.TCPPort, commArgs_0.strUDPIP, commArgs_0.UDPPort, commArgs_0.IsUseProxy, commArgs_0.strProxyIP, commArgs_0.ProxyPort); } if (response.ResultCode != 0L) { base.alarmMsg.FunctionName = "icar_SetCommArg"; base.alarmMsg.AlarmText = string.Concat(new object[] { "workid-", base.WorkId, ",simNum-", info.SimNum, ",OrderCode-", commArgs_0.OrderCode }); base.alarmMsg.Code = response.ResultCode.ToString(); base.log.WriteAlarm(base.alarmMsg); } response.ResultCode = 0L; } catch (Exception exception) { base.errMsg.ErrorText = "下发消息指令时发生错误!"; response.ErrorMsg = base.ErrorMsg = base.errMsg.ErrorText; base.log.WriteError(base.errMsg, exception); } } return response; } response.ErrorMsg = base.ErrorMsg; return response; }
private CommArgs GetCommArgs() { CommArgs args = new CommArgs { OrderCode = CmdParam.OrderCode.设置GPRS参数, ServerType = (this.cmbServerList.SelectedIndex == 0) ? 0 : 1 }; string s = "0"; if (this.rdoGprsCdma.Checked) { s = "1"; } else if (this.rdoMessage.Checked) { s = "0"; } else { s = "2"; } int num = int.Parse(s); args.CommMode = (CmdParam.CommMode) num; if (args.CommMode == CmdParam.CommMode.短信) { args.IsUseProxy = CmdParam.IsUseProxy.不使用代理; args.ProxyPort = 0; args.strAPNAddr = ""; args.strPassword = ""; args.strProxyIP = ""; args.strTCPIP = ""; args.strUDPIP = ""; args.strUser = ""; args.TCPPort = 0; args.UDPPort = 0; return args; } string text = this.cmbApnType.Text; if (string.IsNullOrEmpty(text)) { MessageBox.Show("请选择接入方式!"); this.cmbApnType.Focus(); return null; } args.strAPNAddr = text; string str3 = this.txtTcpIp.Text; string str4 = this.txtUdpIp.Text; if (string.IsNullOrEmpty(str3) && string.IsNullOrEmpty(str4)) { MessageBox.Show("请选择TCP/UDP地址!"); this.txtTcpIp.Focus(); return null; } if (!string.IsNullOrEmpty(str3)) { if (!Check.CheckIpAddress(str3)) { MessageBox.Show("TCPIP地址格式有误!"); this.txtTcpIp.Focus(); return null; } args.strTCPIP = str3; string str5 = this.txtTcpPort.Text; if (!string.IsNullOrEmpty(str5)) { try { args.TCPPort = int.Parse(str5); } catch { } } } if (!string.IsNullOrEmpty(str4)) { if (!Check.CheckIpAddress(str4)) { MessageBox.Show("UDPIP地址格式有误!"); this.txtUdpIp.Focus(); return null; } args.strUDPIP = str4; string str6 = this.txtUdpPort.Text; if (!string.IsNullOrEmpty(str6)) { try { args.UDPPort = int.Parse(str6); } catch { } } } if (this.txtUser.Text.Trim().Length == 0) { MessageBox.Show("请输入拨号用户名!"); this.txtUser.Focus(); return null; } if (this.txtPassword.Text.Trim().Length == 0) { MessageBox.Show("请输入拨号密码!"); this.txtPassword.Focus(); return null; } args.strUser = this.txtUser.Text.Trim(); args.strPassword = this.txtPassword.Text.Trim(); if (this.chkSurrogate.Checked) { args.IsUseProxy = CmdParam.IsUseProxy.使用代理; string strIpAddress = this.txtSurrogateIp.Text; if (!Check.CheckIpAddress(strIpAddress)) { MessageBox.Show("代理服务器IP地址格式有误!"); this.txtSurrogateIp.Focus(); return null; } args.strProxyIP = strIpAddress; string str8 = this.txtSurrogatePort.Text; if (!string.IsNullOrEmpty(str8)) { try { int result = 0; if (!int.TryParse(str8, out result)) { MessageBox.Show("代理服务器端口有误!"); this.txtSurrogatePort.Focus(); return null; } args.ProxyPort = result; return args; } catch { return args; } } MessageBox.Show("代理服务器端口有误!"); this.txtSurrogatePort.Focus(); return null; } args.IsUseProxy = CmdParam.IsUseProxy.不使用代理; return args; }
public static Response DownData_SetCommArg(CmdParam.ParamType ParamType, string CarValues, string CarPw, CmdParam.CommMode CommMode, CommArgs commArgs) { Response response; if (RemotingClient.app == null) { return RemotingClient.reResult; } try { response = RemotingClient.app.DownData_SetCommArg(ParamType, CarValues, CarPw, CommMode, commArgs); } catch (Exception exception) { Record.execFileRecord("配置终端通讯参数", exception.Message); response = RemotingClient.reResult; } return response; }
private void btnSendCommunication_Click(object sender, EventArgs e) { try { CommArgs commArgs = new CommArgs(); commArgs = this.GetCommArgs(); if (commArgs != null) { this.reResult = RemotingClient.DownData_SetCommArg(CmdParam.ParamType.CarId, this.sCarId, "", CmdParam.CommMode.未知方式, commArgs); if (this.reResult.ResultCode != 0L) { MessageBox.Show(this.reResult.ErrorMsg); } else { this.execSaveCmnParam(this.tpCommunication); this.showSucceedMsg(); } } } catch (Exception exception) { MessageBox.Show(exception.Message); } }
public Response DownData_SetCommArg(CmdParam.ParamType ParamType, string CarValues, string CarPw, CmdParam.CommMode CommMode, CommArgs commArgs) { try { return this.myDownData.icar_SetCommArg(ParamType, CarValues, CarPw, CommMode, commArgs); } catch (Exception exception) { this.m_LogHelper.WriteError(new ErrorMsg("RemotingServer", "DownData_SetCommArg", exception.ToString())); return new Response(); } }