Exemplo n.º 1
0
 public static ContentCharacterizer GetInstance()
 {
     if (_single == null)
     {
         _single = new ContentCharacterizer();
     }
     return(_single);
 }
Exemplo n.º 2
0
        public Document(IFormFile FileForUpload, DateTime uploadDate)
        {
            Filename = FileForUpload.FileName;
            LoadDate = uploadDate;

            if (FileForUpload.ContentType.Contains("pdf"))
            {
                Contents = ReadPdfDocument(FileForUpload);
            }
            else if (FileForUpload.ContentType.Contains("openxml"))
            {
                Contents = ReadWordDocument(FileForUpload);
            }
            else if (FileForUpload.ContentType.Contains("image"))
            {
                Contents = ReadImageDocument(FileForUpload);
            }
            else
            {
                Contents = ReadTextDocument(FileForUpload);
            }

            ContentCharacterizer characterizer = ContentCharacterizer.GetInstance();

            Type = characterizer.GetDocumentType(Contents);

            IssueDate = characterizer.GetIssuingDate(Contents);

            List <string> companyNames = characterizer.GetCompanyNames(Contents);

            NamedCompanies = characterizer.GetConcatenatedNames(companyNames);

            List <string> namedParts = characterizer.GetNames(Contents);

            foreach (string companyName in companyNames)
            {
                namedParts.Remove(companyName);
            }

            NamedParts = characterizer.GetConcatenatedNames(namedParts);

            NotaryName = characterizer.GetNotary(Contents);

            PersonIDs = characterizer.GetConcatenatedIDs(Contents);
            if (String.IsNullOrEmpty(PersonIDs))
            {
                PersonIDs = "(No se detectaron)";
            }

            SuccessfullyProcessed = (Contents.StartsWith("Failed to ") ? false: true);
        }