예제 #1
0
        public DbDevice GetDevice(string uid)
        {
            if (_devices.ContainsKey(uid))
            {
                return(DbDevice.Copy(_devices[uid]));
            }

            return(null);
        }
예제 #2
0
        private List <Fill> GetFills(DbDevice dbDevice, MessageDto dto)
        {
            var          list         = new List <Fill>();
            const string prefix       = "PORT";
            const string opCodePrefix = "NUMEMAIL";

            int opCode = 0;

            foreach (var tag in dto.Tags.ToArray())
            {
                if (tag.Key == opCodePrefix)
                {
                    int.TryParse(tag.Value, out opCode);
                }


                if (!tag.Key.Contains(prefix))
                {
                    continue;
                }

                var tapCodeStr = tag.Key.Substring(prefix.Length);
                int tapCode;
                if (!int.TryParse(tapCodeStr, out tapCode))
                {
                    continue;
                }

                int volume;
                if (!int.TryParse(tag.Value, out volume))
                {
                    continue;
                }

                list.Add(new Fill
                {
                    idDevice      = dbDevice.Id,
                    TapCode       = tapCode,
                    Ts            = dto.TimeStamp,
                    Volume        = volume,
                    Total         = GetTotal(tapCode, dto),
                    OperationCode = opCode
                });
            }

            return(list);
        }
예제 #3
0
 public static DbDevice Copy(DbDevice x) => new DbDevice
 {
     Id       = x.Id,
     IdMarket = x.IdMarket
 };