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); }
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); } } } }
/// <summary> /// Add a new mog asset to the listView items array /// </summary> /// <param name="mogAsset"></param> /// <param name="version"></param> /// <param name="pProperties"></param> /// <param name="failedString"></param> /// <returns></returns> public ListViewItem ItemAdd(MOG_Filename mogAsset, MOG_Properties pProperties, string failedString) { //MOG_Time assetTime = new MOG_Time(version); ListViewItem item = AddItemToListView(mogAsset, pProperties, ToString(mogAsset, pProperties, mogAsset.GetVersionTimeStamp()).GetEncodedFilename()); //item.SubItems[FindColumn("Failed Check")].Text = failedString; // Failed string return(item); }
/// <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(); } }
public override void MakeAssetCurrent(MOG_Filename assetFilename) { // Call our parent's MakeAssetCurrent base.MakeAssetCurrent(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) { // Check if this node was previously marked as a deleted version? if (foundNode.ForeColor == Archive_Color) { // Collapse this baby and let it get rebuilt the next time the user expands it because it needs to change it internal structure foundNode.Collapse(); foundNode.Nodes.Clear(); foundNode.Nodes.Add(Blank_Node_Text); } // Reset the color foundNode.ForeColor = Color.Black; // Update this parent node with the new information concerning this asset Mog_BaseTag assetTag = foundNode.Tag as Mog_BaseTag; if (assetTag != null) { // Create a dateFormat just like that used in standard MS Windows USA regional date settings 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(); // Scan the children nodes looking for other places needing to be fixed up foreach (TreeNode node in foundNode.Nodes) { // Make sure this is a valid node? if (node != null) { // Checkif this is the 'All Revisions'? if (node.Text == Revisions_Text) { bool bFoundCurrentRevisionNode = false; // Fixup this list of revisions foreach (TreeNode revisionNode in node.Nodes) { Mog_BaseTag baseTag = revisionNode.Tag as Mog_BaseTag; if (baseTag != null) { MOG_Filename revisionFilename = new MOG_Filename(baseTag.FullFilename); if (revisionFilename.GetVersionTimeStamp() == assetFilename.GetVersionTimeStamp()) { revisionNode.ForeColor = CurrentVersion_Color; bFoundCurrentRevisionNode = true; } else { revisionNode.ForeColor = Color.Black; } } } // Check if we need to add our new revision node? if (!bFoundCurrentRevisionNode) { // Looks like this is a new revision and needs to be added // Hey Whipple - What do I do here? // It seems like this is already added by an earlier event so I suspect we will never hit this. } } else { // Check if this is the 'Current <' node if (node.Text.StartsWith(Current_Text + " <")) { node.Text = Current_Text + " <" + assetFilename.GetVersionTimeStampString(dateFormat) + ">"; } // Update it's tag Mog_BaseTag currentTag = node.Tag as Mog_BaseTag; if (currentTag != null) { assetTag.FullFilename = assetFilename.GetOriginalFilename(); } // Finally collapse this baby and let it get rebuilt the next time the user expands it node.Collapse(); node.Nodes.Clear(); node.Nodes.Add(Blank_Node_Text); } } } } } } }
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); }
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 void UpdateItem(ListViewItem item) { string status = ""; string username = ""; string comment = ""; string localTimestamp = ""; // Find our desired columns int statusIdx = FindColumn("Status"); int userIdx = FindColumn("User"); int commentIdx = FindColumn("Comment"); int localTimestampIdx = FindColumn("Local Timestamp"); int serverTimestampIdx = FindColumn("Server Timestamp"); int localFileIdx = FindColumn("LocalFile"); int repositoryFileIdx = FindColumn("RepositoryFile"); string repositoryFile = item.SubItems[repositoryFileIdx].Text; MOG_Filename repositoryAssetFilename = new MOG_Filename(repositoryFile); // Check if this file exist locally? string localFile = item.SubItems[localFileIdx].Text; if (localFile.Length != 0) { // Obtain the localFile info FileInfo fileInfo = new FileInfo(localFile); // Does this local file exist? if (fileInfo != null && fileInfo.Exists) { // Compare our local file's timestamp to the server's revision localTimestamp = MOG_Time.GetVersionTimestamp(fileInfo.LastWriteTime); if (localTimestamp == repositoryAssetFilename.GetVersionTimeStamp()) { // Indicate this item is synced and up-to-date status = "Up-to-date"; } else { // Indicate this item is synced status = "Out-of-date"; } } else { // Indicate this item is not synced status = "unSynced"; } } else { // Indicate this item is not synced status = "unSynced"; } // Check if this file exists in the repository? if (repositoryFile.Length != 0) { // Check the lock statusIdx of the asset MOG_Command sourceLock = MOG_ControllerProject.PersistentLock_Query(repositoryAssetFilename.GetAssetFullName()); if (sourceLock.IsCompleted() && sourceLock.GetCommand() != null) { MOG_Command lockHolder = sourceLock.GetCommand(); // Obtain the lock info item.ImageIndex = MogUtil_AssetIcons.GetLockedBinaryIcon(repositoryFile); username = lockHolder.GetUserName(); comment = lockHolder.GetDescription(); // Check if this is locked by me? if (username == MOG_ControllerProject.GetUserName()) { status = "CheckedOut"; } else { status = "Locked"; } } else { // Update this file's icon item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(repositoryFile); } } // Update the item with the new information item.SubItems[statusIdx].Text = status; item.SubItems[userIdx].Text = username; item.SubItems[commentIdx].Text = comment; item.SubItems[localTimestampIdx].Text = MogUtils_StringVersion.VersionToString(localTimestamp); item.SubItems[serverTimestampIdx].Text = MogUtils_StringVersion.VersionToString(repositoryAssetFilename.GetVersionTimeStamp()); // Update the color for this locked item UpdateListViewItemColors(item, status); }
static protected void assetTreeViewCreate_AddVersionNodes(TreeView tree, TreeNode parent, int defaultIndex) { // Add version nodes TreeNode versionRoot = new TreeNode(VERSION_TOKEN, defaultIndex, 0); versionRoot.Tag = parent.Tag; parent.Nodes.Clear(); // 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(); // Create a tag for ease of use guiAssetTreeTag parentTag = (guiAssetTreeTag)parent.Tag; // Get the lastest version string string versionStr = MOG_DBAssetAPI.GetAssetVersion(new MOG_Filename(parentTag.FullFilename)); // Populate HDD versions DirectoryInfo[] hddVersions = DosUtils.DirectoryGetList(parentTag.FullFilename, ""); // Arrange it latest date first Array.Reverse(hddVersions); // Populate DB versions ArrayList dbVersions = MOG_DBAssetAPI.GetAllAssetRevisions(new MOG_Filename(parentTag.FullFilename)); // Turn off sorting for this part of the tree tree.Sorted = false; foreach (DirectoryInfo version in hddVersions) { // Create a new versionNode MOG_Filename versionFile = new MOG_Filename(version.FullName); string textLabel = "<" + versionFile.GetVersionTimeStampString(dateFormat) + ">"; TreeNode versionNode = new TreeNode(textLabel, defaultIndex, 0); // Add guiAssetTreeTag and change color to indicate HDD-only status versionNode.Tag = new guiAssetTreeTag(version.FullName, guiAssetTreeTag.TREE_FOCUS.VERSION, true); // If this is a version matched in the DB, color is black if (assetTreeViewCreate_IsAssetVersionInDB(dbVersions, version.Name)) { versionNode.ForeColor = Color.Black; } // Else, turn color gray else { versionNode.ForeColor = Color.DarkGray; } //glk: This still needs to be tested against the case where there is no directory that matches the verion in versionStr // If this is the most recent asset, display it as such if (versionStr == versionFile.GetVersionTimeStamp()) { versionNode.ForeColor = Color.Blue; // Create a currentVersion node, manually cloning versionNode // glk: object.Clone() does not function properly TreeNode currentVersion = new TreeNode(textLabel, versionNode.ImageIndex, versionNode.SelectedImageIndex); currentVersion.ForeColor = Color.Blue; currentVersion.Tag = new guiAssetTreeTag(version.FullName, guiAssetTreeTag.TREE_FOCUS.VERSION, true); // Keep tree from drawing itself for a bit tree.BeginUpdate(); // Document the horizontal and vertical // positions of tree's scrollbar using extern functions int horizPos = GetHScrollPosition(tree); int vertPos = GetVScrollPosition(tree); // Expand the tree: This is the operation which causes // really erratic behavior from TreeView Control currentVersion.Expand(); // Add ghost node for further expansion currentVersion.Nodes.Add(new TreeNode("")); parent.Nodes.Add(currentVersion); // Set the scrollbar horizontal and vertical positions // back to what they were. SetHScrollPosition(tree, horizPos); SetVScrollPosition(tree, vertPos); // Allow tree to draw itself tree.EndUpdate(); } // Add new placeholder for further expansion versionNode.Nodes.Add(new TreeNode("")); versionRoot.Nodes.Add(versionNode); } parent.Nodes.Add(versionRoot); // Turn sorting back on tree.Sorted = true; }