コード例 #1
0
ファイル: MainForm.cs プロジェクト: simplygreenzhu/CFX
        public MainForm()
        {
            InitializeComponent();

            theEndpoint              = new AmqpCFXEndpoint();
            txtCFXHandle.Text        = Properties.Settings.Default.CFXHandle;
            txtTransmitChannels.Text = Properties.Settings.Default.TransmitChannels;
            txtReceiveChannels.Text  = Properties.Settings.Default.ReceiveChannels;
            txtRequestPort.Text      = Properties.Settings.Default.RequestPort;
            reqUri.Text              = Properties.Settings.Default.RequestTargetUri;
            reqHandle.Text           = Properties.Settings.Default.RequestTargetHandle;
            reqUsername.Text         = Properties.Settings.Default.RequestUsername;
            reqPassword.Text         = Properties.Settings.Default.RequestPassword;
            //txtReceiveChannels.Text = Utilities.GetNextEndpointReceiveChannel();

            //CFXExampleGenerator gen = new CFXExampleGenerator();
            //string result = gen.GenerateAll();
            //File.WriteAllText(@"c:\Code\Git\CFX\Documentation\Help\CFX_JSON_Examples.txt", result, Encoding.UTF8);
            //return;

            if (!string.IsNullOrWhiteSpace(CFXHandle))
            {
                OpenEndpoint();
            }

            RefreshControls();

            //CFX.Utilities.AppLog.LoggingEnabled = true;
            //CFX.Utilities.AppLog.LogFilePath = @"c:\jjwtemp\CFXDiagLog.txt";
            //CFX.Utilities.AppLog.LoggingLevel = CFX.Utilities.LogMessageType.Error | CFX.Utilities.LogMessageType.Info
            //                                    | CFX.Utilities.LogMessageType.Debug | CFX.Utilities.LogMessageType.Warn;
        }
コード例 #2
0
        public void OpenEndpoint()
        {
            CloseEndpoint();

            CFX.Utilities.AppLog.LoggingEnabled   = true;
            CFX.Utilities.AppLog.LoggingLevel     = CFX.Utilities.LogMessageType.Debug | CFX.Utilities.LogMessageType.Info | CFX.Utilities.LogMessageType.Error | CFX.Utilities.LogMessageType.Warn;
            CFX.Utilities.AppLog.AmqpTraceEnabled = true;
            //AmqpCFXEndpoint.MaxMessagesPerTransmit = 1;

            theEndpoint = new AmqpCFXEndpoint();
            theEndpoint.Open(CFXHandle, RequestUri);
            theEndpoint.OnCFXMessageReceived -= TheEndpoint_OnCFXMessageReceived;
            theEndpoint.OnCFXMessageReceived += TheEndpoint_OnCFXMessageReceived;
            theEndpoint.OnRequestReceived    -= TheEndpoint_OnRequestReceived;
            theEndpoint.OnRequestReceived    += TheEndpoint_OnRequestReceived;

            //X509Certificate cert = AmqpUtilities.GetCertificate("aishqcfx01v");
            X509Certificate cert = null;

            foreach (AmqpChannelAddress addr in TransmitChannels)
            {
                theEndpoint.AddPublishChannel(addr, AuthenticationMode.Auto, cert);
            }

            foreach (AmqpChannelAddress addr in ReceiveChannels)
            {
                theEndpoint.AddSubscribeChannel(addr, AuthenticationMode.Auto, cert);
            }
        }
