полная лба
This commit is contained in:
parent
308a5440c1
commit
6136ebb2fc
130
StudentProgressRecord/Forms/FormStatementDistributionReport.Designer.cs
generated
Normal file
130
StudentProgressRecord/Forms/FormStatementDistributionReport.Designer.cs
generated
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
namespace StudentProgressRecord.Forms
|
||||||
|
{
|
||||||
|
partial class FormStatementDistributionReport
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
buttonFile = new Button();
|
||||||
|
labelFile = new Label();
|
||||||
|
dateTimePickerStart = new DateTimePicker();
|
||||||
|
labelDateFrom = new Label();
|
||||||
|
buttonApply = new Button();
|
||||||
|
labelDateTo = new Label();
|
||||||
|
dateTimePickerEnd = new DateTimePicker();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonFile
|
||||||
|
//
|
||||||
|
buttonFile.Location = new Point(133, 12);
|
||||||
|
buttonFile.Name = "buttonFile";
|
||||||
|
buttonFile.Size = new Size(94, 29);
|
||||||
|
buttonFile.TabIndex = 0;
|
||||||
|
buttonFile.Text = "Выбрать";
|
||||||
|
buttonFile.UseVisualStyleBackColor = true;
|
||||||
|
buttonFile.Click += buttonFile_Click;
|
||||||
|
//
|
||||||
|
// labelFile
|
||||||
|
//
|
||||||
|
labelFile.AutoSize = true;
|
||||||
|
labelFile.Location = new Point(12, 18);
|
||||||
|
labelFile.Name = "labelFile";
|
||||||
|
labelFile.Size = new Size(45, 20);
|
||||||
|
labelFile.TabIndex = 1;
|
||||||
|
labelFile.Text = "Файл";
|
||||||
|
//
|
||||||
|
// dateTimePickerStart
|
||||||
|
//
|
||||||
|
dateTimePickerStart.Location = new Point(78, 57);
|
||||||
|
dateTimePickerStart.Name = "dateTimePickerStart";
|
||||||
|
dateTimePickerStart.Size = new Size(161, 27);
|
||||||
|
dateTimePickerStart.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// labelDateFrom
|
||||||
|
//
|
||||||
|
labelDateFrom.AutoSize = true;
|
||||||
|
labelDateFrom.Location = new Point(12, 62);
|
||||||
|
labelDateFrom.Name = "labelDateFrom";
|
||||||
|
labelDateFrom.Size = new Size(60, 20);
|
||||||
|
labelDateFrom.TabIndex = 3;
|
||||||
|
labelDateFrom.Text = "Дата от";
|
||||||
|
//
|
||||||
|
// buttonApply
|
||||||
|
//
|
||||||
|
buttonApply.Location = new Point(12, 165);
|
||||||
|
buttonApply.Name = "buttonApply";
|
||||||
|
buttonApply.Size = new Size(215, 29);
|
||||||
|
buttonApply.TabIndex = 4;
|
||||||
|
buttonApply.Text = "Сформировать";
|
||||||
|
buttonApply.UseVisualStyleBackColor = true;
|
||||||
|
buttonApply.Click += buttonApply_Click;
|
||||||
|
//
|
||||||
|
// labelDateTo
|
||||||
|
//
|
||||||
|
labelDateTo.AutoSize = true;
|
||||||
|
labelDateTo.Location = new Point(12, 95);
|
||||||
|
labelDateTo.Name = "labelDateTo";
|
||||||
|
labelDateTo.Size = new Size(62, 20);
|
||||||
|
labelDateTo.TabIndex = 6;
|
||||||
|
labelDateTo.Text = "Дата до";
|
||||||
|
//
|
||||||
|
// dateTimePickerEnd
|
||||||
|
//
|
||||||
|
dateTimePickerEnd.Location = new Point(78, 90);
|
||||||
|
dateTimePickerEnd.Name = "dateTimePickerEnd";
|
||||||
|
dateTimePickerEnd.Size = new Size(161, 27);
|
||||||
|
dateTimePickerEnd.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// FormStatementDistributionReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(294, 206);
|
||||||
|
Controls.Add(labelDateTo);
|
||||||
|
Controls.Add(dateTimePickerEnd);
|
||||||
|
Controls.Add(buttonApply);
|
||||||
|
Controls.Add(labelDateFrom);
|
||||||
|
Controls.Add(dateTimePickerStart);
|
||||||
|
Controls.Add(labelFile);
|
||||||
|
Controls.Add(buttonFile);
|
||||||
|
Name = "FormStatementDistributionReport";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "FormStatementDistributionReport";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonFile;
|
||||||
|
private Label labelFile;
|
||||||
|
private DateTimePicker dateTimePickerStart;
|
||||||
|
private Label labelDateFrom;
|
||||||
|
private Button buttonApply;
|
||||||
|
private Label labelDateTo;
|
||||||
|
private DateTimePicker dateTimePickerEnd;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
using StudentProgressRecord.Reports;
|
||||||
|
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 Unity;
|
||||||
|
|
||||||
|
namespace StudentProgressRecord.Forms
|
||||||
|
{
|
||||||
|
public partial class FormStatementDistributionReport : Form
|
||||||
|
{
|
||||||
|
private string _fileName = string.Empty;
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
public FormStatementDistributionReport(IUnityContainer container)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ??
|
||||||
|
throw new ArgumentNullException(nameof(container));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonFile_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var sfd = new SaveFileDialog()
|
||||||
|
{
|
||||||
|
Filter = "Pdf Files | *.pdf"
|
||||||
|
};
|
||||||
|
if (sfd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_fileName = sfd.FileName;
|
||||||
|
labelFile.Text = Path.GetFileName(_fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonApply_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(_fileName))
|
||||||
|
{
|
||||||
|
throw new Exception("Отсутствует имя файла для отчета");
|
||||||
|
}
|
||||||
|
if (dateTimePickerEnd.Value <=
|
||||||
|
dateTimePickerStart.Value)
|
||||||
|
{
|
||||||
|
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||||
|
}
|
||||||
|
if
|
||||||
|
(_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePickerStart.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
StudentProgressRecord/Forms/FormStatementDistributionReport.resx
Normal file
120
StudentProgressRecord/Forms/FormStatementDistributionReport.resx
Normal 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>
|
@ -40,6 +40,7 @@
|
|||||||
ReportToolStripMenuItem = new ToolStripMenuItem();
|
ReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
ToolStripMenuItemDirectory = new ToolStripMenuItem();
|
ToolStripMenuItemDirectory = new ToolStripMenuItem();
|
||||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
операцииToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
анализToolStripMenuItem = new ToolStripMenuItem();
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -104,7 +105,7 @@
|
|||||||
//
|
//
|
||||||
// ReportToolStripMenuItem
|
// ReportToolStripMenuItem
|
||||||
//
|
//
|
||||||
ReportToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ToolStripMenuItemDirectory, операцииToolStripMenuItem });
|
ReportToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ToolStripMenuItemDirectory, операцииToolStripMenuItem, анализToolStripMenuItem });
|
||||||
ReportToolStripMenuItem.Name = "ReportToolStripMenuItem";
|
ReportToolStripMenuItem.Name = "ReportToolStripMenuItem";
|
||||||
ReportToolStripMenuItem.Size = new Size(73, 24);
|
ReportToolStripMenuItem.Size = new Size(73, 24);
|
||||||
ReportToolStripMenuItem.Text = "Отчеты";
|
ReportToolStripMenuItem.Text = "Отчеты";
|
||||||
@ -112,17 +113,27 @@
|
|||||||
// ToolStripMenuItemDirectory
|
// ToolStripMenuItemDirectory
|
||||||
//
|
//
|
||||||
ToolStripMenuItemDirectory.Name = "ToolStripMenuItemDirectory";
|
ToolStripMenuItemDirectory.Name = "ToolStripMenuItemDirectory";
|
||||||
ToolStripMenuItemDirectory.Size = new Size(224, 26);
|
ToolStripMenuItemDirectory.ShortcutKeys = Keys.Control | Keys.W;
|
||||||
|
ToolStripMenuItemDirectory.Size = new Size(233, 26);
|
||||||
ToolStripMenuItemDirectory.Text = "Справочник";
|
ToolStripMenuItemDirectory.Text = "Справочник";
|
||||||
ToolStripMenuItemDirectory.Click += ToolStripMenuItemDirectory_Click;
|
ToolStripMenuItemDirectory.Click += ToolStripMenuItemDirectory_Click;
|
||||||
//
|
//
|
||||||
// операцииToolStripMenuItem
|
// операцииToolStripMenuItem
|
||||||
//
|
//
|
||||||
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
||||||
операцииToolStripMenuItem.Size = new Size(224, 26);
|
операцииToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
||||||
|
операцииToolStripMenuItem.Size = new Size(233, 26);
|
||||||
операцииToolStripMenuItem.Text = "Операции";
|
операцииToolStripMenuItem.Text = "Операции";
|
||||||
операцииToolStripMenuItem.Click += операцииToolStripMenuItem_Click;
|
операцииToolStripMenuItem.Click += операцииToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// анализToolStripMenuItem
|
||||||
|
//
|
||||||
|
анализToolStripMenuItem.Name = "анализToolStripMenuItem";
|
||||||
|
анализToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
|
||||||
|
анализToolStripMenuItem.Size = new Size(233, 26);
|
||||||
|
анализToolStripMenuItem.Text = "Анализ";
|
||||||
|
анализToolStripMenuItem.Click += анализToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// FormUniversity
|
// FormUniversity
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
@ -152,5 +163,6 @@
|
|||||||
private ToolStripMenuItem StatementToolStripMenuItem;
|
private ToolStripMenuItem StatementToolStripMenuItem;
|
||||||
private ToolStripMenuItem ToolStripMenuItemDirectory;
|
private ToolStripMenuItem ToolStripMenuItemDirectory;
|
||||||
private ToolStripMenuItem операцииToolStripMenuItem;
|
private ToolStripMenuItem операцииToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem анализToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -113,5 +113,18 @@ namespace StudentProgressRecord
|
|||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void анализToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormStatementDistributionReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,6 @@ namespace StudentProgressRecord
|
|||||||
container.RegisterType<IStudentTransitionRepository, StudentTransitionRepository>
|
container.RegisterType<IStudentTransitionRepository, StudentTransitionRepository>
|
||||||
(new TransientLifetimeManager());
|
(new TransientLifetimeManager());
|
||||||
|
|
||||||
container.RegisterType<FormDirectoryReport>();
|
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
54
StudentProgressRecord/Reports/ChartReport.cs
Normal file
54
StudentProgressRecord/Reports/ChartReport.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using StudentProgressRecord.Repositories;
|
||||||
|
using StudentProgressRecord.RepositoryImp;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StudentProgressRecord.Reports
|
||||||
|
{
|
||||||
|
internal class ChartReport
|
||||||
|
{
|
||||||
|
private readonly IStatementRepository _statementRepository;
|
||||||
|
private readonly ILogger<ChartReport> _logger;
|
||||||
|
public ChartReport(IStatementRepository statementRepository,
|
||||||
|
ILogger<ChartReport> logger)
|
||||||
|
{
|
||||||
|
_statementRepository = statementRepository ?? throw new ArgumentNullException(nameof(statementRepository));
|
||||||
|
_logger = logger ??
|
||||||
|
throw new ArgumentNullException(nameof(logger));
|
||||||
|
}
|
||||||
|
public bool CreateChart(string filePath, DateTime dateTimeStart, DateTime dateTimeEnd)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new PdfBuilder(filePath)
|
||||||
|
.AddHeader("Оценки студентов")
|
||||||
|
.AddPieChart("Оценки", GetData(dateTimeStart, dateTimeEnd))
|
||||||
|
.Build();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private List<(string Caption, double Value)> GetData(DateTime dateTimeStart, DateTime dateTimeEnd)
|
||||||
|
{
|
||||||
|
|
||||||
|
return _statementRepository
|
||||||
|
.ReadStatements()
|
||||||
|
.Where(x => x.Date >= dateTimeStart && x.Date <= dateTimeEnd)
|
||||||
|
.SelectMany(x => x.Marks)
|
||||||
|
.GroupBy(x => x.Mark, (key, group) => new {
|
||||||
|
Id = key,
|
||||||
|
Count = group.Count()
|
||||||
|
})
|
||||||
|
.Select(x => (x.Id.ToString(), (double)x.Count))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StudentProgressRecord.Reports
|
namespace StudentProgressRecord.Reports
|
||||||
{
|
{
|
||||||
internal class PdfBuilder
|
public class PdfBuilder
|
||||||
{
|
{
|
||||||
private readonly string _filePath;
|
private readonly string _filePath;
|
||||||
private readonly Document _document;
|
private readonly Document _document;
|
||||||
|
1
StudentProgressRecord/Temp.txt
Normal file
1
StudentProgressRecord/Temp.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
Loading…
x
Reference in New Issue
Block a user