private static int CountDocumentsWithTag(WebLibraryDetail web_library_detail, string search_tag)
        {
            int count = 0;

            foreach (PDFDocument pdf_document in web_library_detail.Xlibrary.PDFDocuments)
            {
                foreach (string tag in TagTools.ConvertTagBundleToTags(pdf_document.Tags))
                {
                    if (0 == String.Compare(tag, search_tag))
                    {
                        ++count;
                        break;
                    }
                }
            }
            return(count);
        }
示例#2
0
        private void SynchronizeMetadata_INTERNAL_BACKGROUND(WebLibraryDetail web_library_detail, bool is_readonly)
        {
            Dictionary <string, string> historical_sync_file = HistoricalSyncFile.GetHistoricalSyncFile(web_library_detail);

            try
            {
                SynchronisationStates ss = SynchronisationStateBuilder.Build(web_library_detail, historical_sync_file);
                SynchronisationAction sa = SynchronisationActionBuilder.Build(web_library_detail, ss);
                SynchronisationExecutor.Sync(web_library_detail, is_readonly, historical_sync_file, sa);
            }
            catch (Exception ex)
            {
                UnhandledExceptionMessageBox.DisplayException(ex);
            }

            HistoricalSyncFile.PutHistoricalSyncFile(web_library_detail, historical_sync_file);
        }
        /// <summary>
        /// Builds a map of SynchronisationState objects of the form
        ///     filename -> SynchronisationState
        /// </summary>
        /// <returns></returns>
        internal static SynchronisationStates Build(WebLibraryDetail web_library_detail, Dictionary <string, string> historical_sync_file)
        {
            SynchronisationStates synchronisation_states = new SynchronisationStates();

            StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_META(web_library_detail), "Building sync state from local history");
            BuildFromHistoricalSyncFile(historical_sync_file, ref synchronisation_states);

            StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_META(web_library_detail), "Building sync state from local files");
            BuildFromLocal(web_library_detail, ref synchronisation_states);

            StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_META(web_library_detail), "Building sync state from Web/Intranet Library");
            BuildFromRemote(web_library_detail, ref synchronisation_states);

            FilterSynchronisationStates(ref synchronisation_states);

            return(synchronisation_states);
        }
        void TextLibraryForCitations_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            FeatureTrackingManager.Instance.UseFeature(Features.InCite_Popup_ChooseLibrary);

            // Pick a new library...
            WebLibraryDetail web_library_detail = WebLibraryPicker.PickWebLibrary();

            if (null != web_library_detail)
            {
                ConfigurationManager.Instance.ConfigurationRecord.InCite_LastLibrary = web_library_detail.Title;
                ConfigurationManager.Instance.ConfigurationRecord_Bindable.NotifyPropertyChanged(() => ConfigurationManager.Instance.ConfigurationRecord.InCite_LastLibrary);

                ChooseNewLibrary(web_library_detail);
            }

            e.Handled = true;
        }
 public static void AddNewDocumentToLibraryFromInternet_ASYNCHRONOUS(WebLibraryDetail web_library_detail, string download_url)
 {
     // we also need to fetch nasty URIs like these ones:
     //
     //    http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.49.6383&rep=rep1&type=pdf
     //    https://digitalcommons.unl.edu/cgi/viewcontent.cgi?article=1130&context=cseconfwork
     //
     // hence we don't care about the exact extension '.pdf' but merely if it MIGHT be a PDF....
     //
     // fetch the PDF, iff any!
     //
     // (Ignore the search engine 'base' URLs, which may be fed into here)
     if (!urls_which_are_guaranteed_to_be_NOT_a_download.Contains(download_url))
     {
         SafeThreadPool.QueueUserWorkItem(o => AddNewDocumentToLibraryFromInternet_SYNCHRONOUS(web_library_detail, download_url));
     }
 }
        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);

            // base.OnClosed() invokes this class' Closed() code, so we flipped the order of exec to reduce the number of surprises for yours truly.
            // This NULLing stuff is really the last rites of Dispose()-like so we stick it at the end here.

            WizardDPs.ClearPointOfInterest(this);
            WizardDPs.ClearPointOfInterest(CmdGenerate);

            web_library_detail = null;
            pdf_documents.Clear();
            pdf_documents = null;

            ListTags.ItemsSource = null;
            ListTags.Items.Clear();
        }
