Esempio n. 1
0
        //验证输入的参数是否符合格式
        private bool ConfirmConnectParameter(ref string AStrReturn)
        {
            bool LBoolReturn = false;

            string LStrServerName    = string.Empty;
            string LStrServerPort    = string.Empty;
            int    LIntServerPort    = 0;
            string LStrLoginName     = string.Empty;
            string LStrLoginPassword = string.Empty;


            try
            {
                IListConnectArguments.Clear();
                App.GStrCatchException = string.Empty;

                LStrServerName    = TextBoxServerName.Text.Trim();
                LStrServerPort    = TextBoxServerPort.Text.Trim();
                LStrLoginName     = TextBoxLoginName.Text.Trim();
                LStrLoginPassword = PasswordBoxLoginPassword.Password;

                if (string.IsNullOrEmpty(LStrServerName))
                {
                    AStrReturn = "E00001"; TextBoxServerName.Focus(); return(LBoolReturn);
                }
                if (!int.TryParse(LStrServerPort, out LIntServerPort))
                {
                    AStrReturn = "E00002"; TextBoxServerPort.Focus(); return(LBoolReturn);
                }
                if (LIntServerPort <= 1024 || LIntServerPort >= 65535)
                {
                    AStrReturn = "E00002"; TextBoxServerPort.Focus(); return(LBoolReturn);
                }
                if (string.IsNullOrEmpty(LStrLoginName))
                {
                    AStrReturn = "E00003"; TextBoxLoginName.Focus(); return(LBoolReturn);
                }
                if (string.IsNullOrEmpty(LStrLoginPassword))
                {
                    AStrReturn = "E00004"; PasswordBoxLoginPassword.Focus(); return(LBoolReturn);
                }

                IListConnectArguments.Add(LStrServerName); IListConnectArguments.Add(LStrServerPort); IListConnectArguments.Add(LStrLoginName); IListConnectArguments.Add(LStrLoginPassword);

                LBoolReturn = true;
            }
            catch (Exception ex)
            {
                LBoolReturn            = false;
                AStrReturn             = "E00000";
                App.GStrCatchException = ex.ToString();
            }
            return(LBoolReturn);
        }
Esempio n. 2
0
        private void ConnectToServer_Loaded(object sender, RoutedEventArgs e)
        {
            App.DrawWindowsBackGround(this);
            ButtonApplicationMenu.ContextMenu      = App.InitApplicationMenu();
            App.GSystemMainWindow.IOperationEvent += GSystemMainWindow_IOperationEvent;
            ImageLinkToServer.Source = new BitmapImage(new Uri(System.IO.Path.Combine(App.GStrApplicationDirectory, @"Images\00000008.ico"), UriKind.RelativeOrAbsolute));
            DisplayElementCharacters(false);

            if (App.GBoolRunAtServer)
            {
                TextBoxServerName.Text = "127.0.0.1";
                TextBoxServerPort.Text = "8081";
                TextBoxLoginName.Text  = "administrator";
            }
            TextBoxServerName.Focus();
            if (App.GStrAllowRemoteConnect == "0")
            {
                TextBoxServerName.IsReadOnly = true;
                TextBoxServerPort.IsReadOnly = true;
                PasswordBoxLoginPassword.Focus();
            }
        }
        /// <summary>
        /// 验证界面输入的连接信息是否正确
        /// </summary>
        /// <param name="AStrReturn">返回错误码和错误信息 </param>
        /// <returns>True:验证正确; False:验证错误</returns>
        private bool ConfirmConnectParameter(ref string AStrReturn)
        {
            bool LBoolReturn = false;

            string LStrServerName           = string.Empty;
            int    LIntServerPort           = 0;
            string LStrLoginName            = string.Empty;
            string LStrLoginPassword        = string.Empty;
            string LStrRememberPassword     = "******";
            int    LIntNetworkProtocolIndex = 1;
            string LStrNetworkProtocol      = string.Empty;
            int    LIntConnectionTimeOut    = 60;
            int    LIntExcutionTimeOut      = 0;

            try
            {
                IListConnectInfo.Clear();

                LStrServerName = ComboBoxServerName.Text.Trim();
                if (string.IsNullOrEmpty(LStrServerName))
                {
                    AStrReturn = "E001001" + App.GStrSpliterChar; ComboBoxServerName.Focus(); return(LBoolReturn);
                }

                if (!int.TryParse(TextBoxServerPort.GetElementData().Trim(), out LIntServerPort))
                {
                    AStrReturn = "E001002" + App.GStrSpliterChar; TextBoxServerPort.Focus(); return(LBoolReturn);
                }
                if (LIntServerPort <= 10)
                {
                    AStrReturn = "E001002" + App.GStrSpliterChar; TextBoxServerPort.Focus(); return(LBoolReturn);
                }

                LStrLoginName = ComboBoxLoginName.Text.Trim();
                if (string.IsNullOrEmpty(LStrLoginName))
                {
                    AStrReturn = "E001003" + App.GStrSpliterChar; ComboBoxLoginName.Focus(); return(LBoolReturn);
                }

                LStrLoginPassword = PasswordBoxLoginPassword.Password;
                if (string.IsNullOrEmpty(LStrLoginPassword))
                {
                    AStrReturn = "E001004" + App.GStrSpliterChar; PasswordBoxLoginPassword.Focus(); return(LBoolReturn);
                }

                if (CheckBoxRemberPassword.IsChecked == true)
                {
                    LStrRememberPassword = "******";
                }

                IListConnectInfo.Add(LStrServerName);                       //0
                IListConnectInfo.Add(LIntServerPort.ToString());            //1
                IListConnectInfo.Add(LStrLoginName);                        //2
                IListConnectInfo.Add(LStrLoginPassword);                    //3
                IListConnectInfo.Add(LStrRememberPassword);                 //4
                IListConnectInfo.Add(LIntNetworkProtocolIndex.ToString());  //5
                IListConnectInfo.Add(LStrNetworkProtocol);                  //6
                IListConnectInfo.Add(LIntConnectionTimeOut.ToString());     //7
                IListConnectInfo.Add(LIntExcutionTimeOut.ToString());       //8
                IListConnectInfo.Add("F");                                  //9首次连接服务器
                IListConnectInfo.Add("");                                   //10登录流水号
                IListConnectInfo.Add("");                                   //11用户19位编码
                LBoolReturn = true;
            }
            catch (Exception ex)
            {
                LBoolReturn = false;
                AStrReturn  = "E001999" + App.GStrSpliterChar + ex.Message;
            }

            return(LBoolReturn);
        }