コード例 #3
0
ファイル: BrokerTests.cs プロジェクト: oezguer-cirakoglu/CFX
        private void SetupEndpoint(bool auth, bool sec, bool useAltHost)
        {
            KillEndpoint();

            endpoint = new AmqpCFXEndpoint();
            endpoint.ValidateCertificates = false;
            endpoint.Open(TestSettings.ClientHandle, certificate: TestSettings.GetCertificate(sec));

            string virtualHost = null;

            if (useAltHost)
            {
                virtualHost = TestSettings.BrokerVirtualHost;
            }

            Exception ex  = null;
            Uri       uri = TestSettings.GetBrokerUri(auth, sec);

            if (!endpoint.TestPublishChannel(uri, TestSettings.BrokerExchange, out ex, virtualHost))
            {
                throw new Exception($"Cannot connect to broker at {uri.ToString()}, Exchange {TestSettings.BrokerExchange}:  {ex.Message}", ex);
            }

            endpoint.AddPublishChannel(uri, TestSettings.BrokerExchange, TestSettings.BrokerVirtualHost);
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: schwagdawg/CFX
        public MainForm()
        {
            InitializeComponent();

            theEndpoint              = new AmqpCFXEndpoint();
            txtCFXHandle.Text        = Properties.Settings.Default.CFXHandle;
            txtTransmitChannels.Text = Properties.Settings.Default.TransmitChannels;
            txtReceiveChannels.Text  = Properties.Settings.Default.ReceiveChannels;
            txtRequestUri.Text       = Properties.Settings.Default.RequestUri;
            reqUri.Text              = Properties.Settings.Default.RequestTargetUri;
            reqHandle.Text           = Properties.Settings.Default.RequestTargetHandle;
            reqUsername.Text         = Properties.Settings.Default.RequestUsername;
            reqPassword.Text         = Properties.Settings.Default.RequestPassword;

            CFXExampleGenerator gen = new CFXExampleGenerator();
            string result           = gen.GenerateAll();

            File.WriteAllText(CFX_JSON_Examples, result, Encoding.UTF8);
            return;

            if (!string.IsNullOrWhiteSpace(CFXHandle))
            {
                OpenEndpoint();
            }

            RefreshControls();

            CFX.Utilities.AppLog.LoggingEnabled = true;
            CFX.Utilities.AppLog.LogFilePath    = LogFilePath;
            //CFX.Utilities.AppLog.AmqpTraceEnabled = false;
            CFX.Utilities.AppLog.LoggingLevel = CFX.Utilities.LogMessageType.Error | CFX.Utilities.LogMessageType.Info | CFX.Utilities.LogMessageType.Debug | CFX.Utilities.LogMessageType.Warn;
        }
コード例 #5
0
ファイル: DirectConnectTests.cs プロジェクト: xietielong/CFX
        private void SetupEndpoint(bool auth, bool sec)
        {
            KillEndpoint();

            endpoint = new AmqpCFXEndpoint();
            endpoint.Open(TestSettings.ClientHandle, certificate: TestSettings.GetCertificate(sec));
            endpoint.ValidateCertificates = false;

            //CFX.Utilities.AppLog.LoggingEnabled = true;
            //CFX.Utilities.AppLog.LogFilePath = @"c:\stuff\cfxlog.txt";
            //CFX.Utilities.AppLog.LoggingLevel = CFX.Utilities.LogMessageType.Debug | CFX.Utilities.LogMessageType.Error | CFX.Utilities.LogMessageType.Info | CFX.Utilities.LogMessageType.Warn;
            //CFX.Utilities.AppLog.LoggingLevel = CFX.Utilities.LogMessageType.Error | CFX.Utilities.LogMessageType.Warn;
            //CFX.Utilities.AppLog.AmqpTraceEnabled = true;

            //AmqpCFXEndpoint.MaxFrameSize = 1000000;

            Exception ex  = null;
            Uri       uri = TestSettings.GetListenerUri(auth, sec);

            if (!endpoint.TestPublishChannel(uri, TestSettings.ListenerAddress, out ex))
            {
                throw new Exception($"Cannot connect to listener at {uri.ToString()}:  {ex.Message}", ex);
            }

            endpoint.AddPublishChannel(uri, TestSettings.ListenerAddress);
        }
コード例 #6
0
ファイル: BrokerTests.cs プロジェクト: schwagdawg/CFX
        private void SetupListener(bool auth, bool sec, bool useAltHost)
        {
            KillListener();

            listener = new AmqpCFXEndpoint();
            listener.ValidateCertificates = true;
            listener.Open(TestSettings.ClientHandle, certificate: TestSettings.GetCertificate(sec));
            listener.OnCFXMessageReceived += Listener_OnCFXMessageReceived;

            string virtualHost = null;

            if (useAltHost)
            {
                virtualHost = TestSettings.BrokerVirtualHost;
            }

            Exception ex  = null;
            Uri       uri = TestSettings.GetBrokerUri(auth, sec);

            if (!listener.TestSubscribeChannel(uri, TestSettings.BrokerQueue, out ex, virtualHost, TestSettings.GetCertificate(sec)))
            {
                throw new Exception($"Cannot subscribe to broker at {uri.ToString()}, Queue {TestSettings.BrokerQueue}:  {ex.Message}", ex);
            }

            listener.AddSubscribeChannel(uri, TestSettings.BrokerQueue, virtualHost, TestSettings.GetCertificate(sec));
        }
コード例 #7
0
ファイル: BrokerTests.cs プロジェクト: schwagdawg/CFX
        private void SetupEndpoint(bool auth, bool sec, bool useAltHost)
        {
            KillEndpoint();

            //CFX.Utilities.AppLog.LoggingEnabled = true;
            //CFX.Utilities.AppLog.LogFilePath = @"c:\stuff\cfxlog.txt";
            //CFX.Utilities.AppLog.LoggingLevel = CFX.Utilities.LogMessageType.Debug | CFX.Utilities.LogMessageType.Error | CFX.Utilities.LogMessageType.Info | CFX.Utilities.LogMessageType.Warn;
            //CFX.Utilities.AppLog.LoggingLevel = CFX.Utilities.LogMessageType.Error | CFX.Utilities.LogMessageType.Warn;
            //CFX.Utilities.AppLog.AmqpTraceEnabled = true;

            endpoint = new AmqpCFXEndpoint();
            endpoint.ValidateCertificates = false;
            endpoint.Open(TestSettings.ClientHandle, certificate: TestSettings.GetCertificate(sec));

            string virtualHost = null;

            if (useAltHost)
            {
                virtualHost = TestSettings.BrokerVirtualHost;
            }

            Exception ex  = null;
            Uri       uri = TestSettings.GetBrokerUri(auth, sec);

            if (!endpoint.TestPublishChannel(uri, TestSettings.BrokerExchange, out ex, virtualHost))  //, TestSettings.GetCertificate(sec)))
            {
                throw new Exception($"Cannot connect to broker at {uri.ToString()}, Exchange {TestSettings.BrokerExchange}:  {ex.Message}", ex);
            }

            endpoint.AddPublishChannel(uri, TestSettings.BrokerExchange, virtualHost, TestSettings.GetCertificate(sec));
        }
コード例 #8
0
        public void SecureMessages()
        {
            AmqpCFXEndpoint endpoint = new AmqpCFXEndpoint();

            endpoint.Open("Vendor1.Model1.Machine34");

            // Note the user of "amqps://" instead of "amqp://"
            // Uri uri = new Uri("amqps://mycfxbroker.mydomain.com");

            // Encode your username and password into the destination Uri
            string username = "******";
            string password = "******";
            string hostname = "mycfxbroker.mydomain.com";

            //  eg.  amqps://myusername:[email protected]
            Uri uri = new Uri(string.Format("amqps://{0}:{1}@{2}", username, password, hostname));

            // Target exchange on broker (shown here in RabbitMQ compatible format)
            string amqpTarget = "/exchange/myexchange";

            endpoint.AddPublishChannel(uri, amqpTarget);

            // Source queue on broker (shown here in RabbitMQ compatible format)
            string amqpSource = "/queue/myqueue";

            endpoint.AddSubscribeChannel(uri, amqpSource);
        }
コード例 #9
0
ファイル: BrokerTests.cs プロジェクト: schwagdawg/CFX
 private void KillEndpoint()
 {
     if (endpoint != null)
     {
         endpoint.Close();
         endpoint = null;
     }
 }
コード例 #10
0
 public void CloseBrokerSubscription()
 {
     if (endpoint != null)
     {
         endpoint.Close();
         endpoint = null;
     }
 }
コード例 #11
0
ファイル: BrokerTests.cs プロジェクト: schwagdawg/CFX
 private void KillListener()
 {
     if (listener != null)
     {
         listener.Close();
         listener = null;
     }
 }
コード例 #12
0
        public void OpenEndpoint()
        {
            endpoint     = new AmqpCFXEndpoint();
            myRequestUri = new Uri(string.Format("amqp://{0}", System.Net.Dns.GetHostName()));

            endpoint.OnRequestReceived += Endpoint_OnRequestReceived;
            endpoint.Open(myCFXHandle, myRequestUri);
        }
コード例 #13
0
ファイル: Form1.cs プロジェクト: simplygreenzhu/CFX
 private void btnClose_Click(object sender, EventArgs e)
 {
     btnSend.Enabled = false;
     if (theEndpoint != null)
     {
         theEndpoint.Close();
         theEndpoint = null;
     }
 }
コード例 #14
0
        public void OpenEndpointSecure()
        {
            endpoint     = new AmqpCFXEndpoint();
            myRequestUri = new Uri(string.Format("amqps://{0}", System.Net.Dns.GetHostName()));

            // Load certificate from local machine or user certificate store
            X509Certificate2 cert = AmqpUtilities.GetCertificate("MyCertificateName");

            endpoint.OnRequestReceived += Endpoint_OnRequestReceived;
            endpoint.Open(myCFXHandle, myRequestUri, cert);
        }
コード例 #15
0
        public void EstablishBrokerSubscription()
        {
            string myCFXHandle   = "Vendor1.Model1.Machine1234";
            string myBrokerUri   = "amqp://mybroker:5672";
            string myBrokerQueue = "/queue/EventQueue1";

            endpoint = new AmqpCFXEndpoint();
            endpoint.OnCFXMessageReceived += Endpoint_OnCFXMessageReceived;
            endpoint.Open(myCFXHandle);
            endpoint.AddSubscribeChannel(new Uri(myBrokerUri), myBrokerQueue);
        }
コード例 #16
0
ファイル: DirectConnectTests.cs プロジェクト: xietielong/CFX
        private void SetupListener(bool auth, bool sec)
        {
            KillListener();

            listener = new AmqpCFXEndpoint();
            listener.Open(TestSettings.ListenerHandle, TestSettings.GetListenerUri(auth, sec), certificate: TestSettings.GetCertificate(sec));
            listener.OnCFXMessageReceivedFromListener += Listener_OnCFXMessageReceivedFromListener;
            listener.OnRequestReceived += Listener_OnRequestReceived;

            listener.AddListener(TestSettings.ListenerAddress);
        }
コード例 #17
0
ファイル: Form1.cs プロジェクト: simplygreenzhu/CFX
        private void btnOpen_Click(object sender, EventArgs e)
        {
            if (theEndpoint != null)
            {
                btnClose_Click(sender, e);
            }

            theEndpoint = new AmqpCFXEndpoint();
            theEndpoint.Open("MyHandle-" + Guid.NewGuid().ToString());
            theEndpoint.AddPublishChannel(new Uri("amqp://cfx.aiscorp.com:5672"), "/exchange/AegisCloud");
            btnSend.Enabled = true;
        }
コード例 #18
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            if (theEndpoint != null)
            {
                btnClose_Click(sender, e);
            }

            theEndpoint = new AmqpCFXEndpoint();
            theEndpoint.Open(myHandle);
            theEndpoint.AddPublishChannel(new Uri(myBroker), myExchange);
            btnSend.Enabled = true;
        }
