void UpdateWorkspace(WorkspaceUpdateContext Context) { string StatusMessage; WorkspaceUpdateResult Result = WorkspaceUpdateResult.FailedToSync; try { Result = UpdateWorkspaceInternal(Context, out StatusMessage); if (Result != WorkspaceUpdateResult.Success) { Log.WriteLine("{0}", StatusMessage); } } catch (ThreadAbortException) { StatusMessage = "Canceled."; Log.WriteLine("Canceled."); } catch (Exception Ex) { StatusMessage = "Failed with exception - " + Ex.ToString(); Log.WriteException(Ex, "Failed with exception"); } bSyncing = false; PendingChangeNumber = CurrentChangeNumber; if (OnUpdateComplete != null) { OnUpdateComplete(Context, Result, StatusMessage); } }
void CompleteAutomatedSync(WorkspaceUpdateResult Result, string SelectedFileName, AutomationRequest Request) { if (Result == WorkspaceUpdateResult.Success) { Request.SetOutput(new AutomationRequestOutput(AutomationRequestResult.Ok, Encoding.UTF8.GetBytes(SelectedFileName))); } else if (Result == WorkspaceUpdateResult.Canceled) { Request.SetOutput(new AutomationRequestOutput(AutomationRequestResult.Canceled)); } else { Request.SetOutput(new AutomationRequestOutput(AutomationRequestResult.Error)); } }
void UpdateComplete(WorkspaceUpdateContext Context, WorkspaceUpdateResult Result, string ResultMessage) { UpdateTimer.Stop(); UpdateSyncConfig(Workspace.CurrentChangeNumber); if(Result == WorkspaceUpdateResult.Success && Context.Options.HasFlag(WorkspaceUpdateOptions.SyncSingleChange)) { Settings.CurrentWorkspace.AdditionalChangeNumbers.Add(Context.ChangeNumber); Settings.Save(); } if(Result == WorkspaceUpdateResult.Success && Settings.CurrentWorkspace.ExpandedArchiveTypes != null) { Settings.CurrentWorkspace.ExpandedArchiveTypes = Settings.CurrentWorkspace.ExpandedArchiveTypes.Except(Context.ArchiveTypeToDepotPath.Where(x => x.Value == null).Select(x => x.Key)).ToArray(); } Settings.CurrentWorkspace.LastSyncChangeNumber = Context.ChangeNumber; Settings.CurrentWorkspace.LastSyncResult = Result; Settings.CurrentWorkspace.LastSyncResultMessage = ResultMessage; Settings.CurrentWorkspace.LastSyncTime = DateTime.UtcNow; Settings.CurrentWorkspace.LastSyncDurationSeconds = (int)(Settings.CurrentWorkspace.LastSyncTime.Value - Context.StartTime).TotalSeconds; Settings.CurrentWorkspace.LastBuiltChangeNumber = Workspace.LastBuiltChangeNumber; Settings.Save(); if(Result == WorkspaceUpdateResult.FilesToResolve) { MessageBox.Show("You have files to resolve after syncing your workspace. Please check P4."); } else if(Result == WorkspaceUpdateResult.FilesToClobber) { Taskbar.SetState(Handle, TaskbarState.Paused); ClobberWindow Window = new ClobberWindow(Context.ClobberFiles); if(Window.ShowDialog(this) == DialogResult.OK) { StartWorkspaceUpdate(Context); return; } } else if(Result == WorkspaceUpdateResult.FailedToCompileWithCleanWorkspace) { EventMonitor.PostEvent(Context.ChangeNumber, EventType.DoesNotCompile); } else if(Result == WorkspaceUpdateResult.Success) { if(Context.Options.HasFlag(WorkspaceUpdateOptions.Build)) { EventMonitor.PostEvent(Context.ChangeNumber, EventType.Compiles); } if(Context.Options.HasFlag(WorkspaceUpdateOptions.RunAfterSync)) { LaunchEditor(); } if(Context.Options.HasFlag(WorkspaceUpdateOptions.OpenSolutionAfterSync)) { OpenSolution(); } } Taskbar.SetState(Handle, (Result == WorkspaceUpdateResult.Success)? TaskbarState.NoProgress : TaskbarState.Error); BuildList.Invalidate(); Refresh(); UpdateStatusPanel(); UpdateSyncActionCheckboxes(); }
void UpdateCompleteCallback(WorkspaceUpdateContext Context, WorkspaceUpdateResult Result, string ResultMessage) { Invoke(new MethodInvoker(() => UpdateComplete(Context, Result, ResultMessage))); }
private static bool GetGenericLastUpdateMessage(WorkspaceUpdateResult Result, out string Message) { switch(Result) { case WorkspaceUpdateResult.Canceled: Message = "Sync canceled."; return true; case WorkspaceUpdateResult.FailedToSync: Message = "Failed to sync files."; return true; case WorkspaceUpdateResult.FilesToResolve: Message = "Sync finished with unresolved files."; return true; case WorkspaceUpdateResult.FilesToClobber: Message = "Sync failed due to modified files in workspace."; return true; case WorkspaceUpdateResult.FailedToCompile: case WorkspaceUpdateResult.FailedToCompileWithCleanWorkspace: Message = "Compile failed."; return true; default: Message = null; return false; } }
private static bool GetLastUpdateMessage(WorkspaceUpdateResult Result, string ResultMessage, out string Message) { if(Result != WorkspaceUpdateResult.Success && ResultMessage != null) { Message = ResultMessage; return true; } return GetGenericLastUpdateMessage(Result, out Message); }