/// <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);
        }
Пример #2
0
        /// <summary>
        /// Shows Assets based on MOG_Property(s) assigned to PropertyList
        /// </summary>
        private void ExpandPropertyTreeDown(TreeNode node)
        {
            BeginUpdate();

            List <string> classificationsToAdd = GetSubClassifications(node);
            List <string> assetsToAdd          = GetAssets(node);

            // Sort our classifications alphabetically
            classificationsToAdd.Sort();

            // Foreach classification, add it
            foreach (string classification in classificationsToAdd)
            {
                TreeNode classificationNode = new TreeNode(classification);

                // Assign the default node checked state
                classificationNode.Checked = node.Checked;

                classificationNode.Tag = new Mog_BaseTag(classificationNode, classification, RepositoryFocusLevel.Classification, false);
                ((Mog_BaseTag)classificationNode.Tag).PackageNodeType = PackageNodeTypes.Class;
                node.Nodes.Add(classificationNode);

                classificationNode.Name = classificationNode.FullPath;
                SetImageIndices(classificationNode, GetClassificationImageIndex(classificationNode.FullPath));

                classificationNode.Nodes.Add(new TreeNode(Blank_Node_Text));
            }

            // Use the System.IComparable interface for `string` to sort our list
            assetsToAdd.Sort();

            // Foreach Asset, add it
            foreach (string assetFilename in assetsToAdd)
            {
                MOG_Filename assetFile = new MOG_Filename(assetFilename);
                assetFile = MOG_ControllerProject.GetAssetCurrentBlessedPath(assetFile);
                TreeNode assetNode;
                // If we are expandingAssets or expandingPackageGroups, we need to be able to expand down
                if (ExpandAssets || ExpandPackageGroups)
                {
                    assetNode = new TreeNode(assetFile.GetAssetName(), new TreeNode[] { new TreeNode(Blank_Node_Text) });
                }
                // Else, do not expand down.  Showing the Asset is all we need to do
                else
                {
                    assetNode = new TreeNode(assetFile.GetAssetName());
                }

                assetNode.Tag = new Mog_BaseTag(assetNode, assetFile.GetEncodedFilename(), FocusForAssetNodes, true);
                ((Mog_BaseTag)assetNode.Tag).PackageNodeType = PackageNodeTypes.Asset;
                ((Mog_BaseTag)assetNode.Tag).PackageFullName = assetFile.GetAssetFullName();
                node.Nodes.Add(assetNode);
                assetNode.Name = assetFile.GetAssetFullName();

                SetImageIndices(assetNode, GetAssetFileImageIndex(assetFile.GetEncodedFilename()));
            }

            EndUpdate();
        }
Пример #3
0
        /// <summary>
        /// Used to get an Asset node with a good node.Tag for this TreeView or any inheriting classes.
        ///  Does not use full filename.
        /// </summary>
        protected virtual TreeNode CreateAssetNode(MOG_Filename asset)
        {
            // Create a basic tree node
            TreeNode     assetNode = new TreeNode(asset.GetAssetName());
            MOG_Filename assetFile = MOG_ControllerProject.GetAssetCurrentBlessedPath(asset);

            assetNode.Tag  = new Mog_BaseTag(assetNode, "", RepositoryFocusLevel.Repository, true);
            assetNode.Name = asset.GetAssetFullName();
            // Initialize the treenode's image
            SetImageIndices(assetNode, GetAssetImageIndex(asset.GetAssetFullName()));

            return(assetNode);
        }
        /// <summary>
        /// Prepare a drag object to recieve any driped items from the package tree
        /// </summary>
        private DataObject PrepareDragObject(TreeView tree, TreeNode node)
        {
            // failsafe for unpopulated package lists
            if (tree.Nodes.Count <= 0)
            {
                return(null);
            }

            // Create our list holders
            ArrayList    packages = new ArrayList();
            MOG_Filename package  = new MOG_Filename(node.Text);

            // Get the package names
            if (package.GetAssetPlatform().Length == 0)
            {
                // We need to make a new MOG_Filename with a valid platform
                // To do this we need to get to the class, label and desired platform
                string classification = FindClassification(node);
                string packgePath     = IsolatePackagePath(node.FullPath, classification);

                if (packgePath.Length > 0)
                {
                    package = MOG_Filename.CreateAssetName(classification, "All", packgePath);

                    // Add the platforms
                    foreach (MOG_Platform platform in MOG_ControllerProject.GetProject().GetPlatforms())
                    {
                        package = MOG_Filename.CreateAssetName(classification, platform.mPlatformName, packgePath);
                        packages.Add(package.GetAssetFullName());
                    }
                }
                else
                {
                    MOG_Prompt.PromptMessage("Create package name", "Could not locate pachage path in package(" + node.FullPath + ")");
                    return(null);
                }
            }
            else
            {
                packages.Add(package.GetAssetFullName());
            }

            if (packages.Count > 0)
            {
                // Create a new Data object for the send
                return(new DataObject("Package", packages));
            }

            return(null);
        }
        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);
        }
