Exemplo n.º 1
0
        public static PDFDocument CreateFromVanillaReference(Library library)
        {
            PDFDocument pdf_document = new PDFDocument(library);

            // Store the most important information
            pdf_document.FileType            = 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 = library.LibraryDB.GetLibraryItems(pdf_document.Fingerprint, PDFDocumentFileLocations.METADATA);

            if (0 == library_items.Count)
            {
                DocumentQueuedStorer.Instance.Queue(pdf_document);
            }
            else
            {
                try
                {
                    LibraryDB.LibraryItem library_item = library_items[0];
                    pdf_document = LoadFromMetaData(library, library_item.data, null);
                }
                catch (Exception ex)
                {
                    Logging.Error(ex, "There was a problem reloading an existing PDF from existing metadata, so overwriting it!");
                    DocumentQueuedStorer.Instance.Queue(pdf_document);
                }
            }

            return(pdf_document);
        }
Exemplo n.º 2
0
        public static PDFDocument CreateFakeForDesigner()
        {
            PDFDocument pdf_document = new PDFDocument(null);

            // 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;

            return(pdf_document);
        }
Exemplo n.º 3
0
        internal void QueueGet(string fingerprint, Library library)
        {
            // We never fetch vanilla ref PDFs from S3.
            if (VanillaReferenceCreating.IsVanillaReferenceFingerprint(fingerprint))
            {
                return;
            }

            lock (fingerprints_to_get)
            {
                fingerprints_to_get.Add(new SyncQueueEntry {
                    fingerprint = fingerprint, library = library
                });
            }
        }
Exemplo n.º 4
0
        internal void QueuePut(string fingerprint, Library library)
        {
            //We never send vanilla ref PDFs to s3.
            if (VanillaReferenceCreating.IsVanillaReferenceFingerprint(fingerprint))
            {
                return;
            }

            lock (fingerprints_to_put)
            {
                fingerprints_to_put.Add(new SyncQueueEntry {
                    fingerprint = fingerprint, library = library
                });
            }
        }
Exemplo n.º 5
0
        internal void QueueGet(string fingerprint, WebLibraryDetail web_library_detail)
        {
            // We never fetch vanilla ref PDFs from S3.
            if (VanillaReferenceCreating.IsVanillaReferenceFingerprint(fingerprint))
            {
                return;
            }

            // Utilities.LockPerfTimer l1_clk = Utilities.LockPerfChecker.Start();
            lock (fingerprints_to_get)
            {
                // l1_clk.LockPerfTimerStop();
                fingerprints_to_get.Add(new SyncQueueEntry {
                    fingerprint = fingerprint, web_library_detail = web_library_detail
                });
            }
        }
Exemplo n.º 6
0
        internal void QueuePut(string fingerprint, Library library)
        {
            // We never send vanilla ref PDFs to s3.
            if (VanillaReferenceCreating.IsVanillaReferenceFingerprint(fingerprint))
            {
                return;
            }

            // Utilities.LockPerfTimer l1_clk = Utilities.LockPerfChecker.Start();
            lock (fingerprints_to_put)
            {
                // l1_clk.LockPerfTimerStop();
                fingerprints_to_put.Add(new SyncQueueEntry {
                    fingerprint = fingerprint, library = library
                });
            }
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        public static PDFDocument CreateFromVanillaReference(Library library)
        {
            LockObject  _lock        = new LockObject();
            PDFDocument pdf_document = new PDFDocument(_lock, library);

            // 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 = library.LibraryDB.GetLibraryItems(pdf_document.Fingerprint, PDFDocumentFileLocations.METADATA);

            if (0 == library_items.Count)
            {
                pdf_document.QueueToStorage();
            }
            else
            {
                try
                {
                    LibraryDB.LibraryItem library_item = library_items[0];
                    pdf_document = LoadFromMetaData(library, library_item.data, null);
                }
                catch (Exception ex)
                {
                    Logging.Error(ex, "There was a problem reloading an existing PDF from existing metadata, so overwriting it!");

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

            return(pdf_document);
        }