Ejemplo n.º 1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_dbAccessor != null)
         {
             _dbAccessor.Dispose();
             _dbAccessor = null;
         }
     }
     base.Dispose(disposing);
 }
Ejemplo n.º 2
0
        public Task Execute(IJobExecutionContext context)
        {
            try
            {
                _logger.LogInformation("Начало синхронизации с Bitrix");
                var iRPCSDbAccessor       = new RPCSSingletonDbAccessor(_dbContextOptions);
                var rPCSRepositoryFactory = new RPCSRepositoryFactory(iRPCSDbAccessor);
                var userService           = new UserService(rPCSRepositoryFactory, _httpContextAccessor);
                var budgetService         = new BudgetLimitService(rPCSRepositoryFactory, userService);
                var departmentService     = new DepartmentService(rPCSRepositoryFactory, userService);
                var employeeService       = new EmployeeService(rPCSRepositoryFactory, departmentService, userService);
                var projectService        = new ProjectService(rPCSRepositoryFactory, userService);

                var              costSubItemService    = new CostSubItemService(rPCSRepositoryFactory, userService);
                var              expensesRecordService = new ExpensesRecordService(rPCSRepositoryFactory, _bitrixConfigOptions);
                var              projectRoleService    = new ProjectRoleService(rPCSRepositoryFactory);
                var              taskSyncWithBitrix    = new SyncWithBitrixTask(budgetService, _bitrixConfigOptions, employeeService, projectService, departmentService, costSubItemService, expensesRecordService, projectRoleService);
                string           id = Guid.NewGuid().ToString();
                BitrixSyncResult syncWithBitrixResult = null;

                if (taskSyncWithBitrix.Add(id, true) == true)
                {
                    try
                    {
                        syncWithBitrixResult = taskSyncWithBitrix.ProcessLongRunningAction("", id);

                        var fileHtmlReport = string.Empty;

                        foreach (var html in syncWithBitrixResult.fileHtmlReport)
                        {
                            fileHtmlReport += html;
                        }

                        _memoryCache.Set(syncWithBitrixResult.fileId, fileHtmlReport);
                    }
                    catch (Exception)
                    {
                    }

                    taskSyncWithBitrix.Remove(id);
                }
            }
            catch (Exception e)
            {
                string errorMessage = e.Message;
                _logger.LogError(e.Message);
            }
            _logger.LogInformation("Процесс синхронизации закончен!!");
            return(Task.CompletedTask);
        }
Ejemplo n.º 3
0
 protected DataAwareMvcController()
 {
     // TODO: надо использовать IoC механизм (например, Unity) для получения зависимостей
     _dbAccessor = new RPCSSingletonDbAccessor(_dbContextOptions);
 }