/// <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; } }
protected override async Task <TerminateProcessResponse> OnTerminateByProcessNoStatusingAsync(int processId, ops.Person terminatingUser, CancellationToken cancellationToken, IDictionary <object, object> context) { try { NetworkIdentification1 terminateUser = new NetworkIdentification1 { Domain = terminatingUser.Network.Domain, NetworkId = terminatingUser.Network.Username }; Binding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport) { SendTimeout = new TimeSpan(0, 5, 0), ReceiveTimeout = new TimeSpan(0, 5, 0) }; ChannelFactory <RoutingSoap> factory = new ChannelFactory <RoutingSoap>(binding, new EndpointAddress(_client.BaseAddress)); RoutingSoap serviceProxy = factory.CreateChannel(); TerminationResponse result = await serviceProxy.TerminateByProcessNoStatusingAsync(processId, terminateUser); factory.Close(); TerminateProcessResponse terminateProcessResponse = new TerminateProcessResponse() { ProcessId = processId, ResultId = result.ResultId, Status = result.Status.ToUpper() }; return(terminateProcessResponse); } catch (Exception exception) { _logger.LogError($"A web service error occurred while terminating the process with id: {processId}. Reason: {exception}"); throw; } }