Exemple #1
0
        public List <string> GetAssets(TreeNode node)
        {
            ArrayList assetList          = new ArrayList();
            string    nodeClassification = node.FullPath;

            // Check if we should show asset-level nodes?
            if (ShowAssets || ExpandPackageGroups)
            {
                // Check if this is a classification we want to display everything in?
                if (ShowEntireClassificationContents(nodeClassification))
                {
                    // Get the list of assets
                    assetList = MOG_DBAssetAPI.GetAllAssetsByClassification(nodeClassification);
                }
                else
                {
                    assetList = GetRequiredAssets(nodeClassification);
                }
            }

            // Exclude assets from our list that have undefined the property
            assetList = ExcludeAssets(assetList, nodeClassification);

            // Prepare our list of assets for return
            List <string> returnAssets = new List <string>();

            foreach (MOG_Filename asset in assetList)
            {
                // Check if we want to exclude platform-specific asset?
                if (!ShowPlatformSpecific)
                {
                    MOG_Filename filename = new MOG_Filename(asset);
                    if (filename.IsPlatformSpecific())
                    {
                        continue;
                    }
                }

                returnAssets.Add(asset.GetAssetFullName());
            }

            return(returnAssets);
        }
Exemple #2
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;
                            }
                        }
                    }
                }
            }
        }