1
This commit is contained in:
parent
ea5afbeaf6
commit
e5c8b35348
@ -1,138 +1,133 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UniversityBusinessLogics.MailWorker;
|
using UniversityBusinessLogics.MailWorker;
|
||||||
using UniversityBusinessLogics.OfficePackage;
|
using UniversityBusinessLogics.OfficePackage;
|
||||||
using UniversityContracts.BindingModels;
|
using UniversityContracts.BindingModels;
|
||||||
using UniversityContracts.BusinessLogicContracts;
|
using UniversityContracts.BusinessLogicContracts;
|
||||||
using UniversityContracts.StoragesContracts;
|
using UniversityContracts.StoragesContracts;
|
||||||
|
|
||||||
namespace UniversityBusinessLogics.BusinessLogic
|
namespace UniversityBusinessLogics.BusinessLogics;
|
||||||
|
|
||||||
|
public class ReportLogic : IReportLogic
|
||||||
{
|
{
|
||||||
public class ReportLogic : IReportLogic
|
private readonly AbstractSaveToWord _saveToWord;
|
||||||
{
|
private readonly IPurchaseStorage _purchaseStorage;
|
||||||
private readonly AbstractSaveToWord _saveToWord;
|
private readonly IOperationStorage _carStorage;
|
||||||
private readonly IPurchaseStorage _purchaseStorage;
|
private readonly AbstractSaveToExcel _saveToExcel;
|
||||||
private readonly IOperationStorage _carStorage;
|
private readonly IPaymentStorage _paymentStorage;
|
||||||
private readonly AbstractSaveToExcel _saveToExcel;
|
private readonly AbstractMailWorker _mailWorker;
|
||||||
private readonly IPaymentStorage _paymentStorage;
|
private readonly AbstractSaveToPdf _saveToPdf;
|
||||||
private readonly AbstractMailWorker _mailWorker;
|
|
||||||
private readonly AbstractSaveToPdf _saveToPdf;
|
|
||||||
|
|
||||||
public ReportLogic(AbstractSaveToWord saveToWord, IPurchaseStorage purchaseStorage, AbstractSaveToExcel saveToExcel,
|
public ReportLogic(AbstractSaveToWord saveToWord, IPurchaseStorage purchaseStorage, AbstractSaveToExcel saveToExcel,
|
||||||
AbstractMailWorker mailWorker, IPaymentStorage paymentStorage, AbstractSaveToPdf saveToPdf, IOperationStorage carStorage)
|
AbstractMailWorker mailWorker, IPaymentStorage paymentStorage, AbstractSaveToPdf saveToPdf, IOperationStorage carStorage)
|
||||||
{
|
{
|
||||||
_mailWorker = mailWorker;
|
_mailWorker = mailWorker;
|
||||||
_paymentStorage = paymentStorage;
|
_paymentStorage = paymentStorage;
|
||||||
_saveToExcel = saveToExcel;
|
_saveToExcel = saveToExcel;
|
||||||
_saveToWord = saveToWord;
|
_saveToWord = saveToWord;
|
||||||
_purchaseStorage = purchaseStorage;
|
_purchaseStorage = purchaseStorage;
|
||||||
_saveToPdf = saveToPdf;
|
_saveToPdf = saveToPdf;
|
||||||
_carStorage = carStorage;
|
_carStorage = carStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SavePurchasesToWord(ReportBindingModel option)
|
public void SavePurchasesToWord(ReportBindingModel option)
|
||||||
{
|
{
|
||||||
_saveToWord.CreateDoc(new()
|
_saveToWord.CreateDoc(new()
|
||||||
{
|
{
|
||||||
FileName = option.FileName,
|
FileName = option.FileName,
|
||||||
Stream = option.Stream,
|
Stream = option.Stream,
|
||||||
Title = "Список сделок вместе с операциями",
|
Title = "Список сделок вместе с операциями",
|
||||||
ReportObjects = _purchaseStorage.GetFilteredList(new() { OperationsIds = option.Ids.ToList() })
|
ReportObjects = _purchaseStorage.GetFilteredList(new() { OperationsIds = option.Ids.ToList() })
|
||||||
.Select(x => (object)x).ToList(),
|
.Select(x => (object)x).ToList(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SavePurchasesToExcel(ReportBindingModel option)
|
public void SavePurchasesToExcel(ReportBindingModel option)
|
||||||
{
|
{
|
||||||
_saveToExcel.CreateReportPurchase(new()
|
_saveToExcel.CreateReportPurchase(new()
|
||||||
{
|
{
|
||||||
FileName = option.FileName,
|
FileName = option.FileName,
|
||||||
Stream = option.Stream,
|
Stream = option.Stream,
|
||||||
Title = "Список сделок вместе с операциями",
|
Title = "Список сделок вместе с операциями",
|
||||||
ReportObjects = _purchaseStorage.GetFilteredList(new() { OperationsIds = option.Ids.ToList() })
|
ReportObjects = _purchaseStorage.GetFilteredList(new() { OperationsIds = option.Ids.ToList() })
|
||||||
.Select(x => (object)x).ToList(),
|
.Select(x => (object)x).ToList(),
|
||||||
Headers = new() { "Сделка", "Дата сделки", }
|
Headers = new() { "Сделка", "Дата сделки",}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendPaymentsToEmail(ReportDateRangeBindingModel option, string email)
|
public void SendPaymentsToEmail(ReportDateRangeBindingModel option, string email)
|
||||||
{
|
{
|
||||||
var payments = _paymentStorage.GetFilteredList(new()
|
var payments = _paymentStorage.GetFilteredList(new()
|
||||||
{
|
{
|
||||||
DateFrom = option.DateFrom,
|
DateFrom = option.DateFrom,
|
||||||
DateTo = option.DateTo,
|
DateTo = option.DateTo,
|
||||||
});
|
});
|
||||||
option.Stream = new MemoryStream();
|
option.Stream = new MemoryStream();
|
||||||
_saveToPdf.CreateDocForPayments(new()
|
_saveToPdf.CreateDocForPayments(new()
|
||||||
{
|
{
|
||||||
DateFrom = option.DateFrom,
|
DateFrom = option.DateFrom,
|
||||||
DateTo = option.DateTo,
|
DateTo = option.DateTo,
|
||||||
Stream = option.Stream,
|
Stream = option.Stream,
|
||||||
Title = "Данные по операциям с оплатами за период",
|
Title = "Данные по операциям с оплатами за период",
|
||||||
ReportObjects = payments.Select(x => (object)x).ToList()
|
ReportObjects = payments.Select(x => (object)x).ToList()
|
||||||
});
|
});
|
||||||
|
|
||||||
_mailWorker.MailSendAsync(new()
|
_mailWorker.MailSendAsync(new()
|
||||||
{
|
{
|
||||||
FilesStreams = new() { new(option.Stream, "report.pdf") },
|
FilesStreams = new() { new(option.Stream, "report.pdf") },
|
||||||
Subject = $"Отчет по оплатам за {option.DateFrom.ToShortDateString()}-{option.DateTo.ToShortDateString()}",
|
Subject = $"Отчет по оплатам за {option.DateFrom.ToShortDateString()}-{option.DateTo.ToShortDateString()}",
|
||||||
MailAddress = email,
|
MailAddress = email,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveOperationsToWord(ReportBindingModel option)
|
public void SaveOperationsToWord(ReportBindingModel option)
|
||||||
{
|
{
|
||||||
_saveToWord.CreateDoc(new()
|
_saveToWord.CreateDoc(new()
|
||||||
{
|
{
|
||||||
FileName = option.FileName,
|
FileName = option.FileName,
|
||||||
Stream = option.Stream,
|
Stream = option.Stream,
|
||||||
Title = "Список операций вместе с сделками",
|
Title = "Список операций вместе с сделками",
|
||||||
ReportObjects = _carStorage.GetFilteredList(new() { PurchasesIds = option.Ids.ToList() })
|
ReportObjects = _carStorage.GetFilteredList(new() { PurchasesIds = option.Ids.ToList() })
|
||||||
.Select(x => (object)x).ToList(),
|
.Select(x => (object)x).ToList(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveOperationsToExcel(ReportBindingModel option)
|
public void SaveOperationsToExcel(ReportBindingModel option)
|
||||||
{
|
{
|
||||||
_saveToExcel.CreateReportOperations(new()
|
_saveToExcel.CreateReportOperations(new()
|
||||||
{
|
{
|
||||||
FileName = option.FileName,
|
FileName = option.FileName,
|
||||||
Stream = option.Stream,
|
Stream = option.Stream,
|
||||||
Ids = option.Ids.ToList(),
|
Ids = option.Ids.ToList(),
|
||||||
Title = "Список операций вместе с сделками",
|
Title = "Список операций вместе с сделками",
|
||||||
ReportObjects = _carStorage.GetFilteredList(new() { PurchasesIds = option.Ids.ToList() })
|
ReportObjects = _carStorage.GetFilteredList(new() { PurchasesIds = option.Ids.ToList() })
|
||||||
.Select(x => (object)x).ToList(),
|
.Select(x => (object)x).ToList(),
|
||||||
Headers = new() { "Вид", "Тип", "Дата" }
|
Headers = new() { "Вид", "Тип", "Дата"}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendCostsToEmail(ReportDateRangeBindingModel option, string email)
|
public void SendCostsToEmail(ReportDateRangeBindingModel option, string email)
|
||||||
{
|
{
|
||||||
var purchaseVisit = _purchaseStorage.GetFilteredList(new()
|
var purchaseVisit = _purchaseStorage.GetFilteredList(new()
|
||||||
{
|
{
|
||||||
DateFrom = option.DateFrom,
|
DateFrom = option.DateFrom,
|
||||||
DateTo = option.DateTo,
|
DateTo = option.DateTo,
|
||||||
});
|
});
|
||||||
option.Stream = new MemoryStream();
|
option.Stream = new MemoryStream();
|
||||||
_saveToPdf.CreateDocForPurchases(new()
|
_saveToPdf.CreateDocForPurchases(new()
|
||||||
{
|
{
|
||||||
DateFrom = option.DateFrom,
|
DateFrom = option.DateFrom,
|
||||||
DateTo = option.DateTo,
|
DateTo = option.DateTo,
|
||||||
Stream = option.Stream,
|
Stream = option.Stream,
|
||||||
Title = "Данные по сделке со статьями затрат за период",
|
Title = "Данные по сделке со статьями затрат за период",
|
||||||
ReportObjects = purchaseVisit.Select(x => (object)x).ToList()
|
ReportObjects = purchaseVisit.Select(x => (object)x).ToList()
|
||||||
});
|
});
|
||||||
|
|
||||||
_mailWorker.MailSendAsync(new()
|
_mailWorker.MailSendAsync(new()
|
||||||
{
|
{
|
||||||
FilesStreams = new() { new(option.Stream, "report.pdf") },
|
FilesStreams = new() { new(option.Stream, "report.pdf") },
|
||||||
Subject = $"Отчет по статьям затрат за {option.DateFrom.ToShortDateString()}-{option.DateTo.ToShortDateString()}",
|
Subject = $"Отчет по статьям затрат за {option.DateFrom.ToShortDateString()}-{option.DateTo.ToShortDateString()}",
|
||||||
MailAddress = email,
|
MailAddress = email,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -188,17 +188,17 @@ namespace UniversityBusinessLogics.OfficePackage.Implements
|
|||||||
_shareStringPart.SharedStringTable = new SharedStringTable();
|
_shareStringPart.SharedStringTable = new SharedStringTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Создаем лист в книгу
|
// Create a new worksheet part
|
||||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
var workbookPart = _spreadsheetDocument.AddWorkbookPart();
|
||||||
worksheetPart.Worksheet = new Worksheet(new SheetData());
|
workbookPart.Workbook = new Workbook();
|
||||||
|
|
||||||
// Добавляем лист в книгу
|
// Set the new worksheet as the active worksheet
|
||||||
var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
|
var sheets = workbookPart.Workbook.AppendChild(new Sheets());
|
||||||
var sheet = new Sheet()
|
var sheet = new Sheet
|
||||||
{
|
{
|
||||||
Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||||
SheetId = 1,
|
SheetId = (uint)sheets.ChildElements.Count + 1,
|
||||||
Name = "Лист"
|
Name = "Sheet1" // You can change the name as needed
|
||||||
};
|
};
|
||||||
sheets.Append(sheet);
|
sheets.Append(sheet);
|
||||||
|
|
||||||
@ -290,10 +290,7 @@ namespace UniversityBusinessLogics.OfficePackage.Implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mergeCell = new MergeCell()
|
var mergeCell = new MergeCell { Reference = excelParams.Merge };
|
||||||
{
|
|
||||||
Reference = new StringValue(excelParams.Merge)
|
|
||||||
};
|
|
||||||
mergeCells.Append(mergeCell);
|
mergeCells.Append(mergeCell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Serilog;
|
using Serilog;
|
||||||
using UniversityBusinessLogics.BusinessLogic;
|
using UniversityBusinessLogics.BusinessLogic;
|
||||||
|
using UniversityBusinessLogics.BusinessLogics;
|
||||||
using UniversityBusinessLogics.MailWorker;
|
using UniversityBusinessLogics.MailWorker;
|
||||||
using UniversityBusinessLogics.OfficePackage;
|
using UniversityBusinessLogics.OfficePackage;
|
||||||
using UniversityBusinessLogics.OfficePackage.Implements;
|
using UniversityBusinessLogics.OfficePackage.Implements;
|
||||||
|
Loading…
Reference in New Issue
Block a user