Beispiel #1
0
        public void ShellSpawnWithLock()
        {
            if (mBinary == null || mAsset == null)
            {
                MOG_Prompt.PromptMessage("Spawn Viewer Error!", "One of the following was not initialized: Viewer, Binary, Asset", Environment.StackTrace);
                return;
            }
            else
            {
                MOG_Command command = new MOG_Command();

                // Get Asset Lock
                command = MOG.COMMAND.MOG_CommandFactory.Setup_LockReadRequest(mAsset.GetOriginalFilename(), "Asset View - Open Asset");
                if (MOG_ControllerSystem.GetCommandManager().CommandProcess(command))
                {
                    string output = "";
                    if (mViewer != null && mViewer.Length == 0)
                    {
                        guiCommandLine.ShellExecute(mBinary);
                    }
                    else
                    {
                        guiCommandLine.ShellExecute(mViewer, mBinary, ProcessWindowStyle.Normal, ref output);
                    }

                    command = MOG.COMMAND.MOG_CommandFactory.Setup_LockReadRelease(mAsset.GetOriginalFilename());
                    MOG_ControllerSystem.GetCommandManager().CommandProcess(command);
                }
            }
        }
Beispiel #2
0
        private ListViewItem AddItemToListView(MOG_Filename mogAsset, MOG_Properties pProperties, string fullPath)
        {
            ListViewItem item = new ListViewItem();

            foreach (ColumnHeader column in ListListView.Columns)
            {
                item.SubItems.Add("");
            }

            SetSubColumnText(item, "Name", mogAsset.GetAssetLabel());
            SetSubColumnText(item, "MOG Classification", mogAsset.GetAssetClassification());
            SetSubColumnText(item, "Platform", mogAsset.GetAssetPlatform());
            SetSubColumnText(item, "Version", mogAsset.GetVersionTimeStampString(""));

            if (pProperties != null)
            {
                SetSubColumnText(item, "Size", guiAssetController.FormatSize(pProperties.Size));
                SetSubColumnText(item, "Package", GetPackages(pProperties));
                SetSubColumnText(item, "Creator", pProperties.Creator);
                SetSubColumnText(item, "Last Bless", pProperties.Owner);
                SetSubColumnText(item, "Computer", pProperties.SourceMachine);
                SetSubColumnText(item, "GamePath", pProperties.SyncTargetPath);
                SetSubColumnText(item, "Last Comment", pProperties.LastComment);
            }

            SetSubColumnText(item, "Fullname", fullPath);

            // Icon
            item.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(mogAsset.GetOriginalFilename(), pProperties, false);
            return(ListListView.Items.Add(item));
        }
Beispiel #3
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);
            }
        }
        public bool Remove(MOG_Filename filename, BackgroundWorker worker)
        {
            Debug.Write(filename.GetOriginalFilename(), "\nClick_Delete");
            MOG_ControllerInbox.Delete(filename);

            // Check if this asset was within our own inbox?
            if (string.Compare(filename.GetUserName(), MOG_ControllerProject.GetUserName_DefaultAdmin(), true) == 0)
            {
                // Check if this was one of our drafts or inbox assets?
                if (filename.IsDrafts() || filename.IsInbox())
                {
                    // Add this asset to all of our active workspaces
                    if (WorkspaceManager.RemoveAssetFromWorkspaces(filename, true, worker))
                    {
                    }
                }
            }

            return(true);
        }
        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);
                    }
                }
            }
        }
        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);
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Remove packages from Assets currently selected.  Use CheckForBlessedAssetMessage() before calling.
        /// </summary>
        /// <param name="packagesToRemove">ArrayList of MOG_Property objects for packages to be removed</param>
        private void RemovePackageLinkFromAssets(ArrayList packagesToRemove)
        {
            foreach (ListViewItem item in AssetList.Items)
            {
                MOG_Filename assetFilename = item.Tag as MOG_Filename;
                if (assetFilename != null)
                {
                    // If this asset is not a blessed Asset, and it's not a classification...
                    if (!assetFilename.IsBlessed() && assetFilename.GetFilenameType() != MOG_FILENAME_TYPE.MOG_FILENAME_Unknown)
                    {
                        // Open up this asset so we can remove the package relationships
                        MOG_ControllerAsset asset = MOG_ControllerAsset.OpenAsset(assetFilename);
                        if (asset != null)
                        {
                            // Remove the packages
                            asset.GetProperties().RemovePackages(packagesToRemove);
                            // Depending on how the user clicked, it is possible that an inherited package assignment can be left behind as a non-inherited property
                            // The following code ensures all non-inherited package assignments are flushed by restamping any non-inherited assignemnts.
                            asset.GetProperties().SetProperties(asset.GetProperties().GetNonInheritedPackages());

                            // Make sure we keep the group in sync with our new assignment
                            MOG_ControllerAsset.SetDefaultGroup(asset);

                            // Change the state of the asset to indicate it has been modified
                            MOG_ControllerInbox.UpdateInboxView(asset, MOG_AssetStatusType.Modifying);
                            ModifyingAssets = true;

                            asset.Close();
                        }
                    }
                    else
                    {
                        // We should be looking at a classification, so treat it as such...
                        MOG_Properties properties = MOG_Properties.OpenClassificationProperties(assetFilename.GetOriginalFilename());
                        if (properties != null)
                        {
                            properties.RemovePackages(packagesToRemove);
                            properties.Close();
                        }
                    }
                }
            }
        }
