private void MoveGuestPreviewPDFDocument(WebLibraryDetail web_library_detail)
        {
            PDFDocument source_pdf_document = pdf_renderer_control_stats.pdf_document;

            SafeThreadPool.QueueUserWorkItem(o =>
            {
                PDFDocument cloned_pdf_document = ImportingIntoLibrary.ClonePDFDocumentsFromOtherLibrary_SYNCHRONOUS(source_pdf_document, web_library_detail.library, false);

                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 != source_pdf_document)
                    {
                        source_pdf_document.Deleted = true;
                        source_pdf_document.Bindable.NotifyPropertyChanged(nameof(source_pdf_document.Deleted));
                    }
                });
            });
        }
        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);
                    }
                });
            });
        }
예제 #3
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);
                }
            }
        }