Example #1
0
        private async Task OnComplete(List <Compare.DuplicatesResult> duplicatesResults, Job job, JobConfiguration config)
        {
            try
            {
                if (duplicatesResults != null)
                {
                    _mainManager.SetStatusBarInfoText($"Save compare result ({duplicatesResults.Count} Duplicates)");
                    foreach (var item in duplicatesResults)
                    {
                        Models.DuplicateValue duplicateValue = null;

                        foreach (var result in item.FileResults)
                        {
                            if (duplicateValue == null)
                            {
                                duplicateValue = await _jobServiceRepository.CreateDuplicateValue((int)result.CompareValue);
                            }
                            await _jobServiceRepository.CreatePathDuplicate(job.Id, duplicateValue.Id, result.FilePath);
                        }
                    }
                }
                job.JobState = Jobs.JobState.Idle;
                await _repository.Update(job);

                JobStateChanged?.Invoke(this, job.JobState);
                _duplicatesManager.RaiseRefreshData();
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            } finally
            {
                try
                {
                    if (jobTasks.Any(x => x.Key.Id == job.Id))
                    {
                        var key = jobTasks.First(x => x.Key.Id == job.Id).Key;
                        jobTasks.Remove(key);
                    }
                }
                catch (Exception ex1)
                {
                    _logger.Error(ex1);
                }
            }
        }
Example #2
0
 /// <summary>
 /// Adds custom object state observer
 /// </summary>
 /// <param name="jobStateChangedListener"></param>
 public void AddCustomStateListener(JobStateChanged jobStateChangedListener)
 {
     StateListener += jobStateChangedListener;
 }