private bool Find(ITableRepository tableRepository, IPatcher patcher, ICheckNotifier notifier) { var db = tableRepository.DiscoveredServer.GetCurrentDatabase(); notifier.OnCheckPerformed(new CheckEventArgs(string.Format("Connecting to {0} on {1}", db.GetRuntimeName(), db.Server.Name), CheckResult.Success)); //is it reachable try { tableRepository.TestConnection(); } catch (Exception ex) { //no DatabaseFound(this, new PlatformDatabaseFoundEventArgs(tableRepository, patcher, RDMPPlatformDatabaseStatus.Unreachable, ex)); return(false); } Patch.PatchingState patchingRequired; try { //is it up-to-date on patches? Version databaseVersion; Patch[] patchesInDatabase; SortedDictionary <string, Patch> allPatchesInAssembly; patchingRequired = Patch.IsPatchingRequired((SqlConnectionStringBuilder)tableRepository.ConnectionStringBuilder, patcher, out databaseVersion, out patchesInDatabase, out allPatchesInAssembly); } catch (Exception e) { //database is broken (maybe the version of the db is ahead of the host assembly?) DatabaseFound(this, new PlatformDatabaseFoundEventArgs(tableRepository, patcher, RDMPPlatformDatabaseStatus.Broken, e)); return(false); } switch (patchingRequired) { case Patch.PatchingState.NotRequired: DatabaseFound(this, new PlatformDatabaseFoundEventArgs(tableRepository, patcher, RDMPPlatformDatabaseStatus.Healthy)); break; case Patch.PatchingState.Required: DatabaseFound(this, new PlatformDatabaseFoundEventArgs(tableRepository, patcher, RDMPPlatformDatabaseStatus.RequiresPatching)); break; case Patch.PatchingState.SoftwareBehindDatabase: DatabaseFound(this, new PlatformDatabaseFoundEventArgs(tableRepository, patcher, RDMPPlatformDatabaseStatus.SoftwareOutOfDate)); break; default: throw new ArgumentOutOfRangeException("patchingRequired"); } return(true); }
private void ExpectFileExtension(ICheckNotifier notifier, string expectedExtension, string actualExtension) { if (expectedExtension.Equals(actualExtension)) { notifier.OnCheckPerformed(new CheckEventArgs("File extension matched expectations (" + expectedExtension + ")", CheckResult.Success)); } else { notifier.OnCheckPerformed(new CheckEventArgs("Unexpected file extension '" + actualExtension + "' (expected " + expectedExtension + ") ", CheckResult.Warning)); } }
private void CheckDataLoadTaskStatusTable(ICheckNotifier notifier) { Dictionary <int, string> desired = new Dictionary <int, string>(); desired.Add(1, "Open"); desired.Add(2, "Ready"); desired.Add(3, "Commited"); CheckLookupTableIsCorrectlyPopulated(notifier, "status", "z_DataLoadTaskStatus", desired); }
/// <summary> /// Checks that the configuration is in a valid state. Supports both released (frozen) <see cref="ExtractionConfiguration"/> and unreleased ones. /// </summary> /// <param name="notifier"></param> public void Check(ICheckNotifier notifier) { if (_config.IsReleased) { CheckReleaseConfiguration(notifier); } else { CheckInProgressConfiguration(notifier); } }
public void Check(ICheckNotifier notifier) { try { SetupFTP(); } catch (Exception e) { notifier.OnCheckPerformed(new CheckEventArgs("Failed to SetupFTP", CheckResult.Fail, e)); } }
/// <summary> /// Creates a new platform database and patches it /// </summary> /// <param name="patcher">Determines the SQL schema created</param> /// <param name="notifier">audit object, can be a new ThrowImmediatelyCheckNotifier if you aren't in a position to pass one</param> public void CreateAndPatchDatabase(IPatcher patcher, ICheckNotifier notifier) { var initialPatch = patcher.GetInitialCreateScriptContents(Database); CreateDatabase(initialPatch, notifier); //get everything in the /up/ folder that are .sql var patches = patcher.GetAllPatchesInAssembly(Database); PatchDatabase(patches, notifier, (p) => true);//apply all patches without question }
private void AddBadAssembly(FileInfo f, Exception ex, ICheckNotifier listener) { if (!BadAssembliesDictionary.ContainsKey(f.FullName)) //couldn't load anything out of it { BadAssembliesDictionary.Add(f.FullName, ex); if (listener != null) { listener.OnCheckPerformed(new CheckEventArgs("Encountered Bad Assembly " + f.FullName + " into memory", CheckResult.Fail, ex)); } } }
public void Check(ICheckNotifier notifier) { if (CustomReleaseFolder != null) { notifier.OnCheckPerformed(new CheckEventArgs("Custom Release folder is:" + CustomReleaseFolder, CheckResult.Success)); } else { notifier.OnCheckPerformed(new CheckEventArgs("Release folder will be the project extraction folder", CheckResult.Success)); } }
public void Check(ICheckNotifier notifier) { if (UriToFile == null) { notifier.OnCheckPerformed(new CheckEventArgs("No URI has been specified", CheckResult.Fail)); } else { notifier.OnCheckPerformed(new CheckEventArgs("URI is:" + UriToFile, CheckResult.Success)); } }
/// <summary> /// Checks that all the components defined in the pipeline are found using a MEFChecker. This will also handle classes changing namespaces by updating /// class name reference. /// </summary> /// <param name="notifier"></param> public void Check(ICheckNotifier notifier) { var mef = ((ICatalogueRepository)_pipeline.Repository).MEF; foreach (var component in _pipeline.PipelineComponents) { var copy = component; var mefChecker = new MEFChecker(mef, component.Class, delegate(string s) { copy.Class = s; copy.SaveToDatabase(); }); mefChecker.Check(notifier); } }
public void Check(ICheckNotifier notifier) { try { if (LoadProgress == null) { notifier.OnCheckPerformed(new CheckEventArgs("A LoadProgress must be selected for a Cache to run", CheckResult.Fail)); return; } var cp = LoadProgress.CacheProgress; if (cp == null) { notifier.OnCheckPerformed( new CheckEventArgs( "LoadProgress must have a CacheProgress associated with it to support CachedFileRetrieval", CheckResult.Fail)); return; } var layout = CreateCacheLayout(cp, new FromCheckNotifierToDataLoadEventListener(notifier)); if (layout == null) { notifier.OnCheckPerformed(new CheckEventArgs("CacheLayout created was null!", CheckResult.Fail)); return; } notifier.OnCheckPerformed(new CheckEventArgs("Archive type is:" + layout.ArchiveType, CheckResult.Success)); notifier.OnCheckPerformed(new CheckEventArgs("DateFormat is:" + layout.DateFormat, CheckResult.Success)); notifier.OnCheckPerformed(new CheckEventArgs("Granularity is:" + layout.CacheFileGranularity, CheckResult.Success)); notifier.OnCheckPerformed(new CheckEventArgs("CacheLayout is:" + layout, CheckResult.Success)); var filesFound = layout.CheckCacheFilesAvailability(new FromCheckNotifierToDataLoadEventListener(notifier)); notifier.OnCheckPerformed(new CheckEventArgs("Files Found In Cache:" + filesFound, filesFound ? CheckResult.Success : CheckResult.Warning)); var d = layout.GetLoadCacheDirectory(new FromCheckNotifierToDataLoadEventListener(notifier)); if (d == null) { notifier.OnCheckPerformed(new CheckEventArgs("Cache Directory was null!", CheckResult.Fail)); return; } notifier.OnCheckPerformed(new CheckEventArgs("Cache Directory Is:" + d.FullName, CheckResult.Success)); } catch (Exception ex) { notifier.OnCheckPerformed(new CheckEventArgs("Checking failed on " + this, CheckResult.Fail, ex)); } }
public void Check(ICheckNotifier notifier) { if (ExitCodeToReturnIfConditionMet == ExitCodeType.Success) { notifier.OnCheckPerformed(new CheckEventArgs("You cannot return Success if you are anticipating terminating the load early, you must choose LoadNotRequired or Error", CheckResult.Fail)); } if (ConditionsToTerminateUnder == PrematureLoadEndCondition.Always) { notifier.OnCheckPerformed(new CheckEventArgs("ConditionsToTerminateUnder is Always. This means that the load will not complete if executed", CheckResult.Warning)); } }
public void Check(ICheckNotifier notifier) { if (ZipArchivePattern != null) { notifier.OnCheckPerformed(new CheckEventArgs("Found ZipArchivePattern " + ZipArchivePattern, CheckResult.Success)); } if (ZipEntryPattern != null) { notifier.OnCheckPerformed(new CheckEventArgs("Found ZipEntryPattern " + ZipEntryPattern, CheckResult.Success)); } }
public void Check(ICheckNotifier notifier) { if (OriginDate != null && OriginDate > DateTime.Now) { notifier.OnCheckPerformed(new CheckEventArgs($"OriginDate cannot be in the future ({Name})", CheckResult.Fail)); } if (DataLoadProgress != null && DataLoadProgress > DateTime.Now) { notifier.OnCheckPerformed(new CheckEventArgs($"DataLoadProgress cannot be in the future ({Name})", CheckResult.Fail)); } }
/// <summary> /// Checks that the Lookup configuration is legal (e.g. not a table linking against itself etc). /// </summary> /// <param name="notifier"></param> public void Check(ICheckNotifier notifier) { if (ForeignKey.TableInfo_ID == PrimaryKey.TableInfo_ID) { notifier.OnCheckPerformed(new CheckEventArgs("Foreign Key and Primary Key are from the same table for Lookup " + this.ID, CheckResult.Fail)); } if (Description.TableInfo_ID != PrimaryKey.TableInfo_ID) { notifier.OnCheckPerformed(new CheckEventArgs("Description Key and Primary Key are from different tables (Not allowed) in Lookup " + this.ID, CheckResult.Fail)); } }
public void Check(ICheckNotifier notifier) { try { var p = GetPattern(); new Regex(p); } catch (Exception e) { notifier.OnCheckPerformed(new CheckEventArgs("Problem occurred getting Regex pattern for blacklist", CheckResult.Fail, e)); } }
public void Synchronize(ICheckNotifier notifier) { //there are no columns going to dump (because constructor didnt give us a server) if (_externalDatabaseServer == null) { return; } IdentifierDumperSynchronizer synchronizer = new IdentifierDumperSynchronizer(this, _externalDatabaseServer); synchronizer.Synchronize(notifier); }
public virtual void Check(ICheckNotifier notifier) { if (ColumnToDilute == null) { throw new DilutionColumnNotSetException("ColumnToDilute has not been set yet, this is the column which will be diluted and is usually set by the DilutionOperationFactory but it is null"); } if (string.IsNullOrWhiteSpace(ColumnToDilute.SqlDataType)) { notifier.OnCheckPerformed(new CheckEventArgs("IPreLoadDiscardedColumn " + ColumnToDilute + " is of unknown datatype", CheckResult.Fail)); } }
public void SaveTo(DirectoryInfo subdir, string nameOfFile, ICheckNotifier notifier, Dictionary <AggregateGraphUI, string> graphSaveLocations = null) { if (!Done) { notifier.OnCheckPerformed( new CheckEventArgs( "Graph could not be extracted to " + nameOfFile + " because Done is false, possibly the graph has not been loaded yet or crashed?", CheckResult.Fail)); return; } string imgSavePath = Path.Combine(subdir.FullName, nameOfFile + ".png"); string dataSavePath = Path.Combine(subdir.FullName, nameOfFile + ".csv"); string querySavePath = Path.Combine(subdir.FullName, nameOfFile + ".sql"); try { chart1.SaveImage(imgSavePath, ChartImageFormat.Png); notifier.OnCheckPerformed(new CheckEventArgs("Saved chart image to " + imgSavePath, CheckResult.Success)); if (graphSaveLocations != null) { graphSaveLocations.Add(this, imgSavePath); } } catch (Exception e) { notifier.OnCheckPerformed(new CheckEventArgs("Failed to save image to " + imgSavePath, CheckResult.Fail, e)); } try { var dt = (DataTable)dataGridView1.DataSource; dt.SaveAsCsv(dataSavePath); notifier.OnCheckPerformed(new CheckEventArgs("Saved chart data to " + dataSavePath, CheckResult.Success)); } catch (Exception e) { notifier.OnCheckPerformed(new CheckEventArgs("Failed to save chart data to " + dataSavePath, CheckResult.Fail, e)); } try { File.WriteAllText(querySavePath, QueryEditor.Text); notifier.OnCheckPerformed(new CheckEventArgs("Wrote SQL used to " + querySavePath, CheckResult.Success)); } catch (Exception e) { notifier.OnCheckPerformed(new CheckEventArgs("Failed to save SQL query to " + querySavePath, CheckResult.Fail, e)); } }
public void Check(ICheckNotifier notifier) { Catalogue[] catalogueMetadatas = null; try { //check there are catalogues and we can retrieve them catalogueMetadatas = _loadMetadata.GetAllCatalogues().Cast <Catalogue>().ToArray(); } catch (Exception e) { notifier.OnCheckPerformed(new CheckEventArgs("Crashed trying to fetch Catalogues for metadata", CheckResult.Fail, e)); return; } //there no catalogues if (catalogueMetadatas.Length == 0) { notifier.OnCheckPerformed(new CheckEventArgs("There are no Catalogues associated with this metadata", CheckResult.Fail, null)); } List <ITableInfo> tablesFound = new List <ITableInfo>(); //check each catalogue is sufficiently configured to perform a migration foreach (Catalogue catalogue in catalogueMetadatas) { notifier.OnCheckPerformed(new CheckEventArgs("Found Catalogue:" + catalogue, CheckResult.Success, null)); ITableInfo[] tableInfos = catalogue.GetTableInfoList(true).Distinct().ToArray(); if (tableInfos.Length == 0) { notifier.OnCheckPerformed(new CheckEventArgs( "Catalogue " + catalogue.Name + " does not have any TableInfos", CheckResult.Fail, null)); } tablesFound.AddRange(tableInfos.Where(tableInfo => !tablesFound.Contains(tableInfo))); } //check regular tables foreach (TableInfo regularTable in tablesFound) { notifier.OnCheckPerformed(new CheckEventArgs("About To check configuration of TableInfo:" + regularTable, CheckResult.Success, null)); CheckTableInfo(regularTable, notifier); //check anonymisation AnonymisationChecks anonymisationChecks = new AnonymisationChecks(regularTable); anonymisationChecks.Check(notifier); } }
public void Check(ICheckNotifier notifier) { if (MetadataNamingPattern != null && MetadataNamingPattern.Contains("$a")) { var dsRequest = _request as ExtractDatasetCommand; if (dsRequest != null && string.IsNullOrWhiteSpace(dsRequest.Catalogue.Acronym)) { notifier.OnCheckPerformed(new CheckEventArgs("Catalogue '" + dsRequest.Catalogue + "' does not have an Acronym but MetadataNamingPattern contains $a", CheckResult.Fail)); } } }
public void Check(ICheckNotifier notifier) { if (string.IsNullOrWhiteSpace(ColumnNameToFind)) { notifier.OnCheckPerformed(new CheckEventArgs("No value specified for argument ColumnNameToFind", CheckResult.Fail)); } if (string.IsNullOrWhiteSpace(ReplacementName)) { notifier.OnCheckPerformed(new CheckEventArgs("No value specified for argument ReplacementName", CheckResult.Fail)); } }
public virtual void Check(ICheckNotifier notifier) { try { var _sql = GetSQL(); notifier.OnCheckPerformed(new CheckEventArgs("successfully built extraction SQL:" + _sql, CheckResult.Success)); } catch (Exception e) { notifier.OnCheckPerformed(new CheckEventArgs("Could not build extraction SQL for '" + AggregateConfiguration + "' (ID=" + AggregateConfiguration.ID + ")", CheckResult.Fail, e)); } }
public void Check(ICheckNotifier notifier) { var container = _cohortIdentificationConfiguration.RootCohortAggregateContainer; if (container != null) { if (container.IsDisabled) { notifier.OnCheckPerformed(new CheckEventArgs("Root container is disabled", CheckResult.Fail)); } foreach (CohortAggregateContainer sub in container.GetAllSubContainersRecursively()) { if (sub.IsDisabled) { notifier.OnCheckPerformed(new CheckEventArgs("Query includes disabled container '" + sub + "'", CheckResult.Warning)); } foreach (AggregateConfiguration configuration in sub.GetAggregateConfigurations()) { if (configuration.IsDisabled) { notifier.OnCheckPerformed(new CheckEventArgs("Query includes disabled aggregate '" + configuration + "'", CheckResult.Warning)); } } } } try { if (_cohortIdentificationConfiguration.Frozen) { notifier.OnCheckPerformed( new CheckEventArgs( "CohortIdentificationConfiguration " + _cohortIdentificationConfiguration + " is Frozen (By " + _cohortIdentificationConfiguration.FrozenBy + " on " + _cohortIdentificationConfiguration.FrozenDate + "). It might have already been imported once before.", CheckResult.Warning)); } var result = TryGetPreview(); if (result.Rows.Count == 0) { throw new Exception("No Identifiers were returned by the cohort query"); } } catch (Exception e) { notifier.OnCheckPerformed(new CheckEventArgs("Could not build extraction SQL for " + _cohortIdentificationConfiguration, CheckResult.Fail, e)); } }
public void Check(ICheckNotifier notifier) { var dt = GenerateTable(); if (dt.Columns.Count <= 0) { notifier.OnCheckPerformed(new CheckEventArgs($"Failed to build table. Check {nameof(HeadersToRead)}", CheckResult.Fail)); } else { notifier.OnCheckPerformed(new CheckEventArgs($"Built table successfully", CheckResult.Success)); } }
public override void Check(ICheckNotifier notifier) { base.Check(notifier); //confirm type safety if (!ColumnToDilute.SqlDataType.ToLower().Contains("date")) { notifier.OnCheckPerformed(new CheckEventArgs( "ColumnToDilute '" + ColumnToDilute.RuntimeColumnName + "' has operation RoundDateToMiddleOfQuarter configured but it's datatype is " + ColumnToDilute.SqlDataType, CheckResult.Fail, null)); } }
/// <summary> /// Checks that the keyword is valid syntax for the <see cref="DatabaseType"/> and can be set on a <see cref="DbConnectionStringBuilder"/> /// </summary> /// <param name="notifier"></param> public void Check(ICheckNotifier notifier) { try { var accumulator = new ConnectionStringKeywordAccumulator(DatabaseType); accumulator.AddOrUpdateKeyword(Name, Value, ConnectionStringKeywordPriority.SystemDefaultLow); notifier.OnCheckPerformed(new CheckEventArgs("Integrity of keyword is ok according to ConnectionStringKeywordAccumulator", CheckResult.Success)); } catch (Exception e) { notifier.OnCheckPerformed(new CheckEventArgs(e.Message, CheckResult.Fail, e)); } }
public void Check(ICheckNotifier notifier) { MakeAssessment(); var message = "Environment Releasability is " + Assesment; if (!string.IsNullOrWhiteSpace(Reason)) { message += " - " + Reason; } notifier.OnCheckPerformed(new CheckEventArgs(message, GetCheckResultFor(Assesment), Exception)); }
private void CheckCohortDatabaseAccessible(ICheckNotifier notifier) { try { DataAccessPortal.GetInstance().ExpectServer(this, DataAccessContext.DataExport).TestConnection(); notifier.OnCheckPerformed(new CheckEventArgs("Connected to Cohort database '" + Name + "'", CheckResult.Success, null)); } catch (Exception e) { notifier.OnCheckPerformed(new CheckEventArgs("Could not connect to Cohort database called '" + Name + "'", CheckResult.Fail, e)); } }
private void CheckRowErrorTypeTable(ICheckNotifier notifier) { var expectedRowErrorTypes = new Dictionary <int, string> { { 1, "LoadRow" }, { 2, "Duplication" }, { 3, "Validation" }, { 4, "DatabaseOperation" }, { 5, "Unknown" } }; CheckLookupTableIsCorrectlyPopulated(notifier, "type", "z_RowErrorType", expectedRowErrorTypes); }