/// <summary> /// Create api model from service model /// </summary> /// <param name="model"></param> public PublishedDataSetSourceApiModel(PublishedDataSetSourceModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } Connection = model.Connection == null ? null : new ConnectionApiModel(model.Connection); PublishedVariables = model.PublishedVariables == null ? null : new PublishedDataItemsApiModel(model.PublishedVariables); PublishedEvents = model.PublishedEvents == null ? null : new PublishedDataSetEventsApiModel(model.PublishedEvents); SubscriptionSettings = model.SubscriptionSettings == null ? null : new PublishedDataSetSettingsApiModel(model.SubscriptionSettings); }
/// <summary> /// Returns an uniquie identifier for the DataSetWriterId from a set of writers belonging to a group /// </summary> private static string GetUniqueWriterId(IEnumerable <PublishedDataSetSourceModel> set, PublishedDataSetSourceModel model) { var result = model.Connection.Id; var subset = set.Where(x => x.Connection.Id == model.Connection.Id).ToList(); if (subset.Count > 1) { result += !string.IsNullOrEmpty(result) ? "_" : string.Empty; result += $"{model.SubscriptionSettings.PublishingInterval.GetValueOrDefault().TotalMilliseconds}"; if (subset.Where(x => x.SubscriptionSettings.PublishingInterval == model.SubscriptionSettings.PublishingInterval).Count() > 1) { result += $"_{model.PublishedVariables.PublishedData.First().PublishedVariableNodeId}"; } } else { result ??= model.SubscriptionSettings.PublishingInterval.GetValueOrDefault().TotalMilliseconds.ToString(); } return(result); }