コード例 #19
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            Exception       ex;
            AmqpCFXEndpoint endPoint = new AmqpCFXEndpoint();

            if (!endPoint.TestChannel(new Uri(txtAddress.Text), out ex))
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("Connection Successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #20
0
        private void OpenEndpoint()
        {
            CloseEndpoint();    // Just in case already open

            // Initialize Diagnostic Logging (messages will appear in Debug Output Window)
            // You can also use write diagnostic messages to a file by specifying the
            // CFX.Utilities.AppLog.LogFilePath property.  Set to the full path and filename
            // of your log file (folder must already exist).
            CFX.Utilities.AppLog.LoggingEnabled   = true;
            CFX.Utilities.AppLog.AmqpTraceEnabled = true;
            CFX.Utilities.AppLog.LoggingLevel     = CFX.Utilities.LogMessageType.Debug
                                                    | CFX.Utilities.LogMessageType.Error
                                                    | CFX.Utilities.LogMessageType.Info
                                                    | CFX.Utilities.LogMessageType.Warn;

            // Create endpoint, and initialize with you CFX handle.
            // Endpoints DO NOT need to receive and process requests for the show,
            // they only need to MAKE requests.  So, no need to specify request processor.
            MyEndpoint = new AmqpCFXEndpoint();
            MyEndpoint.Open(MyCFXHandle);

            // Test to make sure you have connectivity to the CFX Demo broker.
            Exception ex = null;

            if (!MyEndpoint.TestPublishChannel(CFXDemoEventBroker, CFXDemoEventBrokerExchange, out ex))
            {
                // Problem connecting.
                AddToResults($"ERROR:  Unable to connect to broker {CFXDemoEventBroker} Exchange {CFXDemoEventBrokerExchange}\nERROR MESSAGE:  {ex.Message}");
                CloseEndpoint();
                return;
            }
            else
            {
                AddToResults("CONNECTION TO BROKER SUCCESSFUL");
            }

            // Add a publish channel to the CFX Demo broker.  All "Event" type messages
            // will be published to this channel
            MyEndpoint.AddPublishChannel(new Uri("amqp://cfxbroker.connectedfactoryexchange.com"), "/exchange/AegisCloud");

            // Set request timeout to 30 seconds
            AmqpCFXEndpoint.RequestTimeout = TimeSpan.FromSeconds(30);

            // Update buttons
            RefreshUI();
        }
コード例 #21
0
        public void HeartbeatTest()
        {
            string          handle = "Aegis.CFXSimulator.Machine1";
            AmqpCFXEndpoint ep     = new AmqpCFXEndpoint();

            ep.HeartbeatFrequency = TimeSpan.FromSeconds(4);
            ep.Open(handle);
            ep.AddPublishChannel(new Uri("amqp://cfxbroker.connectedfactoryexchange.com"), "/exchange/AegisCloud");
            //ep.Publish(new CFX.EndpointConnected() { CFXHandle = handle });

            DateTime start = DateTime.Now;

            while ((DateTime.Now - start) < TimeSpan.FromSeconds(30))
            {
                System.Threading.Thread.Sleep(1);
            }
        }
コード例 #22
0
        private void SetupEndpoint(bool auth, bool sec)
        {
            KillEndpoint();

            endpoint = new AmqpCFXEndpoint();
            endpoint.Open(TestSettings.ClientHandle, certificate: TestSettings.GetCertificate(sec));
            endpoint.ValidateCertificates = false;

            Exception ex  = null;
            Uri       uri = TestSettings.GetListenerUri(auth, sec);

            if (!endpoint.TestPublishChannel(uri, TestSettings.ListenerAddress, out ex))
            {
                throw new Exception($"Cannot connect to listener at {uri.ToString()}:  {ex.Message}", ex);
            }

            endpoint.AddPublishChannel(uri, TestSettings.ListenerAddress);
        }
コード例 #23
0
ファイル: MainForm.cs プロジェクト: oezguer-cirakoglu/CFX
        public void OpenEndpoint()
        {
            CloseEndpoint();

            //AmqpCFXEndpoint.MaxMessagesPerTransmit = 1;

            try
            {
                theEndpoint = new AmqpCFXEndpoint();

                X509Certificate2 requestCert = null;
                if (RequestUri?.Scheme.ToLower() == "amqps")
                {
                    requestCert = AmqpUtilities.GetCertificate("aishqcfx01v");
                }

                theEndpoint.Open(CFXHandle, RequestUri, certificate: requestCert);
                theEndpoint.OnCFXMessageReceived -= TheEndpoint_OnCFXMessageReceived;
                theEndpoint.OnCFXMessageReceived += TheEndpoint_OnCFXMessageReceived;
                theEndpoint.OnRequestReceived    -= TheEndpoint_OnRequestReceived;
                theEndpoint.OnRequestReceived    += TheEndpoint_OnRequestReceived;

                //X509Certificate cert = AmqpUtilities.GetCertificate("aishqcfx01v");
                X509Certificate cert = null;
                //string virtualHostName = "vhost:/jjwtesthost";
                string virtualHostName = null;

                foreach (AmqpChannelAddress addr in TransmitChannels)
                {
                    theEndpoint.AddPublishChannel(addr, virtualHostName, cert);
                }

                foreach (AmqpChannelAddress addr in ReceiveChannels)
                {
                    theEndpoint.AddSubscribeChannel(addr, virtualHostName, cert);
                }
            }
            catch (Exception ex)
            {
                lstResults.Items.Insert(0, "Exception Opening Endpoint:  " + ex.Message);
            }
        }
コード例 #24
0
ファイル: MainForm.cs プロジェクト: simplygreenzhu/CFX
        public void OpenEndpoint()
        {
            CloseEndpoint();

            theEndpoint = new AmqpCFXEndpoint();
            theEndpoint.Open(CFXHandle, RequestUri);
            theEndpoint.OnCFXMessageReceived -= TheEndpoint_OnCFXMessageReceived;
            theEndpoint.OnCFXMessageReceived += TheEndpoint_OnCFXMessageReceived;
            theEndpoint.OnRequestReceived    -= TheEndpoint_OnRequestReceived;
            theEndpoint.OnRequestReceived    += TheEndpoint_OnRequestReceived;

            foreach (AmqpChannelAddress addr in TransmitChannels)
            {
                theEndpoint.AddPublishChannel(addr);
            }

            foreach (AmqpChannelAddress addr in ReceiveChannels)
            {
                theEndpoint.AddSubscribeChannel(addr);
            }
        }
コード例 #25
0
        public void MakingRequests()
        {
            string myCFXHandle = "Vendor1.Model1.Machine34";

            AmqpCFXEndpoint endpoint = new AmqpCFXEndpoint();

            endpoint.Open(myCFXHandle);

            string targetEndpointHostname = "machine55.mydomain.com";
            string targetCFXHandle        = "Vendor2.Model2.Machine55";
            string remoteUri = string.Format("amqp://{0}", targetEndpointHostname);

            // Set a timeout of 20 seconds.  If the target endpoint does not
            // respond in this time, the request will time out.
            AmqpCFXEndpoint.RequestTimeout = TimeSpan.FromSeconds(20);

            // Build a GetEndpointInfomation Request
            CFXEnvelope request = CFXEnvelope.FromCFXMessage(new GetEndpointInformationRequest()
            {
                CFXHandle = targetCFXHandle
            });

            CFXEnvelope response = endpoint.ExecuteRequest(remoteUri, request);
        }
コード例 #26
0
        public void MalformedTest()
        {
            CFX.Utilities.AppLog.LoggingEnabled = true;
            CFX.Utilities.AppLog.LoggingLevel   = LogMessageType.All;
            //CFX.Utilities.AppLog.AmqpTraceEnabled = true;
            CFX.Utilities.AppLog.OnTraceMessage += AppLog_OnTraceMessage;


            string          handle = "Aegis.CFXSimulator.Machine1";
            AmqpCFXEndpoint ep     = new AmqpCFXEndpoint();

            ep.HeartbeatFrequency = TimeSpan.FromSeconds(4);
            ep.Open(handle);
            ep.OnCFXMessageReceived       += Ep_OnCFXMessageReceived;
            ep.OnMalformedMessageReceived += Ep_OnMalformedMessageReceived;
            ep.AddSubscribeChannel(new Uri("amqp://cfxbroker.connectedfactoryexchange.com"), "/queue/JJWTestQueue");

            DateTime start = DateTime.Now;

            while ((DateTime.Now - start) < TimeSpan.FromSeconds(30))
            {
                System.Threading.Thread.Sleep(1);
            }
        }
コード例 #27
0
        public void ReplayEvents()
        {
            CFX.Utilities.AppLog.LoggingEnabled = true;
            CFX.Utilities.AppLog.LoggingLevel   = LogMessageType.All;
            //CFX.Utilities.AppLog.AmqpTraceEnabled = true;
            CFX.Utilities.AppLog.OnTraceMessage += AppLog_OnTraceMessage;


            string          handle = "Heller.Reflow.1809-Booth";
            AmqpCFXEndpoint ep     = new AmqpCFXEndpoint();

            ep.HeartbeatFrequency = TimeSpan.FromSeconds(4);
            ep.Open(handle);
            ep.AddPublishChannel(new Uri("amqp://cfxbroker.connectedfactoryexchange.com"), "/exchange/AegisCloud");

            string fileName = @"d:\stuff\TestData.json";
            string file;

            using (StreamReader reader = new StreamReader(fileName))
            {
                file = reader.ReadToEnd();
            }

            string        message     = null;
            int           startPos    = 0;
            DateTime?     startTime   = null;
            DateTime      actualStart = DateTime.Now;
            List <string> messages    = new List <string>();

            while ((message = GetNextMessage(file, ref startPos)) != null)
            {
                messages.Add(message);
            }

            messages.Reverse();

            foreach (string msg in messages)
            {
                CFXEnvelope env = CFXEnvelope.FromJson(msg);
                if (!startTime.HasValue)
                {
                    startTime = env.TimeStamp;
                }
                env.TimeStamp = actualStart + (env.TimeStamp - startTime.Value);

                if (env.MessageBody is WorkStarted || env.MessageBody is WorkCompleted)
                {
                    env.Source = handle;
                    if (env.MessageBody is WorkStarted)
                    {
                        //WorkStarted ws = env.MessageBody as WorkStarted;
                        //ws.Units = new List<CFX.Structures.UnitPosition>();
                        //ws.Units.Add(new CFX.Structures.UnitPosition() { PositionNumber = 1 });
                    }
                    ep.Publish(env);
                    //break;
                }
            }


            DateTime start = DateTime.Now;

            while ((DateTime.Now - start) < TimeSpan.FromSeconds(30))
            {
                System.Threading.Thread.Sleep(1);
            }
        }