/// <summary>
        /// Activate or deactivate an endpoint
        /// </summary>
        /// <param name="endpointId"></param>
        /// <param name="checkedValue"></param>
        /// <returns></returns>
        private async Task SetActivationAsync(EndpointInfo endpoint)
        {
            string endpointId = endpoint.EndpointModel.Registration.Id;

            if (!IsEndpointActivated(endpoint))
            {
                try {
                    await RegistryService.ActivateEndpointAsync(endpointId);
                }
                catch (Exception e) {
                    if (e.Message.Contains("404103"))
                    {
                        Status = "The endpoint is not available.";
                    }
                    else
                    {
                        Status = e.Message;
                    }
                }
            }
            else
            {
                try {
                    await RegistryService.DeactivateEndpointAsync(endpointId);
                }
                catch (Exception e) {
                    Status = e.Message;
                }
            }
        }
        public async Task <ActionResult> Activate(string endpointId)
        {
            OpcSessionModel sessionModel = new OpcSessionModel {
                EndpointId = endpointId
            };

            try
            {
                await RegistryService.ActivateEndpointAsync(endpointId);
            }
            catch (Exception exception)
            {
                // Generate an error to be shown in the error view and trace    .
                string errorMessageTrace = string.Format(Strings.BrowserConnectException, exception.Message,
                                                         exception.InnerException?.Message ?? "--", exception?.StackTrace ?? "--");
                Trace.TraceError(errorMessageTrace);
                if (exception.Message.Contains("ResourceNotFound"))
                {
                    sessionModel.ErrorHeader = Strings.BrowserEndpointErrorHeader;
                }
                else
                {
                    sessionModel.ErrorHeader = Strings.BrowserConnectErrorHeader;
                }
                return(Json(sessionModel));
            }

            Session["EndpointId"] = endpointId;
            return(Json(sessionModel));
        }
Beispiel #3
0
        /// <summary>
        /// Activate or deactivate an endpoint
        /// </summary>
        /// <param name="endpointId"></param>
        /// <param name="checkedValue"></param>
        /// <returns></returns>
        private async Task SetActivationAsync(EndpointInfo endpoint)
        {
            string endpointId = endpoint.EndpointModel.Registration.Id;

            if (!IsEndpointActivated(endpoint))
            {
                try {
                    await RegistryService.ActivateEndpointAsync(endpointId);
                }
                catch (Exception e) {
                    Status = e.Message;
                }
            }
            else
            {
                try {
                    await RegistryService.DeactivateEndpointAsync(endpointId);
                }
                catch (Exception e) {
                    Status = e.Message;
                }
            }
        }