Пример #6
0
        /// <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 ()
Пример #7
0
        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);
                    }
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Makes the selected assets the current version in the current branch
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MakeCurrentMenuItem_Click(object sender, System.EventArgs e)
        {
            try
            {
                ArrayList selectedItems  = ControlGetSelectedItems();
                ArrayList assetFilenames = new ArrayList();

                // Scan the list and prepare it for delivery to the DLL
                string message = "";
                foreach (guiAssetTreeTag tag in selectedItems)
                {
                    if (tag.Execute)
                    {
                        MOG_Filename filename = new MOG_Filename(tag.FullFilename);
                        if (filename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                        {
                            assetFilenames.Add(filename);
                        }

                        message = message + filename.GetAssetFullName() + "\n";
                    }
                }

                // Check if this request effects more than 1 asset??
                if (selectedItems.Count > 1)
                {
                    if (MOG_Prompt.PromptResponse("Are you sure you want to make all of these assets the current versions?", message, MOGPromptButtons.OKCancel) != MOGPromptResult.OK)
                    {
                        return;
                    }
                }

                // Stamp all the specified assets
                if (MOG_ControllerProject.MakeAssetCurrentVersion(assetFilenames, "Made current by " + MOG_ControllerProject.GetUserName_DefaultAdmin()))
                {
                    // Check if this request effects more than 1 asset??
                    if (selectedItems.Count > 1)
                    {
                        // Inform the user this may take a while
                        MOG_Prompt.PromptResponse("Completed",
                                                  "This change requires Slave processing.\n" +
                                                  "The project will not reflect these changes until all slaves have finished processing the generated commands.\n" +
                                                  "The progress of this task can be monitored in the Connections Tab.");
                    }
                }
                else
                {
                    MOG_Prompt.PromptMessage("Make Current Failed", "The system was unable to fully complete the task!", Environment.StackTrace);
                }
            }
            catch (Exception ex)
            {
                MOG_Report.ReportMessage("MakeCurrent Exception", ex.Message, ex.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
            }
        }
        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 void RenameNode(NodeLabelEditEventArgs e, MOG_Filename repositoryName)
		{
			TreeNode parent = e.Node.Parent;

			e.Node.Text = repositoryName.GetAssetName();

			e.Node.Tag = new Mog_BaseTag(e.Node, repositoryName.GetEncodedFilename(), RepositoryFocusLevel.Repository, true);
			((Mog_BaseTag)e.Node.Tag).PackageNodeType = PackageNodeTypes.Asset;
			((Mog_BaseTag)e.Node.Tag).PackageFullName = repositoryName.GetAssetFullName();

			e.CancelEdit = true;
		}
Пример #11
0
 /// <summary>
 /// Make sure that we keep our currently selected node's FullPath stored in our global variable.
 /// </summary>
 private void MogControl_BaseTreeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     // If we are not ignoring events...
     if (!bIgnoreEvents)
     {
         // Save the path of our last selected node
         Mog_BaseTag tag = e.Node.Tag as Mog_BaseTag;
         if (tag != null)
         {
             MOG_Filename filename = new MOG_Filename(tag.FullFilename);
             mLastNodePath = filename.GetAssetFullName();
         }
     }
 }
Пример #12
0
        public static bool ImportAsOne(string[] sourceFilenames, bool looseFileMatching)
        {
            if (sourceFilenames.Length > 0)
            {
                ArrayList propertiesList = new ArrayList();

                List <object> args = new List <object>();
                args.Add(looseFileMatching);
                args.Add(sourceFilenames);

                ProgressDialog progress = new ProgressDialog("Importing asset as single asset", "Please wait while MOG imports the asset.", ImportAsOne_Worker, args, true);
                if (progress.ShowDialog(MogMainForm.MainApp) == DialogResult.OK)
                {
                    ArrayList assetNames = progress.WorkerResult as ArrayList;
                    string    theOneName = "";

                    // Check if we failed to find a single match?
                    if (assetNames.Count == 1)
                    {
                        MOG_Filename assetName = assetNames[0] as MOG_Filename;
                        theOneName = assetName.GetAssetFullName();
                    }
                    else
                    {
                        //None of these files appear to be in the repository already, so we're going to have to do things the hard way
                        guiAssetImportCheck check = new guiAssetImportCheck();
                        check.CheckImportAssetName(sourceFilenames[0], ref theOneName, ref propertiesList, assetNames);
                    }

                    // Make sure we found theOneName
                    if (!string.IsNullOrEmpty(theOneName))
                    {
                        args = new List <object>();
                        args.Add(theOneName);
                        args.Add(sourceFilenames);
                        args.Add(propertiesList);

                        ProgressDialog creationProgress = new ProgressDialog("Creating Asset", "IMPORTING ASSET: " + theOneName + " with " + sourceFilenames.Length + " files", CreateSingleAsset_Worker, args, false);
                        creationProgress.ShowDialog(MogMainForm.MainApp);

                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #13
0
        /// <summary>
        /// Update populated tree node icons or status based on updated commands from the eventManager
        /// </summary>
        /// <param name="asset"></param>
        public void UpdateAsset(MOG_Command asset)
        {
            // Encapsulate this method in a try-catch
            try
            {
                // Update code for all persistent lock changes
                if (asset.GetCommand() != null && (asset.ToString().ToLower().IndexOf("lock") != -1))
                {
                    MOG_Command  userLock  = asset.GetCommand();
                    MOG_Filename assetName = userLock.GetAssetFilename();

                    string nodeKey = assetName.GetAssetFullName();

                    // Is this a class?
                    if (assetName.GetFilenameType() != MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                    {
                        nodeKey = assetName.GetOriginalFilename().TrimEnd("*".ToCharArray());
                    }

                    if (mainForm.ProjectManagerClassificationTreeView.IsInitialized)
                    {
                        FindAndUpdateNodeLockStatus(nodeKey, assetName, mainForm.ProjectManagerClassificationTreeView);
                    }
                    if (mainForm.ProjectManagerPackageTreeView.IsInitialized)
                    {
                        FindAndUpdateNodeLockStatus(nodeKey, assetName, mainForm.ProjectManagerPackageTreeView);
                    }
                    if (mainForm.ProjectManagerArchiveTreeView.IsInitialized)
                    {
                        FindAndUpdateNodeLockStatus(nodeKey, assetName, mainForm.ProjectManagerArchiveTreeView);
                    }
                    if (mainForm.ProjectManagerSyncTargetTreeView.IsInitialized)
                    {
                        FindAndUpdateNodeLockStatus(nodeKey, assetName, mainForm.ProjectManagerSyncTargetTreeView);
                    }
                }
            }
            // Catch any .NET-standard errors
            catch (Exception ex)
            {
                // Add MOG_Report stuff here.
                MOG_Report.ReportSilent("UpdateAsset", ex.Message, ex.StackTrace);
            }
        }
Пример #14
0
        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"));
            }
        }
Пример #15
0
        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);
                    }
                }
            }
        }
