コード例 #1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("确定保存服务器基本参数?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK)
            {
                //检测数据正确性
                if (!Parameters.IsIP((object)Parameters.ServerBaseParameter.StrDbIpAddr))
                {
                    JsonInterFace.ShowMessage("数据库IP地址非法!", 16); return;
                }
                if (!Parameters.IsIP((object)Parameters.ServerBaseParameter.StrFtpIpAddr))
                {
                    JsonInterFace.ShowMessage("FTP服务器IP地址非法!", 16); return;
                }

                if (!Parameters.ISDigital(Parameters.ServerBaseParameter.StrFtpPort))
                {
                    JsonInterFace.ShowMessage("FTP服务器端口非法!", 16);
                    return;
                }
                else
                {
                    if (int.Parse(Parameters.ServerBaseParameter.StrFtpPort) < 1 || int.Parse(Parameters.ServerBaseParameter.StrFtpPort) > 65535)
                    {
                        JsonInterFace.ShowMessage("FTP服务器端口非法!", 16);
                        return;
                    }
                }
                if (!Parameters.ISDigital(Parameters.ServerBaseParameter.StrStartPortCDMA_ZYF))
                {
                    JsonInterFace.ShowMessage("CDMA监听端口非法!", 16);
                    return;
                }
                else
                {
                    if (int.Parse(Parameters.ServerBaseParameter.StrStartPortCDMA_ZYF) < 1 || int.Parse(Parameters.ServerBaseParameter.StrStartPortCDMA_ZYF) > 65535)
                    {
                        JsonInterFace.ShowMessage("CDMA监听端口非法!", 16);
                        return;
                    }
                }

                if (!Parameters.ISDigital(Parameters.ServerBaseParameter.StrStartPortGSM_ZYF))
                {
                    JsonInterFace.ShowMessage("GSMV2监听端口非法!", 16);
                    return;
                }
                else
                {
                    if (int.Parse(Parameters.ServerBaseParameter.StrStartPortGSM_ZYF) < 1 || int.Parse(Parameters.ServerBaseParameter.StrStartPortGSM_ZYF) > 65535)
                    {
                        JsonInterFace.ShowMessage("GSMV2监听端口非法!", 16);
                        return;
                    }
                }

                if (!Parameters.ISDigital(Parameters.ServerBaseParameter.StrStartPortGSM_HJT))
                {
                    JsonInterFace.ShowMessage("GSM监听端口非法!", 16);
                    return;
                }
                else
                {
                    if (int.Parse(Parameters.ServerBaseParameter.StrStartPortGSM_HJT) < 1 || int.Parse(Parameters.ServerBaseParameter.StrStartPortGSM_HJT) > 65535)
                    {
                        JsonInterFace.ShowMessage("GSM监听端口非法!", 16);
                        return;
                    }
                }

                if (!Parameters.ISDigital(Parameters.ServerBaseParameter.StrStartPortLTE))
                {
                    JsonInterFace.ShowMessage("LTE监听端口非法!", 16);
                    return;
                }
                else
                {
                    if (int.Parse(Parameters.ServerBaseParameter.StrStartPortLTE) < 1 || int.Parse(Parameters.ServerBaseParameter.StrStartPortLTE) > 65535)
                    {
                        JsonInterFace.ShowMessage("LTE监听端口非法!", 16);
                        return;
                    }
                }

                if (!Parameters.ISDigital(Parameters.ServerBaseParameter.StrStartPortTDS))
                {
                    JsonInterFace.ShowMessage("TDS监听端口非法!", 16);
                    return;
                }
                else
                {
                    if (int.Parse(Parameters.ServerBaseParameter.StrStartPortTDS) < 1 || int.Parse(Parameters.ServerBaseParameter.StrStartPortTDS) > 65535)
                    {
                        JsonInterFace.ShowMessage("TDS监听端口非法!", 16);
                        return;
                    }
                }

                if (!Parameters.ISDigital(Parameters.ServerBaseParameter.StrStartPortWCDMA))
                {
                    JsonInterFace.ShowMessage("WCDMA监听端口非法!", 16);
                    return;
                }
                else
                {
                    if (int.Parse(Parameters.ServerBaseParameter.StrStartPortWCDMA) < 1 || int.Parse(Parameters.ServerBaseParameter.StrStartPortWCDMA) > 65535)
                    {
                        JsonInterFace.ShowMessage("WCDMA监听端口非法!", 16);
                        return;
                    }
                }

                if (!Parameters.ISDigital(Parameters.ServerBaseParameter.StrStartPortAppWindows))
                {
                    JsonInterFace.ShowMessage("Client监听端口非法!", 16);
                    return;
                }
                else
                {
                    if (int.Parse(Parameters.ServerBaseParameter.StrStartPortAppWindows) < 1 || int.Parse(Parameters.ServerBaseParameter.StrStartPortAppWindows) > 65535)
                    {
                        JsonInterFace.ShowMessage("Client监听端口非法!", 16);
                        return;
                    }
                }

                if (!Parameters.ISDigital(Parameters.ServerBaseParameter.StrStartPortAppLinux))
                {
                    JsonInterFace.ShowMessage("AP监听端口非法!", 16);
                    return;
                }
                else
                {
                    if (int.Parse(Parameters.ServerBaseParameter.StrStartPortAppLinux) < 1 || int.Parse(Parameters.ServerBaseParameter.StrStartPortAppLinux) > 65535)
                    {
                        JsonInterFace.ShowMessage("AP监听端口非法!", 16);
                        return;
                    }
                }

                if (!Parameters.ISDigital(Parameters.ServerBaseParameter.StrStartPortAppAndroid))
                {
                    JsonInterFace.ShowMessage("Android监听端口非法!", 16);
                    return;
                }
                else
                {
                    if (int.Parse(Parameters.ServerBaseParameter.StrStartPortAppAndroid) < 1 || int.Parse(Parameters.ServerBaseParameter.StrStartPortAppAndroid) > 65535)
                    {
                        JsonInterFace.ShowMessage("Android监听端口非法!", 16);
                        return;
                    }
                }

                if (!Parameters.ISDigital(Parameters.ServerBaseParameter.LogMaxSize))
                {
                    JsonInterFace.ShowMessage("Log文件大小值非法!", 16);
                    return;
                }
                else
                {
                    if (int.Parse(Parameters.ServerBaseParameter.LogMaxSize) < 1 || int.Parse(Parameters.ServerBaseParameter.LogMaxSize) > 65535)
                    {
                        JsonInterFace.ShowMessage("Log文件大小值非法!", 16);
                        return;
                    }
                }

                Dictionary <string, string> Params = new Dictionary <string, string>();
                Params.Add("strDbIpAddr", Parameters.ServerBaseParameter.StrDbIpAddr);
                Params.Add("logOutputLevel", Parameters.ServerBaseParameter.LogOutputLevel);
                Params.Add("strFtpIpAddr", Parameters.ServerBaseParameter.StrFtpIpAddr);
                Params.Add("strFtpUserId", Parameters.ServerBaseParameter.StrFtpUserId);
                Params.Add("strFtpUserPsw", Parameters.ServerBaseParameter.StrFtpUserPsw);
                Params.Add("strFtpPort", Parameters.ServerBaseParameter.StrFtpPort);
                Params.Add("strFtpUpdateDir", Parameters.ServerBaseParameter.StrFtpUpdateDir);
                Params.Add("strStartPortCDMA_ZYF", Parameters.ServerBaseParameter.StrStartPortCDMA_ZYF);
                Params.Add("strStartPortGSM_ZYF", Parameters.ServerBaseParameter.StrStartPortGSM_ZYF);
                Params.Add("strStartPortGSM_HJT", Parameters.ServerBaseParameter.StrStartPortGSM_HJT);
                Params.Add("strStartPortLTE", Parameters.ServerBaseParameter.StrStartPortLTE);
                Params.Add("strStartPortTDS", Parameters.ServerBaseParameter.StrStartPortTDS);
                Params.Add("strStartPortWCDMA", Parameters.ServerBaseParameter.StrStartPortWCDMA);
                Params.Add("strStartPortAppWindows", Parameters.ServerBaseParameter.StrStartPortAppWindows);
                Params.Add("strStartPortAppLinux", Parameters.ServerBaseParameter.StrStartPortAppLinux);
                Params.Add("strStartPortAppAndroid", Parameters.ServerBaseParameter.StrStartPortAppAndroid);
                Params.Add("dataAlignMode", Parameters.ServerBaseParameter.DataAlignMode);
                Params.Add("logMaxSize", Parameters.ServerBaseParameter.LogMaxSize);

                if (NetWorkClient.ControllerServer.Connected)
                {
                    NetWorkClient.ControllerServer.Send(JsonInterFace.ServerBaseParameterSaveRequest(Params));
                }
                else
                {
                    MessageBox.Show("网络与服务器已断开!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
        }
コード例 #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);
            }
        }