public void Execute()
        {
            try
            {
                using (var dbContext = new FileMonitoringContext(MainSheduler.AppConfiguration.GetConnectionString(Constants.DefaultConnectionName)))
                {
                    var dataService = new FileMonitoringDataService(dbContext);
                    var tasks       = dataService.GetNewSendingTasks();
                    if (tasks.Count <= 0)
                    {
                        return;
                    }

                    var apiClient = new ApiClient(MainSheduler.MonitoringConfig, MainSheduler.Logger, MainSheduler.MetricServer);

                    foreach (var task in tasks)
                    {
                        var responseStatus = apiClient.SendFileInfoRequest(task, task.Recipient, task.Name);
                        switch (responseStatus)
                        {
                        case ApiResponseStatus.SuccessfullyProcessed:
                            dataService.UpdateProcessedTask(task, TaskStatus.Completed);
                            break;

                        case ApiResponseStatus.ServerIsNotAvailable:
                            break;

                        case ApiResponseStatus.BusConnectException:
                            break;

                        case ApiResponseStatus.InternalBusError:
                            dataService.UpdateProcessedTask(task, TaskStatus.Error);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MainSheduler.CounterException.WithLabels("Ошибка сохранения информации о отправленных файлах").Set(1);
                MainSheduler.Logger.LogError(ex, "Ошибка сохранения информации о отправленных файлах");
            }
        }
        public void Execute()
        {
            try
            {
                foreach (var folder in MainSheduler.MonitoringConfig.Folders)
                {
                    if (Directory.Exists(folder.Path))
                    {
                        var files = Directory.GetFiles(folder.Path);
                        if (files.Length < 1)
                        {
                            continue;
                        }
                        if (folder.ShareFolder != null)
                        {
                            using (var dbContext = new FileMonitoringContext(
                                       MainSheduler.AppConfiguration.GetConnectionString(Constants.DefaultConnectionName)))
                            {
                                var dataService = new FileMonitoringDataService(dbContext);
                                files.ToList().ForEach(file =>
                                {
                                    var fileInfo            = new FileInfo(file);
                                    SendingFile sendingFile = new SendingFile();

                                    sendingFile.Path       = file;
                                    sendingFile.Status     = TaskStatus.New;
                                    sendingFile.CreateDate = fileInfo.CreationTime;
                                    sendingFile.FileName   = fileInfo.Name;
                                    dataService.SaveSendingFile(sendingFile);
                                });
                            }

                            using (var dbContext = new FileMonitoringContext(
                                       MainSheduler.AppConfiguration.GetConnectionString(Constants.DefaultConnectionName)))
                            {
                                var         dataService          = new FileMonitoringDataService(dbContext);
                                var         newSendingFilesFiles = dataService.GetNewSendingFiles();
                                FileManager fileManager          = new FileManager(MainSheduler.MonitoringConfig, MainSheduler.Logger, folder.ShareFolder, MainSheduler.MetricServer);
                                foreach (var file in newSendingFilesFiles)
                                {
                                    var taskStatus = fileManager.SendFile(file.Path);
                                    dataService.UpdateProcessedTask(file, taskStatus);
                                }
                            }
                        }
                        else
                        {
                            var tasks = from file in files select CreateSendingTask(file, folder);

                            using (var dbContext = new FileMonitoringContext(
                                       MainSheduler.AppConfiguration.GetConnectionString(Constants.DefaultConnectionName)))
                            {
                                var dataService = new FileMonitoringDataService(dbContext);
                                dataService.SaveSendingTasks(tasks);
                            }
                        }
                    }
                }
            }
            catch (IOException ex)
            {
                MainSheduler.CounterException.WithLabels("Ошибка при опросе папок").Set(1);
                MainSheduler.Logger.LogError(ex, "Ошибка при опросе папок");
            }
            catch (Exception ex)
            {
                MainSheduler.CounterException.WithLabels("Ошибка при сохранении информации по опрошенным папкам").Set(1);
                MainSheduler.Logger.LogError(ex, "Ошибка при сохранении информации по опрошенным папкам");
            }
        }