示例#7
0
 private void SynchronizeDocuments_Upload_INTERNAL_BACKGROUND(WebLibraryDetail web_library_detail, List <PDFDocument> pdf_documents, bool is_readonly)
 {
     // TODO: Replace this with a pretty interface class ------------------------------------------------
     if (is_readonly)
     {
         // Do nothing...
         Logging.Info("Not queueing upload of PDFs for read-only library '{0}'.", web_library_detail);
     }
     else if (web_library_detail.IsIntranetLibrary)
     {
         SyncQueues_Intranet.QueueUploadOfMissingPDFs(web_library_detail, pdf_documents);
     }
     else
     {
         throw new Exception(String.Format("Did not understand how to queue upload PDFs for library {0}", web_library_detail.Title));
     }
     // -----------------------------------------------------------------------------------------------------
 }
示例#8
0
        // -------------------------------------------------------------------------------------------------------------------------------------------------------

        internal void Sync(SyncControlGridItemSet sync_control_grid_item_set)
        {
            Logging.Info("Syncing");

            foreach (SyncControlGridItem sync_control_grid_item_temp in sync_control_grid_item_set.grid_items)
            {
                // Needed for passing to background thread...
                SyncControlGridItem sync_control_grid_item = sync_control_grid_item_temp;
                WebLibraryDetail    web_library_detail     = sync_control_grid_item.library_sync_detail.web_library_detail;

                if (!web_library_detail.IsIntranetLibrary)
                {
                    string local_sync_db = HistoricalSyncFile.GetSyncDbFilename(web_library_detail);

                    if (File.Exists(local_sync_db))
                    {
                        Logging.Warn("INTEGRITY CHECK 'CURIOSITY': library '{0}' has a Historical Sync file at '{1}', while at the same time seems to NOT HAVE a Sync Point a.k.a. Share Target set and thus cannot be synced. The presense of the Histrorical Sync File indicates that this library has had a Sync Point sometime in the past.", web_library_detail, local_sync_db);
                    }

                    Logging.Warn("SYNC IGNORE: library '{0}' has no Sync Point a.k.a. Share Target set and thus cannot be synced.", web_library_detail);
                }

                if (web_library_detail.Xlibrary.sync_in_progress)
                {
                    if (!sync_control_grid_item_set.sync_request.suppress_already_in_progress_notification)
                    {
                        MessageBoxes.Info("A sync operation is already in progress for library {0}.  Please wait for it to finish before trying to sync again.", web_library_detail.Title);
                    }
                    else
                    {
                        Logging.Info("A sync operation is already in progress for library {0}.  This has been suppressed from the GUI.", web_library_detail.Title);
                    }
                }
                else
                {
                    if (sync_control_grid_item.SyncLibrary)
                    {
                        web_library_detail.Xlibrary.sync_in_progress = true;
                        SafeThreadPool.QueueUserWorkItem(o => Sync_BACKGROUND(sync_control_grid_item));
                    }
                }
            }
        }
        public void FindDuplicates(WebLibraryDetail web_library_detail)
        {
            // Utilities.LockPerfTimer l1_clk = Utilities.LockPerfChecker.Start();
            lock (locker)
            {
                // l1_clk.LockPerfTimerStop();
                if (already_finding_duplicates)
                {
                    Logging.Warn("Not finding duplicates while a previous invocation is still running.");
                    return;
                }
                else
                {
                    already_finding_duplicates = true;
                }
            }

            SafeThreadPool.QueueUserWorkItem(o => FindDuplicates_BACKGROUND(web_library_detail));
        }
        private static PDFDocument AddQiqqaManualToLibrary(WebLibraryDetail web_library_detail)
        {
            FilenameWithMetadataImport fwmi = new FilenameWithMetadataImport();

            fwmi.filename = QiqqaManualFilename.Value;
            fwmi.tags.Add("manual");
            fwmi.tags.Add("help");
            fwmi.bibtex =
                "@booklet{qiqqa_manual" + "\n" +
                ",	title	= {The Qiqqa Manual}"+ "\n" +
                ",	author	= {The Qiqqa Team,}"+ "\n" +
                ",	year	= {2013}"+ "\n" +
                "}"
            ;

            PDFDocument pdf_document = ImportingIntoLibrary.AddNewPDFDocumentsToLibraryWithMetadata_SYNCHRONOUS(web_library_detail, true, new FilenameWithMetadataImport[] { fwmi });

            return(pdf_document);
        }
