DepartmentProject/DepartmentPortal/Security/SecurityWindowsDesktop/SpecialControls/BackupControl.cs

89 lines
2.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DesktopTools.Helpers;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using ModuleTools.BusinessLogics;
using ModuleTools.Enums;
using SecurityBusinessLogic.BindingModels;
using SecurityBusinessLogic.BusinessLogics;
using System;
using System.Windows.Forms;
namespace SecurityWindowsDesktop.SpecialControls
{
public partial class BackupControl : UserControl, IControl
{
private readonly BackupBusinessLogic _businessLogic;
/// <summary>
/// Событие, вызываемое при закрытии контрола
/// </summary>
private event Action<Guid> CloseEvent;
public BackupControl()
{
InitializeComponent();
_businessLogic = DependencyManager.Instance.Resolve<BackupBusinessLogic>();
Title = "Работа с бекапом";
ControlId = new Guid("cc9844e6-5d92-4c89-b817-4c17ec382bc1");
AccessOperation = AccessOperation.РаботасБекапом;
}
public Guid ControlId { get; private set; }
public string Title { get; private set; }
public AccessOperation AccessOperation { get; private set; }
public IControl GetInstance() => new BackupControl() { ControlId = Guid.NewGuid() };
public void LoadFromXml(string xml)
{
}
public void Open(ControlOpenModel model)
{
if (model.CloseList != null)
{
CloseEvent += model.CloseList;
}
Dock = DockStyle.Fill;
}
public string SaveToXml()
{
return string.Empty;
}
private void ButtonSelectFolder_Click(object sender, EventArgs e)
{
var fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
{
textBoxFolderName.Text = fbd.SelectedPath;
}
}
private void ButtonCreateBackup_Click(object sender, EventArgs e)
{
if (_businessLogic.CreateBackUp(new BackupBindingModel
{
FolderName = textBoxFolderName.Text,
FullData = checkBoxFullLoad.Checked,
CreateArchive = checkBoxCreateArchive.Checked
}))
{
DialogHelper.MessageInformation("Сохранение прошло успешно", "Результат");
}
else
{
DialogHelper.MessageException(_businessLogic.Errors, "Ошибки при сохранении");
}
}
private void ToolStripHeader_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
CloseEvent?.Invoke(ControlId);
Dispose();
}
}
}