ISEbd-21 Melnikov I. O. Lab Work 08 Base #26

Closed
Igor-Melnikov wants to merge 8 commits from lab8 into lab7
5 changed files with 60 additions and 15 deletions
Showing only changes of commit a33e89a0dd - Show all commits

View File

@ -39,11 +39,12 @@
this.reportManufactureComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.reportOrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.doWorkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mailsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonCreateOrder = new System.Windows.Forms.Button();
this.buttonIssuedOrder = new System.Windows.Forms.Button();
this.buttonRef = new System.Windows.Forms.Button();
this.mailsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.backupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
@ -54,7 +55,8 @@
this.refbooksToolStripMenuItem,
this.reportsToolStripMenuItem,
this.doWorkToolStripMenuItem,
this.mailsToolStripMenuItem});
this.mailsToolStripMenuItem,
this.backupToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(1795, 24);
@ -138,6 +140,13 @@
this.doWorkToolStripMenuItem.Text = "Запуск работ";
this.doWorkToolStripMenuItem.Click += new System.EventHandler(this.DoWorkToolStripMenuItem_Click);
//
// mailsToolStripMenuItem
//
this.mailsToolStripMenuItem.Name = "mailsToolStripMenuItem";
this.mailsToolStripMenuItem.Size = new System.Drawing.Size(62, 20);
this.mailsToolStripMenuItem.Text = "Письма";
this.mailsToolStripMenuItem.Click += new System.EventHandler(this.MailsToolStripMenuItem_Click);
//
// dataGridView
//
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
@ -181,12 +190,12 @@
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// mailsToolStripMenuItem
// backupToolStripMenuItem
//
this.mailsToolStripMenuItem.Name = "mailsToolStripMenuItem";
this.mailsToolStripMenuItem.Size = new System.Drawing.Size(62, 20);
this.mailsToolStripMenuItem.Text = "Письма";
this.mailsToolStripMenuItem.Click += new System.EventHandler(this.MailsToolStripMenuItem_Click);
this.backupToolStripMenuItem.Name = "backupToolStripMenuItem";
this.backupToolStripMenuItem.Size = new System.Drawing.Size(51, 20);
this.backupToolStripMenuItem.Text = "Бэкап";
this.backupToolStripMenuItem.Click += new System.EventHandler(this.BackupToolStripMenuItem_Click);
//
// FormMain
//
@ -228,5 +237,6 @@
private ToolStripMenuItem implementersToolStripMenuItem;
private ToolStripMenuItem doWorkToolStripMenuItem;
private ToolStripMenuItem mailsToolStripMenuItem;
private ToolStripMenuItem backupToolStripMenuItem;
}
}

View File

@ -14,7 +14,8 @@ namespace BlacksmithWorkshopView
private readonly IReportLogic _reportLogic;
private readonly IImplementerLogic _implementerLogic;
private readonly IWorkProcess _workProcess;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IImplementerLogic implementerLogic, IMessageInfoLogic messageInfoLogic)
private readonly IBackupLogic _backupLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IImplementerLogic implementerLogic, IMessageInfoLogic messageInfoLogic, IBackupLogic backupLogic)
{
InitializeComponent();
_logger = logger;
@ -22,6 +23,7 @@ namespace BlacksmithWorkshopView
_reportLogic = reportLogic;
_workProcess = workProcess;
_implementerLogic = implementerLogic;
_backupLogic = backupLogic;
}
private void FormMain_Load(object sender, EventArgs e)
{
@ -191,5 +193,15 @@ namespace BlacksmithWorkshopView
form.ShowDialog();
LoadData();
}
private void BackupToolStripMenuItem_Click(object sender, EventArgs e)
{
using var dialog = new FolderBrowserDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
_backupLogic.CreateBackup(new() { FolderName = dialog.SelectedPath});
MessageBox.Show("Бэкап сохранен", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}

View File

@ -48,8 +48,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
var assembly = typeIId.Assembly;
if (assembly == null)
{
throw new ArgumentNullException("Сборка не найдена",
nameof(assembly));
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
}
var types = assembly.GetTypes();
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);

View File

@ -0,0 +1,29 @@
using BlacksmithWorkshopContracts.StoragesContracts;
using BlacksmithWorkshopDatabaseImplement.Implements;
namespace BlacksmithWorkshopDatabaseImplement
{
public class BackupInfo : IBackupInfo
{
public List<T>? GetList<T>() where T : class, new()
{
using var context = new BlacksmithWorkshopDatabase();
return context.Set<T>().ToList();
}
public Type? GetTypeByModelInterface(string modelInterfaceName)
{
var assembly = typeof(BackupInfo).Assembly;
var types = assembly.GetTypes();
foreach (var type in types)
{
if (type.IsClass &&
type.GetInterface(modelInterfaceName) != null)
{
return type;
}
}
return null;
}
}
}

View File

@ -1,9 +1,4 @@
using BlacksmithWorkshopContracts.StoragesContracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BlacksmithWorkshopListImplement.Implements
{