Ejemplo n.º 1
0
        /// <summary>
        /// Get container
        /// </summary>
        public IContainer GetContainer(MARC.HI.EHRS.SVC.Core.DataTypes.VersionedDomainIdentifier containerId, bool loadFast)
        {
            // Get the persister that will handle the HealthServiceRecord type

            var persister = m_persisters.Values.FirstOrDefault(o => o is IQueryComponentPersister && (o as IQueryComponentPersister).ComponentTypeOid == containerId.Domain);

            if (persister == null)
            {
                persister = GetPersister(typeof(RegistrationEvent));
            }

            ISystemConfigurationService configService = Context.GetService(typeof(ISystemConfigurationService)) as ISystemConfigurationService;

            DbUtil.ClearPersistedCache();

            if (persister != null)
            {
                IDbConnection conn = null;
                try
                {
                    conn = DatabasePersistenceService.ReadOnlyConnectionManager.GetConnection();

                    // Is the record something that we have access to?
                    //if (containerId.Domain != null && !containerId.Domain.Equals(configService.OidRegistrar.GetOid(ClientRegistryOids.REGISTRATION_EVENT).Oid))
                    //    throw new ArgumentException(String.Format("The record OID '{0}' cannot be retrieved by this repository, expecting OID '{1}'",
                    //        containerId.Domain, configService.OidRegistrar.GetOid(ClientRegistryOids.REGISTRATION_EVENT).Oid));
                    if (persister == null)
                    {
                        throw new ArgumentException(String.Format("The record type OID '{0}' cannot be retrieved by this repository",
                                                                  containerId.Domain));
                    }
                    decimal tryDec = default(decimal);

                    if (Decimal.TryParse(containerId.Identifier, out tryDec))
                    {
                        return(persister.DePersist(conn, tryDec, null, null, loadFast) as IContainer);
                    }
                    else
                    {
                        throw new ArgumentException(String.Format("The identifier '{0}' is not a valid identifier for this repository", containerId.Identifier));
                    }
                }
                finally
                {
                    if (conn != null)
                    {
                        DatabasePersistenceService.ConnectionManager.ReleaseConnection(conn);
                    }
                }
            }
            else
            {
                Trace.TraceError("Can't find a persistence handler for type '{0}'", containerId.Domain);
                throw new DataException("Can't persist type HealthServiceRecordEvent");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create an instance identifier set
        /// </summary>
        /// <param name="versionedDomainIdentifier"></param>
        /// <returns></returns>
        public SET <II> CreateIISet(MARC.HI.EHRS.SVC.Core.DataTypes.VersionedDomainIdentifier id)
        {
            SET <II> retVal = new SET <II>(2, II.Comparator);

            retVal.Add(new II(id.Domain, id.Identifier)
            {
                Scope = IdentifierScope.BusinessIdentifier
            });
            retVal.Add(new II(id.Domain, id.Version)
            {
                Scope = IdentifierScope.VersionIdentifier
            });
            return(retVal);
        }