//private void timer1_Tick(object sender, EventArgs e) //{ // timer1.Enabled = false; // show(); // timer1.Enabled = true; //} private void fthread() { dt = Model.RealInterfaceFuction.GetRealMac(); MethodInvoker In1 = new MethodInvoker(() => show()); this.BeginInvoke(In1); while (_isRun) { try { //DataTable dt = Model.RealInterfaceFuction.GetRealMac(); dt = Model.RealInterfaceFuction.GetRealMac(); //MethodInvoker In1 = new MethodInvoker(() => show()); //this.BeginInvoke(In1); for (int i = 0; i < dt.Rows.Count; i++) { NetDeviceSettingInfo tempNetInfo = _NetworkModuleService.GetNetworkModuletParameters(new NetworkModuletParametersGetRequest() { Mac = dt.Rows[i]["mac"].ToString() }).Data; if (tempNetInfo == null) { dt.Rows[i]["Switch1000State"] = "-"; dt.Rows[i]["Switch100State"] = "-"; dt.Rows[i]["Switch100RJ45State"] = "-"; continue; } string switch1000StateString = ""; if (tempNetInfo.NetSetting != null && tempNetInfo.NetSetting.Switch1000JkState != null) { for (int j = 0; j < tempNetInfo.NetSetting.Switch1000JkState.Length; j++) { switch1000StateString += "千兆光口" + (j + 1).ToString() + ":" + (tempNetInfo.NetSetting.Switch1000JkState[j] == 0 ? "断开" : "正常") + "\r\n"; } } dt.Rows[i]["Switch1000State"] = switch1000StateString == "" ? "-" : switch1000StateString; string switch100StateString = ""; if (tempNetInfo.NetSetting != null && tempNetInfo.NetSetting.Switch100JkState != null) { for (int j = 0; j < tempNetInfo.NetSetting.Switch100JkState.Length; j++) { switch100StateString += "百兆光口" + (j + 1).ToString() + ":" + (tempNetInfo.NetSetting.Switch100JkState[j] == 0 ? "断开" : "正常") + "\r\n"; } } dt.Rows[i]["Switch100State"] = switch100StateString == "" ? "-" : switch100StateString; string switch100RJ45State = ""; if (tempNetInfo.NetSetting != null && tempNetInfo.NetSetting.Switch100RJ45State != null) { for (int j = 0; j < tempNetInfo.NetSetting.Switch100RJ45State.Length; j++) { switch100RJ45State += "百兆电口" + (j + 1).ToString() + ":" + (tempNetInfo.NetSetting.Switch100RJ45State[j] == 0 ? "断开" : "正常") + "\r\n"; } } dt.Rows[i]["Switch100RJ45State"] = switch100RJ45State == "" ? "-" : switch100RJ45State; } In1 = new MethodInvoker(() => show()); this.BeginInvoke(In1); } catch (Exception ex) { Basic.Framework.Logging.LogHelper.Error(ex); } Thread.Sleep(15000); } }
private void barButtonISave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { if (!Basic.Framework.Common.ValidationHelper.IsRightIP(ipTxt.Text)) { XtraMessageBox.Show("分站IP输入不合法!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrEmpty(ymTxt.Text)) { XtraMessageBox.Show("子网掩码输入不合法!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!Basic.Framework.Common.ValidationHelper.IsRightIP(gatewayTxt.Text)) { XtraMessageBox.Show("网关地址输入不合法!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //if (!Basic.Framework.Common.ValidationHelper.IsNumber(CtxbSrvPort.Text)) //{ // XtraMessageBox.Show("服务端口输入不合法!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} //if (!Basic.Framework.Common.ValidationHelper.IsNumber(CtxbModulePort.Text)) //{ // XtraMessageBox.Show("模块端口输入不合法!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} NetDeviceSettingInfo pConvSetting = new NetDeviceSettingInfo(); pConvSetting.SockSetting = new SocketSetting[8]; pConvSetting.ComSetting = new ComSetting[8]; //目前主要设置交换机的IP、子网掩码、网关信息 pConvSetting.NetSetting = new Netsetting(); pConvSetting.NetSetting.IpAddr = ipTxt.Text; //模块 IP pConvSetting.NetSetting.SubMask = ymTxt.Text; //模块 子网掩码 pConvSetting.NetSetting.GatewayIp = gatewayTxt.Text; //模块 网关 pConvSetting.NetSetting.SetFzh = byte.Parse(fzhTxt.Text); //分站号 pConvSetting.NetSetting.srcPacket = null; pConvSetting.NetSetting.IsUseStaticIP = 1; pConvSetting.NetSetting.DnsIp = ""; //模块 DNS pConvSetting.NetSetting.NetWorkName = ""; //模块名称 pConvSetting.NetSetting.User = ""; //用户名 pConvSetting.NetSetting.PassWord = ""; //密码 if (Model.MACServiceModel.SetConvSetting(macTxt.Text, pConvSetting, 8000, "1")) { //CcmbIP.Text = CtxbModuleIP.Text; //设置网络模块参数成功的同时,更新缓存及数据库的模块IP地址 20171220 //if (CtxbModuleIP.Text != ModuleIPNow) //{ // //更新网络模块IP地址 // Jc_MacInfo ExistIPModule = Model.MACServiceModel.QueryMACByCode(_ArrPoint); // if (ExistIPModule != null) // { // //表示更新 // ExistIPModule.IP = CtxbModuleIP.Text; // ExistIPModule.InfoState = InfoState.Modified; // try // { // Model.MACServiceModel.UpdateMACCache(ExistIPModule); // } // catch (Exception ex) // { // XtraMessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; // } // ModuleIPNow = CtxbModuleIP.Text; // } //} isSerach = true; XtraMessageBox.Show("设置网络设备参数成功!", "提示"); } else { XtraMessageBox.Show("设置网络设备参数失败!", "警告"); } } catch (Exception ex) { LogHelper.Error("更新模块信息【barButtonISave_ItemClick】", ex); } }