Пример #16
0
        /// <summary>
        /// Used to get an Asset node with a good node.Tag for this TreeView or any inheriting classes.
        ///  Does not use full filename.
        /// </summary>
        protected override TreeNode CreateAssetNode(MOG_Filename asset)
        {
            TreeNode assetNode = base.CreateAssetNode(asset);

            // If we are expandingAssets or expandingPackageGroups, we need to be able to expand down
            if (ExpandAssets || ExpandPackageGroups)
            {
                // Add the dummy node so the usere will be given the opportunity to expand it
                assetNode.Nodes.Add(new TreeNode(Blank_Node_Text));
            }

            // Rebuild the node's tag
            MOG_Filename assetFile = MOG_ControllerProject.GetAssetCurrentBlessedPath(asset);
            Mog_BaseTag  tag       = new Mog_BaseTag(assetNode, assetFile.GetEncodedFilename(), FocusForAssetNodes, true);

            tag.PackageNodeType = PackageNodeTypes.Asset;
            tag.PackageFullName = assetFile.GetAssetFullName();
            assetNode.Tag       = tag;

            return(assetNode);
        }
        /// <summary>
        /// Remove a Package from the PackageManagement Tree.
        ///  Adapted from MogControl_AssetContextMenu.cs::MenuItemRemoveFromProject_Click()
        /// </summary>
        private void RemovePackageFromProject(Mog_BaseTag packageTag)
        {
            try
            {
                string message = "Are you sure you want to remove this package from the game?\r\n" + packageTag.PackageFullName;

                // If user OKs our removal...
                if (MOG_Prompt.PromptResponse("Remove Asset From Project", message, MOGPromptButtons.OKCancel) == MOGPromptResult.OK)
                {
                    if (packageTag.Execute)
                    {
                        MOG_Filename filename = new MOG_Filename(packageTag.FullFilename);

                        // Make sure we are an asset before showing log
                        if (filename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                        {
                            // Proceed to remove this package from the project; skiping the unpackage merge event
                            if (MOG_ControllerProject.RemoveAssetFromProject(filename, "No longer needed", false))
                            {
                                // Go ahead and actually remove the node
                                packageTag.ItemRemove();
                            }
                            else
                            {
                                MOG_Prompt.PromptMessage("Remove Package From Project Failed",
                                                         "The package could not be removed from the project.\n" +
                                                         "PACKAGE: " + filename.GetAssetFullName() + "\n\n" +
                                                         "We are now aborting the remove process.\n", Environment.StackTrace);
                                return;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MOG_Report.ReportMessage("Remove From Project", ex.Message, ex.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
            }
        }
Пример #18
0
        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);
        }
Пример #19
0
        /// <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);
            }
        }
Пример #20
0
        /// <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();
            }
        }
