コード例 #1
0
        /// <summary>
        /// Starts 1 async fetch request for each cohort endpoint e.g. NormalCohorts ExternalCohortTable database contains 100 cohorts while FreakyCohorts ExternalCohortTable database
        /// has another 30.
        ///
        /// <para>These async requests are managed by the CohortDescriptionDataTableAsyncFetch object which has a callback for compeltion.  Each ExtractableCohortDescription subscribes to
        /// the callback to self populate</para>
        /// </summary>
        /// <returns></returns>
        public Dictionary <CohortDescriptionDataTableAsyncFetch, ExtractableCohortDescription[]> Create()
        {
            var toReturn = new Dictionary <CohortDescriptionDataTableAsyncFetch, ExtractableCohortDescription[]>();

            foreach (ExternalCohortTable source in _sources)
            {
                //setup the async data retreival which can take a long time if there are a lot of cohorts or millions of identifiers
                var asyncFetch = new CohortDescriptionDataTableAsyncFetch(source);
                var cohorts    = _cohorts.Where(c => c.ExternalCohortTable_ID == source.ID).Select(c => new ExtractableCohortDescription(c, asyncFetch)).ToArray();

                asyncFetch.Begin();

                toReturn.Add(asyncFetch, cohorts);
            }

            return(toReturn);
        }
コード例 #2
0
        /// <summary>
        /// Creates a new description based on the async fetch request for all cohorts including row counts etc (which might have already completed btw).  If you
        /// use this constructor then the properties will start out with text like "Loading..." but it will perform much faster, when the fetch completes the
        /// values will be populated.  In general if you want to use this feature you should probably use CohortDescriptionFactory and only use it if you are
        /// trying to get all the cohorts at once.
        ///
        /// </summary>
        /// <param name="cohort"></param>
        /// <param name="fetch"></param>
        public ExtractableCohortDescription(ExtractableCohort cohort, CohortDescriptionDataTableAsyncFetch fetch)
        {
            Cohort        = cohort;
            Fetch         = fetch;
            OriginID      = cohort.OriginID;
            Count         = -1;
            CountDistinct = -1;
            SourceName    = fetch.Source.Name;

            try
            {
                ReleaseIdentifier = cohort.GetReleaseIdentifier(true);
            }
            catch (Exception)
            {
                ReleaseIdentifier = "Unknown";
            }

            try
            {
                PrivateIdentifier = cohort.GetPrivateIdentifier(true);
            }
            catch (Exception)
            {
                PrivateIdentifier = "Unknown";
            }

            ProjectNumber = -1;
            Version       = -1;
            Description   = "Loading...";

            //if it's already finished
            if (fetch.Task != null && fetch.Task.IsCompleted)
            {
                FetchOnFinished();
            }
            else
            {
                fetch.Finished += FetchOnFinished;
            }
        }