Ejemplo n.º 1
0
        private ListViewItem CreateListViewItemForFile(string localFile)
        {
            ListViewItem item = null;

            // Only put the asset in the list if it is actually a library asset
            if (MOG_ControllerLibrary.IsPathWithinLibrary(localFile))
            {
                item = new ListViewItem(Path.GetFileName(localFile));

                string classification = MOG_ControllerLibrary.ConstructLibraryClassificationFromPath(localFile);
                string localTimestamp = GetLocalFileTimestamp(localFile);
                string fullname       = localFile;
                string status         = "Unknown";
                string extension      = DosUtils.PathGetExtension(localFile);

                // Populate the item
                item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(localFile);
                item.SubItems.Add(extension);               // Extension
                item.SubItems.Add(classification);          // Classification
                item.SubItems.Add("");                      // User
                item.SubItems.Add("");                      // Comment
                item.SubItems.Add(localTimestamp);          // Local TimeStamp
                item.SubItems.Add("");                      // Server Timestamp
                item.SubItems.Add(status);                  // Status
                item.SubItems.Add(fullname);                // Fullname
                item.SubItems.Add(localFile);               // LocalFile
                item.SubItems.Add("");                      // RepositoryFile

                UpdateListViewItemColors(item, status);
            }

            return(item);
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 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);
        }
        public static bool PromptUserForConfirmation(string[] filenames, string classification)
        {
            bool bProceed = true;

            // Make sure we have valid information?
            if (filenames == null || filenames.Length == 0)
            {
                MOG_Prompt.PromptMessage("Add Files", "Unable to add files because no files were specified.");
                bProceed = false;
            }
            else if (string.IsNullOrEmpty(classification))
            {
                MOG_Prompt.PromptMessage("Add Files", "Unable to add files because no classification was specified.");
                bProceed = false;
            }
            else
            {
                // Check if this file is already located within the library
                if (MOG_ControllerLibrary.IsPathWithinLibrary(Path.GetDirectoryName(filenames[0])))
                {
                    // Assume all the files have the same path and construct a classification from the path of the first file
                    string libraryClassification = MOG_ControllerLibrary.ConstructLibraryClassificationFromPath(Path.GetDirectoryName(filenames[0]));
                    if (libraryClassification != classification)
                    {
                        // Prompt the user about what they want
                        string message = "This file is located elsewhere within the 'Library Working Folder'.\n\n" +
                                         "Are you sure you want to add this file to this new location as well?";
                        if (filenames.Length > 2)
                        {
                            message = "These files are located elsewhere within the 'Library Working Folder'.\n\n" +
                                      "Are you sure you want to add these files to this new location as well?";
                        }
                        if (MOG_Prompt.PromptResponse("Add Files", message, MOGPromptButtons.YesNo) == MOGPromptResult.No)
                        {
                            // Early out because they clicked cancel
                            bProceed = false;
                        }
                    }
                }
                else
                {
                    // Ask user for confirmation that they really want
                    string msg = "";
                    if (filenames.Length < 20)
                    {
                        msg += "Are you sure you want to import the following?\n\n";

                        // Build a file/dir list for the confirmation message
                        foreach (string filename in filenames)
                        {
                            msg += Path.GetFileName(filename) + "\n";
                        }
                    }
                    else
                    {
                        // There are too many files to display in a MessageBox, so just ask for generic confirmation
                        msg = "Are you sure you want to import these " + filenames.Length.ToString() + " items?";
                    }

                    if (MOG_Prompt.PromptResponse("Confirm File Importation", msg, MOGPromptButtons.YesNo) == MOGPromptResult.No)
                    {
                        bProceed = false;
                    }
                }
            }

            return(bProceed);
        }