コード例 #1
0
ファイル: Program.cs プロジェクト: NiclasOlofsson/HIE
		private Application CreateHl7Application(ApplicationHost pipelineManager)
		{
			Application application = new Application();

			// Endpoints

			{
				var receiveEndoint = new TcpReceiveEndpoint();
				TcpReceieveOptions options = new TcpReceieveOptions { Endpoint = new IPEndPoint(IPAddress.Any, 5678) };
				options.SohDelimiters = new byte[0];
				options.EotDelimiters = new byte[0];
				receiveEndoint.Initialize(_applicationHost, options);
				Port port = new Port { Endpoint = receiveEndoint };
				port.Assembers.Add(new Hl7Disassembler());
				application.Ports.Add(port);
			}
			{
				var sendEndpoint = new TcpSendEndpoint();
				TcpSendOptions options = new TcpSendOptions() { Endpoint = new IPEndPoint(IPAddress.Loopback, 8756) };
				options.SohDelimiters = new byte[0];
				options.EotDelimiters = new byte[0];
				sendEndpoint.Initialize(_applicationHost, options);
				Port port = new Port { Endpoint = sendEndpoint };
				port.Assembers.Add(new Hl7Assembler());
				application.Ports.Add(port);
			}
			{
				var fileEndpoint = new FileWriterEndpoint("service-output.txt", true, Encoding.UTF8, false);
				fileEndpoint.Initialize(_applicationHost, null);
				Port port = new Port { Endpoint = fileEndpoint };
				application.Ports.Add(port);
			}

			// Channels

			Channel channel = new Channel();
			channel.Source = new Source();
			application.Channels.Add(channel);

			{
				// This destination will transform the message
				Destination destination = new Destination();
				destination.Filters.Add(new DelegateFilter((src, message) => true));
				destination.Transformers.Add(new DelegateTransformer(TransformerTest));
				destination.Transformers.Add(new JavaScriptTransformer()
				{
					Script = @"

if(msg['MSH']['MSH.8'] != null) delete msg['MSH']['MSH.8'];
msg['MSH']['MSH.2'] = 'TEST';

"
				});
				channel.Destinations.Add(destination);
			}

			return application;
		}
コード例 #2
0
        public void BasicFileEndpointTest()
        {
            // A new application
            Application application = new Application();

            // Add endpoints
            string             filePath           = "test-file.txt";
            FileReaderEndpoint fileReaderEndpoint = new FileReaderEndpoint(filePath, 100, Encoding.Default);

            application.Ports.Add(new Port {
                Endpoint = fileReaderEndpoint
            });

            string             fileOutPath        = "test-file-out.txt";
            FileWriterEndpoint fileWriterEndpoint = new FileWriterEndpoint(fileOutPath, true, Encoding.Default, true);

            application.Ports.Add(new Port {
                Endpoint = fileWriterEndpoint
            });

            // Add a channel
            Channel channel = new Channel();

            application.Channels.Add(channel);

            // Source setup
            Source source = new Source();

            channel.Source = source;

            Destination destination = new Destination();

            destination.Target = fileWriterEndpoint;
            channel.Destinations.Add(destination);

            // Host
            ApplicationHost applicationHost = new ApplicationHost();

            applicationHost.Deploy(application);

            // Start the processing
            applicationHost.StartProcessing();
            fileReaderEndpoint.WaitForMessage();
            fileReaderEndpoint.WaitForMessage();

            // Check that endpoint wrote the message

            using (StreamReader reader = new StreamReader(fileOutPath))
            {
                string text = reader.ReadToEnd();
                Assert.AreEqual("Hello world!\nHello world!", text.Trim().Replace("\r\n", "\n"));
                reader.Close();
            }
        }
コード例 #3
0
		public void BasicFileEndpointTest()
		{
			// A new application
			Application application = new Application();

			// Add endpoints
			string filePath = "test-file.txt";
			FileReaderEndpoint fileReaderEndpoint = new FileReaderEndpoint(filePath, 100, Encoding.Default);
			application.Ports.Add(new Port { Endpoint = fileReaderEndpoint });

			string fileOutPath = "test-file-out.txt";
			FileWriterEndpoint fileWriterEndpoint = new FileWriterEndpoint(fileOutPath, true, Encoding.Default, true);
			application.Ports.Add(new Port { Endpoint = fileWriterEndpoint });

			// Add a channel
			Channel channel = new Channel();
			application.Channels.Add(channel);

			// Source setup
			Source source = new Source();
			channel.Source = source;

			Destination destination = new Destination();
			destination.Target = fileWriterEndpoint;
			channel.Destinations.Add(destination);

			// Host
			ApplicationHost applicationHost = new ApplicationHost();
			applicationHost.Deploy(application);

			// Start the processing
			applicationHost.StartProcessing();
			fileReaderEndpoint.WaitForMessage();
			fileReaderEndpoint.WaitForMessage();

			// Check that endpoint wrote the message

			using (StreamReader reader = new StreamReader(fileOutPath))
			{
				string text = reader.ReadToEnd();
				Assert.AreEqual("Hello world!\nHello world!", text.Trim().Replace("\r\n", "\n"));
				reader.Close();
			}
		}