private static IEnumerable<EnhancedFileInfo> FindFiles(TheImport theImport,
             string rootFolder)
        {
            var filenames = new List<string>();

            var foundFiles
                = new List<EnhancedFileInfo>();

            RecurseFolders
                (theImport, rootFolder, filenames);

            FileInfo nextFile = null;

            foreach (string filename in filenames.Distinct())
            {

                try
                {
                    nextFile = theImport.NextFileInfo(filename);
                }
                catch (Exception ex)
                {
                    theImport.Importer.LogMessages.Enqueue(new LogMessage("Warn", "Unable to create FileInfo object for: " + filename, ex));
                }

                if (nextFile != null)
                {
                    foundFiles.Add(new EnhancedFileInfo(nextFile));
                }

            }

            return foundFiles;
        }
 public DefaultRootFolderHandler(
     TheImport import,
     EnhancedDriveInfo drive_sInfo,
     string rootFolder,
     List<EnhancedFileInfo> foundFiles,
     ImageCache cachedImages)
     : base(import, drive_sInfo, rootFolder, foundFiles, cachedImages)
 {
 }
 public ChainByTagsRootFolderHandler(
     TheImport import,
     EnhancedDriveInfo driveSInfo,
     string rootFolder,
     List<EnhancedFileInfo> foundFiles,
     ImageCache cachedImages)
     : base(import, driveSInfo, rootFolder, foundFiles, cachedImages)
 {
     this.item2File = new Item2File();
 }
 protected RootFolderHandlerBase(
     TheImport import,
     EnhancedDriveInfo infoOfDrive,
     string rootFolder,
     List<EnhancedFileInfo> foundFiles,
     ImageCache cachedImages)
 {
     _import = import;
     _infoOfDrive = infoOfDrive;
     _files = foundFiles;
     RootFolder = rootFolder;
     _images = cachedImages;
 }
 internal static RootFolderHandlerBase ProvideRootFolderHandlerInstance(
     TheImport import,
     EnhancedDriveInfo infoOfDrive,
     string rootFolder,
     List<EnhancedFileInfo> foundFiles,
     ImageCache cachedImages)
 {
     if (import.Importer.ChainingOption == ChainOption.ChainByTags)
     {
         return new ChainByTagsRootFolderHandler(import, infoOfDrive, rootFolder, foundFiles, cachedImages);
     }
     else if (import.Importer.ChainingOption == ChainOption.ChainByFolder)
     {
         return new ChainByFolderRootFolderHandler(import, infoOfDrive, rootFolder, foundFiles, cachedImages);
     }
     else
     {
         return new DefaultRootFolderHandler(import, infoOfDrive, rootFolder, foundFiles, cachedImages);
     }
 }
        internal static void AnalyzeRootFoldersByDrives(TheImport theImport)
        {
            string mappedRootFolder;

            foreach (string rootFolder in theImport.Importer.RootFolders)
            {

                mappedRootFolder = theImport.RootFolderOrUnc2RootFolder[rootFolder];

                if (mappedRootFolder == " :")
                    continue;

                theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "MappedRootFolder: " + mappedRootFolder));
                string partition = Directory.GetDirectoryRoot(mappedRootFolder);
                try
                {

                    if (!theImport.DriveLetters.Keys.Contains(partition))
                    {
                        theImport.DriveLetters.Add(partition, null);
                    }

                    theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Partition: " + partition));
                    theImport.DriveLetters[partition] = new EnhancedDriveInfo(theImport.Importer, new DriveInfo(partition));
                }
                catch (ArgumentException ex)
                {
                    theImport.Importer.LogMessages.Enqueue(new LogMessage("Error", ex.ToString()));
                    theImport.Importer.LogMessages.FlushAllMessages();
                }
                catch (Exception ex)
                {
                    theImport.Importer.LogMessages.Enqueue(new LogMessage("Error", ex.ToString()));
                    theImport.Importer.LogMessages.FlushAllMessages();
                }

            }

            foreach (KeyValuePair<string, EnhancedDriveInfo> driveLetter in theImport.DriveLetters)
            {
                KeyValuePair<string, EnhancedDriveInfo> letter = driveLetter;
                var results =
                    theImport.RootFoldersOfDrive.Keys.Where(diex => diex.SerialNumber == letter.Value.SerialNumber);
                EnhancedDriveInfo result = null;
                foreach (EnhancedDriveInfo diex in results)
                {
                    result = diex;
                }

                if (result == null)
                {
                    theImport.RootFoldersOfDrive.Add(result = driveLetter.Value, new List<string>());
                }

                foreach (string rootFolder in theImport.Importer.RootFolders)
                {
                    mappedRootFolder = theImport.RootFolderOrUnc2RootFolder[rootFolder];
                    if (mappedRootFolder == " :")
                        continue;

                    if (driveLetter.Key == Directory.GetDirectoryRoot(mappedRootFolder))
                    {
                        theImport.RootFoldersOfDrive[result].Add(rootFolder);
                    }

                }

            }
        }
        internal static void LogProperties(TheImport theImport)
        {
            theImport.Importer.LogMessages.Enqueue
                (new LogMessage("Debug",
                    "Import Settings:"
                    + Environment.NewLine));

            theImport.Importer.LogMessages.Enqueue
                (new LogMessage("Debug",
                    "Root folders: "));

            if (theImport.Importer.RootFolders != null)
            {
                foreach (string rootFolder in theImport.Importer.RootFolders)
                {
                    theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", rootFolder));
                }
            }
            else
            {
                theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "null"));
            }

            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Tag masks: "));
            if (theImport.Importer.TagMasksStrings != null)
            {
                foreach (TagMask tagMask in theImport.Importer.TagMasks)
                {
                    theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", tagMask.Mask));
                    theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "RegEx: " + tagMask.RegExp));
                }
            }

            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Chain files: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.ChainFiles.ToString(CultureInfo.InvariantCulture)));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Chaining options: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.ChainingOption.ToString()));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Chaining tags: "));
            string message = (theImport.Importer.TagsToChainBy != null)
                                 ? theImport.Importer.TagsToChainBy.ToString()
                                 : String.Empty;
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", message));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Delete nonexistent files: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.DeleteNonExistentFiles.ToString(CultureInfo.InvariantCulture)));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Update all items: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.AlwaysUpdate.ToString(CultureInfo.InvariantCulture)));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Include file masks: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.IncludeFileMasks ?? "null"));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Exclude file masks: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.ExcludeFileMasks ?? "null"));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Include hidden files: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.IncludeHiddenFiles.ToString(CultureInfo.InvariantCulture)));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Min file size: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.MinFileSize.ToString(CultureInfo.InvariantCulture)));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Always update images: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.AlwaysUpdateImages.ToString(CultureInfo.InvariantCulture)));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            /*
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Image root folder: "));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", this.Importer.ImageFolder ?? "null"));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", string.Empty));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Search the files folder: "));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", this.Importer.FileFolderImage));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", string.Empty));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", "File folder image file masks: "));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", this.Importer.FileFolderImageFileMasks));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", string.Empty));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Image folder image file masks: "));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", this.Importer.ImageFolderImageFileMasks));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", string.Empty));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Image tag name: "));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", this.Importer.ImageTagName));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", string.Empty));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Image count: "));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", this.Importer.ImageCount.ToString()));
            this.Importer.LogMessages.Enqueue(new LogMessage("Debug", string.Empty));
            */
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Import creation date: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.CreationDate.ToString(CultureInfo.InvariantCulture)));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Creation date tag name: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.CreationDateTagName));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Import last access date: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.LastAccessDate.ToString(CultureInfo.InvariantCulture)));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Last access date tag name: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.LastAccessDateTagName));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Import last modification date: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.LastModificationDate.ToString(CultureInfo.InvariantCulture)));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Last modification date tag name: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.LastModificationDateTagName));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Import file size: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.FileSize.ToString(CultureInfo.InvariantCulture)));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "File size tag name: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.FileSizeTagName));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Import serial number: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.SerialNumber.ToString(CultureInfo.InvariantCulture)));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Serial number tag name: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.SerialNumberTagName));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Import volume name: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.VolumeName.ToString(CultureInfo.InvariantCulture)));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", "Volume name tag name: "));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", theImport.Importer.VolumeNameTagName));
            theImport.Importer.LogMessages.Enqueue(new LogMessage("Debug", String.Empty));
        }
        /// <exception cref="Exception"><c>Exception</c>.</exception>
        internal static void ScanDrive(TheImport theImport,
             KeyValuePair<EnhancedDriveInfo, 
                 List<string>> driveRootFolders, 
             ref FilesQueue filesQueue)
        {
            var allFoundFiles = new List<EnhancedFileInfo>();

            var foundFiles = new List<EnhancedFileInfo>();

            try
            {

                ImageCache cachedImages = new ImageCache();

                foreach (string rootFolder in driveRootFolders.Value)
                {

                    if (Directory.Exists(rootFolder))
                    {

                        foundFiles.Clear();

                        foundFiles.AddRange(FindFiles(theImport, rootFolder));

                        RootFolderHandlerBase rootFolderHandler =
                            RootFolderHandlerProvider.ProvideRootFolderHandlerInstance(
                                theImport, driveRootFolders.Key, rootFolder, foundFiles, cachedImages);

                        RootFolderHandlerExecuter.Execute(rootFolderHandler);

                        allFoundFiles.AddRange(foundFiles);

                    }
                    else
                    {
                        theImport.Importer.LogMessages.Enqueue(
                            new LogMessage("Warn", "RootFolder doesn't exist: " + rootFolder));
                    }

                }

                EnhancedFileInfo[] foundFilesArray
                    = allFoundFiles.ToArray();

                filesQueue
                    .Enqueue
                    (foundFilesArray);

            }
            catch (Exception ex)
            {
                theImport.Importer.LogMessages.Enqueue(new LogMessage("Error", ex.ToString()));
                throw;
            }
            finally
            {
                allFoundFiles.Clear();
                foundFiles.Clear();
            }

            theImport.Importer.LogMessages.Enqueue
                (new LogMessage("Debug",
                                "Return from ScanDrive"));
        }
        private static void RecurseFolders(TheImport theImport, string folder, 
            List<string> foundFiles)
        {
            try
            {
                foreach (string includeFileMask in theImport.Importer.IncludeFileMasks.Split(';'))
                {
                    foundFiles.AddRange(Directory.GetFiles(folder, includeFileMask, SearchOption.TopDirectoryOnly));
                }
            }
            catch (Exception ex)
            {
                string logMessage = "Unable to get files in " + folder + Environment.NewLine + ex;
                theImport.Importer.LogMessages.Enqueue(new LogMessage("Error", logMessage));
            }

            try
            {
                foreach (string dir in Directory.GetDirectories(folder, "*", SearchOption.TopDirectoryOnly))
                {
                    RecurseFolders(theImport, dir, foundFiles);
                }
            }
            catch (Exception ex)
            {
                string logMessage = "Unable to get subfolders of " + folder + Environment.NewLine + ex;
                theImport.Importer.LogMessages.Enqueue(new LogMessage("Error", logMessage));
            }
        }
        internal static bool Run(TheImport theImport)
        {
            try
            {
                theImport.StartTime = DateTime.Now;

                CoreEngineHelpers.SetupLogging(theImport.Importer);

                ExistingItemScanner.ScanExistingItems(theImport);

                theImport.Importer
                    .LogMessages.Enqueue
                    (new LogMessage("Info",
                        "Importer version: 1.0.15.338"));

                PluginPropertiesLogger
                    .LogProperties(theImport);

                if (theImport.Importer
                    .DeleteNonExistentFiles)
                {

                    theImport.Importer
                        .LogMessages.Enqueue
                        (new LogMessage("Info",
                            "Delete non existent files"));

                    theImport.Importer
                        .Section.BeginUpdate();

                    NonExistentItemRemover
                        .DeleteNonExistentItems(theImport);

                    theImport.Importer
                        .Section.EndUpdate();

                    theImport.Importer
                        .LogMessages.Enqueue
                        (new LogMessage("Info",
                            "Deleted non existent files."));

                }

                if (theImport.Importer.RootFolders != null)
                {

                    theImport
                        .RootFolders2MappedDrives();

                    theImport.Importer
                        .LogMessages.Enqueue
                        (new LogMessage("Info",
                            "Analyzing rootfolders by drives."));

                    RootFoldersAnalyzer.AnalyzeRootFoldersByDrives(theImport);

                }
                else
                {

                    theImport.Importer
                        .LogMessages.Enqueue(
                        new LogMessage("Warn",
                            "You haven't specified " +
                            "a rootfolder for the file search!"));

                    theImport.Importer
                        .LogMessages.Enqueue
                        (new LogMessage("Warn",
                            TheImport.RootfolderRequestMessage));

                    theImport.Importer
                        .ImportProgress.Progress
                        (100, TheImport
                        .RootfolderRequestMessage
                        .Translate());

                    return true;

                }

                if (!theImport.CheckProgress(10, "Scanning Rootfolders"))
                {
                    return true;
                }

                theImport.AsyncCalls = new List<AsyncResult>();
            ////                this.filesLock = new object();
                theImport.Importer.Section.BeginUpdate();

                using (theImport.Files
                    = new FilesQueue(theImport))
                {

                    foreach (KeyValuePair<EnhancedDriveInfo,
                        List<string>> driveRootFolder
                        in theImport.RootFoldersOfDrive)
                    {

                        string logMessage
                            = "Drive: "
                            + driveRootFolder.Key.SerialNumber
                            + " - " + driveRootFolder.Value.Select
                            (Path.GetPathRoot).Aggregate
                            ((chain, link)
                                => chain + ", " + link);

                        theImport.Importer
                            .LogMessages.Enqueue
                            (new LogMessage
                                ("Info", logMessage));

                        theImport.Importer
                            .LogMessages.Enqueue
                            (new LogMessage
                                ("Info",
                                "Rootfolders on that drive: "));

                        foreach (string rootFolder in driveRootFolder.Value)
                        {
                            theImport.Importer
                                .LogMessages
                                .Enqueue(new LogMessage
                                    ("Info", "  " + rootFolder));
                        }

                        TheImport.ScanDriveDelegate
                            delegateScanDrive
                            =
                            (KeyValuePair<EnhancedDriveInfo,
                                List<string>> driveRootFolders,
                                ref FilesQueue filesQueue)
                            =>
                            DirectoryScanner.ScanDrive
                            (theImport, driveRootFolders,
                            ref filesQueue);

                        theImport.AsyncCalls.Add(
                            (AsyncResult)
                            delegateScanDrive
                            .BeginInvoke
                            (driveRootFolder,
                            ref theImport.Files,
                            theImport.Callback, null));

                    }

                    var waitHandles = new WaitHandle[theImport.RootFoldersOfDrive.Count];
                    AsyncResult[] asyncCallsArray = theImport.AsyncCalls.ToArray();
                    for (int asyncCallPos = 0; asyncCallPos < asyncCallsArray.Length; asyncCallPos++)
                    {
                        waitHandles[asyncCallPos] = asyncCallsArray[asyncCallPos].AsyncWaitHandle;
                    }

                    for (int waitHandlePos = 0; waitHandlePos < waitHandles.Length; waitHandlePos++)
                    {
                        waitHandles[waitHandlePos].WaitOne();
                        waitHandles[waitHandlePos].Close();
                        waitHandles[waitHandlePos] = null;
                    }

                    theImport.AsyncCalls.Clear();
                    if (theImport.Importer.ChainingOption == ChainOption.ChainByTags)
                    {
                        theImport.Files.StartDequeueing();
                    }

                }

                theImport.Duration = DateTime.Now.Subtract(theImport.StartTime);
                string text = "Import finished after " +
                              (theImport.Duration.Hours > 0 ? theImport.Duration.Hours + " hours  " : String.Empty) +
                              (theImport.Duration.Minutes > 0 ? theImport.Duration.Minutes + " minutes  " : String.Empty) +
                              (theImport.Duration.Seconds + " seconds  ") + "\nAdded files:     " + theImport.AddedFiles +
                              "\nUpdated files: " + theImport.UpdatedFiles +
                              ("\nDeleted files:  " + theImport.DeletedFiles).PadRight(128);
                if (!theImport.CheckProgress(100, text))
                {
                }
                else
                {

                    theImport.Importer.Section.EndUpdate();

                    theImport.Importer
                        .LogMessages.Enqueue
                        (new LogMessage("Info",
                            "Import finished"));

                    theImport.Importer
                        .LogMessages.Enqueue
                        (new LogMessage
                            ("Info", "Added:   "
                            + theImport.AddedFiles
                            + " files"));

                    theImport.Importer.LogMessages.Enqueue(
                        new LogMessage("Info", "Updated: " + theImport.UpdatedFiles + " files"));
                    theImport.Importer.LogMessages.Enqueue(
                        new LogMessage("Info", "Deleted: " + theImport.DeletedFiles + " files"));
                    if (theImport.Importer.ExcludeUnmatchedFiles)
                    {
                        theImport.Importer.LogMessages.Enqueue(
                            new LogMessage("Info", "Ignored (unmatched tags): " + theImport.UnmatchedFiles.Count + " files"));
                        foreach (EnhancedFileInfo file in theImport.UnmatchedFiles)
                        {
                            string logMessage = "Ignored (unmatched tags): " + file.FileInformation.FullName;
                            theImport.Importer.LogMessages.Enqueue(new LogMessage("Info", logMessage));
                        }
                    }

                    theImport.Importer.LogMessages.Enqueue(new LogMessage("Info", "Duration: " + theImport.Duration));

                }
            }
            catch (Exception ex)
            {
                string logMessage = "Import cancelled because of an unhandled error." + Environment.NewLine + ex;
                theImport.Importer.LogMessages.Enqueue(new LogMessage("Error", logMessage));
                theImport.Importer.ImportProgress.Progress(100, logMessage);
                theImport.Importer.Section.CancelUpdate();
            }
            finally
            {
                foreach (NetworkDrive drive in theImport.TemporaryMappedDrives)
                {
                    drive.UnmapDrive();
                }
            }

            return true;
        }
        /// <exception cref="FileImporterInitializationException"><c>FileImporterInitializationException</c>.</exception>
        public bool Import(IMLSection section, IMLImportProgress progress)
        {
            CoreEngineHelpers.Snapshot();
            try
            {
                if (!Initialized)
                {
                    throw new FileImporterInitializationException();
                }

                Section = section;
                ImportProgress = progress;
                using (ImportFunc = new TheImport(this))
                {
                    ImportCore.Run(this.ImportFunc);
                }
            }
            catch (FileImporterInitializationException ex)
            {
                MessageBox.Show(ex.Message);
            }

            CoreEngineHelpers.Snapshot();
            return true;
        }