/// <summary> /// Populate all the mog aware directories within the 'MyProjects' node /// </summary> private void PopulateMogProjects() { TreeNode mogProjects = new TreeNode("MyProjects", 1, 1); GameDataTreeView.Nodes.Add(mogProjects); string userName = MOG_ControllerProject.GetUserName_DefaultAdmin(); // Get a list of all our projects that the server knows about ArrayList projectsArray = MOG_DBSyncedDataAPI.GetAllSyncedLocations(MOG_ControllerSystem.GetComputerName(), null, userName); if (projectsArray != null && projectsArray.Count > 0) { foreach (MOG_DBSyncedLocationInfo project in projectsArray) { // Hash our local tab name string LocalBranchName = "@" + project.mWorkingDirectory; MOG_ControllerSyncData targetGameData = new MOG_ControllerSyncData(project.mWorkingDirectory, project.mProjectName, project.mBranchName, project.mPlatformName, userName); TreeNode projectNode = new TreeNode(LocalBranchName, 4, 4); projectNode.Tag = new guiAssetTreeTag(project.mWorkingDirectory, projectNode, targetGameData); FillDirectory(projectNode, project.mWorkingDirectory, targetGameData); mogProjects.Nodes.Add(projectNode); } } // Create the helper project mogProjects.Nodes.Add("<Create new local branch>"); mogProjects.Expand(); }
private void RefreshLists() { // get connection lists MOG_CommandServerCS commandServer = (MOG_CommandServerCS)MOG_ControllerSystem.GetCommandManager(); if (commandServer == null) { return; } this.slaveList = commandServer.GetRegisteredSlaves(); this.clientList = commandServer.GetRegisteredClients(); this.editorList = commandServer.GetRegisteredEditors(); this.serverList = new ArrayList(); // build server's "command" MOG_Command command = new MOG_Command(); command.SetComputerName(MOG_ControllerSystem.GetComputerName()); command.SetComputerIP(MOG_ControllerSystem.GetComputerIP()); command.SetNetworkID(1); command.SetCommandType(0); command.SetDescription(""); this.serverList.Add(command); }
public static void SwitchCurrentWorkspaceBranch(string newBranchName) { // Check if this branch is changing? if (string.Compare(newBranchName, MOG_ControllerProject.GetCurrentSyncDataController().GetBranchName(), true) != 0) { // Push the new branch down into the current workspace if (MOG_DBSyncedDataAPI.SwitchWorkspaceBranch(MOG_ControllerSystem.GetComputerName(), MOG_ControllerProject.GetCurrentSyncDataController().GetProjectName(), MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName(), MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory(), MOG_ControllerProject.GetCurrentSyncDataController().GetUserName(), newBranchName)) { // Update our loaded workspace MOG_ControllerProject.GetCurrentSyncDataController().SetBranchName(newBranchName); } } }
/// <summary> /// Open an explorer window in the target of the selected asset(s) /// </summary> /// <param name="sender"> Must be a ListView and have a string[] in its Tag describing the columns</param> /// <param name="e"></param> private void RemoveMenuItem_Click(object sender, System.EventArgs e) { ArrayList selectedItems = ControlGetSelectedItems(); string message = ""; foreach (guiAssetTreeTag tag in selectedItems) { if (tag.Execute) { message = message + tag.FullFilename + "\n"; } } if (MOG_Prompt.PromptResponse("Are you sure you want to remove all of these assets from the project?", message, MOGPromptButtons.OKCancel) == MOGPromptResult.OK) { // Obtain a unique bless label string jobLabel = "RemoveAsset." + MOG_ControllerSystem.GetComputerName() + "." + MOG_Time.GetVersionTimestamp(); foreach (guiAssetTreeTag tag in selectedItems) { if (tag.Execute) { MOG_Filename filename = new MOG_Filename(tag.FullFilename); // Make sure we are an asset before showing log if (filename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset) { if (guiAssetController.RemoveBlessed(filename, jobLabel)) { tag.ItemRemove(); } } } } // Start the job MOG_ControllerProject.StartJob(jobLabel); } }
private void SQLServerComboBox_DropDown(object sender, System.EventArgs e) { SQLServerComboBox.Items.Clear(); string [] servers = SqlLocator.GetServers(); if (servers != null) { this.Cursor = Cursors.WaitCursor; Application.DoEvents(); foreach (string server in servers) { SQLServerComboBox.Items.Add(server); } this.Cursor = Cursors.Default; } else { SQLServerComboBox.Items.Add(MOG_ControllerSystem.GetComputerName()); } }
/// <summary> /// Create Package for each platform in this Project /// </summary> private MOG_Filename CreatePackageForPlatform(NodeLabelEditEventArgs e, MOG_Filename packageName, TreeNode parent) { // Initialize our ArrayList for MOG_Property objects ArrayList targetSyncPath = null; // If our node name already exists, return... if (!ValidateNewNodeName(e, packageName)) { return null; } // If our targetSyncPath is null, even after we try to get a valid one, return... if (targetSyncPath == null && (targetSyncPath = GetValidTargetSyncPath(e, packageName)) == null) { return null; } MOG_Property syncTargetPathProperty = targetSyncPath[0] as MOG_Property; // Create the new package MOG_Filename createdPackageFilename = MOG_ControllerProject.CreatePackage(packageName, syncTargetPathProperty.mValue); if (createdPackageFilename == null) { return null; } RenameNode(e, createdPackageFilename); // Post the projects new assets string jobLabel = "NewPackageCreated." + MOG_ControllerSystem.GetComputerName() + "." + MOG_Time.GetVersionTimestamp(); MOG_ControllerProject.PostAssets(MOG_ControllerProject.GetProjectName(), MOG_ControllerProject.GetBranchName(), jobLabel); // Return our created package return createdPackageFilename; }
void CommandEventCallBack_Invoked(MOG_Command command) { switch (command.GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemAlert: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemError: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemException: #region MOG_COMMAND_NotifySystemException MOG_ALERT_LEVEL level = MOG_ALERT_LEVEL.ALERT; switch (command.GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemAlert: level = MOG_ALERT_LEVEL.ALERT; break; case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemError: level = MOG_ALERT_LEVEL.ERROR; break; case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemException: level = MOG_ALERT_LEVEL.CRITICAL; break; } MOG_Prompt.PromptMessage(command.GetTitle(), command.GetDescription(), command.GetSource(), level); #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_LockPersistentNotify: #region MOG_COMMAND_LockPersistentNotify // Check if this is the same project? MOG_Command lockInfo = command.GetCommand(); if (lockInfo != null) { // Check if we are on the locks tab? if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Locks", true) == 0) { if (mainForm.mLibraryManager != null) { mainForm.mLibraryManager.RefreshItem(command); } } // Check if this lock is related to our project? if (MOG_Filename.IsClassificationValidForProject(lockInfo.GetAssetFilename().GetOriginalFilename(), MOG_ControllerProject.GetProjectName())) { // Check if we are on the workspace tab? if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Workspace", true) == 0) { if (mainForm.mAssetManager != null) { mainForm.mAssetManager.RefreshLockStatus(command); // JohnRen - Removed because this is just too slow when the server sends us a ton of locks at startup // mainForm.LocalBranchMogControl_GameDataDestinationTreeView.RefreshFileLockStatus(command); mainForm.mAssetManager.mLocal.RefreshLockStatus(command); } } // Check if we are on the project tab? else if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Project", true) == 0) { if (mainForm.mProjectManager != null) { mainForm.mProjectManager.UpdateAsset(command); } } // Check if we are on the library tab? else if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Library", true) == 0) { if (mainForm.mLibraryManager != null) { mainForm.mLibraryManager.RefreshItem(command); } } // Check if this notify just got processed? if (command.GetOptions().Contains("{Processed}")) { // Check if we have a local workspace defined? MOG_ControllerSyncData workspace = MOG_ControllerProject.GetCurrentSyncDataController(); if (workspace != null) { // Time to check if this was our lock that just got released? if (string.Compare(lockInfo.GetUserName(), MOG_ControllerProject.GetUserName(), true) == 0 && string.Compare(lockInfo.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) == 0) { // Is this lockInfo for an asset? if (lockInfo.GetAssetFilename().GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset) { // Check the user's privilege MOG_Privileges privileges = MOG_ControllerProject.GetPrivileges(); if (!privileges.GetUserPrivilege(MOG_ControllerProject.GetUserName(), MOG_PRIVILEGE.IgnoreSyncAsReadOnly)) { MOG_Filename bestAssetFilename = lockInfo.GetAssetFilename(); // Check if there is a better inbox asset that can be substituted? MOG_Filename inboxAssetFilename = MOG_ControllerInbox.LocateBestMatchingAsset(bestAssetFilename); if (inboxAssetFilename != null) { bestAssetFilename = inboxAssetFilename; } // Check if this asset has it's files synced as read only? MOG_Properties properties = new MOG_Properties(bestAssetFilename); if (properties.SyncAsReadOnly) { switch (lockInfo.GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest: workspace.SetLocalFileAttributes(lockInfo.GetAssetFilename(), FileAttributes.Normal); break; case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRelease: workspace.SetLocalFileAttributes(lockInfo.GetAssetFilename(), FileAttributes.ReadOnly); break; } } } } } } } } } #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_ViewUpdate: #region MOG_COMMAND_ViewUpdate // Make sure this is relevant to our active project? if (string.Compare(command.GetProject(), MOG_ControllerProject.GetProjectName(), true) != 0) { break; } if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Project", true) == 0) { // Process the auto process and package commands switch (MOG_AssetStatus.GetType(command.GetDescription())) { case MOG_AssetStatusType.Modified: case MOG_AssetStatusType.Unprocessed: // Check to see if this command comes from us if (string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) != 0) { break; } // Check for Auto Process if (mainForm.AssetManagerAutoProcessCheckBox.Checked && string.Compare(command.GetUserName(), MOG_ControllerProject.GetUser().GetUserName(), true) == 0) { guiAssetController.Process(command.GetDestination()); } break; //KLK - This may be overkill because we are on the Project tab and why do we want to change their local package button case MOG_AssetStatusType.Packaged: break; case MOG_AssetStatusType.Unpackaged: case MOG_AssetStatusType.Repackage: case MOG_AssetStatusType.PackageError: case MOG_AssetStatusType.Unpackage: // We just got a new asset. Make sure we inform the gui that a package is now required if (mainForm.mAssetManager != null) { mainForm.mAssetManager.RefreshWindowsBoth(command); } break; } } //if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Workspace", true) == 0) if (true) { if (string.Compare(command.GetDescription(), "UnGrouped", true) == 0) { command.SetDestination(""); } try { // Filter out updates to other computers that share our username and project if ((string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) != 0) && (string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.Copied), true) == 0 || string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.Unpackaged), true) == 0 || string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.Repackage), true) == 0 || string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.Packaged), true) == 0 || string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.PackageError), true) == 0 || string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.Unpackage), true) == 0)) { return; } else { mainForm.mAssetManager.RefreshWindowsBoth(command); } } catch (Exception e) { Debug.Write(e.ToString()); } // JohnRen - Changed... // The ViewUpdate command contains the computer name of who generated the view command...not the computer name of the originator of the rip // Because of this, AutoUpdate local would not work anytime somebody else's slave performed the rip. // Changed the AutoUpdate events to respect the login user instead of the computer name because this will be 100% correct... // However, multiple users will experience the event if they are logged in as the same user. // // Process the auto process and package commands // // only do this code if the command came from us // if (string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) == 0) MOG_Filename destinationFilename = new MOG_Filename(command.GetDestination()); if (string.Compare(destinationFilename.GetUserName(), MOG_ControllerProject.GetUserName(), true) == 0) { switch (MOG_AssetStatus.GetType(command.GetDescription())) { case MOG_AssetStatusType.Modified: case MOG_AssetStatusType.Unprocessed: // Check for Auto Process if (mainForm.AssetManagerAutoProcessCheckBox.Checked) { // Only auto-process this if it is in the drafts folder if (destinationFilename.IsDrafts()) { // Make sure we are the ones that requested it if (string.Compare(command.GetUserName(), MOG_ControllerProject.GetUser().GetUserName(), true) == 0 && (string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) == 0)) { guiAssetController.Process(command.GetDestination()); } } } break; case MOG_AssetStatusType.Imported: // Only auto-process this if it is in the drafts folder if (destinationFilename.IsDrafts()) { // Make sure we are the ones that requested it if (string.Compare(command.GetUserName(), MOG_ControllerProject.GetUser().GetUserName(), true) == 0 && (string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) == 0)) { guiAssetController.UpdateLocal(command.GetDestination(), false); } } break; case MOG_AssetStatusType.Processed: case MOG_AssetStatusType.Sent: // Check if the MainForm's AutoUpdate button is checked? if (mainForm.AssetManagerAutoUpdateLocalCheckBox.Checked) { // Only auto-process this if it is in the drafts folder if (destinationFilename.IsDrafts()) { // Make sure we are the ones that requested it if (string.Compare(command.GetUserName(), MOG_ControllerProject.GetUser().GetUserName(), true) == 0 && (string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) == 0)) { // Check if we have a current workspace? if (MOG_ControllerProject.GetCurrentSyncDataController() != null) { guiAssetController.UpdateLocal(command.GetDestination(), false); } } } } break; case MOG_AssetStatusType.Rebuilt: if (mainForm.mAssetManager != null) { mainForm.mAssetManager.RefreshActiveWindow(); } break; case MOG_AssetStatusType.Deleted: MOG_Filename assetName = new MOG_Filename(command.GetSource()); if (assetName.IsTrash() && mainForm.mAssetManager != null && mainForm.mAssetManager.mTrash != null && mainForm.AssetManagerInboxTabControl.SelectedTab.Name == "AssetManagerTrashTabPage") { mainForm.mAssetManager.mTrash.RefreshRemove(command); } else if (assetName.IsLocal() && mainForm.mAssetManager != null) { MOG_Filename tempAssetName = new MOG_Filename(command.GetSource()); } break; } } } #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterEditor: #region MOG_COMMAND_RegisterEditor // We just lost an Editor WorkspaceManager.RegisterEditor(command.GetWorkingDirectory()); #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_ShutdownEditor: #region MOG_COMMAND_ShutdownEditor // We just lost an Editor WorkspaceManager.ShutdownEditor(command.GetWorkingDirectory()); #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_ConnectionLost: #region MOG_COMMAND_ConnectionLost // The server was shutdown Bitmap DisconnectedIcon = new Bitmap(mainForm.StatusBarImageList.Images[1]); mainForm.MOGStatusBarConnectionStatusBarPanel.Icon = System.Drawing.Icon.FromHandle(DisconnectedIcon.GetHicon()); mainForm.MOGStatusBarConnectionStatusBarPanel.Text = "Disconnected"; mainForm.MOGStatusBarConnectionStatusBarPanel.ToolTipText = "Server is disconnected!"; #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_ConnectionNew: #region MOG_COMMAND_ConnectionNew Bitmap ConnectedIcon = new Bitmap(mainForm.StatusBarImageList.Images[0]); mainForm.MOGStatusBarConnectionStatusBarPanel.Icon = System.Drawing.Icon.FromHandle(ConnectedIcon.GetHicon()); mainForm.MOGStatusBarConnectionStatusBarPanel.Text = "Connected"; mainForm.MOGStatusBarConnectionStatusBarPanel.ToolTipText = mainForm.RefreshConnectionToolText(); #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_Complete: #region MOG_COMMAND_Complete // Make sure this contains an encapsulated command? if (command.GetCommand() != null) { // Determin the type of encapsulated command switch (command.GetCommand().GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_Post: #region MOG_COMMAND_PostComplete if (mainForm != null) { // Check if we are on a tab that cares about this event? if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Connections", true) == 0) { if (mainForm.mConnectionManager != null) { // Only listen for the final Post w/o any assetFilename listed or else we would cause too many full refreshes if (command.GetCommand().GetAssetFilename().GetOriginalFilename().Length == 0) { // Refresh the pending package listview mainForm.mConnectionManager.RefreshMerging(); // Refresh the pending post listview mainForm.mConnectionManager.RefreshPosting(); } } } // Check if this remove was successful? if (command.GetCommand().IsCompleted()) { // Someday this would be nice, but the library tab does refresh when it gets reselected so we need to process this event even though we are on another tab // // Check if we are on a tab that cares about this event? // if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Library", true) == 0) // { if (command.GetCommand().GetAssetFilename().IsLibrary()) { if (mainForm.mLibraryManager != null) { mainForm.mLibraryManager.RefreshItem(command); } } // } // Check if we are on a tab that cares about this event? if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Project", true) == 0) { if (mainForm.mProjectManager != null) { mainForm.mProjectManager.MakeAssetCurrent(command.GetCommand().GetAssetFilename()); } } } } #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_ReinstanceAssetRevision: #region MOG_COMMAND_ReinstanceAssetRevision // Check if this remove was successful? if (command.GetCommand().IsCompleted()) { if (mainForm.mProjectManager != null) { mainForm.mProjectManager.RemoveAssetFromProject(new MOG_Filename(command.GetCommand().GetSource())); mainForm.mProjectManager.MakeAssetCurrent(command.GetCommand().GetAssetFilename()); } if (mainForm.LibraryExplorer != null) { mainForm.LibraryExplorer.LibraryListView.RefreshItem(command); } } #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_RemoveAssetFromProject: #region MOG_COMMAND_RemoveAssetFromProject // Check if this remove was successful? if (command.GetCommand().IsCompleted()) { if (mainForm.mProjectManager != null) { mainForm.mProjectManager.RemoveAssetFromProject(command.GetCommand().GetAssetFilename()); } if (mainForm.LibraryExplorer != null) { mainForm.LibraryExplorer.LibraryListView.RefreshItem(command); } } #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_NetworkPackageMerge: case MOG_COMMAND_TYPE.MOG_COMMAND_LocalPackageMerge: case MOG_COMMAND_TYPE.MOG_COMMAND_EditorPackageMergeTask: case MOG_COMMAND_TYPE.MOG_COMMAND_NetworkPackageRebuild: WorkspaceManager.EndPackaging(command.GetCommand().GetWorkingDirectory()); break; } } #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveConnection: #region MOG_COMMAND_NotifyActiveConnection if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Connections", true) == 0) { if (mainForm.mConnectionManager != null) { mainForm.mConnectionManager.UpdateConnections(command); } } #endregion break; // These are the all around locks requested commands from the server case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveLock: #region MOG_COMMAND_NotifyActiveLock switch (command.GetCommand().GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRelease: case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest: case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRelease: case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest: if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Locks", true) == 0) { if (mainForm.mLockManager != null) { mainForm.mLockManager.RefreshLockWindows(command); } } break; } #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshProject: #region MOG_COMMAND_RefreshProject MainMenuProjectsClass.MOGGlobalRefreshProject(mainForm); #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshApplication: break; case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshTools: break; // These are the all around general commands from the server case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveCommand: #region MOG_COMMAND_NotifyActiveCommand // The command manager needs to know about all commands if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Connections", true) == 0) { if (mainForm.mConnectionManager != null) { mainForm.mConnectionManager.UpdateCommands(command); } } #endregion break; } }
public void BuildMerge(bool ShowSyncWindow, bool silent, string tag, string filter, bool updateModifiedMissing, bool cleanUnknownFiles) { //get the sync data controller MOG_ControllerSyncData gameDataHandle = MOG_ControllerProject.GetCurrentSyncDataController(); //if we don't have one infom the user that we need one if (gameDataHandle == null) { MOG_Prompt.PromptMessage("Update Build", "Cannot update a build without a valid local Workspace and Workspace tab created. Create a local Workspace first then try again.", Environment.StackTrace); return; } SyncLatestForm update = new SyncLatestForm(mainForm, mainForm.mAdministratorMode, tag, filter, mDefaultUpdateBuildType, gameDataHandle.GetSyncDirectory(), mCurrentVersion, mHidePlatforms, updateModifiedMissing, cleanUnknownFiles); try { //if we are expected to show the SyncWindow if (ShowSyncWindow) { if (update.ShowDialog(mainForm) == DialogResult.OK) { // Make sure we update our local variables that could get changed within the dialog tag = update.SyncTag; updateModifiedMissing = update.UpdateBuildCheckMissingCheckBox.Checked; cleanUnknownFiles = update.UpdateBuildCleanUnknownFilesCheckBox.Checked; } else { //the result is not ok, so do not proceed with the sync return; } } //get the sync directory from the SyncDataController string targetProjectPath = gameDataHandle.GetSyncDirectory(); // Get the current SyncData controller MOG_ControllerSyncData sync = MOG_ControllerProject.GetCurrentSyncDataController(); if (sync != null) { // Check if the user has specified a cleaning? if (cleanUnknownFiles) { // Check if we need to clean the workspace? string startingPath = sync.GetSyncDirectory(); try { MogUtil_WorkspaceCleaner cleaner = new MogUtil_WorkspaceCleaner(); cleaner.Clean(startingPath); } catch (Exception ex) { MOG_Prompt.PromptMessage("Clean", "The cleaner exited with the following error (" + ex.Message + ")"); } } // Attempt to use the dialog's MOG_LocalSyncInfo MOG_LocalSyncInfo localSyncInfo = update.mLocalSyncInfo; if (localSyncInfo == null) { // Looks like we need to build our own MOG_LocalSyncInfo string computerName = MOG_ControllerSystem.GetComputerName(); string projectName = MOG_ControllerProject.GetProjectName(); string platformName = MOG_ControllerProject.GetPlatformName(); string syncDirectory = MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory(); string userName = MOG_ControllerProject.GetUserName(); string classification = MOG_ControllerProject.GetProjectName(); localSyncInfo = new MOG_LocalSyncInfo(computerName, projectName, platformName, syncDirectory, tag, userName, classification, ""); } // Check if we want to update missing sync.SyncRepositoryData(MOG_ControllerProject.GetProjectName(), update.Exclusions, update.Inclusions, updateModifiedMissing, localSyncInfo); // Show the summary file SyncLatestSummaryForm summary = new SyncLatestSummaryForm(sync.GetSyncLog()); if (silent) { summary.Show(mainForm); } else { summary.ShowDialog(mainForm); } } guiUserPrefs.SaveDynamic_LayoutPrefs("AssetManager", mainForm); update.Dispose(); } catch (Exception e) { MOG_Report.ReportMessage("Update", "Could not perform update due to error:\n\n" + e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR); } }
public static void BlessAssets_Worker(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; List <object> parameters = e.Argument as List <object>; List <MOG_Filename> filenames = parameters[0] as List <MOG_Filename>; string comment = parameters[1] as string; bool maintainLock = (bool)parameters[2]; bool bUserAltered = false; string loginUser = MOG_ControllerProject.GetUser().GetUserName(); string activeUser = MOG_ControllerProject.GetActiveUser().GetUserName(); // Make sure the inbox that we are in matches the logged in user if (string.Compare(MOG_ControllerProject.GetUser().GetUserName(), MOG_ControllerProject.GetActiveUser().GetUserName(), true) != 0) { // Login as this user so that his bless targets will be respected during this bless! MOG_ControllerProject.LoginUser(MOG_ControllerProject.GetActiveUser().GetUserName()); bUserAltered = true; } // Obtain a unique bless jobLabel string timestamp = MOG_Time.GetVersionTimestamp(); string jobLabel = "Bless." + MOG_ControllerSystem.GetComputerName() + "." + timestamp; // Changed to a for-loop to facilitate the loop breakout box on bless failure below for (int assetIndex = 0; assetIndex < filenames.Count; assetIndex++) { MOG_Filename asset = filenames[assetIndex] as MOG_Filename; if (asset != null) { string message = "Blessing:\n" + " " + asset.GetAssetClassification() + "\n" + " " + asset.GetAssetName(); worker.ReportProgress(assetIndex * 100 / filenames.Count, message); // Try to bless each asset and report if there is a failure try { if (MOG_ControllerInbox.BlessAsset(asset, comment, maintainLock, jobLabel, worker)) { WorkspaceManager.MarkLocalAssetBlessed(asset, timestamp); } else { // If there are more assets to bless, ask the user how to proceed if (assetIndex < filenames.Count - 1) { MOGPromptResult result = MOG_Prompt.PromptResponse("Bless Error", "An error has occurred while blessing " + asset.GetAssetFullName() + "\nWould you like to continue blessing assets?", MOGPromptButtons.YesNo); if (result == MOGPromptResult.Yes) { // continue with the next asset continue; } else if (result == MOGPromptResult.No) { // bail return; } } } } catch (Exception ex) { // Send this Exception back to the server MOG_Report.ReportMessage("Bless", ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL); // Check if we are logged in an anyone? if (MOG_ControllerProject.IsUser()) { // Send a notification to the ofending user MOG_Report.ReportMessage("Bless", ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL); } } } } // Start the job MOG_ControllerProject.StartJob(jobLabel); // Restore user if changed if (bUserAltered) { MOG_ControllerProject.LoginUser(loginUser); MOG_ControllerProject.SetActiveUserName(activeUser); } }
public void DisplayUpdateExistingConnections() { //first let's kill the existing ones. foreach (ListViewItem item in mainForm.lviewMonitor.Items) { mainForm.lviewMonitor.Items.Remove(item); } //this needs to walk the connections and add all the connected computers. MOG_CommandServerCS commandServer = (MOG_CommandServerCS)MOG_ControllerSystem.GetCommandManager(); if (commandServer == null) { return; } ArrayList slavesArray = new ArrayList(commandServer.GetRegisteredSlaves()); ArrayList clientsArray = new ArrayList(commandServer.GetRegisteredClients()); ArrayList editorsArray = new ArrayList(commandServer.GetRegisteredEditors()); //show the server first. DislayAddConnection(MOG_ControllerSystem.GetComputerName(), MOG_ControllerSystem.GetComputerIP(), 1, 0, ""); foreach (Object item in clientsArray) { MOG_Command connection = (MOG_Command)item; // Describe the current command of this connection string description = FilterDesiredCommand(connection); if (description != null) { DislayAddConnection(connection.GetComputerName(), connection.GetComputerIP(), connection.GetNetworkID(), MOG_COMMAND_TYPE.MOG_COMMAND_RegisterClient, description); } } foreach (Object item in editorsArray) { MOG_Command connection = (MOG_Command)item; // Describe the current command of this connection string description = FilterDesiredCommand(connection); if (description != null) { DislayAddConnection(connection.GetComputerName(), connection.GetComputerIP(), connection.GetNetworkID(), MOG_COMMAND_TYPE.MOG_COMMAND_RegisterEditor, description); } } foreach (Object item in slavesArray) { MOG_Command connection = (MOG_Command)item; string description; // Check if this Slave is actively assigned anything? MOG_Command workingCommand = connection.GetCommand(); if (workingCommand == null) { // Describe the current command of this connection description = FilterDesiredCommand(connection); } else { // Describe the current command of this connection's command description = FilterDesiredCommand(workingCommand); } if (description != null) { DislayAddConnection(connection.GetComputerName(), connection.GetComputerIP(), connection.GetNetworkID(), MOG_COMMAND_TYPE.MOG_COMMAND_RegisterSlave, description); } } }
/// <summary> /// Create a Directory TreeNode checking to see if this directory is a MOG sync target /// </summary> /// <param name="fullname"></param> /// <returns></returns> private TreeNode CreateDirectoryNode(string fullname, MOG_ControllerSyncData targetGameData) { string name = fullname; try { name = Path.GetFileName(fullname); } catch { } //Check active user for null/empty string and default to Admin if that is the case. string userName = MOG_ControllerProject.GetUserName_DefaultAdmin(); TreeNode directory = new TreeNode(name); directory.Tag = new guiAssetTreeTag(fullname, directory); // This is a virtual directory if (targetGameData != null) { directory.ImageIndex = 5; directory.SelectedImageIndex = 5; directory.Tag = new guiAssetTreeTag(fullname, directory, targetGameData); } else { // Is this a MOG controlled directory - Always remove ' characters when talking to the database? if (MOG.DATABASE.MOG_DBSyncedDataAPI.DoesSyncedLocationExist(MOG_ControllerSystem.GetComputerName(), null, null, fullname.Replace("'", ""), userName)) { ArrayList gameDataArray = MOG.DATABASE.MOG_DBSyncedDataAPI.GetAllSyncedLocations(MOG_ControllerSystem.GetComputerName(), fullname.Replace("'", ""), userName); if (gameDataArray.Count == 1) { MOG_DBSyncedLocationInfo dbLocation = (MOG_DBSyncedLocationInfo)gameDataArray[0]; MOG_ControllerSyncData gameData = new MOG_ControllerSyncData(dbLocation.mWorkingDirectory, dbLocation.mProjectName, dbLocation.mBranchName, dbLocation.mPlatformName, userName); directory.Tag = new guiAssetTreeTag(fullname, directory, gameData); } else if (gameDataArray.Count > 1) { MOG_Report.ReportMessage("Create Mog Aware directory", "Got back too many gameDataControllers for this directory!\n\nDIRECTORY: " + fullname + "\n\nTaking first one...", Environment.StackTrace, MOG_ALERT_LEVEL.ERROR); MOG_DBSyncedLocationInfo dbLocation = (MOG_DBSyncedLocationInfo)gameDataArray[0]; MOG_ControllerSyncData gameData = new MOG_ControllerSyncData(dbLocation.mWorkingDirectory, dbLocation.mProjectName, dbLocation.mBranchName, dbLocation.mPlatformName, userName); directory.Tag = new guiAssetTreeTag(fullname, directory, gameData); } else if (gameDataArray.Count == 0) { MOG_Report.ReportMessage("Create Mog Aware directory", "Got back zero gameDataControllers for this directory!\n\nDIRECTORY: " + fullname, Environment.StackTrace, MOG_ALERT_LEVEL.ERROR); return(directory); } directory.ImageIndex = 4; directory.SelectedImageIndex = 4; } else { directory.ImageIndex = 3; directory.SelectedImageIndex = 3; } } return(directory); }
private void btnCreate_Click(object sender, EventArgs e) { if (IsInformationValid()) { string[] platforms = Platform.Split(",".ToCharArray()); // Make sure there was something specified before we do anything if (platforms.Length > 0) { bool bPromptUser = true; bool bCreatePackage = true; bool bRebuildPackage = false; foreach (string platform in platforms) { // Create the new package name MOG_Filename assetName = MOG_Filename.CreateAssetName(Classification, platform.Trim(), PackageName); // Check if we should prompt the user? if (bPromptUser) { // Don't bother the user again bPromptUser = false; // Check if this was a platform specific package? if (assetName.IsPlatformSpecific()) { // Check if there are ANY assiciated assets with this new platform-specific package? if (MOG_ControllerPackage.GetAssociatedAssetsForPackage(assetName).Count > 0) { // Prompt the user if they wish to automatically populate this new platform-specific packages? string message = "Whenever new platform-specific packages are created, they sometimes need to be populated if existing package assignments exist.\n\n" + "MOG has detected this to be the case and recommends you to automatically populated this package."; MOGPromptResult result = MOG_Prompt.PromptResponse("Automatically populate this new platform-specific package?", message, MOGPromptButtons.YesNo); switch (result) { case MOGPromptResult.Yes: bCreatePackage = true; bRebuildPackage = true; break; case MOGPromptResult.No: bCreatePackage = true; bRebuildPackage = false; break; case MOGPromptResult.Cancel: bCreatePackage = false; bRebuildPackage = false; break; } } } } // Check if we should create the package? if (bCreatePackage) { MOG_Filename newPackage = MOG_ControllerProject.CreatePackage(assetName, SyncTarget); if (newPackage != null) { // Post the new package into the project mAssetName = newPackage; string jobLabel = "NewPackageCreated." + MOG_ControllerSystem.GetComputerName() + "." + MOG_Time.GetVersionTimestamp(); MOG_ControllerProject.PostAssets(MOG_ControllerProject.GetProjectName(), MOG_ControllerProject.GetBranchName(), jobLabel); // Check if we should rebuild the package? if (bRebuildPackage) { jobLabel = "PopulateNewPackage." + MOG_ControllerSystem.GetComputerName() + "." + MOG_Time.GetVersionTimestamp(); // Schedule the rebuild command MOG_ControllerPackage.RebuildPackage(assetName, jobLabel); // Start the job MOG_ControllerProject.StartJob(jobLabel); } // Well, this is a bit of a hack but was the easiest and safest way to ensure unique JobIDs... // JobIDs are only accurate to the microsecond so lets sleep for a very short time. Thread.Sleep(10); // Setting the dialog's result will automatically close the dialog since we proceeded to create the package DialogResult = DialogResult.OK; } } } } } }