/// <summary> /// Bundle resource listener /// </summary> public BundleResourceInterceptor(IEnumerable <IDisposable> listeners) { if (listeners == null) { throw new ArgumentNullException(nameof(listeners), "Listeners for chained invokation is required"); } this.m_listeners = listeners; foreach (var itm in this.m_listeners) { this.m_tracer.TraceInfo("Bundles will be chained to {0}", itm.GetType().FullName); } this.m_notifyRepository = ApplicationServiceContext.Current.GetService <INotifyRepositoryService <Bundle> >(); this.m_bundlePersistence = ApplicationServiceContext.Current.GetService <IDataPersistenceService <Bundle> >(); // Subscribe this.m_notifyRepository.Inserting += this.OnPrePersistenceValidate; this.m_notifyRepository.Saving += this.OnPrePersistenceValidate; this.m_notifyRepository.Obsoleting += this.OnPrePersistenceValidate; this.m_notifyRepository.Inserting += this.OnInserting; this.m_notifyRepository.Saving += this.OnSaving; this.m_notifyRepository.Obsoleting += this.OnObsoleting; this.m_notifyRepository.Retrieved += this.OnRetrieved; this.m_notifyRepository.Retrieving += this.OnRetrieving; this.m_notifyRepository.Querying += this.OnQuerying; }
/// <summary> /// Test update only /// </summary> /// <param name="objectUnderTest"></param> /// <param name="propertyToChange"></param> /// <returns></returns> public TModel DoTestUpdate(TModel objectUnderTest, String propertyToChange) { IDataPersistenceService <TModel> persistenceService = ApplicationContext.Current.GetService <IDataPersistenceService <TModel> >(); Assert.IsNotNull(persistenceService); var propertyInfo = typeof(TModel).GetProperty(propertyToChange); Object oldValue = propertyInfo.GetValue(objectUnderTest); if (propertyInfo.PropertyType == typeof(String)) { propertyInfo.SetValue(objectUnderTest, "NEW_VALUE"); } else if (propertyInfo.PropertyType == typeof(Nullable <DateTimeOffset>) || propertyInfo.PropertyType == typeof(DateTimeOffset)) { propertyInfo.SetValue(objectUnderTest, DateTimeOffset.MaxValue); } else if (propertyInfo.PropertyType == typeof(Boolean) || propertyInfo.PropertyType == typeof(Nullable <Boolean>)) { propertyInfo.SetValue(objectUnderTest, !(bool)propertyInfo.GetValue(objectUnderTest)); } var objectAfterUpdate = persistenceService.Update(objectUnderTest); Assert.AreEqual(objectUnderTest.Key, objectAfterUpdate.Key); objectAfterUpdate = persistenceService.Get(objectAfterUpdate.Key.Value); // Update attributes should be set Assert.AreNotEqual(oldValue, propertyInfo.GetValue(objectAfterUpdate)); Assert.AreEqual(objectUnderTest.Key, objectAfterUpdate.Key); return(objectAfterUpdate); }
/// <summary> /// Finds a model element. /// </summary> public static async Task <T> FindOneAsync <T>(this IDataPersistenceService persistence, Expression <Func <T, bool> > predicate) where T : class { using (var context = persistence.OpenContext <T>(false)) { return(await context.FindOneAsync(predicate).ConfigureAwait(false)); } }
public static void ClassSetup(TestContext context) { AppDomain.CurrentDomain.SetData( "DataDirectory", Path.Combine(context.TestDeploymentDir, string.Empty)); IIdentityProviderService identityProvider = ApplicationContext.Current.GetService <IIdentityProviderService>(); var identity = identityProvider.CreateIdentity(nameof(SecurityRolePersistenceServiceTest), "password", AuthenticationContext.SystemPrincipal); // Give this identity the administrative functions group IRoleProviderService roleProvider = ApplicationContext.Current.GetService <IRoleProviderService>(); roleProvider.AddUsersToRoles(new string[] { identity.Name }, new string[] { "ADMINISTRATORS" }, AuthenticationContext.SystemPrincipal); // Authorize s_authorization = identityProvider.Authenticate(nameof(SecurityRolePersistenceServiceTest), "password"); IDataPersistenceService <SecurityPolicy> policyService = ApplicationContext.Current.GetService <IDataPersistenceService <SecurityPolicy> >(); s_chickenCostumePolicy = new SecurityPolicy() { Name = "Allow wearing of chicken costume", Oid = "2.3.23.543.25.2" }; s_chickenCostumePolicy = policyService.Insert(s_chickenCostumePolicy, s_authorization, TransactionMode.Commit); }
/// <summary> /// Resource listener /// </summary> public MdmResourceHandler() { // Register the master this.m_dataManager = MdmDataManagerFactory.GetDataManager <TModel>(); this.m_policyEnforcement = ApplicationServiceContext.Current.GetService <IPolicyEnforcementService>(); this.m_batchRepository = ApplicationServiceContext.Current.GetService <IDataPersistenceService <Bundle> >(); this.m_adhocCache = ApplicationServiceContext.Current.GetService <IAdhocCacheService>(); // Validate the match configuration exists var matchConfigService = ApplicationServiceContext.Current.GetService <IRecordMatchingConfigurationService>(); this.m_notifyRepository = ApplicationServiceContext.Current.GetService <IRepositoryService <TModel> >() as INotifyRepositoryService <TModel>; if (this.m_notifyRepository == null) { throw new InvalidOperationException($"Could not find repository service for {typeof(TModel)}"); } this.m_classConceptKey = typeof(TModel).GetCustomAttributes <ClassConceptKeyAttribute>(false).Select(o => Guid.Parse(o.ClassConcept)).ToArray(); // Subscribe this.m_notifyRepository.Inserting += this.OnPrePersistenceValidate; this.m_notifyRepository.Saving += this.OnPrePersistenceValidate; this.m_notifyRepository.Obsoleting += this.OnPrePersistenceValidate; this.m_notifyRepository.Inserting += this.OnInserting; this.m_notifyRepository.Saving += this.OnSaving; this.m_notifyRepository.Obsoleting += this.OnObsoleting; this.m_notifyRepository.Retrieved += this.OnRetrieved; this.m_notifyRepository.Retrieving += this.OnRetrieving; this.m_notifyRepository.Querying += this.OnQuerying; // Bind down the repository services // TODO: Determine if this level of interception is required - this only impacts when (for example) IRepositoryService<Patient> // is bound to MDM and someone calls IRepositoryService<Person> - without it calls to the former will return MDM based resources // whereas calls to the latter will return raw non-MDM resources (even if they are patients - they will be local, non-MDM patients). var baseType = typeof(TModel).BaseType; while (typeof(Entity).IsAssignableFrom(baseType) || typeof(Act).IsAssignableFrom(baseType)) { var repoType = typeof(INotifyRepositoryService <>).MakeGenericType(baseType); var repoInstance = ApplicationServiceContext.Current.GetService(repoType); if (repoInstance == null) { break; } // Hand off reflection notifcation var eventHandler = repoType.GetEvent("Queried"); var parmType = typeof(QueryResultEventArgs <>).MakeGenericType(baseType); var parameter = Expression.Parameter(parmType); var dataAccess = Expression.MakeMemberAccess(parameter, parmType.GetProperty("Results")); var principalAccess = Expression.MakeMemberAccess(parameter, parmType.GetProperty("Principal")); var methodInfo = this.GetType().GetGenericMethod(nameof(OnGenericQueried), new Type[] { baseType }, new Type[] { typeof(IEnumerable <>).MakeGenericType(baseType), typeof(IPrincipal) }); var lambdaMethod = typeof(Expression).GetGenericMethod(nameof(Expression.Lambda), new Type[] { eventHandler.EventHandlerType }, new Type[] { typeof(Expression), typeof(ParameterExpression[]) }); var lambdaAccess = lambdaMethod.Invoke(null, new object[] { Expression.Assign(dataAccess, Expression.Call(Expression.Constant(this), (MethodInfo)methodInfo, dataAccess, principalAccess)), new ParameterExpression[] { Expression.Parameter(typeof(Object)), parameter } }) as LambdaExpression; eventHandler.AddEventHandler(repoInstance, lambdaAccess.Compile()); //var lamdaAccess = Expression.Lambda(Expression.Call(Expression.Constant(this), this.GetType().GetMethod(nameof(OnGenericQueried))), dataAccess), Expression.Parameter(typeof(Object)), parameter); // Continue down base types baseType = baseType.BaseType; } }
/// <summary> /// Finds a read-only predicated list from a data persistence service, managing the context automatically. /// ToIList is called on the whole thing. /// </summary> public static async Task <IList <T> > FindAllAsync <T>(this IDataPersistenceService persistence) where T : class { using (var context = persistence.OpenContext <T>(false)) { return(await context.FindAllAsync().ToIListAsync().ConfigureAwait(false)); } }
/// <summary> /// Creates a new local security repository service /// </summary> public LocalSecurityRepository( IRepositoryService <SecurityUser> userRepository, IRepositoryService <SecurityApplication> applicationRepository, IRepositoryService <SecurityRole> roleRepository, IRepositoryService <SecurityDevice> deviceRepository, IRepositoryService <SecurityPolicy> policyRepository, IRepositoryService <UserEntity> userEntityRepository, IDataPersistenceService <SecurityProvenance> provenanceRepository, IRoleProviderService roleProviderService, IIdentityProviderService identityProviderService, IApplicationIdentityProviderService applicationIdentityProvider, IDeviceIdentityProviderService deviceIdentityProvider) { this.m_userRepository = userRepository; this.m_applicationIdentityProvider = applicationIdentityProvider; this.m_applicationRepository = applicationRepository; this.m_identityProviderService = identityProviderService; this.m_provenancePersistence = provenanceRepository; this.m_deviceIdentityProvider = deviceIdentityProvider; this.m_deviceRepository = deviceRepository; this.m_policyRepository = policyRepository; this.m_roleRepository = roleRepository; this.m_userEntityRepository = userEntityRepository; this.m_roleProvider = roleProviderService; }
/// <summary> /// Test the insertion of a valid security user /// </summary> public TModel DoTestInsert(TModel objectUnderTest, IPrincipal authContext = null) { // Auth context if (authContext == null) { authContext = AuthenticationContext.AnonymousPrincipal; } // Store user IDataPersistenceService <TModel> persistenceService = ApplicationContext.Current.GetService <IDataPersistenceService <TModel> >(); Assert.IsNotNull(persistenceService); var objectAfterTest = persistenceService.Insert(objectUnderTest, authContext, TransactionMode.Commit); // Key should be set Assert.AreNotEqual(Guid.Empty, objectAfterTest.Key); // Verify objectAfterTest = persistenceService.Get(objectAfterTest.Id(), authContext, false); if (objectAfterTest is BaseEntityData) { Assert.AreNotEqual(default(DateTimeOffset), (objectAfterTest as BaseEntityData).CreationTime); } return(objectAfterTest); }
/// <summary> /// Existing match service /// </summary> public MdmRecordMatchingService(IDataPersistenceService <AssigningAuthority> authorityService, IDataPersistenceService <Bundle> bundleService, IDataPersistenceService <EntityRelationship> erService, IDataPersistenceService <ActRelationship> arService, IRecordMatchingService existingMatchService = null) { this.m_matchService = existingMatchService; this.m_erService = erService; this.m_arService = arService; this.m_uniqueAuthorities = authorityService.Query(o => o.IsUnique, AuthenticationContext.SystemPrincipal).Select(o => o.Key.Value).ToList(); bundleService.Inserted += (o, e) => { foreach (var i in e.Data.Item.OfType <AssigningAuthority>()) { if (i.BatchOperation == BatchOperationType.Delete || i.ObsoletionTime.HasValue) { this.m_uniqueAuthorities.Remove(i.Key.Value); } else if (i.IsUnique) { this.m_uniqueAuthorities.Add(i.Key.Value); } } }; authorityService.Inserted += (o, e) => { if (e.Data.IsUnique) { this.m_uniqueAuthorities.Add(e.Data.Key.Value); } }; authorityService.Obsoleted += (o, e) => { this.m_uniqueAuthorities.Remove(e.Data.Key.Value); }; }
public void ClassSetup() { AuthenticationContext.EnterSystemContext(); IIdentityProviderService identityProvider = ApplicationServiceContext.Current.GetService <IIdentityProviderService>(); var identity = identityProvider.CreateIdentity(nameof(SecurityRolePersistenceServiceTest), "password", AuthenticationContext.Current.Principal); // Give this identity the administrative functions group IRoleProviderService roleProvider = ApplicationServiceContext.Current.GetService <IRoleProviderService>(); roleProvider.AddUsersToRoles(new string[] { identity.Name }, new string[] { "ADMINISTRATORS" }, AuthenticationContext.Current.Principal); // Authorize s_authorization = identityProvider.Authenticate(nameof(SecurityRolePersistenceServiceTest), "password"); IDataPersistenceService <SecurityPolicy> policyService = ApplicationServiceContext.Current.GetService <IDataPersistenceService <SecurityPolicy> >(); s_chickenCostumePolicy = new SecurityPolicy() { Name = "Allow wearing of chicken costume", Oid = "2.3.23.543.25.2" }; s_chickenCostumePolicy = policyService.Insert(s_chickenCostumePolicy, TransactionMode.Commit, s_authorization); }
/// <summary> /// Privacy enforcement service /// </summary> public LocalConceptRepository(IPolicyEnforcementService policyService, ILocalizationService localizationService, IDataPersistenceService <ConceptReferenceTerm> referenceTermService, IDataPersistenceService <ConceptName> conceptNameService, IPrivacyEnforcementService privacyService = null, IAdhocCacheService adhocCacheService = null) : base(policyService, localizationService, privacyService) { this.m_adhocCacheService = adhocCacheService; this.m_conceptNameService = conceptNameService; this.m_referenceTermService = referenceTermService; }
public CommandHandlingService(IServiceProvider provider, DiscordSocketClient discord, CommandService commands, IDataPersistenceService database) { _discord = discord; _commands = commands; _provider = provider; _database = database; _discord.MessageReceived += MessageReceived; }
/// <summary> /// Repository listener /// </summary> public MdmRepositoryListener() { this.m_repositoryService = ApplicationServiceContext.Current.GetService <INotifyRepositoryService <T> >(); this.m_persistenceService = ApplicationServiceContext.Current.GetService <IDataPersistenceService <T> >(); this.m_repositoryService.Inserting += this.OnPrePersistenceEvent; this.m_repositoryService.Saving += this.OnPrePersistenceEvent; this.m_repositoryService.Obsoleting += this.OnPrePersistenceEvent; this.m_repositoryService.Retrieving += this.OnRetrieveEvent; }
/// <summary> /// Internal notification logic /// </summary> private void NotifyInternal(object state) { // Get the state try { NotificationQueueWorkItem workItem = state as NotificationQueueWorkItem; ILocalizationService locale = this.Context.GetService(typeof(ILocalizationService)) as ILocalizationService; IDataPersistenceService idps = this.Context.GetService(typeof(IDataPersistenceService)) as IDataPersistenceService; if (workItem == null) { throw new ArgumentException("workItem"); } var evt = workItem.Event; if (idps != null) { evt = idps.GetContainer(workItem.Event.AlternateIdentifier, true) as RegistrationEvent; } var subject = workItem.Event.FindComponent(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.SubjectOf) as Person; if (subject == null) { throw new InvalidOperationException(locale.GetString("NTFE001")); } // Now determine who will receive updates Trace.TraceInformation("Searching for targets for patient notification..."); List <TargetConfiguration> targets = null; lock (s_syncLock) { targets = s_configuration.Targets.FindAll(o => o.NotificationDomain.Exists(delegate(NotificationDomainConfiguration dc) { bool action = dc.Actions.Exists(act => (act.Action & workItem.Action) == workItem.Action); bool domain = dc.Domain == "*" || subject.AlternateIdentifiers.Exists(id => id.Domain == dc.Domain); return(action && domain); } )); } Trace.TraceInformation("{0} targets for patient notification found..."); // Notify the targets foreach (var itm in targets) { itm.Notifier.Context = this.Context; itm.Notifier.Notify(workItem); } } catch (Exception e) { Trace.TraceError(e.ToString()); } }
/// <summary> /// Get one registration event /// </summary> public Core.ComponentModel.RegistrationEvent GetRegistrationEvent(decimal id) { // Get all Services IAuditorService auditSvc = ApplicationContext.CurrentContext.GetService(typeof(IAuditorService)) as IAuditorService; IDataPersistenceService repSvc = ApplicationContext.CurrentContext.GetService(typeof(IDataPersistenceService)) as IDataPersistenceService; // Audit message AuditData audit = this.ConstructAuditData(ActionType.Read, EventIdentifierType.Export); audit.EventTypeCode = new CodeValue("ADM_GetRegistrationEvent"); try { // Result identifiers var retVal = repSvc.GetContainer(new VersionedDomainIdentifier() { Domain = ApplicationContext.ConfigurationService.OidRegistrar.GetOid("REG_EVT").Oid, Identifier = id.ToString() }, false) as RegistrationEvent; // Add audit data if (retVal != null) { audit.AuditableObjects.Add(new AuditableObject() { IDTypeCode = AuditableObjectIdType.ReportNumber, LifecycleType = AuditableObjectLifecycle.Export, ObjectId = String.Format("{0}^^^&{1}&ISO", retVal.AlternateIdentifier.Identifier, retVal.AlternateIdentifier.Domain), Role = AuditableObjectRole.MasterFile, Type = AuditableObjectType.SystemObject, QueryData = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("loadFast=false")) }); } return(retVal); } catch (Exception e) { Trace.TraceError("Could not execute GetRegistration : {0}", e.ToString()); audit.Outcome = OutcomeIndicator.EpicFail; #if DEBUG throw new FaultException(new FaultReason(e.ToString()), new FaultCode(e.GetType().Name)); #else throw new FaultException(new FaultReason(e.Message), new FaultCode(e.GetType().Name)); #endif } finally { if (auditSvc != null) { auditSvc.SendAudit(audit); } } }
public CyberPatriotEventHandlingService(IServiceProvider provider, DiscordSocketClient discord, IDataPersistenceService database, IConfiguration config, ScoreboardMessageBuilderService messageBuilder, IScoreRetrievalService scoreRetriever, ICompetitionRoundLogicService competitionLogic, LogService logService) { _discord = discord; _provider = provider; _database = database; _config = config; _messageBuilder = messageBuilder; _scoreRetriever = scoreRetriever; _competitionLogic = competitionLogic; _logService = logService; }
/// <summary> /// Creates a new entity merger service /// </summary> public MdmEntityMerger(IDataPersistenceService <Bundle> batchService, IThreadPoolService threadPool, IPolicyEnforcementService policyEnforcement, IStoredQueryDataPersistenceService <TEntity> persistenceService, IFastQueryDataPersistenceService <EntityRelationship> relationshipPersistence) { this.m_dataManager = MdmDataManagerFactory.GetDataManager <TEntity>(); this.m_batchPersistence = batchService; this.m_pepService = policyEnforcement; this.m_entityPersistence = persistenceService; this.m_relationshipPersistence = relationshipPersistence; this.m_threadPool = threadPool; if (this.m_relationshipPersistence is IReportProgressChanged irpc) { irpc.ProgressChanged += (o, e) => this.ProgressChanged?.Invoke(o, e); // pass through progress reports } }
/// <summary> /// Perform a query /// </summary> public IEnumerable <TModel> DoTestQuery(Expression <Func <TModel, bool> > predicate, Guid?knownResultKey) { IDataPersistenceService <TModel> persistenceService = ApplicationContext.Current.GetService <IDataPersistenceService <TModel> >(); Assert.IsNotNull(persistenceService); // Perform query var results = persistenceService.Query(predicate); // Look for the known key Assert.IsTrue(results.Any(p => p.Key == knownResultKey), "Result doesn't contain known key"); return(results); }
/// <summary> /// Do a test step for an update /// </summary> public TModel DoTestInsertUpdate(TModel objectUnderTest, String propertyToChange) { // Auth context // Store user IDataPersistenceService <TModel> persistenceService = ApplicationContext.Current.GetService <IDataPersistenceService <TModel> >(); Assert.IsNotNull(persistenceService); // Update the user var objectAfterInsert = persistenceService.Insert(objectUnderTest); // Update return(this.DoTestUpdate(objectAfterInsert, propertyToChange)); }
/// <summary> /// Insert troublesome place /// </summary> //[TestMethod] public void InsertTroublesomePlace() { IDataPersistenceService <Place> idp = ApplicationContext.Current.GetService <IDataPersistenceService <Place> >(); XmlSerializer xsz = new XmlSerializer(typeof(Bundle)); using (var s = typeof(PlacePersistenceServiceTest).Assembly.GetManifestResourceStream("OpenIZ.Mobile.Core.Test.IMSI.TroublesomePlaceBundle.xml")) { var bundle = xsz.Deserialize(s) as Bundle; bundle.Reconstitute(); foreach (var i in bundle.Item) { idp.Insert(i); } } }
public CyberPatriotEventHandlingService(IServiceProvider provider, DiscordSocketClient discord, IDataPersistenceService database, IConfiguration config, ScoreboardMessageBuilderService messageBuilder, IScoreRetrievalService scoreRetriever, ICompetitionRoundLogicService competitionLogic, LogService logService) { _discord = discord; _provider = provider; _database = database; _config = config; _messageBuilder = messageBuilder; _scoreRetriever = scoreRetriever; _competitionLogic = competitionLogic; _logService = logService; _discord.MessageReceived += MessageReceived; _teamUrlRegex = new Regex("https?://" + _config["httpConfig:defaultHostname"].Replace(".", "\\.") + "/team\\.php\\?team=([0-9]{2}-[0-9]{4})"); }
/// <summary> /// Do a test step for an update /// </summary> public TModel DoTestUpdate(TModel objectUnderTest, IPrincipal authContext, String propertyToChange) { // Auth context if (authContext == null) { authContext = AuthenticationContext.AnonymousPrincipal; } // Store user IDataPersistenceService <TModel> persistenceService = ApplicationContext.Current.GetService <IDataPersistenceService <TModel> >(); Assert.IsNotNull(persistenceService); // Update the user var objectAfterInsert = persistenceService.Insert(objectUnderTest, authContext, TransactionMode.Commit); // Update var propertyInfo = typeof(TModel).GetProperty(propertyToChange); object originalValue = propertyInfo.GetValue(objectUnderTest); if (propertyInfo.PropertyType == typeof(String)) { propertyInfo.SetValue(objectAfterInsert, "NEW_VALUE"); } else if (propertyInfo.PropertyType == typeof(Nullable <DateTimeOffset>) || propertyInfo.PropertyType == typeof(DateTimeOffset)) { propertyInfo.SetValue(objectAfterInsert, DateTimeOffset.MaxValue); } else if (propertyInfo.PropertyType == typeof(Boolean) || propertyInfo.PropertyType == typeof(Nullable <Boolean>)) { propertyInfo.SetValue(objectAfterInsert, true); } var objectAfterUpdate = persistenceService.Update(objectAfterInsert, authContext, TransactionMode.Commit); Assert.AreEqual(objectAfterInsert.Key, objectAfterUpdate.Key); objectAfterUpdate = persistenceService.Get(objectAfterUpdate.Id(), authContext, false); // Update attributes should be set Assert.AreNotEqual(originalValue, propertyInfo.GetValue(objectAfterUpdate)); Assert.AreEqual(objectAfterInsert.Key, objectAfterUpdate.Key); return(objectAfterUpdate); }
/// <summary> /// DI constructor /// </summary> public SystemPolicySynchronizationJob(INetworkInformationService networkInformationService, ITickleService tickleService, IAdministrationIntegrationService amiIntegrationService, IOfflinePolicyInformationService offlinePip, IOfflineRoleProviderService offlineRps, ISecurityRepositoryService securityRepository, IJobStateManagerService jobStateManager, IDataPersistenceService <SecurityChallenge> securityChallengeService = null) { this.m_networkInformationService = networkInformationService; this.m_offlinePip = offlinePip; this.m_offlineRps = offlineRps; this.m_securityRepository = securityRepository; this.m_jobStateManager = jobStateManager; this.m_securityChallenge = securityChallengeService; this.m_amiIntegrationService = amiIntegrationService; this.m_tickleService = tickleService; }
/// <summary> /// Perform a query /// </summary> public IEnumerable <TModel> DoTestQuery(Expression <Func <TModel, bool> > predicate, Guid?knownResultKey, IPrincipal authContext) { // Auth context if (authContext == null) { authContext = AuthenticationContext.AnonymousPrincipal; } IDataPersistenceService <TModel> persistenceService = ApplicationContext.Current.GetService <IDataPersistenceService <TModel> >(); Assert.IsNotNull(persistenceService); // Perform query var results = persistenceService.Query(predicate, authContext); // Look for the known key Assert.IsTrue(results.Any(p => p.Key == knownResultKey), "Result doesn't contain known key"); return(results); }
/// <summary> /// Test the insertion of a valid security user /// </summary> public TModel DoTestInsert(TModel objectUnderTest) { // Store user IDataPersistenceService <TModel> persistenceService = ApplicationContext.Current.GetService <IDataPersistenceService <TModel> >(); Assert.IsNotNull(persistenceService); var objectAfterTest = persistenceService.Insert(objectUnderTest); // Key should be set Assert.AreNotEqual(Guid.Empty, objectAfterTest.Key); // Verify objectAfterTest = persistenceService.Get(objectAfterTest.Key.Value); if (objectAfterTest is BaseEntityData) { Assert.AreNotEqual(default(DateTimeOffset), (objectAfterTest as BaseEntityData).CreationTime); } return(objectAfterTest); }
/// <summary> /// Bind the enforcement point /// </summary> protected void BindClinicalEnforcement <TData>(IDataPersistenceService <TData> persister) where TData : IdentifiedData { // Demand query persister.Querying += (o, e) => { new PolicyPermission(System.Security.Permissions.PermissionState.Unrestricted, PermissionPolicyIdentifiers.QueryClinicalData).Demand(); }; // Demand insert persister.Inserting += (o, e) => { new PolicyPermission(System.Security.Permissions.PermissionState.Unrestricted, PermissionPolicyIdentifiers.WriteClinicalData).Demand(); }; // Demand update persister.Updating += (o, e) => { new PolicyPermission(System.Security.Permissions.PermissionState.Unrestricted, PermissionPolicyIdentifiers.WriteClinicalData).Demand(); }; // Obsoletion permission demand persister.Obsoleting += (o, e) => { new PolicyPermission(System.Security.Permissions.PermissionState.Unrestricted, PermissionPolicyIdentifiers.DeleteClinicalData).Demand(); }; // Queried data filter persister.Queried += (o, e) => { new PolicyPermission(System.Security.Permissions.PermissionState.Unrestricted, PermissionPolicyIdentifiers.ReadClinicalData).Demand(); QueryResultEventArgs <TData> dqre = e as QueryResultEventArgs <TData>; // Filter dataset if (dqre != null) { dqre.Results = dqre.Results.Where(i => ApplicationContext.Current.PolicyDecisionService.GetPolicyDecision(AuthenticationContext.Current.Principal, i).Outcome == SanteDB.Core.Model.Security.PolicyGrantType.Grant); } }; }
public TasExplorerViewModel(IServiceProvider services) : base(services) { _errorDialogService = services.GetRequiredService <IErrorDialog>(); _threadingService = services.GetRequiredService <IThreadingService>(); _dataPersistenceService = services.GetRequiredService <IDataPersistenceService>(); _confirmDelete = services.GetRequiredService <IAppDeletionConfirmationViewModel>(); _viewLocatorService = services.GetRequiredService <IViewLocatorService>(); string existingSavedConnectionName = _dataPersistenceService.ReadStringData(ConnectionNameKey); string existingSavedConnectionAddress = _dataPersistenceService.ReadStringData(ConnectionAddressKey); bool savedConnectionCredsExist = CloudFoundryService.IsValidConnection(); if (existingSavedConnectionName == null || existingSavedConnectionAddress == null || !savedConnectionCredsExist) { TasConnection = null; } else { var restoredConnection = new CloudFoundryInstance(name: existingSavedConnectionName, apiAddress: existingSavedConnectionAddress); SetConnection(restoredConnection); } }
/// <summary> /// Clear operation /// </summary> public MdmClearOperation(IConfigurationManager configurationManager, IDataPersistenceService <Bundle> batchService) : base(configurationManager, batchService) { }
public PreferenceProviderService(IDataPersistenceService database) { Database = database; }
/// <summary> /// Read a patint resource /// </summary> public SVC.Messaging.FHIR.FhirOperationResult Read(string id, string versionId) { FhirOperationResult result = new FhirOperationResult(); result.Details = new List <IResultDetail>(); result.Results = new List <ResourceBase>(); // Data persistence service IDataPersistenceService dataPersistence = ApplicationContext.CurrentContext.GetService(typeof(IDataPersistenceService)) as IDataPersistenceService; var container = dataPersistence.GetContainer(new VersionedDomainIdentifier() { Domain = this.DataDomain, Identifier = id, Version = String.IsNullOrEmpty(versionId) ? null : versionId }, String.IsNullOrEmpty(versionId)); // Container was not found if (container == null) { result.Outcome = ResultCode.NotAvailable; } else { var processor = FhirMessageProcessorUtil.GetComponentProcessor(container.GetType()); // Was there a history? if (versionId == null) { result.Results.Add(processor.ProcessComponent(container as IComponent, result.Details)); } else if (versionId == String.Empty) // Get all versions { while (container != null) { var hsrc = container as HealthServiceRecordContainer; var resource = processor.ProcessComponent(container as IComponent, result.Details); if (hsrc.IsMasked) // record is masked so add a detected issue { result.Issues.Add(new SVC.Core.Issues.DetectedIssue() { MitigatedBy = ManagementType.OtherActionTaken, Severity = IssueSeverityType.Moderate, Text = String.Format("{0}/_history/{1} will not be returned as it has been masked", resource.Id, resource.VersionId), Type = IssueType.DetectedIssue }); } else { result.Results.Add(resource); } container = hsrc.FindComponent(HealthServiceRecordSiteRoleType.OlderVersionOf) as IContainer; } } else // Some version { while (container != null) { var hsrc = container as HealthServiceRecordContainer; var resource = processor.ProcessComponent(container as IComponent, result.Details); container = hsrc.FindComponent(HealthServiceRecordSiteRoleType.ReplacementOf) as IContainer; if (resource != null && resource.VersionId.ToString() != versionId) { continue; } if (hsrc.IsMasked) // record is masked so add a detected issue { result.Issues.Add(new SVC.Core.Issues.DetectedIssue() { MitigatedBy = ManagementType.OtherActionTaken, Severity = IssueSeverityType.Moderate, Text = String.Format("{0}/_history/{1} will not be returned as it has been masked", resource.Id, resource.VersionId), Type = IssueType.DetectedIssue }); } else { result.Results.Add(resource); } } } result.Outcome = ResultCode.Accepted; } result.Results.RemoveAll(o => o == null); return(result); }