Пример #1
0
        public void Check(ICheckNotifier notifier)
        {
            if (Separator == null)
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Separator argument has not been set on " + GetType().Name, CheckResult.Fail));
            }
            else
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Separator on " + GetType().Name + " is " + Separator, CheckResult.Success));
            }

            if (!StronglyTypeInput)
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs("StronglyTypeInput is false, this feature is highly recommended", CheckResult.Warning));
            }

            if (_fileToLoad.File == null)
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        "Input object FlatFileToLoad had a null .File property.  This means the FlatFileToLoad is not known.  This is only valid at DesignTime and only if the source file is unknown.  It means we can't check our compatibility with the file",
                        CheckResult.Warning));
                return;
            }

            if (_fileToLoad != null)
            {
                CheckExpectedFileExtensions(notifier, _fileToLoad.File.Extension);
            }
        }
Пример #2
0
        private void NotifyFail(Exception e, ICheckNotifier notifier, ITriggerImplementer microsoftSQLTrigger)
        {
            bool shouldCreate = notifier.OnCheckPerformed(new CheckEventArgs(
                                                              "Trigger error encountered when checking integrity of table " + _table,
                                                              CheckResult.Warning, e, "Drop and then Re-Create Trigger on table " + _table));

            if (shouldCreate)
            {
                string problemsDroppingTrigger;
                string thingsThatWorkedDroppingTrigger;

                microsoftSQLTrigger.DropTrigger(out problemsDroppingTrigger, out thingsThatWorkedDroppingTrigger);

                if (!string.IsNullOrWhiteSpace(thingsThatWorkedDroppingTrigger))
                {
                    notifier.OnCheckPerformed(new CheckEventArgs(thingsThatWorkedDroppingTrigger, CheckResult.Success, null));
                }

                if (!string.IsNullOrWhiteSpace(problemsDroppingTrigger))
                {
                    notifier.OnCheckPerformed(new CheckEventArgs(problemsDroppingTrigger, CheckResult.Warning, null));
                }

                microsoftSQLTrigger.CreateTrigger(notifier);
                TriggerCreated = true;
            }
        }
Пример #3
0
        /// <summary>
        /// Checks that the AggregateConfiguration can be resolved into a runnable SQL quer <see cref="GetQueryBuilder"/>
        /// </summary>
        /// <param name="notifier"></param>
        public void Check(ICheckNotifier notifier)
        {
            if (HavingSQL != null && HavingSQL.StartsWith("HAVING", StringComparison.CurrentCultureIgnoreCase))
            {
                notifier.OnCheckPerformed(new CheckEventArgs("HavingSql does not need the word 'HAVING' at the start, it is implicit", CheckResult.Fail));
            }

            //these are not checkable since they are intended for use by CohortQueryBuilder instead
            if (IsCohortIdentificationAggregate)
            {
                return;
            }

            //if it's a normal aggregate then don't let the user have more than 2 columns
            if (AggregateDimensions.Length > 2)
            {
                throw new QueryBuildingException("Too many columns, You can only have a maximum of 2 columns in any graph (plus a count column).  These are: \r\n 1. The time axis (if any) \r\n 2. The pivot column (if any)");
            }

            if (AggregateDimensions.Length == 2 && !PivotOnDimensionID.HasValue)
            {
                throw new QueryBuildingException("In order to have 2 columns, one must be selected as a pivot");
            }

            try
            {
                var qb = GetQueryBuilder();
                notifier.OnCheckPerformed(new CheckEventArgs("successfully generated Aggregate SQL:" + qb.SQL,
                                                             CheckResult.Success));
            }
            catch (Exception e)
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Failed to generate Aggregate SQL", CheckResult.Fail, e));
            }
        }
Пример #4
0
        public string FindDefaultSQLServerDatabaseDirectory(ICheckNotifier notifier)
        {
            notifier.OnCheckPerformed(new CheckEventArgs("About to look up Sql Server DATA directory Path", CheckResult.Success));

            try
            {
                //connect to master to run the data directory discovery SQL
                var builder = new SqlConnectionStringBuilder(_dbInfo.Server.Builder.ConnectionString);
                builder.InitialCatalog = "master";

                using (var connection = new SqlConnection(builder.ConnectionString))
                {
                    connection.Open();

                    notifier.OnCheckPerformed(new CheckEventArgs("About to run:\r\n" + GetDefaultSQLServerDatabaseDirectory, CheckResult.Success));

                    string result = new SqlCommand(GetDefaultSQLServerDatabaseDirectory, connection).ExecuteScalar() as string;

                    if (string.IsNullOrWhiteSpace(result))
                    {
                        throw new Exception("Looking up DATA directory on server returned null (user may not have permissions to read from relevant sys tables)");
                    }

                    return(result);
                }
            }
            catch (SqlException e)
            {
                throw new Exception("Could not execute the command: " + GetDefaultSQLServerDatabaseDirectory, e);
            }
        }
