/// <summary> /// Data policy filter service with DI /// </summary> public DataPolicyFilterService(IConfigurationManager configurationManager, IPasswordHashingService passwordService, IPolicyDecisionService pdpService, IThreadPoolService threadPoolService, IDataCachingService dataCachingService, ISubscriptionExecutor subscriptionExecutor = null, IAdhocCacheService adhocCache = null) { this.m_hasher = passwordService; this.m_adhocCache = adhocCache; this.m_pdpService = pdpService; this.m_subscriptionExecutor = subscriptionExecutor; this.m_dataCachingService = dataCachingService; this.m_threadPool = threadPoolService; // Configuration load this.m_configuration = configurationManager.GetSection <DataPolicyFilterConfigurationSection>(); if (this.m_configuration == null) { this.m_tracer.TraceWarning("No data policy configuration exists. Setting all to HIDE"); this.m_configuration = new DataPolicyFilterConfigurationSection() { DefaultAction = ResourceDataPolicyActionType.Hide, Resources = new List <ResourceDataPolicyFilter>() }; } if (this.m_configuration.Resources != null) { foreach (var t in this.m_configuration.Resources) { if (typeof(Act).IsAssignableFrom(t.ResourceType.Type) || typeof(Entity).IsAssignableFrom(t.ResourceType.Type) || typeof(AssigningAuthority).IsAssignableFrom(t.ResourceType.Type)) { this.m_tracer.TraceInfo("Binding privacy action {0} to {1}", t.Action, t.ResourceType.Type); this.m_actions.TryAdd(t.ResourceType.Type, t); } } } }
public CurrenciesService( ILogger <CurrenciesService> logger, IExternalSourceClient externalApiClient, IDataCachingService dataCachingService) { _logger = logger; _externalApiClient = externalApiClient; _dataCachingService = dataCachingService; }
#pragma warning restore CS0067 /// <summary> /// Create new audit repository service /// </summary> public AdoAuditRepositoryService(IConfigurationManager configurationManager, IDataCachingService dataCachingService, IBiMetadataRepository biMetadataRepository, IConceptRepositoryService conceptRepository, IAdhocCacheService adhocCacheService = null) { this.m_configuration = configurationManager.GetSection <AdoAuditConfigurationSection>(); this.m_adhocCache = adhocCacheService; this.m_dataCachingService = dataCachingService; this.m_conceptRepository = conceptRepository; try { this.m_configuration.Provider.UpgradeSchema("SanteDB.Persistence.Audit.ADO"); ApplicationServiceContext.Current.Started += (o, e) => { using (AuthenticationContext.EnterSystemContext()) { // Add audits as a BI data source biMetadataRepository .Insert(new BiDataSourceDefinition() { IsSystemObject = true, ConnectionString = this.m_configuration.ReadonlyConnectionString, MetaData = new BiMetadata() { Version = typeof(AdoAuditRepositoryService).Assembly.GetName().Version.ToString(), Status = BiDefinitionStatus.Active, Demands = new List <string>() { PermissionPolicyIdentifiers.AccessAuditLog } }, Id = "org.santedb.bi.dataSource.audit", Name = "audit", ProviderType = typeof(OrmBiDataProvider) }); } }; this.m_mapper = new ModelMapper(typeof(AdoAuditRepositoryService).Assembly.GetManifestResourceStream("SanteDB.Persistence.Auditing.ADO.Data.Map.ModelMap.xml")); this.m_builder = new QueryBuilder(this.m_mapper, this.m_configuration.Provider); } catch (ModelMapValidationException e) { this.m_traceSource.TraceError("Error validing map: {0}", e.Message); foreach (var i in e.ValidationDetails) { this.m_traceSource.TraceError("{0}:{1} @ {2}", i.Level, i.Message, i.Location); } throw; } }
/// <summary> /// Creates a new instance of this pub-sub manager /// </summary> public AdoPubSubManager(IServiceManager serviceManager, IPolicyEnforcementService policyEnforcementService, IConfigurationManager configurationManager, ISecurityRepositoryService securityRepository, IDataCachingService cachingService) { this.m_cache = cachingService; this.m_configuration = configurationManager.GetSection <AdoPubSubConfigurationSection>(); this.m_policyEnforcementService = policyEnforcementService; this.m_securityRepository = securityRepository; this.m_serviceManager = serviceManager; this.m_configuration.Provider.UpgradeSchema("SanteDB.Persistence.PubSub.ADO"); }
/// <summary> /// Create injected service /// </summary> public MdmDataManagementService(IServiceManager serviceManager, IConfigurationManager configuration, IDataCachingService cachingService = null, IRecordMatchingConfigurationService matchConfigurationService = null, IRecordMatchingService matchingService = null, ISubscriptionExecutor subscriptionExecutor = null, SimDataManagementService simDataManagementService = null, IJobManagerService jobManagerService = null) { this.m_configuration = configuration.GetSection <ResourceManagementConfigurationSection>(); this.m_matchingService = matchingService; this.m_serviceManager = serviceManager; this.m_subscriptionExecutor = subscriptionExecutor; this.m_jobManager = jobManagerService; this.m_matchConfigurationService = matchConfigurationService; this.m_dataCachingService = cachingService; if (simDataManagementService != null) { throw new InvalidOperationException("Cannot run MDM and SIM in same mode"); } }
/// <summary> /// Creates a new instance with DI /// </summary> public ExemptablePolicyFilterService(IConfigurationManager configManager, IPasswordHashingService passwordService, IPolicyDecisionService pdpService, IThreadPoolService threadPoolService, IDataCachingService dataCachingService, IAdhocCacheService adhocCache = null, ISubscriptionExecutor subscriptionExecutor = null) : base(configManager, passwordService, pdpService, threadPoolService, dataCachingService, subscriptionExecutor, adhocCache) { }
/// <summary> /// Create new local tag persistence service /// </summary> public LocalTagPersistenceService(IDataCachingService cacheService = null) { this.m_cacheService = cacheService; }
/// <summary> /// Cache convert an act version /// </summary> protected override Act CacheConvert(DbIdentified dataInstance, LocalDataContext context) { if (dataInstance == null) { return(null); } DbAct dbAct = dataInstance as DbAct; Act retVal = null; IDataCachingService cache = ApplicationContext.Current.GetService <IDataCachingService>(); if (dbAct != null) { switch (new Guid(dbAct.ClassConceptUuid).ToString().ToUpper()) { case ControlAct: retVal = cache?.GetCacheItem <ControlAct>(dbAct.Key); break; case SubstanceAdministration: retVal = cache?.GetCacheItem <SubstanceAdministration>(dbAct.Key); break; case Observation: var dbObs = context.Connection.Table <DbObservation>().Where(o => o.Uuid == dbAct.Uuid).FirstOrDefault(); if (dbObs != null) { switch (dbObs.ValueType) { case "ST": retVal = cache?.GetCacheItem <TextObservation>(dbAct.Key); break; case "CD": retVal = cache?.GetCacheItem <CodedObservation>(dbAct.Key); break; case "PQ": retVal = cache?.GetCacheItem <QuantityObservation>(dbAct.Key); break; } } break; case Encounter: retVal = cache?.GetCacheItem <PatientEncounter>(dbAct.Key); break; case Condition: default: retVal = cache?.GetCacheItem <Act>(dbAct.Key); break; } } else if (dataInstance is DbControlAct) { retVal = cache?.GetCacheItem <ControlAct>(dataInstance.Key); } else if (dataInstance is DbSubstanceAdministration) { retVal = cache?.GetCacheItem <SubstanceAdministration>(dataInstance.Key); } else if (dataInstance is DbTextObservation) { retVal = cache?.GetCacheItem <TextObservation>(dataInstance.Key); } else if (dataInstance is DbCodedObservation) { retVal = cache?.GetCacheItem <CodedObservation>(dataInstance.Key); } else if (dataInstance is DbQuantityObservation) { retVal = cache?.GetCacheItem <QuantityObservation>(dataInstance.Key); } else if (dataInstance is DbPatientEncounter) { retVal = cache?.GetCacheItem <PatientEncounter>(dataInstance.Key); } // Return cache value if (retVal != null) { if (retVal.LoadState < context.DelayLoadMode) { retVal.LoadAssociations(context, // Exclude nameof(OpenIZ.Core.Model.Acts.Act.Extensions), nameof(OpenIZ.Core.Model.Acts.Act.Tags), nameof(OpenIZ.Core.Model.Acts.Act.Identifiers), nameof(OpenIZ.Core.Model.Acts.Act.Notes), nameof(OpenIZ.Core.Model.Acts.Act.Policies) ); } return(retVal); } else { return(base.CacheConvert(dataInstance, context)); } }
/// <summary> /// Perform the cache convert /// </summary> internal Entity DoCacheConvert(DbIdentified dataInstance, LocalDataContext context) { if (dataInstance == null) { return(null); } // Alright first, which type am I mapping to? var dbEntity = dataInstance as DbEntity; Entity retVal = null; IDataCachingService cache = ApplicationContext.Current.GetService <IDataCachingService>(); if (dbEntity != null) { switch (new Guid(dbEntity.ClassConceptUuid).ToString().ToUpper()) { case Device: retVal = cache?.GetCacheItem <DeviceEntity>(dbEntity.Key); break; case NonLivingSubject: retVal = cache?.GetCacheItem <ApplicationEntity>(dbEntity.Key); break; case Person: retVal = cache?.GetCacheItem <UserEntity>(dbEntity.Key); if (retVal == null) { retVal = cache?.GetCacheItem <Person>(dbEntity.Key); } break; case Patient: retVal = cache?.GetCacheItem <Patient>(dbEntity.Key); break; case Provider: retVal = cache?.GetCacheItem <Provider>(dbEntity.Key); break; case Place: case CityOrTown: case Country: case CountyOrParish: case State: case ServiceDeliveryLocation: retVal = cache?.GetCacheItem <Place>(dbEntity.Key); break; case Organization: retVal = cache?.GetCacheItem <Organization>(dbEntity.Key); break; case Material: retVal = cache?.GetCacheItem <Material>(dbEntity.Key); break; case ManufacturedMaterial: retVal = cache?.GetCacheItem <ManufacturedMaterial>(dbEntity.Key); break; default: retVal = cache?.GetCacheItem <Entity>(dbEntity.Key); break; } } else if (dataInstance is DbDeviceEntity) { retVal = cache?.GetCacheItem <DeviceEntity>(dataInstance.Key); } else if (dataInstance is DbApplicationEntity) { retVal = cache?.GetCacheItem <ApplicationEntity>(dataInstance.Key); } else if (dataInstance is DbPerson) { retVal = cache?.GetCacheItem <UserEntity>(dataInstance.Key); } else if (dataInstance is DbPatient) { retVal = cache?.GetCacheItem <Patient>(dataInstance.Key); } else if (dataInstance is DbProvider) { retVal = cache?.GetCacheItem <Provider>(dataInstance.Key); } else if (dataInstance is DbPlace) { retVal = cache?.GetCacheItem <Place>(dataInstance.Key); } else if (dataInstance is DbOrganization) { retVal = cache?.GetCacheItem <Organization>(dataInstance.Key); } else if (dataInstance is DbMaterial) { retVal = cache?.GetCacheItem <Material>(dataInstance.Key); } else if (dataInstance is DbManufacturedMaterial) { retVal = cache?.GetCacheItem <ManufacturedMaterial>(dataInstance.Key); } // Return cache value if (retVal != null) { if (retVal.LoadState < context.DelayLoadMode) { retVal.LoadAssociations(context, // Exclude nameof(OpenIZ.Core.Model.Entities.Entity.Extensions), nameof(OpenIZ.Core.Model.Entities.Entity.Notes), nameof(OpenIZ.Core.Model.Entities.Entity.Participations), nameof(OpenIZ.Core.Model.Entities.Entity.Telecoms), nameof(OpenIZ.Core.Model.Entities.UserEntity.SecurityUser) ); } return(retVal); } else { return(base.CacheConvert(dataInstance, context)); } }
/// <summary> /// HDSI service behavior /// </summary> public HdsiServiceBehavior() : base(ApplicationServiceContext.Current.GetService <IDataCachingService>()) { this.m_dataCachingService = ApplicationServiceContext.Current.GetService <IDataCachingService>(); }
/// <summary> /// DI ctor /// </summary> /// <param name="dataCache"></param> public HdsiServiceBehavior(IDataCachingService dataCache) : base(dataCache) { }