예제 #1
0
 private void btnSetLngLat_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (StructureInfo.ParentName != "" || StructureInfo.ParentName != null)
         {
             mapweb.InvokeScript("deleteAllMarker");
             mapweb.InvokeScript("setStructureNodePoint", new Object[] { StructureInfo.Tmplng, StructureInfo.Tmplat, StructureInfo.MarkerTitle });
             var ParentName = string.Empty;
             for (int i = 0; i < StructureInfo.ParentName.Split(new char[] { '.' }).Length - 1; i++)
             {
                 if (i == 0)
                 {
                     ParentName += StructureInfo.ParentName.Split(new char[] { '.' })[i];
                 }
                 else
                 {
                     ParentName += "." + StructureInfo.ParentName.Split(new char[] { '.' })[i];
                 }
             }
             if (NetWorkClient.ControllerServer.Connected)
             {
                 NetWorkClient.ControllerServer.Send(JsonInterFace.Set_station_location_Request(ParentName, StructureInfo.MarkerTitle, StructureInfo.Tmplng, StructureInfo.Tmplat));
             }
             else
             {
                 Parameters.PrintfLogsExtended("网络与服务器断开!", "Connected: Failed!");
             }
         }
         else
         {
             MessageBox.Show("请先选择站点");
         }
     }
     catch (Exception ex)
     {
         Parameters.PrintfLogsExtended("手动设置站点位置事件:", ex.Message, ex.StackTrace);
     }
 }
예제 #2
0
        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);
            }
        }
예제 #3
0
 private void AddStructureNode()
 {
     Thread.Sleep(5000);
     while (true)
     {
         try
         {
             if (ThreadFlag)
             {
                 Dispatcher.Invoke(() =>
                 {
                     string Point = mapweb.InvokeScript("getPoint").ToString();
                     if (Point != null && Point.Length > 0)
                     {
                         StructureInfo.Tmplng = Point.Split(new char[] { ',' })[0];
                         StructureInfo.Tmplat = Point.Split(new char[] { ',' })[1];
                     }
                     string StructureInfostr = mapweb.InvokeScript("getPointInfo").ToString();
                     if (StructureInfostr != null && StructureInfostr.Length > 0)
                     {
                         if (StructureInfostr.Split(new char[] { ',' }).Length > 1)
                         {
                             StructureInfo.ParentName  = ((CheckBoxTreeModel)(DeviceTreeViewItem[0] as CheckBox).DataContext).FullName;
                             StructureInfo.MarkerTitle = ((CheckBoxTreeModel)(DeviceTreeViewItem[0] as CheckBox).DataContext).Name;
                             string[] name             = StructureInfo.ParentName.Split(new char[] { '.' });
                             string ParentName         = string.Empty;
                             for (int i = 0; i < name.Length - 1; i++)
                             {
                                 if (i == 0)
                                 {
                                     ParentName += name[i];
                                 }
                                 else
                                 {
                                     ParentName += "." + name[i];
                                 }
                             }
                             StructureInfo.Tmplng       = StructureInfostr.Split(new char[] { ',' })[0];
                             StructureInfo.Tmplat       = StructureInfostr.Split(new char[] { ',' })[1];
                             StructureInfo.SetExistence = Convert.ToBoolean(StructureInfostr.Split(new char[] { ',' })[2]);
                             if (NetWorkClient.ControllerServer.Connected)
                             {
                                 //添加域(不重复实现)
                                 //NetWorkClient.ControllerServer.Send(JsonInterFace.AddDomainNodeName(StructureInfo.ParentName, StructureInfo.MarkerTitle, Convert.ToInt32(StructureInfo.IsStation), StructureInfo.Des));
                                 //如果添加站点,则保存位置
                                 if (StructureInfo.SetExistence)
                                 {
                                     NetWorkClient.ControllerServer.Send(JsonInterFace.Set_station_location_Request(ParentName, StructureInfo.MarkerTitle, StructureInfo.Tmplng, StructureInfo.Tmplat));
                                 }
                             }
                             else
                             {
                                 Parameters.PrintfLogsExtended("网络与服务器断开!", "Connected: Failed!");
                             }
                         }
                     }
                 });
             }
         }
         catch (Exception ex)
         {
             Parameters.PrintfLogsExtended("添加站点错误", ex.Message, ex.StackTrace);
         }
         Thread.Sleep(50);
     }
 }