コード例 #1
0
ファイル: FhirService.cs プロジェクト: HowardEdidin/spark
        public ResourceEntry Conformance()
        {
            var conformance = ConformanceBuilder.Build();
            var re          = new ResourceEntry <Conformance>(new Uri("urn:guid:" + Guid.NewGuid()), DateTimeOffset.Now, conformance);

            return(re);


            //Uri location =
            //     ResourceIdentity.Build(
            //        ConformanceBuilder.CONFORMANCE_COLLECTION_NAME,
            //        ConformanceBuilder.CONFORMANCE_ID
            //    ).OperationPath;

            //BundleEntry conformance = _store.FindEntryById(location);

            //if (conformance == null || !(conformance is ResourceEntry))
            //{
            //    throw new SparkException(
            //        HttpStatusCode.InternalServerError,
            //        "Cannot find an installed conformance statement for this server. Has it been initialized?");
            //}
            //else
            //    return (ResourceEntry)conformance;
        }
コード例 #2
0
        /// <summary>
        /// Reinitializes the (database of) the server to its initial state
        /// </summary>
        /// <returns></returns>
        /// <remarks>Quite a destructive operation, mostly useful in debugging situations</remarks>
        public OperationOutcome Initialize()
        {
            //Note: also clears the counters collection, so id generation starts anew and
            //clears all stored binaries at Amazon S3.
            Stopwatch w = new Stopwatch();

            w.Start();
            _store.Clean();
            //_store.EraseData();
            //_store.EnsureIndices();

            _index.Clean();

            w.Stop();
            long cleaning = w.ElapsedMilliseconds;

            //Insert our own conformance statement into Conformance collection

            ResourceEntry conformanceentry = ResourceEntry.Create(ConformanceBuilder.Build());

            _service.Create(ConformanceBuilder.CONFORMANCE_COLLECTION_NAME, conformanceentry, ConformanceBuilder.CONFORMANCE_ID);

            //Insert standard examples
            w.Restart();
            var examples = loadExamples();


            var count = examples.Entries.OfType <Condition>().Count();

            w.Stop();
            long loadex = w.ElapsedMilliseconds;

            w.Restart();
            _service.Transaction(examples);
            w.Stop();
            var batch = w.ElapsedMilliseconds;


            //Start numbering new resources at an id higher than the examples (we hope)
            //EK: I like the convention of examples having id <10000, and new records >10.000, so please retain
            _store.EnsureNextSequenceNumberHigherThan(9999);


            string message = String.Format("Database was succesfully re-initialized: cleaning {0}, examples {1}, storage {2} ms", cleaning, loadex, batch);

            return(new OperationOutcome().Message(message));
        }
コード例 #3
0
ファイル: FhirMaintainance.cs プロジェクト: schellack/spark
        /// <summary>
        /// Reinitializes the (database of) the server to its initial state
        /// </summary>
        /// <returns></returns>
        /// <remarks>Quite a destructive operation, mostly useful in debugging situations</remarks>

        public string Initialize(bool extract)
        {
            //Note: also clears the counters collection, so id generation starts anew and
            //clears all stored binaries at Amazon S3.
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            store.Clean();
            index.Clean();
            stopwatch.Stop();
            double time_cleaning = stopwatch.Elapsed.Seconds;

            //Insert our own conformance statement into Conformance collection

            ResourceEntry conformanceentry = ResourceEntry.Create(ConformanceBuilder.Build());

            service.Upsert(conformanceentry, ConformanceBuilder.CONFORMANCE_COLLECTION_NAME, ConformanceBuilder.CONFORMANCE_ID);

            //Insert standard examples
            stopwatch.Restart();
            var examples = loadExamples(extract);

            stopwatch.Stop();
            double time_loading = stopwatch.Elapsed.Seconds;

            stopwatch.Restart();
            service.Transaction(examples);
            stopwatch.Stop();
            double time_storing = stopwatch.Elapsed.Seconds;

            //Start numbering new resources at an id higher than the examples (we hope)
            //EK: I like the convention of examples having id <10000, and new records >10.000, so please retain
            //_store.EnsureNextSequenceNumberHigherThan(9999);

            string message = String.Format(
                "Database was succesfully re-initialized. \nTime spent:" +
                "\nCleaning: {0}sec \nLoading examples: {1}sec, \nStoring: {2}sec",
                time_cleaning, time_loading, time_storing);

            return(message);
        }