public IResourceServiceOutcome OperationPostBaseWithParameters(string BaseRequestUri, HttpRequestMessage Request, string operation, Resource Resource) { using (DbContextTransaction Transaction = IUnitOfWork.BeginTransaction()) { try { IRequestServiceRootValidate.Validate(BaseRequestUri); IRequestMeta RequestMeta = IRequestMetaFactory.CreateRequestMeta().Set(Request); IFhirBaseOperationService FhirBaseOperationService = IFhirBaseOperationServiceFactory.CreateFhirBaseOperationService(); IResourceServiceOutcome ResourceServiceOutcome = FhirBaseOperationService.Process(operation, Resource, RequestMeta); ResourceServiceOutcome.SummaryType = RequestMeta.SearchParameterGeneric.SummaryType; if (ResourceServiceOutcome.SuccessfulTransaction) { Transaction.Commit(); } else { Transaction.Rollback(); } return(ResourceServiceOutcome); } catch (Exception Exec) { Transaction.Rollback(); ILog.Error(Exec, $"PyroService.BaseOperationWithParameters, Request: {Request.RequestUri.OriginalString}"); throw new PyroException(System.Net.HttpStatusCode.InternalServerError, Common.Tools.FhirOperationOutcomeSupport.Create(OperationOutcome.IssueSeverity.Error, OperationOutcome.IssueType.Exception, Exec.Message), Exec.Message); } } }
private bool SetSearchParameterServerIndex(string Id) { string ResourceName = ResourceType.SearchParameter.GetLiteral(); Parameters Parameters = new Parameters(); Parameters.Parameter = new List <Parameters.ParameterComponent>(); var ParameterComponent = new Parameters.ParameterComponent(); Parameters.Parameter.Add(ParameterComponent); ParameterComponent.Name = $"{ResourceName}"; var Ref = new ResourceReference(); IRequestMeta RequestMetaTemp = IRequestMetaFactory.CreateRequestMeta().Set($"{ResourceName}/{Id}"); Ref.Reference = $"{RequestMetaTemp.PyroRequestUri.FhirRequestUri.OriginalString}"; ParameterComponent.Value = Ref; string OperationName = FhirOperationEnum.OperationType.ServerIndexesSet.GetPyroLiteral(); IRequestMeta RequestMeta = IRequestMetaFactory.CreateRequestMeta().Set(""); try { IFhirBaseOperationService FhirBaseOperationService = IFhirBaseOperationServiceFactory.CreateFhirBaseOperationService(); IResourceServiceOutcome ResourceServiceOutcome = IServerSearchParameterOperation.ProcessSet(RequestMeta.PyroRequestUri, RequestMeta.SearchParameterGeneric, Parameters, true); if (ResourceServiceOutcome.HttpStatusCode == System.Net.HttpStatusCode.OK) { return(true); } else { string OperationOutcomeMessage = string.Empty; if (ResourceServiceOutcome.ResourceResult != null && ResourceServiceOutcome.ResourceResult is OperationOutcome OptOut) { OptOut.Issue.ForEach(x => OperationOutcomeMessage = OperationOutcomeMessage + " " + x.Details.Text); string Message = $"Internal Server Error: Failed to Set SearchParameter Server index calling operation ${OperationName} with the SearchParmeter Resource {RequestMetaTemp.PyroRequestUri.FhirRequestUri.OriginalString} with extra detail: {OperationOutcomeMessage}"; ILog.Error(Message); throw new Exception(Message); } else { string Message = $"Internal Server Error: Failed to Set SearchParameter Server index calling operation ${OperationName} with the SearchParmeter Resource {RequestMetaTemp.PyroRequestUri.FhirRequestUri.OriginalString}"; ILog.Error(Message); throw new Exception(Message); } } } catch (Exception Exec) { string Message = $"{Exec.Message}, Internal Server Error: Failed to Set SearchParameter Server index calling operation ${OperationName}"; ILog.Error(Exec, Message); throw new Exception(Message); } }