Example #1
0
        public static void UpdateSystemInfo(ref SystemEntity systemEntity, Contract.Model.SystemInfo systemInfo)
        {
            if (systemInfo.DeviceId != 0)
            {
                systemEntity.DeviceId = systemInfo.DeviceId.ToString();
            }

            if (!string.IsNullOrWhiteSpace(systemInfo.Mac))
            {
                systemEntity.Mac = systemInfo.Mac;
            }

            if (!string.IsNullOrWhiteSpace(systemInfo.SerialNumber))
            {
                systemEntity.SerialNumber = systemInfo.SerialNumber;
            }

            if (!string.IsNullOrWhiteSpace(systemInfo.DeviceModel))
            {
                systemEntity.Model = systemInfo.DeviceModel;
            }

            if (!string.IsNullOrWhiteSpace(systemInfo.Password))
            {
                systemEntity.Password = systemInfo.Password;
            }

            if (systemInfo.Services != null)
            {
                foreach (var s in systemInfo.Services)
                {
                    if (s is TcpConnectionService)
                    {
                        TcpConnectionServiceMapper.UpdateDeviceData(ref systemEntity, s as TcpConnectionService);
                    }
                    else if (s is UdpConnectionService)
                    {
                        UdpConnectionServiceMapper.UpdateDeviceData(ref systemEntity, s as UdpConnectionService);
                    }
                }
            }
        }