public IPersonSearchService SearchIdentificationExp(string nameOfStrategy, PersonIdentification personIdentification, bool isAndClause = true) { IPersonExpSearchStrategy <PersonIdentification> personExpSearchStrategy = _personIdentificationExpSearchStrategyFactory[nameOfStrategy]; _personExpression = personExpSearchStrategy.Run(_personExpression, personIdentification, isAndClause); return(this); }
private PersonIdentification CreateTestItem() { var testItem = new PersonIdentification { EmployeeId = "99999", HanfordId = "7777777", Domain = "PNL", NetworkId = "LLLLDDDD" }; return(testItem); }
/// <summary> /// Asynchronously retrieves a <see cref="PersonIdentification"/>. /// </summary> /// <param name="id">The list of process identification numbers that we are going to retrieve.</param> /// <param name="cancellationToken">The optional token to monitor for cancellation requests.</param> /// <param name="context">The optional execution context that applies to this operation.</param> /// <returns>A <see cref="Task{TResult}"/> </returns> public async Task <PersonIdentification> GetByIdAsync(string id, CancellationToken cancellationToken = default(CancellationToken), IDictionary <object, object> context = null) { cancellationToken.ThrowIfCancellationRequested(); if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException(nameof(id)); } try { // TODO: How to update the cache. if (!_cache.TryGetValue(CacheName, out IList <PersonIdentification> list)) { list = new List <PersonIdentification>(); } PersonIdentification personIdentification = list.FirstOrDefault(i => i.HanfordId == id); if (personIdentification == null) { personIdentification = list.FirstOrDefault(i => i.EmployeeId == id); } if (personIdentification == null) { personIdentification = list.FirstOrDefault(i => i.NetworkId == id); } if (personIdentification == null) { personIdentification = await OnGetByIdAsync(id, cancellationToken, context ?? new Dictionary <object, object>()); list.Add(personIdentification); DateTime expiry = DateTime.Today.AddHours(2).AddDays(1); MemoryCacheEntryOptions cacheEntryOptions = new MemoryCacheEntryOptions { AbsoluteExpiration = expiry }; _cache.Set(CacheName, list, cacheEntryOptions); } return(personIdentification); } catch (Exception ex) { throw ex; } }
public IPersonSearchService SearchIdentification(String nameOfStrategy, PersonIdentification personIdentification, bool isEagerLoaded = true) { if (isEagerLoaded) { _personQuery = _personQuery.Include(person => person.PersonIdentifications); } IPersonSearchStrategy <PersonIdentification> personSearchStrategy = _personIdentificationSearchStrategyFactory[nameOfStrategy]; _personQuery = personSearchStrategy.Run(_personQuery, personIdentification); return(this); }
/// <summary> /// Asynchronously applies an actor action to an activity /// </summary> /// <param name="actorAction">The information necessary to instantiate a new routing.</param> /// <param name="cancellationToken">The optional token to monitor for cancellation requests.</param> /// <param name="context">The optional execution context that applies to this operation.</param> /// <returns>An integer that contains the new process id.</returns> protected override async Task <int?> OnApplyActorActionAsync(ActorAction actorAction, CancellationToken cancellationToken = default(CancellationToken), IDictionary <object, object> context = null) { // TODO: Fix this, errors in here need to be aggregated and passed back, right now it's a bit obtuse, but we need to validate the hanford ids PersonIdentification actingUser = await _personIdentificationStore.GetByHanfordIdAsync(actorAction.ActorHanfordId, cancellationToken, context); //PersonIdentification originatorIds = await _personIdentificationStore.GetByHanfordIdAsync(routingItem.SubmitUserHanfordId, cancellationToken, context); //PersonIdentification beneficiaryIds = await _personIdentificationStore.GetByHanfordIdAsync(routingItem.SubmitUserHanfordId, cancellationToken, context); try { ChannelFactory <RoutingSoap> factory = null; RoutingSoap serviceProxy = null; Binding binding = null; binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); factory = new ChannelFactory <RoutingSoap>(binding, new EndpointAddress(_client.BaseAddress)); serviceProxy = factory.CreateChannel(); sendActionRequest sendActionRequest = CreateSendActionRequest(actorAction, actingUser); var result = await serviceProxy.sendActionAsync(sendActionRequest); if (result.sendActionResult.StatusCode != SendActionStatus.Success) { throw new ArgumentException(result.sendActionResult.StatusDescription); } int?approvalResponse = actorAction.ActivityId; return(approvalResponse); } catch (ArgumentException exception) { _logger.LogError("A web service error occurred while submitting release for review. Reason: {@Exception}", exception); throw; } catch (Exception exception) { _logger.LogError("A web service error occurred while submitting release for review. Reason: {@Exception}", exception); throw; } }
/// <summary> /// Asynchronously routes an item for approvals /// </summary> /// <param name="routingItem">The information necessary to instantiate a new routing.</param> /// <param name="cancellationToken">The optional token to monitor for cancellation requests.</param> /// <param name="context">The optional execution context that applies to this operation.</param> /// <returns>An integer that contains the new process id.</returns> protected override async Task <int?> OnCreateRoutingAsync(RoutingItem routingItem, CancellationToken cancellationToken = default(CancellationToken), IDictionary <object, object> context = null) { // TODO: Fix this, errors in here need to be aggregated and passed back, right now it's a bit obtuse, but we need to validate the hanford ids PersonIdentification submitterIds = await _personIdentificationStore.GetByHanfordIdAsync(routingItem.SubmitUserHanfordId, cancellationToken, context); PersonIdentification originatorIds = await _personIdentificationStore.GetByHanfordIdAsync(routingItem.OriginatorHanfordId, cancellationToken, context); PersonIdentification beneficiaryIds = await _personIdentificationStore.GetByHanfordIdAsync(routingItem.BeneficiaryHanfordId, cancellationToken, context); try { Binding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); ChannelFactory <RoutingSoap> factory = new ChannelFactory <RoutingSoap>(binding, new EndpointAddress(_client.BaseAddress)); RoutingSoap serviceProxy = factory.CreateChannel(); InstantiateProcessRequest process = CreateInstProcessRequest(routingItem, submitterIds, originatorIds, beneficiaryIds); var result = await serviceProxy.InstantiateProcessAsync(process); if (result.InstantiateProcessResult.InstProcessId == 0) { throw new ArgumentException(result.InstantiateProcessResult.Status); } int?approvalResponse = result.InstantiateProcessResult.InstProcessId; return(approvalResponse); } catch (ArgumentException exception) { throw exception; } catch (Exception exception) { _logger.LogError("A web service error occurred while submitting the item for routing. Reason: {@Exception}", exception); _logger.LogDebug(JsonSerializer.Serialize(routingItem)); throw; } }
private async Task <PagedResult <Process> > ExecuteSearch(int offset, int limit, IDictionary <object, object> context, string query, DynamicParameters parameters, CancellationToken cancellationToken) { var policy = _connectionFactory.PolicySelector(_logger); var result = await policy.ExecuteAsync(async() => { using (var connection = _connectionFactory.Create("raa")) { int count = await GetProcessCountAsync(BuildCountQuery(query), parameters, connection, cancellationToken, context); IDictionary <int, Process> processList = await GetProcessList(BuildResultSetQuery(query), parameters, offset, limit, connection, cancellationToken, context); foreach (var processId in processList.Keys) { var process = processList[processId]; PersonIdentification org = await _personIdentificationStore.GetByIdAsync(process.OriginatorId); process.OriginatorHanfordId = org.HanfordId; PersonIdentification beni = await _personIdentificationStore.GetByIdAsync(process.BeneficiaryId); process.BeneficiaryHanfordId = beni.HanfordId; foreach (var activity in process.Activities) { if (!string.IsNullOrEmpty(activity.Value.ActedUserId)) { PersonIdentification act = await _personIdentificationStore.GetByIdAsync(activity.Value.ActedUserId); activity.Value.ActedHanfordId = act.HanfordId; } } } return(new PagedResult <Process>(offset, limit, count, processList.Values.ToList())); } }); return(result); }
private static InstantiateProcessRequest CreateInstProcessRequest(RoutingItem routingItem, PersonIdentification submitterIds, PersonIdentification originatorIds, PersonIdentification beneficiaryIds) { NetworkIdentification1 instantiateUser = new NetworkIdentification1 { Domain = submitterIds.Domain, NetworkId = submitterIds.NetworkId }; InstantiateProcessRequest process = new InstantiateProcessRequest { InstantiateUser = instantiateUser }; RoutingPayload pay = new RoutingPayload { MetaData = new DocMetaData() }; pay.MetaData.ApplicationIRI = (int)routingItem.ApplicationItemId; pay.MetaData.DocumentTypeName = routingItem.DocumentTypeName; pay.MetaData.DocumentAtAGlance = routingItem.DocumentTitle; pay.MetaData.DocumentId = routingItem.DocumentId; pay.MetaData.DocumentOriginator = new NetworkIdentification { Domain = originatorIds.Domain, NetworkId = originatorIds.NetworkId }; pay.MetaData.DocumentBeneficiary = new NetworkIdentification { Domain = beneficiaryIds.Domain, NetworkId = beneficiaryIds.NetworkId }; // Example //<MetaData> //<ApprovalTechEmplId/> //<ApprovalUserEmplId/> //<AuthorEmplId/> //<ChangeSw/> //<OtherApproverList> //<OtherApproverList_items Type="USERIDLIST -or- ROLENAME -or- LISTVALUES"> //<ListItem Key="" Value=""/> //</OtherApproverList_items> //</OtherApproverList> //<QualityEngineerEmplId/> //<RadiologicalControlEmplId/> //<RespManagerEmplId/> //<SafetyAndHealth/> //<SMEApproverList> //<SMEApproverList_items Type="USERIDLIST -or- ROLENAME -or- LISTVALUES"> //<ListItem Key="" Value=""/> //</SMEApproverList_items> //</SMEApproverList> //<USQDSESNo/> //<USQTNumber/> //</MetaData> XElement metaData = new XElement("MetaData"); if (routingItem.IntFields != null && routingItem.IntFields.Count > 0) { foreach (var item in routingItem.IntFields) { XElement element = new XElement(item.Key) { Value = item.Value.ToString() }; metaData.Add(element); } } if (routingItem.StringFields != null && routingItem.StringFields.Count > 0) { foreach (var item in routingItem.StringFields) { XElement element = new XElement(item.Key) { Value = item.Value }; metaData.Add(element); } } if (routingItem.ListFields != null && routingItem.ListFields.Count > 0) { foreach (var item in routingItem.ListFields) { XElement listElement = new XElement(item.Key); var list = item.Value; XAttribute attribute = new XAttribute("Type", list.ListType); listElement.Add(attribute); XElement items = new XElement("LIST_ITEMS"); listElement.Add(item); foreach (var value in list.Values) { XElement element = new XElement("LIST_ITEM") { Value = value }; metaData.Add(element); } } } pay.MetaData.DocumentRoutingData = metaData; process.RoutingPayload = pay; pay.Document = new Document { FileExtension = routingItem.Document.FileExtension, MimeType = routingItem.Document.MimeType, AsciiContent = routingItem.Document.AsciiContent, XslStylesheet = routingItem.Document.XslStyleSheet, Content = routingItem.Document.Content }; return(process); }
private sendActionRequest CreateSendActionRequest(ActorAction actorAction, PersonIdentification actionPerson) { // <action> // <processId>string</processId> // <activityId>string</activityId> // <comments>string</comments> // <actionTaken>string</actionTaken> // <websignRedirect>string</websignRedirect> // <documentDescription>string</documentDescription> // <actionUser> // <domain>string</domain> // <networkId>string</networkId> // </actionUser> // <document> // <fileExtension>string</fileExtension> // <mimeType>string</mimeType> // <content>base64Binary</content> // <asciiContent>string</asciiContent> // <xslStylesheet>string</xslStylesheet> // </document> //</action> // byte[] bPlain; byte[] bSigned; XElement action = new XElement("action"); XElement process = new XElement("processId") { Value = actorAction.ProcessId.ToString() }; action.Add(process); XElement activity = new XElement("activityId"); activity.Value = actorAction.ActivityId.ToString(); action.Add(activity); XElement comment = new XElement("comments"); comment.Value = actorAction.Comment; action.Add(comment); XElement actionTaken = new XElement("actionTaken") { Value = actorAction.ActionTaken.ToString() }; action.Add(actionTaken); XElement websignRedirect = new XElement("websignRedirect"); action.Add(websignRedirect); XElement actionUser = new XElement("actionUser"); XElement domain = new XElement("domain") { Value = actionPerson.Domain }; actionUser.Add(domain); XElement netId = new XElement("networkId") { Value = actionPerson.NetworkId }; actionUser.Add(netId); action.Add(actionUser); XElement document = new XElement("document"); action.Add(document); try { bPlain = System.Text.Encoding.ASCII.GetBytes(action.ToString()); RSACryptoServiceProvider RSA; RSACryptoServiceProvider.UseMachineKeyStore = true; CspParameters csp = new CspParameters { Flags = CspProviderFlags.UseExistingKey | CspProviderFlags.UseMachineKeyStore, KeyContainerName = "approvalskey" }; using (RSA = new RSACryptoServiceProvider(csp)) { bSigned = RSA.SignData(bPlain, "MD5"); } } catch (Exception ex) { //Internal.Cryptography.CryptoThrowHelper + WindowsCryptographicException string exs = ex.GetType().ToString(); if (exs == "Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException") { throw new InvalidOperationException("Crytography keyset does not exist!", ex); } else { throw; } } sendActionRequest sendActionRequest = new sendActionRequest() { processId = actorAction.ProcessId, actionPayload = action.ToString(), SignedString = bSigned }; return(sendActionRequest); }