/// <summary>
 /// Clone
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static PublishedDataSetSourceModel Clone(this PublishedDataSetSourceModel model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new PublishedDataSetSourceModel {
         Connection = model.Connection.Clone(),
         PublishedEvents = model.PublishedEvents.Clone(),
         PublishedVariables = model.PublishedVariables.Clone(),
         SubscriptionSettings = model.SubscriptionSettings.Clone()
     });
 }
예제 #2
0
 /// <summary>
 /// Create subscription
 /// </summary>
 /// <param name="dataSetSource"></param>
 /// <returns></returns>
 public static SubscriptionConfigurationModel ToSubscriptionConfigurationModel(
     this PublishedDataSetSourceModel dataSetSource)
 {
     if (dataSetSource == null)
     {
         throw new ArgumentNullException(nameof(dataSetSource));
     }
     return(new SubscriptionConfigurationModel {
         Priority = dataSetSource.SubscriptionSettings?.Priority,
         LifetimeCount = dataSetSource.SubscriptionSettings?.LifeTimeCount,
         KeepAliveCount = dataSetSource.SubscriptionSettings?.MaxKeepAliveCount,
         MaxNotificationsPerPublish = dataSetSource.SubscriptionSettings?.MaxNotificationsPerPublish,
         PublishingInterval = dataSetSource.SubscriptionSettings?.PublishingInterval
     });
 }
        /// <summary>
        /// Create hash
        /// </summary>
        /// <returns></returns>
        public static string GetHashSafe(this PublishedDataSetSourceModel model)
        {
            var id = model.Connection?.Endpoint?.Url +
                     model.Connection?.Endpoint?.SecurityMode.ToString() +
                     model.Connection?.Endpoint?.SecurityPolicy +
                     model.Connection?.User?.Type.ToString() +
                     model.Connection?.User?.Value.ToJson() +
                     model.SubscriptionSettings?.PublishingInterval.ToString() +
                     model.PublishedVariables.PublishedData.First()?.Id +
                     model.PublishedVariables.PublishedData.First()?.PublishedVariableNodeId +
                     model.PublishedVariables.PublishedData.First()?.PublishedVariableDisplayName +
                     model.PublishedVariables.PublishedData.First()?.SamplingInterval +
                     model.PublishedVariables.PublishedData.First()?.HeartbeatInterval;

            return(id.ToSha1Hash());
        }
        /// <summary>
        /// Convert dataset source to monitored item
        /// </summary>
        /// <param name="dataSetSource"></param>
        /// <returns></returns>
        public static List <MonitoredItemModel> ToMonitoredItems(
            this PublishedDataSetSourceModel dataSetSource)
        {
            var monitoredItems = Enumerable.Empty <MonitoredItemModel>();

            if (dataSetSource.PublishedVariables?.PublishedData != null)
            {
                monitoredItems = monitoredItems
                                 .Concat(dataSetSource.PublishedVariables.ToMonitoredItems());
            }
            if (dataSetSource.PublishedEvents?.SelectedFields != null)
            {
                monitoredItems = monitoredItems
                                 .Append(dataSetSource.PublishedEvents.ToMonitoredItem());
            }
            return(monitoredItems.ToList());
        }