2022-03-19 19:58:10 +04:00
|
|
|
|
using SecurityContract.Interfaces;
|
|
|
|
|
using SecurityContract.Logics;
|
2021-04-02 20:46:41 +04:00
|
|
|
|
using System;
|
2022-03-19 19:58:10 +04:00
|
|
|
|
using ToolsModule.BusinessLogics;
|
|
|
|
|
using ToolsModule.Enums;
|
2021-04-02 20:46:41 +04:00
|
|
|
|
|
|
|
|
|
namespace SecurityBusinessLogic.BusinessLogics
|
|
|
|
|
{
|
2022-03-19 19:58:10 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Логика синхронизации пользователей
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class SynchronizationBusinessLogic : CoreBusinessLogic, ISynchronizationLogic
|
2021-04-02 20:46:41 +04:00
|
|
|
|
{
|
|
|
|
|
/// <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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|