public void Resend_archive_with_files_in_folder() { var file = "price_in_dir.zip"; var priceFile = "price.txt"; source.SourceType = PriceSourceType.Lan; source.PricePath = file; source.ExtrMask = priceFile; source.Save(); PriceDownloadLog downloadLog; using (var scope = new TransactionScope(OnDispose.Rollback)) { downloadLog = new PriceDownloadLog { Addition = String.Empty, ArchFileName = file, ExtrFileName = priceFile, Host = Environment.MachineName, LogTime = DateTime.Now, PriceItemId = priceItem.Id, ResultCode = 2 }; downloadLog.Save(); scope.VoteCommit(); } var priceSrcPath = Path.Combine(DataDirectory, file); var priceDestPath = Path.Combine(Settings.Default.HistoryPath, downloadLog.Id + Path.GetExtension(file)); File.Copy(priceSrcPath, priceDestPath, true); WcfCallResendPrice(downloadLog.Id); Assert.That(PriceItemList.list.FirstOrDefault(i => i.PriceItemId == priceItem.Id), Is.Not.Null, "Прайса нет в очереди на формализацию"); }
public void Copy_source_file_resend_price() { var sourceFileName = "6905885.eml"; var archFileName = "сводныйпрайсч.rar"; //"prs.txt"; var externalFileName = "сводныйпрайсч.txt"; // archFileName; var email = "*****@*****.**"; source.SourceType = PriceSourceType.Email; source.EmailFrom = email; source.EmailTo = email; source.PricePath = archFileName; source.ExtrMask = externalFileName; source.Save(); PriceDownloadLog downloadLog; using (var scope = new TransactionScope(OnDispose.Rollback)) { downloadLog = new PriceDownloadLog { Addition = String.Empty, ArchFileName = archFileName, ExtrFileName = externalFileName, Host = Environment.MachineName, LogTime = DateTime.Now, PriceItemId = priceItem.Id, ResultCode = 2 }; downloadLog.Save(); scope.VoteCommit(); } var priceSrcPath = DataDirectory + Path.DirectorySeparatorChar + sourceFileName; var priceDestPath = Settings.Default.HistoryPath + Path.DirectorySeparatorChar + downloadLog.Id + Path.GetExtension(sourceFileName); File.Copy(priceSrcPath, priceDestPath, true); WcfCallResendPrice(downloadLog.Id); var files = Directory.GetFiles(Settings.Default.HistoryPath); Assert.That(files.Length, Is.EqualTo(2)); Assert.That(Path.GetExtension(files[0]), Is.EqualTo(Path.GetExtension(files[1]))); }
public void Resend_eml_price() { var file = "price1.zip"; source.SourceType = PriceSourceType.Email; source.EmailFrom = "*****@*****.**"; source.EmailTo = "*****@*****.**"; source.PricePath = file; source.ExtrMask = "price.txt"; source.Save(); PriceDownloadLog downloadLog; using (var scope = new TransactionScope(OnDispose.Rollback)) { downloadLog = new PriceDownloadLog { Addition = String.Empty, ArchFileName = file, ExtrFileName = "price.txt", Host = Environment.MachineName, LogTime = DateTime.Now, PriceItemId = priceItem.Id, ResultCode = 2 }; downloadLog.Save(); scope.VoteCommit(); } using (var sw = new FileStream(Path.Combine(Settings.Default.HistoryPath, downloadLog.Id + ".eml"), FileMode.CreateNew)) { var attachments = new List <string> { Path.Combine(DataDirectory, file) }; var message = ImapHelper.BuildMessageWithAttachments("*****@*****.**", "*****@*****.**", attachments.ToArray()); var bytes = message.ToByteData(); sw.Write(bytes, 0, bytes.Length); } WcfCallResendPrice(downloadLog.Id); Assert.That(PriceItemList.list.FirstOrDefault(i => i.PriceItemId == priceItem.Id), Is.Not.Null, "Прайса нет в очереди на формализацию"); Assert.IsFalse(File.Exists(Path.Combine(Path.GetTempPath(), file)), "Не удален временный файл из темп"); }