Exemplo n.º 1
0
        private void LoadFile()
        {
            _bLoading = true;
            try
            {
                if (_scintilla == null)
                {
                    ScintillaTextEditorFactory factory = new ScintillaTextEditorFactory();
                    _scintilla = factory.Create(new RDMPCombineableFactory());
                    groupBox1.Controls.Add(_scintilla);
                    _scintilla.SavePointLeft      += ScintillaOnSavePointLeft;
                    ObjectSaverButton1.BeforeSave += objectSaverButton1_BeforeSave;
                }

                SetupAutocomplete();

                try
                {
                    _scintilla.Text = File.ReadAllText(_processTask.Path);
                    _scintilla.SetSavePoint();
                }
                catch (Exception e)
                {
                    CommonFunctionality.Fatal("Could not open file " + _processTask.Path, e);
                }
            }
            finally
            {
                _bLoading = false;
            }
        }
        private void GenerateQuery()
        {
            QueryEditor.ReadOnly = false;
            CommonFunctionality.ResetChecks();

            try
            {
                var cic     = (CohortIdentificationConfiguration)DatabaseObject;
                var builder = new CohortQueryBuilder(cic, null);

                if (!btnUseCache.Checked && cic.QueryCachingServer_ID.HasValue)
                {
                    builder.CacheServer = null;
                }

                QueryEditor.Text = builder.SQL;
                CommonFunctionality.ScintillaGoRed(QueryEditor, false);
            }
            catch (Exception ex)
            {
                QueryEditor.Text = "Could not build Sql:" + ex.Message;
                CommonFunctionality.ScintillaGoRed(QueryEditor, true);
                CommonFunctionality.Fatal("Failed to build query", ex);
            }


            QueryEditor.ReadOnly = true;
        }
Exemplo n.º 3
0
        public override void SetDatabaseObject(IActivateItems activator, Lookup databaseObject)
        {
            base.SetDatabaseObject(activator, databaseObject);

            _keyColumn         = databaseObject.PrimaryKey;
            _descriptionColumn = databaseObject.Description;
            _tableInfo         = _keyColumn.TableInfo;

            lblCode.Text        = _keyColumn.GetRuntimeName();
            lblDescription.Text = _descriptionColumn.GetRuntimeName();

            ScintillaTextEditorFactory factory = new ScintillaTextEditorFactory();

            _scintilla = factory.Create();

            gbScintilla.Controls.Add(_scintilla);

            try
            {
                SendQuery();
            }
            catch (System.Exception ex)
            {
                CommonFunctionality.Fatal("Could not connect to database", ex);
            }
        }
Exemplo n.º 4
0
        private void DiscoverStates()
        {
            if (tlvLoadedTables.Objects == null || !tlvLoadedTables.Objects.Cast <Object>().Any())
            {
                CommonFunctionality.Fatal("There are no tables loaded by the load", null);
            }


            //update the states of the objects (do UI code happens here)
            foreach (LoadDiagramServerNode root in tlvLoadedTables.Objects)
            {
                root.DiscoverState();
            }
        }
        public override void SetDatabaseObject(IActivateItems activator, Catalogue databaseObject)
        {
            base.SetDatabaseObject(activator, databaseObject);

            serverDatabaseTableSelector1.SetItemActivator(activator);
            try
            {
                _planManager = new ForwardEngineerANOCataloguePlanManager(activator.RepositoryLocator, databaseObject);
            }
            catch (QueryBuildingException e)
            {
                CommonFunctionality.Fatal("Could not generate a valid query for the Catalogue", e);
                return;
            }

            if (!_setup)
            {
                var settings = new RDMPCollectionCommonFunctionalitySettings {
                    AddFavouriteColumn = false, AllowPinning = false, AddCheckColumn = false
                };

                //Set up tree view to show ANO Tables that are usable
                tlvANOTablesCommonFunctionality = new RDMPCollectionCommonFunctionality();
                tlvANOTablesCommonFunctionality.SetUp(RDMPCollection.None, tlvANOTables, activator, olvANOTablesName, null, settings);

                tlvANOTables.AddObject(activator.CoreChildProvider.AllANOTablesNode);
                tlvANOTables.ExpandAll();

                //Setup tree view to show all TableInfos that you are trying to Migrate
                tlvTableInfoMigrationsCommonFunctionality = new RDMPCollectionCommonFunctionality();
                tlvTableInfoMigrationsCommonFunctionality.SetUp(RDMPCollection.None, tlvTableInfoMigrations, activator, olvTableInfoName, null, settings);

                //don't display anything below ColumnInfo
                tlvTableInfoMigrationsCommonFunctionality.AxeChildren = new[] { typeof(ColumnInfo) };

                _setup = true;
            }

            //Add them and expand them
            tlvTableInfoMigrations.ClearObjects();
            tlvTableInfoMigrations.AddObjects(_planManager.TableInfos);
            tlvTableInfoMigrations.ExpandAll();

            ddDateColumn.DataSource = _planManager.TableInfos.SelectMany(t => t.ColumnInfos).Where(c => c.Data_type != null && c.Data_type.Contains("date")).ToArray();

            Check();
        }
