Esempio n. 1
0
        /// <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);
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
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;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
 private void btnRestart_Click(object sender, EventArgs e)
 {
     MOG_ControllerProject.StartJob(mCommand.GetJobLabel());
 }