/// <summary> /// Utility method for the Package portion of AfterLabelEdit() (above) /// </summary> private ArrayList GetValidTargetSyncPath(NodeLabelEditEventArgs e, MOG_Filename packageName) { // Get the gameDataPath for this new package GameDataPathForm getPath = new GameDataPathForm(packageName.GetAssetPlatform(), packageName.GetAssetName()); ArrayList targetSyncPath = null; // This dialog should be pushed to topmost when it doesn't have a parent or else it can ger lost behind other apps. // You would think this is simple but for some reason MOG has really struggled with these dialogs being kept on top... // We have tried it all and finally ended up with this...toggling the TopMost mode seems to be working 100% of the time. getPath.TopMost = true; getPath.TopMost = false; getPath.TopMost = true; // Show the dialog if (DialogResult.Cancel != getPath.ShowDialog()) { targetSyncPath = getPath.MOGPropertyArray; // Get a value for our relative gamedata path string relativePath = null; if (targetSyncPath.Count > 0) { relativePath = ((MOG_Property)targetSyncPath[0]).mPropertyValue; } // If we found our relativePath... if (relativePath != null) { // Go ahead and add an initial backslash, if necessary... if (relativePath.Length > 0 && relativePath[0] != '\\') { relativePath = "\\" + relativePath; } // Find all our assets with this gamedata path ArrayList assets = MOG_DBAssetAPI.GetAllAssetsBySyncLocation(relativePath, packageName.GetAssetPlatform()); // If we found assets... if (assets != null && assets.Count > 0) { // Check and see if any of the assets we found match the package we want to add... foreach (MOG_Filename asset in assets) { // If we already have the package name we want to add, warn user and quit... if (asset.GetAssetName().ToLower() == packageName.GetAssetName().ToLower()) { MessageBox.Show(this, "Package name, " + packageName.GetAssetName() + ", already exists in location, '" + relativePath.Substring(1) + "'!", "Package Already Exists!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); e.Node.EndEdit(true); e.Node.Remove(); return null; } } } } } // Finished our method, so return true return targetSyncPath; }
private ListViewItem AddItemToListView(MOG_Filename mogAsset, MOG_Properties pProperties, string fullPath) { ListViewItem item = new ListViewItem(); foreach (ColumnHeader column in ListListView.Columns) { item.SubItems.Add(""); } SetSubColumnText(item, "Name", mogAsset.GetAssetLabel()); SetSubColumnText(item, "MOG Classification", mogAsset.GetAssetClassification()); SetSubColumnText(item, "Platform", mogAsset.GetAssetPlatform()); SetSubColumnText(item, "Version", mogAsset.GetVersionTimeStampString("")); if (pProperties != null) { SetSubColumnText(item, "Size", guiAssetController.FormatSize(pProperties.Size)); SetSubColumnText(item, "Package", GetPackages(pProperties)); SetSubColumnText(item, "Creator", pProperties.Creator); SetSubColumnText(item, "Last Bless", pProperties.Owner); SetSubColumnText(item, "Computer", pProperties.SourceMachine); SetSubColumnText(item, "GamePath", pProperties.SyncTargetPath); SetSubColumnText(item, "Last Comment", pProperties.LastComment); } SetSubColumnText(item, "Fullname", fullPath); // Icon item.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(mogAsset.GetOriginalFilename(), pProperties, false); return(ListListView.Items.Add(item)); }
/// <summary> /// Add group or object to the database /// </summary> private bool AddGroupToDatabase(string addCandidate, MOG_Filename packageAsset) { // Are we platform generic? bool success = true; if (packageAsset.GetAssetPlatform() == "All") { string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset); if (packageVersion.Length > 0) { success = MOG_DBPackageAPI.AddPackageGroupName(packageAsset, packageVersion, addCandidate, MOG_ControllerProject.GetUser().GetUserName()); } } // We are platform generic, loop through all platforms then ArrayList platforms = MOG_ControllerProject.GetProject().GetPlatforms(); for (int p = 0; p < platforms.Count && success; p++) { MOG_Platform platform = (MOG_Platform)platforms[p]; // Set this package to be platform specific for this platform name packageAsset = MOG_Filename.CreateAssetName(packageAsset.GetAssetClassification(), platform.mPlatformName, packageAsset.GetAssetLabel()); string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset); if (packageVersion.Length > 0) { // Add to the database success &= MOG_DBPackageAPI.AddPackageGroupName(packageAsset, packageVersion, addCandidate, MOG_ControllerProject.GetUser().GetUserName()); } } return success; }
/// <summary> /// Prepare a drag object to recieve any driped items from the package tree /// </summary> private DataObject PrepareDragObject(TreeView tree, TreeNode node) { // failsafe for unpopulated package lists if (tree.Nodes.Count <= 0) { return(null); } // Create our list holders ArrayList packages = new ArrayList(); MOG_Filename package = new MOG_Filename(node.Text); // Get the package names if (package.GetAssetPlatform().Length == 0) { // We need to make a new MOG_Filename with a valid platform // To do this we need to get to the class, label and desired platform string classification = FindClassification(node); string packgePath = IsolatePackagePath(node.FullPath, classification); if (packgePath.Length > 0) { package = MOG_Filename.CreateAssetName(classification, "All", packgePath); // Add the platforms foreach (MOG_Platform platform in MOG_ControllerProject.GetProject().GetPlatforms()) { package = MOG_Filename.CreateAssetName(classification, platform.mPlatformName, packgePath); packages.Add(package.GetAssetFullName()); } } else { MOG_Prompt.PromptMessage("Create package name", "Could not locate pachage path in package(" + node.FullPath + ")"); return(null); } } else { packages.Add(package.GetAssetFullName()); } if (packages.Count > 0) { // Create a new Data object for the send return(new DataObject("Package", packages)); } return(null); }
private string GetTargetName(MOG_Filename assetCheck, string classification, string platform, string label) { // Rename according to pattern string targetName = ""; // Attach classification (e.g. "textures~humans") if (classification == "*") { targetName += assetCheck.GetAssetClassification(); } else { targetName += classification; } // Attach platform label (e.g. 'all' OR 'pc' OR 'xbox') if (platform == "*") { targetName += "{" + assetCheck.GetAssetPlatform() + "}"; } else { targetName += "{" + platform + "}"; } // Attach label for files (e.g. 'body') if (label == "*") { targetName += assetCheck.GetAssetLabel(); } else { targetName += label; } return(targetName); }
public static MOG_Property RepairProperty(MOG_Property propertyObject) { MOG_Property fixedPropertyObject = null; string key = propertyObject.mKey; string section = propertyObject.mSection; string propertySection = propertyObject.mPropertySection; string propertyKey = propertyObject.mPropertyKey; string propertyValue = propertyObject.mPropertyValue; MOG_Property tempProperty = MOG_PropertyFactory.MOG_Relationships.New_RelationshipAssignment("", "", "", ""); MOG_Property tempPackageProperty = MOG_PropertyFactory.MOG_Relationships.New_PackageAssignment("", "", ""); MOG_Property tempSourceFileProperty = MOG_PropertyFactory.MOG_Relationships.New_AssetSourceFile(""); // Check if this property is a package relationship? if (string.Compare(section, tempPackageProperty.mSection, true) == 0) { string assetName = MOG_ControllerPackage.GetPackageName(propertyKey); string groups = MOG_ControllerPackage.GetPackageGroups(propertyKey); string objects = MOG_ControllerPackage.GetPackageObjects(propertyKey); // Remap various properties making sure we correct any problem areas MOG_Filename assetFilename = null; // Check if this property is a SourceFile relationship? if (string.Compare(propertySection, tempSourceFileProperty.mPropertySection, true) == 0) { // Check if the specified file is within the library? if (MOG_ControllerLibrary.IsPathWithinLibrary(propertyKey)) { // Map this library file to a real asset name assetFilename = MOG_ControllerProject.MapFilenameToLibraryAssetName(assetName, MOG_ControllerProject.GetPlatformName()); if (assetFilename != null) { fixedPropertyObject = MOG_PropertyFactory.MOG_Relationships.New_AssetSourceFile(assetFilename.GetFullFilename()); } } } else { // Try to find the assetname for the specified asset ArrayList assets = MOG_ControllerProject.MapFilenameToAssetName(assetName, MOG_ControllerProject.GetPlatformName(), MOG_ControllerProject.GetWorkspaceDirectory()); if (assets == null || assets.Count == 0) { // The package could not be found if (string.Compare(propertySection, tempPackageProperty.mPropertySection, true) == 0) { // Check if we actually had something specified? if (assetName.Length > 0) { // Set the deafult packageFilename info string assetClassification = ""; string assetPlatformName = "All"; string assetLabel = DosUtils.PathGetFileNameWithoutExtension(assetName); string syncTargetPath = DosUtils.PathGetDirectoryPath(assetName); // Check if the assetName was already a valid MOG_Filename? MOG_Filename packageFilename = new MOG_Filename(assetName); if (packageFilename.GetAssetClassification().Length > 0) { assetClassification = MOG_Filename.AppendAdamObjectNameOnClassification(packageFilename.GetAssetClassification()); } if (packageFilename.GetAssetPlatform().Length > 0) { assetPlatformName = packageFilename.GetAssetPlatform(); } if (packageFilename.GetAssetLabel().Length > 0) { assetLabel = packageFilename.GetAssetLabel(); } // Prompt user to complete the unknown information about this packageFile string message = "MOG has detected a new package assignment to a previously non-existing package. Please complete the following red fields so that a proper package can be created in MOG."; PackageCreator creator = new PackageCreator(); creator.Classification = assetClassification; creator.PackageName = assetLabel; creator.SyncTarget = syncTargetPath; creator.Platform = assetPlatformName; if (creator.ShowDialog() == DialogResult.OK) { // Use this newly created packageFilename as our assetFilename to be fixed assetFilename = creator.AssetName; } else { // The PackageName is invalid message = "New Package Not Created.\n" + "The user chose not to create a new package."; MOG_Report.ReportMessage("Package Assignment", message, Environment.StackTrace, MOG_ALERT_LEVEL.ERROR); } } else { // The PackageName is invalid string message = "Invalid PackageName specified.\n" + "The packaged asset was not assigned to a package."; MOG_Report.ReportMessage("Package Assignment", message, Environment.StackTrace, MOG_ALERT_LEVEL.ERROR); } } } else { // Always use the first one assetFilename = assets[0] as MOG_Filename; MOG_ControllerProject.MapFilenameToAssetName_WarnAboutAmbiguousMatches(assetName, assets); } // Now do we finally have a package asset name? if (assetFilename != null) { // Replace the propertyObject with the fixed up one fixedPropertyObject = MOG_PropertyFactory.MOG_Relationships.New_RelationshipAssignment(propertySection, assetFilename.GetAssetFullName(), groups, objects); } } } // Check if we fixed the property? if (fixedPropertyObject != null) { return(fixedPropertyObject); } return(propertyObject); }
string ResolveToken(string token) { string value = ""; // Make sure this token starts with the '{'? if (token.StartsWith("{")) { // Get the name of this token string[] parts = token.Split("{}.".ToCharArray(), 3); // Make sure this resembled a real token? if (parts.Length == 3) { // Check for any contained commands? string testToken = "{" + parts[1] + "}"; // Determine which token we have? switch (testToken) { // Repository Tokens case TOKEN_Repository_Path: value = MOG_ControllerSystem.GetSystemRepositoryPath(); break; case TOKEN_Repository_ProjectsPath: value = MOG_ControllerSystem.GetSystemProjectsPath(); break; case TOKEN_Repository_ToolsPath: value = MOG_ControllerSystem.GetSystemRepositoryPath() + "\\Tools"; break; case TOKEN_Repository_Project_Path: value = MOG_ControllerProject.GetProjectPath(); break; case TOKEN_Repository_Project_ToolsPath: value = MOG_ControllerProject.GetProjectPath() + "\\Tools"; break; case TOKEN_Repository_Project_AssetsPath: value = MOG_ControllerRepository.GetRepositoryPath(); break; case TOKEN_Repository_Project_ArchivePath: value = MOG_ControllerRepository.GetArchivePath(); break; case TOKEN_Repository_Project_UsersPath: value = MOG_ControllerProject.GetProjectPath() + "\\Users"; break; // Project Tokens case TOKEN_Project_Name: value = MOG_ControllerProject.GetProjectName(); break; case TOKEN_Project_BranchName: value = MOG_ControllerProject.GetBranchName(); break; case TOKEN_Project_UserName: value = MOG_ControllerProject.GetUserName_DefaultAdmin(); break; case TOKEN_Project_PlatformName: value = MOG_ControllerProject.GetPlatformName(); break; case TOKEN_Project_WorkspaceDirectory: value = MOG_ControllerProject.GetWorkspaceDirectory(); break; // Ripper Tokens case TOKEN_Ripper_SourcePath: value = mRipperSourcePath; break; case TOKEN_Ripper_SourceFilePattern: value = mRipperSourceFilePattern; break; case TOKEN_Ripper_DestinationPath: value = mRipperDestinationPath; break; // Package Tokens case TOKEN_Package_WorkspaceDirectory: if (mPackageFileInfo != null) { value = mPackageFileInfo.mPackageWorkspaceDirectory; } break; case TOKEN_Package_DataDirectory: if (mPackageFileInfo != null) { value = mPackageFileInfo.mPackageDataDirectory; } break; case TOKEN_Package_PackageFile_Filename: if (mPackageFileInfo != null) { value = mPackageFileInfo.mPackageFile; } break; case TOKEN_Package_PackageFile_FullName: { MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment)); value = packageFilename.GetAssetFullName(); } break; case TOKEN_Package_PackageFile_Classification: { MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment)); value = packageFilename.GetAssetClassification(); } break; case TOKEN_Package_PackageFile_Label: { MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment)); value = packageFilename.GetAssetLabel(); } break; case TOKEN_Package_PackageFile_Platform: { MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment)); value = packageFilename.GetAssetPlatform(); } break; case TOKEN_Package_PackageFile_Group: value = MOG_ControllerPackage.GetPackageGroups(mPackageAssignment); break; case TOKEN_Package_PackageFile_Object: value = MOG_ControllerPackage.GetPackageObjects(mPackageAssignment); break; // Inbox Tokens case TOKEN_Inbox_UserName: value = mAssetFilename.GetUserName(); break; case TOKEN_Inbox_UserPath: value = mAssetFilename.GetUserPath(); break; case TOKEN_Inbox_BoxName: value = mAssetFilename.GetBoxName(); break; case TOKEN_Inbox_BoxPath: value = mAssetFilename.GetBoxPath(); break; // Asset Tokens case TOKEN_Asset_AssetName_Path: value = mAssetFilename.GetPath(); break; case TOKEN_Asset_AssetName_FullName: value = mAssetFilename.GetAssetFullName(); break; case TOKEN_Asset_AssetName_Classification: value = mAssetFilename.GetAssetClassification(); break; case TOKEN_Asset_AssetName_Name: value = mAssetFilename.GetAssetName(); break; case TOKEN_Asset_AssetName_PlatformName: value = mAssetFilename.GetAssetPlatform(); break; case TOKEN_Asset_AssetName_Label: value = mAssetFilename.GetAssetLabel(); break; case TOKEN_Asset_ImportedFile: case TOKEN_Asset_RippedFile: value = ResolveToken_AssetFile(token); break; case TOKEN_Asset_Property: value = ResolveToken_Property(token); break; case TOKEN_Asset_ClassificationPath: value = MOG_Filename.GetClassificationPath(mAssetFilename.GetAssetClassification()); break; case TOKEN_Asset_VersionTimeStamp: value = mAssetFilename.GetVersionTimeStamp(); break; } // Check if we have a command? if (parts[2] != ".") { } } } return(value); }
/// <summary> /// Update an existing ListView node for the asset manager inboxes /// </summary> /// <param name="pProperties"></param> /// <param name="nodeColor"></param> /// <returns></returns> public static void UpdateListViewItem(ListViewItem item, MOG_Filename asset, string status, MOG_Properties pProperties) { string date = ""; string size = ""; string creator = ""; string owner = ""; string group = ""; string target = ""; // Check if we have a properties? if (pProperties != null) { // If we have a valid gameDataController, set our platform scope if (MOG_ControllerProject.GetCurrentSyncDataController() != null) { // Set our current platform pProperties.SetScope(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName()); } // Gather the following info from our properties date = MOG_Time.FormatTimestamp(pProperties.CreatedTime, ""); size = guiAssetController.FormatSize(pProperties.Size); creator = pProperties.Creator; owner = pProperties.Owner; group = pProperties.Group; // Check if this is a packaged asset? if (pProperties.IsPackagedAsset) { // Check if we have have any package assignments in our propeerties? ArrayList packages = pProperties.GetPackages(); if (packages.Count == 0) { // Indicate this is a packaged asset w/o any package assignments target = "Missing package assignment..."; } else if (packages.Count == 1) { MOG_Property package = packages[0] as MOG_Property; MOG_Filename packageName = new MOG_Filename(MOG_ControllerPackage.GetPackageName(package.mPropertyKey)); string packageGroupPath = MOG_ControllerPackage.GetPackageGroups(package.mPropertyKey); string displayString = MOG_ControllerPackage.CombinePackageAssignment(packageName.GetAssetLabel(), packageGroupPath, ""); target = "{Package} " + displayString + " in " + MOG_Filename.GetAdamlessClassification(packageName.GetAssetClassification()); } else { target = "{Package} " + packages.Count + " Assignments..."; } } else if (pProperties.SyncFiles) { // Get the formatted SyncTarget of this asset target = MOG_Tokens.GetFormattedString("{Workspace}\\" + pProperties.SyncTargetPath, asset, pProperties.GetPropertyList()); } } item.Text = asset.GetAssetLabel(); // Populate the item's SubItems // I tried for a long time to be smart here and use ColumnNameFind(thisListView.Columns, "Name") but // I kept running into walls because this function is used by a lot of workers outside of the ListView's thread. // So, I gave up and am just going to do it the ugly brute force way! YUCK!! item.SubItems[(int)AssetBoxColumns.NAME].Text = asset.GetAssetLabel(); item.SubItems[(int)AssetBoxColumns.CLASS].Text = asset.GetAssetClassification(); item.SubItems[(int)AssetBoxColumns.TARGETPATH].Text = target; item.SubItems[(int)AssetBoxColumns.DATE].Text = date; item.SubItems[(int)AssetBoxColumns.SIZE].Text = size; item.SubItems[(int)AssetBoxColumns.PLATFORM].Text = asset.GetAssetPlatform(); item.SubItems[(int)AssetBoxColumns.STATE].Text = status; item.SubItems[(int)AssetBoxColumns.CREATOR].Text = creator; item.SubItems[(int)AssetBoxColumns.RESPPARTY].Text = owner; item.SubItems[(int)AssetBoxColumns.OPTIONS].Text = ""; item.SubItems[(int)AssetBoxColumns.FULLNAME].Text = asset.GetEncodedFilename(); item.SubItems[(int)AssetBoxColumns.BOX].Text = asset.GetBoxName(); item.SubItems[(int)AssetBoxColumns.GROUP].Text = group; // Set the item's Icons item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(asset.GetEncodedFilename(), pProperties); if (MogMainForm.MainApp != null && MogMainForm.MainApp.mAssetManager != null) { // mAssetStatus.GetStatusInfo() is sort of a black sheep and should maybe become static item.StateImageIndex = MogMainForm.MainApp.mAssetManager.mAssetStatus.GetStatusInfo(status).IconIndex; } // Set the item's color item.ForeColor = MOG_AssetStatus.GetColor(status); // Check if this is a local item that has been blessed? if (asset.IsLocal() && string.Compare(status, MOG_AssetStatus.GetText(MOG_AssetStatusType.Blessed), true) == 0) { // Mark local blessed items with light gray item.ForeColor = Color.LightGray; } }
private void InitializeAssetNames(ArrayList sourceFiles) { RenameListView.Items.Clear(); InitializePlatformComboBox(); string listOfBlessedAssets = ""; // Check for presence of wildcards foreach (string fullFilename in sourceFiles) { MOG_Filename asset = new MOG_Filename(fullFilename); // If this Asset has been previously blessed... if (CheckIfAssetHasBeenBlessed(asset)) { listOfBlessedAssets += asset.GetAssetFullName() + "\r\n"; } // Get the imported filenames ArrayList importFiles = DosUtils.FileGetRecursiveList(MOG_ControllerAsset.GetAssetImportedDirectory(MOG_Properties.OpenFileProperties(fullFilename + "\\Properties.info")), "*.*"); if (importFiles.Count > 1) { // If there are more that one, then we cannot rename the files of this asset RenameFiles.Checked = false; RenameFiles.Enabled = false; importFilename = "*Complex asset*"; } else { String importFile = importFiles[0] as string; // Does this asset label match the imported filename? if (string.Compare(DosUtils.PathGetFileNameWithoutExtension(importFile), DosUtils.PathGetFileNameWithoutExtension(asset.GetAssetLabel()), true) == 0) { // All is good then importFilename = DosUtils.PathGetFileName(importFile); } else { // We cannot rename the files of this asset because the label and the imported filename do not match RenameFiles.Checked = false; RenameFiles.Enabled = false; importFilename = string.Format("Asset label({0}) and imported filename({1}) do not match!", DosUtils.PathGetFileNameWithoutExtension(asset.GetAssetLabel()), DosUtils.PathGetFileNameWithoutExtension(importFile)); } } mFullFilename = fullFilename; ListViewItem item = RenameListView.Items.Add(asset.GetAssetFullName()); item.SubItems.Add(asset.GetAssetFullName()); item.SubItems.Add(asset.GetAssetEncodedPath()); item.SubItems.Add(importFilename); item.Selected = true; CheckStringForMatch(ref mCommonClass, asset.GetAssetClassification()); CheckStringForMatch(ref mCommonPlatform, asset.GetAssetPlatform()); CheckStringForMatch(ref mCommonLabel, asset.GetAssetLabel()); } // If we have any Blessed Assets and we don't have privilege to rename them, warn the user if (listOfBlessedAssets.Length > 0 && !CheckPrivilegeToRename()) { MOG_Prompt.PromptMessage("Insufficient privileges to rename already blessed assets", "You do not have permission to rename these previously blessed assets:\r\n" + listOfBlessedAssets); } // Else, If we have any Blessed Assets, warn user about the rename else if (listOfBlessedAssets.Length > 0) { MOG_Prompt.PromptMessage("Inbox renames don't rename previously blessed assets", "The following blessed assets will still exist when renamed assets are blessed:\r\n" + listOfBlessedAssets); } RenameListView.Select(); InitializeTextBoxes(mCommonClass, mCommonPlatform, mCommonLabel); // Make it so that our user will hopefully type over the "*" when assigning a classification... if (mCommonClass == "*") { this.RenameNewClassNameTextBox.SelectAll(); } bInitialized = true; } // end ()
private void InitializeAssetName(MOG_Filename mogFilename) { InitializePlatformComboBox(); InitializeTextBoxes(mogFilename.GetAssetClassification(), mogFilename.GetAssetPlatform(), mogFilename.GetAssetName()); }
public static bool RebuildNetworkPackage(MOG_Filename packageFilename, string jobLabel) { // Make sure this represents the currently blessed revision of this package if (!packageFilename.IsWithinRepository()) { // Obtain the current revision for this specified package packageFilename = MOG_ControllerProject.GetAssetCurrentBlessedVersionPath(packageFilename); } // Now we should be ensured a package located within the repository if (packageFilename.IsWithinRepository()) { // Send our Rebuild package command to the server MOG_Command rebuildPackageCommand = MOG_CommandFactory.Setup_NetworkPackageRebuild(packageFilename.GetEncodedFilename(), packageFilename.GetAssetPlatform(), jobLabel); return(MOG_ControllerSystem.GetCommandManager().SendToServer(rebuildPackageCommand)); } return(false); }
/// <summary> /// Remove a Group or Package Object from the database /// </summary> /// <param name="removeCandidate">Full path of Group or Object with /// '/' as delimiter, starting from package name.</param> /// <param name="packageAsset">The Asset that is the Package</param> /// <param name="platformGeneric"> /// Whether or not this is a platform Generic operation. /// /// This is where the "Show Platform Specific" checkbox would /// plug in from the PackageManagementTreeView /// </param> /// <returns>Bool indicating success/failure</returns> public bool RemoveGroupFromDatabase(string removeCandidate, MOG_Filename packageAsset) { try { bool success = true; // Get the current version of this package string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset); // Check to see if any assets reference this if (MOG_DBPackageAPI.GetAllAssetsInPackageGroup(packageAsset, packageVersion, removeCandidate).Count == 0) { // If all is ok, remove it from the database success &= MOG_DBPackageAPI.RemovePackageGroupName(packageAsset, packageVersion, removeCandidate, MOG_ControllerProject.GetUser().GetUserName()); } else { throw (new Exception("Cannot remove object or group that is used by active assets!")); } // Are we platform generic? if (String.Compare(packageAsset.GetAssetPlatform(), "All", true) == 0) { // We are platform generic, loop through all platforms then ArrayList platforms = MOG_ControllerProject.GetProject().GetPlatforms(); for (int p = 0; p < platforms.Count; p++) { MOG_Platform platform = (MOG_Platform)platforms[p]; // Set this package to be platform specific for this platform name packageAsset = MOG_Filename.CreateAssetName(packageAsset.GetAssetClassification(), platform.mPlatformName, packageAsset.GetAssetLabel()); packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset); if (packageVersion.Length > 0) { // Check to see if any assets reference this if (MOG_DBPackageAPI.GetAllAssetsInPackageGroup(packageAsset, packageVersion, removeCandidate).Count == 0) { // If all is ok, remove it from the database success &= MOG_DBPackageAPI.RemovePackageGroupName(packageAsset, packageVersion, removeCandidate, MOG_ControllerProject.GetUser().GetUserName()); } else { throw (new Exception("Cannot remove object or group that is used by active assets!")); } } } } return success; } catch (Exception e) { // Get the current version of this package string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset); // See if we can report to the user about why this node could not be deleted ArrayList assignedAssets = MOG_DBPackageAPI.GetAllAssetsInPackageGroup(packageAsset, packageVersion, removeCandidate); if (assignedAssets != null) { // Walk all associated assets and make a list string assets = ""; foreach (MOG_Filename assetName in assignedAssets) { if (assets.Length == 0) { assets = assetName.GetEncodedFilename(); } else { assets = assets + "\n" + assetName.GetEncodedFilename(); } } // Tell the user MOG_Prompt.PromptMessage("Remove node", "Cannot remove this node because the following assets are assigned to it:\n\n" + assets); } else { // This must have been another problem MOG_Prompt.PromptMessage("Remove node", "Cannot remove this node.\nMessage\n" + e.Message); } } return false; }