Пример #21
0
        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);
        }
Пример #22
0
        private string FixName(string name, ImportFile fullFilename, ref ArrayList properties)
        {
            string newName = null;
            bool   succeed = false;
            bool   cancel  = false;

            // Have we previously specified whether or not to apply changes to all names?
            if (mOkToAll == false)
            {
                // Looks like we need to fix up the name...
                ImportAssetTreeForm mImportForm = new ImportAssetTreeForm(fullFilename);

                // Keep trying until we either fix the name or we cancel.
                while (!succeed && !cancel)
                {
                    // Show BlessDialog as a modal dialog and determine if DialogResult = OK.
                    mImportForm.ShowDialog(MogMainForm.MainApp);
                    DialogResult rc = mImportForm.DialogResult;

                    // Save our extension settings for multi import
                    mShowExtensions = mImportForm.MOGShowExtensions;

                    // Check dialog results
                    if (rc == DialogResult.Cancel)
                    {
                        // This means the user clicked cancel
                        cancel = true;
                    }
                    else
                    {
                        if (rc == DialogResult.Yes)
                        {
                            // This is the OkToAll button
                            mOkToAll = true;
                        }

                        // Construct the new name based on the dialog fields
                        newName = mImportForm.GetFixedAssetName();

                        // Always check each name to make sure it worked...
                        succeed = CheckName(newName);
                        if (succeed)
                        {
                            properties.AddRange(mImportForm.MOGPropertyArray);

                            // Set previous settings for future imports
                            mPreviousProperties = new ArrayList();
                            mPreviousProperties.AddRange(mImportForm.MOGPropertyArray);
                            mPreviousClassifiaton = mImportForm.FinalAssetName.GetAssetClassification();
                            mPreviousPlatform     = mImportForm.FinalAssetName.GetAssetPlatform();
                        }
                    }
                }
            }
            else
            {
                // Since the OkToAll button was previously selected, just fix this name the same way w/o asking
                // Make sure to create mog names that match our previous settings of 'Extension' or 'No Extension'
                if (mShowExtensions)
                {
                    name = DosUtils.PathGetFileName(fullFilename.mImportFilename);
                }
                else
                {
                    name = DosUtils.PathGetFileNameWithoutExtension(fullFilename.mImportFilename);
                }

                MOG_Filename newAssetName = MOG_Filename.CreateAssetName(mPreviousClassifiaton, mPreviousPlatform, name);
                newName = newAssetName.GetAssetFullName();

                // Always check each name to make sure it worked...
                succeed = CheckName(newName);
                if (succeed == false)
                {
                    // Wow, this current name failed after a previous one succeeded...force the dialog to display agian.
                    mOkToAll = false;
                    newName  = FixName(name, fullFilename, ref properties);
                }
                else
                {
                    // Load previous properties set on earlier imports
                    properties.AddRange(mPreviousProperties);
                }
            }

            return(newName);
        }
        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);
                                }
                            }
                        }
                    }
                }
            }
        }
		private void MogControl_PackageTreeView_AfterLabelEdit(object sender, System.Windows.Forms.NodeLabelEditEventArgs e)
		{
			// Encapsulate all of this in a try-catch, since we don't want to crash MOG
			try
			{
				if (!CheckLabelEdit(e))
				{
					return;
				}

				// Disable further label editing
				e.Node.TreeView.LabelEdit = false;

				// Find our parent package
				TreeNode package = FindPackage(e.Node);

				TreeNode parent = e.Node.Parent;

				string nodeText = e.Node.Text.ToLower();
				ArrayList packagePlatforms = GetPackageLabelEditPlatforms(e, ref nodeText);

				// Switch base on what our nodeText was before the user editted it
				switch (nodeText.ToLower())
				{
				case "newgroup":
					#region new-group
					if (package != null)
					{
						// Get the new edited label name
						//string groupName = e.Label;

						MOG_Filename packageAsset = new MOG_Filename(((Mog_BaseTag)package.Tag).FullFilename);

						string groupName = GetQualifiedGroupName(e, package);

						// If we have a duplicate, do not add it
						if (ValidateNodeIsNotDuplicate(e.Node.Parent, groupName) == true)
						{
							MOG_Prompt.PromptResponse("Duplicate Entry!", "The group, " + groupName + ", "
								+ "already exists!  Group not added.");
							e.Node.Remove();
							return;
						}

						// Add group to Database
						if (!AddGroupToDatabase(groupName, packageAsset))
						{
							// We need to clean up the unsuccessfull add to the database
							e.Node.Remove();

							// Show error
							MOG_Prompt.PromptMessage("Create group", "We were unable to add this group to the database. Aborting");
						}

						AttachValidatedTagToNewObjectOrGroup(package, e.Node, PackageNodeTypes.Group);
						// Go ahead and select our node
						e.Node.TreeView.SelectedNode = e.Node;
					}
					#endregion newgroup
					break;
				case "(newpackageobject)":
					#region new-package-object
					if (package != null)
					{
						// Get the new edited label name
						string objectName = e.Label;
						e.Node.Text = "(" + objectName + ")";

						// If we have a duplicate, do not add it
						if (ValidateNodeIsNotDuplicate(e.Node.Parent, e.Node.Text) == true)
						{
							MOG_Prompt.PromptResponse("Duplicate Entry!", "The object, (" + objectName + "), "
								+ "already exists!  Package object not added.");
							e.Node.Remove();
							return;
						}

						MOG_Filename packageAsset = new MOG_Filename(((Mog_BaseTag)package.Tag).FullFilename);

						string groupPath = GetQualifiedGroupName(e, package);

						// Add group to Database
						if (!AddGroupToDatabase(groupPath, packageAsset))
						{
							// We need to clean up the unsuccessfull add to the database
							e.Node.Remove();

							// Show error
							MOG_Prompt.PromptMessage("Create object", "We were unable to add this object to the database. Aborting");
						}
						else
						{
							e.CancelEdit = true;
							AttachValidatedTagToNewObjectOrGroup(package, e.Node, PackageNodeTypes.Object);
							// Go ahead and select our node
							e.Node.TreeView.SelectedNode = e.Node;
						}
					}
					#endregion new-package-object
					break;
				case "newpackage":
					#region new-package
					// Get the new package name
					string nodeFullname = MOG_Filename.JoinClassificationString(e.Node.FullPath, e.Label);

					// Construct a valid filename
					MOG_Filename[] packages = new MOG_Filename[packagePlatforms.Count];
					bool duplicateExists = false;
					string duplicates = "";
					for (int i = 0; i < packages.Length && i < packagePlatforms.Count; ++i)
					{
						MOG_Filename packageName = MOG_Filename.CreateAssetName(e.Node.Parent.FullPath, (string)packagePlatforms[i], e.Label);
						packages[i] = packageName;
						// If we have a duplicate package, store 
						if ((duplicateExists |= ValidateNodeIsNotDuplicate(e.Node.Parent, packageName.GetAssetName())) == true)
						{
							duplicates += packageName + "\r\n";
						}
					}

					// If we had duplicates, warn user and exit
					if (duplicateExists)
					{
						MOG_Prompt.PromptResponse("Duplicate Entry(ies) Detected!", "The following were already exist:\r\n\r\n"
							+ duplicates);
						e.Node.Remove();
						return;
					}

					// If we did not get a ValidPackageName (or the user decided to abort...)
					foreach (MOG_Filename packageName in packages)
					{
						if (!ValidatePackageExtension(e, packageName))
						{
							return;
						}
					}

					bool problemAdding = false;
					string packageErrorPrompt = "Did not complete package add for the following: \r\n";

					// Go backwards through our packages (so we can get the right platforms.
					for (int i = packages.Length - 1; i > -1; --i)
					{
						MOG_Filename packageName = packages[i];
						// Did we get a valid package name?
						if (packageName != null)
						{
							// Create the package
							MOG_Filename createdPackage = CreatePackageForPlatform(e, packageName, parent);

							// If the user cancelled some part of the process or we had an error...
							if (createdPackage == null)
							{
								// Remove the node
								packageErrorPrompt += "\t" + packageName + ".";
								problemAdding = true;
								break;
							}


							TreeNode newPackageNode;

							// For our first platform, we've already got a node, use it...
							if (i == 0)
							{
								e.Node.Text = createdPackage.GetAssetName();
								e.Label.ToString();
								newPackageNode = e.Node;
							}
							// For subsequent platforms, add a new node...
							else
							{
								newPackageNode = e.Node.Parent.Nodes.Add(createdPackage.GetAssetName());
							}

							// Now that we've got our initial information, add our tag
							newPackageNode.Tag = new Mog_BaseTag(newPackageNode, createdPackage.GetEncodedFilename(), this.FocusForAssetNodes, true);
							((Mog_BaseTag)newPackageNode.Tag).PackageNodeType = PackageNodeTypes.Package;
							((Mog_BaseTag)newPackageNode.Tag).PackageFullName = createdPackage.GetAssetFullName();
							SetImageIndices(newPackageNode, GetAssetFileImageIndex(createdPackage.GetEncodedFilename()));
						}
					}

					// If we had a problem, let the user know and remove our package
					if (problemAdding)
					{
						MOG_Prompt.PromptMessage("Unable to Add Package(s)",
							packageErrorPrompt);
						e.Node.Remove();
						foreach (MOG_Filename packageName in packages)
						{
							RemovePackage(packageName);
						}
					}
					else // Else, we were OK, so go ahead and select this node...
					{
						e.Node.TreeView.SelectedNode = e.Node;

						foreach (MOG_Filename packageName in packages)
						{
							// Add this package to the list of newly added packages
							this.CreatedPackages.Add(packageName);
						}

						// Fire the after package create event
						if (AfterPackageCreate != null)
						{
							AfterPackageCreate(this, EventArgs.Empty);
						}
					}
					#endregion new-package
					break;
				}
			}
			catch (Exception ex)
			{
				MOG_Report.ReportMessage("TreeNode Error!", "Error committing change to package, group, or package object label:\n" + ex.Message, ex.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR);
				if (e.Node != null)
				{
					e.Node.Remove();
				}
			}
		}
