Пример #1
0
        public override bool Evaluate(ActorsTransaction actorsTransaction)
        {
            bool isConditionTrue = true;

            if (actorsTransaction.FromActorName == this.actorName)
            {
                isConditionTrue = true;
            }
            else
            {
                isConditionTrue = false;
            }

            return(isConditionTrue);
        }
Пример #2
0
        public override bool Evaluate(ActorsTransaction actorsTransaction)
        {
            bool isConditionTrue = true;

            if (actorsTransaction.Direction == this.transactionDirection)
            {
                isConditionTrue = true;
            }
            else
            {
                isConditionTrue = false;
            }

            return(isConditionTrue);
        }
Пример #3
0
        public override bool Evaluate(Object theObject)
        {
            bool isConditionTrue = true;

            ActorsTransaction actorsTransaction = theObject as ActorsTransaction;

            if (actorsTransaction == null)
            {
                isConditionTrue = true;
            }
            else
            {
                isConditionTrue = Evaluate(actorsTransaction);
            }

            return(isConditionTrue);
        }
Пример #4
0
 /// <summary>
 /// Inserts an <see cref="ActorsTransaction"/> element into the <see cref="ActorsTransactionLog"/> at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which value should be inserted.</param>
 /// <param name="value">The <see cref="ActorsTransaction"/> to insert.</param>
 public void Insert(int index, ActorsTransaction value)
 {
     List.Insert(index, value);
 }
Пример #5
0
        /// <summary>
        /// Process Hl7 requests and responses.
        /// </summary>
        public void ProcessMessages()
        {
            _hl7Mllp = new Hl7Mllp();

            for(;;)
            {
                System.String message = System.String.Format("Listening for incoming HL7 connection on port {0}...", _config.PortNumber);
                _hl7ThreadForHl7Server.LogInformation(message);

                try
                {
                    // listen for a connection
                    _hl7Mllp.Listen(_config.PortNumber);

                    for(;;)
                    {
                        // accept the connection - only one at a time
                        _hl7Mllp.Accept();

                        // the message delimiters will be filled in by the ReceiveMessage method
                        Hl7MessageDelimiters messageDelimiters = null;

                        // receive an HL7 message
                        Hl7Message hl7RequestMessage = _hl7Mllp.ReceiveMessage(out messageDelimiters);
                        if (hl7RequestMessage != null)
                        {
                            System.String messageType = hl7RequestMessage.Value(Hl7SegmentEnum.MSH, 9);
                            message = System.String.Format("HL7 Server thread - received message \"{0}\".", messageType);
                            _hl7ThreadForHl7Server.LogInformation(message);
                            _hl7ThreadForHl7Server.LogInformation(hl7RequestMessage.ToString(messageDelimiters));

                            // Validate the message
                            if (_config.AutoValidate == true)
                            {
                                ValidateMessage(hl7RequestMessage, messageDelimiters);
                            }

                            // call the message handler to get a response
                            Hl7Message hl7ResponseMessage = MessageHandler(hl7RequestMessage);

                            // copy some fields from the request
                            hl7ResponseMessage.SendingApplication = hl7RequestMessage.ReceivingApplication;
                            hl7ResponseMessage.SendingFacility = hl7RequestMessage.ReceivingFacility;
                            hl7ResponseMessage.ReceivingApplication = hl7RequestMessage.SendingApplication;
                            hl7ResponseMessage.ReceivingFacility = hl7RequestMessage.SendingFacility;
                            hl7ResponseMessage.MessageControlId = hl7RequestMessage.MessageControlId;

                            // set the date/time of message
                            hl7ResponseMessage.DateTimeOfMessage = System.DateTime.Now.ToString("yyyyMMddhhmmss", System.Globalization.CultureInfo.InvariantCulture);

                            // send the response
                            _hl7Mllp.SendMessage(hl7ResponseMessage, messageDelimiters);

                            messageType = hl7ResponseMessage.Value(Hl7SegmentEnum.MSH, 9);
                            message = System.String.Format("HL7 Server thread - sent message \"{0}\".", messageType);
                            _hl7ThreadForHl7Server.LogInformation(message);
                            _hl7ThreadForHl7Server.LogInformation(hl7ResponseMessage.ToString(messageDelimiters));

                            // get the next transaction number - needed to sort the
                            // transactions correctly
                            int transactionNumber = TransactionNumber.GetNextTransactionNumber();

                            // save the transaction
                            Hl7Transaction transaction = new Hl7Transaction(TransactionNameEnum.RAD_1, TransactionDirectionEnum.TransactionReceived);
                            transaction.Request = hl7RequestMessage;
                            transaction.Response = hl7ResponseMessage;

                            _hl7ThreadForHl7Server.LogInformation(String.Format("{0} - received Hl7 event from {1}", ParentActor.ActorName, ActorName));

                            ActorsTransaction actorsTransaction = new ActorsTransaction(transactionNumber,
                                ActorName,  // from actor
                                ParentActor.ActorName,  // to actor
                                transaction,
                                _hl7ThreadForHl7Server.Options.ResultsFileNameOnly,
                                _hl7ThreadForHl7Server.Options.ResultsFullFileName,
                                (uint)_hl7ThreadForHl7Server.NrErrors,
                                (uint)_hl7ThreadForHl7Server.NrWarnings);

                            // save the transaction in the Actor log
                            ParentActor.ActorsTransactionLog.Add(actorsTransaction);

                            // publish the transaction event to any interested parties
                            PublishTransactionAvailableEvent(ActorName, actorsTransaction);
                        }

                        _hl7Mllp.Close();

                        _hl7ThreadForHl7Server.StopResultsGathering();
                        _hl7ThreadForHl7Server.StartResultsGathering();
                    }
                }
                catch
                {
                    // System.Net.Sockets.Socket.Accept() exception thrown when the server is stopped by closing the listen socket.
                    break;
                }
            }
        }
