This commit is contained in:
Maxim 2024-12-03 00:34:28 +04:00
parent fdfc7602b2
commit 997ce2f09e
22 changed files with 1883 additions and 15 deletions

View File

@ -1,4 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise">
<file url="file://$PROJECT_DIR$/FormAdvocateApp.cs" charset="windows-1251" />
</component>
</project>

View File

@ -0,0 +1,73 @@
using Microsoft.Extensions.Logging;
using ProjectGSM.Repositories;
namespace ProjectGSM.Documents;
public class ChartReport
{
private readonly ICaseRepository _caseRepository;
private readonly ICaseAdvocateRepository _caseAdvocateRepository;
private readonly IAdvocateRepository _advocateRepository;
private readonly ILogger<ChartReport> _logger;
public ChartReport(ICaseRepository caseRepository,
IAdvocateRepository advocateRepository,
ICaseAdvocateRepository caseAdvocateRepository,
ILogger<ChartReport> logger)
{
_caseRepository = caseRepository ??
throw new
ArgumentNullException(nameof(caseRepository));
_advocateRepository = advocateRepository ??
throw new ArgumentNullException(nameof(advocateRepository));
_caseAdvocateRepository = caseAdvocateRepository ??
throw new ArgumentNullException(nameof(caseAdvocateRepository));
_logger = logger ??
throw new ArgumentNullException(nameof(logger));
}
public bool CreateChart(string filePath, DateTime dateTime)
{
try
{
new PdfBuilder(filePath)
.AddHeader("Доля выручки адвоката")
.AddPieChart($"Всего до: {dateTime.Date}", GetData(dateTime))
.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
public List<(string, double)> GetData(DateTime dateTime)
{
try
{
var advocateEarnings = _caseRepository
.ReadCases()
.Where(x => x.CreatedAt.Date <= dateTime.Date)
.Join(_caseAdvocateRepository.ReadCaseAdvocates().Where(x => x.CreatedAt.Date <= dateTime.Date),
caseItem => caseItem.Id,
caseAdvocate => caseAdvocate.CaseId,
(caseItem, caseAdvocate) => new { caseItem, caseAdvocate })
.GroupBy(x => x.caseAdvocate.AdvocateId, (key, group) => new
{
AdvocateName = _advocateRepository.ReadAdvocateById(key)?.Name ?? "Unknown",
Earnings = group.Sum(x => x.caseItem.Payment ? (x.caseItem.Verdict ? x.caseItem.VictoryPrice : x.caseItem.Price) : 0)
})
.Select(x => (x.AdvocateName, (double)x.Earnings))
.ToList();
return advocateEarnings;
}
catch (Exception ex)
{
_logger.LogError(ex, "Error occurred while calculating advocate earnings");
return new List<(string, double)>();
}
}
}

View File

@ -0,0 +1,113 @@
using Microsoft.Extensions.Logging;
using ProjectGSM.Repositories;
namespace ProjectGSM.Documents;
public class DocReport
{
private readonly IAdvocateRepository _advocateRepository;
private readonly IClientRepository _clientRepository;
private readonly ICourtRepository _courtRepository;
private readonly ILogger<DocReport> _logger;
public DocReport(IAdvocateRepository advocateRepository, IClientRepository
clientRepository,
ICourtRepository courtRepository, ILogger<DocReport> logger)
{
_advocateRepository = advocateRepository ??
throw new
ArgumentNullException(nameof(advocateRepository));
_clientRepository = clientRepository ??
throw new ArgumentNullException(nameof(clientRepository));
_courtRepository = courtRepository ??
throw new ArgumentNullException(nameof(courtRepository));
_logger = logger ??
throw new ArgumentNullException(nameof(logger));
}
public bool CreateDoc(string filePath, bool includeAdvocates, bool
includeClients, bool includeCourts)
{
try
{
var builder = new WordBuilder(filePath)
.AddHeader("Документ со справочниками");
if (includeAdvocates)
{
builder.AddParagraph("Адвокаты")
.AddTable([2400, 1200, 2400, 1200, 1200, 1200, 2400, 2400, 2400, 5000],
GetAdvocates());
}
if (includeClients)
{
builder.AddParagraph("Клиенты")
.AddTable([2400, 2400, 2400, 2400, 2400, 2400], GetClients());
}
if (includeCourts)
{
builder.AddParagraph("Суды")
.AddTable([2400, 2400], GetCourts());
}
builder.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
private List<string[]> GetAdvocates()
{
return
[
[
"ФИО", "Пол", "Дата рождения", "Опыт", "Кол-во завершенных дел", "Рейтинг", "E-mail", "Номер телефона",
"Адрес", "Лицензии"
],
.. _advocateRepository
.ReadAdvocates()
.Select(x => new[]
{
x.Name,
x.Sex ? "Мужчина" : "Женщина", x.DateOfBirth.ToShortDateString(), x.Experience.ToString(),
x.CompletedTasks.ToString(), x.Rating.ToString(), x.Email, x.PhoneNumber, x.Address,
x.LicenseType.ToString()
}),
];
}
private List<string[]> GetClients()
{
return
[
["ФИО", "Пол", "Дата рождения", "E-mail", "Номер телефона", "Адрес"],
.. _clientRepository
.ReadClients()
.Select(x => new[]
{
x.Name,
x.Sex ? "Мужчина" : "Женщина", x.DateOfBirth.ToShortDateString(), x.Email, x.PhoneNumber, x.Address
}),
];
}
private List<string[]> GetCourts()
{
return
[
["Название", "Адрес"],
.. _courtRepository
.ReadCourts()
.Select(x => new[]
{
x.Name,
x.Address
}),
];
}
}

View File

@ -0,0 +1,286 @@
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
namespace ProjectGSM.Documents;
public class ExcelBuilder
{
private readonly string _filePath;
private readonly SheetData _sheetData;
private readonly MergeCells _mergeCells;
private readonly Columns _columns;
private uint _rowIndex = 0;
public ExcelBuilder(string filePath)
{
if (string.IsNullOrWhiteSpace(filePath))
{
throw new ArgumentNullException(nameof(filePath));
}
if (File.Exists(filePath))
{
File.Delete(filePath);
}
_filePath = filePath;
_sheetData = new SheetData();
_mergeCells = new MergeCells();
_columns = new Columns();
_rowIndex = 1;
}
public ExcelBuilder AddHeader(string header, int startIndex, int count)
{
CreateCell(startIndex, _rowIndex, header,
StyleIndex.BoldTextWithoutBorder);
for (int i = startIndex + 1; i < startIndex + count; ++i)
{
CreateCell(i, _rowIndex, "",
StyleIndex.BoldTextWithoutBorder);
}
_mergeCells.Append(new MergeCell()
{
Reference =
new
StringValue(
$"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}")
});
_rowIndex++;
return this;
}
public ExcelBuilder AddParagraph(string text, int columnIndex)
{
CreateCell(columnIndex, _rowIndex++, text,
StyleIndex.SimpleTextWithoutBorder);
return this;
}
public ExcelBuilder AddTable(int[] columnsWidths, List<string[]> data)
{
if (columnsWidths == null || columnsWidths.Length == 0)
{
throw new ArgumentNullException(nameof(columnsWidths));
}
if (data == null || data.Count == 0)
{
throw new ArgumentNullException(nameof(data));
}
if (data.Any(x => x.Length != columnsWidths.Length))
{
throw new InvalidOperationException("widths.Length != data.Length");
}
uint counter = 1;
int coef = 2;
_columns.Append(columnsWidths.Select(x => new Column
{
Min = counter,
Max = counter++,
Width = x * coef,
CustomWidth = true
}));
for (var j = 0; j < data.First().Length; ++j)
{
CreateCell(j, _rowIndex, data.First()[j],
StyleIndex.SimpleTextWithoutBorder);
}
_rowIndex++;
for (var i = 1; i < data.Count - 1; ++i)
{
for (var j = 0; j < data[i].Length; ++j)
{
CreateCell(j, _rowIndex, data[i][j],
StyleIndex.SimpleTextWithoutBorder);
}
_rowIndex++;
}
for (var j = 0; j < data.Last().Length; ++j)
{
CreateCell(j, _rowIndex, data.Last()[j],
StyleIndex.SimpleTextWithoutBorder);
}
_rowIndex++;
return this;
}
public void Build()
{
using var spreadsheetDocument = SpreadsheetDocument.Create(_filePath,
SpreadsheetDocumentType.Workbook);
var workbookpart = spreadsheetDocument.AddWorkbookPart();
GenerateStyle(workbookpart);
workbookpart.Workbook = new Workbook();
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
worksheetPart.Worksheet = new Worksheet();
if (_columns.HasChildren)
{
worksheetPart.Worksheet.Append(_columns);
}
worksheetPart.Worksheet.Append(_sheetData);
var sheets =
spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
var sheet = new Sheet()
{
Id =
spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
SheetId = 1,
Name = "Лист 1"
};
sheets.Append(sheet);
if (_mergeCells.HasChildren)
{
worksheetPart.Worksheet.InsertAfter(_mergeCells,
worksheetPart.Worksheet.Elements<SheetData>().First());
}
}
private static void GenerateStyle(WorkbookPart workbookPart)
{
var workbookStylesPart =
workbookPart.AddNewPart<WorkbookStylesPart>();
workbookStylesPart.Stylesheet = new Stylesheet();
var fonts = new Fonts()
{
Count = 2, KnownFonts =
BooleanValue.FromBoolean(true)
};
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
{
FontSize = new FontSize() { Val = 11 },
FontName = new FontName() { Val = "Calibri" },
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
FontScheme = new FontScheme()
{
Val = new
EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
},
Bold = new Bold()
});
workbookStylesPart.Stylesheet.Append(fonts);
// Default Fill
var fills = new Fills() { Count = 1 };
fills.Append(new Fill
{
PatternFill = new PatternFill()
{
PatternType = new
EnumValue<PatternValues>(PatternValues.None)
}
});
workbookStylesPart.Stylesheet.Append(fills);
// Default Border
var borders = new Borders() { Count = 2 };
// Add a border with thin lines
borders.Append(new Border
{
LeftBorder = new LeftBorder { Style = BorderStyleValues.Thin },
RightBorder = new RightBorder { Style = BorderStyleValues.Thin },
TopBorder = new TopBorder { Style = BorderStyleValues.Thin },
BottomBorder = new BottomBorder { Style = BorderStyleValues.Thin },
DiagonalBorder = new DiagonalBorder()
});
workbookStylesPart.Stylesheet.Append(borders);
// Default cell format and a date cell format
var cellFormats = new CellFormats() { Count = 4 };
// Add additional cell formats
// Add additional cell formats
cellFormats.Append(new CellFormat
{
NumberFormatId = 0,
FormatId = 0,
FontId = 1, // Use the bold font
BorderId = 1, // Use the thin border
FillId = 0,
Alignment = new Alignment()
{
Horizontal = HorizontalAlignmentValues.Left,
Vertical = VerticalAlignmentValues.Center,
WrapText = true
}
});
workbookStylesPart.Stylesheet.Append(cellFormats);
}
private enum StyleIndex
{
SimpleTextWithoutBorder = 0,
BoldTextWithoutBorder = 1,
ItalicTextWithoutBorder = 2,
// Add more styles as needed
}
private void CreateCell(int columnIndex, uint rowIndex, string text,
StyleIndex styleIndex)
{
var columnName = GetExcelColumnName(columnIndex);
var cellReference = columnName + rowIndex;
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex!
== rowIndex);
if (row == null)
{
row = new Row() { RowIndex = rowIndex };
_sheetData.Append(row);
}
var newCell = row.Elements<Cell>()
.FirstOrDefault(c => c.CellReference != null &&
c.CellReference.Value == columnName + rowIndex);
if (newCell == null)
{
Cell? refCell = null;
foreach (Cell cell in row.Elements<Cell>())
{
if (cell.CellReference?.Value != null &&
cell.CellReference.Value.Length == cellReference.Length)
{
if (String.Compare(cell.CellReference.Value,
cellReference, StringComparison.OrdinalIgnoreCase) > 0)
{
refCell = cell;
break;
}
}
}
newCell = new Cell() { CellReference = cellReference };
row.InsertBefore(newCell, refCell);
}
newCell.CellValue = new CellValue(text);
newCell.DataType = CellValues.String;
newCell.StyleIndex = (uint)styleIndex;
}
private static string GetExcelColumnName(int columnNumber)
{
columnNumber += 1;
int dividend = columnNumber;
string columnName = string.Empty;
int modulo;
while (dividend > 0)
{
modulo = (dividend - 1) % 26;
columnName = Convert.ToChar(65 + modulo).ToString() +
columnName;
dividend = (dividend - modulo) / 26;
}
return columnName;
}
}

View File

@ -0,0 +1,82 @@
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Shapes.Charts;
using MigraDoc.Rendering;
namespace ProjectGSM.Documents;
public class PdfBuilder
{
private readonly string _filePath;
private readonly Document _document;
public PdfBuilder(string filePath)
{
if (string.IsNullOrWhiteSpace(filePath))
{
throw new ArgumentNullException(nameof(filePath));
}
if (File.Exists(filePath))
{
File.Delete(filePath);
}
_filePath = filePath;
_document = new Document();
DefineStyles();
}
public PdfBuilder AddHeader(string header)
{
_document.AddSection().AddParagraph(header, "NormalBold");
return this;
}
public PdfBuilder AddPieChart(string title, List<(string Caption, double
Value)> data)
{
if (data == null || data.Count == 0)
{
return this;
}
var chart = new Chart(ChartType.Pie2D);
var series = chart.SeriesCollection.AddSeries();
series.Add(data.Select(x => x.Value).ToArray());
var xseries = chart.XValues.AddXSeries();
xseries.Add(data.Select(x => x.Caption).ToArray());
chart.DataLabel.Type = DataLabelType.Percent;
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
chart.Width = Unit.FromCentimeter(16);
chart.Height = Unit.FromCentimeter(12);
chart.TopArea.AddParagraph(title);
chart.XAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.HasMajorGridlines = true;
chart.PlotArea.LineFormat.Width = 1;
chart.PlotArea.LineFormat.Visible = true;
chart.TopArea.AddLegend();
_document.LastSection.Add(chart);
return this;
}
public void Build()
{
var renderer = new PdfDocumentRenderer(true)
{
Document = _document
};
renderer.RenderDocument();
renderer.PdfDocument.Save(_filePath);
}
private void DefineStyles()
{
var normalStyle = _document.Styles["Normal"];
normalStyle.Font.Name = "Arial";
normalStyle.Font.Size = 12;
var normalBoldStyle = _document.Styles.AddStyle("NormalBold", "Normal");
normalBoldStyle.Font.Bold = true;
}
}

View File

@ -0,0 +1,78 @@
using Microsoft.Extensions.Logging;
using ProjectGSM.Entities;
using ProjectGSM.Repositories;
namespace ProjectGSM.Documents;
internal class TableReport
{
private readonly ICaseRepository _caseRepository;
private readonly IStatusHistoryRepository _statusHistoryRepository;
private readonly ILogger<TableReport> _logger;
internal static readonly string[] item = ["Статусы", "Дата", "Изменений статуса"];
public TableReport(
ICaseRepository caseRepository,
IStatusHistoryRepository statusHistoryRepository,
ILogger<TableReport> logger)
{
_caseRepository = caseRepository ??
throw new
ArgumentNullException(nameof(caseRepository));
_statusHistoryRepository = statusHistoryRepository ??
throw new
ArgumentNullException(nameof(statusHistoryRepository));
_logger = logger ??
throw new ArgumentNullException(nameof(logger));
}
public bool CreateTable(string filePath, int caseId, DateTime startDate,
DateTime endDate)
{
try
{
new ExcelBuilder(filePath)
.AddHeader($"Сводка по делу \"{_caseRepository.ReadCaseById(caseId).Description}\"", 0, 4)
.AddParagraph("за период", 0)
.AddTable([10, 10, 15], GetData(caseId, startDate,
endDate))
.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
private List<string[]> GetData(int caseId, DateTime startDate, DateTime endDate)
{
var statusData = _statusHistoryRepository
.ReadStatusHistories()
.Where(x => x.CreatedAt >= startDate && x.CreatedAt <= endDate && x.CaseId == caseId)
.GroupBy(x => (x.Status, x.CreatedAt.Date))
.Select(x => new
{
Status = x.Key.Status,
Date = x.Key.Date,
Count = x.Count()
})
.ToList();
return new List<string[]>() { item }
.Union(
statusData
.Select(x => new string[]
{
x.Status.ToString(), x.Date.ToString(), x.Count.ToString()
}))
.Union(
[
[
"Всего", "", statusData.Sum(x => x.Count).ToString()
]
])
.ToList();
}
}

View File

@ -0,0 +1,133 @@
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
internal class WordBuilder
{
private readonly string _filePath;
private readonly Document _document;
private readonly Body _body;
public WordBuilder(string filePath)
{
if (string.IsNullOrWhiteSpace(filePath))
{
throw new ArgumentNullException(nameof(filePath));
}
if (File.Exists(filePath))
{
File.Delete(filePath);
}
_filePath = filePath;
_document = new Document();
_body = _document.AppendChild(new Body());
}
public WordBuilder AddHeader(string header)
{
var paragraph = _body.AppendChild(new Paragraph());
var run = paragraph.AppendChild(new Run());
run.RunProperties = new RunProperties(new Bold());
run.AppendChild(new Text(header));
return this;
}
public WordBuilder AddParagraph(string text)
{
var paragraph = _body.AppendChild(new Paragraph());
var run = paragraph.AppendChild(new Run());
run.AppendChild(new Text(text));
return this;
}
public WordBuilder AddTable(int[] widths, List<string[]> data)
{
if (widths == null || widths.Length == 0)
{
throw new ArgumentNullException(nameof(widths));
}
if (data == null || data.Count == 0)
{
throw new ArgumentNullException(nameof(data));
}
if (data.Any(x => x.Length != widths.Length))
{
throw new InvalidOperationException("widths.Length != data.Length");
}
var table = new Table();
table.AppendChild(new TableProperties(
new TableBorders(
new TopBorder()
{
Val = new
EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new BottomBorder()
{
Val = new
EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new LeftBorder()
{
Val = new
EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new RightBorder()
{
Val = new
EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new InsideHorizontalBorder()
{
Val = new
EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new InsideVerticalBorder()
{
Val = new
EnumValue<BorderValues>(BorderValues.Single),
Size = 12
}
)
));
// Заголовок
var tr = new TableRow();
for (var j = 0; j < widths.Length; ++j)
{
tr.Append(new TableCell(
new TableCellProperties(new TableCellWidth()
{
Width =
widths[j].ToString()
}),
new Paragraph(new Run(new RunProperties(new Bold()), new
Text(data.First()[j])))));
}
table.Append(tr);
// Данные
table.Append(data.Skip(1).Select(x =>
new TableRow(x.Select(y => new TableCell(new Paragraph(new
Run(new Text(y))))))));
_body.Append(table);
return this;
}
public void Build()
{
using var wordDocument = WordprocessingDocument.Create(_filePath,
WordprocessingDocumentType.Document);
var mainPart = wordDocument.AddMainDocumentPart();
mainPart.Document = _document;
}
}

View File

@ -40,11 +40,14 @@
directoriesMenuItem = new ToolStripMenuItem();
clientsMenuItem = new ToolStripMenuItem();
advocatesMenuItem = new ToolStripMenuItem();
casesMenuItem = new ToolStripMenuItem();
courtsToolStripMenuItem = new ToolStripMenuItem();
operationsMenuItem = new ToolStripMenuItem();
casesMenuItem = new ToolStripMenuItem();
statusHistoryRepositoryMenuItem = new ToolStripMenuItem();
reportsMenuItem = new ToolStripMenuItem();
infoToolStripMenuItem = new ToolStripMenuItem();
caseToolStripMenuItem = new ToolStripMenuItem();
statusesToolStripMenuItem = new ToolStripMenuItem();
menuStrip.SuspendLayout();
SuspendLayout();
//
@ -68,28 +71,21 @@
// clientsMenuItem
//
clientsMenuItem.Name = "clientsMenuItem";
clientsMenuItem.Size = new Size(161, 22);
clientsMenuItem.Size = new Size(127, 22);
clientsMenuItem.Text = "Клиенты";
clientsMenuItem.Click += clientsMenuItem_Click_1;
//
// advocatesMenuItem
//
advocatesMenuItem.Name = "advocatesMenuItem";
advocatesMenuItem.Size = new Size(161, 22);
advocatesMenuItem.Size = new Size(127, 22);
advocatesMenuItem.Text = "Адвокаты";
advocatesMenuItem.Click += advocatesMenuItem_Click;
//
// casesMenuItem
//
casesMenuItem.Name = "casesMenuItem";
casesMenuItem.Size = new Size(161, 22);
casesMenuItem.Text = "Дела";
casesMenuItem.Click += casesMenuItem_Click;
//
// courtsToolStripMenuItem
//
courtsToolStripMenuItem.Name = "courtsToolStripMenuItem";
courtsToolStripMenuItem.Size = new Size(161, 22);
courtsToolStripMenuItem.Size = new Size(127, 22);
courtsToolStripMenuItem.Text = "Суды";
courtsToolStripMenuItem.Click += courtsToolStripMenuItem_Click;
//
@ -100,19 +96,48 @@
operationsMenuItem.Size = new Size(75, 20);
operationsMenuItem.Text = "Операции";
//
// casesMenuItem
//
casesMenuItem.Name = "casesMenuItem";
casesMenuItem.Size = new Size(191, 22);
casesMenuItem.Text = "Дела";
casesMenuItem.Click += casesMenuItem_Click;
//
// statusHistoryRepositoryMenuItem
//
statusHistoryRepositoryMenuItem.Name = "statusHistoryRepositoryMenuItem";
statusHistoryRepositoryMenuItem.Size = new Size(221, 22);
statusHistoryRepositoryMenuItem.Size = new Size(191, 22);
statusHistoryRepositoryMenuItem.Text = "Хронология статусов";
statusHistoryRepositoryMenuItem.Click += statusHistoryRepositoryMenuItem_Click;
//
// reportsMenuItem
//
reportsMenuItem.DropDownItems.AddRange(new ToolStripItem[] { infoToolStripMenuItem, caseToolStripMenuItem, statusesToolStripMenuItem });
reportsMenuItem.Name = "reportsMenuItem";
reportsMenuItem.Size = new Size(60, 20);
reportsMenuItem.Text = "Отчеты";
//
// infoToolStripMenuItem
//
infoToolStripMenuItem.Name = "infoToolStripMenuItem";
infoToolStripMenuItem.Size = new Size(207, 22);
infoToolStripMenuItem.Text = "Выгрузка справочников";
infoToolStripMenuItem.Click += infoToolStripMenuItem_Click;
//
// caseToolStripMenuItem
//
caseToolStripMenuItem.Name = "caseToolStripMenuItem";
caseToolStripMenuItem.Size = new Size(207, 22);
caseToolStripMenuItem.Text = "Отчет по делам";
caseToolStripMenuItem.Click += caseToolStripMenuItem_Click;
//
// statusesToolStripMenuItem
//
statusesToolStripMenuItem.Name = "statusesToolStripMenuItem";
statusesToolStripMenuItem.Size = new Size(207, 22);
statusesToolStripMenuItem.Text = "Статусы дел";
statusesToolStripMenuItem.Click += statusesToolStripMenuItem_Click;
//
// FormAdvocateApp
//
AutoScaleDimensions = new SizeF(7F, 15F);
@ -134,5 +159,8 @@
#endregion
private ToolStripMenuItem courtsToolStripMenuItem;
private ToolStripMenuItem infoToolStripMenuItem;
private ToolStripMenuItem caseToolStripMenuItem;
private ToolStripMenuItem statusesToolStripMenuItem;
}
}

View File

@ -77,5 +77,42 @@ throw new ArgumentNullException(nameof(container));
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void infoToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormDirectoryReport>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå îò÷åòà",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void caseToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormCaseReport>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå îò÷åòà",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void statusesToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormStatusesCasesReport>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå îò÷åòà",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,163 @@
namespace ProjectGSM.Forms
{
partial class FormCaseReport
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
textBoxFilePath = new TextBox();
fileLabel = new Label();
labelCase = new Label();
comboBoxCase = new ComboBox();
labelData1 = new Label();
labelDate2 = new Label();
dateTimePickerBegin = new DateTimePicker();
dateTimePickerEnd = new DateTimePicker();
ButtonSelectFilePath = new Button();
buttonMakeReport = new Button();
SuspendLayout();
//
// textBoxFilePath
//
textBoxFilePath.Enabled = false;
textBoxFilePath.Location = new Point(124, 30);
textBoxFilePath.Name = "textBoxFilePath";
textBoxFilePath.Size = new Size(163, 23);
textBoxFilePath.TabIndex = 0;
//
// fileLabel
//
fileLabel.AutoSize = true;
fileLabel.Location = new Point(28, 33);
fileLabel.Name = "fileLabel";
fileLabel.Size = new Size(90, 15);
fileLabel.TabIndex = 1;
fileLabel.Text = "Путь до файла:";
//
// labelCase
//
labelCase.AutoSize = true;
labelCase.Location = new Point(28, 77);
labelCase.Name = "labelCase";
labelCase.Size = new Size(38, 15);
labelCase.TabIndex = 2;
labelCase.Text = "Дело:";
//
// comboBoxCase
//
comboBoxCase.FormattingEnabled = true;
comboBoxCase.Location = new Point(124, 69);
comboBoxCase.Name = "comboBoxCase";
comboBoxCase.Size = new Size(200, 23);
comboBoxCase.TabIndex = 3;
//
// labelData1
//
labelData1.AutoSize = true;
labelData1.Location = new Point(28, 128);
labelData1.Name = "labelData1";
labelData1.Size = new Size(77, 15);
labelData1.TabIndex = 4;
labelData1.Text = "Дата начала:";
//
// labelDate2
//
labelDate2.AutoSize = true;
labelDate2.Location = new Point(28, 177);
labelDate2.Name = "labelDate2";
labelDate2.Size = new Size(71, 15);
labelDate2.TabIndex = 5;
labelDate2.Text = "Дата конца:";
//
// dateTimePickerBegin
//
dateTimePickerBegin.Location = new Point(124, 122);
dateTimePickerBegin.Name = "dateTimePickerBegin";
dateTimePickerBegin.Size = new Size(200, 23);
dateTimePickerBegin.TabIndex = 6;
//
// dateTimePickerEnd
//
dateTimePickerEnd.Location = new Point(124, 171);
dateTimePickerEnd.Name = "dateTimePickerEnd";
dateTimePickerEnd.Size = new Size(200, 23);
dateTimePickerEnd.TabIndex = 7;
//
// ButtonSelectFilePath
//
ButtonSelectFilePath.Location = new Point(293, 30);
ButtonSelectFilePath.Name = "ButtonSelectFilePath";
ButtonSelectFilePath.Size = new Size(31, 23);
ButtonSelectFilePath.TabIndex = 8;
ButtonSelectFilePath.Text = "...";
ButtonSelectFilePath.UseVisualStyleBackColor = true;
ButtonSelectFilePath.Click += ButtonSelectFilePath_Click;
//
// buttonMakeReport
//
buttonMakeReport.Location = new Point(110, 221);
buttonMakeReport.Name = "buttonMakeReport";
buttonMakeReport.Size = new Size(166, 23);
buttonMakeReport.TabIndex = 9;
buttonMakeReport.Text = "Сформировать";
buttonMakeReport.UseVisualStyleBackColor = true;
buttonMakeReport.Click += ButtonMakeReport_Click;
//
// FormCaseReport
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(368, 257);
Controls.Add(buttonMakeReport);
Controls.Add(ButtonSelectFilePath);
Controls.Add(dateTimePickerEnd);
Controls.Add(dateTimePickerBegin);
Controls.Add(labelDate2);
Controls.Add(labelData1);
Controls.Add(comboBoxCase);
Controls.Add(labelCase);
Controls.Add(fileLabel);
Controls.Add(textBoxFilePath);
Name = "FormCaseReport";
Text = "Отчет по статусам дела";
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBoxFilePath;
private Label fileLabel;
private Label labelCase;
private ComboBox comboBoxCase;
private Label labelData1;
private Label labelDate2;
private DateTimePicker dateTimePickerBegin;
private DateTimePicker dateTimePickerEnd;
private Button ButtonSelectFilePath;
private Button buttonMakeReport;
}
}

View File

@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ProjectGSM.Documents;
using ProjectGSM.Repositories;
using Unity;
namespace ProjectGSM.Forms
{
public partial class FormCaseReport : Form
{
private readonly IUnityContainer _container;
public FormCaseReport(IUnityContainer container, ICaseRepository
feedRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
comboBoxCase.DataSource = feedRepository.ReadCases();
comboBoxCase.DisplayMember = "Description";
comboBoxCase.ValueMember = "Id";
}
private void ButtonSelectFilePath_Click(object sender, EventArgs e)
{
var sfd = new SaveFileDialog()
{
Filter = "Excel Files | *.xlsx"
};
if (sfd.ShowDialog() != DialogResult.OK)
{
return;
}
textBoxFilePath.Text = sfd.FileName;
}
private void ButtonMakeReport_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxFilePath.Text))
{
throw new Exception("Отсутствует имя файла для отчета");
}
if (comboBoxCase.SelectedIndex < 0)
{
throw new Exception("Не выбран корм");
}
if (dateTimePickerEnd.Value <=
dateTimePickerBegin.Value)
{
throw new Exception("Дата начала должна быть раньше даты окончания");
}
if
(_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text,
(int)comboBoxCase.SelectedValue!,
dateTimePickerBegin.Value, dateTimePickerEnd.Value))
{
MessageBox.Show("Документ сформирован",
"Формирование документа",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Возникли ошибки при формировании документа. Подробности в логах",
"Формирование документа",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при создании очета",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonMakeReport_Click_1(object sender, EventArgs e)
{
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,99 @@
namespace ProjectGSM.Forms
{
partial class FormDirectoryReport
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
checkBoxAdvocates = new CheckBox();
checkBoxClients = new CheckBox();
checkBoxCourts = new CheckBox();
buttonBuild = new Button();
SuspendLayout();
//
// checkBoxAdvocates
//
checkBoxAdvocates.AutoSize = true;
checkBoxAdvocates.Location = new Point(58, 53);
checkBoxAdvocates.Name = "checkBoxAdvocates";
checkBoxAdvocates.Size = new Size(79, 19);
checkBoxAdvocates.TabIndex = 0;
checkBoxAdvocates.Text = "Адвокаты";
checkBoxAdvocates.UseVisualStyleBackColor = true;
//
// checkBoxClients
//
checkBoxClients.AutoSize = true;
checkBoxClients.Location = new Point(58, 78);
checkBoxClients.Name = "checkBoxClients";
checkBoxClients.Size = new Size(74, 19);
checkBoxClients.TabIndex = 1;
checkBoxClients.Text = "Клиенты";
checkBoxClients.UseVisualStyleBackColor = true;
//
// checkBoxCourts
//
checkBoxCourts.AutoSize = true;
checkBoxCourts.Location = new Point(58, 103);
checkBoxCourts.Name = "checkBoxCourts";
checkBoxCourts.Size = new Size(55, 19);
checkBoxCourts.TabIndex = 2;
checkBoxCourts.Text = "Суды";
checkBoxCourts.UseVisualStyleBackColor = true;
//
// buttonBuild
//
buttonBuild.Location = new Point(204, 74);
buttonBuild.Name = "buttonBuild";
buttonBuild.Size = new Size(151, 23);
buttonBuild.TabIndex = 3;
buttonBuild.Text = "Сформировать";
buttonBuild.UseVisualStyleBackColor = true;
buttonBuild.Click += ButtonBuild_Click;
//
// FormDirectoryReport
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(367, 173);
Controls.Add(buttonBuild);
Controls.Add(checkBoxCourts);
Controls.Add(checkBoxClients);
Controls.Add(checkBoxAdvocates);
Name = "FormDirectoryReport";
Text = "Выгрузка справочников";
ResumeLayout(false);
PerformLayout();
}
#endregion
private CheckBox checkBoxAdvocates;
private CheckBox checkBoxClients;
private CheckBox checkBoxCourts;
private Button buttonBuild;
}
}

View File

@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ProjectGSM.Documents;
using Unity;
namespace ProjectGSM.Forms
{
public partial class FormDirectoryReport : Form
{
private readonly IUnityContainer _container;
public FormDirectoryReport(IUnityContainer container)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
}
private void ButtonBuild_Click(object sender, EventArgs e)
{
try
{
if (!checkBoxAdvocates.Checked &&
!checkBoxClients.Checked && !checkBoxCourts.Checked)
{
throw new Exception("Не выбран ни один справочник для выгрузки");
}
var sfd = new SaveFileDialog()
{
Filter = "Docx Files | *.docx"
};
if (sfd.ShowDialog() != DialogResult.OK)
{
throw new Exception("Не выбран файла для отчета");
}
if
(_container.Resolve<DocReport>().CreateDoc(sfd.FileName, checkBoxAdvocates.Checked,
checkBoxClients.Checked,
checkBoxCourts.Checked))
{
MessageBox.Show("Документ сформирован",
"Формирование документа",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Возникли ошибки при формировании документа. Подробности в логах",
"Формирование документа",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при создании отчета", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,107 @@
namespace ProjectGSM.Forms
{
partial class FormStatusesCasesReport
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
ButtonSelectFileName = new Button();
labelFileName = new Label();
labelDate = new Label();
dateTimePicker = new DateTimePicker();
ButtonCreate = new Button();
SuspendLayout();
//
// ButtonSelectFileName
//
ButtonSelectFileName.Location = new Point(12, 12);
ButtonSelectFileName.Name = "ButtonSelectFileName";
ButtonSelectFileName.Size = new Size(106, 23);
ButtonSelectFileName.TabIndex = 0;
ButtonSelectFileName.Text = "Выбрать";
ButtonSelectFileName.UseVisualStyleBackColor = true;
ButtonSelectFileName.Click += ButtonSelectFileName_Click;
//
// labelFileName
//
labelFileName.AutoSize = true;
labelFileName.Location = new Point(202, 16);
labelFileName.Name = "labelFileName";
labelFileName.Size = new Size(36, 15);
labelFileName.TabIndex = 1;
labelFileName.Text = "Файл";
//
// labelDate
//
labelDate.AutoSize = true;
labelDate.Location = new Point(12, 58);
labelDate.Name = "labelDate";
labelDate.Size = new Size(35, 15);
labelDate.TabIndex = 2;
labelDate.Text = "Дата:";
//
// dateTimePicker
//
dateTimePicker.Location = new Point(74, 55);
dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(279, 23);
dateTimePicker.TabIndex = 3;
//
// ButtonCreate
//
ButtonCreate.Location = new Point(97, 97);
ButtonCreate.Name = "ButtonCreate";
ButtonCreate.Size = new Size(154, 23);
ButtonCreate.TabIndex = 4;
ButtonCreate.Text = "Сформировать";
ButtonCreate.UseVisualStyleBackColor = true;
ButtonCreate.Click += ButtonCreate_Click;
//
// FormStatusesCasesReport
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(365, 143);
Controls.Add(ButtonCreate);
Controls.Add(dateTimePicker);
Controls.Add(labelDate);
Controls.Add(labelFileName);
Controls.Add(ButtonSelectFileName);
Name = "FormStatusesCasesReport";
Text = "Доля выручки адвоката";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button ButtonSelectFileName;
private Label labelFileName;
private Label labelDate;
private DateTimePicker dateTimePicker;
private Button ButtonCreate;
}
}

View File

@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ProjectGSM.Documents;
using Unity;
namespace ProjectGSM.Forms
{
public partial class FormStatusesCasesReport : Form
{
private string _fileName = string.Empty;
private readonly IUnityContainer _container;
public FormStatusesCasesReport(IUnityContainer container)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
}
private void ButtonSelectFileName_Click(object sender, EventArgs e)
{
var sfd = new SaveFileDialog()
{
Filter = "Pdf Files | *.pdf"
};
if (sfd.ShowDialog() == DialogResult.OK)
{
_fileName = sfd.FileName;
labelFileName.Text = Path.GetFileName(_fileName);
}
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(_fileName))
{
throw new Exception("Отсутствует имя файла для отчета");
}
if
(_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePicker.Value))
{
MessageBox.Show("Документ сформирован",
"Формирование документа",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Возникли ошибки при формировании документа. Подробности в логах",
"Формирование документа",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при создании очета",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,7 +1,5 @@
using System.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using ProjectGSM.Forms;
using ProjectGSM.Repositories;
using ProjectGSM.Repositories.Implementations;
using Serilog;
@ -33,6 +31,7 @@ namespace ProjectGSM
container.RegisterType<IConnectionString,
PSQLConnectionString>(new SingletonLifetimeManager());
container.RegisterType<ICaseAdvocateRepository, CaseAdvocatesRepository>(new TransientLifetimeManager());
container.RegisterType<IAdvocateRepository, AdvocateRepository>(new TransientLifetimeManager());
container.RegisterType<ICaseRepository, CaseRepository>(new TransientLifetimeManager());
container.RegisterType<IClientRepository, ClientRepository>(new TransientLifetimeManager());

View File

@ -51,7 +51,9 @@
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageReference Include="MigraDocXML" Version="3.0.0" />
<PackageReference Include="Npgsql" Version="9.0.0" />
<PackageReference Include="Open-XML-SDK" Version="2.9.1" />
<PackageReference Include="Serilog" Version="4.2.0-dev-02328" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.1-dev-10410" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />

View File

@ -0,0 +1,10 @@
using ProjectGSM.Entities;
namespace ProjectGSM.Repositories;
public interface ICaseAdvocateRepository
{
IEnumerable<CaseAdvocate> ReadCaseAdvocates(DateTime? dateForm = null, DateTime? dateTo = null,
int? caseId = null, int? advocateId = null);
void CreateCaseAdvocates(CaseAdvocate caseAdvocate);
}

View File

@ -0,0 +1,64 @@
using System.Data.SqlClient;
using System.Text.Json;
using Dapper;
using Microsoft.Extensions.Logging;
using Npgsql;
using ProjectGSM.Entities;
namespace ProjectGSM.Repositories.Implementations;
public class CaseAdvocatesRepository : ICaseAdvocateRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<CaseAdvocatesRepository> _logger;
public CaseAdvocatesRepository(IConnectionString connectionString,
ILogger<CaseAdvocatesRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public IEnumerable<CaseAdvocate> ReadCaseAdvocates(DateTime? dateForm = null, DateTime? dateTo = null,
int? caseId = null, int? statusId = null)
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM case_advocates";
var caseAdvocates =
connection.Query<CaseAdvocate>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonSerializer.Serialize(caseAdvocates));
return caseAdvocates;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public void CreateCaseAdvocates(CaseAdvocate caseAdvocate)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}",
JsonSerializer.Serialize(caseAdvocate));
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO case_advocates (caseid, advocateid, post, createdat)
VALUES (@CaseId, @AdvocateId, @Post, @CreatedAt)";
connection.Execute(queryInsert, caseAdvocate);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
}