2022-03-18 22:48:14 +04:00
|
|
|
|
using ToolsDesktop.Helpers;
|
|
|
|
|
using ToolsDesktop.Interfaces;
|
|
|
|
|
using ToolsDesktop.Models;
|
2022-03-18 22:38:52 +04:00
|
|
|
|
using ToolsModule.BusinessLogics;
|
|
|
|
|
using ToolsModule.Enums;
|
2021-04-02 20:46:41 +04:00
|
|
|
|
using SecurityBusinessLogic.BusinessLogics;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
|
|
|
|
namespace SecurityWindowsDesktop.SpecialControls
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Контрол для работы с синхронизацией
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class SynchronizationControl : UserControl, IControl
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Класс с бизнес-логикой работы с синхронизацией
|
|
|
|
|
/// </summary>
|
|
|
|
|
private readonly SynchronizationBusinessLogic _businessLogic;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Событие, вызываемое при закрытии контрола
|
|
|
|
|
/// </summary>
|
|
|
|
|
private event Action<Guid> CloseEvent;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Контрол для работы с синхронизацией
|
|
|
|
|
/// </summary>
|
|
|
|
|
public SynchronizationControl()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
_businessLogic = DependencyManager.Instance.Resolve<SynchronizationBusinessLogic>();
|
|
|
|
|
Title = "Синхронизация";
|
|
|
|
|
ControlId = new Guid("c392818b-9036-4c4b-8a57-8ff935115e6a");
|
|
|
|
|
AccessOperation = AccessOperation.Синхронизация;
|
|
|
|
|
toolStripButtonClose.Click += (object sender, EventArgs e) =>
|
|
|
|
|
{
|
|
|
|
|
CloseEvent?.Invoke(ControlId);
|
|
|
|
|
Dispose();
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region IControl
|
|
|
|
|
public Guid ControlId { get; private set; }
|
|
|
|
|
|
|
|
|
|
public string Title { get; private set; }
|
|
|
|
|
|
|
|
|
|
public AccessOperation AccessOperation { get; private set; }
|
|
|
|
|
|
|
|
|
|
public IControl GetInstance() => new SynchronizationControl() { ControlId = Guid.NewGuid() };
|
|
|
|
|
|
|
|
|
|
public void Open(ControlOpenModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model.CloseList != null)
|
|
|
|
|
{
|
|
|
|
|
CloseEvent += model.CloseList;
|
|
|
|
|
}
|
|
|
|
|
Dock = DockStyle.Fill;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string SaveToXml() => new XElement("Control",
|
|
|
|
|
new XAttribute("Type", GetType().FullName),
|
|
|
|
|
new XAttribute("ControlId", ControlId),
|
|
|
|
|
new XAttribute("Title", Title),
|
|
|
|
|
new XAttribute("AccessOperation", AccessOperation)).ToString();
|
|
|
|
|
|
|
|
|
|
public void LoadFromXml(string xml)
|
|
|
|
|
{
|
|
|
|
|
var control = XElement.Parse(xml);
|
|
|
|
|
ControlId = new Guid(control.Attribute("ControlId").Value.ToString());
|
|
|
|
|
Title = control.Attribute("Title").Value.ToString();
|
|
|
|
|
AccessOperation = (AccessOperation)Enum.Parse(typeof(AccessOperation), control.Attribute("AccessOperation").Value.ToString());
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Запуск синхронизации
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void ButtonRunSynchronization_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var cursor = Cursor.Current;
|
|
|
|
|
Cursor.Current = Cursors.WaitCursor;
|
|
|
|
|
if (_businessLogic.RunSynchronization())
|
|
|
|
|
{
|
|
|
|
|
DialogHelper.MessageInformation("Синхронизация прошла успешно", "Результат");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DialogHelper.MessageException(_businessLogic.Errors, "Ошибки при синхронизации");
|
|
|
|
|
}
|
|
|
|
|
Cursor.Current = cursor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|