правки 1

This commit is contained in:
GokaPek 2024-04-09 22:12:15 +04:00
parent 78d888b600
commit 87a199d096
30 changed files with 120 additions and 125 deletions

View File

@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="1.50.5147" />
<PackageReference Include="PDFsharp-MigraDoc" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -1,5 +1,5 @@
using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels;
using AbstractLawFirmBusinessLogic.OfficePackage;
using AbstractLawFirmBusinessLogic.OfficePackage;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels;
using AbstractLawFirmContracts.BindingModels;
using AbstractLawFirmContracts.BusinessLogicsContracts;
using AbstractLawFirmContracts.SearchModels;
@ -11,7 +11,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractLawFirmBusinessLogic
namespace AbstractLawFirmBusinessLogic.BusinessLogic
{
public class ReportLogic : IReportLogic
{
@ -39,24 +39,20 @@ namespace AbstractLawFirmBusinessLogic
/// <returns></returns>
public List<ReportDocumentComponentViewModel> GetDocumentComponent()
{
var components = _componentStorage.GetFullList();
var documents = _documentStorage.GetFullList();
var list = new List<ReportDocumentComponentViewModel>();
foreach (var component in components)
foreach (var document in documents)
{
var record = new ReportDocumentComponentViewModel
{
ComponentName = component.ComponentName,
Document = new List<Tuple<string, int>>(),
DocumentName = document.DocumentName,
Components = new List<(string Component, int Count)>(),
TotalCount = 0
};
foreach (var document in documents)
foreach (var component in document.DocumentComponents.Values)
{
if (document.DocumentComponents.ContainsKey(component.Id))
{
record.Document.Add(new Tuple<string, int>(document.DocumentName, document.DocumentComponents[component.Id].Item2));
record.TotalCount += document.DocumentComponents[component.Id].Item2;
}
record.Components.Add((component.Item1.ComponentName, component.Item2));
record.TotalCount += component.Item2;
}
list.Add(record);
}
@ -71,7 +67,8 @@ namespace AbstractLawFirmBusinessLogic
{
return _orderStorage.GetFilteredList(new OrderSearchModel
{
DateFrom = model.DateFrom,
DateFrom
= model.DateFrom,
DateTo = model.DateTo
})
.Select(x => new ReportOrdersViewModel
@ -79,7 +76,8 @@ namespace AbstractLawFirmBusinessLogic
Id = x.Id,
DateCreate = x.DateCreate,
DocumentName = x.DocumentName,
Sum = x.Sum
Sum = x.Sum,
Status = x.Status.ToString(),
})
.ToList();
}
@ -87,13 +85,13 @@ namespace AbstractLawFirmBusinessLogic
/// Сохранение компонент в файл-Word
/// </summary>
/// <param name="model"></param>
public void SaveComponentsToWordFile(ReportBindingModel model)
public void SaveDocumentsToWordFile(ReportBindingModel model)
{
_saveToWord.CreateDoc(new WordInfo
{
FileName = model.FileName,
Title = "Список компонент",
Components = _componentStorage.GetFullList()
Title = "Список пакетов документов",
Documents = _documentStorage.GetFullList()
});
}
/// <summary>
@ -124,6 +122,6 @@ namespace AbstractLawFirmBusinessLogic
Orders = GetOrders(model)
});
}
}
}
}

View File

@ -1,10 +1,10 @@
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Office2010.Excel;
using DocumentFormat.OpenXml.Office2013.Excel;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractLawFirmBusinessLogic.OfficePackage
{
@ -30,33 +30,31 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage
CellToName = "C1"
});
uint rowIndex = 2;
foreach (var dc in info.DocumentComponents)
foreach (var pc in info.DocumentComponents)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = dc.ComponentName,
Text = pc.DocumentName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var document in dc.Document)
foreach (var (Component, Count) in pc.Components)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = document.Item1,
StyleInfo =
ExcelStyleInfoType.TextWithBroder
Text = Component,
StyleInfo = ExcelStyleInfoType.TextWithBorder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = document.Item2.ToString(),
StyleInfo =
ExcelStyleInfoType.TextWithBroder
Text = Count.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBorder
});
rowIndex++;
}
@ -71,7 +69,7 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage
{
ColumnName = "C",
RowIndex = rowIndex,
Text = dc.TotalCount.ToString(),
Text = pc.TotalCount.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
@ -101,4 +99,3 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage
protected abstract void SaveExcel(ExcelInfo info);
}
}

