public bool Run(out string ErrorMessage) { // Set the default login state to failed LoginResult = LoginResult.Failed; // Get the server settings if (!TryGetServerSettings(ProjectFileName, ref ServerAndPort, ref UserName, Log)) { ErrorMessage = "Unable to get Perforce server settings."; return(false); } // Create the connection PerforceConnection Perforce = new PerforceConnection(UserName, null, ServerAndPort); // If we've got a password, execute the login command if (Password != null) { string PasswordErrorMessage; LoginResult = Perforce.Login(Password, out PasswordErrorMessage, Log); if (LoginResult != LoginResult.Succeded) { Log.WriteLine(PasswordErrorMessage); ErrorMessage = String.Format("Unable to login: {0}", PasswordErrorMessage); return(false); } } // Check that we're logged in bool bLoggedIn; if (!Perforce.GetLoggedInState(out bLoggedIn, Log)) { ErrorMessage = "Unable to get login status."; return(false); } if (!bLoggedIn) { LoginResult = LoginResult.MissingPassword; ErrorMessage = "User is not logged in to Perforce."; Log.WriteLine(ErrorMessage); return(false); } // Execute the inner task LoginResult = LoginResult.Succeded; return(InnerTask.Run(Perforce, Log, out ErrorMessage)); }
public bool Run(PerforceConnection Perforce, out string ErrorMessage) { // Make sure we're logged in bool bLoggedIn; if (!Perforce.GetLoggedInState(out bLoggedIn, Log)) { ErrorMessage = "Error while checking login status."; return(false); } if (!bLoggedIn) { ErrorMessage = "User is not logged in to Perforce."; return(false); } // Execute like a regular task return(Run(Perforce, Log, out ErrorMessage)); }
public bool Run(out string ErrorMessage) { // Get the server settings string ServerAndPort = SelectedProject.ServerAndPort; string UserName = SelectedProject.UserName; string ProjectFileName = null; if (SelectedProject.Type == UserSelectedProjectType.Local) { ProjectFileName = SelectedProject.LocalPath; } if (!PerforceModalTask.TryGetServerSettings(ProjectFileName, ref ServerAndPort, ref UserName, Log)) { ErrorMessage = "Unable to get Perforce server settings."; return(false); } // Create the connection PerforceConnection Perforce = new PerforceConnection(UserName, null, ServerAndPort); // Make sure we're logged in bool bLoggedIn; if (!Perforce.GetLoggedInState(out bLoggedIn, Log)) { ErrorMessage = "Error while checking login status."; return(false); } if (!bLoggedIn) { ErrorMessage = "User is not logged in to Perforce."; return(false); } // Execute like a regular task return(Run(Perforce, Log, out ErrorMessage)); }
public bool Run(out string ErrorMessage) { // Set the default login state to failed LoginResult = LoginResult.Failed; // If we've got a password, execute the login command if (Password != null) { string PasswordErrorMessage; LoginResult = Perforce.Login(Password, out PasswordErrorMessage, Log); if (LoginResult != LoginResult.Succeded) { Log.WriteLine(PasswordErrorMessage); ErrorMessage = String.Format("Unable to login: {0}", PasswordErrorMessage); return(false); } } // Check that we're logged in bool bLoggedIn; if (!Perforce.GetLoggedInState(out bLoggedIn, Log)) { ErrorMessage = "Unable to get login status."; return(false); } if (!bLoggedIn) { LoginResult = LoginResult.MissingPassword; ErrorMessage = "User is not logged in to Perforce."; Log.WriteLine(ErrorMessage); return(false); } // Execute the inner task LoginResult = LoginResult.Succeded; return(InnerTask.Run(Perforce, Log, out ErrorMessage)); }
void PollForUpdates() { string StreamName; if (!Perforce.GetActiveStream(out StreamName, LogWriter)) { StreamName = null; } // Try to update the zipped binaries list before anything else, because it causes a state change in the UI UpdateZippedBinaries(); while (!bDisposing) { Stopwatch Timer = Stopwatch.StartNew(); // Check we still have a valid login ticket bool bLoggedIn; if (Perforce.GetLoggedInState(out bLoggedIn, LogWriter)) { if (!bLoggedIn) { LastStatusMessage = "User is not logged in"; OnLoginExpired(); } else { // Check we haven't switched streams string NewStreamName; if (Perforce.GetActiveStream(out NewStreamName, LogWriter) && NewStreamName != StreamName) { OnStreamChange(); } // Update the stream list if (StreamName != null) { List <string> NewOtherStreamNames; if (!Perforce.FindStreams(PerforceUtils.GetClientOrDepotDirectoryName(StreamName) + "/*", out NewOtherStreamNames, LogWriter)) { NewOtherStreamNames = new List <string>(); } OtherStreamNames = NewOtherStreamNames; } // Check for any p4 changes if (!UpdateChanges()) { LastStatusMessage = "Failed to update changes"; } else if (!UpdateChangeTypes()) { LastStatusMessage = "Failed to update change types"; } else if (!UpdateZippedBinaries()) { LastStatusMessage = "Failed to update zipped binaries list"; } else { LastStatusMessage = String.Format("Last update took {0}ms", Timer.ElapsedMilliseconds); } } } // Wait for another request, or scan for new builds after a timeout RefreshEvent.WaitOne((IsActive? 1 : 10) * 60 * 1000); } }
void PollForUpdatesInner() { string StreamName; if (!Perforce.GetActiveStream(out StreamName, LogWriter)) { StreamName = null; } // Get the perforce server settings PerforceInfoRecord PerforceInfo; if (Perforce.Info(out PerforceInfo, LogWriter)) { ServerTimeZone = PerforceInfo.ServerTimeZone; } // Try to update the zipped binaries list before anything else, because it causes a state change in the UI UpdateArchives(); while (!bDisposing) { Stopwatch Timer = Stopwatch.StartNew(); // Check we still have a valid login ticket bool bLoggedIn; if (Perforce.GetLoggedInState(out bLoggedIn, LogWriter)) { if (!bLoggedIn) { LastStatusMessage = "User is not logged in"; OnLoginExpired(); } else { // Check we haven't switched streams string NewStreamName; if (Perforce.GetActiveStream(out NewStreamName, LogWriter) && NewStreamName != StreamName) { OnStreamChange(); } // Check for any p4 changes if (!UpdateChanges()) { LastStatusMessage = "Failed to update changes"; } else if (!UpdateChangeTypes()) { LastStatusMessage = "Failed to update change types"; } else if (!UpdateArchives()) { LastStatusMessage = "Failed to update zipped binaries list"; } else { LastStatusMessage = String.Format("Last update took {0}ms", Timer.ElapsedMilliseconds); } } } // Wait for another request, or scan for new builds after a timeout RefreshEvent.WaitOne((IsActive? 2 : 10) * 60 * 1000); } }