Пример #6
0
        private void ProcessTrigger(Hl7Trigger trigger)
        {
            _hl7Mllp = new Hl7Mllp();

            // get the next transaction number - needed to sort the
            // transactions correctly
            int transactionNumber = TransactionNumber.GetNextTransactionNumber();

            System.String message = System.String.Format("HL7 Client thread - connecting to \"{0}\" on port {1}...", _config.ToActorIpAddress, _config.PortNumber);
            _hl7ThreadForHl7Client.LogInformation(message);

            if (_hl7Mllp.Connect(_config.ToActorIpAddress, _config.PortNumber))
            {
                Hl7Message hl7RequestMessage = trigger.Trigger;

                // Set the sending and receiving applications
                hl7RequestMessage.SendingApplication = _config.FromActorAeTitle;
                hl7RequestMessage.ReceivingApplication = _config.ToActorAeTitle;

                // Add the control id and date/time of message
                hl7RequestMessage.MessageControlId = _messageControlId.ToString();
                _messageControlId++;
                hl7RequestMessage.DateTimeOfMessage = System.DateTime.Now.ToString("yyyyMMddhhmmss", System.Globalization.CultureInfo.InvariantCulture);

                // get initial HL7 message delimiters from the config
                Hl7MessageDelimiters messageDelimiters = _config.MessageDelimiters;

                System.String messageType = hl7RequestMessage.Value(Hl7SegmentEnum.MSH, 9);
                _hl7ThreadForHl7Client.LogInformation(System.String.Format("HL7 Client thread - send message \"{0}\".", messageType));
                _hl7ThreadForHl7Client.LogInformation(hl7RequestMessage.ToString(messageDelimiters));

                if (_hl7Mllp.SendMessage(hl7RequestMessage, messageDelimiters) == true)
                {
                    Hl7Message hl7ResponseMessage = _hl7Mllp.ReceiveMessage(out messageDelimiters);

                    if (hl7ResponseMessage != null)
                    {
                        messageType = hl7ResponseMessage.Value(Hl7SegmentEnum.MSH, 9);
                        _hl7ThreadForHl7Client.LogInformation(System.String.Format("HL7 Client thread - received message \"{0}\".", messageType));
                        _hl7ThreadForHl7Client.LogInformation(hl7ResponseMessage.ToString(messageDelimiters));

                        // Validate the message
                        if (_config.AutoValidate == true)
                        {
                            ValidateMessage(hl7ResponseMessage, messageDelimiters);
                        }

                        // save the transaction
                        Hl7Transaction transaction = new Hl7Transaction(TransactionNameEnum.RAD_1, TransactionDirectionEnum.TransactionSent);
                        transaction.Request = hl7RequestMessage;
                        transaction.Response = hl7ResponseMessage;

                        ActorsTransaction actorsTransaction = new ActorsTransaction(transactionNumber,
                            ActorName, // from actor
                            ParentActor.ActorName,  // to actor
                            transaction,
                            _hl7ThreadForHl7Client.Options.ResultsFileNameOnly,
                            _hl7ThreadForHl7Client.Options.ResultsFullFileName,
                            (uint)_hl7ThreadForHl7Client.NrErrors,
                            (uint)_hl7ThreadForHl7Client.NrWarnings);

                        // save the transaction in the Actor log
                        ParentActor.ActorsTransactionLog.Add(actorsTransaction);

                        // publish the transaction event to any interested parties
                        PublishTransactionAvailableEvent(ActorName, actorsTransaction);
                    }
                }

                _hl7Mllp.Stop();

                _hl7ThreadForHl7Client.StopResultsGathering();
                _hl7ThreadForHl7Client.StartResultsGathering();
            }

            if (_awaitCompletion == true)
            {
                _semaphore.Signal();
            }
        }
