/// <summary>
 /// Create service model from api model
 /// </summary>
 public static PublishedItemModel ToServiceModel(
     this PublishedItemApiModel model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new PublishedItemModel {
         NodeId = model.NodeId,
         SamplingInterval = model.SamplingInterval,
         PublishingInterval = model.PublishingInterval
     });
 }
Exemple #2
0
        public ListNodeRequested(PublishedItemApiModel publishedItem)
        {
            if (publishedItem?.PublishingInterval != null)
            {
                RequestedPublishingInterval = publishedItem.PublishingInterval.Value.TotalMilliseconds.ToString();
            }

            if (publishedItem?.SamplingInterval != null)
            {
                RequestedSamplingInterval = publishedItem.SamplingInterval.Value.TotalMilliseconds.ToString();
            }

            if (publishedItem?.HeartbeatInterval != null)
            {
                RequestedHeartbeatInterval = publishedItem.HeartbeatInterval.Value.TotalSeconds.ToString();
            }
        }
        public ListNodeRequested(PublishedItemApiModel publishedItem)
        {
            if (publishedItem?.PublishingInterval.HasValue ?? false &&
                publishedItem.PublishingInterval.Value != TimeSpan.MinValue)
            {
                RequestedPublishingInterval = publishedItem.PublishingInterval.Value.TotalMilliseconds.ToString();
            }

            if (publishedItem?.SamplingInterval.HasValue ?? false &&
                publishedItem.SamplingInterval.Value != TimeSpan.MinValue)
            {
                RequestedSamplingInterval = publishedItem.SamplingInterval.Value.TotalMilliseconds.ToString();
            }

            if (publishedItem?.HeartbeatInterval.HasValue ?? false &&
                publishedItem.HeartbeatInterval.Value != TimeSpan.MinValue)
            {
                RequestedHeartbeatInterval = publishedItem.HeartbeatInterval.Value.TotalSeconds.ToString();
            }
        }
        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)));
            }
        }
 public ListNodeRequested(PublishedItemApiModel publishedItem)
 {
     _requestedPublishingInterval = publishedItem?.PublishingInterval;
     _requestedSamplingInterval   = publishedItem?.SamplingInterval;
     _requestedHeartbeatInterval  = publishedItem?.HeartbeatInterval;
 }