Пример #1
0
        /// <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;
            }
        }
Пример #2
0
        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);
        }