Exemple #1
0
 public void AddTo <T>(T entity)
 {
     if (typeof(T) == typeof(AlarmCategory))
     {
         AlarmCategories.Add(entity as AlarmCategory);
     }
     else if (typeof(T) == typeof(AlarmTag))
     {
         AlarmTags.Add(entity as AlarmTag);
     }
     else if (typeof(T) == typeof(DigTag))
     {
         DigTags.Add(entity as DigTag);
     }
     else if (typeof(T) == typeof(IoDevice))
     {
         IoDevices.Add(entity as IoDevice);
     }
     else if (typeof(T) == typeof(Log))
     {
         Logs.Add(entity as Log);
     }
     else if (typeof(T) == typeof(NumTag))
     {
         NumTags.Add(entity as NumTag);
     }
     else if (typeof(T) == typeof(TrendCategory))
     {
         TrendCategories.Add(entity as TrendCategory);
     }
     else if (typeof(T) == typeof(TrendTag))
     {
         TrendTags.Add(entity as TrendTag);
     }
     else if (typeof(T) == typeof(User))
     {
         Users.Add(entity as User);
     }
     else
     {
         throw new NotImplementedException();
     }
 }
        private async Task PopulateIoSystemLvl()
        {
            DeviceItem controller    = (DeviceItem)ioSystem.Parent.Parent.Parent;
            var        ioDeviceTasks = new List <Task <NetworkDeviceItem> >();

            var IoControllerTask = NetworkDeviceItem.Create(controller, NetworkDeviceItemLevel.IoSystem,
                                                            NetworkDeviceItemWorkMode.IoController, SubnetLevel, this);

            foreach (var connector in ioSystem.ConnectedIoDevices)
            {
                DeviceItem di = (DeviceItem)connector.Parent.Parent;
                ioDeviceTasks.Add(NetworkDeviceItem.Create(di, NetworkDeviceItemLevel.IoSystem,
                                                           NetworkDeviceItemWorkMode.IoDevice, SubnetLevel, this));

                //if (ioDevice != null) IoDevices.Add(ioDevice);
            }

            IoController = await IoControllerTask.ConfigureAwait(false);

            NetworkDeviceItem[] ioDevices = await Task.WhenAll <NetworkDeviceItem>(ioDeviceTasks).ConfigureAwait(false);

            IoDevices.AddRange(ioDevices.Where(iod => iod != null));
            //IoDevices.RemoveAll((iod) => iod == null);
        }