Esempio n. 1
0
        public void SetStateValue(string groupName, string state, string quantityExp)
        {
            var sv = EntityStateValues.SingleOrDefault(x => x.StateName == groupName);

            if (sv == null)
            {
                sv = new EntityStateVal {
                    StateName = groupName, State = state
                };
                EntityStateValues.Add(sv);
            }
            else
            {
                sv.State = state;
            }
            sv.Quantity       = QuantityFuncParser.Parse(quantityExp, sv.Quantity);
            sv.LastUpdateTime = DateTime.Now;

            if (string.IsNullOrEmpty(sv.State))
            {
                EntityStateValues.Remove(sv);
            }

            EntityStates       = JsonHelper.Serialize(EntityStateValues);
            _entityStateValues = null;
        }
Esempio n. 2
0
        public void SetCustomData(string fieldName, string value)
        {
            value = QuantityFuncParser.Parse(value, GetCustomData(fieldName));
            value = DateFuncParser.Parse(value, GetCustomData(fieldName));
            var list = JsonHelper.Deserialize <List <CustomDataValue> >(CustomData);

            if (list.All(x => x.Name != fieldName))
            {
                list.Add(new CustomDataValue {
                    Name = fieldName
                });
            }
            list.Single(x => x.Name == fieldName).Value = value;
            CustomData = JsonHelper.Serialize(list);
        }