Exemple #1
0
        public List <string> GetSettedData(ref string AStrCallReturn)
        {
            List <string> LListStrReturn = new List <string>();
            string        LStrDBServer   = string.Empty;
            string        LStrDBPort     = string.Empty;
            string        LStrLoginID    = string.Empty;
            string        LStrLoginPwd   = string.Empty;
            int           LIntDBPort     = 0;

            string LStrVerificationCode004 = string.Empty;

            try
            {
                AStrCallReturn          = string.Empty;
                LStrVerificationCode004 = App.CreateVerificationCode(EncryptionAndDecryption.UMPKeyAndIVType.M004);

                LStrDBServer = TextBoxServerName.Text.Trim();
                LStrDBPort   = TextBoxServerPort.Text.Trim();
                LStrLoginID  = TextBoxLoginName.Text.Trim();
                LStrLoginPwd = PasswordBoxLoginPassword.Password;

                if (string.IsNullOrEmpty(LStrDBServer))
                {
                    TextBoxServerName.Focus(); AStrCallReturn = "ER0001"; return(LListStrReturn);
                }

                if (string.IsNullOrEmpty(LStrDBPort))
                {
                    TextBoxServerPort.Focus(); AStrCallReturn = "ER0002"; return(LListStrReturn);
                }
                if (!int.TryParse(LStrDBPort, out LIntDBPort))
                {
                    TextBoxServerPort.Focus(); AStrCallReturn = "ER0002"; return(LListStrReturn);
                }
                if (LIntDBPort <= 0 || LIntDBPort > 65535)
                {
                    TextBoxServerPort.Focus(); AStrCallReturn = "ER0002"; return(LListStrReturn);
                }

                if (string.IsNullOrEmpty(LStrLoginID))
                {
                    TextBoxLoginName.Focus(); AStrCallReturn = "ER0003"; return(LListStrReturn);
                }

                LStrDBServer = EncryptionAndDecryption.EncryptDecryptString(LStrDBServer, LStrVerificationCode004, EncryptionAndDecryption.UMPKeyAndIVType.M004);
                LStrDBPort   = EncryptionAndDecryption.EncryptDecryptString(LStrDBPort, LStrVerificationCode004, EncryptionAndDecryption.UMPKeyAndIVType.M004);
                LStrLoginID  = EncryptionAndDecryption.EncryptDecryptString(LStrLoginID, LStrVerificationCode004, EncryptionAndDecryption.UMPKeyAndIVType.M004);
                LStrLoginPwd = EncryptionAndDecryption.EncryptDecryptString(LStrLoginPwd, LStrVerificationCode004, EncryptionAndDecryption.UMPKeyAndIVType.M004);

                LListStrReturn.Add(LStrDBServer); LListStrReturn.Add(LStrDBPort); LListStrReturn.Add(LStrLoginID); LListStrReturn.Add(LStrLoginPwd);
            }
            catch { LListStrReturn.Clear(); }

            return(LListStrReturn);
        }
        //验证输入的参数是否符合格式
        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);
        }
        private void ConnectToAppServer_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));

            IStrVerificationCode001 = CreateVerificationCode(PFShareClassesC.EncryptionAndDecryption.UMPKeyAndIVType.M001);
            IStrVerificationCode101 = CreateVerificationCode(PFShareClassesC.EncryptionAndDecryption.UMPKeyAndIVType.M101);

            TextBoxServerPort.SetElementData("8081");

            DisplayElementCharacters(false);
            InitConnectedServerList();
            ComboBoxServerName.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);
        }