static public bool SetLoginBranch(string branch) { if (string.Compare(MOG_ControllerProject.GetBranchName(), branch, true) != 0) { if (MOG_ControllerProject.LoginProject(MOG_ControllerProject.GetProjectName(), branch) != null && string.Compare(MOG_ControllerProject.GetBranchName(), branch, true) == 0) { MessageBox.Show("You have been switched to a different branch of the project.\n" + "Please keep this in mind as you bless assets, browse project trees or configure project settings.\n\n" + " BRANCH: " + branch + "\n", "Changing Project Branch", MessageBoxButtons.OK); UpdateGuiBranch(MOG_ControllerProject.GetBranchName()); // Check if we have a current workspace? if (MOG_ControllerProject.GetCurrentSyncDataController() != null) { // Check if this branch is different than our workspace's branch? if (string.Compare(branch, MOG_ControllerProject.GetCurrentSyncDataController().GetBranchName(), true) != 0) { // Switch the associated branch of the current workspace WorkspaceManager.SwitchCurrentWorkspaceBranch(branch); } } // Update the project manager if it has been initialized if (mainForm.mProjectManager != null) { mainForm.mProjectManager.BuildRepositoryTrees(true); } return(true); } MOG_Prompt.PromptMessage("Login Branch", "Could not login to selected branch!\nProject:" + MOG_ControllerProject.GetProjectName() + "\nBranch:" + branch, Environment.StackTrace); return(false); } return(true); }
public void CreateAssetConfigs() { RaiseAssetImport_Begin(); try { MOG_Project proj = MOG_ControllerProject.GetProject(); if (proj != null) { ProgressDialog progress = new ProgressDialog("Importing Assets", "Please wait while the Assets are imported into the Project's Repository.", CreateAssetConfigs_Worker, null, true); progress.ShowDialog(); // Post the projects new assets skipping the PostScanProcess MOG_ControllerProject.PostAssets(MOG_ControllerProject.GetProjectName(), MOG_ControllerProject.GetBranchName(), MOG_ControllerProject.GetProjectName(), true); } } catch (Exception e) { MOG_Report.ReportMessage("Unable to import asset", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL); } finally { RaiseAssetImport_Finish(); } }
private void CreateAssetConfigs_Worker(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; MOG_ControllerProject.LoginUser("Admin"); // Construct a new common timestamp for all of these assets string timestamp = MOG_Time.GetVersionTimestamp(); // Activate the properties cache to help save time during the importation process MOG_Properties.ActivatePropertiesCache(true); for (int nodeIndex = 0; nodeIndex < assetFilenameNodes.Count; nodeIndex++) { classTreeNode tn = assetFilenameNodes[nodeIndex] as classTreeNode; string fullAssetName = tn.FullPath; //tn.Parent.FullPath + tn.Text; string fileList = Utils.ArrayListToString(tn.importFiles, ""); // Check if this is a library asset? bool bIsInLibrary = false; if (tn.TreeView != null) { string fullPath = tn.FullPath + tn.TreeView.PathSeparator; string testPath = tn.TreeView.PathSeparator + "Library" + tn.TreeView.PathSeparator; if (fullPath.IndexOf(testPath, 0, StringComparison.CurrentCultureIgnoreCase) != -1) { bIsInLibrary = true; } } MOG_Filename repositoryName = null; if (bIsInLibrary && tn.importFiles.Count > 0) { // Use the timestamp of the file (Needed for out-of-date checks with library assets) String libraryTimestamp = ""; FileInfo file = new FileInfo(tn.importFiles[0] as string); if (file != null && file.Exists) { libraryTimestamp = MOG_Time.GetVersionTimestamp(file.LastWriteTime); } repositoryName = MOG_ControllerRepository.GetAssetBlessedVersionPath(new MOG_Filename(fullAssetName), libraryTimestamp); } else { // Use the common timestamp for all the assets repositoryName = MOG_ControllerRepository.GetAssetBlessedVersionPath(new MOG_Filename(fullAssetName), timestamp); } MOG_Filename createdAssetFilename = null; string message = "Importing:\n" + " " + repositoryName.GetAssetClassification() + "\n" + " " + repositoryName.GetAssetName(); worker.ReportProgress(nodeIndex * 100 / assetFilenameNodes.Count, message); if (worker.CancellationPending) { if (Utils.ShowMessageBoxConfirmation("Are you sure you want to cancel asset importation?", "Cancel Asset Importation?") == MOGPromptResult.Yes) { return; } } try { string dirScope = MOG_ControllerAsset.GetCommonDirectoryPath(this.projectRootPath, tn.importFiles); // Construct our list non-inherited asset assuming none ArrayList props = null; if (tn.props != null) { // Ask the tn.props for the list of non-inherited properties props = tn.props.GetNonInheritedProperties(); } else { props = new ArrayList(); // Setup SyncTargetPath Property string assetDirectoryScope = MOG_ControllerAsset.GetCommonDirectoryPath(this.projectRootPath, tn.importFiles); if (assetDirectoryScope.Length > this.projectRootPath.Length) { string syncTargetPath = assetDirectoryScope.Substring(this.projectRootPath.Length + 1); props.Add(MOG.MOG_PropertyFactory.MOG_Sync_OptionsProperties.New_SyncTargetPath(syncTargetPath)); } } // Proceed to import the asset createdAssetFilename = MOG_ControllerAsset.CreateAsset(repositoryName, dirScope, tn.importFiles, null, props, false, false); if (createdAssetFilename == null) { // it's probably a network problem (TODO: Check for sure) // build a list of files for error message string files = "\n\nFiles contained in " + tn.Text + "\n"; foreach (string fname in tn.importFiles) { files += "\t" + fname + "\n"; } MOGPromptResult r = MOG_Prompt.PromptResponse("Import Error", "Importation of " + tn.FullPath + " failed. Please ensure that the file is accessible and click Retry." + files, MOGPromptButtons.AbortRetryIgnore); if (r == MOGPromptResult.Retry) { --nodeIndex; // stay on the same node (continue auto-increments) continue; } else if (r == MOGPromptResult.Abort) { RaiseAssetImport_Finish(); MOG_Prompt.PromptResponse("Cancelled", "Importation Cancelled", Environment.StackTrace, MOGPromptButtons.OK, MOG_ALERT_LEVEL.MESSAGE); return; } else if (r == MOGPromptResult.Ignore) { continue; } } // Schedule this asset for posting under this project name MOG_ControllerProject.AddAssetForPosting(createdAssetFilename, MOG_ControllerProject.GetProjectName()); } catch (Exception ex) { MOG_Report.ReportMessage("Create Asset", "Could not correctly create asset.\nMessage=" + ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL); continue; } } // Shut off the properties cache MOG_Properties.ActivatePropertiesCache(false); }
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; } } } } } }
public void UpdateCommands(MOG_Command command) { ListViewItem item; MOG_Command action = command.GetCommand(); if (action != null) { bool bAdd = false; bool bRemove = false; switch (action.GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_None: case MOG_COMMAND_TYPE.MOG_COMMAND_ConnectionKill: case MOG_COMMAND_TYPE.MOG_COMMAND_ConnectionLost: case MOG_COMMAND_TYPE.MOG_COMMAND_ConnectionNew: case MOG_COMMAND_TYPE.MOG_COMMAND_InstantMessage: case MOG_COMMAND_TYPE.MOG_COMMAND_LaunchSlave: case MOG_COMMAND_TYPE.MOG_COMMAND_LockCopy: case MOG_COMMAND_TYPE.MOG_COMMAND_LockMove: 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: case MOG_COMMAND_TYPE.MOG_COMMAND_LoginProject: case MOG_COMMAND_TYPE.MOG_COMMAND_LoginUser: case MOG_COMMAND_TYPE.MOG_COMMAND_NetworkBroadcast: case MOG_COMMAND_TYPE.MOG_COMMAND_NewBranch: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveCommand: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveConnection: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveLock: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemAlert: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemError: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemException: case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterClient: case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterCommandLine: case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterEditor: case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterSlave: case MOG_COMMAND_TYPE.MOG_COMMAND_RequestActiveCommands: case MOG_COMMAND_TYPE.MOG_COMMAND_RequestActiveConnections: case MOG_COMMAND_TYPE.MOG_COMMAND_ShutdownClient: case MOG_COMMAND_TYPE.MOG_COMMAND_ShutdownCommandLine: case MOG_COMMAND_TYPE.MOG_COMMAND_ShutdownEditor: case MOG_COMMAND_TYPE.MOG_COMMAND_ShutdownSlave: case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshApplication: case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshTools: case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshProject: case MOG_COMMAND_TYPE.MOG_COMMAND_ViewConnection: case MOG_COMMAND_TYPE.MOG_COMMAND_ViewLock: case MOG_COMMAND_TYPE.MOG_COMMAND_ActiveViews: case MOG_COMMAND_TYPE.MOG_COMMAND_ViewUpdate: // Eat these commands, we don't need to show them in this window break; case MOG_COMMAND_TYPE.MOG_COMMAND_Complete: // Drill one more level into this Complete command action = action.GetCommand(); bRemove = true; break; // All other commands can simply be added default: bAdd = true; break; } // Check if we are removing the command? if (bRemove) { // Strip out any matching commands do { // Find it using specific information // item = LocateItem((int)CommandsColumns.COMMANDID, action.GetCommandID().ToString(), mainForm.ConnectionManagerCommandsListView); item = LocateCommandItem(action); if (item != null) { item.Remove(); } } while(item != null); } // Check if we are adding the command? if (bAdd) { // Find it using a generic approach item = LocateCommandItem(action); if (item != null) { // Check if this could replace an existing command? if (action.IsRemoveDuplicateCommands()) { // Remove the duplicate item.Remove(); item = null; } } // Check if the item already exists if (item == null) { //It doesn't already exist, so let's make a new one item = new ListViewItem(); MOG_Time time = new MOG_Time(); time.SetTimeStamp(command.GetCommandTimeStamp()); string assetFullName = "PROJECT: " + action.GetProject() + " ASSET: " + action.GetAssetFilename().GetAssetOriginalFullName(); if (string.Compare(action.GetProject(), MOG_ControllerProject.GetProjectName(), true) == 0) { assetFullName = action.GetAssetFilename().GetAssetFullName(); } item.Text = action.ToString(); item.SubItems.Add(assetFullName); item.SubItems.Add(action.GetPlatform()); item.SubItems.Add(action.IsCompleted() ? "Working" : ""); item.SubItems.Add(action.GetJobLabel()); item.SubItems.Add(action.GetComputerName().ToString()); item.SubItems.Add(action.GetComputerIP().ToString()); item.SubItems.Add(action.GetNetworkID().ToString()); item.SubItems.Add(action.GetCommandID().ToString()); item.Tag = action; item.ImageIndex = GetImageIndex(action.GetCommandType()); mainForm.ConnectionManagerCommandsListView.Items.Add(item); } } } }
public string GetClientStatusDescription(MOG_Command command) { // Describe the current command of this connection string description = ""; // Check if this was a registered slave reporting? switch (command.GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterSlave: description = "Idle"; // Get the contained command this slave is working on MOG_Command slaveTask = command.GetCommand(); if (slaveTask != null) { // Check if we have a ProjectName specified? if (slaveTask.GetProject().Length > 0) { // Add on our ProjectName description = "PROJECT: " + slaveTask.GetProject(); } // Check if there is an encoded platform in this command? if (slaveTask.GetPlatform().Length > 0) { // Get the slave's active platform description += " PLATFORM: " + slaveTask.GetPlatform(); } // Check if we have a UserName specified? if (slaveTask.GetUserName().Length > 0) { // Add on our ProjectName description += " USER: "******" COMMAND: " + slaveTask.ToString(); // Make sure we are in the same project if (string.Compare(slaveTask.GetProject(), MOG_ControllerProject.GetProjectName(), true) == 0) { // Check if we have an asset specified? if (slaveTask.GetAssetFilename().GetAssetName().Length > 0) { // Build the slave's description description += " ASSET: " + slaveTask.GetAssetFilename().GetAssetName(); } } } break; default: // Check if we have a ProjectName specified? if (command.GetProject().Length > 0) { // Add on our ProjectName description += "PROJECT: " + command.GetProject(); } // Check if we have a ProjectName specified? if (command.GetBranch().Length > 0) { // Add on our ProjectName description += " BRANCH: " + command.GetBranch(); } // Check if we have a UserName specified? if (command.GetUserName().Length > 0) { // Add on our ProjectName description += " USER: "******" TAB: " + command.GetTab(); } // Check if we have a Platform specified? if (command.GetPlatform().Length > 0) { description += " PLATFORM: " + command.GetPlatform(); } // Check if we have a Tab specified? if (command.GetUserName().Length > 0) { description += " INBOX: " + command.GetUserName(); } break; } return(description); }
static private void LaunchBuild(MogMainForm mainForm, string command, MOG_Ini options) { // Extract the Build's Options string BuildPlatform = ""; string BuildType = ""; // Split up the Build's Options string [] commands = command.Trim().Split(" ".ToCharArray()); if (command.Length == 0 || commands.Length < 1) { MOG_Prompt.PromptMessage("Request build", "Bad or missing command (" + command + ") in request build!", Environment.StackTrace); return; } BuildType = commands[0]; if (commands.Length > 1) { BuildPlatform = commands[1]; } // Get the list of available slaves to use for builds // Get the highest slaves string validSlaves = ""; if (options.SectionExist("Builds.ValidSlaves") && options.KeyExist("Builds.ValidSlaves", "Builds")) { validSlaves = options.GetString("Builds.ValidSlaves", "Builds"); } string buildTypeSection = "Builds." + BuildType; // Locate the buildTool within the Build.Options.Info file string buildTool = ""; // Determine what the executable name is if (options.SectionExist(buildTypeSection)) { // Check for a buildTypeSection level validSlaves definition if (options.SectionExist("Builds.ValidSlaves") && options.KeyExist("Builds.ValidSlaves", buildTypeSection)) { validSlaves = options.GetString("Builds.ValidSlaves", buildTypeSection); } // Check if a specific BuildPlatform was specified? and // Check if we have keys in our buildTypeSection? if (BuildPlatform.Length > 0 && options.CountKeys(buildTypeSection) > 0) { // Obtain the build tool for this build type and BuildPlatform buildTool = options.GetString(buildTypeSection, BuildPlatform); if (buildTool.Length > 0) { // Check for a BuildPlatform level validSlaves definition if (options.SectionExist("Builds.ValidSlaves") && options.KeyExist("Builds.ValidSlaves", buildTypeSection + "." + BuildPlatform)) { validSlaves = options.GetString("Builds.ValidSlaves", buildTypeSection + "." + BuildPlatform); } } } else if (options.KeyExist("Builds", BuildType)) { buildTool = options.GetString("Builds", BuildType); } else { } } // Make sure we have a valid build tool? if (buildTool.Length > 0) { // Locate the buildTool in the tools directories string buildToolRelativePath = Path.GetDirectoryName(buildTool); buildTool = MOG_ControllerSystem.LocateTool(buildToolRelativePath, buildTool); if (buildTool.Length > 0) { //:: ----------------------------------------------------------------------- //:: MOG ENVIRONMENT VARIABLES //:: ----------------------------------------------------------------------- string EnvVariables = MOG_EnvironmentVars.CreateToolsPathEnvironmentVariableString(buildToolRelativePath) + "," + MOG_EnvironmentVars.GetBuildProjectName() + "=" + MOG_ControllerProject.GetProjectName() + "," + MOG_EnvironmentVars.GetBuildProjectBranchName() + "=" + MOG_ControllerProject.GetBranchName() + "," + MOG_EnvironmentVars.GetBuildType() + "=" + BuildType + "," + MOG_EnvironmentVars.GetBuildPlatformName() + "=" + BuildPlatform + "," + MOG_EnvironmentVars.GetBuildTool() + "=" + buildTool + "," + MOG_EnvironmentVars.GetBuildToolPath() + "=" + System.IO.Path.GetDirectoryName(buildTool) + "," + MOG_EnvironmentVars.GetBuildRequestedBy() + "=" + MOG_ControllerProject.GetUser().GetUserName(); // Fire off the build if (MOG_ControllerProject.Build(buildTool, validSlaves, MOG_ControllerProject.GetUser().GetUserName(), EnvVariables)) { string message = "Build Request Successfull.\n" + "You will be notified when it is completed."; MessageBox.Show(message, "Refresh Build", MessageBoxButtons.OK); } } else { string message = "MOG was unable to locate the specified build tool.\n" + "BUILD TOOL: " + buildTool + "\n\n" + "Your MOG Administrator may need to internalize this tool before it will work."; MOG_Prompt.PromptMessage("Request Build", message); } } else { string message = "No build tool was located for the selected build type.\n" + "BUILD TYPE: " + buildTypeSection + "\n\n" + "Your MOG Administrator may need to edit the 'Build.Options.Info' file to configure this build type."; MOG_Prompt.PromptMessage("Request Build", message); } }
static public void MOGGlobalToolsRequestBuild(MogMainForm mainForm, MenuItem MenuPlatform) { // Build default values string targetProject = MOG_ControllerProject.GetProject().GetProjectCvsName().ToLower(); string targetDirectory = MOG_ControllerProject.GetProject().GetProjectBuildDirectory(); string sourceDirectory = MOG_ControllerProject.GetProject().GetProjectToolsPath(); // Get the build type string parentMenu = MenuPlatform.Parent.ToString().ToLower(); // Parse the string to get to the name "Advent.Gold" then move our index to the length of the word "advent" + 1 for the "." string BuildType = parentMenu.Substring(parentMenu.LastIndexOf(targetProject) + targetProject.Length + 1); // Get the list of available slaves to use for builds string validSlaves = ""; if (MOG_ControllerProject.GetProject().GetConfigFile().SectionExist("BuildMachines")) { for (int i = 0; i < MOG_ControllerProject.GetProject().GetConfigFile().CountKeys("BuildMachines"); i++) { if (validSlaves.Length == 0) { validSlaves = MOG_ControllerProject.GetProject().GetConfigFile().GetKeyNameByIndexSLOW("BuildMachines", i); } else { validSlaves = string.Concat(validSlaves, ",", MOG_ControllerProject.GetProject().GetConfigFile().GetKeyNameByIndexSLOW("BuildMachines", i)); } } } string platform; // Determine BuildPlatform if (string.Compare(MenuPlatform.Text, "All", true) == 0) { ArrayList platformList = MOG_ControllerProject.GetProject().GetPlatforms(); for (int p = 0; p < platformList.Count; p++) { MOG_Platform MogPlatform = (MOG_Platform)platformList[p]; platform = MogPlatform.mPlatformName; // Create build name string buildName = string.Concat(MOG_ControllerProject.GetProjectName(), ".", "Build.", targetProject, ".", BuildType, ".AdventGameCode.", platform); // Fire the refresh build // if (MOG_ControllerProject.Build(buildName, sourceDirectory, targetDirectory, validSlaves, false, MOG_ControllerProject::GetActiveUser().GetUserName(), "")) // { // MessageBox.Show(string.Concat("Server has recieved your build request for a (", BuildPlatform, ") build. You will be notified when it completes."), "Refresh Build", MOGPromptButtons.OK); // } } } else { platform = MenuPlatform.Text; // Create build name string buildName = string.Concat(MOG_ControllerProject.GetProjectName(), ".", "Build.", targetProject, ".", BuildType, ".AdventGameCode.", platform); // Fire the refresh build // if (MOG_ControllerProject.Build(buildName, sourceDirectory, targetDirectory, validSlaves, false, MOG_ControllerProject::GetActiveUser().GetUserName(), "")) // { // MessageBox.Show("Server has recieved your build request. You will be notified when it completes.", "Refresh Build", MOGPromptButtons.OK); // } } }