Exemplo n.º 6
0
        public void RefreshUIFromDatabase()
        {
            tlvLoadedTables.ClearObjects();

            if (_loadMetadata == null)
            {
                return;
            }

            TableInfo[] allTables;
            HICDatabaseConfiguration config;

            try
            {
                if (!_loadMetadata.GetAllCatalogues().Any())
                {
                    throw new Exception("There are no Catalogues (Datasets) associated with this LoadMetadata, choose one or more Catalogues by clicking 'Edit..' in LoadMetadataUI ");
                }

                allTables = _loadMetadata.GetDistinctTableInfoList(true).ToArray();
                config    = new HICDatabaseConfiguration(_loadMetadata);
            }
            catch (Exception e)
            {
                CommonFunctionality.Fatal("Could not fetch data", e);
                tlvLoadedTables.Visible = false;
                return;
            }
            tlvLoadedTables.Visible = true;

            _raw = new LoadDiagramServerNode(LoadBubble.Raw, config.DeployInfo[LoadBubble.Raw], allTables, config);
            var staging = new LoadDiagramServerNode(LoadBubble.Staging, config.DeployInfo[LoadBubble.Staging], allTables, config);
            var live    = new LoadDiagramServerNode(LoadBubble.Live, config.DeployInfo[LoadBubble.Live], allTables, config);

            tlvLoadedTables.AddObject(_raw);
            tlvLoadedTables.AddObject(staging);
            tlvLoadedTables.AddObject(live);

            //expand the servers
            foreach (var rootObject in tlvLoadedTables.Objects)
            {
                ExpandToDepth(2, rootObject);
            }

            loadStateUI1.SetStatus(LoadStateUI.LoadState.Unknown);
        }
Exemplo n.º 7
0
        public void GenerateChart()
        {
            CommonFunctionality.ResetChecks();

            var allCatalogues = _collection.GetCatalogues();

            Dictionary <Catalogue, Dictionary <DateTime, ArchivalPeriodicityCount> > cataloguesToAdd = new Dictionary <Catalogue, Dictionary <DateTime, ArchivalPeriodicityCount> >();

            DQERepository dqeRepository;

            try
            {
                dqeRepository = new DQERepository(_activator.RepositoryLocator.CatalogueRepository);
            }
            catch (NotSupportedException e)
            {
                CommonFunctionality.Fatal("Failed to get DQE Repository", e);
                return;
            }

            foreach (var cata in allCatalogues.OrderBy(c => c.Name))
            {
                var eval = dqeRepository.GetMostRecentEvaluationFor(cata);

                Dictionary <DateTime, ArchivalPeriodicityCount> dictionary = null;

                if (eval != null)
                {
                    dictionary = PeriodicityState.GetPeriodicityCountsForEvaluation(eval);
                }

                cataloguesToAdd.Add(cata, dictionary);
            }

            //every month seen in every dataset ever
            var buckets = GetBuckets(cataloguesToAdd);

            racewayRenderArea.AddTracks(_activator, cataloguesToAdd, buckets, _collection.IgnoreRows);
            racewayRenderArea.Refresh();

            this.Invalidate();
        }
