示例#1
0
        public void ClearAll(Guid access)
        {
            string code = ConfigurationManager.AppSettings.Get("clearAllCode");

            if (!string.IsNullOrEmpty(code) && access.ToString() == code)
            {
                fhirStoreAdministration.Clean();
                fhirIndex.Clean();
            }
        }
示例#2
0
        public void LoadData()
        {
            var messages = new StringBuilder();

            messages.AppendLine("Import completed!");
            try
            {
                //cleans store and index
                Progress("Clearing the database...", 0);
                fhirStoreAdministration.Clean();
                fhirIndex.Clean();

                Progress("Loading examples data...", 5);
                this.resources = GetExampleData();

                var resarray = resources.ToArray();
                ResourceCount = resarray.Count();

                for (int x = 0; x <= ResourceCount - 1; x++)
                {
                    var res = resarray[x];
                    // Sending message:
                    var msg = Message("Importing " + res.ResourceType.ToString() + " " + res.Id + "...", x);
                    Clients.Caller.sendMessage(msg);

                    try
                    {
                        //Thread.Sleep(1000);
                        Key key = res.ExtractKey();

                        if (res.Id != null && res.Id != "")
                        {
                            fhirService.Put(key, res);
                        }
                        else
                        {
                            fhirService.Create(key, res);
                        }
                    }
                    catch (Exception e)
                    {
                        // Sending message:
                        var msgError = Message("ERROR Importing " + res.ResourceType.ToString() + " " + res.Id + "... ", x);
                        Clients.Caller.sendMessage(msg);
                        messages.AppendLine(msgError.Message + ": " + e.Message);
                    }
                }

                Progress(messages.ToString(), 100);
            }
            catch (Exception e)
            {
                Progress("Error: " + e.Message);
            }
        }
示例#3
0
        public async void ClearStore()
        {
            var notifier = new HubContextProgressNotifier(_hubContext, _logger);

            try
            {
                await notifier.SendProgressUpdate("Clearing the database...", 0);

                _fhirStoreAdministration.Clean();
                _fhirIndex.Clean();
                await notifier.SendProgressUpdate("Database cleared", 100);
            }
            catch (Exception e)
            {
                await notifier.SendProgressUpdate("ERROR CLEARING :( " + e.InnerException, 100);
            }
        }
示例#4
0
        public async void ClearStore()
        {
            try
            {
                await _hubContext.Clients.All.SendAsync("UpdateProgress", "Starting clearing database...").ConfigureAwait(false);

                await _fhirStoreAdministration.Clean().ConfigureAwait(false);

                await _hubContext.Clients.All.SendAsync("UpdateProgress", "... and cleaning indexes...").ConfigureAwait(false);

                await _fhirIndex.Clean().ConfigureAwait(false);

                await _hubContext.Clients.All.SendAsync("UpdateProgress", "Database cleared").ConfigureAwait(false);
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Failed to clear store.");
                await _hubContext.Clients.All.SendAsync("UpdateProgress", $"ERROR CLEARING :(").ConfigureAwait(false);
            }
        }