Пример #7
0
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="actorName">Event source Actor Name.</param>
 /// <param name="transaction">Transaction.</param>
 public TransactionAvailableEventArgs(ActorName actorName, ActorsTransaction transaction)
 {
     _actorName = actorName;
     _transaction = transaction;
 }
Пример #8
0
        /// <summary>
        /// Publish the Transaction Available Event.
        /// </summary>
        /// <param name="actorName">Name of Actor from which the Transaction was received.</param>
        /// <param name="transaction">Transaction.</param>
        public void PublishTransactionAvailableEvent(ActorName actorName, ActorsTransaction transaction)
        {
            TransactionAvailableEventArgs transactionAvailableEvent = new TransactionAvailableEventArgs(actorName, transaction);

            if (OnTransactionAvailable != null)
            {
                OnTransactionAvailable(this, transactionAvailableEvent);
            }
        }
Пример #9
0
 /// <summary>
 /// Adds an object to the end of the <see cref="ActorsTransactionLog"/>.
 /// </summary>
 /// <param name="value">The <see cref="ActorsTransaction"/> to be added to the end of the <see cref="ActorsTransactionLog"/>.</param>
 /// <returns>The <see cref="ActorsTransactionLog"/> index at which the value has been added.</returns>
 public int Add(ActorsTransaction value)
 {
     return(List.Add(value));
 }
Пример #10
0
        private void LogTransaction()
        {
            DicomThread dicomThread = (DicomThread)DvtkHighLevelInterface.Common.Threads.Thread.CurrentThread;
            if (dicomThread == null) return;

            if (_currentDicomTransaction == null) return;

            // get the next transaction number - needed to sort the
            // transactions correctly
            int transactionNumber = TransactionNumber.GetNextTransactionNumber();

            // save the transaction
            ActorsTransaction actorsTransaction = new ActorsTransaction(transactionNumber,
                ActorName,  // from actor
                ParentActor.ActorName,  // to actor
                _currentDicomTransaction,
                dicomThread.Options.ResultsFileNameOnly,
                dicomThread.Options.ResultsFullFileName,
                (uint)dicomThread.NrOfErrors,
                (uint)dicomThread.NrOfWarnings);

            // save the transaction in the Actor log
            ParentActor.ActorsTransactionLog.Add(actorsTransaction);

            // publish the transaction event to any interested parties
            PublishTransactionAvailableEvent(ActorName, actorsTransaction);

            // remove any messages from the dicom thread
            dicomThread.ClearMessages();

            _currentDicomTransaction = null;
        }
Пример #11
0
 public abstract bool Evaluate(ActorsTransaction actorsTransaction);
Пример #12
0
 /// <summary>
 /// Searches for the specified <see cref="ActorsTransaction"/> and
 /// returns the zero-based index of the first occurrence within the entire <see cref="ActorsTransactionLog"/>.
 /// </summary>
 /// <param name="value">The <see cref="ActorsTransaction"/> to locate in the <see cref="ActorsTransactionLog"/>.</param>
 /// <returns>
 /// The zero-based index of the first occurrence of value within the entire <see cref="ActorsTransactionLog"/>,
 /// if found; otherwise, -1.
 /// </returns>
 public int IndexOf(ActorsTransaction value)
 {
     return(List.IndexOf(value));
 }
Пример #13
0
 /// <summary>
 /// Searches for the specified <see cref="ActorsTransaction"/> and 
 /// returns the zero-based index of the first occurrence within the entire <see cref="ActorsTransactionLog"/>.
 /// </summary>
 /// <param name="value">The <see cref="ActorsTransaction"/> to locate in the <see cref="ActorsTransactionLog"/>.</param>
 /// <returns>
 /// The zero-based index of the first occurrence of value within the entire <see cref="ActorsTransactionLog"/>, 
 /// if found; otherwise, -1.
 /// </returns>
 public int IndexOf(ActorsTransaction value)
 {
     return (List.IndexOf(value));
 }
