private void PackageManagementForm_Closing(object sender, System.ComponentModel.CancelEventArgs e) { guiUserPrefs.SaveDynamic_LayoutPrefs(guiUserPrefs.PackageManagementForm_Text, this); // Check if we were modyifying assets? if (ModifyingAssets) { // Itterate through all the assets and mark them as being modified foreach (ListViewItem item in AssetList.Items) { MOG_Filename assetFilename = item.Tag as MOG_Filename; if (assetFilename != null) { // Open up this asset so we can remove the package relationships MOG_ControllerAsset asset = MOG_ControllerAsset.OpenAsset(assetFilename); if (asset != null) { if (asset.GetProperties().NativeDataType) { MOG_ControllerInbox.UpdateInboxView(asset, MOG_AssetStatusType.Processed); } else { MOG_ControllerInbox.UpdateInboxView(asset, MOG_AssetStatusType.Modified); } asset.Close(); } } } } }
public static void MarkLocalAssetBlessed(MOG_Filename assetFilename, string blessedTimestamp) { // Walk through all of our workspaces foreach (MOG_ControllerSyncData workspace in mWorkspaces.Values) { // Check if this is the current workspace? or // Check if this workspace is active? if (workspace == MOG_ControllerProject.GetCurrentSyncDataController() || workspace.IsAlwaysActive()) { // Build the expected path to this asset in our local workspace MOG_Filename workspaceAsset = MOG_Filename.GetLocalUpdatedTrayFilename(workspace.GetSyncDirectory(), assetFilename); // Open the local asset MOG_ControllerAsset localAsset = MOG_ControllerAsset.OpenAsset(workspaceAsset); if (localAsset != null) { // Stamp this locally update asset with the newly blessed revision timestamp localAsset.GetProperties().BlessedTime = blessedTimestamp; // Change the state of this asset to blessed MOG_ControllerInbox.UpdateInboxView(localAsset, MOG_AssetStatusType.Blessed); localAsset.Close(); } } } }
/// <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(); } } } } }
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); }
static public bool AddAssetToWorkspaces(MOG_Filename assetFilename, bool userInitiated, BackgroundWorker worker) { bool bFailed = false; // Open the asset now to save time later so it doesn't need to be opened for each workspace MOG_ControllerAsset asset = MOG_ControllerAsset.OpenAsset(assetFilename); if (asset != null) { try { // Walk through all of our workspaces foreach (MOG_ControllerSyncData workspace in mWorkspaces.Values) { bool bAddAsset = false; // Check if this workspace is active? if (workspace.IsAlwaysActive()) { bAddAsset = true; } // Imported asset has special logic else if (asset.GetProperties().Status == MOG_AssetStatus.GetText(MOG_AssetStatusType.Imported)) { // Check if this asset originated from within this workspace? (special case added for SmartBomb so editor will always update the workspace of an object sent from the editor) if (DosUtils.PathIsWithinPath(workspace.GetSyncDirectory(), asset.GetProperties().SourcePath)) { bAddAsset = true; } // Check if the user actually initiated this event? else if (userInitiated && workspace == MOG_ControllerProject.GetCurrentSyncDataController()) { bAddAsset = true; } } // All other assets should simply go into the current else if (workspace == MOG_ControllerProject.GetCurrentSyncDataController()) { bAddAsset = true; } // Should this asset be added? if (bAddAsset) { // Decide if the user wants to be notified about the asset's update bool bInformUser = userInitiated; // Check if no worker was specified? or // Check if this isn't the active workspace? if (worker == null || workspace != MOG_ControllerProject.GetCurrentSyncDataController()) { // Don't bother the user about any problems bInformUser = false; } // Check if we can add this asset to the local workspace? if (workspace.CanAddAssetToLocalWorkspace(asset, bInformUser)) { // Check if this asset comming from an inbox? and // Check if this asset comming from our inbox? and // Check if this asset's current state is 'Imported' and // Check if this asset originated from this workspace? // Finally, Make sure this wasn't user initiated? if (assetFilename.IsWithinInboxes() && string.Compare(assetFilename.GetUserName(), MOG_ControllerProject.GetUserName(), true) == 0 && string.Compare(asset.GetProperties().Status, MOG_AssetStatus.GetText(MOG_AssetStatusType.Imported), true) == 0 && MOG_Filename.IsWithinPath(workspace.GetSyncDirectory(), asset.GetProperties().SourcePath) && !userInitiated) { // Looks like we can proceed to import if (!workspace.AddAssetToLocalUpdatedTray(asset, worker)) { bFailed = true; } // Continue on to the next asset continue; } // Proceed to add the asset to this workspace if (!workspace.AddAssetToLocalWorkspace(asset, worker)) { bFailed = true; } } } } } finally { asset.Close(); } } else { bFailed = true; } if (!bFailed) { return(true); } return(false); }