58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
using SecurityContract.Services;
|
||
using SecurityContract.Logics;
|
||
using System;
|
||
using ToolsModule.BusinessLogics;
|
||
using ToolsModule.Enums;
|
||
|
||
namespace SecurityBusinessLogic.BusinessLogics
|
||
{
|
||
/// <summary>
|
||
/// Логика синхронизации пользователей
|
||
/// </summary>
|
||
public class SynchronizationBusinessLogic : CoreBusinessLogic, ISynchronizationLogic
|
||
{
|
||
/// <summary>
|
||
/// Серивс для работы с бекапом
|
||
/// </summary>
|
||
private readonly ISynchronizationService _service;
|
||
|
||
/// <summary>
|
||
/// Логика работы с бекапом
|
||
/// </summary>
|
||
/// <param name="service"></param>
|
||
public SynchronizationBusinessLogic(ISynchronizationService service)
|
||
{
|
||
_service = service;
|
||
_serviceOperation = AccessOperation.Синхронизация;
|
||
_entity = "Синхронизация";
|
||
}
|
||
|
||
/// <summary>
|
||
/// Запуск синхронизации
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
/// <returns></returns>
|
||
public bool RunSynchronization()
|
||
{
|
||
try
|
||
{
|
||
if (NoAccess(null, AccessType.Delete))
|
||
{
|
||
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;
|
||
}
|
||
}
|
||
}
|
||
} |