2021-04-02 20:46:41 +04:00
|
|
|
|
using ModuleTools.BusinessLogics;
|
|
|
|
|
using ModuleTools.Enums;
|
|
|
|
|
using SecurityBusinessLogic.Interfaces;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace SecurityBusinessLogic.BusinessLogics
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Логика синхронизации пользователей
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class SynchronizationBusinessLogic : CoreBusinessLogic
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Серивс для работы с бекапом
|
|
|
|
|
/// </summary>
|
|
|
|
|
private readonly ISynchronizationService _service;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Логика работы с бекапом
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="service"></param>
|
2021-04-05 10:08:49 +04:00
|
|
|
|
public SynchronizationBusinessLogic(ISynchronizationService service)
|
|
|
|
|
{
|
|
|
|
|
_service = service;
|
|
|
|
|
_serviceOperation = AccessOperation.Синхронизация;
|
|
|
|
|
_entity = "Синхронизация";
|
|
|
|
|
}
|
2021-04-02 20:46:41 +04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Запуск синхронизации
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool RunSynchronization()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-04-05 10:08:49 +04:00
|
|
|
|
if (NoAccess(null, AccessType.Delete))
|
2021-04-02 20:46:41 +04:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
var result = _service.RunSynchronization();
|
|
|
|
|
if (!result.IsSucceeded)
|
|
|
|
|
{
|
|
|
|
|
Errors.AddRange(result.Errors);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Errors.Add(("Ошибка", ex.Message));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|