Esempio n. 1
0
        public async Task <bool> Update(SystemCategories.Category category)
        {
            ILabSystemService service = new LabSystemService(new LabSystemsContextFactory());

            string hostName = GetHostName();

            LabSystem existingEntity = await service.Get(hostName);

            LabSystem entity = new LabSystem()
            {
                Ipaddress = GetIPAddress(),
                HostName  = hostName,
                Osversion = GetOSVersion(),
                Timestamp = GetTimestamp(),
                Category  = category,
            };

            if (existingEntity != null)
            {
                entity.Id = existingEntity.Id;

                if (category == SystemCategories.Category.Unknown)
                {
                    entity.Category = existingEntity.Category;
                }
            }

            entity.DiskDrives?.Clear();
            entity.DiskDrives = await(new UpdateDiskDriveInfo()).Update();

            Task <LabSystem> task = service.CreateOrUpdate(hostName, entity);

            task.Wait();
            return(task.IsCompleted);
        }
Esempio n. 2
0
        public LabSystemViewModel(LabSystemsContextFactory contextFactory)
        {
            _service = new LabSystemService(contextFactory);

            RefreshCommand = new AsyncCommand(async() =>
            {
                Systems.Clear();
                IsNotScanning = false;

                Task <IEnumerable <LabSystem> > task = _service.GetAll();

                await task;

                foreach (LabSystem system in task.Result)
                {
                    Systems.Add(system);
                }

                IsNotScanning = true;
            });
        }