/// <summary> /// Used to get an Asset node with a good node.Tag for this TreeView or any inheriting classes. /// </summary> private TreeNode CreateAssetNode(MOG_Filename asset, System.Drawing.Color foreColor, bool useFullFilename) { string assetName = asset.GetAssetFullName(); MOG_Filename assetFullFilename; // If we found revisions, go ahead and select the first one as the full filename for our tag... assetFullFilename = MOG_ControllerRepository.GetAssetBlessedPath(asset); TreeNode assetNode = new TreeNode(asset.GetAssetName()); if (useFullFilename) { assetNode.Text = asset.GetAssetFullName(); } assetNode.Tag = new Mog_BaseTag(assetNode, assetFullFilename.GetEncodedFilename(), RepositoryFocusLevel.Repository, true); // If we are Archive_Color, remain displayed as such if (foreColor == Archive_Color) { assetNode.ForeColor = Archive_Color; } assetNode.Nodes.Add(new TreeNode(Blank_Node_Text)); assetNode.Name = asset.GetAssetFullName(); SetImageIndices(assetNode, GetAssetImageIndex(((Mog_BaseTag)assetNode.Tag).FullFilename)); return(assetNode); }
public bool ToolNewerCheck(MOG_Filename mogAsset, string version, MOG_Project pProject, ref string failedString) { MOG_Time assetTime = new MOG_Time(version); MOG_Time correctAssetTime = new MOG_Time(); DirectoryInfo [] dirs = DosUtils.DirectoryGetList(MOG_ControllerRepository.GetAssetBlessedPath(mogAsset).GetEncodedFilename(), "*.*"); if (dirs != null) { foreach (DirectoryInfo dir in dirs) { string checkVersion = dir.Name.Substring(dir.Name.LastIndexOf(".") + 1); MOG_Time dirTime = new MOG_Time(checkVersion); // Is this asset equal or newer than this dir version? if (assetTime.Compare(dirTime) < 0) { failedString = "Out of date," + failedString; return(false); } } } return(true); }
protected TreeNode CreateSyncTargetTreeNode(MOG_DBSyncTargetInfo info, string platform) { bool ableToGetSourceFileAssetLinks = false; string currentVersionStamp = info.mVersion; MOG_Filename tempFilename = MOG_Filename.CreateAssetName(info.mAssetClassification, info.mAssetPlatform, info.mAssetLabel); MOG_Filename assetRealFile = MOG_ControllerRepository.GetAssetBlessedVersionPath(tempFilename, currentVersionStamp); // Create node with FocusLevel that does not plug into the BaseLeafTreeView TreeNode node = new TreeNode(info.FilenameOnly, new TreeNode[] { new TreeNode(Blank_Node_Text) }); Mog_BaseTag tag = new Mog_BaseTag(node, assetRealFile.GetEncodedFilename(), RepositoryFocusLevel.Classification, true); node.Name = tempFilename.GetAssetFullName(); tag.AttachedSyncTargetInfo = info; node.Tag = tag; string gamedataFilePath; if (ableToGetSourceFileAssetLinks) { gamedataFilePath = assetRealFile.GetEncodedFilename() + "\\Files.Imported\\" + info.mSyncTargetFile; } else { gamedataFilePath = assetRealFile.GetEncodedFilename() + "\\Files.Imported\\" + info.FilenameOnly; } //This is either a file or an asset SetImageIndices(node, base.GetAssetFileImageIndex(gamedataFilePath)); return(node); }
public bool ToolExistsCheck(MOG_Filename mogAsset, string version, MOG_Project pProject, ref string failedString) { if (!Directory.Exists(MOG_ControllerRepository.GetAssetBlessedVersionPath(mogAsset, version).GetEncodedFilename())) { failedString = "Doesn't exist," + failedString; return(false); } return(true); }
/// <summary> /// Determine and return the full filename for this asset /// </summary> /// <param name="mogAsset"></param> /// <param name="pProperties"></param> /// <param name="version"></param> /// <returns></returns> private MOG_Filename ToString(MOG_Filename mogAsset, MOG_Properties pProperties, string version) { // Is this asset already in the repository? if (mogAsset.IsBlessed()) { return(mogAsset); } // Create a path to the blessed version of this asset else if (pProperties != null && version.Length > 0) { return(MOG_ControllerRepository.GetAssetBlessedVersionPath(mogAsset, version)); } // OK, just return thr fullFilename of this asset else { return(mogAsset); } }
public void RemoveAssetFromProject(MOG_Filename filename) { if (mainForm.ProjectManagerClassificationTreeView != null) { TreeNode foundNode = mainForm.ProjectManagerClassificationTreeView.FindNode(filename.GetAssetFullName()); if (foundNode != null) { foundNode.Remove(); } } if (mainForm.ProjectManagerPackageTreeView != null) { TreeNode foundNode = mainForm.ProjectManagerPackageTreeView.FindNode(filename.GetAssetFullName()); if (foundNode != null) { foundNode.Remove(); } } if (mainForm.ProjectManagerArchiveTreeView != null) { //? RemoveAssetFromProject - Known Issue...We'll never be able to find the right node of assets being purged from the repository because the slave will have already removed the asset's name from the database before we get this event containing an encocded name! TreeNode foundNode = mainForm.ProjectManagerArchiveTreeView.FindNode(filename.GetAssetFullName()); if (foundNode != null) { // Check if this node was already red? if (foundNode.ForeColor == Color.Red) { foundNode.Remove(); } else { // Set this node to red for 'removed' // Should we set the parent to red too? SetParentForecolors(filename, foundNode, MOG_ControllerRepository.GetBlessedRevisions(filename, true, false).Count); // Set all their children to red SetChildForecolors(foundNode); } } } }
private void ExpandSyncTargetAssetNode(TreeNode gamedataNode, string platform) { Mog_BaseTag gamedataTag = (Mog_BaseTag)gamedataNode.Tag; // If we have valid data... if (gamedataTag.AttachedSyncTargetInfo != null) { // Key is gamedataFilename, Value is gamedataFilenameOnly MOG_DBSyncTargetInfo gamedataInfo = gamedataTag.AttachedSyncTargetInfo; string currentVersionStamp = gamedataInfo.mVersion; MOG_Filename tempFilename = MOG_Filename.CreateAssetName(gamedataInfo.mAssetClassification, gamedataInfo.mAssetPlatform, gamedataInfo.mAssetLabel); MOG_Filename assetRealFile = MOG_ControllerRepository.GetAssetBlessedVersionPath(tempFilename, currentVersionStamp); // Add the asset this gamedata file is associated with under the oldGamedataNode TreeNode assetNode = new TreeNode(assetRealFile.GetAssetFullName(), new TreeNode[] { new TreeNode(Blank_Node_Text) }); assetNode.Tag = new Mog_BaseTag(assetNode, assetRealFile.GetEncodedFilename(), LeafFocusLevel.RepositoryItems, true); assetNode.Name = assetRealFile.GetAssetFullName(); gamedataNode.Nodes.Add(assetNode); SetImageIndices(assetNode, GetAssetFileImageIndex(assetRealFile.GetEncodedFilename())); } }
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); }
static protected MOG_Filename GetAssetFullname(MOG_Filename asset, string contentsInfo) { // The source will be out in the blessed asset tree return(MOG_ControllerRepository.GetAssetBlessedPath(asset)); }
/// <summary> /// Load a report form from a file and populate it /// </summary> /// <param name="filename"></param> public void LoadReportList(string filename) { MOG_Ini report = new MOG_Ini(filename); // Set the form title Text = Path.GetFileName(filename); if (report.SectionExist("ASSETS")) { ListListView.Items.Clear(); ListListView.BeginUpdate(); ProgressMax(report.CountKeys("ASSETS")); for (int x = 0; x < report.CountKeys("ASSETS"); x++) { MOG_Filename mogAsset = new MOG_Filename(report.GetKeyNameByIndexSLOW("ASSETS", x)); string extraInfo = report.GetKeyByIndexSLOW("ASSETS", x); MOG_Properties pProperties = new MOG_Properties(mogAsset); string version = mogAsset.GetVersionTimeStamp(); string currentVersion = MOG_DBAssetAPI.GetAssetVersion(mogAsset); //mCurrentInfo.GetString("ASSETS", mogAsset.GetAssetName()); MOG_Time assetTime = new MOG_Time(version); MOG_Time currentAssetTime = new MOG_Time(currentVersion); ListViewItem item = new ListViewItem(); // We have support for the old lists as well as the new ones that have extra information stored. if (string.Compare(extraInfo, "ReportList", true) != 0) { string [] extraItems = extraInfo.Split(",".ToCharArray()); foreach (string extra in extraItems) { if (item.Text.Length == 0) { item.Text = extra; } else { item.SubItems.Add(extra); } } // Update the version if (assetTime.Compare(currentAssetTime) != 0) { item.SubItems[FindColumn("Version")].Text = currentAssetTime.FormatString(""); item.SubItems[FindColumn("Version")].ForeColor = Color.Red; } } else { item = AddItemToListView(mogAsset, pProperties, MOG_ControllerRepository.GetAssetBlessedVersionPath(mogAsset, version).GetEncodedFilename()); // Get version if (assetTime.Compare(currentAssetTime) != 0) // Version { item.SubItems[FindColumn("Version")].Text = currentAssetTime.FormatString(""); item.SubItems[FindColumn("Version")].ForeColor = Color.Red; version = currentVersion; } else { item.SubItems[FindColumn("Version")].Text = assetTime.FormatString(""); } } // Icon item.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(mogAsset.GetAssetFullName()); ListListView.Items.Add(item); ProgressStep(); } UpdateAssetTotals(); ListListView.EndUpdate(); ProgressReset(); } }
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 protected MOG_Filename GetAssetFullname(MOG_Filename asset, string contentsInfo) { return(MOG_ControllerRepository.GetAssetBlessedPath(asset)); }
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); }