示例#11
0
        public static PDFDocument CreateFromVanillaReference(WebLibraryDetail web_library_detail)
        {
            PDFDocument pdf_document = new PDFDocument(web_library_detail);

            // Store the most important information
            //
            // thread-UNSAFE access is permitted as the PDF has just been created so there's no thread-safety risk yet.
            pdf_document.FileType            = Constants.VanillaReferenceFileType;
            pdf_document.Fingerprint         = VanillaReferenceCreating.CreateVanillaReferenceFingerprint();
            pdf_document.DateAddedToDatabase = DateTime.UtcNow;
            pdf_document.DateLastModified    = DateTime.UtcNow;

            Directory.CreateDirectory(pdf_document.DocumentBasePath);

            List <LibraryDB.LibraryItem> library_items = web_library_detail.Xlibrary.LibraryDB.GetLibraryItems(PDFDocumentFileLocations.METADATA, new List <string>()
            {
                pdf_document.Fingerprint
            });

            ASSERT.Test(library_items.Count < 2);
            if (0 == library_items.Count)
            {
                pdf_document.QueueToStorage();
            }
            else
            {
                LibraryDB.LibraryItem library_item = null;
                try
                {
                    library_item = library_items[0];
                    pdf_document = LoadFromMetaData(web_library_detail, pdf_document.Fingerprint, library_item.data);
                }
                catch (Exception ex)
                {
                    Logging.Error(ex, "There was a problem reloading an existing PDF from existing metadata, so overwriting it! (document fingerprint: {0}, data: {1})", pdf_document.Fingerprint, library_item?.MetadataAsString() ?? "???");

                    // TODO: WARNING: overwriting old (possibly corrupted) records like this can loose you old/corrupted/unsupported metadata content!
                    pdf_document.QueueToStorage();
                }
            }

            return(pdf_document);
        }
示例#12
0
        void ButtonGrabPDFs_Click(object sender, RoutedEventArgs e)
        {
            Uri    current_uri = CurrentWebBrowserControl.CurrentUri;
            string html        = CurrentWebBrowserControl.PageHTML;

            List <string> urls = DownloadableFileGrabber.Grab(html, "pdf");

            List <Uri> uris = new List <Uri>();

            foreach (string url in urls)
            {
                Uri uri;
                if (Uri.TryCreate(current_uri, url, out uri))
                {
                    uris.Add(uri);
                }
            }

            if (0 < uris.Count)
            {
                string msg = String.Format(
                    "Qiqqa has found {0} PDFs on this page.  Please choose the library into which you want to import them."
                    , uris.Count
                    );

                WebLibraryDetail web_library_detail = WebLibraryPicker.PickWebLibrary(msg);
                if (null != web_library_detail)
                {
                    foreach (Uri uri in uris)
                    {
                        ImportingIntoLibrary.AddNewDocumentToLibraryFromInternet_ASYNCHRONOUS(web_library_detail.library, uri.ToString());
                    }
                }
                else
                {
                    MessageBoxes.Warn("No PDFs have been imported.");
                }
            }
            else
            {
                MessageBoxes.Info("Qiqqa could not find links to any PDFs on this page (with URLs ending in .pdf");
            }
        }
        public void ChooseNewLibrary(WebLibraryDetail web_library_detail)
        {
            this.WebLibraryDetail = web_library_detail;

            if (null != web_library_detail)
            {
                ObjLibraryTextBox.Text = web_library_detail.Title;
            }
            else
            {
                ObjLibraryTextBox.Text = "Click to choose a library.";
            }

            // Callback
            if (null != OnWebLibraryPicked)
            {
                OnWebLibraryPicked(web_library_detail);
            }
        }
