/// <summary> /// Standard constructor /// </summary> public YalvViewModel() { _manageRepoViewModel = new ManageRepositoryViewModel(); _manageRepoViewModel.ActiveChanged += ManageRepoViewModelOnPropertyChanged; _logAnalysis = new LogAnalysis(); YalvRegistry.Instance.ActualWorkspace.CurrentAnalysis = _logAnalysis; _manageTextMarkersViewModel = new ManageTextMarkersViewModel(_logAnalysis); _logEntryRows = new DisplayLogViewModel(_manageTextMarkersViewModel); CommandCancelProcessing = new CommandRelay(CommandCancelProcessingExecuted, CommandCancelProcessingCanExecute); CommandRefresh = new CommandRelay(CommandRefreshExecute, CommandRequiresDataCanExecute); CommandDelete = new CommandRelay(LogEntryRows.CommandDeleteExecute, LogEntryRows.CommandDeleteCanExecute); CommandUpdateTextMarkers = new CommandRelay(_manageTextMarkersViewModel.CommandUpdateTextMarkersExecute, _manageTextMarkersViewModel.CommandUpdateTextMarkersCanExecute); CommandUpdateDelta = new CommandRelay(CommandUpdateDeltaExecute, CommandUpdateDeltaCanExecute); }
/* public void LoadFiles(List<string> paths, EntriesProviderType providerType) * { * try * { * ProviderType = providerType; * if (ProviderType.Equals(EntriesProviderType.Yalv)) * { * LogAnalysisWorkspace loadedWorkspace = new LogAnalysisWorkspaceLoader(paths.ElementAt(0)).Load(); * * YalvRegistry.Instance.SetActualLogAnalysisWorkspace(loadedWorkspace); * * YalvRegistry.Instance.ActualWorkspace.CurrentAnalysis = * YalvRegistry.Instance.ActualWorkspace.Analyses.First(); * * _repositories.Clear(); * * AddRepositories(YalvRegistry.Instance.ActualWorkspace.SourceRepositories.ToList()); * } * else * { * var listRepo = new List<LogEntryRepository>(); * List<string> reposPath = * Repositories.Select(x => x.Repository.Path).ToList(); * * foreach (string path in paths) * { * if (!File.Exists(path)) * { * MessageBox.Show(Resources.GlobalHelper_CantAccessFile_Error_Text, path); * return; * } * * // If this is the first file or the file hasnt be loaded yet, we can add it to the repo * if ((Repositories.Any() && !reposPath.Contains(path)) || !Repositories.Any()) * { * listRepo.Add(CreateLogFileEntryRepository(path)); * } * else * { * MessageBox.Show(Resources.GlobalHelper_RepositoryAlreadyExists_Error_Text); * } * } * foreach (LogEntryRepository logEntryRepository in listRepo) * { * YalvRegistry.Instance.ActualWorkspace.SourceRepositories.Add(logEntryRepository); * } * } * } * catch (Exception exception) * { * string message = string.Format(Resources.GlobalHelper_ParseLogFile_Error_Text, paths, * exception.Message); * MessageBox.Show(message, Resources.GlobalHelper_ParseLogFile_Error_Title, * MessageBoxButton.OK, MessageBoxImage.Exclamation); * } * }*/ /// <summary> /// Load the list of files with the given provider type. /// Update the repository list /// </summary> /// <param name="paths">Paths of the files</param> /// <param name="providerType">Type of the provider for the given files</param> /// <param name="vm"></param> public void LoadFiles(List <string> paths, EntriesProviderType providerType, ManageRepositoryViewModel vm) { var cancelTokenSource = new CancellationTokenSource(); var cancelToken = cancelTokenSource.Token; try { vm.ProviderType = providerType; if (vm.ProviderType.Equals(EntriesProviderType.Yalv)) { LogAnalysisWorkspace loadedWorkspace = new LogAnalysisWorkspaceLoader(paths.ElementAt(0)).Load(); YalvRegistry.Instance.ActualWorkspace = (loadedWorkspace); cancelToken.ThrowIfCancellationRequested(); YalvRegistry.Instance.ActualWorkspace.CurrentAnalysis = YalvRegistry.Instance.ActualWorkspace.Analyses.First(); cancelToken.ThrowIfCancellationRequested(); Application.Current.Dispatcher.Invoke( DispatcherPriority.Normal, (Action) delegate { vm._repositories.Clear(); vm.AddRepositories( YalvRegistry.Instance.ActualWorkspace.SourceRepositories.ToList()); }); } else { var listRepo = new List <LogEntryRepository>(); List <string> reposPath = vm.Repositories.Select(x => x.Repository.Path).ToList(); foreach (string path in paths) { cancelToken.ThrowIfCancellationRequested(); if (!File.Exists(path)) { MessageBox.Show(Resources.GlobalHelper_CantAccessFile_Error_Text, path); return; } // If this is the first file or the file hasnt be loaded yet, we can add it to the repo if ((vm.Repositories.Any() && !reposPath.Contains(path)) || !vm.Repositories.Any()) { listRepo.Add(vm.CreateLogFileEntryRepository(path, ProviderType)); } else { MessageBox.Show(Resources.GlobalHelper_RepositoryAlreadyExists_Error_Text); } } vm.UpdateWorkspace(listRepo); } } catch (Exception exception) { string message = string.Format(Resources.GlobalHelper_ParseLogFile_Error_Text, paths, exception.Message); /*MessageBox.Show(message, Resources.GlobalHelper_ParseLogFile_Error_Title, * MessageBoxButton.OK, MessageBoxImage.Exclamation);*/ throw new Exception(message, exception); } }