Esempio n. 1
0
        private IEnumerable <BillBase> GenerateBills(IEnumerable <MultiFileMessage> messages, BillType type, string saveFolderName)
        {
            TextExtractor textExtractor = new TextExtractor();

            foreach (MultiFileMessage message in messages)
            {
                foreach (FileModel file in message.Files)
                {
                    Debug.Assert(file != null);

                    string localFilePath = _fileManager.CopyToLocalStorage(file, saveFolderName);

                    string   fullText = textExtractor.ExtractFullText(localFilePath);
                    BillBase bill     = BillBase.CreateBill(type, fullText);

                    string readableFilename = Path.Combine(Path.GetDirectoryName(localFilePath), GetBillFilename(bill));
                    if (!File.Exists(readableFilename))
                    {
                        File.Copy(localFilePath, readableFilename);
                    }

                    yield return(bill);
                }
            }
        }