Ejemplo n.º 1
0
        private void CreateDescriptionsTable(XWPFDocument document, Catalogue c)
        {
            var extractionInformations = c.GetAllExtractionInformation(ExtractionCategory.Any).Where(Include).ToList();

            extractionInformations.Sort(IsExtractionIdentifiersFirstOrder);

            if (!extractionInformations.Any())
            {
                return;
            }

            InsertHeader(document, "Extractable Columns", 2);

            var table = InsertTable(document, extractionInformations.Count + 1, 4);

            int tableLine = 0;

            SetTableCell(table, tableLine, 0, "Column", TextFontSize);
            SetTableCell(table, tableLine, 1, "Datatype", TextFontSize);
            SetTableCell(table, tableLine, 2, "Description", TextFontSize);
            SetTableCell(table, tableLine, 3, "Category", TextFontSize);

            tableLine++;


            foreach (ExtractionInformation information in extractionInformations)
            {
                SetTableCell(table, tableLine, 0, information.GetRuntimeName(), TextFontSize);
                SetTableCell(table, tableLine, 1, information.ColumnInfo == null ? "ORPHAN":information.ColumnInfo.Data_type, TextFontSize);
                string description = information.CatalogueItem.Description;

                //a field should only ever be a foreign key to one Lookup table
                var lookups = information.ColumnInfo?.GetAllLookupForColumnInfoWhereItIsA(LookupType.ForeignKey);

                //if it has any lookups
                if (lookups != null && lookups.Any())
                {
                    var pkTableId = lookups.Select(l => l.PrimaryKey.TableInfo_ID).Distinct().SingleOrDefault();

                    var lookupTable = _repository.GetObjectByID <TableInfo>(pkTableId);

                    if (!LookupsEncounteredToAppearInAppendix.Contains(lookupTable))
                    {
                        LookupsEncounteredToAppearInAppendix.Add(lookupTable);
                    }

                    description += "References Lookup Table " + lookupTable.GetRuntimeName();
                }

                SetTableCell(table, tableLine, 2, description, TextFontSize);
                SetTableCell(table, tableLine, 3, information.ExtractionCategory.ToString(), TextFontSize);

                tableLine++;
            }

            AutoFit(table);
        }
Ejemplo n.º 2
0
        private Pipeline Get()
        {
            var id = (int?)_property.GetValue(User);

            if (id == null)
            {
                return(null);
            }

            return(_catalogueRepository.GetObjectByID <Pipeline>(id.Value));
        }
Ejemplo n.º 3
0
        private void ShowEditPipelineDialog()
        {
            //create pipeline UI with NO explicit destination/source (both must be configured within the extraction context by the user)
            var dialog = new ConfigurePipelineUI(Pipeline, _useCase, _repository);

            dialog.ShowDialog();

            ddPipelines.Items.Remove(Pipeline);

            Pipeline = _repository.GetObjectByID <Pipeline>(Pipeline.ID);
            ddPipelines.Items.Add(Pipeline);
            ddPipelines.SelectedItem = Pipeline;
        }
Ejemplo n.º 4
0
        public ITicketingSystem CreateIfExists(TicketingSystemConfiguration ticketingSystemConfiguration)
        {
            //if there is no ticketing system
            if (ticketingSystemConfiguration == null)
            {
                return(null);
            }

            //if there is no Type
            if (string.IsNullOrWhiteSpace(ticketingSystemConfiguration.Type))
            {
                return(null);
            }

            IDataAccessCredentials creds = null;

            //if there are credentials create with those (otherwise create with null credentials)
            if (ticketingSystemConfiguration.DataAccessCredentials_ID != null)
            {
                creds = _repository.GetObjectByID <DataAccessCredentials>((int)ticketingSystemConfiguration.DataAccessCredentials_ID);
            }

            return(Create(ticketingSystemConfiguration.Type, ticketingSystemConfiguration.Url, creds));
        }
