示例#1
0
        private void btnEnter_Click(object sender, RoutedEventArgs e)
        {
            Regex regexInt = new Regex(@"\d");

            try
            {
                if (txtTxpower.Text.Trim() != "")
                {
                    if (regexInt.Match(txtTxpower.Text).Success)
                    {
                        if (Convert.ToInt32(txtTxpower.Text) < -128 || Convert.ToInt32(txtTxpower.Text) > 0)
                        {
                            MessageBox.Show("衰减值超出范围,范围[-128~0]", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("衰减值格式非法,范围[-128~0]", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("请输入衰减值,范围[-128~0]", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                if (txtDuration.Text.Trim() != "")
                {
                    if (regexInt.Match(txtDuration.Text).Success)
                    {
                        if (Convert.ToUInt32(txtDuration.Text) < 0 || Convert.ToUInt32(txtDuration.Text) > 65535)
                        {
                            MessageBox.Show("白名单自学习时长超出范围,范围[0-65535]", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("白名单自学习时长格式非,范围[0-65535]", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("请输入白名单自学习时长,范围[0-65535]", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                string   ParentFullNamePath  = string.Empty;
                string[] _ParentFullNamePath = RemoteAPInfoParameter.DomainFullPathName.Split(new char[] { '.' });
                for (int i = 0; i < _ParentFullNamePath.Length - 1; i++)
                {
                    if (ParentFullNamePath == null || ParentFullNamePath == "")
                    {
                        ParentFullNamePath = _ParentFullNamePath[i];
                    }
                    else
                    {
                        ParentFullNamePath += "." + _ParentFullNamePath[i];
                    }
                }


                // >>> 检测白名单自学习工作状态 <<<
                if (JsonInterFace.LTEDeviceDetail.Command == "已启动")
                {
                    if (JsonInterFace.WhiteListSelfLearningParameter.Command != "0")
                    {
                        MessageBox.Show("操作绝拒,白名单自学习正在工作......,请先停止!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                }


                //发送
                if (NetWorkClient.ControllerServer.Connected)
                {
                    NetWorkClient.ControllerServer.Send(
                        JsonInterFace.APWhiteListSelfLearningSettingRequest(
                            ParentFullNamePath,
                            RemoteAPInfoParameter.DeviceName,
                            RemoteAPInfoParameter.IP,
                            RemoteAPInfoParameter.Port,
                            RemoteAPInfoParameter.InnerType,
                            RemoteAPInfoParameter.SN
                            ));
                    DialogResult = true;
                }
                else
                {
                    MessageBox.Show("网络与服务器断开!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }
            }
            catch (Exception ex)
            {
                Parameters.PrintfLogsExtended(ex.Message, ex.StackTrace);
            }
        }