Beispiel #9
0
        private bool AddPackageLinkToAssets(string packageName, Color color, bool markAsInherited, bool setPackageProperties)
        {
            bool success = true;

            ListViewItem item = FindAssignmentListItem(packageName);

            if (item == null)
            {
                item           = new ListViewItem(packageName);
                item.ForeColor = color;
                AssignmentList.Items.Add(item);

                if (setPackageProperties)
                {
                    success = false;

                    ArrayList PackageAssignmentProps = new ArrayList();
                    PackageAssignmentProps.Add(CreatePackageAssignmentProperty(packageName));

                    // Go through our listview items again to Add or Remove assets we found in the previous foreach loop
                    foreach (ListViewItem assetItem in AssetList.Items)
                    {
                        MOG_Filename assetFilename = assetItem.Tag as MOG_Filename;
                        if (assetFilename != null &&
                            assetFilename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                        {
                            // If this asset is not a blessed Asset, and it's not a classification...
                            if (!assetFilename.IsBlessed())
                            {
                                MOG_ControllerAsset asset = MOG_ControllerAsset.OpenAsset(assetFilename);
                                if (asset != null)
                                {
                                    if (asset.GetProperties().AddPackages(PackageAssignmentProps))
                                    {
                                        success = true;

                                        // Make sure we keep the group in sync with our new assignment
                                        MOG_ControllerAsset.SetDefaultGroup(asset);

                                        // Change the state of the asset to indicate it has been modified
                                        MOG_ControllerInbox.UpdateInboxView(asset, MOG_AssetStatusType.Modifying);
                                        ModifyingAssets = true;
                                    }

                                    asset.Close();
                                }
                            }
                            else
                            {
                                MOG_Prompt.PromptMessage("Cannot add PackageAssignments to Blessed Assets",
                                                         "Please copy the Asset to your Inbox and change its package assignments from there so it can be properly processed and re-Blessed.",
                                                         "",
                                                         MOG.PROMPT.MOG_ALERT_LEVEL.ALERT);
                            }
                        }
                        else if (assetFilename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Unknown)
                        {
                            // We should be looking at a classification, so treat it as such...
                            MOG_Properties properties = MOG_Properties.OpenClassificationProperties(assetFilename.GetOriginalFilename());
                            if (properties != null)
                            {
                                if (properties.AddPackages(PackageAssignmentProps))
                                {
                                    success = true;
                                }
                                properties.Close();
                            }
                        }
                    }
                }
            }

            if (item != null && markAsInherited)
            {
                item.Font = new Font(AssignmentList.Font, FontStyle.Italic);
            }

            if (!success)
            {
                MOG_Report.ReportMessage("Error Adding Package Assignment", "Failed to add package assignment!", Environment.StackTrace, MOG_ALERT_LEVEL.ERROR);
            }

            return(success);
        }
Beispiel #10
0
        /// <summary>
        /// Update the inboxes with the new command that just came in
        /// </summary>
        /// <param name="command"></param>
        public void RefreshWindowsBoth(MOG_Command command)
        {
            MOG_Filename del = new MOG_Filename(command.GetSource());
            MOG_Filename add = new MOG_Filename(command.GetDestination());

            // We need to strip off the root folder so that we get a more accurate user path
            // Without this change, we got y:\\Projects\Users when we selected a root drive at the repository
            string userPath = MOG_ControllerProject.GetActiveUser().GetUserPath().ToLower();

            // Check if the add is within the inboxes
            if (add.IsWithinInboxes())
            {
                // Check if we are not within the path that is relevant for this user?
                if (!add.IsWithinPath(userPath))
                {
                    // Eat it
                    add.SetFilename("");
                }
            }
            // Check if this is outside our current workspace directory?
            else if (add.IsLocal())
            {
                // Check if we are not within the path that is relevant for this user?
                if (!add.IsWithinPath(MOG_ControllerProject.GetWorkspaceDirectory()))
                {
                    // Eat it
                    add.SetFilename("");
                }
            }

            // Check if the del is within the inboxes
            if (del.IsWithinInboxes())
            {
                // Check if we are not within the path that is relevant for this user?
                if (!del.IsWithinPath(userPath))
                {
                    // Eat it
                    del.SetFilename("");
                }
            }
            // Check if this is outside our current workspace directory?
            else if (del.IsLocal())
            {
                // Check if we are not within the path that is relevant for this user?
                if (!del.IsWithinPath(MOG_ControllerProject.GetWorkspaceDirectory()))
                {
                    // Eat it
                    del.SetFilename("");
                }
            }

            // Determin which one we can test for the asset type?
            MOG_Filename check = (add.GetOriginalFilename().Length != 0) ? add : del;

            switch (check.GetFilenameType())
            {
            case MOG_FILENAME_TYPE.MOG_FILENAME_Group:
            case MOG_FILENAME_TYPE.MOG_FILENAME_Asset:
            case MOG_FILENAME_TYPE.MOG_FILENAME_Link:
                if (mAssets != null)
                {
                    mAssets.RefreshBox(add, del, command);
                }
                break;
            }

            //Application.DoEvents();
        }