Пример #5
0
        public void Check(ICheckNotifier notifier)
        {
            try
            {
                dqeRepository = new DQERepository((ICatalogueRepository)_loadProgress.Repository);
            }
            catch (Exception ex)
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        "Could not contact DQE server to check the 'real' coverage of the datasets linked to this LoadProgress, possibly because there isn't a DQE server yet.  You should create one in ManageExternalServers",
                        CheckResult.Fail, ex));
                return;
            }

            if (CataloguesPeriodictiyData == null)
            {
                FetchDataFromDQE(notifier);
            }

            if (CachePeriodictiyData == null)
            {
                FetchCacheData(notifier);
            }

            foreach (Catalogue cataloguesMissingDQERun in CataloguesMissingDQERuns)
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        "Catalogue '" + cataloguesMissingDQERun +
                        "' is associated with the load '" + _loadMetadata +
                        "' but has never had a DQE run executed on it, you should configure some basic validation on it and choose a time periodicity column and execute a DQE run on it.",
                        CheckResult.Fail));
            }
        }
Пример #6
0
        public override void Check(ICheckNotifier notifier)
        {
            base.Check(notifier);
            if (Request == null || Request == ExtractDatasetCommand.EmptyCommand) // it is the globals, and there is no PK involved in there... although there should be...
            {
                return;
            }

            var cataloguePrimaryKeys = GetCatalogueItemPrimaryKeys().ToArray();

            if (!cataloguePrimaryKeys.Any())
            {
                notifier.OnCheckPerformed(new CheckEventArgs("PKSynthesizer:No CatalogueItems marked IsPrimaryKey in '" + Request.SelectedDataSets + "'", CheckResult.Warning));

                var columnInfoPrimaryKeys = GetColumnInfoPrimaryKeys().ToArray();

                if (columnInfoPrimaryKeys.Any())
                {
                    notifier.OnCheckPerformed(new CheckEventArgs("PKSynthesizer:Found ColumnInfo(s) marked IsPrimaryKey in '" + Request.SelectedDataSets + "'" + string.Join(",", columnInfoPrimaryKeys.Select(c => c.Name)), CheckResult.Success));
                }
                else
                {
                    notifier.OnCheckPerformed(new CheckEventArgs("PKSynthesizer:No ColumnInfo marked IsPrimaryKey in '" + Request.SelectedDataSets + "'", CheckResult.Fail));
                }
            }
            else
            {
                notifier.OnCheckPerformed(new CheckEventArgs("PKSynthesizer:Found CatalogueItem(s) marked IsPrimaryKey in '" + Request.SelectedDataSets + "'" + string.Join(",", cataloguePrimaryKeys.Select(c => c.GetRuntimeName())), CheckResult.Success));
            }
        }
Пример #7
0
        /// <summary>
        /// Checks whether the dita file generation is likely to work e.g. that all datasets have unique acronymns etc
        /// </summary>
        /// <param name="notifier"></param>
        public void Check(ICheckNotifier notifier)
        {
            var catas = _repository.GetAllObjects <Catalogue>().Where(c => !c.IsInternalDataset && !c.IsColdStorageDataset).ToArray();

            //Catalogues with no acronyms
            foreach (Catalogue c in catas.Where(c => string.IsNullOrWhiteSpace(c.Acronym)))
            {
                string suggestion    = GetAcronymSuggestionFromCatalogueName(c.Name);
                bool   useSuggestion = notifier.OnCheckPerformed(new CheckEventArgs("Catalogue " + c.Name + " has no Acronym", CheckResult.Fail, null, "Assign it a suggested acronym: '" + suggestion + "'?"));

                if (useSuggestion)
                {
                    c.Acronym = suggestion;
                    c.SaveToDatabase();
                }
            }

            //acronym collisions
            for (int i = 0; i < catas.Length; i++)
            {
                string acronym = catas[i].Acronym;

                for (int j = i + 1; j < catas.Length; j++)
                {
                    if (catas[j].Acronym.Equals(acronym))
                    {
                        notifier.OnCheckPerformed(new CheckEventArgs(
                                                      string.Format(
                                                          "Duplication in acronym between Catalogues {0} and {1}, duplicate acronym value is {2}",
                                                          catas[i], catas[j], acronym), CheckResult.Fail, null));
                    }
                }
            }
        }
