private void CreateLateResolverItem(MOG_DBPackageCommandInfo packageCommand) { MOG_Filename assetName = new MOG_Filename(packageCommand.mAssetName); if (assetName.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset) { ListViewItem item = new ListViewItem(); // "NAME, CLASSIFICATION, DATE, TARGET PACKAGE, OWNER, FULLNAME, COMMANDID, LABEL, VERSION" item.Text = assetName.GetAssetLabel(); item.SubItems.Add(assetName.GetAssetClassification()); // Class item.SubItems.Add(MogUtils_StringVersion.VersionToString(packageCommand.mAssetVersion)); item.SubItems.Add(packageCommand.mPackageName); item.SubItems.Add((packageCommand.mBlessedBy.Length != 0) ? packageCommand.mBlessedBy : packageCommand.mCreatedBy); item.SubItems.Add(packageCommand.mAssetName); item.SubItems.Add(packageCommand.mID.ToString()); item.SubItems.Add(packageCommand.mLabel); item.SubItems.Add(packageCommand.mAssetVersion); item.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(packageCommand.mAssetName, null, false); mainForm.ConnectionManagerLateResolversListView.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; }
private ArrayList GetRequiredAssets(string classification) { ArrayList requiredAssetList = new ArrayList(); // Break up classification into its parts string[] classificationParts = MOG_Filename.SplitClassificationString(classification); // Scan our list of required assets looking for any immediate children that should be included? foreach (DictionaryEntry requiredAsset in mRequiredAssets) { MOG_Filename requiredAssetFilename = new MOG_Filename(requiredAsset.Key.ToString()); string requiredClassification = requiredAssetFilename.GetAssetClassification(); // Check if classification is a parent for requiredClassification? if (MOG_Filename.IsParentClassificationString(requiredClassification, classification)) { // Break up classification into its parts string[] requiredClassificationParts = MOG_Filename.SplitClassificationString(requiredClassification); // Make sure there is an immediate child classification we can extract? if (requiredClassificationParts.Length == classificationParts.Length) { requiredAssetList.Add(requiredAssetFilename); } } } return(requiredAssetList); }
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)); }
private void CheckPackages(HybridDictionary packages, bool markAsInherited) { // Add our packages to our mogPackagesSet and expand the tree to that node foreach (DictionaryEntry entry in packages) { string package = entry.Key as string; int count = (int)entry.Value; // Generate a MOG_Filename and concat our path from it MOG_Filename packageFile = new MOG_Filename(package); string assetName = packageFile.GetAssetName(); string assetFullName = packageFile.GetAssetClassification() + assetName; // Make sure we have this Package selected (if possible) TreeNode node = FindPackageNode(assetFullName); if (node == null) { node = AddPackageNode(assetFullName); } if (node != null) { if (count < AssetList.Items.Count) { node.ForeColor = Color.Gray; } if (markAsInherited) { node.NodeFont = new Font(node.TreeView.Font, FontStyle.Italic); } node.Checked = true; } } }
/// <summary> SetAssetIcon /// Searches through mAssetTypes to find the matching key with /// that of the filename. Then returns the index /// </summary> /// <param name="filename"></param> /// <returns>index of icon in the mAssetTypeImages list</returns> static public int GetClassIconIndex(String filename) { // Construct a filename MOG_Filename file = null; try { file = new MOG_Filename(filename); } catch (Exception e) { e.ToString(); return(0); } string classification; switch (file.GetFilenameType()) { case MOG_FILENAME_TYPE.MOG_FILENAME_Asset: classification = file.GetAssetClassification(); break; case MOG_FILENAME_TYPE.MOG_FILENAME_Group: classification = "group"; break; default: classification = filename; break; } // Get the index of the key in the types array int x = 0; foreach (string classType in mAssetTypes) { if (string.Compare(classType, classification, true) == 0) { break; } else { x++; } } // If the asset was not found, return for first icon in the list if (x >= mAssetTypes.Count) { return(0); } // Return the index of the icon return(x); } // end ()
/// <summary> SetAssetIcon /// Searches through mAssetTypes to find the matching key with /// that of the filename. Then returns the index /// </summary> /// <param name="filename"></param> /// <returns>index of icon in the mAssetTypeImages list</returns> static public int GetClassIconIndex(string filename, MOG_Properties properties) { // Construct a filename MOG_Filename file = null; try { file = new MOG_Filename(filename); } catch (Exception e) { e.ToString(); return(0); } string classification; switch (file.GetFilenameType()) { case MOG_FILENAME_TYPE.MOG_FILENAME_Asset: classification = file.GetAssetClassification(); break; case MOG_FILENAME_TYPE.MOG_FILENAME_Group: classification = "group"; break; default: classification = filename; break; } try { TstDictionaryEntry node = mAssetTypes.Find(classification); if (node != null && node.IsKey) { return((int)node.Value); } else { if (properties == null) { // If we didn't get anything, we need to load this icon into our array properties = new MOG_Properties(classification); } return(MogUtil_AssetIcons.LoadIcon(properties.ClassIcon, classification)); } } catch { return(0); } } // end ()
/// <summary> SetAssetIcon /// Searches through mAssetTypes to find the matching key with /// that of the filename. Then returns the index /// </summary> /// <param name="filename"></param> /// <returns>index of icon in the mAssetTypeImages list</returns> static public int GetClassIconIndex(string filename, MOG_Properties properties) { // Construct a filename MOG_Filename file = null; try { file = new MOG_Filename(filename); } catch (Exception e) { e.ToString(); return(0); } string classification; string lockName; switch (file.GetFilenameType()) { case MOG_FILENAME_TYPE.MOG_FILENAME_Asset: classification = file.GetAssetClassification(); lockName = file.GetAssetFullName(); break; case MOG_FILENAME_TYPE.MOG_FILENAME_Group: classification = "group"; lockName = file.GetAssetFullName(); break; default: classification = filename; lockName = classification; break; } // Check for locks on this asset if (MOG_ControllerProject.IsLocked(lockName)) { // Currently we dont distinguish between read and write locks return(GetLockedIcon(lockName, IconType.CLASS, properties)); } else { return(FindOrAddIcon(ref properties, IconType.CLASS, classification, classification)); } } // end ()
static public int GetAssetIconIndex(string filename, MOG_Properties properties, bool bCheckLockedIcons) { // Construct a filename MOG_Filename file = null; try { file = new MOG_Filename(filename); } catch (Exception e) { e.ToString(); return(0); } string assetName = "default"; switch (file.GetFilenameType()) { case MOG_FILENAME_TYPE.MOG_FILENAME_Asset: assetName = file.GetAssetClassification(); break; case MOG_FILENAME_TYPE.MOG_FILENAME_Group: assetName = "group"; break; default: assetName = filename; break; } // Check for locks on this asset if (bCheckLockedIcons == true && MOG_ControllerProject.IsLocked(file.GetAssetFullName())) { // Currently we dont distinguish between read and write locks return(GetLockedIcon(assetName, IconType.ASSET, properties)); } else { return(FindOrAddIcon(ref properties, IconType.ASSET, assetName, assetName + "_ASSET")); } }
private ArrayList GetRequiredClassificationChildren(string classification) { ArrayList childClassificationList = new ArrayList(); // Scan our list of required classifications looking for any immediate children that should be included? foreach (DictionaryEntry requiredClassification in mRequiredClassifications) { // Parse for the immediate child of this classification string childClassification = ParseForChildClassification(classification, requiredClassification.Key.ToString()); if (childClassification.Length > 0) { // Make sure we don't already have this child? if (!childClassificationList.Contains(childClassification)) { // Add this child classification childClassificationList.Add(childClassification); } } } // Scan our list of required assets looking for any immediate children that should be included? foreach (DictionaryEntry requiredAsset in mRequiredAssets) { // Obtain the classification from the asset MOG_Filename requiredAssetFilename = new MOG_Filename(requiredAsset.Key.ToString()); string requiredClassification = requiredAssetFilename.GetAssetClassification(); // Parse for the immediate child of this classification string childClassification = ParseForChildClassification(classification, requiredClassification); if (childClassification.Length > 0) { // Make sure we don't already have this child? if (!childClassificationList.Contains(childClassification)) { // Add this child classification childClassificationList.Add(childClassification); } } } return(childClassificationList); }
public virtual void MakeAssetCurrent(MOG_Filename assetFilename) { // Make sure this assetFilename has the info we want if (assetFilename != null && assetFilename.GetVersionTimeStamp().Length > 0) { TreeNode foundNode = FindNode(assetFilename.GetAssetFullName()); if (foundNode != null) { // Update this parent node with the new information concerning this asset Mog_BaseTag assetTag = foundNode.Tag as Mog_BaseTag; if (assetTag != null) { assetTag.FullFilename = assetFilename.GetOriginalFilename(); } } else { // Try to find the asset's classification node? foundNode = FindNode(assetFilename.GetAssetClassification()); if (foundNode != null) { // Create a new asset node TreeNode assetNode = CreateAssetNode(assetFilename); // Find the right spot in the list for this new asset int insertPosition = 0; foreach (TreeNode node in foundNode.Nodes) { if (string.Compare(node.Text, assetNode.Text, true) < 0) { insertPosition++; } break; } // Insert the new asset node foundNode.Nodes.Insert(insertPosition, assetNode); } } } }
public List <string> DrillToAsset_BuildDrillPathParts(MOG_Filename assetFilename, bool includeRevisions) { List <string> parts = new List <string>(); if (Nodes != null) { if (Nodes.Count > 0) { if (!String.IsNullOrEmpty(assetFilename.GetOriginalFilename())) { // Add classification elements string classification = assetFilename.GetAssetClassification(); if (!String.IsNullOrEmpty(classification)) { string[] classificationParts = MOG_Filename.SplitClassificationString(classification); parts.AddRange(classificationParts); // Add asset name elements string assetName = assetFilename.GetAssetName(); if (!String.IsNullOrEmpty(assetName)) { parts.Add(assetName); // Check if we have a version? if (!String.IsNullOrEmpty(assetFilename.GetVersionTimeStamp()) && includeRevisions) { // Date format string string dateFormat = MOG_Tokens.GetMonth_1() + "/" + MOG_Tokens.GetDay_1() + "/" + MOG_Tokens.GetYear_4() + " " + MOG_Tokens.GetHour_1() + ":" + MOG_Tokens.GetMinute_2() + " " + MOG_Tokens.GetAMPM(); parts.Add(Revisions_Text); parts.Add("<" + assetFilename.GetVersionTimeStampString(dateFormat) + ">"); } } } } } } return(parts); }
private void ClearInheritedPackageAssignments() { foreach (ListViewItem item in AssignmentList.Items) { // Generate a MOG_Filename and concat our path from it MOG_Filename packageFile = new MOG_Filename(item.Text); string assetName = packageFile.GetAssetName(); string assetFullName = packageFile.GetAssetClassification() + assetName; // Find this package's node TreeNode node = FindPackageNode(assetFullName); if (node != null) { // Check if this was inherited? if (node.NodeFont != null && node.NodeFont.Italic) { // Clear the check and reset its font node.Checked = false; node.NodeFont = new Font(AssignmentList.Font, FontStyle.Regular); } } } }
private ListViewItem CreateListViewItemForAsset(MOG_Filename asset) { ListViewItem item = null; // Only put the asset in the list if it is actually a library asset if (asset.IsLibrary()) { // Make sure we have something valid in our Filename if (asset.GetAssetLabel().Length > 0) { item = new ListViewItem(asset.GetAssetLabel()); // Get the source imported file MOG_Filename repositoryAssetFilename = MOG_ControllerRepository.GetAssetBlessedVersionPath(asset, asset.GetVersionTimeStamp()); string repositoryFile = MOG_ControllerLibrary.ConstructBlessedFilenameFromAssetName(repositoryAssetFilename); string localFile = MOG_ControllerLibrary.ConstructLocalFilenameFromAssetName(repositoryAssetFilename); string extension = DosUtils.PathGetExtension(localFile); // Populate the item item.SubItems.Add(extension); // Extension item.SubItems.Add(asset.GetAssetClassification()); // Classification item.SubItems.Add(""); // User item.SubItems.Add(""); // Comment item.SubItems.Add(""); // Local TimeStamp item.SubItems.Add(asset.GetVersionTimeStampString("")); // Server Timestamp item.SubItems.Add("New"); // Status item.SubItems.Add(asset.GetAssetFullName()); // Fullname item.SubItems.Add(localFile); // LocalFile item.SubItems.Add(repositoryFile); // RepositoryFile // Update the item UpdateItem(item); } } return(item); }
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); }
private void CreatePostItem(MOG_DBPostInfo post) { MOG_Filename assetName = new MOG_Filename(post.mAssetName); if (assetName.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset) { ListViewItem item = new ListViewItem(); // "NAME, CLASSIFICATION, DATE, OWNER, FULLNAME, COMMANDID" item.Text = assetName.GetAssetLabel(); //item.SubItems.Add(assetName.GetAssetLabel()); item.SubItems.Add(assetName.GetAssetClassification()); item.SubItems.Add(MogUtils_StringVersion.VersionToString(post.mAssetVersion)); item.SubItems.Add(post.mBlessedBy); item.SubItems.Add(post.mAssetName); item.SubItems.Add(post.mID.ToString()); item.SubItems.Add(post.mLabel); item.SubItems.Add(post.mAssetVersion); item.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(post.mAssetName, null, false); mainForm.ConnectionManagerPostingListView.Items.Add(item); } }
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); }
private void CreateAssetConfigs_Worker(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; MOG_ControllerProject.LoginUser("Admin"); // Construct a new common timestamp for all of these assets string timestamp = MOG_Time.GetVersionTimestamp(); // Activate the properties cache to help save time during the importation process MOG_Properties.ActivatePropertiesCache(true); for (int nodeIndex = 0; nodeIndex < assetFilenameNodes.Count; nodeIndex++) { classTreeNode tn = assetFilenameNodes[nodeIndex] as classTreeNode; string fullAssetName = tn.FullPath; //tn.Parent.FullPath + tn.Text; string fileList = Utils.ArrayListToString(tn.importFiles, ""); // Check if this is a library asset? bool bIsInLibrary = false; if (tn.TreeView != null) { string fullPath = tn.FullPath + tn.TreeView.PathSeparator; string testPath = tn.TreeView.PathSeparator + "Library" + tn.TreeView.PathSeparator; if (fullPath.IndexOf(testPath, 0, StringComparison.CurrentCultureIgnoreCase) != -1) { bIsInLibrary = true; } } MOG_Filename repositoryName = null; if (bIsInLibrary && tn.importFiles.Count > 0) { // Use the timestamp of the file (Needed for out-of-date checks with library assets) String libraryTimestamp = ""; FileInfo file = new FileInfo(tn.importFiles[0] as string); if (file != null && file.Exists) { libraryTimestamp = MOG_Time.GetVersionTimestamp(file.LastWriteTime); } repositoryName = MOG_ControllerRepository.GetAssetBlessedVersionPath(new MOG_Filename(fullAssetName), libraryTimestamp); } else { // Use the common timestamp for all the assets repositoryName = MOG_ControllerRepository.GetAssetBlessedVersionPath(new MOG_Filename(fullAssetName), timestamp); } MOG_Filename createdAssetFilename = null; string message = "Importing:\n" + " " + repositoryName.GetAssetClassification() + "\n" + " " + repositoryName.GetAssetName(); worker.ReportProgress(nodeIndex * 100 / assetFilenameNodes.Count, message); if (worker.CancellationPending) { if (Utils.ShowMessageBoxConfirmation("Are you sure you want to cancel asset importation?", "Cancel Asset Importation?") == MOGPromptResult.Yes) { return; } } try { string dirScope = MOG_ControllerAsset.GetCommonDirectoryPath(this.projectRootPath, tn.importFiles); // Construct our list non-inherited asset assuming none ArrayList props = null; if (tn.props != null) { // Ask the tn.props for the list of non-inherited properties props = tn.props.GetNonInheritedProperties(); } else { props = new ArrayList(); // Setup SyncTargetPath Property string assetDirectoryScope = MOG_ControllerAsset.GetCommonDirectoryPath(this.projectRootPath, tn.importFiles); if (assetDirectoryScope.Length > this.projectRootPath.Length) { string syncTargetPath = assetDirectoryScope.Substring(this.projectRootPath.Length + 1); props.Add(MOG.MOG_PropertyFactory.MOG_Sync_OptionsProperties.New_SyncTargetPath(syncTargetPath)); } } // Proceed to import the asset createdAssetFilename = MOG_ControllerAsset.CreateAsset(repositoryName, dirScope, tn.importFiles, null, props, false, false); if (createdAssetFilename == null) { // it's probably a network problem (TODO: Check for sure) // build a list of files for error message string files = "\n\nFiles contained in " + tn.Text + "\n"; foreach (string fname in tn.importFiles) { files += "\t" + fname + "\n"; } MOGPromptResult r = MOG_Prompt.PromptResponse("Import Error", "Importation of " + tn.FullPath + " failed. Please ensure that the file is accessible and click Retry." + files, MOGPromptButtons.AbortRetryIgnore); if (r == MOGPromptResult.Retry) { --nodeIndex; // stay on the same node (continue auto-increments) continue; } else if (r == MOGPromptResult.Abort) { RaiseAssetImport_Finish(); MOG_Prompt.PromptResponse("Cancelled", "Importation Cancelled", Environment.StackTrace, MOGPromptButtons.OK, MOG_ALERT_LEVEL.MESSAGE); return; } else if (r == MOGPromptResult.Ignore) { continue; } } // Schedule this asset for posting under this project name MOG_ControllerProject.AddAssetForPosting(createdAssetFilename, MOG_ControllerProject.GetProjectName()); } catch (Exception ex) { MOG_Report.ReportMessage("Create Asset", "Could not correctly create asset.\nMessage=" + ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL); continue; } } // Shut off the properties cache MOG_Properties.ActivatePropertiesCache(false); }
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); }
static public int GetLockedAssetIcon(MOG_Filename file) { try { // Check to see if we can find this loced icon in our cache TstDictionaryEntry assetLocked = mAssetTypes.Find(file.GetAssetClassification() + "ASSETICON_locked"); if (assetLocked != null) { // Yup, return the index return((int)assetLocked.Value); } else { // Nope, We are going to have to create it // Setup some new containers Bitmap myImage = null; Bitmap lockSource = null; Bitmap source = null; // Can we find the locked image TstDictionaryEntry nodeLocked = mAssetTypes.Find("locked"); if (nodeLocked != null && nodeLocked.IsKey) { // Great, get a copy of that lockSource = (Bitmap)mAssetTypeImages.Images[(int)nodeLocked.Value]; // Can we find the class icon for this asset TstDictionaryEntry nodeSource = mAssetTypes.Find(file.GetAssetClassification() + "_ASSETICON"); if (nodeSource != null && nodeSource.IsKey) { // Great get a copy of that source = (Bitmap)mAssetTypeImages.Images[(int)nodeSource.Value]; } else { // If we didn't get anything, we need to load this icon into our array MOG_Properties properties = new MOG_Properties(file.GetAssetClassification()); source = (Bitmap)mAssetTypeImages.Images[MogUtil_AssetIcons.LoadIcon(properties.AssetIcon, file.GetAssetClassification() + "_ASSETICON")]; } // Ok, if we got a lockSource and a class source icon, lets attempt to overlay them if (source != null && lockSource != null) { myImage = BitmapManipulator.OverlayBitmap(source, lockSource, 100, BitmapManipulator.ImageCornerEnum.BottomRight); } // Did the overlay work? if (myImage != null) { lock (mAssetTypes) { // Add the image and the type to the arrayLists mAssetTypeImages.Images.Add(myImage); mAssetTypes.Add(file.GetAssetClassification() + "ASSETICON_locked", mAssetTypeImages.Images.Count - 1); return(mAssetTypeImages.Images.Count - 1); } } } else { // Try to just turn the source icon red or something string message = "We could not locate the (FileLocked.png)lock icon! Make sure that it is located in one of your images directories within the MOG repository!"; MOG_Report.ReportMessage("Load Icon", message, "No StackTrace available", MOG_ALERT_LEVEL.ERROR); } } } catch (Exception e) { MOG_Report.ReportMessage("Get Locked Icon", e.Message, e.StackTrace, MOG_ALERT_LEVEL.CRITICAL); } return(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); } }
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 PackageRemoveMenuItem_Click(object sender, System.EventArgs e) { try { TreeNode selectedNode = ProjectPackagesTreeView.SelectedNode; // If we have not expanded this node, go ahead and do so... if (selectedNode != null && !selectedNode.IsExpanded) { // Get rid of any Blank node selectedNode.Expand(); } // Make sure we have a selected node and that that node does not have sub nodes other than the blank node if (selectedNode != null && selectedNode.Nodes.Count == 0) { Mog_BaseTag packageTag = (Mog_BaseTag)ProjectPackagesTreeView.SelectedNode.Tag; // Are we a package? if (packageTag.PackageNodeType == PackageNodeTypes.Asset || packageTag.PackageNodeType == PackageNodeTypes.Package) { RemovePackageFromProject(packageTag); return; } // Are we a classification? else if (packageTag.PackageNodeType == PackageNodeTypes.Class) { MessageBox.Show(this, "Cannot remove a Classification node. Please go to Project Tab | Project Trees " + "to be able to do this."); return; } string removeCandidate = ProjectPackagesTreeView.SelectedNode.Text; // Find our parent package TreeNode package = ProjectPackagesTreeView.FindPackage(ProjectPackagesTreeView.SelectedNode); if (package != null) { MOG_Filename packageAsset = new MOG_Filename(((Mog_BaseTag)package.Tag).FullFilename); // Remove the classification from our fullPath string objectPath = ProjectPackagesTreeView.SelectedNode.FullPath.Replace(packageAsset.GetAssetClassification() + "/", ""); // First, get the index of our package name int assetNameIndex = objectPath.IndexOf(packageAsset.GetAssetName()); // If we have a valid index for the package's name... if (assetNameIndex > -1) { // Remove everything before our package name objectPath = objectPath.Substring(assetNameIndex); } // Now remove our package name objectPath = objectPath.Replace(packageAsset.GetAssetName(), ""); // Add back in our Group/Object separator objectPath = objectPath.Replace("~", "/"); // If we have an initial forward slash... if (objectPath.IndexOf("/") == 0) { // Get rid of it objectPath = objectPath.Substring(1); } // If we can remove it from the databse, remove the treenode? if (ProjectPackagesTreeView.RemoveGroupFromDatabase(objectPath, packageAsset)) { // Remove the node ProjectPackagesTreeView.SelectedNode.Remove(); } } } else { MOG_Prompt.PromptMessage("Remove node", "Could not remove this node because:\n\tNode must not contain any sub-nodes before removal."); } } catch (Exception ex) { MOG_Report.ReportMessage("Remove node", "MOG encountered an unexpected problem. Aborting node remove.\nSystem Message:" + ex.Message, ex.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL); } }
/// <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 static void UpdateLocalProgress_Worker(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; int autoCount = 0; int userCount = 0; // Suspend the auto packaging WorkspaceManager.SuspendPackaging(true); // Begin this GetLatest WorkspaceManager.ModifyLocalWorkspace_Begin(); while (true) { MOG_Filename filename = new MOG_Filename(); bool userInitiated = false; lock (mAutoUpdateQueue) { // See if there are any auto update items needing to be processed? if (mAutoUpdateQueue.Count > 0) { filename = mAutoUpdateQueue.Dequeue(); autoCount++; } // See if there are any user initiated items needing to be processed? else if (mUserUpdateQueue.Count > 0) { filename = mUserUpdateQueue.Dequeue(); userCount++; userInitiated = true; } } // Recalulate total within this loop because it can be changing outside of us in another thread... int total = (mAutoUpdateQueue.Count + autoCount) + (mUserUpdateQueue.Count + userCount); string message = "Updating:\n" + " " + filename.GetAssetClassification() + "\n" + " " + filename.GetAssetName(); worker.ReportProgress((autoCount + userCount) * 100 / total, message); // Only allow updates of valid assets if (filename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset || filename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Group) { // Add this asset to all of our active workspaces WorkspaceManager.AddAssetToWorkspaces(filename, userInitiated, worker); } lock (mUpdateQueueLock) { if (mAutoUpdateQueue.Count == 0 && mUserUpdateQueue.Count == 0) { mAutoUpdateQueue = null; mUserUpdateQueue = null; break; } // Check if the user canceled things? if (worker.CancellationPending) { mAutoUpdateQueue = null; mUserUpdateQueue = null; break; } } } // Restore the auto packaging WorkspaceManager.SuspendPackaging(false); // End this GetLatest WorkspaceManager.ModifyLocalWorkspace_Complete(); }
/// <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; }
/// <summary> SetAssetIcon /// Searches through mAssetTypes to find the matching key with /// that of the filename. Then returns the index /// </summary> /// <param name="filename"></param> /// <returns>index of icon in the mAssetTypeImages list</returns> static public int SetAssetIcon(String filename) { // Construct a filename MOG_Filename file = null; try { file = new MOG_Filename(filename); } catch (Exception e) { e.ToString(); return(0); } string classification; switch (file.GetType()) { case MOG_FILENAME_TYPE.MOG_FILENAME_Asset: classification = file.GetAssetClassification(); break; case MOG_FILENAME_TYPE.MOG_FILENAME_Group: classification = "group"; break; default: classification = filename; break; } // Check for locks on this asset if (!guiAssetSourceLock.QueryPersistentLock(file.GetAssetFullName(), true)) { // Check if this asset is locked by our current user if (guiAssetSourceLock.OkToBless(file.GetAssetFullName(), true)) { // Look for an icon type of _readLocked int y = mAssetTypes.IndexOf(classification + "_readlocked"); if (y == -1) { // Can't find it, use default return(0); } else { // Return the location of the _readLocked icon return(y); } } else { // Look for an icon type of _locked int y = mAssetTypes.IndexOf(classification + "_locked"); if (y == -1) { // Can't find it, use default return(0); } else { // Return the location of the _locked icon return(y); } } } else { // Get the index of the key in the types array int x = mAssetTypes.IndexOf(classification); // If the asset was not found, return 0 for first icon in the list if (x == -1) { return(0); } // Return the index of the icon return(x); } }
private void InitializeAssetName(MOG_Filename mogFilename) { InitializePlatformComboBox(); InitializeTextBoxes(mogFilename.GetAssetClassification(), mogFilename.GetAssetPlatform(), mogFilename.GetAssetName()); }