void btnImport_Click(object sender, RoutedEventArgs e)
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Library_ImportFromThirdParty);

            IEnumerable <AugmentedBindable <BibTeXEntry> > allEntries = GetEntries().Where(x => x.Underlying.Selected);

            if (allEntries.Count() == 0)
            {
                MessageBoxes.Error("Please select at least one entry to import, by checking the checkbox.");
                return;
            }

            List <ImportingIntoLibrary.FilenameWithMetadataImport> filename_and_bibtex_imports = new List <ImportingIntoLibrary.FilenameWithMetadataImport>();

            foreach (AugmentedBindable <BibTeXEntry> entry in allEntries)
            {
                ImportingIntoLibrary.FilenameWithMetadataImport filename_with_metadata_import = new ImportingIntoLibrary.FilenameWithMetadataImport
                {
                    filename = entry.Underlying.Filename,
                    bibtex   = entry.Underlying.BibTeX,
                    tags     = entry.Underlying.Tags,
                    notes    = entry.Underlying.Notes
                };

                filename_and_bibtex_imports.Add(filename_with_metadata_import);
            }

            StatusManager.Instance.UpdateStatus("ImportFromThirdParty", "Started importing documents");

            ImportingIntoLibrary.AddNewPDFDocumentsToLibraryWithMetadata_ASYNCHRONOUS(_library, false, false, filename_and_bibtex_imports.ToArray());

            MessageBoxes.Info("{0} files are now being imported - this may take a little while.  You can track the import progress in the status bar.", filename_and_bibtex_imports.Count);

            this.Close();
        }
コード例 #2
0
        private void ProcessTheNewDocuments(List <string> filenames_that_are_new)
        {
            if (0 == filenames_that_are_new.Count)
            {
                return;
            }

            if (Utilities.Shutdownable.ShutdownableManager.Instance.IsShuttingDown)
            {
                Logging.Info("FolderWatcher: Breaking out due to daemon termination");
                return;
            }

            if (Qiqqa.Common.Configuration.ConfigurationManager.Instance.ConfigurationRecord.DisableAllBackgroundTasks)
            {
                Logging.Info("FolderWatcher: Breaking out due to DisableAllBackgroundTasks");
                return;
            }

            // Create the import records
            List <FilenameWithMetadataImport> filename_with_metadata_imports = new List <FilenameWithMetadataImport>();

            foreach (var filename in filenames_that_are_new)
            {
                filename_with_metadata_imports.Add(new FilenameWithMetadataImport
                {
                    filename = filename,
                    tags     = new HashSet <string>(tags)
                });

                // TODO: refactor this: delay until the PDF has actually been processed completely!
                //
                // Add this file to the list of processed files...
                folder_watcher_manager.RememberProcessedFile(filename);
            }

            // Get the library to import all these new files
            ImportingIntoLibrary.AddNewPDFDocumentsToLibraryWithMetadata_ASYNCHRONOUS(library, true, true, filename_with_metadata_imports.ToArray());

            // TODO: refactor the ImportingIntoLibrary class
            //
            // HACK & QUICK PATCH until we have refactored this stuff:
            filenames_that_are_new.Clear();
        }
コード例 #3
0
        private static void DoImportMyDocuments(object obj)
        {
            if (null == mdd)
            {
                Logging.Warn("Not sure how MendeleyImporter.MendeleyDatabaseDetails is null if we got a command to import...");
                return;
            }

            FeatureTrackingManager.Instance.UseFeature(Features.Library_ImportAutoFromMendeley);

            WebLibraryDetail web_library_detail = null;

            WPFDoEvents.InvokeInUIThread(() =>
                                         web_library_detail = WebLibraryPicker.PickWebLibrary()
                                         );

            if (null != web_library_detail)
            {
                ImportingIntoLibrary.AddNewPDFDocumentsToLibraryWithMetadata_ASYNCHRONOUS(web_library_detail.library, false, false, mdd.metadata_imports.ToArray());
            }
        }