示例#14
0
        public LibraryDB(WebLibraryDetail web_library_detail)
        {
            base_path    = web_library_detail.LIBRARY_BASE_PATH;
            library_path = LibraryDB.GetLibraryDBPath(base_path);
            string db_syncref_path = IntranetLibraryTools.GetLibraryMetadataPath(base_path);

            // Copy a library into place...
            // but only if this is not a Internet sync directory/DB!
            if (File.Exists(db_syncref_path))
            {
                throw new Exception(String.Format("MUST NOT attempt to create a regular Qiqqa library in the Qiqqa Internet/Intranet Sync directory: '{0}'", base_path));
            }
            if (!File.Exists(library_path))
            {
                Logging.Warn($"Library db for '{web_library_detail.Id}' does not exist so copying the template to '{library_path}'");
                string library_template_path = LibraryDB.GetLibraryDBTemplatePath();
                File.Copy(library_template_path, library_path);
            }
        }
        private static Dictionary <string, PDFDocumentExportItem> Export_Docs(WebLibraryDetail web_library_detail, List <PDFDocument> pdf_documents, string base_path)
        {
            // Where the original docs go
            string doc_base_path_original = Path.GetFullPath(Path.Combine(base_path, @"docs_original"));

            Directory.CreateDirectory(doc_base_path_original);

            // Where the modified docs go
            string doc_base_path = Path.GetFullPath(Path.Combine(base_path, @"docs"));

            Directory.CreateDirectory(doc_base_path);

            Dictionary <string, PDFDocumentExportItem> pdf_document_export_items = new Dictionary <string, PDFDocumentExportItem>();

            foreach (PDFDocument pdf_document in pdf_documents)
            {
                try
                {
                    if (File.Exists(pdf_document.DocumentPath))
                    {
                        // The original docs
                        string filename_original = Path.GetFullPath(Path.Combine(doc_base_path_original, ExportingTools.MakeExportFilename(pdf_document)));
                        File.Copy(pdf_document.DocumentPath, filename_original, true);

                        // The modified docs
                        string filename = Path.GetFullPath(Path.Combine(doc_base_path, ExportingTools.MakeExportFilename(pdf_document)));
                        File.Copy(pdf_document.DocumentPath, filename, true);

                        // And the ledger entry
                        PDFDocumentExportItem item = new PDFDocumentExportItem();
                        item.pdf_document = pdf_document;
                        item.filename     = filename;
                        pdf_document_export_items[item.pdf_document.Fingerprint] = item;
                    }
                }
                catch (Exception ex)
                {
                    Logging.Error(ex, "Error copying file from {0}", pdf_document.DocumentPath);
                }
            }

            return(pdf_document_export_items);
        }
        private void MoveOrCopyCommon(Feature feature, bool delete_source_pdf_documents)
        {
            WebLibraryDetail web_library_detail = WebLibraryPicker.PickWebLibrary();

            if (null == web_library_detail)
            {
                Logging.Warn("User did not pick a library to copy or move to: pick = NULL.");
                return;
            }

            // Check that we are not moving any docs into the same library
            bool same_library = false;

            foreach (var pdf_document in pdf_documents)
            {
                if (pdf_document.Library.WebLibraryDetail == web_library_detail)
                {
                    same_library = true;
                }
            }
            if (same_library)
            {
                MessageBoxes.Error("You can not move/copy a PDF from/to the same library.");
                return;
            }

            // Copying / Moving PDFDocuments takes a while, particularly if it's a large set.
            //
            // Hence this WORK should be executed by a background task.
            SafeThreadPool.QueueUserWorkItem(o =>
            {
                FeatureTrackingManager.Instance.UseFeature(feature);

                ImportingIntoLibrary.ClonePDFDocumentsFromOtherLibrary_SYNCHRONOUS(pdf_documents, web_library_detail.library, delegate(PDFDocument target, PDFDocument source)
                {
                    if (delete_source_pdf_documents && null != target && null != source && target != source)
                    {
                        source.Library.DeleteDocument(source);
                    }
                });
            });
        }