View File

@ -1,10 +1,10 @@
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels;
namespace AbstractLawFirmBusinessLogic.OfficePackage
{
@ -16,18 +16,19 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage
CreateParagraph(new PdfParagraph
{
Text = info.Title,
Style =
"NormalTitle",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateParagraph(new PdfParagraph
{
Text = $"с{ info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style= "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center
Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm" });
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "4cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Сумма" },
Texts = new List<string> { "Номер", "Дата заказа", "Пакет документов", "Сумма", "Статус" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
@ -36,7 +37,7 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage
CreateRow(new PdfRowParameters
{
Texts = new List<string> { order.Id.ToString(),
order.DateCreate.ToShortDateString(), order.DocumentName, order.Sum.ToString() },
order.DateCreate.ToShortDateString(), order.DocumentName, order.Sum.ToString(), order.Status },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});

View File

@ -1,10 +1,10 @@
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
namespace AbstractLawFirmBusinessLogic.OfficePackage
{
@ -22,11 +22,14 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage
JustificationType = WordJustificationType.Center
}
});
foreach (var component in info.Components)
foreach (var document in info.Documents)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (component.ComponentName, new WordTextProperties { Size = "24", }) },
Texts = new List<(string, WordTextProperties)> {
(document.DocumentName + " - ", new WordTextProperties { Size = "24", Bold = true}),
(document.Price.ToString(), new WordTextProperties { Size = "24", })
},
TextProperties = new WordTextProperties
{
Size = "24",

View File

@ -10,7 +10,7 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums
{
Title,
Text,
TextWithBroder
TextWithBorder
}
}

View File

@ -10,7 +10,6 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums
{
Center,
Left,
Rigth
}

View File

@ -1,9 +1,9 @@
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperModels
{

View File

@ -1,9 +1,9 @@
using AbstractLawFirmContracts.ViewModels;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AbstractLawFirmContracts.ViewModels;
namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperModels
{
@ -16,6 +16,6 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperModels
get;
set;
} = new();
}
}
}

View File

@ -1,9 +1,9 @@
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperModels
{

View File

@ -1,9 +1,9 @@
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperModels
{
@ -13,5 +13,4 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperModels
public string Style { get; set; } = string.Empty;
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
}
}

View File

@ -11,6 +11,6 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.HelperModels
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ComponentViewModel> Components { get; set; } = new();
public List<DocumentViewModel> Documents { get; set; } = new();
}
}

View File

@ -1,16 +1,16 @@
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels;
using DocumentFormat.OpenXml.Office2010.Excel;
using DocumentFormat.OpenXml.Office2013.Excel;
using DocumentFormat.OpenXml.Office2016.Excel;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.Office2010.Excel;
using DocumentFormat.OpenXml.Office2013.Excel;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
namespace AbstractLawFirmBusinessLogic.OfficePackage.Implements
{
@ -105,8 +105,7 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.Implements
var cellFormatFont = new CellFormat()
{
NumberFormatId = 0U,
FontId =
0U,
FontId = 0U,
FillId = 0U,
BorderId = 0U,
FormatId = 0U,
@ -206,7 +205,7 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.Implements
return styleInfo switch
{
ExcelStyleInfoType.Title => 2U,
ExcelStyleInfoType.TextWithBroder => 1U,
ExcelStyleInfoType.TextWithBorder => 1U,
ExcelStyleInfoType.Text => 0U,
_ => 0U,
};
@ -283,8 +282,8 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.Implements
else
{
// Все ячейки должны быть последовательно друг за другом расположены
// нужно определить, после какой вставлять
Cell? refCell = null;
// нужно определить, после какой вставлять
Cell? refCell = null;
foreach (Cell rowCell in row.Elements<Cell>())
{
if (string.Compare(rowCell.CellReference!.Value,
@ -350,8 +349,8 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.Implements
return;
}
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
//_spreadsheetDocument.Close();
_spreadsheetDocument.Dispose();
}
}
}
}

View File

@ -1,13 +1,13 @@
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels;
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
using MigraDoc.DocumentObjectModel.Tables;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
namespace AbstractLawFirmBusinessLogic.OfficePackage.Implements
{
@ -102,5 +102,6 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.Implements
renderer.RenderDocument();
renderer.PdfDocument.Save(info.FileName);
}
}
}