Пример #25
0
        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);
        }
Пример #26
0
        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);
        }
Пример #27
0
        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 ()
Пример #28
0
 private void FindAndUpdateNodeLockStatus(string nodeKey, MOG_Filename assetName, MogControl_BaseTreeView tree)
 {
     // Attempt to find this node in our tree
     TreeNode[] foundNodes = tree.Nodes.Find(nodeKey, true);
     if (foundNodes != null && foundNodes.Length > 0)
     {
         foreach (TreeNode node in foundNodes)
         {
             Mog_BaseTag tag = node.Tag as Mog_BaseTag;
             if (tag != null)
             {
                 // Is this a sync target node
                 if (tag.AttachedSyncTargetInfo != null)
                 {
                     // Update this assets status
                     string assetRepositoryName = tag.FullFilename + "\\Files.Imported\\" + tag.AttachedSyncTargetInfo.FilenameOnly;
                     node.ImageIndex         = MogUtil_AssetIcons.GetBinaryLockedOrUnlockedIcon(assetName.GetAssetFullName(), assetRepositoryName);
                     node.SelectedImageIndex = node.ImageIndex;
                 }
                 else
                 {
                     // Update this assets status
                     node.ImageIndex         = MogUtil_AssetIcons.GetAssetIconIndex(assetName.GetAssetFullName());
                     node.SelectedImageIndex = node.ImageIndex;
                 }
             }
         }
     }
 }
