/// <summary> /// Event handled when P4Logout is clicked. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void P4Logout_Click(object sender, RoutedEventArgs e) { P4Execute executer = new P4Execute(); P4ExecutingParameters exePar = new P4ExecutingParameters("CMD.exe", "logout", null, null); string data = executer.ExecuteCommand(exePar); //Message }
/// <summary> /// Method to call get workspace information from perforce server. /// </summary> /// <param name="sender"></param> /// <param name="tabView"></param> /// <param name="field"></param> private void SelectWorkSpace(object sender, ITabView tabView, string field) { P4Execute executor = new P4Execute(); P4ExecutingParameters exeParameters; string data = null; Application.Current.Dispatcher.Invoke(() => { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; }); if (!string.IsNullOrEmpty(_sessionUser.Username) && !string.IsNullOrWhiteSpace(_sessionUser.Username)) { exeParameters = new P4ExecutingParameters("CMD.exe", "workspaces -u", null, new List <string> { _sessionUser.Username.Trim() }); data = executor.ExecuteCommand(exeParameters); } else { exeParameters = new P4ExecutingParameters("CMD.exe", "user -o", null, null); data = executor.ExecuteCommand(exeParameters); if (!string.IsNullOrEmpty(data) && !string.IsNullOrWhiteSpace(data)) { data = data.Remove(data.LastIndexOf("Email:")); data = data.Substring(data.LastIndexOf("User:"******"CMD.exe", "workspaces -u", null, new List <string> { data }); data = executor.ExecuteCommand(exeParameters); } else { Application.Current.Dispatcher.Invoke(() => { Mouse.OverrideCursor = null; }); return; } } if (workspaceDisplay.IsActive || workspaceDisplay.IsLoaded) { workspaceDisplay.PopulateTable(data, sender, tabView, field, _WorkSpaceEvent); } else { workspaceDisplay = new Workspace(this); workspaceDisplay.PopulateTable(data, sender, tabView, field, _WorkSpaceEvent); } Application.Current.Dispatcher.Invoke(() => { Mouse.OverrideCursor = null; }); }
/// <summary> /// Event for Submit button in the SingInWindow. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Submit_Click(object sender, RoutedEventArgs e) { Message.Visibility = Visibility.Hidden; Message.Content = ""; string username = UserName.Text.ToLower().Trim(); string password = Password.Password; if (ValidateUsernameAndPassword(username, password)) { P4Execute executer = new P4Execute(); P4ExecutingParameters exePar = new P4ExecutingParameters("CMD.exe", "set P4USER="******"CMD.exe", "login", null, null, $"echo {password}|"); data = executer.ExecuteCommand(exePar); password = null; if (data.Contains("User")) { data = !System.String.IsNullOrEmpty(data) ? data.Substring(data.IndexOf("User")) : ""; } else { Message.Visibility = Visibility.Visible; Message.Content = "UserName or Password incorrect. Try Again!"; return; } _mainWindow._sessionUser.Username = username; Messages msg = new Messages(data.Trim(), "", _mainWindow); msg.PublishMessage(); if (!string.IsNullOrEmpty(username) && !string.IsNullOrWhiteSpace(username)) { _mainWindow.mast.Content += $" - (P4V user: {username}* logged-in)"; } this.Close(); _mainWindow.Show(); _mainWindow.Activate(); } else { MessageBox.Show("User Name or Password cannot be blank! \n\nPlease Enter the same or click Cancel."); } }