Пример #8
0
        private void CheckDocument(SupportingDocument document, ICheckNotifier notifier)
        {
            if (document == null)
            {
                notifier.OnCheckPerformed(new CheckEventArgs("SupportingDocument has not been set", CheckResult.Fail));
                return;
            }

            try
            {
                var toCopy = document.GetFileName();

                if (toCopy != null && toCopy.Exists)
                {
                    notifier.OnCheckPerformed(
                        new CheckEventArgs("Found SupportingDocument " + toCopy.Name + " and it exists",
                                           CheckResult.Success));
                }
                else
                {
                    notifier.OnCheckPerformed(
                        new CheckEventArgs("SupportingDocument " + document + "(ID=" + document.ID +
                                           ") does not map to an existing file despite being flagged as Extractable",
                                           CheckResult.Fail));
                }
            }
            catch (Exception e)
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Could not check supporting documents of " + _catalogue, CheckResult.Fail, e));
            }
        }
Пример #9
0
        private void CheckInProgressConfiguration(ICheckNotifier notifier)
        {
            var repo = (DataExportRepository)_config.Repository;

            notifier.OnCheckPerformed(new CheckEventArgs("Found configuration '" + _config + "'", CheckResult.Success));

            var datasets = _config.GetAllExtractableDataSets().ToArray();

            foreach (ExtractableDataSet dataSet in datasets)
            {
                if (dataSet.DisableExtraction)
                {
                    notifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "Dataset " + dataSet +
                            " is set to DisableExtraction=true, probably someone doesn't want you extracting this dataset at the moment",
                            CheckResult.Fail));
                }
            }

            if (!datasets.Any())
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        "There are no datasets selected for open configuration '" + _config + "'",
                        CheckResult.Fail));
            }

            if (_config.Cohort_ID == null)
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        "Open configuration '" + _config + "' does not have a cohort yet",
                        CheckResult.Fail));
                return;
            }

            //make sure that it's cohort is retrievable
            repo.GetObjectByID <ExtractableCohort>((int)_config.Cohort_ID);

            if (CheckDatasets)
            {
                foreach (ISelectedDataSets s in _config.SelectedDataSets)
                {
                    new SelectedDataSetsChecker(s).Check(notifier);
                }
            }

            //globals
            if (CheckGlobals)
            {
                if (datasets.Any())
                {
                    foreach (SupportingSQLTable table in _config.GetGlobals().OfType <SupportingSQLTable>())
                    {
                        new SupportingSQLTableChecker(table).Check(notifier);
                    }
                }
            }
        }
Пример #10
0
        public void Synchronize(ICheckNotifier notifier)
        {
            IdentifierDumper dumper = new IdentifierDumper(_tableToSync);

            dumper.Check(notifier);

            CheckForDuplicateANOVsRegularNames();

            var columnInfosWithANOTransforms = _tableToSync.ColumnInfos.Where(c => c.ANOTable_ID != null).ToArray();

            if (!columnInfosWithANOTransforms.Any())
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        "There are no ANOTables configured for this table so skipping ANOTable checking",
                        CheckResult.Success));
            }

            foreach (ColumnInfo columnInfoWithANOTransform in columnInfosWithANOTransforms)
            {
                ANOTable anoTable = columnInfoWithANOTransform.ANOTable;
                anoTable.Check(new ThrowImmediatelyCheckNotifier());

                if (!anoTable.GetRuntimeDataType(LoadStage.PostLoad).Equals(columnInfoWithANOTransform.Data_type))
                {
                    throw new ANOConfigurationException("Mismatch between anoTable.GetRuntimeDataType(LoadStage.PostLoad) = " + anoTable.GetRuntimeDataType(LoadStage.PostLoad) + " and column " + columnInfoWithANOTransform + " datatype = " + columnInfoWithANOTransform.Data_type);
                }

                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        "ANOTable " + anoTable + " has shared compatible datatype " + columnInfoWithANOTransform.Data_type + " with ColumnInfo " +
                        columnInfoWithANOTransform, CheckResult.Success));
            }
        }
Пример #11
0
        /// <summary>
        /// Checks extraction directory for unexpected files.  Call <see cref="GetEvaluator"/> if want to know whether a specific global artifact is in a valid
        /// state.
        /// </summary>
        /// <param name="notifier"></param>
        public void Check(ICheckNotifier notifier)
        {
            // checks for pollution in the globals directory
            foreach (var extractionConfiguration in _configurations)
            {
                var allExtracted = extractionConfiguration.SupplementalExtractionResults.Where(ser => IsValidPath(ser.DestinationDescription));
                var extractDir   = extractionConfiguration.GetProject().ExtractionDirectory;
                var folder       = new ExtractionDirectory(extractDir, extractionConfiguration).GetGlobalsDirectory();

                var unexpectedDirectories = folder.EnumerateDirectories().Where(d => !d.Name.Equals("SupportingDocuments")).ToList();

                if (unexpectedDirectories.Any())
                {
                    notifier.OnCheckPerformed(new CheckEventArgs("Unexpected directories found in extraction directory (" +
                                                                 String.Join(",", unexpectedDirectories.Select(d => d.FullName)) +
                                                                 ". Pollution of extract directory is not permitted.", CheckResult.Fail));
                }

                var unexpectedFiles = folder.EnumerateFiles("*.*", SearchOption.AllDirectories).Where(f => allExtracted.All(ae => ae.DestinationDescription != f.FullName)).ToList();

                if (unexpectedFiles.Any())
                {
                    notifier.OnCheckPerformed(new CheckEventArgs("Unexpected files found in extract directory (" +
                                                                 String.Join(",", unexpectedFiles.Select(d => d.FullName)) +
                                                                 "). Pollution of extract directory is not permitted.", CheckResult.Fail));
                }
            }
        }