Пример #14
0
 /// <summary>
 /// Copies the elements of the <see cref="ICollection"/> to a strong-typed <c>ActorsTransaction[]</c>, 
 /// starting at a particular <c>ActorsTransaction[]</c> index.
 /// </summary>
 /// <param name="array">
 /// The one-dimensional <c>ActorsTransaction[]</c> that is the destination of the elements 
 /// copied from <see cref="ICollection"/>.
 /// The <c>ActorsTransaction[]</c> must have zero-based indexing. 
 /// </param>
 /// <param name="index">
 /// The zero-based index in array at which copying begins.
 /// </param>
 /// <remarks>
 /// Provides the strongly typed member for <see cref="ICollection"/>.
 /// </remarks>
 public void CopyTo(ActorsTransaction[] array, int index)
 {
     ((ICollection)this).CopyTo(array, index);
 }
Пример #15
0
 /// <summary>
 /// Determines whether the <see cref="ActorsTransactionLog"/> contains a specific element.
 /// </summary>
 /// <param name="value">The <see cref="ActorsTransaction"/> to locate in the <see cref="ActorsTransactionLog"/>.</param>
 /// <returns>
 /// <c>true</c> if the <see cref="ActorsTransactionLog"/> contains the specified value; 
 /// otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(ActorsTransaction value)
 {
     // If value is not of type Code, this will return false.
     return (List.Contains(value));
 }
Пример #16
0
 /// <summary>
 /// Removes the first occurrence of a specific <see cref="ActorsTransaction"/> from the <see cref="ActorsTransactionLog"/>.
 /// </summary>
 /// <param name="value">The <see cref="ActorsTransaction"/> to remove from the <see cref="ActorsTransactionLog"/>.</param>
 public void Remove(ActorsTransaction value)
 {
     List.Remove(value);
 }
Пример #17
0
 /// <summary>
 /// Inserts an <see cref="ActorsTransaction"/> element into the <see cref="ActorsTransactionLog"/> at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which value should be inserted.</param>
 /// <param name="value">The <see cref="ActorsTransaction"/> to insert.</param>
 public void Insert(int index, ActorsTransaction value)
 {
     List.Insert(index, value);
 }
Пример #18
0
 /// <summary>
 /// Removes the first occurrence of a specific <see cref="ActorsTransaction"/> from the <see cref="ActorsTransactionLog"/>.
 /// </summary>
 /// <param name="value">The <see cref="ActorsTransaction"/> to remove from the <see cref="ActorsTransactionLog"/>.</param>
 public void Remove(ActorsTransaction value)
 {
     List.Remove(value);
 }
Пример #19
0
 /// <summary>
 /// Adds an object to the end of the <see cref="ActorsTransactionLog"/>.
 /// </summary>
 /// <param name="value">The <see cref="ActorsTransaction"/> to be added to the end of the <see cref="ActorsTransactionLog"/>.</param>
 /// <returns>The <see cref="ActorsTransactionLog"/> index at which the value has been added.</returns>
 public int Add(ActorsTransaction value)
 {
     return (List.Add(value));
 }
Пример #20
0
        private void LogTransaction()
        {
            DicomThread dicomThread = (DicomThread)DvtkHighLevelInterface.Common.Threads.Thread.CurrentThread;
            if (dicomThread == null) return;

            if (_currentDicomTransaction == null) return;

            // save the transaction
            ActorsTransaction actorsTransaction = new ActorsTransaction(_transactionNumber,
                _dicomClient.ActorName, // from actor
                _dicomClient.ParentActor.ActorName,  // to actor
                _currentDicomTransaction,
                this.Options.ResultsFileNameOnly,
                this.Options.ResultsFullFileName,
                (uint)dicomThread.NrOfErrors,
                (uint)dicomThread.NrOfWarnings);

            // save the transaction in the Actor log
            _dicomClient.ParentActor.ActorsTransactionLog.Add(actorsTransaction);

            // publish the transaction event to any interested parties
            _dicomClient.PublishTransactionAvailableEvent(_dicomClient.ActorName, actorsTransaction);

            // remove any messages from the dicom thread
            dicomThread.ClearMessages();

            _currentDicomTransaction = null;
        }
Пример #21
0
 /// <summary>
 /// Determines whether the <see cref="ActorsTransactionLog"/> contains a specific element.
 /// </summary>
 /// <param name="value">The <see cref="ActorsTransaction"/> to locate in the <see cref="ActorsTransactionLog"/>.</param>
 /// <returns>
 /// <c>true</c> if the <see cref="ActorsTransactionLog"/> contains the specified value;
 /// otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(ActorsTransaction value)
 {
     // If value is not of type Code, this will return false.
     return(List.Contains(value));
 }