View File

@ -1,15 +1,14 @@
using System;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperEnums;
using AbstractLawFirmBusinessLogic.OfficePackage.HelperModels;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
namespace AbstractLawFirmBusinessLogic.OfficePackage.Implements
{
public class SaveToWord : AbstractSaveToWord
@ -125,7 +124,8 @@ namespace AbstractLawFirmBusinessLogic.OfficePackage.Implements
}
_docBody.AppendChild(CreateSectionProperties());
_wordDocument.MainDocumentPart!.Document.Save();
//_wordDocument.Close();
_wordDocument.Dispose();
}
}
}

View File

@ -25,7 +25,7 @@ namespace AbstractLawFirmContracts.BusinessLogicsContracts
/// Сохранение компонент в файл-Word
/// </summary>
/// <param name="model"></param>
void SaveComponentsToWordFile(ReportBindingModel model);
void SaveDocumentsToWordFile(ReportBindingModel model);
/// <summary>
/// Сохранение компонент с указаеним продуктов в файл-Excel
/// </summary>

View File

@ -8,8 +8,8 @@ namespace AbstractLawFirmContracts.ViewModels
{
public class ReportDocumentComponentViewModel
{
public string ComponentName { get; set; } = string.Empty;
public string DocumentName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<Tuple<string, int>> Document { get; set; } = new();
public List<(string Component, int Count)> Components { get; set; } = new();
}
}

View File

@ -12,6 +12,6 @@ namespace AbstractLawFirmContracts.ViewModels
public DateTime DateCreate { get; set; }
public string DocumentName { get; set; } = string.Empty;
public double Sum { get; set; }
public String Status { get; set; } = string.Empty;
}
}

View File

@ -42,13 +42,13 @@ namespace AbstractLawFirmDatabaseImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue)
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
{
return new();
}
using var context = new AbstractLawFirmDataBase();
return context.Orders
.Where(x => x.Id == model.Id)
.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
}

View File

@ -32,11 +32,11 @@ namespace AbstractLawFirmFileImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue)
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
{
return new();
}
return source.Orders.Where(x => x.Id == model.Id).Select(x => GetViewModel(x)).ToList();
return source.Orders.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo).Select(x => x.GetViewModel).ToList();
}
public List<OrderViewModel> GetFullList()

View File

@ -37,7 +37,7 @@ namespace AbstractLawFirmListImplement.Implements
}
foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
if (order.Id == model.Id || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo)
{
result.Add(AccessDocumentStorage(order.GetViewModel));
}

View File

@ -184,7 +184,7 @@ namespace LawFirmView
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
_reportLogic.SaveComponentsToWordFile(new ReportBindingModel
_reportLogic.SaveDocumentsToWordFile(new ReportBindingModel
{
FileName = dialog.FileName
});

View File

@ -35,8 +35,8 @@ namespace LawFirmView
foreach (var elem in dict)
{
// проверить ComponentName Document (поменять местами)
dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" });
foreach (var listElem in elem.Document)
dataGridView.Rows.Add(new object[] { elem.DocumentName, "", "" });
foreach (var listElem in elem.Components)
{
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
}

View File

@ -9,7 +9,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.Tools.Msbuild" Version="16.0.62004.28040" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.28">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@ -1,4 +1,3 @@
using AbstractLawFirmBusinessLogic;
using AbstractLawFirmBusinessLogic.BusinessLogic;
using AbstractLawFirmBusinessLogic.OfficePackage.Implements;
using AbstractLawFirmBusinessLogic.OfficePackage;