Пример #12
0
        public override void Check(ICheckNotifier notifier)
        {
            base.Check(notifier);

            if (string.IsNullOrWhiteSpace(PrimaryKeyColumns))
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Argument PrimaryKeyColumns has not been set", CheckResult.Fail));
            }

            var pks = GetPKs();

            if (string.IsNullOrWhiteSpace(TargetDataTableKeyColumnName))
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Argument TargetDataTableKeyColumnName has not been set", CheckResult.Fail));
            }

            if (string.IsNullOrWhiteSpace(TargetDataTableValueColumnName))
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Argument TargetDataTableValueColumnName has not been set", CheckResult.Fail));
            }

            string duplicate = pks.FirstOrDefault(s => s.Equals(TargetDataTableKeyColumnName) || s.Equals(TargetDataTableValueColumnName));

            if (duplicate != null)
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Field '" + duplicate + "' is both a PrimaryKeyColumn and a TargetDataTable column, this is not allowed.  Your fields Pk1,Pk2,Pketc,Key,Value must all be mutually exclusive", CheckResult.Fail));
            }

            if (TargetDataTableKeyColumnName != null && TargetDataTableKeyColumnName.Equals(TargetDataTableValueColumnName))
            {
                notifier.OnCheckPerformed(new CheckEventArgs("TargetDataTableKeyColumnName cannot be the same as TargetDataTableValueColumnName", CheckResult.Fail));
            }
        }
Пример #13
0
        protected void CheckTablesExist(ICheckNotifier notifier)
        {
            try
            {
                if (!_remoteDatabase.Exists())
                    throw new Exception("Database " + _remoteDatabase + " did not exist on the remote server");

                //still worthwhile doing this incase we cannot connect to the server
                var tables = _remoteDatabase.DiscoverTables(true).Select(t => t.GetRuntimeName()).ToArray();
                
                //overrides table level checks
                if (!string.IsNullOrWhiteSpace(RemoteSelectSQL))
                    return;

                //user has just picked a table to copy exactly so we can precheck for it
                if (tables.Contains(RemoteTableName))
                    notifier.OnCheckPerformed(new CheckEventArgs(
                        "successfully found table " + RemoteTableName + " on server " + _remoteDatabase.Server + " on database " +
                        _remoteDatabase,
                        CheckResult.Success, null));
                else
                    notifier.OnCheckPerformed(new CheckEventArgs(
                        "Could not find table called '" + RemoteTableName + "' on server " + _remoteDatabase.Server + " on database " +
                        _remoteDatabase +Environment.NewLine+"(The following tables were found:"+string.Join(",",tables)+")",
                        CheckResult.Fail, null));
            }
            catch (Exception e)
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Problem occurred when trying to enumerate tables on server " + _remoteDatabase.Server + " on database " +_remoteDatabase, CheckResult.Fail, e));
            }
        }
Пример #14
0
        private void AddChildren(ProjectCohortIdentificationConfigurationAssociationsNode projectCiCsNode, DescendancyList descendancy)
        {
            //add the associations
            HashSet <object> children = new HashSet <object>();

            foreach (ProjectCohortIdentificationConfigurationAssociation association in AllProjectAssociatedCics.Where(assoc => assoc.Project_ID == projectCiCsNode.Project.ID))
            {
                var matchingCic = AllCohortIdentificationConfigurations.SingleOrDefault(cic => cic.ID == association.CohortIdentificationConfiguration_ID);

                if (matchingCic == null)
                {
                    _errorsCheckNotifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "Failed to find Associated Cohort Identification Configuration with ID " +
                            association.CohortIdentificationConfiguration_ID +
                            " which was supposed to be associated with " + association.Project, CheckResult.Fail));//inject knowledge of what the cic is so it doesn't have to be fetched during ToString
                }
                else
                {
                    association.InjectKnown(matchingCic);

                    //document that it is a child of the project cics node
                    children.Add(association);
                }
            }

            AddToDictionaries(children, descendancy);
        }
