/// <summary> /// Finds the specified model /// </summary> public Bundle Find <TModel>(Expression <Func <TModel, bool> > predicate, int offset, int?count, IntegrationQueryOptions options = null) where TModel : IdentifiedData { try { if (this.IsAvailable()) { HdsiServiceClient client = this.GetServiceClient(); 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); } if (options?.Timeout.HasValue == true) { client.Client.Description.Endpoint[0].Timeout = options.Timeout.Value; } this.m_tracer.TraceVerbose("Performing HDSI query ({0}):{1}", typeof(TModel).FullName, predicate); var retVal = client.Query <TModel>(predicate, offset, count, queryId: options?.QueryId); this.Responded?.Invoke(this, new IntegrationResultEventArgs(null, retVal)); //retVal?.Reconstitute(); return(retVal); } return(null); } catch (TargetInvocationException e) { throw Activator.CreateInstance(e.InnerException.GetType(), "Error performing action", e) as Exception; } }
// [PolicyPermission(System.Security.Permissions.SecurityAction.Demand, PolicyId = PermissionPolicyIdentifiers.UnrestrictedMetadata)] public static void AddAssigningAuthority(AddAssigningAuthorityParams parms) { // First, resolve the assigner SecurityApplicationInfo assigner = null; if (!String.IsNullOrEmpty(parms.Assigner)) { assigner = m_amiClient.GetApplications(o => o.Name == parms.Assigner).CollectionItem.FirstOrDefault() as SecurityApplicationInfo; if (assigner == null) { throw new KeyNotFoundException("Assigner unknown"); } } // Scope List <Concept> scope = new List <Concept>(); if (parms.Scope?.Count > 0) { foreach (var s in parms.Scope) { var scp = m_hdsiClient.Query <Concept>(o => o.Mnemonic == s, 0, 1, false).Item.OfType <Concept>().FirstOrDefault(); if (scp == null) { throw new KeyNotFoundException($"Scope {s} unknown"); } scope.Add(scp); } } // Construct AA foreach (var domainName in parms.Authority) { var aa = new AssigningAuthority(domainName, parms.Name, parms.Oid) { Url = parms.Url, AuthorityScope = scope, AssigningApplication = assigner?.Entity, IsUnique = parms.Unique }; aa = m_amiClient.CreateAssigningAuthority(aa); Console.WriteLine("CREATE AUTHORITY {0} = {1}", aa.DomainName, aa.Key); } }