示例#17
0
        private void ChooseNewLibrary(WebLibraryDetail web_library_detail)
        {
            default_library = web_library_detail;
            library_control = null;
            TextLibraryForCitations.Text = "Click to choose a library.";
            ObjLibraryControlPlaceholderRegion.Children.Clear();

            if (null != web_library_detail)
            {
                TextLibraryForCitations.Text = web_library_detail.Title;

                library_control = new LibraryControl(web_library_detail);
                library_control.ObjToolBarTray.Visibility = Visibility.Collapsed;

                HolderForSearchBox.Children.Clear();
                HolderForSearchBox.Children.Add(library_control.DetachSearchBox());

                ObjLibraryControlPlaceholderRegion.Children.Add(library_control);
            }
        }
        internal static void DaemonGet(WebLibraryDetail web_library_detail, string fingerprint)
        {
            string filename_full  = PDFDocumentFileLocations.DocumentPath(web_library_detail, fingerprint, "pdf");
            string filename_short = Path.GetFileName(filename_full);
            string pdf_path       = IntranetLibraryTools.GetLibraryPDFPath(web_library_detail.IntranetPath, filename_short);

            DirectoryTools.CreateDirectory(Path.GetDirectoryName(filename_full));

            Logging.Info("+Copying down {0}", fingerprint);
            File.Copy(pdf_path, filename_full);
            Logging.Info("-Copying down {0}", fingerprint);

            // Write the audit
            if (true)
            {
                string audit_filename  = IntranetLibraryTools.GetLibraryAuditFilename(web_library_detail.IntranetPath);
                string audit_directory = Path.GetDirectoryName(audit_filename);

                if (Directory.Exists(audit_directory))
                {
                    string audit_data = String.Format(
                        "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\r\n"
                        , DateTime.UtcNow.ToString("yyyyMMdd.hhmmss")
                        , ConfigurationManager.Instance.ConfigurationRecord.Account_Username
                        , ConfigurationManager.Instance.ConfigurationRecord.Account_Nickname
                        , Environment.UserName
                        , filename_short
                        , pdf_path
                        );

                    try
                    {
                        File.AppendAllText(audit_filename, audit_data);
                    }
                    catch (Exception ex)
                    {
                        Logging.Warn(ex, "Unable to write intranet sync audit data.");
                    }
                }
            }
        }
示例#19
0
        private static void DoNotifyLibraryOfChanges(WebLibraryDetail web_library_detail, Dictionary <string, string> historical_sync_file, SynchronisationAction synchronisation_action)
        {
            StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_META(web_library_detail), "Notifying library of changes");

            HashSet <string> fingerprints_that_have_changed = new HashSet <string>();

            foreach (SynchronisationState ss in synchronisation_action.states_to_download)
            {
                fingerprints_that_have_changed.Add(ss.fingerprint);
            }

            foreach (string fingerprint in fingerprints_that_have_changed)
            {
                web_library_detail.Xlibrary.NotifyLibraryThatDocumentHasChangedExternally(fingerprint, web_library_detail);
            }

            // Update grid
            web_library_detail.Xlibrary.NotifyLibraryThatDocumentListHasChangedExternally();

            StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_META(web_library_detail), "Notified library of changes");
        }
示例#20
0
        private static void Export_Directories_Titles(WebLibraryDetail web_library_detail, string base_path, Dictionary <string, PDFDocumentExportItem> pdf_document_export_items)
        {
            WshShell shell = new WshShell();

            string titles_base_path = Path.GetFullPath(Path.Combine(base_path, @"titles"));

            Directory.CreateDirectory(titles_base_path);

            foreach (var item in pdf_document_export_items.Values)
            {
                try
                {
                    string filename = Path.GetFullPath(Path.Combine(titles_base_path, FileTools.MakeSafeFilename(item.pdf_document.TitleCombined) + ".lnk"));
                    CreateShortcut(shell, item.filename, filename);
                }
                catch (Exception ex)
                {
                    Logging.Error(ex, "Error creating shortcut for " + item.filename);
                }
            }
        }
示例#21
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());
            }
        }
示例#22
0
        public FolderWatcher(FolderWatcherManager _folder_watcher_manager, WebLibraryDetail _library, string folder_to_watch, string _tags)
        {
            folder_watcher_manager   = new TypedWeakReference <FolderWatcherManager>(_folder_watcher_manager);
            web_library_detail       = new TypedWeakReference <WebLibraryDetail>(_library);
            aspiring_folder_to_watch = folder_to_watch;
            tags = TagTools.ConvertTagBundleToTags(_tags);
            configured_folder_to_watch = null;

            watch_stats = new WatchStatistics();

            file_system_watcher = new FileSystemWatcher();
            file_system_watcher.IncludeSubdirectories = true;
            file_system_watcher.Filter   = "*.pdf";
            file_system_watcher.Changed += file_system_watcher_Changed;
            file_system_watcher.Created += file_system_watcher_Created;
            configured_folder_to_watch   = null;
            FolderContentsHaveChanged    = false;

            file_system_watcher.Path = null;
            file_system_watcher.EnableRaisingEvents = false;
        }
        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());
            }
        }
