static void Main(string[] args) { // sample #1: create an inbound HL7 consumer using MLLP frames over TCP/IP sockets BaseHL7Interface hl7InboundSocketInterface = new HL7InboundSocketInterface("Inbound Socket Sample", 2575); hl7InboundSocketInterface.MessageEvent += OnMessageEvent; hl7InboundSocketInterface.StatusEvent += OnStatusEvent; hl7InboundSocketInterface.ErrorEvent += OnErrorEvent; hl7InboundSocketInterface.SendAcknowledgements = false; hl7InboundSocketInterface.StartAsync(); // sample #2: create an outbound HL7 publisher using MLLP frames over TCP/IP sockets HL7OutboundSocketInterface hl7OutboundSocketInterface = new HL7OutboundSocketInterface("Outbound Socket Sample", "127.0.0.1", 2575); hl7OutboundSocketInterface.MessageEvent += OnMessageEvent; hl7OutboundSocketInterface.StatusEvent += OnStatusEvent; hl7OutboundSocketInterface.ErrorEvent += OnErrorEvent; hl7OutboundSocketInterface.StartAsync(); hl7OutboundSocketInterface.EnqueueMessage(GetSampleHL7Message()); // sample #3: create an inbound HL7 consmer using messages persisted to file system BaseHL7Interface hl7InboundFileSystemInterface = new HL7InboundFileSystemInterface("File System Sample", Environment.CurrentDirectory, "hl7"); hl7InboundFileSystemInterface.MessageEvent += OnMessageEvent; hl7InboundFileSystemInterface.StatusEvent += OnStatusEvent; hl7InboundFileSystemInterface.ErrorEvent += OnErrorEvent; hl7InboundFileSystemInterface.StartAsync(); // sample #4: show statistics for active interfaces Thread.Sleep(4000); // wait a few seconds for async processing to complete before reporting statistics InterfaceStatistics statistics = hl7InboundSocketInterface.Statistics; Console.WriteLine("[Statistics]: Interface Start Time: {0}", statistics.StartDateTime.ToString()); Console.WriteLine("[Statistics]: Interface Uptime: {0}s", statistics.UpTime.TotalSeconds); Console.WriteLine("[Statistics]: Interface Last Message: {0}", statistics.LastMessageDateTime.ToString()); foreach (KeyValuePair <string, int> messageSuccess in statistics.Successes) { Console.WriteLine("[Statistics]: Interface Message {0}: {1}", messageSuccess.Key, messageSuccess.Value); } Console.ReadKey(); hl7InboundSocketInterface.Stop(); hl7InboundFileSystemInterface.Stop(); hl7OutboundSocketInterface.Stop(); }
/// <summary> /// Adds the interface. /// </summary> /// <param name="intr">The interface statistics.</param> public void AddInterface(InterfaceStatistics intr) { myInterfaceList.Add(intr); }