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); }
public void Populate(string classification) { CurrentClassification = classification; mCurrentClassificationProperties = new MOG_Properties(CurrentClassification); // For speed purposes, create 3 HybridDictionary lists // Populate the files that exist on the local hardrive string drivePath = Path.Combine(MOG_ControllerLibrary.GetWorkingDirectory(), MOG_Filename.GetClassificationPath(classification)); string[] files = new string[] { }; if (DosUtils.DirectoryExistFast(drivePath)) { files = Directory.GetFiles(drivePath); } HybridDictionary filesOnDisk = new HybridDictionary(); foreach (string file in files) { filesOnDisk[Path.GetFileName(file)] = file; } // Populate the assets that exist in MOG ArrayList assets = MOG_ControllerAsset.GetAssetsByClassification(classification); HybridDictionary assetsInMOG = new HybridDictionary(); foreach (MOG_Filename asset in assets) { assetsInMOG[asset.GetAssetLabel()] = asset; } // Create a master list HybridDictionary masterList = new HybridDictionary(); foreach (string file in filesOnDisk.Values) { masterList[Path.GetFileName(file)] = Path.GetFileName(file); } foreach (MOG_Filename asset in assetsInMOG.Values) { masterList[asset.GetAssetLabel()] = asset.GetAssetLabel(); } // Rebuild our LibraryListView LibraryListView.BeginUpdate(); mLibrarySortManager.SortEnabled = false; LibraryListView.Items.Clear(); foreach (string file in masterList.Keys) { // Check if this file is in MOG? if (assetsInMOG.Contains(file)) { MOG_Filename asset = assetsInMOG[file] as MOG_Filename; // Create the ListView item for this asset ListViewItem item = CreateListViewItemForAsset(asset); LibraryListView.Items.Add(item); } else { string fullFilename = filesOnDisk[file] as string; bool bIsValid = true; // Check the classification's inclusion filter. if (mCurrentClassificationProperties.FilterInclusions.Length > 0) { MOG.FilePattern inclusions = new MOG.FilePattern(mCurrentClassificationProperties.FilterInclusions); if (inclusions.IsFilePatternMatch(Path.GetFileName(fullFilename)) == false) { bIsValid = false; } } // Check the classification's exclusion filter. if (mCurrentClassificationProperties.FilterExclusions.Length > 0) { MOG.FilePattern exclusions = new MOG.FilePattern(mCurrentClassificationProperties.FilterExclusions); if (exclusions.IsFilePatternMatch(Path.GetFileName(fullFilename)) == true) { bIsValid = false; } } // Check if we determined this to be a valid file to show? if (bIsValid) { ListViewItem item = CreateListViewItemForFile(fullFilename); UpdateListViewItemColors(item, "Unknown"); LibraryListView.Items.Add(item); } } } mLibrarySortManager.SortEnabled = true; LibraryListView.EndUpdate(); // Check if we have a mLastTopItem specified? if (mLastTopItem.Length > 0) { LibraryListView.TopItem = LibraryListView.FindItemWithText(mLastTopItem); mLastTopItem = ""; } }