Пример #29
0
        private static void ImportAsOne_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker            = sender as BackgroundWorker;
            List <object>    args              = e.Argument as List <object>;
            bool             looseFileMatching = (bool)args[0];

            string[]         sourceFilenames = (string[])args[1];
            HybridDictionary exactAssetNames = new HybridDictionary();
            HybridDictionary looseAssetNames = new HybridDictionary();

            for (int i = 0; i < sourceFilenames.Length && !worker.CancellationPending; i++)
            {
                string    filename   = sourceFilenames[i];
                ArrayList assetNames = new ArrayList();

                string message = "Mapping:\n" +
                                 "     " + Path.GetDirectoryName(filename) + "\n" +
                                 "     " + Path.GetFileName(filename);
                worker.ReportProgress(i * 100 / sourceFilenames.Length, message);

                if (DosUtils.DirectoryExistFast(filename))
                {
                    // Obtain the list of contained files
                    ArrayList containedFiles = DosUtils.FileGetRecursiveList(filename, "*.*");
                    if (containedFiles != null)
                    {
                        // Map these filenames to all the possible assetnames
                        assetNames = MOG_ControllerProject.MapFilenamesToAssetNames(containedFiles, "", worker);
                    }
                }
                else
                {
                    // Map this filename to all possible assetnames
                    assetNames = MOG_ControllerProject.MapFilenameToAssetName(filename, "", "");
                }

                // Check if we found some assetNames?
                if (assetNames != null)
                {
                    // Check if we are allowing loose matches? and
                    // Check if this is a possible loose match?
                    if (looseFileMatching &&
                        assetNames.Count == 2)
                    {
                        // Check if this is a blank?
                        MOG_Filename assetName = assetNames[1] as MOG_Filename;
                        if (assetName.GetFullFilename().Length == 0)
                        {
                            // Turn this into an exact match
                            assetNames.RemoveAt(1);
                        }
                    }

                    // Check if we found an exact match?
                    if (assetNames.Count == 1)
                    {
                        // Add this to our list of exactAssetNames if we haven't already found it
                        MOG_Filename assetName = assetNames[0] as MOG_Filename;
                        if (!exactAssetNames.Contains(assetName.GetAssetFullName()))
                        {
                            exactAssetNames[assetName.GetAssetFullName()] = assetName;
                        }
                    }
                    else
                    {
                        // Add all of the assetNames
                        foreach (MOG_Filename assetName in assetNames)
                        {
                            // Check if this is a blank?
                            if (assetName.GetFullFilename().Length == 0)
                            {
                                continue;
                            }

                            // Add this to our list of looseAssetNames if we haven't already found it
                            if (!looseAssetNames.Contains(assetName.GetAssetFullName()))
                            {
                                looseAssetNames[assetName.GetAssetFullName()] = assetName;
                            }
                        }
                    }
                }
            }

            // Check if we have any exact matches?
            if (exactAssetNames.Count > 0)
            {
                e.Result = new ArrayList(exactAssetNames.Values);
            }
            else
            {
                // Check if are allowing loose matching?
                if (looseFileMatching)
                {
                    e.Result = new ArrayList(looseAssetNames.Values);
                }
                else
                {
                    // Add back on the empty entry if it is needed
                    if (looseAssetNames.Count == 1)
                    {
                        looseAssetNames[""] = new MOG_Filename("");
                    }

                    // Return our list of foundAssets
                    e.Result = new ArrayList(looseAssetNames.Values);
                }
            }
        }
Пример #30
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);
            }
        }