/// <summary> /// Creates a log entry model object that can hold common log4net /// imput information as well as specialied information that is /// applicable to a given data source (eg. file or DB server) only. /// </summary> /// <param name="path"></param> /// <param name="providerType"></param> /// <returns></returns> private LogEntryRepository CreateLogFileEntryRepository(string path, EntriesProviderType providerType) { switch (providerType) { case EntriesProviderType.Sqlite: return(new LogEntrySqliteRepository(path)); case EntriesProviderType.Xml: return(new LogEntryFileRepository(path)); } return(null); }
public static IList <LogItem> ParseLogFile(string path, EntriesProviderType selectedFolderEntriesType) { IEnumerable <LogItem> result = null; try { AbstractEntriesProvider provider = EntriesProviderFactory.GetProvider(selectedFolderEntriesType); result = provider.GetEntries(path); return(result.ToList()); } catch (Exception ex) { System.Diagnostics.Trace.TraceError("Error parsing log file [{0}]:\r\n{1}\r\n{2}", path, ex.Message, ex.StackTrace); throw; } }
public static AbstractEntriesProvider GetProvider(EntriesProviderType type = EntriesProviderType.Xml) { switch (type) { case EntriesProviderType.Xml: return(new XmlEntriesProvider()); //case EntriesProviderType.Sqlite: // return new SqliteEntriesProvider(); case EntriesProviderType.MsSqlServer: return(new MsSqlServerEntriesProvider()); default: var message = String.Format("Type {0} not supported", type); throw new NotImplementedException(message); } }
public static AbstractEntriesProvider GetProvider(EntriesProviderType type = EntriesProviderType.Xml) { switch (type) { case EntriesProviderType.Xml: return new XmlEntriesProvider(); case EntriesProviderType.Sqlite: return new SqliteEntriesProvider(); case EntriesProviderType.MsSqlServer: return new MsSqlServerEntriesProvider(); default: var message = String.Format((string) "Type {0} not supported", (object) type); throw new NotImplementedException(message); } }
public static AbstractEntriesProvider GetProvider(EntriesProviderType type = EntriesProviderType.Xml) { switch (type) { case EntriesProviderType.Xml: return(new XmlEntriesProvider()); case EntriesProviderType.Sqlite: return(new SqliteEntriesProvider()); case EntriesProviderType.MsSqlServer: return(new MsSqlServerEntriesProvider()); case EntriesProviderType.Text: return(new FileEntriesProvider()); default: return(new NotImplementedEntriesProvider(type)); } }
public static AbstractEntriesProvider GetProvider(EntriesProviderType type = EntriesProviderType.Xml) { switch (type) { case EntriesProviderType.Text: return(new FileEntriesProvider()); case EntriesProviderType.Json: return(new JsonEntriesProvider()); case EntriesProviderType.Xml: return(new XmlEntriesProvider()); case EntriesProviderType.Sqlite: return(new SqliteEntriesProvider()); case EntriesProviderType.MsSqlServer: return(new MsSqlServerEntriesProvider()); default: var message = String.Format((string)"Type {0} not supported", (object)type); throw new NotImplementedException(message); } }
public NotImplementedEntriesProvider(EntriesProviderType entriesProviderType) { _entriesProviderType = entriesProviderType; }
/* 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); } }