Exemplo n.º 1
0
        public void Parse_waybill_if_parsing_enabled()
        {
            client   = TestClient.CreateNaked(session);
            supplier = TestSupplier.CreateNaked(session);

            var beign = DateTime.Now;

            //Удаляем миллисекунды из даты, т.к. они не сохраняются в базе данных
            beign = beign.AddMilliseconds(-beign.Millisecond);

            var email = String.Format("edata{0}@msk.katren.ru", supplier.Id);

            supplier.WaybillSource.EMailFrom  = email;
            supplier.WaybillSource.SourceType = TestWaybillSourceType.Email;
            session.Save(supplier);
            session.Save(client);

            ImapHelper.ClearImapFolder();
            ImapHelper.StoreMessageWithAttachToImapFolder(
                String.Format("{0}@waybills.analit.net", client.Addresses[0].Id),
                email,
                @"..\..\Data\Waybills\8916.dbf");

            Process();

            var files = GetFileForAddress(DocType.Waybill);

            Assert.That(files.Length, Is.EqualTo(1));

            var logs = session.Query <TestDocumentLog>().Where(d => d.Client.Id == client.Id).ToList();

            Assert.That(logs.Count, Is.EqualTo(1));
            var log     = logs.Single();
            var logTime = log.LogTime;

            Assert.That(logTime.Date.AddHours(logTime.Hour).AddMinutes(logTime.Minute).AddSeconds(logTime.Second),
                        Is.GreaterThanOrEqualTo(beign.Date.AddHours(beign.Hour).AddMinutes(beign.Minute).AddSeconds(beign.Second)));
            Assert.That(log.DocumentSize, Is.GreaterThan(0));

            var documents = session.Query <Document>().Where(d => d.Log.Id == log.Id).ToList();

            Assert.That(documents.Count, Is.EqualTo(1));
            Assert.That(documents.Single().Lines.Count, Is.EqualTo(7));
        }
Exemplo n.º 2
0
        public void Parse_reject()
        {
            client   = TestClient.CreateNaked(session);
            supplier = TestSupplier.CreateNaked(session);
            var price           = supplier.Prices[0];
            var productSynonym  = price.AddProductSynonym("юниэнзим с МПС таб п/о N20", session.Query <TestProduct>().First());
            var producerSynonym = price.AddProducerSynonym("юникем Лабора", session.Query <TestProducer>().First());

            var email = String.Format("edata{0}@msk.katren.ru", supplier.Id);

            supplier.WaybillSource.EMailFrom  = email;
            supplier.WaybillSource.SourceType = TestWaybillSourceType.Email;
            supplier.RejectParser             = "NadezhdaFarm7579RejectParser";
            session.Save(supplier);
            session.Save(client);

            ImapHelper.ClearImapFolder();
            ImapHelper.StoreMessageWithAttachToImapFolder(
                String.Format("{0}@refused.analit.net", client.Addresses[0].Id),
                email,
                @"..\..\Data\Rejects\35115498_Надежда-Фарм Орел_Фарма Орел(protocol).txt");

            Process();

            var files = GetFileForAddress(DocType.Reject);

            Assert.That(files.Length, Is.EqualTo(1));

            var logs = session.Query <TestDocumentLog>().Where(d => d.Client.Id == client.Id).ToList();

            Assert.That(logs.Count, Is.EqualTo(1));
            var log = logs.Single();

            Assert.That(log.DocumentSize, Is.GreaterThan(0));
            Assert.AreEqual(DocumentType.Reject, log.DocumentType);
            var reject = session.Query <RejectHeader>().FirstOrDefault(r => r.Supplier.Id == supplier.Id);

            Assert.AreEqual(1, reject.Lines.Count);
            Assert.AreEqual("NadezhdaFarm7579RejectParser", reject.Parser);
            Assert.AreEqual(productSynonym.Product.Id, reject.Lines[0].ProductEntity.Id);
            Assert.AreEqual(producerSynonym.Producer.Id, reject.Lines[0].ProducerEntity.Id);
        }
        public void EmailPriceInPasswordProtectedArchiveProcessingTest()
        {
            var email = "*****@*****.**";

            source.EmailFrom       = email;
            source.EmailTo         = email;
            source.PriceMask       = "1.zip";
            source.ExtrMask        = "*.txt";
            source.ArchivePassword = "******";
            source.Save();

            // Кладем в IMAP папку сообщение с вложениями
            ImapHelper.StoreMessageWithAttachToImapFolder(Settings.Default.TestIMAPUser,
                                                          Settings.Default.TestIMAPPass, Settings.Default.IMAPSourceFolder,
                                                          email, email, Path.Combine(_dataDir, "1.zip"));

            // Запускаем обработчик
            Process();

            Assert.IsTrue(PriceItemList.list.Any(l => l.PriceItemId == priceItem.Id), "Ошибка обработки файла. Файл не поставлен в очередь на формализацию");
        }