Esempio n. 1
0
        private void LoadConnectionSettings(string applicationName, string taskName)
        {
            var taskConfiguration  = _configuration.GetTaskConfiguration(applicationName, taskName);
            var connectionSettings = new ClientConnectionSettings(taskConfiguration.DatabaseConnectionString,
                                                                  new TimeSpan(0, 0, taskConfiguration.DatabaseTimeoutSeconds));

            ConnectionStore.Instance.SetConnection(new TaskId(applicationName, taskName), connectionSettings);
        }
Esempio n. 2
0
        public TaskExecutionContext(ITasklingConfiguration configuration,
                                    ITaskExecutionRepository taskExecutionRepository,
                                    ICriticalSectionRepository criticalSectionRepository,
                                    IBlockFactory blockFactory,
                                    IRangeBlockRepository rangeBlockRepository,
                                    IListBlockRepository listBlockRepository,
                                    IObjectBlockRepository objectBlockRepository,
                                    ICleanUpService cleanUpService,
                                    string applicationName,
                                    string taskName,
                                    TaskExecutionOptions taskExecutionOptions)
        {
            _configuration             = configuration;
            _taskExecutionRepository   = taskExecutionRepository;
            _criticalSectionRepository = criticalSectionRepository;
            _blockFactory          = blockFactory;
            _rangeBlockRepository  = rangeBlockRepository;
            _listBlockRepository   = listBlockRepository;
            _objectBlockRepository = objectBlockRepository;
            _cleanUpService        = cleanUpService;

            _taskExecutionInstance = new TaskExecutionInstance();
            _taskExecutionInstance.ApplicationName = applicationName;
            _taskExecutionInstance.TaskName        = taskName;

            _taskExecutionOptions = taskExecutionOptions;

            _executionHasFailed = false;

            _taskConfiguration = _configuration.GetTaskConfiguration(applicationName, taskName);
        }
Esempio n. 3
0
 private void StartCleanOldData(string applicationName, string taskName)
 {
     try
     {
         var configuration = _tasklingConfiguration.GetTaskConfiguration(applicationName, taskName);
         var request       = new CleanUpRequest()
         {
             TaskId = new TaskId(applicationName, taskName),
             GeneralDateThreshold            = DateTime.UtcNow.AddDays(-1 * configuration.KeepGeneralDataForDays),
             ListItemDateThreshold           = DateTime.UtcNow.AddDays(-1 * configuration.KeepListItemsForDays),
             TimeSinceLastCleaningThreashold = new TimeSpan(configuration.MinimumCleanUpIntervalHours, 0, 0)
         };
         _cleanUpRepository.CleanOldData(request);
     }
     catch (Exception ex)
     {
         Trace.TraceError("Failed to clean old data. If this continues, data size could grow very large. " + ex);
     }
 }
Esempio n. 4
0
        private async Task StartCleanOldDataAsync(string applicationName, string taskName, string taskExecutionId)
        {
            var checkpoint = new TaskExecutionCheckpointRequest()
            {
                TaskExecutionId = taskExecutionId,
                TaskId          = new TaskId(applicationName, taskName)
            };

            try
            {
                var configuration = _tasklingConfiguration.GetTaskConfiguration(applicationName, taskName);
                var request       = new CleanUpRequest()
                {
                    TaskId = new TaskId(applicationName, taskName),
                    GeneralDateThreshold            = DateTime.UtcNow.AddDays(-1 * configuration.KeepGeneralDataForDays),
                    ListItemDateThreshold           = DateTime.UtcNow.AddDays(-1 * configuration.KeepListItemsForDays),
                    TimeSinceLastCleaningThreashold = new TimeSpan(configuration.MinimumCleanUpIntervalHours, 0, 0)
                };
                var cleaned = await _cleanUpRepository.CleanOldDataAsync(request).ConfigureAwait(false);

                if (cleaned)
                {
                    checkpoint.Message = "Data clean up performed";
                }
                else
                {
                    checkpoint.Message = "Data clean up skipped";
                }
            }
            catch (Exception ex)
            {
                checkpoint.Message = "Failed to clean old data. " + ex;
            }

            await LogCleanupAsync(checkpoint).ConfigureAwait(false);
        }