private void FillInAssets(TreeNode node)
        {
            // Store assets under this classifcation
            ArrayList assets = MOG_ControllerAsset.GetAssetsByClassification(node.FullPath);

            assets.Sort();

            bool assetsValid = (assets != null && assets.Count > 0);

            // If we actually have assets to list, and our archivedAssets do not differ from our branch-related assets...
            if (assetsValid)
            {
                // Foreach asset in this classification...
                foreach (MOG_Filename asset in assets)
                {
                    TreeNode assetNode = CreateAssetNode(asset, node.ForeColor);
                    node.Nodes.Add(assetNode);
                }
            }

            // Also, get our archived assets, if we are in archive view
            ArrayList archivedAssets = MOG_ControllerAsset.GetArchivedAssetsByClassification(node.FullPath);

            archivedAssets.Sort();

            // If we have valid archivedAssets, AND
            //  (we EITHER have more archivedAssets than assets
            //  OR we have no valid assets)
            if (archivedAssets != null && archivedAssets.Count > 0 &&
                ((assetsValid && assets.Count < archivedAssets.Count) || !assetsValid))
            {
                //TODO:  Possibly add a "Removed Assets" node here...
                // If we do have branch-related assets, check for them by name...
                List <string> branchAssetsList = new List <string>();
                if (assets != null && assets.Count > 0)
                {
                    // Create a list of our Current assets
                    foreach (MOG_Filename asset in assets)
                    {
                        branchAssetsList.Add(asset.GetAssetFullName().ToLower());
                    }
                }

                // Fill in any Assets that are not current
                foreach (MOG_Filename archiveAsset in archivedAssets)
                {
                    TreeNode assetNode = null;
                    // If there is nothing in our branchAssetsList OR
                    //  branchAssetsList does not contain the current asset we're looking at...
                    if (branchAssetsList.Count == 0 || !branchAssetsList.Contains(archiveAsset.GetAssetFullName().ToLower()))
                    {
                        assetNode = CreateAssetNode(archiveAsset, Archive_Color);
                        node.Nodes.Add(assetNode);

                        //Add this bad boy to the list so we don't add it more than once
                        branchAssetsList.Add(archiveAsset.GetAssetFullName().ToLower());
                    }
                }
            }
        }
示例#2
0
        public void Populate(string classification)
        {
            CurrentClassification            = classification;
            mCurrentClassificationProperties = new MOG_Properties(CurrentClassification);

            // For speed purposes, create 3 HybridDictionary lists
            // Populate the files that exist on the local hardrive
            string drivePath = Path.Combine(MOG_ControllerLibrary.GetWorkingDirectory(), MOG_Filename.GetClassificationPath(classification));

            string[] files = new string[] { };
            if (DosUtils.DirectoryExistFast(drivePath))
            {
                files = Directory.GetFiles(drivePath);
            }
            HybridDictionary filesOnDisk = new HybridDictionary();

            foreach (string file in files)
            {
                filesOnDisk[Path.GetFileName(file)] = file;
            }
            // Populate the assets that exist in MOG
            ArrayList        assets      = MOG_ControllerAsset.GetAssetsByClassification(classification);
            HybridDictionary assetsInMOG = new HybridDictionary();

            foreach (MOG_Filename asset in assets)
            {
                assetsInMOG[asset.GetAssetLabel()] = asset;
            }
            // Create a master list
            HybridDictionary masterList = new HybridDictionary();

            foreach (string file in filesOnDisk.Values)
            {
                masterList[Path.GetFileName(file)] = Path.GetFileName(file);
            }
            foreach (MOG_Filename asset in assetsInMOG.Values)
            {
                masterList[asset.GetAssetLabel()] = asset.GetAssetLabel();
            }


            // Rebuild our LibraryListView
            LibraryListView.BeginUpdate();
            mLibrarySortManager.SortEnabled = false;

            LibraryListView.Items.Clear();

            foreach (string file in masterList.Keys)
            {
                // Check if this file is in MOG?
                if (assetsInMOG.Contains(file))
                {
                    MOG_Filename asset = assetsInMOG[file] as MOG_Filename;

                    // Create the ListView item  for this asset
                    ListViewItem item = CreateListViewItemForAsset(asset);
                    LibraryListView.Items.Add(item);
                }
                else
                {
                    string fullFilename = filesOnDisk[file] as string;
                    bool   bIsValid     = true;

                    // Check the classification's inclusion filter.
                    if (mCurrentClassificationProperties.FilterInclusions.Length > 0)
                    {
                        MOG.FilePattern inclusions = new MOG.FilePattern(mCurrentClassificationProperties.FilterInclusions);
                        if (inclusions.IsFilePatternMatch(Path.GetFileName(fullFilename)) == false)
                        {
                            bIsValid = false;
                        }
                    }
                    // Check the classification's exclusion filter.
                    if (mCurrentClassificationProperties.FilterExclusions.Length > 0)
                    {
                        MOG.FilePattern exclusions = new MOG.FilePattern(mCurrentClassificationProperties.FilterExclusions);
                        if (exclusions.IsFilePatternMatch(Path.GetFileName(fullFilename)) == true)
                        {
                            bIsValid = false;
                        }
                    }

                    // Check if we determined this to be a valid file to show?
                    if (bIsValid)
                    {
                        ListViewItem item = CreateListViewItemForFile(fullFilename);
                        UpdateListViewItemColors(item, "Unknown");
                        LibraryListView.Items.Add(item);
                    }
                }
            }

            mLibrarySortManager.SortEnabled = true;
            LibraryListView.EndUpdate();

            // Check if we have a mLastTopItem specified?
            if (mLastTopItem.Length > 0)
            {
                LibraryListView.TopItem = LibraryListView.FindItemWithText(mLastTopItem);
                mLastTopItem            = "";
            }
        }