示例#1
0
        private void MakeRequest(CFXEnvelope env)
        {
            CFXEnvelope response = null;

            try
            {
                response = MyEndpoint.ExecuteRequest(FactoryLogixMESEndpointUri, env);
            }
            catch (Exception ex)
            {
                AddToResults($"ERROR OCCURRED MAKING REQUEST TO {FactoryLogixMESEndpointUri}, handle {FactoryLogixMESEndpointHandle}.\nERROR MESSAGE:  {ex.Message} \n{ex.StackTrace}");
            }

            if (response.MessageBody is NotSupportedResponse)
            {
                NotSupportedResponse r = response.MessageBody as NotSupportedResponse;
                AddToResults($"NOT SUPPORTED RESPONSE: {r.RequestResult.ResultCode.ToString()}.\n{r.RequestResult.Message}");
            }
            else if (response.MessageBody is ValidateUnitsResponse)
            {
                ValidateUnitsResponse r = response.MessageBody as ValidateUnitsResponse;
                if (r.Result.Result != StatusResult.Success)
                {
                    AddToResults($"ERROR OCCURRED PROCESSING VALIDATATION REQUEST: {r.PrimaryResult.Result.ToString()}.\n{r.PrimaryResult.Message}");
                }
                else
                {
                    AddToResults($"VALIDATATION RESULT RECEIVED: {r.PrimaryResult.Result.ToString()}.\n{r.PrimaryResult.Message}");
                }
            }
            else
            {
                AddToResults($"UNEXPLAINED RESPONSE:  {response.MessageName}\n{response.ToJson(true)}");
            }
        }
示例#2
0
 private void ReportAddition(MyEndpoint client)
 {
     if (client != null && !clientsListView.Items.Contains(client))
     {
         clientsListView.Items.Add(client);
     }
 }
示例#3
0
 public SendingWindow(MyServer server, MyEndpoint SelectedClient, string FilePath)
 {
     this.FilePath       = FilePath;
     this.server         = server;
     this.SelectedClient = SelectedClient;
     InitializeComponent();
     StartSending();
 }
示例#4
0
        private void CloseEndpoint()
        {
            if (MyEndpoint != null)
            {
                MyEndpoint.Close();
                MyEndpoint = null;
            }

            RefreshUI();
        }
示例#5
0
        public void IsPartOfRouteTemplate_ReturnsFalse_ForNonRouteEndpoint()
        {
            // Arrange
            MyEndpoint endpoint = new MyEndpoint(c => Task.CompletedTask, EndpointMetadataCollection.Empty, "test");

            ODataTemplateTranslateContext translateContext = new ODataTemplateTranslateContext
            {
                Endpoint = endpoint
            };

            // Act
            bool actual = translateContext.IsPartOfRouteTemplate("/{key}");

            // Assert
            Assert.False(actual);
        }
示例#6
0
        private void SendStateChange()
        {
            if (!IsOpen)
            {
                return;
            }

            TimeSpan duration = TimeSpan.FromSeconds(1);

            if (LastStateChange != DateTime.MinValue)
            {
                duration        = LastStateChange - DateTime.Now;
                LastStateChange = DateTime.Now;
            }

            ResourceState oldState = LastState;
            ResourceState newState = ResourceState.USD;

            if (oldState == ResourceState.USD)
            {
                newState = ResourceState.PRD;
            }
            else
            {
                newState = ResourceState.USD;
            }

            LastState = newState;

            // Create a CFXEnvelope containing a new StationStateChanged message
            CFXEnvelope env = new CFXEnvelope(new StationStateChanged()
            {
                OldState         = oldState,
                NewState         = newState,
                OldStateDuration = duration,
            });

            // Publish the message.
            MyEndpoint.Publish(env);

            AddToResults($"MESSAGE PUBLISHED:\n {env.ToJson(true)}");
        }