Esempio n. 1
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));
        }
Esempio n. 2
0
        private bool SetParentForecolors(MOG_Filename filename, TreeNode node, int numberOfRevisions)
        {
            node.ForeColor = Color.Red;

            if (node.Text.EndsWith(filename.GetAssetLabel(), StringComparison.CurrentCultureIgnoreCase))
            {
                // We also need to remove the "Current <DATE>" node
                if (node.Nodes != null &&
                    node.Nodes.Count > 0 &&
                    node.Nodes[0].Text.StartsWith("Current", StringComparison.CurrentCultureIgnoreCase))
                {
                    node.Nodes[0].Remove();
                }

                return(true);
            }
            else if (numberOfRevisions == 1)
            {
                if (node.Parent != null)
                {
                    if (SetParentForecolors(filename, node.Parent, numberOfRevisions))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 3
0
        private void CreateLateResolverItem(MOG_DBPackageCommandInfo packageCommand)
        {
            MOG_Filename assetName = new MOG_Filename(packageCommand.mAssetName);

            if (assetName.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
            {
                ListViewItem item = new ListViewItem();

                // "NAME, CLASSIFICATION, DATE, TARGET PACKAGE, OWNER, FULLNAME, COMMANDID, LABEL, VERSION"

                item.Text = assetName.GetAssetLabel();
                item.SubItems.Add(assetName.GetAssetClassification());                 // Class
                item.SubItems.Add(MogUtils_StringVersion.VersionToString(packageCommand.mAssetVersion));
                item.SubItems.Add(packageCommand.mPackageName);
                item.SubItems.Add((packageCommand.mBlessedBy.Length != 0) ? packageCommand.mBlessedBy : packageCommand.mCreatedBy);
                item.SubItems.Add(packageCommand.mAssetName);
                item.SubItems.Add(packageCommand.mID.ToString());
                item.SubItems.Add(packageCommand.mLabel);
                item.SubItems.Add(packageCommand.mAssetVersion);

                item.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(packageCommand.mAssetName, null, false);

                mainForm.ConnectionManagerLateResolversListView.Items.Add(item);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Make sure this asset is MOG Compliant
        /// </summary>
        private bool CheckName(string filename)
        {
            MOG_Filename assetName;

            try
            {
                assetName = new MOG_Filename(filename);
            }
            catch
            {
                throw new Exception("Unable to convert filename, '" + filename + "' to a valid MOG Filename.");
            }

            // No asset is valid if it has the '[' character
            // Original string == "[]'`,$^:?*<>/\\%#!|="
            // glk:  Kier and I changed this so that ONLY Windows, MOG-Specific, and INI chars are filtered
            if (assetName.GetAssetLabel().Split(ImportFilter_String.ToCharArray()).Length > 1)
            {
                throw new Exception("Non-valid character in import file: \n\n\t " + ImportFilter_String);
            }

            // Make sure the asset name is valid
            if (assetName.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Unknown && MOG_ControllerProject.ValidateAssetFilename(assetName) == false)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        /// <summary>
        /// Create one new node or update an existing node in the tree.
        /// </summary>
        /// <param name="tree"></param>
        /// <param name="assetName"></param>
        /// <param name="nodeColor"></param>
        static public void AssetTreeViewUpdateNode(string dir, TreeView tree, MOG_Filename assetName, Color nodeColor)
        {
            // Find the type in tree if exists
            TreeNode parent = FindAssetNodeInTree(tree, assetName);

            if (parent != null)
            {
                TreeNode node = new TreeNode();
                node.Text      = assetName.GetAssetLabel();                             // Name
                node.ForeColor = nodeColor;                                             // Color
                node.Checked   = true;

                node.ImageIndex = MogUtil_AssetIcons.GetClassIconIndex(assetName.GetEncodedFilename());

                string fullname = dir + "\\" + assetName.GetEncodedFilename();
                node.Tag = new guiAssetTreeTag(fullname, guiAssetTreeTag.TREE_FOCUS.SUBCLASS, true);

                // Add this asset to the tree
                parent.Nodes.Add(node);
            }
        }
Esempio n. 7
0
        private string GetTargetName(MOG_Filename assetCheck, string classification, string platform, string label)
        {
            // Rename according to pattern
            string targetName = "";

            // Attach classification (e.g. "textures~humans")
            if (classification == "*")
            {
                targetName += assetCheck.GetAssetClassification();
            }
            else
            {
                targetName += classification;
            }

            // Attach platform label (e.g. 'all' OR 'pc' OR 'xbox')
            if (platform == "*")
            {
                targetName += "{" + assetCheck.GetAssetPlatform() + "}";
            }
            else
            {
                targetName += "{" + platform + "}";
            }

            // Attach label for files (e.g. 'body')
            if (label == "*")
            {
                targetName += assetCheck.GetAssetLabel();
            }
            else
            {
                targetName += label;
            }

            return(targetName);
        }
Esempio n. 8
0
        private void CreatePostItem(MOG_DBPostInfo post)
        {
            MOG_Filename assetName = new MOG_Filename(post.mAssetName);

            if (assetName.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
            {
                ListViewItem item = new ListViewItem();

                // "NAME, CLASSIFICATION, DATE, OWNER, FULLNAME, COMMANDID"

                item.Text = assetName.GetAssetLabel();
                //item.SubItems.Add(assetName.GetAssetLabel());
                item.SubItems.Add(assetName.GetAssetClassification());
                item.SubItems.Add(MogUtils_StringVersion.VersionToString(post.mAssetVersion));
                item.SubItems.Add(post.mBlessedBy);
                item.SubItems.Add(post.mAssetName);
                item.SubItems.Add(post.mID.ToString());
                item.SubItems.Add(post.mLabel);
                item.SubItems.Add(post.mAssetVersion);
                item.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(post.mAssetName, null, false);

                mainForm.ConnectionManagerPostingListView.Items.Add(item);
            }
        }
Esempio n. 9
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);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        /// <summary>
        /// Update an existing ListView node for the asset manager inboxes
        /// </summary>
        /// <param name="pProperties"></param>
        /// <param name="nodeColor"></param>
        /// <returns></returns>
        public static void UpdateListViewItem(ListViewItem item, MOG_Filename asset, string status, MOG_Properties pProperties)
        {
            string date    = "";
            string size    = "";
            string creator = "";
            string owner   = "";
            string group   = "";
            string target  = "";

            // Check if we have a properties?
            if (pProperties != null)
            {
                // If we have a valid gameDataController, set our platform scope
                if (MOG_ControllerProject.GetCurrentSyncDataController() != null)
                {
                    // Set our current platform
                    pProperties.SetScope(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName());
                }

                // Gather the following info from our properties
                date    = MOG_Time.FormatTimestamp(pProperties.CreatedTime, "");
                size    = guiAssetController.FormatSize(pProperties.Size);
                creator = pProperties.Creator;
                owner   = pProperties.Owner;
                group   = pProperties.Group;

                // Check if this is a packaged asset?
                if (pProperties.IsPackagedAsset)
                {
                    // Check if we have have any package assignments in our propeerties?
                    ArrayList packages = pProperties.GetPackages();
                    if (packages.Count == 0)
                    {
                        // Indicate this is a packaged asset w/o any package assignments
                        target = "Missing package assignment...";
                    }
                    else if (packages.Count == 1)
                    {
                        MOG_Property package          = packages[0] as MOG_Property;
                        MOG_Filename packageName      = new MOG_Filename(MOG_ControllerPackage.GetPackageName(package.mPropertyKey));
                        string       packageGroupPath = MOG_ControllerPackage.GetPackageGroups(package.mPropertyKey);
                        string       displayString    = MOG_ControllerPackage.CombinePackageAssignment(packageName.GetAssetLabel(), packageGroupPath, "");
                        target = "{Package} " + displayString + "  in  " + MOG_Filename.GetAdamlessClassification(packageName.GetAssetClassification());
                    }
                    else
                    {
                        target = "{Package} " + packages.Count + " Assignments...";
                    }
                }
                else if (pProperties.SyncFiles)
                {
                    // Get the formatted SyncTarget of this asset
                    target = MOG_Tokens.GetFormattedString("{Workspace}\\" + pProperties.SyncTargetPath, asset, pProperties.GetPropertyList());
                }
            }

            item.Text = asset.GetAssetLabel();

            // Populate the item's SubItems
            // I tried for a long time to be smart here and use ColumnNameFind(thisListView.Columns, "Name") but
            // I kept running into walls because this function is used by a lot of workers outside of the ListView's thread.
            // So, I gave up and am just going to do it the ugly brute force way!  YUCK!!
            item.SubItems[(int)AssetBoxColumns.NAME].Text       = asset.GetAssetLabel();
            item.SubItems[(int)AssetBoxColumns.CLASS].Text      = asset.GetAssetClassification();
            item.SubItems[(int)AssetBoxColumns.TARGETPATH].Text = target;
            item.SubItems[(int)AssetBoxColumns.DATE].Text       = date;
            item.SubItems[(int)AssetBoxColumns.SIZE].Text       = size;
            item.SubItems[(int)AssetBoxColumns.PLATFORM].Text   = asset.GetAssetPlatform();
            item.SubItems[(int)AssetBoxColumns.STATE].Text      = status;
            item.SubItems[(int)AssetBoxColumns.CREATOR].Text    = creator;
            item.SubItems[(int)AssetBoxColumns.RESPPARTY].Text  = owner;
            item.SubItems[(int)AssetBoxColumns.OPTIONS].Text    = "";
            item.SubItems[(int)AssetBoxColumns.FULLNAME].Text   = asset.GetEncodedFilename();
            item.SubItems[(int)AssetBoxColumns.BOX].Text        = asset.GetBoxName();
            item.SubItems[(int)AssetBoxColumns.GROUP].Text      = group;

            // Set the item's Icons
            item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(asset.GetEncodedFilename(), pProperties);

            if (MogMainForm.MainApp != null &&
                MogMainForm.MainApp.mAssetManager != null)
            {
                // mAssetStatus.GetStatusInfo() is sort of a black sheep and should maybe become static
                item.StateImageIndex = MogMainForm.MainApp.mAssetManager.mAssetStatus.GetStatusInfo(status).IconIndex;
            }

            // Set the item's color
            item.ForeColor = MOG_AssetStatus.GetColor(status);
            // Check if this is a local item that has been blessed?
            if (asset.IsLocal() &&
                string.Compare(status, MOG_AssetStatus.GetText(MOG_AssetStatusType.Blessed), true) == 0)
            {
                // Mark local blessed items with light gray
                item.ForeColor = Color.LightGray;
            }
        }
Esempio n. 12
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 ()
		/// <summary>
		/// Add group or object to the database
		/// </summary>
		private bool AddGroupToDatabase(string addCandidate, MOG_Filename packageAsset)
		{
			// Are we platform generic?
			bool success = true;

			if (packageAsset.GetAssetPlatform() == "All")
			{
				string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset);
				if (packageVersion.Length > 0)
				{
					success = MOG_DBPackageAPI.AddPackageGroupName(packageAsset, packageVersion, addCandidate, MOG_ControllerProject.GetUser().GetUserName());
				}
			}

			// We are platform generic, loop through all platforms then
			ArrayList platforms = MOG_ControllerProject.GetProject().GetPlatforms();
			for (int p = 0; p < platforms.Count && success; p++)
			{
				MOG_Platform platform = (MOG_Platform)platforms[p];

				// Set this package to be platform specific for this platform name
				packageAsset = MOG_Filename.CreateAssetName(packageAsset.GetAssetClassification(), platform.mPlatformName, packageAsset.GetAssetLabel());
				string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset);
				if (packageVersion.Length > 0)
				{
					// Add to the database
					success &= MOG_DBPackageAPI.AddPackageGroupName(packageAsset, packageVersion, addCandidate, MOG_ControllerProject.GetUser().GetUserName());
				}
			}

			return success;
		}
		/// <summary>
		/// Remove a Group or Package Object from the database
		/// </summary>
		/// <param name="removeCandidate">Full path of Group or Object with 
		/// '/' as delimiter, starting from package name.</param>
		/// <param name="packageAsset">The Asset that is the Package</param>
		/// <param name="platformGeneric">
		/// Whether or not this is a platform Generic operation.  
		/// 
		/// This is where the "Show Platform Specific" checkbox would 
		/// plug in from the PackageManagementTreeView
		/// </param>
		/// <returns>Bool indicating success/failure</returns>
		public bool RemoveGroupFromDatabase(string removeCandidate, MOG_Filename packageAsset)
		{
			try
			{
				bool success = true;

				// Get the current version of this package
				string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset);

				// Check to see if any assets reference this
				if (MOG_DBPackageAPI.GetAllAssetsInPackageGroup(packageAsset, packageVersion, removeCandidate).Count == 0)
				{
					// If all is ok, remove it from the database
					success &= MOG_DBPackageAPI.RemovePackageGroupName(packageAsset, packageVersion, removeCandidate, MOG_ControllerProject.GetUser().GetUserName());
				}
				else
				{
					throw (new Exception("Cannot remove object or group that is used by active assets!"));
				}

				// Are we platform generic?
				if (String.Compare(packageAsset.GetAssetPlatform(), "All", true) == 0)
				{
					// We are platform generic, loop through all platforms then
					ArrayList platforms = MOG_ControllerProject.GetProject().GetPlatforms();
					for (int p = 0; p < platforms.Count; p++)
					{
						MOG_Platform platform = (MOG_Platform)platforms[p];

						// Set this package to be platform specific for this platform name
						packageAsset = MOG_Filename.CreateAssetName(packageAsset.GetAssetClassification(), platform.mPlatformName, packageAsset.GetAssetLabel());
						packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset);
						if (packageVersion.Length > 0)
						{
							// Check to see if any assets reference this
							if (MOG_DBPackageAPI.GetAllAssetsInPackageGroup(packageAsset, packageVersion, removeCandidate).Count == 0)
							{
								// If all is ok, remove it from the database
								success &= MOG_DBPackageAPI.RemovePackageGroupName(packageAsset, packageVersion, removeCandidate, MOG_ControllerProject.GetUser().GetUserName());
							}
							else
							{
								throw (new Exception("Cannot remove object or group that is used by active assets!"));
							}
						}
					}
				}

				return success;
			}
			catch (Exception e)
			{
				// Get the current version of this package
				string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset);

				// See if we can report to the user about why this node could not be deleted
				ArrayList assignedAssets = MOG_DBPackageAPI.GetAllAssetsInPackageGroup(packageAsset, packageVersion, removeCandidate);

				if (assignedAssets != null)
				{
					// Walk all associated assets and make a list
					string assets = "";
					foreach (MOG_Filename assetName in assignedAssets)
					{
						if (assets.Length == 0)
						{
							assets = assetName.GetEncodedFilename();
						}
						else
						{
							assets = assets + "\n" + assetName.GetEncodedFilename();
						}
					}

					// Tell the user
					MOG_Prompt.PromptMessage("Remove node", "Cannot remove this node because the following assets are assigned to it:\n\n" + assets);
				}
				else
				{
					// This must have been another problem
					MOG_Prompt.PromptMessage("Remove node", "Cannot remove this node.\nMessage\n" + e.Message);
				}
			}

			return false;
		}