public static void SetNewSource(ErrorLogSources source, string connection, string schema, string application) { Source = source; Connection = connection; Schema = schema; Application = application; _keepAlive = new object(); }
public static string GetInformation(ErrorLogSources source, string connection) { switch (source) { case ErrorLogSources.Files: return string.Format("Connected to directory: {0}", connection); case ErrorLogSources.SqlServer: return string.Format("Connected to {0}: {1}", source.GetDescription(), SqlServerConnectionInformation(connection)); case ErrorLogSources.SqlServerCompact: return string.Format("Connected to {0}: {1}", source.GetDescription(), SplitConnectionString(connection)[0]); } throw new NotImplementedException(); }
public void DisplayConnectionInformation(ErrorLogSources source, string connection) { _directoryToolStripStatusLabel.Text = ConnectionInformationHelper.GetInformation(source, connection); }
private static void InitializeNewErrorLogSource(ErrorLogSources source, string connection, string schema, string application, NetworkConnection networkConnection) { _container.SetLoadingState(); DataSourceScopeController.SetNewSource(source, connection, schema, application); var downloadLogsTask = new Task(() => { return; }); if (networkConnection != null) { var downloader = ServiceLocator.ResolveWithConstructorArguments<ErrorLogDownloader>(new IParameter[] { new ConstructorArgument("connection", networkConnection) }); DataSourceScopeController.SetNewSource(ErrorLogSources.Files, downloader.DownloadDirectory, null, null); downloadLogsTask = new Task(downloader.Download); } var repository = ServiceLocator.Resolve<IErrorLogRepository>(); var viewPresenter = ServiceLocator.Resolve<SearchPresenter>(); var initRepositoryTask = downloadLogsTask.ContinueWith(previousTask => { if (previousTask.Exception != null) { _container.InvokeEx(m => m.DisplayView(new ErrorView(previousTask.Exception))); _container.InvokeEx(m => m.SetInitialState()); return; } repository.Initialize(); }); var updateUiTask = initRepositoryTask.ContinueWith(previousTask => { if (previousTask.Exception != null) { _container.InvokeEx(m => m.DisplayView(new ErrorView(previousTask.Exception))); _container.InvokeEx(m => m.SetInitialState()); return; } _container.InvokeEx(m => m.SetReadyForWorkState()); _container.InvokeEx(m => m.DisplayConnectionInformation(DataSourceScopeController.Source, DataSourceScopeController.Connection)); _container.InvokeEx(m => m.DisplayView(viewPresenter.View as UserControl)); }); downloadLogsTask.Start(); }