/// <summary> /// Create service model from api model /// </summary> public static PublishStopRequestModel ToServiceModel(this PublishStopRequestApiModel model) { if (model == null) { return(null); } return(new PublishStopRequestModel { NodeId = model.NodeId, Header = model.Header?.ToServiceModel() }); }
public async Task <PublishStopResponseApiModel> StopPublishingValuesAsync( string endpointId, [FromBody][Required] PublishStopRequestApiModel request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var result = await _publisher.NodePublishStopAsync( endpointId, request.ToServiceModel()); return(result.ToApiModel()); }
/// <summary> /// Unpublish /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <PublishStopResponseApiModel> PublishStopAsync( PublishStopRequestApiModel request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var result = await _publisher.NodePublishStopAsync( _twin.Endpoint, request.ToServiceModel()); return(new PublishStopResponseApiModel(result)); }
/// <summary> /// StopPublishing /// </summary> /// <param name="endpointId"></param> /// <param name="nodeId"></param> /// <returns>ErrorStatus</returns> public async Task <bool> StopPublishing(string endpointId, string nodeId) { try { var requestApiModel = new PublishStopRequestApiModel() { NodeId = nodeId, }; var resultApiModel = await _publisherService.NodePublishStopAsync(endpointId, requestApiModel); return(resultApiModel.ErrorInfo == null); } catch (Exception e) { var errorMessage = string.Concat(e.Message, e.InnerException?.Message ?? "--", e?.StackTrace ?? "--"); Trace.TraceError(errorMessage); } return(false); }
/// <summary> /// StopPublishing /// </summary> /// <param name="endpointId"></param> /// <param name="nodeId"></param> /// <returns>ErrorStatus</returns> public async Task <bool> StopPublishingAsync(string endpointId, string nodeId, CredentialModel credential = null) { try { var requestApiModel = new PublishStopRequestApiModel() { NodeId = nodeId, }; requestApiModel.Header = Elevate(new RequestHeaderApiModel(), credential); var resultApiModel = await _publisherService.NodePublishStopAsync(endpointId, requestApiModel); return(resultApiModel.ErrorInfo == null); } catch (Exception e) { _logger.Error(e, "Cannot unpublish node {nodeId} on endpointId '{endpointId}'", nodeId, endpointId); } return(false); }
/// <summary> /// StopPublishing /// </summary> /// <param name="endpointId"></param> /// <param name="nodeId"></param> /// <returns>ErrorStatus</returns> public async Task <bool> StopPublishingAsync(string endpointId, string nodeId, CredentialModel credential = null) { try { var requestApiModel = new PublishStopRequestApiModel() { NodeId = nodeId, }; requestApiModel.Header = Elevate(new RequestHeaderApiModel(), credential); var resultApiModel = await _publisherService.NodePublishStopAsync(endpointId, requestApiModel); return(resultApiModel.ErrorInfo == null); } catch (Exception e) { var errorMessage = string.Concat(e.Message, e.InnerException?.Message ?? "--", e?.StackTrace ?? "--"); _logger.Error(errorMessage); } return(false); }
/// <inheritdoc/> public async Task <PublishStopResponseApiModel> NodePublishStopAsync(string endpointId, PublishStopRequestApiModel content, CancellationToken ct) { if (string.IsNullOrEmpty(endpointId)) { throw new ArgumentNullException(nameof(endpointId)); } if (content == null) { throw new ArgumentNullException(nameof(content)); } var request = _httpClient.NewRequest($"{_serviceUri}/v2/publish/{endpointId}/stop", _resourceId); request.SetContent(content); var response = await _httpClient.PostAsync(request, ct).ConfigureAwait(false); response.Validate(); return(response.GetContent <PublishStopResponseApiModel>()); }
/// <summary> /// Stop publishing node values /// </summary> /// <remarks> /// Stop publishing variable node values to IoT Hub. The endpoint must be /// activated and connected and the module client and server must trust each /// other. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='endpointId'> /// The identifier of the activated endpoint. /// </param> /// <param name='body'> /// The unpublish request /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <PublishStopResponseApiModel> StopPublishingValuesAsync(this IAzureOpcPublisherClient operations, string endpointId, PublishStopRequestApiModel body, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.StopPublishingValuesWithHttpMessagesAsync(endpointId, body, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Stop publishing node values /// </summary> /// <remarks> /// Stop publishing variable node values to IoT Hub. The endpoint must be /// activated and connected and the module client and server must trust each /// other. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='endpointId'> /// The identifier of the activated endpoint. /// </param> /// <param name='body'> /// The unpublish request /// </param> public static PublishStopResponseApiModel StopPublishingValues(this IAzureOpcPublisherClient operations, string endpointId, PublishStopRequestApiModel body) { return(operations.StopPublishingValuesAsync(endpointId, body).GetAwaiter().GetResult()); }
public async Task <ActionResult> VariablePublishUnpublish(string jstreeNode, string method) { string[] delimiter = { "__$__" }; string[] jstreeNodeSplit = jstreeNode.Split(delimiter, 3, StringSplitOptions.None); string node; string actionResult = ""; string endpointId = Session["EndpointId"].ToString(); if (jstreeNodeSplit.Length == 1) { node = jstreeNodeSplit[0]; } else { node = jstreeNodeSplit[1]; } try { if (method == "unpublish") { PublishStopRequestApiModel publishModel = new PublishStopRequestApiModel(); publishModel.NodeId = node; var data = await TwinService.UnPublishNodeValuesAsync(endpointId, publishModel); if (data.ErrorInfo != null) { actionResult = Strings.BrowserOpcUnPublishFailed + @"<br/><br/>" + Strings.BrowserOpcMethodStatusCode + ": " + data.ErrorInfo.StatusCode; if (data.ErrorInfo.Diagnostics != null) { actionResult += @"<br/><br/>" + Strings.BrowserOpcDataDiagnosticInfoLabel + ": " + data.ErrorInfo.Diagnostics; } } else { actionResult = Strings.BrowserOpcUnPublishSucceeded; } } else { PublishStartRequestApiModel publishModel = new PublishStartRequestApiModel(); PublishedItemApiModel item = new PublishedItemApiModel(); item.NodeId = node; publishModel.Item = item; var data = await TwinService.PublishNodeValuesAsync(endpointId, publishModel); if (data.ErrorInfo != null) { actionResult = Strings.BrowserOpcPublishFailed + @"<br/><br/>" + Strings.BrowserOpcMethodStatusCode + ": " + data.ErrorInfo.StatusCode; if (data.ErrorInfo.Diagnostics != null) { actionResult += @"<br/><br/>" + Strings.BrowserOpcDataDiagnosticInfoLabel + ": " + data.ErrorInfo.Diagnostics; } } else { actionResult = Strings.BrowserOpcPublishSucceeded; } } return(Content(actionResult)); } catch (Exception exception) { return(Content(CreateOpcExceptionActionString(exception))); } }
/// <inheritdoc/> public Task <PublishStopResponseApiModel> NodePublishStopAsync(string endpointId, PublishStopRequestApiModel content, CancellationToken ct) { return(Task.FromException <PublishStopResponseApiModel>(new NotImplementedException())); }
public PublishStopResponseApiModel UnPublishNodeValues(string endpoint, PublishStopRequestApiModel content) { Task <PublishStopResponseApiModel> t = Task.Run(() => _twinServiceHandler.NodePublishStopAsync(endpoint, content)); return(t.Result); }
public async Task <PublishStopResponseApiModel> UnPublishNodeValuesAsync(string endpoint, PublishStopRequestApiModel content) { var applications = await _twinServiceHandler.NodePublishStopAsync(endpoint, content).ConfigureAwait(false); return(applications); }