/// <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;
		}
Esempio n. 2
0
        public void InitializeVirtual(string platform)
        {
            if (!mInitialized)
            {
                GameDataTreeView.BeginUpdate();

                GameDataTreeView.Nodes.Clear();
                mVirtual = true;

                // Populate our project tree
                ArrayList virtualDirectories        = MOG_DBAssetAPI.GetAllProjectSyncTargetFilesForPlatform(platform);
                ArrayList fixedUpVirtualDirectories = new ArrayList();
                foreach (string file in virtualDirectories)
                {
                    // Only add files that have '\\' in front of them.  These are files.  Those
                    // without '\\' are packages and the files that go into them
                    if (file.StartsWith("\\"))
                    {
                        fixedUpVirtualDirectories.Add(file.TrimStart("\\".ToCharArray()));
                    }
                    else
                    {
                        // File did not have a starting '\', so just add it :)
                        fixedUpVirtualDirectories.Add(file);
                    }
                }

                mSyncTargetFiles = new DirectorySet(fixedUpVirtualDirectories);
                if (MOG_ControllerProject.GetCurrentSyncDataController() != null)
                {
                    mRoot     = new TreeNode(MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory());
                    mRoot.Tag = new guiAssetTreeTag(MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory(), mRoot, MOG_ControllerProject.GetCurrentSyncDataController(), false);

                    VirtualExpand(mRoot, "", MOG_ControllerProject.GetCurrentSyncDataController());

                    FillDirectory(mRoot, MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory(), SystemColors.InactiveCaptionText);

                    GameDataTreeView.Nodes.Add(mRoot);

                    mRoot.Expand();
                }

                mInitialized = true;

                // If we have nothing for this tree, we should disable it...
                if (GameDataTreeView.Nodes.Count < 1)
                {
                    GameDataTreeView.Visible = false;
                    NoLocalDataLabel.Visible = true;
                }
                else
                {
                    GameDataTreeView.Visible = true;
                    NoLocalDataLabel.Visible = false;
                }

                GameDataTreeView.EndUpdate();
            }
        }
		/// <summary>
		/// Utility method for the Package portion of AfterLabelEdit() (above)
		/// </summary>
		private ArrayList GetValidTargetSyncPath(NodeLabelEditEventArgs e, MOG_Filename packageName)
		{
			// Get the gameDataPath for this new package
			GameDataPathForm getPath = new GameDataPathForm(packageName.GetAssetPlatform(), packageName.GetAssetName());
			ArrayList targetSyncPath = null;

			// This dialog should be pushed to topmost when it doesn't have a parent or else it can ger lost behind other apps.
			// You would think this is simple but for some reason MOG has really struggled with these dialogs being kept on top...
			// We have tried it all and finally ended up with this...toggling the TopMost mode seems to be working 100% of the time.
			getPath.TopMost = true;
			getPath.TopMost = false;
			getPath.TopMost = true;
			// Show the dialog
			if (DialogResult.Cancel != getPath.ShowDialog())
			{

				targetSyncPath = getPath.MOGPropertyArray;

				// Get a value for our relative gamedata path
				string relativePath = null;
				if (targetSyncPath.Count > 0)
				{
					relativePath = ((MOG_Property)targetSyncPath[0]).mPropertyValue;
				}
				// If we found our relativePath...
				if (relativePath != null)
				{
					// Go ahead and add an initial backslash, if necessary...
					if (relativePath.Length > 0 && relativePath[0] != '\\')
					{
						relativePath = "\\" + relativePath;
					}

					// Find all our assets with this gamedata path
					ArrayList assets = MOG_DBAssetAPI.GetAllAssetsBySyncLocation(relativePath, packageName.GetAssetPlatform());
					// If we found assets...
					if (assets != null && assets.Count > 0)
					{
						// Check and see if any of the assets we found match the package we want to add...
						foreach (MOG_Filename asset in assets)
						{
							// If we already have the package name we want to add, warn user and quit...
							if (asset.GetAssetName().ToLower() == packageName.GetAssetName().ToLower())
							{
								MessageBox.Show(this, "Package name, " + packageName.GetAssetName() + ", already exists in location, '" + relativePath.Substring(1) + "'!", "Package Already Exists!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
								e.Node.EndEdit(true);
								e.Node.Remove();
								return null;
							}
						}
					}
				}
			}

			// Finished our method, so return true
			return targetSyncPath;
		}
Esempio n. 4
0
        static public void AssetTreeViewCreate(string versionInfoFilename, TreeView tree, TreeNode parent, guiAssetGamedataTreeTag.TREE_FOCUS level, bool createChildNode)
        {
            /// Changes to this function could have side-effects in many other areas...
            int defaultImageIndex = 0;

            guiAssetGamedataTreeTag currentTag = null;

            if (parent != null)
            {
                currentTag = (guiAssetGamedataTreeTag)parent.Tag;
            }

            // Find the items in the ASSETS section, set value of `contents`
            ArrayList contents = new ArrayList();

            switch (level)
            {
            case guiAssetGamedataTreeTag.TREE_FOCUS.BASE:
// TODO - Check this!
//					contents = MOG_DBAssetAPI.GetAllUniqueProjectKeys();
                break;

            case guiAssetGamedataTreeTag.TREE_FOCUS.PLATFORM:
                string[] platformNames = MOG_ControllerProject.GetProject().GetPlatformNames();
                foreach (string platformName in platformNames)
                {
                    contents.Add(platformName);
                }
                break;

            case guiAssetGamedataTreeTag.TREE_FOCUS.KEY:

                // If we have no ListForNode ArrayList, start fresh
                if (currentTag == null || currentTag.ListForNode.Count < 1)
                {
                    contents = MOG_DBAssetAPI.GetAllProjectSyncTargetFilesForPlatform(parent.Text);
                    assetTreeViewCreate_ParseSyncTargetFileNodes(contents, parent, versionInfoFilename, level);
                }
                //Else we are in a subNode and need to process a ListForNode
                else
                {
                    assetTreeViewCreate_ParseSyncTargetFileNodes(currentTag.ListForNode, parent, versionInfoFilename, level);
                }
                return;

            default:
                return;
            }
            assetTreeViewCreate_AddNodes(contents, versionInfoFilename, tree, parent,
                                         level, defaultImageIndex, true);
        }
Esempio n. 5
0
        public List <string> GetAssets(TreeNode node)
        {
            ArrayList assetList          = new ArrayList();
            string    nodeClassification = node.FullPath;

            // Check if we should show asset-level nodes?
            if (ShowAssets || ExpandPackageGroups)
            {
                // Check if this is a classification we want to display everything in?
                if (ShowEntireClassificationContents(nodeClassification))
                {
                    // Get the list of assets
                    assetList = MOG_DBAssetAPI.GetAllAssetsByClassification(nodeClassification);
                }
                else
                {
                    assetList = GetRequiredAssets(nodeClassification);
                }
            }

            // Exclude assets from our list that have undefined the property
            assetList = ExcludeAssets(assetList, nodeClassification);

            // Prepare our list of assets for return
            List <string> returnAssets = new List <string>();

            foreach (MOG_Filename asset in assetList)
            {
                // Check if we want to exclude platform-specific asset?
                if (!ShowPlatformSpecific)
                {
                    MOG_Filename filename = new MOG_Filename(asset);
                    if (filename.IsPlatformSpecific())
                    {
                        continue;
                    }
                }

                returnAssets.Add(asset.GetAssetFullName());
            }

            return(returnAssets);
        }
        private ArrayList GetAllProjectSyncTargetFileForDirectory(MOG_ControllerSyncData targetGameData, string path)
        {
            try
            {
                ArrayList fileList = MOG_DBAssetAPI.GetAllProjectSyncTargetFilesForDirectory(targetGameData.GetSyncDirectory(), path, targetGameData.GetPlatformName());

                string targetDir = path.ToLower().Replace(targetGameData.GetSyncDirectory().ToLower(), "");
                int    depth     = DosUtils.DirectoryDepth(targetDir);

                SortedSet directories = new SortedSet();
                foreach (string file in fileList)
                {
                    if (targetDir.Length == 0)
                    {
                        directories.Add(targetGameData.GetSyncDirectory() + "\\" + DosUtils.DirectoryGetAtDepth(file, depth));
                    }
                    else if (file.ToLower().IndexOf(targetDir.ToLower()) != -1)
                    {
                        directories.Add(targetGameData.GetSyncDirectory() + "\\" + DosUtils.DirectoryGetAtDepth(file, depth));
                    }
                    else
                    {
                        directories.Add(targetGameData.GetSyncDirectory() + "\\" + DosUtils.DirectoryGetAtDepth(file, depth));
                    }
                }

                ArrayList finalFileList = new ArrayList();
                foreach (string dir in directories)
                {
                    finalFileList.Add(dir);
                }

                return(finalFileList);
            }
            catch
            {
                return(new ArrayList());
            }
        }
Esempio n. 7
0
        public List <string> GetSubClassifications(TreeNode node)
        {
            ArrayList classificationList = new ArrayList();
            string    nodeClassification = node.FullPath;

            // Check if this is a classification we want to display everything in?
            if (ShowEntireClassificationContents(nodeClassification))
            {
                // Get all the children of this node's classification
                ArrayList childClassifications = MOG_DBAssetAPI.GetClassificationChildren(nodeClassification);
                if (childClassifications != null)
                {
                    classificationList.AddRange(childClassifications);
                }
                // Make sure we exclude any items that have explicitly undefined the property
                classificationList = ExcludeClassifications(classificationList, nodeClassification);
            }
            else
            {
                // Get the classification children based on the required assets and required classifications
                classificationList = GetRequiredClassificationChildren(nodeClassification);
// I was trying to get required classifications to still be excluded if they had a matching exclusion but...
// This cause the required classifications to be excluded even when they has a child classification that required them to be visible.
// Removed it until later...We really need to know what is a real required classification versus a parent the got included due to a required child
//				// Make sure we exclude any classifications even if they are included as a required classification
//				classificationList = ExcludeClassifications(classificationList, nodeClassification);
            }

            // Transfer the classificationList over to a string array
            List <string> returnClassifications = new List <string>();

            foreach (string classification in classificationList)
            {
                returnClassifications.Add(classification);
            }

            return(returnClassifications);
        }
Esempio n. 8
0
        // recursively check baseClass to see if it or any of its child classes contain assets
        private bool ClassTreeContainsAssets(string baseClass)
        {
            if (MOG_DBAssetAPI.GetAllAssetsByClassification(baseClass).Count > 0)
            {
                return(true);
            }

            // recurse by looking up child classes
            MOG_Project proj = MOG_ControllerProject.GetProject();

            if (proj != null)
            {
                foreach (string className in proj.GetSubClassificationNames(baseClass))
                {
                    if (ClassTreeContainsAssets(baseClass + "~" + className))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 9
0
 private void UpdateAssetVerifyIcon(MOG_Filename verifyFile)
 {
     if (verifyFile.GetType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
     {
         if (MOG_ControllerSystem.GetDB() != null &&
             MOG_DBAssetAPI.GetAssetVersion(verifyFile) != null &&
             MOG_DBAssetAPI.GetAssetVersion(verifyFile).Length != 0)
         {
             // This is a perfect asset that has a prior version
             this.AssetValidPictureBox.Image = new Bitmap(AssetValidImageList.Images[2]);
         }
         else
         {
             // good asset with no prior version
             this.AssetValidPictureBox.Image = new Bitmap(AssetValidImageList.Images[1]);
         }
     }
     else
     {
         // Bad Asset name
         this.AssetValidPictureBox.Image = new Bitmap(AssetValidImageList.Images[0]);
     }
 }
Esempio n. 10
0
        private ArrayList ExcludeAssets(ArrayList assetList, string classification)
        {
            // Check if we have any properties associated with this tree?
            if (MogPropertyList.Count > 0)
            {
                // Get the list of excluded assets for this node classification
                ArrayList excludedAssetList = MOG_DBAssetAPI.GetAllAssetsByProperty(classification, (MOG_Property)MogPropertyList[0], true);
                foreach (MOG_Filename excludedAsset in excludedAssetList)
                {
                    // Check if this excludedAsset is listed?
                    foreach (MOG_Filename asset in assetList)
                    {
                        if (string.Compare(asset.GetAssetFullName(), excludedAsset.GetAssetFullName(), true) == 0)
                        {
                            // Remove this asset from the list
                            assetList.Remove(asset);
                            break;
                        }
                    }
                }
            }

            return(assetList);
        }
Esempio n. 11
0
        protected virtual void InitializeClassificationsList(bool importableOnly)
        {
            ArrayList requiredClassificationList = new ArrayList();
//			ArrayList excludedClassificationList = null;
            ArrayList requiredAssetList = null;

            // If we have no MOG_Property(s), populate as a full TreeView
            if (MogPropertyList.Count > 0)
            {
                // Get the list of required classifications
                requiredClassificationList = MOG_DBAssetAPI.GetAllActiveClassifications((MOG_Property)MogPropertyList[0]);

//				// Get the list of excluded classifications for this node classification
//				excludedClassificationList = MOG_DBAssetAPI.GetAllActiveClassifications((MOG_Property)MogPropertyList[0], true);

                // Check if we should show asset-level nodes?
                if (ShowAssets || ExpandPackageGroups)
                {
                    // Get the list of required assets
                    requiredAssetList = MOG_DBAssetAPI.GetAllAssetsByProperty((MOG_Property)MogPropertyList[0]);
                }
            }
            else
            {
                ArrayList childClassifications = MOG_DBAssetAPI.GetClassificationChildren(MOG_ControllerProject.GetProjectName());
                if (childClassifications != null)
                {
                    requiredClassificationList.AddRange(childClassifications);
                }
            }

            // Process our list of required classifications
            mRequiredClassifications.Clear();
            if (requiredClassificationList != null &&
                requiredClassificationList.Count > 0)
            {
                foreach (string classificationName in requiredClassificationList)
                {
                    // Do we already have this class?
                    if (!mRequiredClassifications.Contains(classificationName))
                    {
                        bool excluded = false;
                        if (ExclusionList.Length > 0)
                        {
                            excluded = StringUtils.IsFiltered(classificationName, ExclusionList);
                        }

                        // Is it excluded?
                        if (excluded == false)
                        {
                            if (!importableOnly || !MOG_Filename.IsLibraryClassification(classificationName))
                            {
                                //we don't have this classification yet, so add it and give it a container for assets
                                List <string> assetList = new List <string>();
                                mRequiredClassifications.Add(classificationName, assetList);
                            }
                        }
                    }
                }
            }

            // Process our list of excluded classifications
            if (false)
            {
                // We need to perform a query and get all the classifications that contain a specific exclusion
                // Then examine each one and add any that are applicable to excluding the file in question to the mExcludedClassifications list
                // This was not implemented because of timeing and the need to obtain the file in question
            }

            // Process our list of required assets
            if (requiredAssetList != null && requiredAssetList.Count > 0)
            {
                foreach (MOG_Filename requiredAsset in requiredAssetList)
                {
                    if (!importableOnly ||
                        !MOG_Filename.IsLibraryClassification(requiredAsset.GetAssetClassification()))
                    {
                        // Check if this asset is excluded?
                        bool excluded = false;
                        if (ExclusionList.Length > 0)
                        {
                            excluded = StringUtils.IsFiltered(requiredAsset.GetAssetFullName(), ExclusionList);
                        }

                        // Make sure we are not excluded?
                        if (!excluded)
                        {
                            mRequiredAssets[requiredAsset.GetAssetFullName()] = requiredAsset;
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        private ArrayList ExcludeClassifications(ArrayList classificationList, string nodeClassification)
        {
            ArrayList excludedClassificationList = new ArrayList();

            // Check if we have any properties associated with this tree?
            if (MogPropertyList.Count > 0)
            {
                // Get the list of excluded classifications for this node classification
                ArrayList excludedClassifications = MOG_DBAssetAPI.GetClassificationChildren(nodeClassification, "", MogPropertyList, true);
                if (excludedClassifications != null)
                {
                    excludedClassificationList.AddRange(excludedClassifications);
                }

                // Not sure if this really is the best place for this logic but exclusions are hooked to the hip of inclusions...
                // Check if the specified property is the Inclusion property
                MOG_Property testProperty = MogPropertyList[0] as MOG_Property;
                if (testProperty != null)
                {
                    // Check if this is the 'FilterInclusion' property?
                    if (string.Compare("FilterInclusions", testProperty.mPropertyKey, true) == 0)
                    {
                        // Obtain the list of assets this filter is specifically excluded from
                        ArrayList exclusionPropertyList = new ArrayList();
                        exclusionPropertyList.Add(MOG.MOG_PropertyFactory.MOG_Classification_InfoProperties.New_FilterExclusions(testProperty.mPropertyValue));
                        // Get the list of excluded classifications for this node classification
                        ArrayList excludedCLassifications = MOG_DBAssetAPI.GetClassificationChildren(nodeClassification, "", exclusionPropertyList);
                        if (excludedCLassifications != null)
                        {
                            excludedClassificationList.AddRange(excludedCLassifications);
                        }
                    }
                }
            }

            // Check for any explicitly specified exclusions?
            if (ExclusionList.Length > 0)
            {
                foreach (string classification in classificationList)
                {
                    string testClassification = MOG_Filename.JoinClassificationString(nodeClassification, classification);
                    if (StringUtils.IsFiltered(testClassification, ExclusionList))
                    {
                        // Remove this asset from the list
                        excludedClassificationList.Add(classification);
                    }
                }
            }

            // Remove the identified classifications to be excluded
            foreach (string excludedClassification in excludedClassificationList)
            {
                // Check if this excludedclassification is listed in our list?
                foreach (string classification in classificationList)
                {
                    if (string.Compare(classification, excludedClassification, true) == 0)
                    {
                        // Remove this asset from the list
                        classificationList.Remove(classification);
                        break;
                    }
                }
            }

            return(classificationList);
        }
Esempio n. 13
0
        protected override void InitializeClassificationsList(bool importableOnly)
        {
            lock (mRequiredClassifications)
            {
                ArrayList assets;
                ArrayList classifications;
                // If we have no MOG_Property(s), populate as a full TreeView
                if (MogPropertyList.Count > 0)
                {
                    assets          = MOG_DBAssetAPI.GetAllAssetsByClassificationAndProperties("", MogPropertyList, true);
                    classifications = MOG_DBAssetAPI.GetAllActiveClassifications(MogPropertyList[0] as MOG_Property);
                }
                else
                {
                    assets          = MOG_DBAssetAPI.GetAllAssets();
                    classifications = MOG_DBAssetAPI.GetAllActiveClassifications();
                }

                mRequiredClassifications.Clear();

                if (classifications != null && classifications.Count > 0)
                {
                    foreach (string classificationName in classifications)
                    {
                        // Do we already have this class?
                        if (!mRequiredClassifications.Contains(classificationName))
                        {
                            bool excluded = false;
                            if (ExclusionList.Length > 0)
                            {
                                excluded = StringUtils.IsFiltered(classificationName, ExclusionList);
                            }

                            // Is it excluded?
                            if (excluded == false)
                            {
                                if (!importableOnly || !MOG_Filename.IsLibraryClassification(classificationName))
                                {
                                    //we don't have this classification yet, so add it and give it a container for assets
                                    List <string> assetList = new List <string>();
                                    mRequiredClassifications.Add(classificationName, assetList);
                                }
                            }
                        }
                    }
                }

                if (assets != null && assets.Count > 0)
                {
                    foreach (MOG_Filename asset in assets)
                    {
                        if (!importableOnly || !MOG_Filename.IsLibraryClassification(asset.GetAssetClassification()))
                        {
                            int index = mRequiredClassifications.IndexOfKey(asset.GetAssetClassification());
                            if (index == -1)
                            {
                                List <string> assetList = new List <string>();
                                mRequiredClassifications.Add(asset.GetAssetClassification(), assetList);
                                index = mRequiredClassifications.Count - 1;
                            }
                            if (index >= 0)
                            {
                                List <string> assetList = mRequiredClassifications.GetByIndex(index) as List <string>;
                                if (assetList != null)
                                {
                                    bool excluded = false;
                                    if (ExclusionList.Length > 0)
                                    {
                                        excluded = StringUtils.IsFiltered(asset.GetAssetFullName(), ExclusionList);
                                    }

                                    // Is it excluded?
                                    if (excluded == false)
                                    {
                                        assetList.Add(asset.GetAssetFullName());
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 14
0
        private void LocateNonMogAssets_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            string           path   = e.Argument as string;

            // Determin our workspaceDirectory and platformName
            string workspaceDirectory = "";
            string relativePath       = "";
            string platformName       = "";

            // Check if this is a library path?
            if (MOG_ControllerLibrary.GetWorkingDirectory().Length > 0 &&
                path.StartsWith(MOG_ControllerLibrary.GetWorkingDirectory(), StringComparison.CurrentCultureIgnoreCase))
            {
                // Determin proper settings for the library
                workspaceDirectory = MOG_ControllerLibrary.GetWorkingDirectory();
                relativePath       = path.Substring(workspaceDirectory.Length).Trim("\\".ToCharArray());
                platformName       = "All";

                // Get the list of known MOG files within the workspace
                string    classification  = MOG_ControllerLibrary.ConstructLibraryClassificationFromPath(path);
                ArrayList containedAssets = MOG_DBAssetAPI.GetAllAssetsByParentClassification(classification);
                foreach (MOG_Filename thisAsset in containedAssets)
                {
                    string thisPath     = MOG_ControllerLibrary.ConstructPathFromLibraryClassification(thisAsset.GetAssetClassification());
                    string thisFilename = Path.Combine(thisPath, thisAsset.GetAssetLabel());
                    mKnownSyncFiles.Add(thisFilename, thisFilename);
                    mKnownSyncFiles_ArrayList.Add(thisFilename);
                }
            }
            // Check if this is a workspace path?
            else
            {
                workspaceDirectory = MOG_ControllerSyncData.DetectWorkspaceRoot(path);
                if (workspaceDirectory.Length > 0)
                {
                    relativePath = path.Substring(workspaceDirectory.Length).Trim("\\".ToCharArray());
                    MOG_ControllerSyncData sync = MOG_ControllerProject.GetCurrentSyncDataController();
                    if (sync != null)
                    {
                        platformName = sync.GetPlatformName();

                        // Get the list of known MOG files within the workspace
                        ArrayList allFiles = MOG_DBAssetAPI.GetAllProjectSyncTargetFilesForPlatform(platformName);
                        foreach (string thisFile in allFiles)
                        {
                            // Trim thisFile just in case it has an extra '\' at the beginning (Needed for BioWare's formulaic sync target booboo)
                            string tempFile = thisFile.Trim("\\".ToCharArray());
                            // Check if this relative directory matches?
                            if (tempFile.StartsWith(relativePath, StringComparison.CurrentCultureIgnoreCase))
                            {
                                string filename = Path.Combine(workspaceDirectory, tempFile);
                                mKnownSyncFiles[filename] = filename;
                                mKnownSyncFiles_ArrayList.Add(filename);
                            }
                        }
                    }
                }
            }

            // Continue as long as we got at least one asset from the database
            ArrayList rogueFiles = new ArrayList();

            LocateNonMogAssetsScanFiles(worker, path, rogueFiles, mKnownSyncFiles, path, null);
            e.Result = rogueFiles;
        }
Esempio n. 15
0
        static protected void assetTreeViewCreate_AddVersionNodes(TreeView tree, TreeNode parent, int defaultIndex)
        {
            // Add version nodes
            TreeNode versionRoot = new TreeNode(VERSION_TOKEN, defaultIndex, 0);

            versionRoot.Tag = parent.Tag;
            parent.Nodes.Clear();

            // Date format string
            string dateFormat = MOG_Tokens.GetMonth_1() + "/" + MOG_Tokens.GetDay_1() + "/" + MOG_Tokens.GetYear_4()
                                + " " + MOG_Tokens.GetHour_1() + ":" + MOG_Tokens.GetMinute_2() + " " + MOG_Tokens.GetAMPM();

            // Create a tag for ease of use
            guiAssetTreeTag parentTag = (guiAssetTreeTag)parent.Tag;

            // Get the lastest version string
            string versionStr = MOG_DBAssetAPI.GetAssetVersion(new MOG_Filename(parentTag.FullFilename));

            // Populate HDD versions
            DirectoryInfo[] hddVersions = DosUtils.DirectoryGetList(parentTag.FullFilename, "");
            // Arrange it latest date first
            Array.Reverse(hddVersions);

            // Populate DB versions
            ArrayList dbVersions = MOG_DBAssetAPI.GetAllAssetRevisions(new MOG_Filename(parentTag.FullFilename));

            // Turn off sorting for this part of the tree
            tree.Sorted = false;
            foreach (DirectoryInfo version in hddVersions)
            {
                // Create a new versionNode
                MOG_Filename versionFile = new MOG_Filename(version.FullName);
                string       textLabel   = "<" + versionFile.GetVersionTimeStampString(dateFormat) + ">";
                TreeNode     versionNode = new TreeNode(textLabel, defaultIndex, 0);
                // Add guiAssetTreeTag and change color to indicate HDD-only status
                versionNode.Tag = new guiAssetTreeTag(version.FullName,
                                                      guiAssetTreeTag.TREE_FOCUS.VERSION, true);

                // If this is a version matched in the DB, color is black
                if (assetTreeViewCreate_IsAssetVersionInDB(dbVersions, version.Name))
                {
                    versionNode.ForeColor = Color.Black;
                }
                // Else, turn color gray
                else
                {
                    versionNode.ForeColor = Color.DarkGray;
                }

//glk:  This still needs to be tested against the case where there is no directory that matches the verion in versionStr

                // If this is the most recent asset, display it as such
                if (versionStr == versionFile.GetVersionTimeStamp())
                {
                    versionNode.ForeColor = Color.Blue;
                    // Create a currentVersion node, manually cloning versionNode
                    //  glk: object.Clone() does not function properly
                    TreeNode currentVersion = new TreeNode(textLabel,
                                                           versionNode.ImageIndex, versionNode.SelectedImageIndex);
                    currentVersion.ForeColor = Color.Blue;
                    currentVersion.Tag       = new guiAssetTreeTag(version.FullName,
                                                                   guiAssetTreeTag.TREE_FOCUS.VERSION, true);

                    // Keep tree from drawing itself for a bit
                    tree.BeginUpdate();

                    // Document the horizontal and vertical
                    //  positions of tree's scrollbar using extern functions
                    int horizPos = GetHScrollPosition(tree);
                    int vertPos  = GetVScrollPosition(tree);

                    // Expand the tree: This is the operation which causes
                    //  really erratic behavior from TreeView Control
                    currentVersion.Expand();

                    // Add ghost node for further expansion
                    currentVersion.Nodes.Add(new TreeNode(""));
                    parent.Nodes.Add(currentVersion);

                    // Set the scrollbar horizontal and vertical positions
                    //  back to what they were.
                    SetHScrollPosition(tree, horizPos);
                    SetVScrollPosition(tree, vertPos);

                    // Allow tree to draw itself
                    tree.EndUpdate();
                }
                // Add new placeholder for further expansion
                versionNode.Nodes.Add(new TreeNode(""));
                versionRoot.Nodes.Add(versionNode);
            }
            parent.Nodes.Add(versionRoot);
            // Turn sorting back on
            tree.Sorted = true;
        }
Esempio n. 16
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();
            }
        }
Esempio n. 17
0
        private void InitializeClassificationList_Worker(object sender, DoWorkEventArgs e)
        {
            lock (mRequiredClassifications)
            {
                ArrayList classifications;

                ExclusionList   = MOG_Filename.GetProjectLibraryClassificationString();
                classifications = MOG_DBReports.ClassificationForProperty("", MOG_PropertyFactory.MOG_Sync_OptionsProperties.New_SyncFiles(true), false);

                mRequiredClassifications.Clear();

                if (classifications != null && classifications.Count > 0)
                {
                    foreach (string classificationName in classifications)
                    {
                        // Do we already have this class?
                        if (!mRequiredClassifications.Contains(classificationName))
                        {
                            bool excluded = false;
                            if (ExclusionList.Length > 0)
                            {
                                excluded = StringUtils.IsFiltered(classificationName, ExclusionList);
                            }

                            // Is it excluded?
                            if (excluded == false)
                            {
                                //we don't have this classification yet, so add it and give it a container for assets
                                List <string> assetList = new List <string>();
                                mRequiredClassifications.Add(classificationName, assetList);
                            }
                        }
                    }
                }

                if (ShowAssets)
                {
                    // Enable this if we wnat to show assets in this tree
                    ArrayList assets = MOG_DBAssetAPI.GetAllAssets(true, MOG_ControllerProject.GetBranchName());

                    // Enable this if we wnat to show assets in this tree
                    if (assets != null && assets.Count > 0)
                    {
                        foreach (MOG_Filename asset in assets)
                        {
                            int index = mRequiredClassifications.IndexOfKey(asset.GetAssetClassification());
                            if (index >= 0)
                            {
                                List <string> assetList = mRequiredClassifications.GetByIndex(index) as List <string>;
                                if (assetList != null)
                                {
                                    bool excluded = false;
                                    if (ExclusionList.Length > 0)
                                    {
                                        excluded = StringUtils.IsFiltered(asset.GetAssetFullName(), ExclusionList);
                                    }

                                    // Is it excluded?
                                    if (excluded == false)
                                    {
                                        assetList.Add(asset.GetAssetFullName());
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
		/// <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;
		}