Пример #15
0
        public void Check(ICheckNotifier notifier)
        {
            var server = _repository.DiscoveredServer;

            if (!server.Exists())
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Could not reach server", CheckResult.Fail));
                return;
            }

            var db = server.GetCurrentDatabase();

            if (!db.Exists())
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Could not find database " + db, CheckResult.Fail));
                return;
            }

            var tables = db.DiscoverTables(false);

            foreach (Type type in _repository.GetCompatibleTypes())
            {
                CheckEntities(notifier, type, tables);
            }
        }
Пример #16
0
        private void CheckDatasetExists(ICheckNotifier notifier, string dataSetID)
        {
            using (var conn = _server.GetConnection())
            {
                conn.Open();

                var cmd = _server.GetCommand("SELECT 1 FROM DataSet WHERE dataSetID=@dsID", conn);
                _server.AddParameterWithValueToCommand("@dsID", cmd, dataSetID);

                var found = cmd.ExecuteScalar();

                if (found != null)
                {
                    notifier.OnCheckPerformed(new CheckEventArgs("Found default dataset: " + dataSetID, CheckResult.Success, null));
                    return;
                }

                if (notifier.OnCheckPerformed(new CheckEventArgs("Did not find default dataset '" + dataSetID + "'.", CheckResult.Fail, null, "Create the dataset '" + dataSetID + "'")))
                {
                    cmd = _server.GetCommand("INSERT INTO DataSet (dataSetID, name) VALUES (@dsID, @dsID)", conn);
                    _server.AddParameterWithValueToCommand("@dsID", cmd, dataSetID);
                    cmd.ExecuteNonQuery();
                }
            }
        }
Пример #17
0
        /// <summary>
        /// Checks that the file exists
        /// </summary>
        /// <param name="notifier"></param>
        public void Check(ICheckNotifier notifier)
        {
            try
            {
                FileInfo fileInfo = new FileInfo(URL);

                if (fileInfo.Exists)
                {
                    notifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "Found intact attachment file " + fileInfo + " with length " +
                            UsefulStuff.GetHumanReadableByteSize(fileInfo.Length), CheckResult.Success));
                }
                else
                {
                    notifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "File " + fileInfo.FullName + " does not exist (for GovernanceDocument '" + this + "' (ID=" +
                            ID + ")", CheckResult.Fail));
                }
            }
            catch (Exception ex)
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        "Failed to check for existance of the file described by GovernanceDocument '" + this + "' (ID=" +
                        ID + ")", CheckResult.Fail, ex));
            }
        }
Пример #18
0
        /// <summary>
        /// Lists assembly load errors and attempts to construct instances of all Types declared as Exports (which are ICheckable)
        /// </summary>
        /// <param name="notifier"></param>
        public void Check(ICheckNotifier notifier)
        {
            foreach (KeyValuePair <string, Exception> badAssembly in _mefPlugins.ListBadAssemblies())
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Could not load assembly " + badAssembly.Key, CheckResult.Fail, badAssembly.Value));
            }

            foreach (Type t in _mefPlugins.GetAllTypes())
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Found Type " + t, CheckResult.Success, null));

                if (typeof(ICheckable).IsAssignableFrom(t))
                {
                    try
                    {
                        _mefPlugins.CreateA <ICheckable>(t.FullName);
                    }
                    catch (Exception ex)
                    {
                        notifier.OnCheckPerformed(new CheckEventArgs(
                                                      "Class " + t.FullName +
                                                      " implements ICheckable but could not be created as an ICheckable.",
                                                      CheckResult.Warning, ex));
                    }
                }
            }
        }
Пример #19
0
        public override void Check(ICheckNotifier notifier)
        {
            // ping configured remote PACS with a C-ECHO request
            //use a new requestSender
            var echoRequestSender = new DicomRequestSender(GetConfiguration(), new FromCheckNotifierToDataLoadEventListener(notifier));

            echoRequestSender.OnRequestException += (ex) =>
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Error sending ECHO", CheckResult.Fail, ex));
            };
            echoRequestSender.OnRequestTimeout += () =>
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Failed to get response from server after timeout", CheckResult.Fail));
            };
            echoRequestSender.OnRequestSucess += () =>
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Successfully received C-ECHO response from remote PACS", CheckResult.Success));
            };

            try
            {
                echoRequestSender.Check();
            }
            catch (Exception e)
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Error when sending C-ECHO to remote PACS", CheckResult.Fail, e));
            }
        }