示例#24
0
        private static void DoUploads(WebLibraryDetail web_library_detail, Dictionary <string, string> historical_sync_file, SynchronisationAction synchronisation_action)
        {
            int upload_count = 0;

            StatusManager.Instance.ClearCancelled(StatusCodes.SYNC_META(web_library_detail));
            foreach (SynchronisationState ss in synchronisation_action.states_to_upload)
            {
                StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_META(web_library_detail), String.Format("Uploading metadata to your Web/Intranet Library ({0} to go)", synchronisation_action.states_to_upload.Count - upload_count), upload_count, synchronisation_action.states_to_upload.Count, true);
                ++upload_count;

                // Has the user canceled?
                if (StatusManager.Instance.IsCancelled(StatusCodes.SYNC_META(web_library_detail)))
                {
                    Logging.Info("User has canceled their metadata upload");
                    break;
                }

                // Upload the file
                {
                    Logging.Info("+Uploading {0}", ss.filename);

                    // TODO: Replace this with a pretty interface class ------------------------------------------------
                    if (web_library_detail.IsIntranetLibrary)
                    {
                        SynchronisationExecutor_Intranet.DoUpload(web_library_detail, ss);
                    }
                    else
                    {
                        throw new Exception(String.Format("Did not understand how to upload for library {0}", web_library_detail.Title));
                    }
                    // -----------------------------------------------------------------------------------------------------

                    Logging.Info("-Uploading {0}");

                    historical_sync_file[ss.filename] = ss.library_item.md5;
                }
            }

            StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_META(web_library_detail), String.Format("Uploaded {0} metadata to your Web/Intranet Library", upload_count));
        }
        private void MoveGuestPreviewPDFDocument(WebLibraryDetail web_library_detail)
        {
            PDFDocument pdf_document = GetPDFDocument();

            ASSERT.Test(pdf_document != null);

            if (pdf_document != null)
            {
                PDFDocument source_pdf_document = pdf_document;

                SafeThreadPool.QueueUserWorkItem(o =>
                {
                    PDFDocument cloned_pdf_document = ImportingIntoLibrary.ClonePDFDocumentsFromOtherLibrary_SYNCHRONOUS(source_pdf_document, web_library_detail);
                    ASSERT.Test(cloned_pdf_document != null);

                    WPFDoEvents.InvokeInUIThread(() =>
                    {
                        // Open the new
                        if (null != cloned_pdf_document)
                        {
                            MainWindowServiceDispatcher.Instance.OpenDocument(cloned_pdf_document);
                        }
                        else
                        {
                            MessageBoxes.Warn("There was a problem moving this document to another library.");
                        }

                        // Close the old
                        MainWindowServiceDispatcher.Instance.ClosePDFReadingControl(this);

                        // Delete the old
                        if (cloned_pdf_document != null && cloned_pdf_document != source_pdf_document)
                        {
                            source_pdf_document.Deleted = true;
                            source_pdf_document.Bindable.NotifyPropertyChanged(nameof(source_pdf_document.Deleted));
                        }
                    });
                });
            }
        }
        public void ReflectLibrary(WebLibraryDetail web_library_detail)
        {
            // Reset
            RegionNoLibrary.Visibility          = Visibility.Collapsed;
            RegionNoExpedition.Visibility       = Visibility.Collapsed;
            RegionStaleExpedition.Visibility    = Visibility.Collapsed;
            RegionExpeditionTooSmall.Visibility = Visibility.Collapsed;

            // Reflect
            if (null == web_library_detail)
            {
                RegionNoLibrary.Visibility = Visibility.Visible;
            }
            else
            {
                ExpeditionDataSource eds = web_library_detail.Xlibrary?.ExpeditionManager?.ExpeditionDataSource;

                if (null != eds)
                {
                    RegionNoExpedition.Visibility = Visibility.Visible;
                }
                else
                {
                    ASSERT.Test(eds.words != null);
                    ASSERT.Test(eds.docs != null);

                    // Is this expedition getting old?
                    if (web_library_detail.Xlibrary.ExpeditionManager.IsStale)
                    {
                        RegionStaleExpedition.Visibility = Visibility.Visible;
                    }

                    // Is this expedition too small?
                    if (eds.docs.Count < 20 || eds.words.Count < 5)
                    {
                        RegionExpeditionTooSmall.Visibility = Visibility.Visible;
                    }
                }
            }
        }
        private static PDFDocument AddLoexManualToLibrary(WebLibraryDetail web_library_detail)
        {
            FilenameWithMetadataImport fwmi = new FilenameWithMetadataImport();

            fwmi.filename = LoexManualFilename.Value;
            fwmi.tags.Add("manual");
            fwmi.tags.Add("help");
            fwmi.bibtex =
                "@article{qiqqatechmatters" + "\n" +
                ",	title	= {TechMatters: “Qiqqa” than you can say Reference Management: A Tool to Organize the Research Process}"+ "\n" +
                ",	author	= {Krista Graham}"+ "\n" +
                ",	year	= {2014}"+ "\n" +
                ",	publication	= {LOEX Quarterly}"+ "\n" +
                ",	volume	= {40}"+ "\n" +
                ",	pages	= {4-6}"+ "\n" +
                "}"
            ;

            PDFDocument pdf_document = ImportingIntoLibrary.AddNewPDFDocumentsToLibraryWithMetadata_SYNCHRONOUS(web_library_detail, true, new FilenameWithMetadataImport[] { fwmi });

            return(pdf_document);
        }
