Esempio n. 1
0
        public void SaveToken(Token token)
        {
            string tokenXml = token.Content.XDocument.ToString();
            string inputMessage = token.GetMessage("input").ToString();
            EndpointAddress endpointAddress = token.GetSourceAddress();

            ExecuteProcedure("SaveToken",
                new SqlParameter[]
                {
                    new SqlParameter("InputGUID", token.Guid),
                    new SqlParameter("Token", tokenXml),
                    new SqlParameter("TokenState", token.State.ToString()),
                    new SqlParameter("Message", inputMessage),
                    (token.Created == DateTime.MinValue ? new SqlParameter("Created", DBNull.Value): new SqlParameter("Created", token.Created)),
                    (token.Received == DateTime.MinValue ? new SqlParameter("Received", DBNull.Value): new SqlParameter("Received", token.Received)),
                    (token.Dispatched == DateTime.MinValue ? new SqlParameter("Dispatched", DBNull.Value): new SqlParameter("Dispatched", token.Dispatched)),
                    (token.Finished == DateTime.MinValue ? new SqlParameter("Finished", DBNull.Value): new SqlParameter("Finished", token.Finished)),
                    new SqlParameter("IsPersistent", token.IsPersistent),
                    new SqlParameter("AdapterName", endpointAddress.AdapterName),
                    new SqlParameter("EndpointName", endpointAddress.EndpointName)
                }).Close();
        }
Esempio n. 2
0
        public void FinishToken(string updatingProcessorName, Token targetToken,
            SerializableXDocument resultMessage)
        {
            lock (syncLock)
            {
                MessageFlowState messageflowState = targetToken.GetMessageFlowState();
                if (messageflowState.AssignedProcessor == updatingProcessorName)
                {
                    storage.UpdateToken(targetToken, delegate(Token token)
                    {
                        token.UpdateMessageFlowState(mfs => { mfs.LastResponseFromProcessor = DateTime.Now; });
                    });

                    XDocument sourceMetadata = targetToken.GetSourceMetadata();
                    var sourceAdress = targetToken.GetSourceAddress();
                    if (sourceAdress != null)
                    {
                        string sourceGatewayName = sourceAdress.GatewayName;
                        GatewayAccessor sourceGateway = componentsAccessors.Values.OfType<GatewayAccessor>().SingleOrDefault(gwa => gwa.ComponentName == sourceGatewayName);
                        sourceGateway.ReceiveReturn(targetToken.Guid, resultMessage, new SerializableXDocument(sourceMetadata));
                    }

                    storage.UpdateToken(targetToken, delegate(Token token)
                    {
                        token.State = TokenState.Finished;
                    });
                }
            }
        }