Пример #20
0
        private void CheckTableInfoSynchronization(TableInfo tableInfo, ICheckNotifier notifier)
        {
            //live is the current data load's (possilby overridden server/database)
            var tableInfoSynchronizer = new TableInfoSynchronizer(tableInfo);

            string problemList = "";

            //synchronize but refuse to apply all fixes, problems are instead added to problemList
            if (tableInfoSynchronizer.Synchronize(notifier))
            {
                notifier.OnCheckPerformed(new CheckEventArgs("TableInfo " + tableInfo + " passed Synchronization check", CheckResult.Success, null)); //passed synchronization
            }
            else
            {
                bool launchSyncFixer = notifier.OnCheckPerformed(new CheckEventArgs(
                                                                     "TableInfo " + tableInfo + " failed Synchronization check with following problems:" + problemList, CheckResult.Fail,
                                                                     null, "Launch Synchronization Fixing")); //failed syncronization

                if (launchSyncFixer)
                {
                    bool userFixed;

                    //if silent running accept all changes
                    userFixed = tableInfoSynchronizer.Synchronize(notifier);

                    if (!userFixed)
                    {
                        notifier.OnCheckPerformed(new CheckEventArgs("TableInfo " + tableInfo + " still failed Synchronization check", CheckResult.Fail, null)); //passed synchronization
                    }
                }
            }
        }
Пример #21
0
 public void Check(ICheckNotifier notifier)
 {
     if (_fileToLoad != null)
     {
         if (!IsAcceptableFileExtension())
         {
             notifier.OnCheckPerformed(
                 new CheckEventArgs("File extension " + _fileToLoad.File +
                                    " has an invalid extension:" + _fileToLoad.File.Extension +
                                    " (this class only accepts:" + string.Join(",", acceptedFileExtensions) + ")",
                                    CheckResult.Fail));
         }
         else
         {
             notifier.OnCheckPerformed(
                 new CheckEventArgs("File extension of file " + _fileToLoad.File.Name + " is acceptable",
                                    CheckResult.Success));
         }
     }
     else
     {
         notifier.OnCheckPerformed(
             new CheckEventArgs(
                 "FlatFileToLoad (Pipeline Requirement) was not met (we weren't initialized with a file)",
                 CheckResult.Warning));
     }
 }
Пример #22
0
        private bool CheckColumnOrderInTablesAndArchiveMatch(string[] liveCols, string[] archiveCols, ICheckNotifier notifier)
        {
            bool passed = true;

            foreach (var requiredArchiveColumns in new[] { "hic_validTo", "hic_userID", "hic_status" })
            {
                if (!archiveCols.Any(c => c.Equals(requiredArchiveColumns, StringComparison.CurrentCultureIgnoreCase)))
                {
                    notifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "Column " + requiredArchiveColumns + " was not found in " + _archiveTable,
                            CheckResult.Fail));
                    passed = false;
                }
            }


            foreach (var missingColumn in liveCols.Except(archiveCols))
            {
                notifier.OnCheckPerformed(new CheckEventArgs(
                                              "Column " + missingColumn + " in table " + _table +
                                              " was not found in the  _Archive table",
                                              CheckResult.Fail, null));
                passed = false;
            }

            return(passed);
        }
Пример #23
0
        /// <inheritdoc/>
        public virtual void Check(ICheckNotifier notifier)
        {
            if (!string.IsNullOrWhiteSpace(ExtractionSubdirectoryPattern))
            {
                if (ExtractionSubdirectoryPattern.Contains("."))
                {
                    notifier.OnCheckPerformed(new CheckEventArgs(
                                                  "ExtractionSubdirectoryPattern cannot contain dots, it must be relative e.g. $c/$d",
                                                  CheckResult.Fail));
                }

                if (!ExtractionSubdirectoryPattern.Contains("$i") && !ExtractionSubdirectoryPattern.Contains("$c"))
                {
                    notifier.OnCheckPerformed(new CheckEventArgs(
                                                  "ExtractionSubdirectoryPattern must contain a Configuration element ($i or $c)",
                                                  CheckResult.Fail));
                }

                if (!ExtractionSubdirectoryPattern.Contains("$a") && !ExtractionSubdirectoryPattern.Contains("$d") && !ExtractionSubdirectoryPattern.Contains("$n"))
                {
                    notifier.OnCheckPerformed(new CheckEventArgs(
                                                  "ExtractionSubdirectoryPattern must contain a Dataset element ($d, $a or $n)",
                                                  CheckResult.Fail));
                }
            }
        }