Exemplo n.º 8
0
        private void UpdateStatesUI(Task task)
        {
            try
            {
                if (task.Exception != null)
                {
                    throw task.Exception;
                }

                foreach (LoadDiagramServerNode root in tlvLoadedTables.Objects)
                {
                    tlvLoadedTables.RefreshObject(root);
                }

                //if RAW is not found then the load has tidied up and is completed / not started
                if (_raw.Children.All(n => n.State == LoadDiagramState.NotFound))
                {
                    loadStateUI1.SetStatus(LoadStateUI.LoadState.NotStarted);
                }
                else if (_raw.Children.All(n => n.State == LoadDiagramState.Anticipated))
                {
                    //we have not checked the state yet
                    loadStateUI1.SetStatus(LoadStateUI.LoadState.Unknown);
                }
                else
                {
                    loadStateUI1.SetStatus(LoadStateUI.LoadState.StartedOrCrashed);
                }
                //it exists or is different etc... basically if RAW exists then a load is underway or crashed
            }
            catch (Exception exception)
            {
                CommonFunctionality.Fatal("Failed to fetch status of load tables", exception);
            }
            finally
            {
                pbLoading.Visible     = false;
                _btnFetchData.Enabled = true;
            }
        }
Exemplo n.º 9
0
        private void RefreshUIFromDatabase()
        {
            CommonFunctionality.ResetChecks();

            try
            {
                if (bLoading)
                {
                    return;
                }

                //only allow reordering when all are visible or only internal are visible otherwise user could select core only and do a reorder leaving supplemental columns as freaky orphans all down at the bottom fo the SQL!
                bLoading = true;

                List <ExtractionInformation> extractionInformations = GetSelectedExtractionInformations();

                //add the available filters
                SetupAvailableFilters(extractionInformations);

                //generate SQL -- only make it readonly after setting the .Text otherwise it ignores the .Text setting even though it is programatical
                QueryPreview.ReadOnly = false;


                var collection = GetCollection(extractionInformations);

                QueryPreview.Text = collection.GetSql();
                CommonFunctionality.ScintillaGoRed(QueryPreview, false);
                QueryPreview.ReadOnly = true;
            }
            catch (Exception ex)
            {
                CommonFunctionality.ScintillaGoRed(QueryPreview, ex);
                CommonFunctionality.Fatal(ex.Message, ex);
            }
            finally
            {
                bLoading = false;
            }
        }
Exemplo n.º 10
0
        void _populateLoadHistory_DoWork(object sender, DoWorkEventArgs e)
        {
            ArchivalDataLoadInfo[] results;
            try
            {
                try
                {
                    _logManager = new LogManager(Collection.RootObject.GetDistinctLoggingDatabase());
                    var unfilteredResults = _logManager.GetArchivalDataLoadInfos(Collection.RootObject.GetDistinctLoggingTask(), _populateLoadHistoryCancel.Token, null, _toFetch);
                    results = Collection.RootObject.FilterRuns(unfilteredResults).ToArray();
                }
                catch (OperationCanceledException)//user cancels
                {
                    results = new ArchivalDataLoadInfo[0];
                }

                _populateLoadHistoryResults = results;
            }
            catch (Exception exception)
            {
                CommonFunctionality.Fatal("Failed to popualte load history", exception);
            }
        }