コード例 #4
0
        static void DoImportMyDocuments(object obj)
        {
            if (null == mdd)
            {
                Logging.Warn("Not sure how EndnoteImporter.EndnoteDatabaseDetails is null if we got a command to import...");
                return;
            }

            Qiqqa.UtilisationTracking.FeatureTrackingManager.Instance.UseFeature(Features.Library_ImportAutoFromEndNote);

            WebLibraryDetail web_library_detail = null;

            Application.Current.Dispatcher.Invoke(((Action)(() =>
                                                            web_library_detail = WebLibraryPicker.PickWebLibrary()
                                                            )));

            if (null != web_library_detail)
            {
                ImportingIntoLibrary.AddNewPDFDocumentsToLibraryWithMetadata_ASYNCHRONOUS(web_library_detail.library, false, false, mdd.metadata_imports.ToArray());
            }
        }
 void CmdAutomaticEndnoteImport_Click(object sender, RoutedEventArgs e)
 {
     Qiqqa.UtilisationTracking.FeatureTrackingManager.Instance.UseFeature(Features.Library_ImportAutoFromEndNote);
     ImportingIntoLibrary.AddNewPDFDocumentsToLibraryWithMetadata_ASYNCHRONOUS(this._library, false, false, edd.metadata_imports.ToArray());
     this.Close();
 }
コード例 #6
0
 private void CmdAutomaticMendeleyImport_Click(object sender, RoutedEventArgs e)
 {
     FeatureTrackingManager.Instance.UseFeature(Features.Library_ImportAutoFromMendeley);
     ImportingIntoLibrary.AddNewPDFDocumentsToLibraryWithMetadata_ASYNCHRONOUS(_library, false, false, mdd.metadata_imports.ToArray());
     Close();
 }
コード例 #7
0
        /// <summary>
        /// The daemon code calls this occasionally to poke it into action to do work
        /// </summary>
        /// <param name="daemon"></param>
        public void TaskDaemonEntryPoint(Daemon daemon)
        {
            // We don't want to start watching files until the library is loaded...
            if (!library.LibraryIsLoaded)
            {
                Logging.Info("Library is not yet loaded, so waiting before watching...");

                // Indicate that the library may still not have been changed...
                folder_contents_has_changed = true;
                return;
            }

            // Update our fole system watcher if necessary
            CheckIfFolderNameHasChanged();

            // If the current folder is blank, do nothing
            if (String.IsNullOrEmpty(folder_to_watch))
            {
                return;
            }

            // If the folder does not exist, do nothing
            if (!Directory.Exists(folder_to_watch))
            {
                return;
            }


            // If the folder or its contents has not changed since the last time, do nothing
            if (!folder_contents_has_changed)
            {
                return;
            }

            // Mark that we are now processing the folder
            folder_contents_has_changed = false;

            // If we get this far then there might be some work to do in the folder...
            string[] filenames_in_folder = Directory.GetFiles(previous_folder_to_watch, "*.pdf", SearchOption.AllDirectories);

            List <PDFDocument> pdf_documents_already_in_library = library.PDFDocuments;

            List <string> filenames_that_are_new = new List <string>();

            foreach (string filename in filenames_in_folder)
            {
                // If we already have this file in the "cache since we started", skip it
                if (folder_watcher_manager.HaveProcessedFile(filename))
                {
                    //Logging.Info("FolderWatcher is skipping {0} as it has already been processed", filename);
                    continue;
                }

                // If we already have this file in the "pdf file locations", skip it
                bool is_already_in_library = false;
                foreach (PDFDocument pdf_document in pdf_documents_already_in_library)
                {
                    if (pdf_document.DownloadLocation == filename)
                    {
                        is_already_in_library = true;
                        break;
                    }
                }

                if (is_already_in_library)
                {
                    // Add this file to the list of processed files...
                    folder_watcher_manager.RememberProcessedFile(filename);

                    continue;
                }

                // Check that the file is not still locked - if it is, mark that the folder is still "changed" and come back later..
                if (IsFileLocked(filename))
                {
                    Logging.Info("Watched folder contains file '{0}' which is locked, so coming back later...", filename);
                    folder_contents_has_changed = true;
                    continue;
                }

                Logging.Info("FolderWatcher is importing {0}", filename);
                filenames_that_are_new.Add(filename);

                // Add this file to the list of processed files...
                folder_watcher_manager.RememberProcessedFile(filename);
            }


            // Create the import records
            List <ImportingIntoLibrary.FilenameWithMetadataImport> filename_with_metadata_imports = new List <ImportingIntoLibrary.FilenameWithMetadataImport>();

            foreach (var filename in filenames_that_are_new)
            {
                filename_with_metadata_imports.Add(new ImportingIntoLibrary.FilenameWithMetadataImport {
                    filename = filename, tags = new List <string>(this.tags)
                });
            }

            // Get the library to import all these new files
            ImportingIntoLibrary.AddNewPDFDocumentsToLibraryWithMetadata_ASYNCHRONOUS(library, true, true, filename_with_metadata_imports.ToArray());
        }