示例#28
0
        public Library(WebLibraryDetail web_library_detail)
        {
            this.web_library_detail = web_library_detail;

            Logging.Info("Library basepath is at {0}", LIBRARY_BASE_PATH);
            Logging.Info("Library document basepath is at {0}", LIBRARY_DOCUMENTS_BASE_PATH);

            Directory.CreateDirectory(LIBRARY_BASE_PATH);
            Directory.CreateDirectory(LIBRARY_DOCUMENTS_BASE_PATH);

            library_db              = new LibraryDB(LIBRARY_BASE_PATH);
            folder_watcher_manager  = new FolderWatcherManager(this);
            library_index           = new LibraryIndex(this);
            ai_tag_manager          = new AITagManager(this);
            recently_read_manager   = new RecentlyReadManager(this);
            blackwhite_list_manager = new BlackWhiteListManager(this);
            password_manager        = new PasswordManager(this);
            expedition_manager      = new ExpeditionManager(this);

            // Start loading the documents in the background...
            SafeThreadPool.QueueUserWorkItem(o => BuildFromDocumentRepository());
        }
        public void ReflectLibrary(WebLibraryDetail library_)
        {
            web_library_detail = library_;
            manifest           = new BundleLibraryManifest();

            string bundle_title = web_library_detail.Title + " Bundle Library";

            bundle_title = bundle_title.Replace("Library Bundle Library", "Bundle Library");

            // Set the manifest
            manifest.Id      = "BUNDLE_" + web_library_detail.Id;
            manifest.Version = DateTime.UtcNow.ToString("yyyyMMdd.HHmmss");

            manifest.Title       = bundle_title;
            manifest.Description = web_library_detail.Description;

            // GUI updates
            DataContext            = manifest;
            ObjRunLibraryName.Text = web_library_detail.Title;

            ResetProgress();
        }
示例#30
0
        private void MoveOrCopyCommon(Feature feature, bool delete_source_pdf_documents)
        {
            WebLibraryDetail web_library_detail = WebLibraryPicker.PickWebLibrary();

            if (null == web_library_detail)
            {
                return;
            }

            // Check that we are not moving any docs into the same library
            bool same_library = false;

            foreach (var pdf_document in pdf_documents)
            {
                if (pdf_document.Library.WebLibraryDetail == web_library_detail)
                {
                    same_library = true;;
                }
            }
            if (same_library)
            {
                MessageBoxes.Error("You can not move/copy a PDF from/to the same library.");
                return;
            }

            FeatureTrackingManager.Instance.UseFeature(feature);

            ImportingIntoLibrary.ClonePDFDocumentsFromOtherLibrary_SYNCHRONOUS(pdf_documents, web_library_detail.library);

            if (delete_source_pdf_documents)
            {
                foreach (var pdf_document in pdf_documents)
                {
                    pdf_document.Deleted = true;
                    pdf_document.Bindable.NotifyPropertyChanged(() => pdf_document.Deleted);
                }
            }
        }