Пибд-24. Ередавкин Р.А Лабораторная работа 2 #2
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -9,17 +10,17 @@ namespace PIbd_24_EredavkinRA_BusBusiness.Entities;
|
||||
public class Bus
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Model { get; private set; } = string.Empty;
|
||||
public ModelType ModelType { get; private set; }
|
||||
public string N_Z { get; private set; } = string.Empty;
|
||||
public int Capacity { get; private set; }
|
||||
public int Bus_mileage { get; private set; }
|
||||
public double Bus_mileage { get; private set; }
|
||||
|
||||
public static Bus CreateEntity(int id, string model, string n_z, int capacity, int bus_mileage)
|
||||
public static Bus CreateEntity(int id, ModelType modeltype, string n_z, double bus_mileage, int capacity)
|
||||
{
|
||||
return new Bus
|
||||
{
|
||||
Id = id,
|
||||
Model = model ?? string.Empty,
|
||||
ModelType = modeltype,
|
||||
N_Z = n_z ?? string.Empty,
|
||||
Capacity = capacity,
|
||||
Bus_mileage = bus_mileage
|
||||
|
@ -9,23 +9,23 @@ namespace PIbd_24_EredavkinRA_BusBusiness.Entities;
|
||||
public class RoutSheet
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public int RoutId { get; private set; }
|
||||
|
||||
public IEnumerable<RoutSheetBus> RoutSheetBuses { get; private set; } = [];
|
||||
public int DriverId { get; private set; }
|
||||
public int ConductorId { get; private set; }
|
||||
public int RoutId { get; private set; }
|
||||
|
||||
public IEnumerable<RoutSheetBus> RoutSheetBus { get; private set; } = [];
|
||||
|
||||
public DateTime BusDate { get; private set; }
|
||||
public static RoutSheet CreatOpeartion(int id, int routid, int driverid, int conductorid, IEnumerable<RoutSheetBus> RoutSheetBuses)
|
||||
public static RoutSheet CreatOpeartion(int id, int driverid, int conductorid, int routid, DateTime busDate, IEnumerable<RoutSheetBus> RoutSheetBus)
|
||||
{
|
||||
return new RoutSheet
|
||||
{
|
||||
Id = id,
|
||||
RoutId = routid,
|
||||
RoutSheetBuses = RoutSheetBuses,
|
||||
DriverId = driverid,
|
||||
ConductorId = conductorid,
|
||||
BusDate = DateTime.Now
|
||||
RoutId = routid,
|
||||
RoutSheetBus = RoutSheetBus,
|
||||
BusDate = busDate,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class Staff
|
||||
public string LastName { get; private set; } = string.Empty;
|
||||
|
||||
public EmployeePost EmployeePost { get; private set; }
|
||||
public static Staff CreatEntity(int id, string first, string last, EmployeePost employeePost)
|
||||
public static Staff CreatEntity(int id, string first, string last, EmployeePost employeePost)
|
||||
{
|
||||
return new Staff
|
||||
{
|
||||
|
@ -12,22 +12,22 @@ public class To
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int BusID { get; private set; }
|
||||
public int MechanicID { get; private set; }
|
||||
public string Description { get; private set; } = string.Empty;
|
||||
public int StaffID { get; private set; }
|
||||
public string Discription { get; private set; } = string.Empty;
|
||||
|
||||
public int Cost { get; private set; }
|
||||
public double Cost { get; private set; }
|
||||
public DateTime DateTo { get; private set; }
|
||||
|
||||
public static To CreatOperation(int id, string description, int cost, int busid, int mechanicid)
|
||||
public static To CreatOperation(int id, string discription, double cost, DateTime dateTo, int busid, int staffid)
|
||||
{
|
||||
return new To()
|
||||
{
|
||||
Id = id,
|
||||
Description = description ?? string.Empty,
|
||||
Discription = discription ?? string.Empty,
|
||||
Cost = cost,
|
||||
DateTo = DateTime.Now,
|
||||
DateTo = dateTo,
|
||||
BusID = busid,
|
||||
MechanicID = mechanicid
|
||||
StaffID = staffid
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -33,13 +33,13 @@
|
||||
labelMileage = new Label();
|
||||
labelCpacity = new Label();
|
||||
textBoxNZ = new TextBox();
|
||||
Mileage = new NumericUpDown();
|
||||
numericUpDownCapacity = new NumericUpDown();
|
||||
Mileage = new NumericUpDown();
|
||||
buttonSave = new Button();
|
||||
buttonleave = new Button();
|
||||
comboBoxBus = new ComboBox();
|
||||
((System.ComponentModel.ISupportInitialize)Mileage).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)Mileage).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelModel
|
||||
@ -85,22 +85,22 @@
|
||||
textBoxNZ.Size = new Size(386, 23);
|
||||
textBoxNZ.TabIndex = 5;
|
||||
//
|
||||
// Mileage
|
||||
//
|
||||
Mileage.Location = new Point(182, 99);
|
||||
Mileage.Maximum = new decimal(new int[] { 2000000, 0, 0, 0 });
|
||||
Mileage.Name = "Mileage";
|
||||
Mileage.Size = new Size(199, 23);
|
||||
Mileage.TabIndex = 6;
|
||||
//
|
||||
// numericUpDownCapacity
|
||||
//
|
||||
numericUpDownCapacity.DecimalPlaces = 2;
|
||||
numericUpDownCapacity.Location = new Point(267, 145);
|
||||
numericUpDownCapacity.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDownCapacity.Location = new Point(253, 147);
|
||||
numericUpDownCapacity.Maximum = new decimal(new int[] { 2000000, 0, 0, 0 });
|
||||
numericUpDownCapacity.Name = "numericUpDownCapacity";
|
||||
numericUpDownCapacity.Size = new Size(131, 23);
|
||||
numericUpDownCapacity.TabIndex = 7;
|
||||
numericUpDownCapacity.Size = new Size(199, 23);
|
||||
numericUpDownCapacity.TabIndex = 6;
|
||||
//
|
||||
// Mileage
|
||||
//
|
||||
Mileage.DecimalPlaces = 2;
|
||||
Mileage.Location = new Point(182, 105);
|
||||
Mileage.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
|
||||
Mileage.Name = "Mileage";
|
||||
Mileage.Size = new Size(131, 23);
|
||||
Mileage.TabIndex = 7;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
@ -139,8 +139,8 @@
|
||||
Controls.Add(comboBoxBus);
|
||||
Controls.Add(buttonleave);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(numericUpDownCapacity);
|
||||
Controls.Add(Mileage);
|
||||
Controls.Add(numericUpDownCapacity);
|
||||
Controls.Add(textBoxNZ);
|
||||
Controls.Add(labelCpacity);
|
||||
Controls.Add(labelMileage);
|
||||
@ -149,8 +149,8 @@
|
||||
Name = "FormBus";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Автобусы";
|
||||
((System.ComponentModel.ISupportInitialize)Mileage).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)Mileage).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -162,8 +162,8 @@
|
||||
private Label labelMileage;
|
||||
private Label labelCpacity;
|
||||
private TextBox textBoxNZ;
|
||||
private NumericUpDown Mileage;
|
||||
private NumericUpDown numericUpDownCapacity;
|
||||
private NumericUpDown Mileage;
|
||||
private Button buttonSave;
|
||||
private Button buttonleave;
|
||||
private ComboBox comboBoxBus;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Entities;
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Entities.Enums;
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
|
||||
using System;
|
||||
@ -28,9 +29,9 @@ public partial class FormBus : Form
|
||||
{
|
||||
throw new InvalidDataException(nameof(bus));
|
||||
}
|
||||
comboBoxBus.Text = bus.Model;
|
||||
comboBoxBus.SelectedItem = bus.ModelType;
|
||||
textBoxNZ.Text = bus.N_Z;
|
||||
Mileage.Value = bus.Bus_mileage;
|
||||
Mileage.Value = (decimal)bus.Bus_mileage;
|
||||
numericUpDownCapacity.Value = bus.Capacity;
|
||||
_busId = bus.Id;
|
||||
}
|
||||
@ -48,13 +49,14 @@ public partial class FormBus : Form
|
||||
InitializeComponent();
|
||||
_busRepository = busRepository ??
|
||||
throw new ArgumentNullException(nameof(busRepository));
|
||||
comboBoxBus.DataSource = Enum.GetValues(typeof(ModelType));
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(comboBoxBus.Text) ||string.IsNullOrWhiteSpace(textBoxNZ.Text))
|
||||
if (comboBoxBus.SelectedIndex < 1 || string.IsNullOrWhiteSpace(textBoxNZ.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
@ -78,10 +80,11 @@ public partial class FormBus : Form
|
||||
private void buttonleave_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private Bus CreateBus(int id) => Bus.CreateEntity(id,
|
||||
comboBoxBus.Text,
|
||||
(ModelType)comboBoxBus.SelectedItem!,
|
||||
textBoxNZ.Text,
|
||||
Convert.ToInt32(Mileage.Value),
|
||||
Convert.ToDouble(Mileage.Value),
|
||||
Convert.ToInt32(numericUpDownCapacity.Value));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -39,13 +39,15 @@
|
||||
comboBoxDriver = new ComboBox();
|
||||
comboBoxConductor = new ComboBox();
|
||||
comboBoxRout = new ComboBox();
|
||||
dateTimePicker1 = new DateTimePicker();
|
||||
npgsqlDataAdapter1 = new Npgsql.NpgsqlDataAdapter();
|
||||
groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewRoutSheet).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(21, 538);
|
||||
buttonSave.Location = new Point(12, 604);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(81, 35);
|
||||
buttonSave.TabIndex = 8;
|
||||
@ -55,7 +57,7 @@
|
||||
//
|
||||
// buttonLeave
|
||||
//
|
||||
buttonLeave.Location = new Point(179, 538);
|
||||
buttonLeave.Location = new Point(179, 604);
|
||||
buttonLeave.Name = "buttonLeave";
|
||||
buttonLeave.Size = new Size(92, 35);
|
||||
buttonLeave.TabIndex = 9;
|
||||
@ -66,7 +68,7 @@
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(dataGridViewRoutSheet);
|
||||
groupBox1.Location = new Point(21, 145);
|
||||
groupBox1.Location = new Point(21, 211);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(250, 387);
|
||||
groupBox1.TabIndex = 10;
|
||||
@ -92,7 +94,6 @@
|
||||
ColumnBus.HeaderText = "Автобус";
|
||||
ColumnBus.Name = "ColumnBus";
|
||||
ColumnBus.Resizable = DataGridViewTriState.True;
|
||||
ColumnBus.Sorted = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
@ -148,11 +149,26 @@
|
||||
comboBoxRout.Size = new Size(188, 23);
|
||||
comboBoxRout.TabIndex = 17;
|
||||
//
|
||||
// dateTimePicker1
|
||||
//
|
||||
dateTimePicker1.Location = new Point(12, 141);
|
||||
dateTimePicker1.Name = "dateTimePicker1";
|
||||
dateTimePicker1.Size = new Size(256, 23);
|
||||
dateTimePicker1.TabIndex = 18;
|
||||
//
|
||||
// npgsqlDataAdapter1
|
||||
//
|
||||
npgsqlDataAdapter1.DeleteCommand = null;
|
||||
npgsqlDataAdapter1.InsertCommand = null;
|
||||
npgsqlDataAdapter1.SelectCommand = null;
|
||||
npgsqlDataAdapter1.UpdateCommand = null;
|
||||
//
|
||||
// FormRoutSheet
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(310, 582);
|
||||
ClientSize = new Size(292, 651);
|
||||
Controls.Add(dateTimePicker1);
|
||||
Controls.Add(comboBoxRout);
|
||||
Controls.Add(comboBoxConductor);
|
||||
Controls.Add(comboBoxDriver);
|
||||
@ -182,5 +198,7 @@
|
||||
private ComboBox comboBoxConductor;
|
||||
private ComboBox comboBoxRout;
|
||||
private DataGridViewComboBoxColumn ColumnBus;
|
||||
private DateTimePicker dateTimePicker1;
|
||||
private Npgsql.NpgsqlDataAdapter npgsqlDataAdapter1;
|
||||
}
|
||||
}
|
@ -13,17 +13,20 @@ public partial class FormRoutSheet : Form
|
||||
_routSheetRepository = routSheetRepository ?? throw new ArgumentNullException(nameof(routSheetRepository));
|
||||
|
||||
comboBoxDriver.DataSource = staffRepositories.ReadStaff();
|
||||
comboBoxDriver.DisplayMember = "FirstName";
|
||||
comboBoxDriver.DisplayMember = "Id";
|
||||
comboBoxDriver.DisplayMember = "LastName";
|
||||
comboBoxDriver.ValueMember = "Id";
|
||||
|
||||
comboBoxConductor.DataSource = staffRepositories.ReadStaff();
|
||||
comboBoxConductor.DisplayMember = "FirstName";
|
||||
comboBoxConductor.DisplayMember = "Id";
|
||||
comboBoxConductor.DisplayMember = "LastName";
|
||||
comboBoxConductor.ValueMember = "Id";
|
||||
|
||||
comboBoxRout.DataSource = routRepositories.ReadRout();
|
||||
comboBoxRout.DisplayMember = "NumberRout";
|
||||
comboBoxRout.DisplayMember = "Id";
|
||||
comboBoxRout.ValueMember = "Id";
|
||||
|
||||
ColumnBus.DataSource = busRepository.ReadBus();
|
||||
ColumnBus.DisplayMember = "N_Z";
|
||||
ColumnBus.ValueMember = "Id";
|
||||
|
||||
|
||||
|
||||
@ -33,15 +36,15 @@ public partial class FormRoutSheet : Form
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dataGridViewRoutSheet.RowCount < 0 || comboBoxDriver.SelectedIndex < 0 || comboBoxRout.SelectedIndex < 0)
|
||||
if (dataGridViewRoutSheet.RowCount < 1 || comboBoxDriver.SelectedIndex < 0 || comboBoxRout.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Имеются не заполненые поля");
|
||||
}
|
||||
_routSheetRepository.CreateRoutSheet(RoutSheet.CreatOpeartion(0, (int)comboBoxDriver.SelectedValue!, (int)comboBoxConductor.SelectedValue!,
|
||||
(int)comboBoxRout.SelectedValue!, CreateListRoudSheetBusFromDataGrid()));
|
||||
(int)comboBoxRout.SelectedValue!, dateTimePicker1.Value, CreateListRoudSheetBusFromDataGrid()));
|
||||
Close();
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
@ -60,12 +63,11 @@ public partial class FormRoutSheet : Form
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list.Add(RoutSheetBus.CreateElement(0,
|
||||
Convert.ToInt32(row.Cells["ColumnBus"].Value)));
|
||||
list.Add(RoutSheetBus.CreateElement(0, Convert.ToInt32( row.Cells["ColumnBus"].Value)));
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -120,4 +120,7 @@
|
||||
<metadata name="ColumnBus.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="npgsqlDataAdapter1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -61,7 +61,7 @@ public partial class FormRoutes : Form
|
||||
}
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<FormBus>();
|
||||
var form = _container.Resolve<FormRout>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
|
@ -40,14 +40,14 @@
|
||||
//
|
||||
// textBoxLastName
|
||||
//
|
||||
textBoxLastName.Location = new Point(132, 12);
|
||||
textBoxLastName.Location = new Point(132, 65);
|
||||
textBoxLastName.Name = "textBoxLastName";
|
||||
textBoxLastName.Size = new Size(228, 23);
|
||||
textBoxLastName.TabIndex = 1;
|
||||
//
|
||||
// textBoxFirstName
|
||||
//
|
||||
textBoxFirstName.Location = new Point(132, 65);
|
||||
textBoxFirstName.Location = new Point(132, 15);
|
||||
textBoxFirstName.Name = "textBoxFirstName";
|
||||
textBoxFirstName.Size = new Size(228, 23);
|
||||
textBoxFirstName.TabIndex = 2;
|
||||
|
@ -57,7 +57,7 @@ public partial class FormStaff : Form
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) ||string.IsNullOrWhiteSpace(textBoxLastName.Text) || checkedListBoxStaff.CheckedItems.Count == 1)
|
||||
if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) ||string.IsNullOrWhiteSpace(textBoxLastName.Text) || checkedListBoxStaff.CheckedItems.Count == 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненныеполя");
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace PIbd_24_EredavkinRA_BusBusiness.Forms
|
||||
}
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<FormBus>();
|
||||
var form = _container.Resolve<FormStaff>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
|
@ -118,6 +118,7 @@
|
||||
//
|
||||
numericUpDownCost.DecimalPlaces = 2;
|
||||
numericUpDownCost.Location = new Point(105, 334);
|
||||
numericUpDownCost.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
|
||||
numericUpDownCost.Name = "numericUpDownCost";
|
||||
numericUpDownCost.Size = new Size(238, 23);
|
||||
numericUpDownCost.TabIndex = 16;
|
||||
|
@ -15,7 +15,7 @@ public partial class FormTO : Form
|
||||
_toRepository = toRepository ?? throw new ArgumentNullException(nameof(toRepository));
|
||||
|
||||
comboBoxStaff.DataSource = staffRepositories.ReadStaff();
|
||||
comboBoxStaff.DisplayMember = "FirstName";
|
||||
comboBoxStaff.DisplayMember = "LastName";
|
||||
comboBoxStaff.ValueMember = "Id";
|
||||
|
||||
comboBoxBus.DataSource = busRepository.ReadBus();
|
||||
@ -31,7 +31,7 @@ public partial class FormTO : Form
|
||||
{
|
||||
throw new Exception("Имеются не заполненые поля");
|
||||
}
|
||||
_toRepository.CreateTo(To.CreatOperation(0, textBoxDescription.Text, Convert.ToInt32(numericUpDownCost.Value), (int)comboBoxBus.SelectedValue!,
|
||||
_toRepository.CreateTo(To.CreatOperation(0, textBoxDescription.Text, Convert.ToDouble(numericUpDownCost.Value), dateTimePicker1.Value, (int)comboBoxBus.SelectedValue!,
|
||||
(int)comboBoxStaff.SelectedValue!));
|
||||
Close();
|
||||
}
|
||||
|
@ -10,7 +10,18 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Npgsql" Version="9.0.1" />
|
||||
<PackageReference Include="Serilog" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,6 +1,11 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
|
||||
using Serilog;
|
||||
using Unity;
|
||||
using Unity.Lifetime;
|
||||
using Unity.Microsoft.Logging;
|
||||
|
||||
namespace PIbd_24_EredavkinRA_BusBusiness
|
||||
{
|
||||
@ -21,12 +26,26 @@ namespace PIbd_24_EredavkinRA_BusBusiness
|
||||
private static IUnityContainer CreateContainer()
|
||||
{
|
||||
var container = new UnityContainer();
|
||||
container.RegisterType<IBusRepository, BusRepository>();
|
||||
container.RegisterType<IRoutRepositories, RoutRepositories>();
|
||||
container.RegisterType<IRoutSheetRepository, RoutSheetRepository>();
|
||||
container.RegisterType<IStaffRepositories, StaffRepository>();
|
||||
container.RegisterType<IToRepository, ToRepository>();
|
||||
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
||||
container.RegisterType<IBusRepository, BusRepository>(new TransientLifetimeManager());
|
||||
container.RegisterType<IRoutRepositories, RoutRepositories>(new TransientLifetimeManager());
|
||||
container.RegisterType<IRoutSheetRepository, RoutSheetRepository>(new TransientLifetimeManager());
|
||||
container.RegisterType<IStaffRepositories, StaffRepository>(new TransientLifetimeManager());
|
||||
container.RegisterType<IToRepository, ToRepository>(new TransientLifetimeManager());
|
||||
|
||||
container.RegisterType<IConnectionString, ConnectionString>(new SingletonLifetimeManager());
|
||||
return container;
|
||||
}
|
||||
private static LoggerFactory CreateLoggerFactory()
|
||||
{
|
||||
var loggerFactory = new LoggerFactory();
|
||||
loggerFactory.AddSerilog(new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build())
|
||||
.CreateLogger());
|
||||
return loggerFactory;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
|
||||
namespace PIbd_24_EredavkinRA_BusBusiness.Repositories;
|
||||
|
||||
public interface IConnectionString
|
||||
{
|
||||
public string ConnectionString { get; }
|
||||
}
|
@ -11,5 +11,5 @@ public interface IRoutSheetRepository
|
||||
{
|
||||
IEnumerable<RoutSheet> ReadRoutSheet(DateTime? dateForm = null, DateTime? dateTo = null, int? routId = null, int? busid = null, int? driverid = null, int? conductorid = null);
|
||||
void CreateRoutSheet(RoutSheet routsheet);
|
||||
void DeleteRoutSheet(int id);
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,8 @@
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Entities;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -10,28 +14,114 @@ namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
|
||||
|
||||
public class BusRepository : IBusRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
|
||||
private readonly ILogger<BusRepository> _logger;
|
||||
|
||||
public BusRepository(IConnectionString connectionString, ILogger<BusRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateBus(Bus bus)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(bus));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO Bus (ModelType, N_Z, Capacity, Bus_mileage)
|
||||
VALUES (@ModelType, @N_Z, @Capacity, @Bus_mileage)";
|
||||
connection.Execute(queryInsert, bus);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void UpdateBus(Bus bus)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(bus));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE Bus
|
||||
SET
|
||||
ModelType=@ModelType,
|
||||
N_Z=@N_Z,
|
||||
Capacity=@Capacity,
|
||||
Bus_mileage=@Bus_mileage
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, bus);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteBus(int id)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM Bus
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public Bus ReadBusByID(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM Bus
|
||||
WHERE Id=@id";
|
||||
var bus = connection.QueryFirst<Bus>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(bus));
|
||||
return bus;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Bus> ReadBus()
|
||||
{
|
||||
return [];
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Bus";
|
||||
var bus = connection.Query<Bus>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(bus));
|
||||
return bus;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Bus ReadBusByID(int id)
|
||||
{
|
||||
return Bus.CreateEntity(0, string.Empty, string.Empty, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
public void UpdateBus(Bus bus)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
|
||||
|
||||
internal class ConnectionString : IConnectionString
|
||||
{
|
||||
string IConnectionString.ConnectionString => "Host=127.0.0.1:5432;Database=basdetebus;Username=postgres;Password=postgres; Include Error Detail=true;";
|
||||
}
|
@ -1,4 +1,8 @@
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Entities;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -9,28 +13,113 @@ namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
|
||||
|
||||
public class RoutRepositories : IRoutRepositories
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
|
||||
private readonly ILogger<RoutRepositories> _logger;
|
||||
|
||||
public RoutRepositories(IConnectionString connectionString, ILogger<RoutRepositories> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateRout(Rout rout)
|
||||
{
|
||||
|
||||
}
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(rout));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO Rout (StartStop, EndStop, NumberRout)
|
||||
VALUES (@StartStop, @EndStop, @NumberRout)";
|
||||
connection.Execute(queryInsert, rout);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
|
||||
public void DeleteRout(int id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<Rout> ReadRout()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public Rout ReadRoutByID(int id)
|
||||
{
|
||||
return Rout.CreateEntity(0, string.Empty, string.Empty, 0);
|
||||
}
|
||||
|
||||
public void UpdateRout(Rout rout)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(rout));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE Rout
|
||||
SET
|
||||
StartStop=@StartStop,
|
||||
EndStop=@EndStop,
|
||||
NumberRout=@NumberRout
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, rout);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void DeleteRout(int id)
|
||||
{
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM Rout
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public Rout ReadRoutByID(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM Rout
|
||||
WHERE Id=@id";
|
||||
var rout = connection.QueryFirst<Rout>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(rout));
|
||||
return rout;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public IEnumerable<Rout> ReadRout()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Rout";
|
||||
var rout = connection.Query<Rout>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(rout));
|
||||
return rout;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,26 +1,72 @@
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Entities;
|
||||
|
||||
|
||||
namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
|
||||
|
||||
public class RoutSheetRepository : IRoutSheetRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
|
||||
private readonly ILogger<RoutSheetRepository> _logger;
|
||||
|
||||
public RoutSheetRepository(IConnectionString connectionString, ILogger<RoutSheetRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateRoutSheet(RoutSheet routsheet)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(routsheet));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
connection.Open();
|
||||
using var transaction = connection.BeginTransaction();
|
||||
var queryInsert = @"
|
||||
INSERT INTO RoutSheet (RoutId, DriverId, ConductorId, BusDate)
|
||||
VALUES (@RoutId, @DriverId, @ConductorID, @BusDate);
|
||||
SELECT MAX(Id) FROM RoutSheet";
|
||||
var routsheetId = connection.QueryFirst<int>(queryInsert, routsheet, transaction);
|
||||
|
||||
var querySubInsert = @"
|
||||
INSERT INTO RoutSheetBus (RoutSheetId, BusId)
|
||||
VALUES (@RoutSheetId, @BusId)";
|
||||
foreach (var elem in routsheet.RoutSheetBus)
|
||||
{
|
||||
connection.Execute(querySubInsert, new { routsheetId, elem.BusID }, transaction);
|
||||
}
|
||||
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteRoutSheet(int id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<RoutSheet> ReadRoutSheet(DateTime? dateForm = null, DateTime? dateTo = null, int? routId = null, int? busid = null, int? driverid = null, int? conductorid = null)
|
||||
public IEnumerable<RoutSheet> ReadRoutSheet(DateTime? dateForm = null, DateTime? dateBus = null, int? routId = null, int? busid = null, int? driverid = null, int? conductorid = null)
|
||||
{
|
||||
return [];
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM RoutSheet";
|
||||
var routsheet = connection.Query<RoutSheet>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(routsheet));
|
||||
return routsheet;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,8 @@
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Entities;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Entities;
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -10,28 +14,112 @@ namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
|
||||
|
||||
internal class StaffRepository : IStaffRepositories
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
|
||||
private readonly ILogger<StaffRepository> _logger;
|
||||
public StaffRepository(IConnectionString connectionString, ILogger<StaffRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateStaff(Staff staff)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(staff));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO Staff (FirstName, LastName, EmployeePost)
|
||||
VALUES (@FirstName, @LastName, @EmployeePost)";
|
||||
connection.Execute(queryInsert, staff);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void UpdateStaff(Staff staff)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(staff));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE Staff
|
||||
SET
|
||||
FirstName=@FirstName,
|
||||
LastName=@LastName,
|
||||
EmployeePost=@EmployeePost
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, staff);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void DeleteStaff(int id)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM Staff
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public Staff ReadStaffByID(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM Staff
|
||||
WHERE Id=@id";
|
||||
var staff = connection.QueryFirst<Staff>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(staff));
|
||||
return staff;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Staff> ReadStaff()
|
||||
{
|
||||
return [];
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Staff";
|
||||
var staff = connection.Query<Staff>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(staff));
|
||||
return staff;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Staff ReadStaffByID(int id)
|
||||
{
|
||||
return Staff.CreatEntity(0, string.Empty, string.Empty, EmployeePost.None);
|
||||
}
|
||||
|
||||
public void UpdateStaff(Staff staff)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,8 @@
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Entities;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using PIbd_24_EredavkinRA_BusBusiness.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -9,19 +13,69 @@ namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
|
||||
|
||||
public class ToRepository : IToRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
|
||||
private readonly ILogger<ToRepository> _logger;
|
||||
|
||||
public ToRepository(IConnectionString connectionString, ILogger<ToRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateTo(To to)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(to));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO TOs (BusId, StaffId, Discription, Cost, DateTo)
|
||||
VALUES (@BusId, @StaffId, @Discription, @Cost, @DateTo)";
|
||||
connection.Execute(queryInsert, to);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteTo(int id)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM TOs
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<To> ReadTo(DateTime? dateForm = null, DateTime? dateTo = null, int? mechanicid = null, int? busid = null)
|
||||
public IEnumerable<To> ReadTo(DateTime? dateForm = null, DateTime? dateTo = null, int? staffid = null, int? busid = null)
|
||||
{
|
||||
return [];
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM TOs";
|
||||
var compilingSchedules = connection.Query<To>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(compilingSchedules));
|
||||
return compilingSchedules;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [ "Serilog.Sinks.File" ],
|
||||
"MinimumLevel": "Debug",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/schedule_log.txt",
|
||||
"rollingInterval": "Day"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
31
test/test.sln
Normal file
31
test/test.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34728.123
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", "{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Debug|x64.Build.0 = Debug|x64
|
||||
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Debug|x86.Build.0 = Debug|Win32
|
||||
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Release|x64.ActiveCfg = Release|x64
|
||||
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Release|x64.Build.0 = Release|x64
|
||||
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Release|x86.ActiveCfg = Release|Win32
|
||||
{F77B0358-2B48-4BD7-8CCD-1AD9C73D1BCB}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {0CC34090-EEB4-4546-B06A-461C6A4A843F}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
34
test/test/test.cpp
Normal file
34
test/test/test.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
|
||||
|
||||
int power_of_2 = 0;
|
||||
int power_of_5 = 0;
|
||||
|
||||
|
||||
while (n % 2 == 0) {
|
||||
n /= 2;
|
||||
power_of_2++;
|
||||
}
|
||||
|
||||
while (n % 5 == 0) {
|
||||
n /= 5;
|
||||
power_of_5++;
|
||||
}
|
||||
|
||||
if (n > 1) {
|
||||
cout << "No" << endl;
|
||||
}
|
||||
else {
|
||||
|
||||
cout << max(power_of_2, power_of_5) << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
135
test/test/test.vcxproj
Normal file
135
test/test/test.vcxproj
Normal file
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{f77b0358-2b48-4bd7-8ccd-1ad9c73d1bcb}</ProjectGuid>
|
||||
<RootNamespace>test</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="test.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
22
test/test/test.vcxproj.filters
Normal file
22
test/test/test.vcxproj.filters
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Исходные файлы">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Файлы заголовков">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Файлы ресурсов">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="test.cpp">
|
||||
<Filter>Исходные файлы</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user
Это что такое?