public override ImportResult Import() { using (var fileBuffer = new FileBuffer(DbfFilename, FileBuffer.BufferType.Read)) { dbfRegistry = new DbfRegistryController(fileBuffer.BufferFilename); return(base.Import()); } }
protected override ExportResult TryExportItems(IEnumerable <RepairPayment> repairPayments) { if (repairPayments == null) { return(new ExportResult()); } var paymentsForExport = repairPayments .Where(repairPayment => repairPayment != null) .Select(repairPayment => new DbfGarbageOrRepairPayment( repairPayment.FinancialPeriodCode, repairPayment.CreateDate, repairPayment.CreateDate, repairPayment.FilialCode, repairPayment.OrganizationCode, repairPayment.CustomerNumber, Utils.RubToCopeck(repairPayment.Cost))); var countItemsForExport = paymentsForExport.Count(); if (countItemsForExport == 0) { return(new ExportResult()); } var dbfFilename = Path.Combine(Config.OutputDirectory, string.Format(Config.RepairPaymentsDbfOutputFileFormat, DateTime.Now)); Exception exportException = null; try { using (var fileBuffer = new FileBuffer(dbfFilename, FileBuffer.BufferType.Create)) { try { var dbfRegistry = new DbfRegistryController(fileBuffer.BufferFilename); dbfRegistry.StoreGarbageCollectionPayments(paymentsForExport); } catch (Exception ex) { exportException = ex; } } } finally { if (exportException != null) { throw exportException; } } return(new ExportResult(countItemsForExport, repairPayments.Count() - countItemsForExport)); }
protected override ExportResult TryExportItems(IEnumerable <WaterCustomerPayment> waterCustomerPayments) { if (waterCustomerPayments == null) { return(new ExportResult()); } var paymentsForExport = waterCustomerPayments .Where(waterCustomerPayment => waterCustomerPayment != null) .Select(waterCustomerPayment => new DbfWaterCustomerPayment( waterCustomerPayment.CreateDate, waterCustomerPayment.WaterCustomer.Number, waterCustomerPayment.Cost, waterCustomerPayment.CreateDate.ToString("yyyyMM"), waterCustomerPayment.Penalty, waterCustomerPayment.WaterCustomer.CounterNumber1, 0, waterCustomerPayment.CounterValue1, waterCustomerPayment.WaterCustomer.CounterNumber2, 0, waterCustomerPayment.CounterValue2, waterCustomerPayment.WaterCustomer.CounterNumber3, 0, waterCustomerPayment.CounterValue3, waterCustomerPayment.WaterCustomer.CounterNumber4, 0, waterCustomerPayment.CounterValue4)); var countItemsForExport = paymentsForExport.Count(); if (countItemsForExport == 0) { return(new ExportResult()); } var dbfFilename = Path.Combine(Config.OutputDirectory, string.Format(Config.WaterCustomerDbfOutputFileFormat, DateTime.Now)); Exception exportException = null; try { using (var fileBuffer = new FileBuffer(dbfFilename, FileBuffer.BufferType.Create)) { try { var dbfRegistry = new DbfRegistryController(fileBuffer.BufferFilename); dbfRegistry.StoreWaterCustomerPayments(paymentsForExport); } catch (Exception ex) { exportException = ex; } } } finally { if (exportException != null) { throw exportException; } } return(new ExportResult(countItemsForExport, waterCustomerPayments.Count() - countItemsForExport)); }
protected override ExportResult TryExportItems(IEnumerable <ArticleSale> articleSales) { if (articleSales == null) { return(new ExportResult()); } string targetExportDirectory = Path.Combine(Config.OutputDirectory, string.Format("{0:dd-MM-yyyy_HH-mm-ss} ({1:dd-MM-yyyy_HH-mm-ss}___{2:dd-MM-yyyy_HH-mm-ss})", DateTime.Now, beginDatetime, endDatetime)); if (Directory.Exists(targetExportDirectory)) { Directory.Delete(targetExportDirectory); } int exportedArticleSalesCount = 0; foreach (ArticleSale articleSale in articleSales) { if (articleSale == null) { continue; } var salesForExport = new List <DbfArticleSale>(); salesForExport.Add(new DbfArticleSale( articleSale.CreateDate, Utils.GetDepartmentDocumentNumber(), Settings.ArticlesWarehouseCode, Settings.ArticlesWarehouseName, string.Empty, string.Empty, 0, 0, 0, 0, // TODO string.Empty, // TODO string.Empty // TODO )); salesForExport.Add(new DbfArticleSale( DateTime.MinValue, string.Empty, string.Empty, string.Empty, articleSale.ArticlePrice.Article.Code, articleSale.ArticlePrice.Article.Name, articleSale.Quantity, articleSale.ArticlePrice.Value, (decimal)articleSale.Quantity * articleSale.ArticlePrice.Value, 0, // TODO string.Empty, // TODO string.Empty // TODO )); var dbfFilename = Path.Combine(targetExportDirectory, string.Format( Config.ArticlesSeparatedDbfOutputFileFormat, Settings.ArticlesWarehouseCode, Settings.ArticlesDocumentNumberCurrentValue.ToString("D5"))); Exception exportException = null; try { using (var fileBuffer = new FileBuffer(dbfFilename, FileBuffer.BufferType.Create)) { try { var dbfRegistry = new DbfRegistryController(fileBuffer.BufferFilename); dbfRegistry.StoreArticleSales(salesForExport); } catch (Exception ex) { exportException = ex; } } } finally { if (exportException != null) { throw exportException; } } Settings.ArticlesDocumentNumberCurrentValue++; Settings.Save(); exportedArticleSalesCount++; } if (exportedArticleSalesCount <= 0) { return(new ExportResult()); } return(new ExportResult(exportedArticleSalesCount, articleSales.Count() - exportedArticleSalesCount)); }
protected override ExportResult TryExportItems(IEnumerable <ArticleSale> articleSales) { if (articleSales == null) { return(new ExportResult()); } var salesForExport = new List <DbfArticleSale>(); salesForExport.Add(new DbfArticleSale( DateTime.Now, Utils.GetDepartmentDocumentNumber(), Settings.ArticlesWarehouseCode, Settings.ArticlesWarehouseName, string.Empty, string.Empty, 0, 0, 0, 0, // TODO string.Empty, // TODO string.Empty // TODO )); salesForExport.AddRange(articleSales .Where(articleSale => articleSale != null) .Select(articleSale => new DbfArticleSale( DateTime.MinValue, string.Empty, string.Empty, string.Empty, articleSale.ArticlePrice.Article.Code, articleSale.ArticlePrice.Article.Name, articleSale.Quantity, articleSale.ArticlePrice.Value, (decimal)articleSale.Quantity * articleSale.ArticlePrice.Value, 0, // TODO string.Empty, // TODO string.Empty // TODO ))); var countItemsForExport = salesForExport.Count() - 1; if (countItemsForExport <= 0) { return(new ExportResult()); } var dbfFilename = Path.Combine(Config.OutputDirectory, string.Format(Config.ArticlesDbfOutputFileFormat, DateTime.Now)); Exception exportException = null; try { using (var fileBuffer = new FileBuffer(dbfFilename, FileBuffer.BufferType.Create)) { try { var dbfRegistry = new DbfRegistryController(fileBuffer.BufferFilename); dbfRegistry.StoreArticleSales(salesForExport); } catch (Exception ex) { exportException = ex; } } } finally { if (exportException != null) { throw exportException; } } Settings.ArticlesDocumentNumberCurrentValue++; return(new ExportResult(countItemsForExport, articleSales.Count() - countItemsForExport)); }