Пример #24
0
        public void Check(ICheckNotifier notifier)
        {
            if (string.IsNullOrWhiteSpace(Server))
            {
                notifier.OnCheckPerformed(new CheckEventArgs("No Server set", CheckResult.Warning));
            }
            else
            if (string.IsNullOrWhiteSpace(Database))
            {
                notifier.OnCheckPerformed(new CheckEventArgs("No Database set", CheckResult.Warning));
            }
            else
            {
                try
                {
                    DataAccessPortal.GetInstance().ExpectServer(this, DataAccessContext.InternalDataProcessing).TestConnection();
                    notifier.OnCheckPerformed(new CheckEventArgs("Successfully connected to server", CheckResult.Success));
                }
                catch (Exception exception)
                {
                    notifier.OnCheckPerformed(new CheckEventArgs("Failed to connect to server", CheckResult.Fail, exception));
                    return;
                }
            }

            //if it's a logging server run logging checks
            if (WasCreatedBy(new LoggingDatabasePatcher()))
            {
                new LoggingDatabaseChecker(this).Check(notifier);
            }
        }
Пример #25
0
        private void CheckReleaseConfiguration(ICheckNotifier notifier)
        {
            var projectDirectory = new DirectoryInfo(_config.Project.ExtractionDirectory);

            notifier.OnCheckPerformed(new CheckEventArgs("Found Frozen/Released configuration '" + _config + "'", CheckResult.Success));

            foreach (DirectoryInfo directoryInfo in projectDirectory.GetDirectories(ExtractionDirectory.GetExtractionDirectoryPrefix(_config) + "*").ToArray())
            {
                string firstFileFound;

                if (DirectoryIsEmpty(directoryInfo, out firstFileFound))
                {
                    bool deleteIt =
                        notifier.OnCheckPerformed(
                            new CheckEventArgs(
                                "Found empty folder " + directoryInfo.Name +
                                " which is left over extracted folder after data release", CheckResult.Warning, null,
                                "Delete empty folder"));

                    if (deleteIt)
                    {
                        directoryInfo.Delete(true);
                    }
                }
                else
                {
                    notifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "Found non-empty folder " + directoryInfo.Name +
                            " which is left over extracted folder after data release (First file found was '" + firstFileFound + "' but there may be others)", CheckResult.Fail));
                }
            }
        }
Пример #26
0
        private void ConfirmStagingAndLiveHaveSameColumns(string tableName, DiscoveredColumn[] stagingCols, DiscoveredColumn[] liveCols, bool requireSameNumberAndOrder, ICheckNotifier notifier)
        {
            //in LIVE but not STAGING
            foreach (var missingColumn in liveCols.Select(c => c.GetRuntimeName()).Except(stagingCols.Select(c => c.GetRuntimeName())))
            {
                //column is in live but not in staging, but it is hic_
                if (SpecialFieldNames.IsHicPrefixed(missingColumn)) //this is permitted
                {
                    continue;
                }
                else
                {
                    notifier.OnCheckPerformed(new CheckEventArgs(
                                                  "Column " + missingColumn + " is missing from STAGING", CheckResult.Fail, null));
                }
            }

            //in STAGING but not LIVE
            foreach (var missingColumn in stagingCols.Except(liveCols))
            {
                notifier.OnCheckPerformed(new CheckEventArgs(
                                              "Column " + missingColumn + " is in STAGING but not LIVE", CheckResult.Fail, null));
            }



            if (requireSameNumberAndOrder)
            {
                bool passedColumnOrderCheck = true;

                if (stagingCols.Length != liveCols.Length)
                {
                    notifier.OnCheckPerformed(new CheckEventArgs(
                                                  "Column count mismatch between staging and live in table " + tableName, CheckResult.Fail, null));
                    passedColumnOrderCheck = false;
                }
                else
                {
                    //check they are in the same order
                    for (int i = 0; i < stagingCols.Length; i++)
                    {
                        if (!stagingCols[i].Equals(liveCols[i]))
                        {
                            notifier.OnCheckPerformed(new CheckEventArgs(
                                                          "Column name/order mismatch between staging and live in table " + tableName +
                                                          ", column " + i + " is " + stagingCols[i] + " in staging but is " + liveCols[i] +
                                                          " in live.", CheckResult.Fail, null));
                            passedColumnOrderCheck = false;
                            break;
                        }
                    }
                }

                if (passedColumnOrderCheck)
                {
                    notifier.OnCheckPerformed(new CheckEventArgs("Column order match confirmed between staging and live on table " + tableName, CheckResult.Success, null));
                }
            }
        }
