private void btnAdd_Click(object sender, RoutedEventArgs e) { try { if (cbxMode.SelectedIndex < 0) { cbxMode.Focus(); cbxMode.IsDropDownOpen = true; MessageBox.Show("请选择该设备的制式!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (MessageBox.Show("确定添加设备[" + JsonInterFace.LteDeviceParameter.DeviceName + "]?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK) { if (NetWorkClient.ControllerServer.Connected) { Parameters.ConfigType = "Manul"; NetWorkClient.ControllerServer.Send(JsonInterFace.AddDeviceNameRequest(JsonInterFace.LteDeviceParameter.DomainFullPathName, JsonInterFace.LteDeviceParameter.DeviceName, JsonInterFace.LteDeviceParameter.DeviceMode)); } else { MessageBox.Show("网络与有服务器断开!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } } } catch (Exception ex) { Parameters.PrintfLogsExtended(ex.Message, ex.StackTrace); } }
private void btnEnter_Click(object sender, RoutedEventArgs e) { try { TreeViewNodeInfoClass.IsStation = (bool)chkStation.IsChecked; if (TreeViewNodeInfoClass.NodeName.Trim().Equals("")) { MessageBox.Show("请输入域名称!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } else { if (!NetWorkClient.ControllerServer.Connected) { MessageBox.Show("网络已断开!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } else { if (regexDomain.Match(TreeViewNodeInfoClass.NodeName).Success) { JsonInterFace.ShowMessage("输入的域名称格式非法,域名只能为[128位以下划线开头的字母或中文或英文组成的名称]!", 16); return; } //添加域名 if (TreeViewNodeInfoClass.Operation == DeviceTreeOperation.DomainAdd) { Parameters.DomainActionInfoClass.SelfID += 1; Parameters.DomainActionInfoClass.SelfName = TreeViewNodeInfoClass.NodeName; Parameters.DomainActionInfoClass.NodeContent = TreeViewNodeInfoClass.DesInfo; Parameters.DomainActionInfoClass.IsStation = (Convert.ToInt32((bool)chkStation.IsChecked)).ToString(); NetWorkClient.ControllerServer.Send(JsonInterFace.AddDomainNodeName(TreeViewNodeInfoClass.FullNodeName, TreeViewNodeInfoClass.NodeName, Convert.ToInt32(TreeViewNodeInfoClass.IsStation), txtDesContent.Text)); //添加经纬度 if (TreeViewNodeInfoClass.IsStation && txtLngContent.Text != "" & txtLatContent.Text != "") { Regex re = new Regex(@"^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$"); if (!re.IsMatch(txtLngContent.Text) || !re.IsMatch(txtLatContent.Text)) { MessageBox.Show("经纬度输入格式有误", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } NetWorkClient.ControllerServer.Send(JsonInterFace.Set_station_location_Request(TreeViewNodeInfoClass.FullNodeName, TreeViewNodeInfoClass.NodeName, JsonInterFace.StationMap.Lng, JsonInterFace.StationMap.Lat)); } } //重命名域名 else if (TreeViewNodeInfoClass.Operation == DeviceTreeOperation.DomainReName) { string oldDomainName = TreeViewNodeInfoClass.FullNodeName; string newDomainName = string.Empty; string[] tmpDomainName = oldDomainName.Split(new char[] { '.' }); if (!Parameters.DomainActionInfoClass.SelfID.Equals(1)) { for (int i = 0; i < tmpDomainName.Length - 1; i++) { if (!newDomainName.Trim().Equals("")) { newDomainName += "." + tmpDomainName[i]; } else { newDomainName += tmpDomainName[i]; } } newDomainName = newDomainName + "." + TreeViewNodeInfoClass.NodeName; Parameters.DomainActionInfoClass.OldFullDomainName = oldDomainName; Parameters.DomainActionInfoClass.SelfName = txtInputContent.Text; Parameters.DomainActionInfoClass.NodeContent = txtInputContent.Text; Parameters.DomainActionInfoClass.AliasName = txtDesContent.Text; Parameters.DomainActionInfoClass.PathName = newDomainName; Parameters.DomainActionInfoClass.NewFullDomainName = newDomainName; Parameters.DomainActionInfoClass.IsStation = (Convert.ToInt32((bool)chkStation.IsChecked)).ToString(); if (NetWorkClient.ControllerServer.Connected) { //判断域名是否修改,如果没有修改就更新备注或者是否站点(需增加接口支持) NetWorkClient.ControllerServer.Send(JsonInterFace.ReNameDomainNodeName(oldDomainName, newDomainName, Convert.ToInt32(Parameters.DomainActionInfoClass.IsStation), Parameters.DomainActionInfoClass.AliasName)); } else { JsonInterFace.ShowMessage("网络与服务器断开!", (int)WindowMessageType.Warnning); } } else { JsonInterFace.ShowMessage("该主域名称不能修改!", (int)WindowMessageType.Warnning); } //添加经纬度 if (TreeViewNodeInfoClass.IsStation && txtLngContent.Text != "" & txtLatContent.Text != "") { string ParentName = string.Empty; Regex re = new Regex(@"^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$"); for (int i = 0; i < TreeViewNodeInfoClass.FullNodeName.Split(new char[] { '.' }).Length - 1; i++) { if (i == 0) { ParentName += TreeViewNodeInfoClass.FullNodeName.Split(new char[] { '.' })[i]; } else { ParentName += "." + TreeViewNodeInfoClass.FullNodeName.Split(new char[] { '.' })[i]; } } if (!re.IsMatch(txtLngContent.Text) || !re.IsMatch(txtLatContent.Text)) { MessageBox.Show("经纬度输入格式有误", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } NetWorkClient.ControllerServer.Send(JsonInterFace.Set_station_location_Request(ParentName, TreeViewNodeInfoClass.NodeName, JsonInterFace.StationMap.Lng, JsonInterFace.StationMap.Lat)); } } else if (TreeViewNodeInfoClass.Operation == DeviceTreeOperation.DeviceAdd) { Parameters.DeviceActionInfoClass.SelfID = Parameters.DomainActionInfoClass.SelfID.ToString(); Parameters.DeviceActionInfoClass.ParentID = Parameters.DomainActionInfoClass.ParentID.ToString(); Parameters.DeviceActionInfoClass.DeviceName = txtInputContent.Text.Trim(); Parameters.DeviceActionInfoClass.DomainFullName = TreeViewNodeInfoClass.FullNodeName; NetWorkClient.ControllerServer.Send(JsonInterFace.AddDeviceNameRequest(Parameters.DeviceActionInfoClass.DomainFullName, Parameters.DeviceActionInfoClass.DeviceName, Parameters.DeviceActionInfoClass.Mode)); } } } } catch (Exception ex) { Parameters.PrintfLogsExtended(ex.Message, ex.StackTrace); } }