/// <summary>
        /// Create a new <see cref="ParameterSubscriptionValueSet"/> from the updated <see cref="ParameterValueSetBase"/>
        /// </summary>
        /// <param name="oldValue">The old <see cref="ParameterSubscriptionValueSet"/></param>
        /// <param name="valueSetBase">The subscribed <see cref="ParameterValueSetBase"/></param>
        /// <param name="container">The container</param>
        /// <param name="transaction">The current transaction</param>
        /// <param name="partition">The current partition</param>
        private void CreateParameterSubscriptionValueSet(ParameterSubscriptionValueSet oldValue, ParameterValueSetBase valueSetBase, ParameterSubscription container, NpgsqlTransaction transaction, string partition)
        {
            var isOldValueNull = oldValue == null;
            var newValueSet    = new ParameterSubscriptionValueSet(Guid.NewGuid(), 1)
            {
                Manual             = new ValueArray <string>((oldValue == null) ? valueSetBase.Manual : oldValue.Manual),
                ValueSwitch        = isOldValueNull ? CDP4Common.EngineeringModelData.ParameterSwitchKind.MANUAL : oldValue.ValueSwitch,
                SubscribedValueSet = valueSetBase.Iid
            };

            this.ParameterSubscriptionValueSetService.CreateConcept(transaction, partition, newValueSet, container);
        }
예제 #2
0
        /// <summary>
        /// Instantiate and deserialize the properties of a <paramref name="ParameterSubscriptionValueSet"/>
        /// </summary>
        /// <param name="jObject">The <see cref="JObject"/> containing the data</param>
        /// <returns>The <see cref="ParameterSubscriptionValueSet"/> to instantiate</returns>
        public static CDP4Common.DTO.ParameterSubscriptionValueSet FromJsonObject(JObject jObject)
        {
            var iid            = jObject["iid"].ToObject <Guid>();
            var revisionNumber = jObject["revisionNumber"].IsNullOrEmpty() ? 0 : jObject["revisionNumber"].ToObject <int>();
            var parameterSubscriptionValueSet = new CDP4Common.DTO.ParameterSubscriptionValueSet(iid, revisionNumber);

            if (!jObject["excludedDomain"].IsNullOrEmpty())
            {
                parameterSubscriptionValueSet.ExcludedDomain.AddRange(jObject["excludedDomain"].ToObject <IEnumerable <Guid> >());
            }

            if (!jObject["excludedPerson"].IsNullOrEmpty())
            {
                parameterSubscriptionValueSet.ExcludedPerson.AddRange(jObject["excludedPerson"].ToObject <IEnumerable <Guid> >());
            }

            if (!jObject["manual"].IsNullOrEmpty())
            {
                parameterSubscriptionValueSet.Manual = SerializerHelper.ToValueArray <string>(jObject["manual"].ToString());
            }

            if (!jObject["modifiedOn"].IsNullOrEmpty())
            {
                parameterSubscriptionValueSet.ModifiedOn = jObject["modifiedOn"].ToObject <DateTime>();
            }

            if (!jObject["subscribedValueSet"].IsNullOrEmpty())
            {
                parameterSubscriptionValueSet.SubscribedValueSet = jObject["subscribedValueSet"].ToObject <Guid>();
            }

            if (!jObject["thingPreference"].IsNullOrEmpty())
            {
                parameterSubscriptionValueSet.ThingPreference = jObject["thingPreference"].ToObject <string>();
            }

            if (!jObject["valueSwitch"].IsNullOrEmpty())
            {
                parameterSubscriptionValueSet.ValueSwitch = jObject["valueSwitch"].ToObject <ParameterSwitchKind>();
            }

            return(parameterSubscriptionValueSet);
        }