示例#1
0
        /// <summary>
        /// Remove packages from Assets currently selected.  Use CheckForBlessedAssetMessage() before calling.
        /// </summary>
        /// <param name="packagesToRemove">ArrayList of MOG_Property objects for packages to be removed</param>
        private void RemovePackageLinkFromAssets(ArrayList packagesToRemove)
        {
            foreach (ListViewItem item in AssetList.Items)
            {
                MOG_Filename assetFilename = item.Tag as MOG_Filename;
                if (assetFilename != null)
                {
                    // If this asset is not a blessed Asset, and it's not a classification...
                    if (!assetFilename.IsBlessed() && assetFilename.GetFilenameType() != MOG_FILENAME_TYPE.MOG_FILENAME_Unknown)
                    {
                        // Open up this asset so we can remove the package relationships
                        MOG_ControllerAsset asset = MOG_ControllerAsset.OpenAsset(assetFilename);
                        if (asset != null)
                        {
                            // Remove the packages
                            asset.GetProperties().RemovePackages(packagesToRemove);
                            // Depending on how the user clicked, it is possible that an inherited package assignment can be left behind as a non-inherited property
                            // The following code ensures all non-inherited package assignments are flushed by restamping any non-inherited assignemnts.
                            asset.GetProperties().SetProperties(asset.GetProperties().GetNonInheritedPackages());

                            // Make sure we keep the group in sync with our new assignment
                            MOG_ControllerAsset.SetDefaultGroup(asset);

                            // Change the state of the asset to indicate it has been modified
                            MOG_ControllerInbox.UpdateInboxView(asset, MOG_AssetStatusType.Modifying);
                            ModifyingAssets = true;

                            asset.Close();
                        }
                    }
                    else
                    {
                        // We should be looking at a classification, so treat it as such...
                        MOG_Properties properties = MOG_Properties.OpenClassificationProperties(assetFilename.GetOriginalFilename());
                        if (properties != null)
                        {
                            properties.RemovePackages(packagesToRemove);
                            properties.Close();
                        }
                    }
                }
            }
        }
示例#2
0
        private bool AddPackageLinkToAssets(string packageName, Color color, bool markAsInherited, bool setPackageProperties)
        {
            bool success = true;

            ListViewItem item = FindAssignmentListItem(packageName);

            if (item == null)
            {
                item           = new ListViewItem(packageName);
                item.ForeColor = color;
                AssignmentList.Items.Add(item);

                if (setPackageProperties)
                {
                    success = false;

                    ArrayList PackageAssignmentProps = new ArrayList();
                    PackageAssignmentProps.Add(CreatePackageAssignmentProperty(packageName));

                    // Go through our listview items again to Add or Remove assets we found in the previous foreach loop
                    foreach (ListViewItem assetItem in AssetList.Items)
                    {
                        MOG_Filename assetFilename = assetItem.Tag as MOG_Filename;
                        if (assetFilename != null &&
                            assetFilename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                        {
                            // If this asset is not a blessed Asset, and it's not a classification...
                            if (!assetFilename.IsBlessed())
                            {
                                MOG_ControllerAsset asset = MOG_ControllerAsset.OpenAsset(assetFilename);
                                if (asset != null)
                                {
                                    if (asset.GetProperties().AddPackages(PackageAssignmentProps))
                                    {
                                        success = true;

                                        // Make sure we keep the group in sync with our new assignment
                                        MOG_ControllerAsset.SetDefaultGroup(asset);

                                        // Change the state of the asset to indicate it has been modified
                                        MOG_ControllerInbox.UpdateInboxView(asset, MOG_AssetStatusType.Modifying);
                                        ModifyingAssets = true;
                                    }

                                    asset.Close();
                                }
                            }
                            else
                            {
                                MOG_Prompt.PromptMessage("Cannot add PackageAssignments to Blessed Assets",
                                                         "Please copy the Asset to your Inbox and change its package assignments from there so it can be properly processed and re-Blessed.",
                                                         "",
                                                         MOG.PROMPT.MOG_ALERT_LEVEL.ALERT);
                            }
                        }
                        else if (assetFilename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Unknown)
                        {
                            // We should be looking at a classification, so treat it as such...
                            MOG_Properties properties = MOG_Properties.OpenClassificationProperties(assetFilename.GetOriginalFilename());
                            if (properties != null)
                            {
                                if (properties.AddPackages(PackageAssignmentProps))
                                {
                                    success = true;
                                }
                                properties.Close();
                            }
                        }
                    }
                }
            }

            if (item != null && markAsInherited)
            {
                item.Font = new Font(AssignmentList.Font, FontStyle.Italic);
            }

            if (!success)
            {
                MOG_Report.ReportMessage("Error Adding Package Assignment", "Failed to add package assignment!", Environment.StackTrace, MOG_ALERT_LEVEL.ERROR);
            }

            return(success);
        }