private void Window_Loaded(object sender, RoutedEventArgs e) { this.textBox_systemGuid.Text = systemGuid; this.textBox_userName.Text = userName; if (!string.IsNullOrEmpty(password)) { this.passwordBox_password.Password = Class_Encrypt.DecryptDES(password); } }
private void button_systemGuid_Click(object sender, RoutedEventArgs e) { Match m = Regex.Match(this.textBox_systemGuid.Text, @"^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$", RegexOptions.IgnoreCase); if (m.Success) { NetworkScanner scanner = new NetworkScanner(); scanner.Scan(); ControllerInfoCollection controllers = scanner.Controllers; foreach (ControllerInfo controllerinfo in controllers) { if (controllerinfo.SystemId.ToString().ToUpper() == this.textBox_systemGuid.Text.ToUpper()) { try { if (this.myController != null) { this.myController.Logoff(); this.myController.Dispose(); this.myController = null; } this.myController = Controller.Connect(new Guid(this.textBox_systemGuid.Text), ConnectionType.Standalone); if (string.IsNullOrEmpty(this.textBox_userName.Text)) { this.myController.Logon(UserInfo.DefaultUser); } else { UserInfo userInfo_login = new UserInfo(this.textBox_userName.Text); userInfo_login.Password = this.passwordBox_password.Password; this.myController.Logon(userInfo_login); } systemGuid = this.textBox_systemGuid.Text; userName = this.textBox_userName.Text; password = Class_Encrypt.EncryptDES(this.passwordBox_password.Password); this.DialogResult = true; return; }catch (Exception exception) { MessageBox.Show(exception.Message); return; } } } MessageBox.Show("This system guid is not valid or the controller is not connected, please check it angin."); } else { MessageBox.Show("This system guid's format is not valid, please check it angin."); } }
public void Login(string userName, string password) { try { UserInfo userInfo_login = UserInfo.DefaultUser; if (!string.IsNullOrEmpty(userName)) { userInfo_login = new UserInfo(userName); if (!string.IsNullOrEmpty(password)) { userInfo_login.Password = Class_Encrypt.DecryptDES(password); } } controller.Logon(userInfo_login); } finally { } }