Exemple #1
0
        public bool ToolNewerCheck(MOG_Filename mogAsset, string version, MOG_Project pProject, ref string failedString)
        {
            MOG_Time assetTime        = new MOG_Time(version);
            MOG_Time correctAssetTime = new MOG_Time();

            DirectoryInfo [] dirs = DosUtils.DirectoryGetList(MOG_ControllerRepository.GetAssetBlessedPath(mogAsset).GetEncodedFilename(), "*.*");

            if (dirs != null)
            {
                foreach (DirectoryInfo dir in dirs)
                {
                    string   checkVersion = dir.Name.Substring(dir.Name.LastIndexOf(".") + 1);
                    MOG_Time dirTime      = new MOG_Time(checkVersion);

                    // Is this asset equal or newer than this dir version?
                    if (assetTime.Compare(dirTime) < 0)
                    {
                        failedString = "Out of date," + failedString;
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemple #2
0
        private bool SyncDirectories(string fullFilename, string filePattern, string targetString)
        {
            // Copy Files

            // Make sure our target directory exists.
CheckDirectory:
            if (!DosUtils.DirectoryExist(fullFilename))
            {
                //Error
                switch (MOG_REPORT.ShowMessageBox("Platform Sync", "Attempted to sync (" + fullFilename + ") but could not find it! \n What should we do?", MessageBoxButtons.AbortRetryIgnore))
                {
                case DialogResult.Ignore:
                    break;

                case DialogResult.Retry:
                    goto CheckDirectory;

                case DialogResult.Abort:
                    return(false);
                }
            }

            // Walk all the directories
            DirectoryInfo[] dirs = DosUtils.DirectoryGetList(fullFilename, "*.*");
            if (dirs != null && dirs.Length > 0)
            {
                foreach (DirectoryInfo dir in dirs)
                {
                    string targetDirectory = dir.FullName.ToLower().Replace(mSourcePath, mSyncRoot);

                    // Copy the files in this directory
                    if (!SyncDirectories(dir.FullName, filePattern, targetDirectory))
                    {
                        return(false);
                    }
                }

                // Now do the files in this directory
                return(SyncFiles(fullFilename, filePattern));
            }
            else
            {
                return(SyncFiles(fullFilename, filePattern));
            }
        }
Exemple #3
0
        /// <summary>
        /// Scans the local branches data to locate all binaries that do not have a counterpart in the project database
        /// </summary>
        private bool LocateNonMogAssetsScanFiles(BackgroundWorker worker, string path, ArrayList rogueFiles, HybridDictionary MergeableAssets, string targetProjectPath, MOG_Properties classificationProperties)
        {
            // Check if this is a library path?
            if (MOG_ControllerLibrary.GetWorkingDirectory().Length > 0 &&
                path.StartsWith(MOG_ControllerLibrary.GetWorkingDirectory(), StringComparison.CurrentCultureIgnoreCase))
            {
                // Build us our library classification for this library path
                string classification = MOG_ControllerLibrary.ConstructLibraryClassificationFromPath(path);
                // Check if this library classification exists?
                if (MOG_ControllerProject.IsValidClassification(classification))
                {
                    // Obtain the properties for this library classification
                    classificationProperties = new MOG_Properties(classification);
                }
            }

            // Get all the files withing this directory
            FileInfo [] files = DosUtils.FileGetList(path, "*.*");
            if (files != null)
            {
                // For each file, check to see if we have a DB link for that filename
                foreach (FileInfo file in files)
                {
                    if (worker.CancellationPending)
                    {
                        return(false);
                    }

                    try
                    {
                        // Check to see if we have a DB link for that filename
                        if (MergeableAssets.Contains(file.FullName) == false)
                        {
                            // Check if we have a classificationProperties?
                            if (classificationProperties != null)
                            {
                                // Make sure this does not violate the classification filters
                                // Check the classification's inclusion filter.
                                if (classificationProperties.FilterInclusions.Length > 0)
                                {
                                    FilePattern inclusions = new FilePattern(classificationProperties.FilterInclusions);
                                    if (inclusions.IsFilePatternMatch(file.FullName) == false)
                                    {
                                        // Skip this file as it is not included
                                        continue;
                                    }
                                }
                                // Check the classification's exclusion filter.
                                if (classificationProperties.FilterExclusions.Length > 0)
                                {
                                    FilePattern exclusions = new FilePattern(classificationProperties.FilterExclusions);
                                    if (exclusions.IsFilePatternMatch(file.FullName) == true)
                                    {
                                        // Skip this file as it is excluded
                                        continue;
                                    }
                                }
                            }

                            // Make sure it is not hidden
                            if (Convert.ToBoolean(file.Attributes & FileAttributes.Hidden) == false)
                            {
                                // If no match was found, add to our list of rogue assets
                                rogueFiles.Add(file.FullName);
                            }
                        }
                    }
                    catch
                    {
                        // Needed just in case we have some files larger than 260 in length
                    }
                }
            }

            // Now check all these subDirs
            DirectoryInfo [] dirs = DosUtils.DirectoryGetList(path, "*.*");
            if (dirs != null)
            {
                foreach (DirectoryInfo dir in dirs)
                {
                    // Make sure it is not hidden
                    if (Convert.ToBoolean(dir.Attributes & FileAttributes.Hidden) == false)
                    {
                        // Scan their respective files
                        if (!LocateNonMogAssetsScanFiles(worker, dir.FullName, rogueFiles, MergeableAssets, targetProjectPath, classificationProperties))
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Exemple #4
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;
        }
Exemple #5
0
        static protected void assetTreeViewCreate_AddFilesNodes(TreeNode parent, int defaultIndex)
        {
            // Create files node
            TreeNode        filesRoot = new TreeNode("Files", defaultIndex, 0);
            guiAssetTreeTag parentTag = (guiAssetTreeTag)parent.Tag;

            filesRoot.Tag = parentTag;
            ((guiAssetTreeTag)filesRoot.Tag).Level = guiAssetTreeTag.TREE_FOCUS.SUBVERSION;

            // Populate files
            TreeNode sourceRoot = new TreeNode("Imported Files", defaultIndex, 0);

            sourceRoot.Tag = filesRoot.Tag;
            TreeNode gameDataRoot = new TreeNode("Processed Files", defaultIndex, 0);

            gameDataRoot.Tag = filesRoot.Tag;

            DirectoryInfo[] directories = DosUtils.DirectoryGetList(parentTag.FullFilename, "");

            // Go through each platform only for the asset of this parent node
            foreach (DirectoryInfo directory in directories)
            {
                // If this is a gamedata, add it with its subnode and file(s)
                if (directory.Name.ToLower().IndexOf("gamedata") > -1)
                {
                    // Get rid of gamedata from directory.Name
                    string gamedataName = directory.Name.ToLower().Replace("files.", "");
                    // Create a new node for each platform
                    TreeNode platformNode = new TreeNode(gamedataName, defaultIndex, 0);
                    platformNode.Tag = filesRoot.Tag;

                    FileInfo[] files = DosUtils.FileGetList(directory.FullName, "");
                    // Add files in gamedata directory to platformNode
                    if (files != null)
                    {
                        // Add each file to each gamedata<platform> node
                        foreach (FileInfo file in files)
                        {
                            TreeNode fileNode = assetTreeViewCreate_GetTreeNodeWithIcon(file.Name, defaultIndex);
                            fileNode.Tag = filesRoot.Tag;
                            platformNode.Nodes.Add(fileNode);
                        }
                    }

                    gameDataRoot.Nodes.Add(platformNode);
                }
                // Else if this is a files folder, add it to the source node
                else if (directory.Name.ToLower().IndexOf("files") > -1)
                {
                    FileInfo[] files = DosUtils.FileGetList(directory.FullName, "");
                    if (files != null)
                    {
                        foreach (FileInfo file in files)
                        {
                            TreeNode fileNode = assetTreeViewCreate_GetTreeNodeWithIcon(file.Name, defaultIndex);
                            fileNode.Tag = filesRoot.Tag;
                            sourceRoot.Nodes.Add(fileNode);
                        }
                    }
                }
            }

            filesRoot.Nodes.Clear();
            filesRoot.Nodes.AddRange(new TreeNode[] { sourceRoot, gameDataRoot });
            parent.Nodes.Add(filesRoot);
        }
Exemple #6
0
        /// <summary>
        /// Shows Assets based on MOG_Property(s) assigned to PropertyList
        /// </summary>
        private void ExpandPropertyTreeDown(TreeNode node)
        {
            BeginUpdate();

            List <string> classificationsToAdd = GetSubClassifications(node);

            string thisClassification     = node.FullPath;
            string thisClassificationPath = MOG_ControllerLibrary.ConstructPathFromLibraryClassification(thisClassification);

            // Check for any local directories
            if (thisClassificationPath.Length > 0)
            {
                DirectoryInfo[] directories = DosUtils.DirectoryGetList(thisClassificationPath, "*.*");
                if (directories != null && directories.Length > 0)
                {
                    foreach (DirectoryInfo directory in directories)
                    {
                        // If we don't already have this classification, add it.
                        if (!classificationsToAdd.Contains(directory.Name))
                        {
                            classificationsToAdd.Add(directory.Name);
                        }
                    }
                }
            }

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

            // Foreach classification, add it
            foreach (string classification in classificationsToAdd)
            {
                string fullClassification = MOG_Filename.JoinClassificationString(node.FullPath, classification);

                // Only add library classifications
                if (MOG_Filename.IsParentClassificationString(fullClassification, MOG_Filename.GetProjectLibraryClassificationString()))
                {
                    TreeNode classificationNode = new TreeNode(classification);

                    // Is this a non-MOG folder?
                    if (!MOG_ControllerProject.IsValidClassification(fullClassification))
                    {
                        classificationNode.ForeColor = Color.LightGray;
                    }

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

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

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

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

            EndUpdate();
        }