Ejemplo n.º 1
0
 private void OnTaskRun()
 {
     try
     {
         Task.Run(async() =>
         {
             try
             {
                 do
                 {
                     if (!stopTask)
                     {
                         await Task.Delay(TimeSpan.FromMinutes(1));
                     }
                     if (!stopTask)
                     {
                         var jobs = await _repository.GetJobs();
                         foreach (var job in jobs)
                         {
                             await OnJobConfigSetState(job);
                         }
                     }
                 } while (!stopTask);
             }
             catch (Exception ex)
             {
                 _logger.Error(ex);
             }
         });
     } catch (Exception ex)
     {
         _logger.Error(ex);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// get Translated Text if it exists
        /// </summary>
        /// <param name="keyValue">Text key to search in the Translation for</param>
        /// <returns></returns>
        public string GetText(string keyValue)
        {
            if (!string.IsNullOrWhiteSpace(keyValue))
            {
                try
                {
                    string tmpValue = _resourceManager.GetString(keyValue);
                    if (string.IsNullOrWhiteSpace(tmpValue))
                    {
#if DEBUG
                        if (!MissingLocalization.Contains(keyValue))
                        {
                            MissingLocalization.Add(keyValue);
                        }
                        tmpValue = "[" + keyValue + "]";
                        keyValue = tmpValue;
#endif
                    }
                    else
                    {
                        keyValue = tmpValue;
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error(ex, "Could not load GetText value from resourceManager");
                }
            }
            return(keyValue);
        }
 private async Task OnRefresh()
 {
     try
     {
         ResultsItems = new ObservableCollection <ViewModels.DuplicatesResultPath>(await _repository.DuplicatesPaths(_duplicateValueId));
     }
     catch (Exception ex)
     {
         _logger.Error(ex, "OnRefresh failed to load data");
     }
 }
Ejemplo n.º 4
0
 private async Task OnRefresh()
 {
     try
     {
         CollectPathItems = new ObservableCollection <Models.CollectPath>(await _repository.GetPaths());
         _mainManager.SetTabGridItem(CollectPathItems.Count, MainWindowViewModel.Tabs.Folders);
     }
     catch (Exception ex)
     {
         _logger.Error(ex, "OnRefresh failed to load data");
     }
 }
Ejemplo n.º 5
0
 private async Task OnRefresh()
 {
     try
     {
         ResultsItems = new ObservableCollection <JobService.Models.PathCompareValue>(await _repository.GetAll());
         _mainManager.SetTabGridItem(ResultsItems.Count, MainWindowViewModel.Tabs.Cache);
     }
     catch (Exception ex)
     {
         _logger.Error(ex, "OnRefresh failed to load data");
     }
 }
Ejemplo n.º 6
0
 public void Save()
 {
     try
     {
         var value = JsonConvert.SerializeObject(this);
         var path  = System.IO.Path.Combine(StaticFolders.GetUserFolder(), GlobalValues.SettingsFileName);
         System.IO.File.WriteAllText(path, value);
     } catch (Exception ex)
     {
         _logger.Error(ex);
     }
 }
 private async Task OnRefresh()
 {
     try
     {
         DialogDuplicateId = Guid.Empty;
         ResultsItems      = new ObservableCollection <ViewModels.DuplicatesResult>(await _repository.Duplicates());
         _mainManager.SetTabGridItem(ResultsItems.Count, MainWindowViewModel.Tabs.Duplicates);
     }
     catch (Exception ex)
     {
         _logger.Error(ex, "OnRefresh failed to load data");
     }
 }
Ejemplo n.º 8
0
 private void OnResetJobStates()
 {
     try
     {
         var task = Task.Run(async() =>
         {
             duplicates.Cancel();
             var jobs = await _repository.GetJobsByState(JobState.Running);
             if (jobs?.Count > 0)
             {
                 for (int i = 0; i < jobs.Count; i++)
                 {
                     jobs[i].JobState = JobState.Idle;
                     await _repository.Update(jobs[i]);
                 }
             }
         });
         task.Wait();
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
     }
     finally
     {
     }
 }
Ejemplo n.º 9
0
        public async Task <bool> Delete(Job job)
        {
            try
            {
                if (job != null)
                {
                    var result1 = await GetJobCollect(job.Id);

                    if (result1 != null && result1.Count > 0)
                    {
                        result1.ForEach(async item =>
                        {
                            await _dBContext.Instance.DeleteAsync(item);
                        });
                    }
                    var result3 = await JobConfigurationDuplicates(job.Id);

                    if (result3 != null)
                    {
                        await _dBContext.Instance.DeleteAsync(result3);
                    }
                    var result2 = await GetJobConfiguration(job.Id);

                    if (result2 != null)
                    {
                        await _dBContext.Instance.DeleteAsync(result2);
                    }
                    var result4 = await _dBContext.Instance.Table <JobService.Models.DuplicateResultProgress>().FirstOrDefaultAsync(x => x.JobId == job.Id);

                    if (result4 != null)
                    {
                        await _dBContext.Instance.DeleteAsync(result4);
                    }
                    var result5 = await _dBContext.Instance.Table <JobService.Models.DuplicateResultProgressIndex>().Where(x => x.JobId == job.Id).ToListAsync();

                    if (result5 != null && result5.Count > 0)
                    {
                        result5.ForEach(async item =>
                        {
                            await _dBContext.Instance.DeleteAsync(item);
                        });
                    }
                    await _dBContext.Instance.DeleteAsync(job);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Failed to delete Job item");
            }
            return(false);
        }
Ejemplo n.º 10
0
        public async Task <bool> Insert(Models.CollectPath collectPath)
        {
            try
            {
                if (collectPath != null)
                {
                    await _dBContext.Instance.InsertAsync(collectPath);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Failed to insert new CollectPath item");
            }
            return(false);
        }
Ejemplo n.º 11
0
        private async Task OnRefresh()
        {
            try
            {
                var model = await _repository.JobConfigurationDuplicates(JobId);

                if (model == null)
                {
                    model = new Models.JobConfigurationDuplicates();
                    model.CompareValueTypes = (int)Compare.CompareValue.Types.Hash;
                }
                CompareValueTypes = (Compare.CompareValue.Types)model.CompareValueTypes;
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "OnRefresh failed to load data");
            }
        }
Ejemplo n.º 12
0
 private void AddFolder_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var folder = txtFolder.Text;
         Task.Run(async() =>
         {
             if (await _viewModel.InsertCollectPath(folder))
             {
                 _viewModel.RefreshCommand.Execute(null);
             }
             else
             {
             }
         });
     } catch (Exception ex)
     {
         _logger.Error(ex);
     }
 }
Ejemplo n.º 13
0
        private async Task OnRefresh()
        {
            try
            {
                Paths = new ObservableCollection <KeyValuePair <Guid, string> >();
                var paths = await _repositoryFolders.GetPaths();

                Paths.Add(new KeyValuePair <Guid, string>(Guid.Empty, "---"));
                foreach (var item in paths)
                {
                    Paths.Add(new KeyValuePair <Guid, string>(item.Id, item.Path));
                }
                PathsSelected = Guid.Empty;
                if (JobId != Guid.Empty)
                {
                    var jobModel = await _repository.GetJobs(jobId);

                    JobName = jobModel.Name;
                    var jobConfigModel = await _repository.GetJobConfiguration(JobId);

                    if (jobConfigModel != null)
                    {
                        JobConfigurationDays              = jobConfigModel.Days;
                        JobConfigurationFileExtensions    = jobConfigModel.FileExtensions;
                        JobConfigurationHours             = jobConfigModel.Hours;
                        JobConfigurationId                = jobConfigModel.Id;
                        JobConfigurationMaxRuntimeMinutes = jobConfigModel.MaxRuntimeMinutes;
                        JobConfigurationMinutes           = jobConfigModel.Minutes;
                        JobConfigurationMaxParallelism    = jobConfigModel.MaxParallelism;
                    }
                    await OnRefreshCollectPaths();
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "OnRefresh failed to load data");
            }
        }
Ejemplo n.º 14
0
 private async Task OnRefresh()
 {
     try
     {
         /*ClipDataTexts = new ObservableCollection<DAL.Models.ClipText>(await Internal.Global.Instance.DBContext.GetClipText());
          * ClipDataImages = new ObservableCollection<DAL.Models.ClipImage>(await Internal.Global.Instance.DBContext.GetClipImage());
          * ClipDataFiles = new ObservableCollection<DAL.Models.ClipFile>(await Internal.Global.Instance.DBContext.GetClipFile());
          * Summary = new ObservableCollection<DAL.Models.Summary>(await Global.Instance.DBContext.GetSummary());*/
         OnChangeTabRows();
     }
     catch (Exception ex)
     {
         _logger.Error(ex, "OnRefresh failed to load data");
     }
 }
Ejemplo n.º 15
0
 private void OpenDirectory_Click(object sender, RoutedEventArgs e)
 {
     if (e.Source is Button button && button.DataContext != null)
     {
         if (button.DataContext is ViewModels.DuplicatesResultPath dupResultPath)
         {
             try
             {
                 StaticFolders.OpenDirectory(dupResultPath.Directory, dupResultPath.FileName, dupResultPath.Extension);
             } catch (Exception ex)
             {
                 _logger.Error(ex);
             }
         }
     }
 }
Ejemplo n.º 16
0
        public async Task <bool> Delete(Models.PathCompareValue pathCompareValue)
        {
            try
            {
                if (pathCompareValue != null)
                {
                    await _dBContext.Instance.DeleteAsync(pathCompareValue);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Failed to delete PathCompareValue item");
            }
            return(false);
        }