예제 #1
0
 public IRequestMeta Set(HttpRequestMessage Request)
 {
     this.PyroRequestUri = IPyroRequestUriFactory.CreateFhirRequestUri();
     this.PyroRequestUri.FhirRequestUri.Parse(Request.RequestUri.OriginalString);
     this.RequestHeader          = IRequestHeaderFactory.CreateRequestHeader().Parse(Request.Headers);
     this.SearchParameterGeneric = ISearchParameterGenericFactory.CreateDtoSearchParameterGeneric().Parse(Request.GetSearchParams());
     return(this);
 }
예제 #2
0
        public bool UpdateTaskAsStatus(Task.TaskStatus TaskStatus, Task Task)
        {
            try
            {
                //Set the task status only if it has not been updated since we got it from the server, using the IfMatch hearder and the VersionId
                var RequestMeta = IRequestMetaFactory.CreateRequestMeta().Set($"{Task.ResourceType.GetLiteral()}/{Task.Id}");
                RequestMeta.RequestHeader         = IRequestHeaderFactory.CreateRequestHeader();
                RequestMeta.RequestHeader.IfMatch = Common.Tools.HttpHeaderSupport.GetETagString(Task.VersionId);

                //Update the Task Properties
                Task.Status = TaskStatus;
                Task.LastModifiedElement = new FhirDateTime(DateTimeOffset.Now);

                this.IResourceTriggerService.TriggersActive = false;
                IResourceServiceOutcome PutResourceServiceOutcome = IResourceServices.Put(Task.Id, Task, RequestMeta);
                this.IResourceTriggerService.TriggersActive = true;
                if (PutResourceServiceOutcome.HttpStatusCode == System.Net.HttpStatusCode.OK)
                {
                    Task = PutResourceServiceOutcome.ResourceResult as Task;
                    return(true);
                }
                else if (PutResourceServiceOutcome.HttpStatusCode == System.Net.HttpStatusCode.Conflict)
                {
                    ILog.Error($"Internal Server Error: UpdateTaskAsStatus failed due to Version Conflict, Task reference was: {Task.ResourceType.GetLiteral()}/{Task.Id}/_history/{Task.VersionId}.");
                    return(true);
                }
                else if (PutResourceServiceOutcome.HttpStatusCode == System.Net.HttpStatusCode.Created)
                {
                    ILog.Error($"Internal Server Error: UpdateTaskAsStatus failed due to 201 Create being returned when OK Update was expected, Transaction was rolled back. Task reference was: {Task.ResourceType.GetLiteral()}/{Task.Id}");
                    return(false);
                }
                else
                {
                    ILog.Error($"Internal Server Error: UpdateTaskAsStatus failed due to unexpected HTTP status code return, code was {PutResourceServiceOutcome.HttpStatusCode.ToString()}. Task reference was: {Task.ResourceType.GetLiteral()}/{Task.Id}/_history/{Task.VersionId}");
                    return(false);
                }
            }
            catch (Exception Exec)
            {
                ILog.Error(Exec, $"ResourceSeeding on Startup, PUT operations failed with exception. Task reference was: {Task.ResourceType.GetLiteral()}/{Task.Id}/_history/{Task.VersionId}");
                return(false);
            }
        }