Beispiel #1
0
        private void CheckValidClassificationExists()
        {
            // If, after we initialize, our TreeView is not Enabled, that means we have nothing to display...
            if (!PackageTree.TreeView.Enabled)
            {
                MOGPromptResult result = MOG_Prompt.PromptResponse("Missing Package Classification",
                                                                   "Package Management requires a package classification.\r\n\r\n"
                                                                   + "MOG can automatically set the '1stPackage' property for you on a specific classification where packages can be added.\r\n\r\n"
                                                                   + "Do you want to enable Package Management in your project?"
                                                                   , MOGPromptButtons.YesNo);
                if (result != MOGPromptResult.Yes)
                {
                    this.Close();
                }
                else
                {
                    // Allow the user to choose the classification he/she would like to use as the first IsPackage Classification
                    BrowseClassTreeForm bctForm = new BrowseClassTreeForm();
                    bctForm.StartPosition = FormStartPosition.CenterParent;
                    bctForm.Text          = "Choose Classification To Add Packages To";

                    if (bctForm.ShowDialog(this) == DialogResult.OK)
                    {
                        string         classificationName = bctForm.Tag as string;
                        MOG_Properties props = MOG_Properties.OpenClassificationProperties(classificationName);
                        props.IsPackage = true;
                        props.Close();
                        PackageTree.TreeView.Enabled = true;
                        PackageTree.TreeView.DeInitialize();
                    }
                    else
                    {
                        this.Close();
                    }
                }
            }
        }
		private bool CheckLabelEdit(NodeLabelEditEventArgs e)
		{
			// Make sure that the node was actually edited.  If not, make them do it again...
			if (e.Label == null)
			{
				e.CancelEdit = true;
				// Show our MessageBox and allow user to decide whether they want to continue editting or not
				MOGPromptResult result = MOG_Prompt.PromptResponse("Create new node", "It seems you have entered an invalid name, try again?", MOGPromptButtons.YesNo);

				// If user is telling us they want to cancel the edit...
				if (result == MOGPromptResult.No)
				{
					e.Node.Remove();
				}
				// Else, try again
				else
				{
					e.Node.BeginEdit();
				}

				return false;
			}
			return true;
		}
        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);
            }
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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;
                            }
                        }
                    }
                }
            }
        }