Пример #27
0
        /// <summary>
        /// Checks that the alleged parent of the cloned IFilter still exists and issues a warning if the SQL has changed vs the master (might not
        ///  be a problem since user customisation is allowed)
        /// </summary>
        /// <param name="notifier"></param>
        public void Check(ICheckNotifier notifier)
        {
            if (_allegedParent == null)
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        "Filter " + _child +
                        " is not cloned from a Catalogue filter so does not need checking for synchronicity",
                        CheckResult.Success));

                return;
            }

            //we were cloned from a filter in the Catalogue
            bool exist = _catalogueDatabaseRepository.StillExists <ExtractionFilter>((int)_allegedParent);

            //tell them if it has been nuked
            notifier.OnCheckPerformed(
                new CheckEventArgs(
                    "Catalogue reports that the original filter we were cloned from " +
                    (exist ? " still exists " : " no longer exists"), exist ? CheckResult.Success : CheckResult.Warning));

            //it hasn't been nuked
            if (exist)
            {
                //get it
                var parent = _catalogueDatabaseRepository.GetObjectByID <ExtractionFilter>((int)_allegedParent);

                if (string.IsNullOrWhiteSpace(parent.WhereSQL) || string.IsNullOrWhiteSpace(_child.WhereSQL))
                {
                    return;
                }

                //see if someone has been monkeying with the parent (or the child) in which case warn them about the disparity
                if (parent.WhereSQL.Equals(_child.WhereSQL))
                {
                    notifier.OnCheckPerformed(new CheckEventArgs(
                                                  "Filter " + _child + " has the same WhereSQL as parent",
                                                  CheckResult.Success));
                }
                else
                {
                    try
                    {
                        throw new ExpectedIdenticalStringsException("Expected WHERE SQL to be identical", parent.WhereSQL, _child.WhereSQL);
                    }
                    catch (ExpectedIdenticalStringsException ex)
                    {
                        notifier.OnCheckPerformed(
                            new CheckEventArgs(
                                _child.GetType().Name + " called '" + _child + "' (ID=" + _child.ID +
                                ") WhereSQL does not match the parent it was originally cloned from (ExtractionFilter ID=" +
                                _allegedParent +
                                ").  You might have made a deliberate change in your copy or it might mean that someone has corrected the parent since you first cloned it",
                                CheckResult.Warning, ex));
                    }
                }
            }
        }
Пример #28
0
        private void CheckTableInfo(TableInfo tableInfo, ICheckNotifier notifier)
        {
            //get all columns
            ColumnInfo[] columnInfos;
            ColumnInfo[] columnInfosWhichArePrimaryKeys;

            //check whether the live database and staging databases have appropriate columns and triggers etc on them
            DiscoveredDatabase staging = _databaseConfiguration.DeployInfo[LoadBubble.Staging];
            DiscoveredDatabase live    = DataAccessPortal.GetInstance().ExpectDatabase(tableInfo, DataAccessContext.DataLoad);

            var liveTable = live.ExpectTable(tableInfo.GetRuntimeName(LoadBubble.Live, _databaseConfiguration.DatabaseNamer), tableInfo.Schema);
            var liveCols  = liveTable.DiscoverColumns();

            CheckTableInfoSynchronization(tableInfo, notifier);

            CheckTableHasColumnInfosAndPrimaryKeys(live, tableInfo, out columnInfos, out columnInfosWhichArePrimaryKeys, notifier);

            try
            {
                //if trigger is created as part of this check then it is likely to have resulted in changes to the underlying table (e.g. added hic_validFrom field) in which case we should resynch the TableInfo to pickup these new columns
                bool runSynchronizationAgain;
                CheckTriggerIntact(liveTable, notifier, out runSynchronizationAgain);

                if (runSynchronizationAgain)
                {
                    CheckTableInfoSynchronization(tableInfo, notifier);
                }

                if (!_databaseConfiguration.RequiresStagingTableCreation)
                {
                    //Important:
                    //Regarding this if block: None of the current loading systems in RDMP have RequiresStagingTableCreation as false but in theory you could build some kind of multi threaded horror
                    //which had multiple simultaneous loads all populating a single STAGING bubble therefore this code is left in the codebase, it probably works ok but you will need a
                    //fair bit of work if you want to realise such a monstrosity (for one cleanup on each run probably cleans up STAGING on exit)

                    //live can have additional hic_ columns which do not appear in staging (lookups cannot)
                    var stagingTable = staging.ExpectTable(tableInfo.GetRuntimeName(LoadBubble.Staging, _databaseConfiguration.DatabaseNamer));

                    if (!stagingTable.Exists())
                    {
                        notifier.OnCheckPerformed(new CheckEventArgs("RequiresStagingTableCreation is false but staging does not exist, this flag should indicate that you anticipate STAGING to be already setup before you kick off the load", CheckResult.Fail));
                    }

                    var stagingCols = stagingTable.DiscoverColumns();

                    ConfirmStagingAndLiveHaveSameColumns(tableInfo.GetRuntimeName(), stagingCols, liveCols, false, notifier);

                    CheckStagingToLiveMigrationForTable(stagingTable, stagingCols, liveTable, liveCols, notifier);
                }
            }
            catch (Exception e)
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Load Checks Crashed " + tableInfo, CheckResult.Fail, e));
            }
        }
Пример #29
0
 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));
     }
 }
Пример #30
0
 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));
     }
 }