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;
        }
Exemple #2
0
        private void btnFetch_Click(object sender, EventArgs e)
        {
            //execution is already underway
            if (taskDiscoverState != null && !taskDiscoverState.IsCompleted)
            {
                return;
            }

            CommonFunctionality.ResetChecks();
            _btnFetchData.Enabled = false;
            pbLoading.Visible     = true;
            taskDiscoverState     = Task.Run(() => DiscoverStates()).ContinueWith(UpdateStatesUI, TaskScheduler.FromCurrentSynchronizationContext());
        }
Exemple #3
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();
        }
        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;
            }
        }
Exemple #5
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;
            }
        }