Пример #1
0
        private AuthorData convertAuthorDataFrom(IDataReader reader)
        {
            Guid          metaDataGuid = new Guid(Convert.ToString(reader[METADATA_ID]));
            List <Author> authors      = _authorTable.GetAllAuthorsOf(metaDataGuid);
            AuthorData    result       = new AuthorData(metaDataGuid, authors);

            result.ShowInPreview = Convert.ToBoolean(reader[METADATA_SHOWINPREVIEW]);
            return(result);
        }
Пример #2
0
        private AuthorData extractAuthors(PdfDocumentInfo info)
        {
            string[] authors = separate(info.GetAuthor());
            if (authors.Length == 0)
            {
                return(null);
            }
            AuthorData result = _metaDataFactory.CreateNew(MetaDataType.Author) as AuthorData;

            foreach (string author in authors)
            {
                result.Add(new Author(Guid.NewGuid(), author));
            }
            return(result);
        }
Пример #3
0
        public Result Extract()
        {
            PdfDocumentInfo info;

            using (FileStream fileStream = File.OpenRead(_path))
            {
                PdfReader   reader      = new PdfReader(fileStream);
                PdfDocument pdfDocument = new PdfDocument(reader);
                info = pdfDocument.GetDocumentInfo();
            }
            TitleData  title   = extractTitle(info);
            AuthorData authors = extractAuthors(info);
            TagsData   tags    = extractTags(info);

            return(new Result(title, authors, tags));
        }
Пример #4
0
        public void AddOrReplace(MetaData metaData, Guid entryID)
        {
            string inhalt;

            switch (metaData.Type)
            {
            case MetaDataType.CreationDate:
                CreationDateData cdd = (CreationDateData)metaData;
                inhalt = cdd.Date.ToString();
                break;

            case MetaDataType.LastChangedDate:
                LastChangeDateData lcd = (LastChangeDateData)metaData;
                inhalt = lcd.Date.ToString();
                break;

            case MetaDataType.Title:
                TitleData td = (TitleData)metaData;
                inhalt = td.Content;
                break;

            case MetaDataType.Author:
                AuthorData ad = (AuthorData)metaData;
                inhalt = string.Empty;
                List <Author> authors = ad.AuthorsCopy;
                foreach (Author author in authors)
                {
                    _authorTable.AddOrReplace(author, metaData.ID);
                }
                break;

            case MetaDataType.Tags:
                TagsData tad = (TagsData)metaData;
                inhalt = string.Empty;
                List <Tag> tags = tad.TagsCopy;
                foreach (Tag tag in tags)
                {
                    _tagsTable.AddOrReplace(tag, metaData);
                }
                break;

            case MetaDataType.Comment:
                CommentData commentData = (CommentData)metaData;
                inhalt = commentData.Content;
                break;

            case MetaDataType.Description:
                DescriptionData descriptionData = (DescriptionData)metaData;
                inhalt = descriptionData.Content;
                break;

            case MetaDataType.PreviewImage:
                PreviewImageData previewData = (PreviewImageData)metaData;
                inhalt = previewData.IsEmpty ? string.Empty : previewData.Uri.AbsoluteUri;
                break;

            default:
                throw new NotImplementedException();
            }
            string command = createAddOrReplaceMetaDataCommand(metaData, inhalt, entryID);

            executeNonQuery(command);
        }
Пример #5
0
 public Result(TitleData title, AuthorData authors, TagsData tags)
 {
     Title   = title;
     Authors = authors;
     Tags    = tags;
 }