/// <summary>
        /// Gets a specified model.
        /// </summary>
        /// <typeparam name="TModel">The type of model data to retrieve.</typeparam>
        /// <param name="key">The key of the model.</param>
        /// <param name="versionKey">The version key of the model.</param>
        /// <param name="options">The integrations query options.</param>
        /// <returns>Returns a model.</returns>
        public TModel Get <TModel>(Guid key, Guid?versionKey, IntegrationQueryOptions options = null) where TModel : IdentifiedData
        {
            try
            {
                HdsiServiceClient client = this.GetServiceClient(); //new HdsiServiceClient(ApplicationContext.Current.GetRestClient("hdsi"));
                client.Client.Requesting += IntegrationQueryOptions.CreateRequestingHandler(options);
                client.Client.Responding += (o, e) => this.Responding?.Invoke(o, e);
                client.Client.Credentials = this.GetCredentials(client.Client);
                if (client.Client.Credentials == null)
                {
                    return(null);
                }

                this.m_tracer.TraceVerbose("Performing HDSI GET ({0}):{1}v{2}", typeof(TModel).FullName, key, versionKey);
                var retVal = client.Get <TModel>(key, versionKey);

                if (retVal is Bundle)
                {
                    (retVal as Bundle)?.Reconstitute();
                    retVal = (retVal as Bundle).GetFocalObject();
                }

                var integrationEvent = new IntegrationResultEventArgs(null, retVal);
                this.Responded?.Invoke(this, integrationEvent);
                return(integrationEvent.ResponseData as TModel);
            }
            catch (TargetInvocationException e)
            {
                throw Activator.CreateInstance(e.InnerException.GetType(), "Error performing action", e) as Exception;
            }
        }
示例#2
0
 /// <summary>
 /// Clinical data repository has responded
 /// </summary>
 private void ClinicalRepositoryResponded(object sender, IntegrationResultEventArgs e)
 {
     if (e.ResponseData is Bundle bundle && e.SubmittedData != null && this.CorrectMdmData(bundle))
     {
         // Update the data
         ApplicationServiceContext.Current.GetService <IDataPersistenceService <Bundle> >().Insert(bundle, TransactionMode.Commit, AuthenticationContext.SystemPrincipal);
     }