Ejemplo n.º 5
0
        protected override void RunSpecificChecks(ICheckNotifier notifier, bool isRunTime)
        {
            if (!_releaseData.ReleaseGlobals || _releaseData.ReleaseState == ReleaseState.DoingPatch)
            {
                notifier.OnCheckPerformed(new CheckEventArgs("You cannot untick globals or release a subset of datasets when releasing from a DB", CheckResult.Fail));
            }

            var foundConnection = String.Empty;
            var tables          = new List <string>();

            foreach (var cumulativeResult in _releaseData.ConfigurationsForRelease.SelectMany(x => x.Key.CumulativeExtractionResults))
            {
                if (cumulativeResult.DestinationDescription.Split('|').Length != 3)
                {
                    throw new Exception("The extraction did not generate a description that can be parsed. " +
                                        "Have you extracted to a mix of CSVs and DB tables?");
                }

                string candidate = cumulativeResult.DestinationDescription.Split('|')[0] + "|" +
                                   cumulativeResult.DestinationDescription.Split('|')[1];

                tables.Add(cumulativeResult.DestinationDescription.Split('|')[2]);

                if (String.IsNullOrEmpty(foundConnection)) // the first time we use the candidate as our connection...
                {
                    foundConnection = candidate;
                }

                if (foundConnection != candidate) // ...then we check that all other candidates point to the same DB
                {
                    throw new Exception("You are trying to extract from multiple servers or databases. This is not allowed! " +
                                        "Please re-run the extracts against the same database.");
                }

                foreach (var supplementalResult in cumulativeResult.SupplementalExtractionResults
                         .Where(x => x.IsReferenceTo(typeof(SupportingSQLTable)) ||
                                x.IsReferenceTo(typeof(TableInfo))))
                {
                    if (supplementalResult.DestinationDescription.Split('|').Length != 3)
                    {
                        throw new Exception("The extraction did not generate a description that can be parsed. " +
                                            "Have you extracted to a mix of CSVs and DB tables?");
                    }

                    candidate = supplementalResult.DestinationDescription.Split('|')[0] + "|" +
                                supplementalResult.DestinationDescription.Split('|')[1];

                    tables.Add(supplementalResult.DestinationDescription.Split('|')[2]);

                    if (foundConnection != candidate) // ...then we check that all other candidates point to the same DB
                    {
                        throw new Exception("You are trying to extract from multiple servers or databases. This is not allowed! " +
                                            "Please re-run the extracts against the same database.");
                    }
                }
            }

            foreach (var globalResult in _releaseData.ConfigurationsForRelease.SelectMany(x => x.Key.SupplementalExtractionResults)
                     .Where(x => x.IsReferenceTo(typeof(SupportingSQLTable)) ||
                            x.IsReferenceTo(typeof(TableInfo))))
            {
                if (globalResult.DestinationDescription.Split('|').Length != 3)
                {
                    throw new Exception("The extraction did not generate a description that can be parsed. " +
                                        "Have you extracted the Globals to CSVs rather than DB tables?");
                }

                string candidate = globalResult.DestinationDescription.Split('|')[0] + "|" +
                                   globalResult.DestinationDescription.Split('|')[1];

                tables.Add(globalResult.DestinationDescription.Split('|')[2]);

                if (String.IsNullOrEmpty(foundConnection)) // the first time we use the candidate as our connection...
                {
                    foundConnection = candidate;
                }

                if (foundConnection != candidate) // ...then we check that all other candidates point to the same DB
                {
                    throw new Exception("You are trying to extract from multiple servers or databases. This is not allowed! " +
                                        "Please re-run the extracts against the same database.");
                }
            }

            var externalServerId = int.Parse(foundConnection.Split('|')[0]);
            var dbName           = foundConnection.Split('|')[1];

            var externalServer = _catalogueRepository.GetObjectByID <ExternalDatabaseServer>(externalServerId);

            if (!String.IsNullOrWhiteSpace(externalServer.MappedDataPath))
            {
                _dataPathMap = new DirectoryInfo(externalServer.MappedDataPath);
            }
            else
            {
                throw new Exception("The selected Server (" + externalServer.Name + ") must have a Data Path in order to be used as an extraction destination.");
            }

            var server = DataAccessPortal.GetInstance().ExpectServer(externalServer, DataAccessContext.DataExport, setInitialDatabase: false);

            _database = server.ExpectDatabase(dbName);

            if (!_database.Exists())
            {
                throw new Exception("Database " + _database + " does not exist!");
            }

            foreach (var table in tables)
            {
                var foundTable = _database.ExpectTable(table);
                if (!foundTable.Exists())
                {
                    throw new Exception("Table " + table + " does not exist!");
                }
            }

            var spuriousTables = _database.DiscoverTables(false).Where(t => !tables.Contains(t.GetRuntimeName())).ToList();

            if (spuriousTables.Any() && !notifier.OnCheckPerformed(new CheckEventArgs("Spurious table(s): " + String.Join(",", spuriousTables) + " found in the DB." +
                                                                                      "These WILL BE released, you may want to check them before proceeding.",
                                                                                      CheckResult.Warning,
                                                                                      null,
                                                                                      "Are you sure you want to continue the release process?")))
            {
                if (!isRunTime)
                {
                    throw new Exception("Release aborted by user.");
                }
            }

            DirectoryInfo sourceFolder   = GetSourceFolder();
            var           dbOutputFolder = sourceFolder.CreateSubdirectory(ExtractionDirectory.MASTER_DATA_FOLDER_NAME);

            var databaseName = _database.GetRuntimeName();

            if (File.Exists(Path.Combine(dbOutputFolder.FullName, databaseName + ".mdf")) ||
                File.Exists(Path.Combine(dbOutputFolder.FullName, databaseName + "_log.ldf")))
            {
                if (notifier.OnCheckPerformed(new CheckEventArgs(String.Format("It seems that database {0} was already detached previously into {1} " +
                                                                               "but not released or cleaned from the extraction folder", databaseName, dbOutputFolder.FullName),
                                                                 CheckResult.Warning,
                                                                 null,
                                                                 "Do you want to delete it? You should check the contents first. Clicking 'No' will abort the Release.")))
                {
                    File.Delete(Path.Combine(dbOutputFolder.FullName, databaseName + ".mdf"));
                    File.Delete(Path.Combine(dbOutputFolder.FullName, databaseName + "_log.ldf"));
                    notifier.OnCheckPerformed(new CheckEventArgs("Cleaned non-empty existing db output folder folder: " + dbOutputFolder.FullName,
                                                                 CheckResult.Success));
                }
                else
                {
                    if (!isRunTime)
                    {
                        throw new Exception("Release aborted by user.");
                    }
                }
            }
        }