Exemplo n.º 11
0
        private void SetEnabledness()
        {
            DiscoveredTable pushedTable;

            try
            {
                pushedTable = _anoTable.GetPushedTable();
            }
            catch (Exception e)
            {
                CommonFunctionality.Fatal("Could not reach ANO Server", e);
                return;
            }

            bool isPushed = pushedTable != null;

            nIntegers.Enabled       = !isPushed;
            nCharacters.Enabled     = !isPushed;
            btnFinalise.Enabled     = !isPushed;
            tbInputDataType.Enabled = !isPushed;

            btnDropANOTable.Enabled = isPushed;
            gbPushedTable.Visible   = isPushed;

            if (isPushed)
            {
                tbInputDataType.Text = _anoTable.GetRuntimeDataType(LoadStage.AdjustRaw);

                lblANOTableName.Text = pushedTable.GetRuntimeName();
                var cols = pushedTable.DiscoverColumns();

                lblPrivate.Text = cols[0].GetRuntimeName() + " " + cols[0].DataType.SQLType;
                lblPublic.Text  = cols[1].GetRuntimeName() + " " + cols[1].DataType.SQLType;

                lblRowCount.Text = pushedTable.GetRowCount() + " rows";
            }
        }
Exemplo n.º 12
0
        private void RefreshUIFromDatabase()
        {
            CommonFunctionality.ResetChecks();

            try
            {
                if (bLoading)
                {
                    return;
                }

                //only allow reordering when all are visible or only internal are visible otherwise user could select core only and do a reorder leaving supplemental columns as freaky orphans all down at the bottom fo the SQL!
                bLoading = true;

                List <ExtractionInformation> extractionInformations = new List <ExtractionInformation>();

                if (rbInternal.Checked)
                {
                    extractionInformations.AddRange(_catalogue.GetAllExtractionInformation(ExtractionCategory.Internal));
                }
                else
                {
                    //always add the project specific ones
                    extractionInformations.AddRange(_catalogue.GetAllExtractionInformation(ExtractionCategory.ProjectSpecific));
                    extractionInformations.AddRange(_catalogue.GetAllExtractionInformation(ExtractionCategory.Core));

                    if (rbSupplemental.Checked || rbSpecialApproval.Checked)
                    {
                        extractionInformations.AddRange(_catalogue.GetAllExtractionInformation(ExtractionCategory.Supplemental));
                    }

                    if (rbSpecialApproval.Checked)
                    {
                        extractionInformations.AddRange(_catalogue.GetAllExtractionInformation(ExtractionCategory.SpecialApprovalRequired));
                    }
                }

                //sort by Default Order
                extractionInformations.Sort();

                //add to listbox
                olvExtractionInformations.ClearObjects();
                olvExtractionInformations.AddObjects(extractionInformations.ToArray());

                //add the available filters
                var filters = extractionInformations.SelectMany(ei => ei.ExtractionFilters).ToArray();

                //remove deleted ones
                if (olvFilters.Objects != null)
                {
                    foreach (ExtractionFilter f in olvFilters.Objects.Cast <ExtractionFilter>().Except(filters).ToArray())
                    {
                        olvFilters.RemoveObject(f);
                    }
                }

                //add new ones
                foreach (ExtractionFilter f in filters)
                {
                    if (olvFilters.IndexOf(f) == -1)
                    {
                        olvFilters.AddObject(f);
                    }
                }

                //generate SQL -- only make it readonly after setting the .Text otherwise it ignores the .Text setting even though it is programatical
                QueryPreview.ReadOnly = false;
                QueryPreview.Text     = GenerateExtractionSQLForCatalogue(extractionInformations.ToArray());
                CommonFunctionality.ScintillaGoRed(QueryPreview, false);
                QueryPreview.ReadOnly = true;
            }
            catch (Exception ex)
            {
                CommonFunctionality.ScintillaGoRed(QueryPreview, ex);
                CommonFunctionality.Fatal(ex.Message, ex);
            }
            finally
            {
                bLoading = false;
            }
        }