Example #1
0
        public static MomentaryValueData ToViewData(this MomentaryValue node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (node == null)
            {
                return(null);
            }
            //var RatioParameterList = new List<int>() { 60004, 60005, 60006, 60007, 60008, 60009, 60010, 60011, 60012, 60019, 60020, 60021, 60022 };
            var RatioParameterList = DictionaryCache.RatioParameterList;
            var model = new MomentaryValueData()
            {
                Id            = node.Id,
                MeterId       = node.MeterId,
                ParameterId   = node.ParameterId,
                ParameterName = node.Parameter == null ? "" : node.Parameter.Type.ChineseName,
                ParameterType = node.Parameter == null ? 0 : node.Parameter.TypeId,
                Value         = node.Meter == null ? node.Value : (RatioParameterList.Contains(node.Parameter == null ? 0 : node.Parameter.TypeId) ? node.Value * node.Meter.Rate : node.Value),
                Time          = node.Time,
                Unit          = node.Parameter == null ? "" : node.Parameter.Unit,
                OriginalValue = node.Value
                                //Parameter = node.Parameter.ToViewData()
            };

            if ((suffix & CategoryDictionary.Parameter) == CategoryDictionary.Parameter)
            {
                model.Parameter = node.Parameter.ToViewData();
            }
            if ((suffix & CategoryDictionary.Meter) == CategoryDictionary.Meter)
            {
                model.Meter = node.Meter.ToViewData();
            }

            return(model);
        }
Example #2
0
 public static MomentaryValue ToModel(this MomentaryValueData node)
 {
     return(new MomentaryValue()
     {
         Id = node.Id,
         MeterId = node.MeterId,
         ParameterId = node.ParameterId,
         Value = node.Value,
         Time = node.Time
     });
 }