private async Task RefreshAllGrids()
        {
            Cursor = Cursors.Wait;
            try
            {
                if (this.CurrentTenantModel != null)
                {
                    ModelManager modelMgr = ModelManager.GetInstance();
                    this.Title = $"Azure Sphere Explorer - {CurrentTenantModel.Tenant}";
                    List <ProductModel> productModel = await modelMgr.GetProductModels(CurrentTenantModel, true);

                    List <DeviceGroupModel> deviceGroupModel = await modelMgr.GetDeviceGroupModels(CurrentTenantModel, true);

                    List <DeviceModel> deviceModels = await modelMgr.GetDeviceModels(CurrentTenantModel, true);

                    this.gridProducts.ItemsSource     = productModel;
                    this.gridDeviceGroups.ItemsSource = deviceGroupModel;
                    this.gridDevices.ItemsSource      = deviceModels;
                }
            }
            finally
            {
                Cursor = null;
            }
        }
Exemplo n.º 2
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ModelManager modelManager = ModelManager.GetInstance();

            this.DeviceGroupModels = await modelManager.GetDeviceGroupModels(CurrentTenantModel, false);

            this.DeviceModels = await modelManager.GetDeviceModels(CurrentTenantModel, false);

            foreach (DeviceGroupModel group in DeviceGroupModels)
            {
                DeviceGroupBox.Items.Add(group.DeviceGroup + "/" + group.Product);
            }

            foreach (DeviceModel model in this.DeviceModels)
            {
                DeviceModelEx newObj;
                if (model == CurrDevice)
                {
                    newObj = new DeviceModelEx(model, true);
                }
                else
                {
                    newObj = new DeviceModelEx(model, false);
                }
                DeviceModelIces.Add(newObj);
            }
            gridDeviceGroups.ItemsSource = this.DeviceModelIces;
        }
        private async void NotificationChangeDeviceGroup(object sender, EventArgs e)
        {
            ModelManager modelMgr = ModelManager.GetInstance();

            Console.Write("called NotificationChangeDeviceGroup()");
            this.DeviceGroups = await modelMgr.GetDeviceGroupModels(CurrTenant, false);

            ViewDeviceGroups(CurrProduct);
        }
        private async void NotificationChangeDeviceGroup(object sender, EventArgs e)
        {
            ModelManager modelMgr = ModelManager.GetInstance();

            Console.Write("called NotificationDeviceGroup()");
            List <DeviceGroupModel> deviceGroupModel = await modelMgr.GetDeviceGroupModels(CurrentTenantModel, false);

            this.gridDeviceGroups.ItemsSource = deviceGroupModel;
            this.gridDeviceGroups.Items.Refresh();
        }
Exemplo n.º 5
0
        private async void Create_Click(object sender, RoutedEventArgs e)
        {
            var index = ProductBox.SelectedIndex;

            ModelManager modelManager = ModelManager.GetInstance();
            JObject      newObj       = new JObject();

            newObj.Add("Description", new JValue(DescriptionBox.Text));
            newObj.Add("Name", new JValue(DeviceGroupNameBox.Text));
            newObj.Add("OsFeedType", new JValue(OsFeedTypeBox.SelectedIndex));
            newObj.Add("ProductId", new JValue(ProductModels[index].Context.Id));
            newObj.Add("UpdatePolicy", new JValue(UpdatePolicyBox.SelectedIndex));

            List <DeviceGroupModel> groups = await modelManager.GetDeviceGroupModels(this.CurrentTenantModel, false);

            foreach (DeviceGroupModel model in groups)
            {
                if (model.Product == ProductModels[index].Product &&
                    model.DeviceGroup == DeviceGroupNameBox.Text)
                {
                    MessageBox.Show("DeviceGroup is already exists",
                                    "Error", MessageBoxButtons.OK);
                    return;
                }
            }

            Cursor = System.Windows.Input.Cursors.Wait;
            this.CreateButton.IsEnabled = false;
            this.CloseButton.IsEnabled  = false;

            if (await modelManager.CreateDeviceGroup(CurrentTenantModel, newObj.ToString()))
            {
                MessageBox.Show("Create DeviceGroup is success.",
                                "Ok", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("Create DeviceGroup is failure",
                                "Error", MessageBoxButtons.OK);
            }
            Cursor = null;
            this.CreateButton.IsEnabled = true;
            this.CloseButton.IsEnabled  = true;
        }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ModelManager modelMgr = ModelManager.GetInstance();

            List <ProductModel> products = await modelMgr.GetProductModels(CurrTenant, false);

            this.DeviceGroups = await modelMgr.GetDeviceGroupModels(CurrTenant, false);

            this.Devices = await modelMgr.GetDeviceModels(CurrTenant, false);

            this.gridProducts.ItemsSource = products;

            if (CurrProduct != null)
            {
                int index = products.IndexOf(CurrProduct);
                this.gridProducts.SelectedIndex = index;

                ViewProduct(index);
                ViewDeviceGroups(CurrProduct);
            }

            if (CurrDeviceGroup != null)
            {
                foreach (ProductModel model in products)
                {
                    if (model.Product == this.CurrDeviceGroup.Product)
                    {
                        CurrProduct = model;
                        break;
                    }
                }

                int indexP = products.IndexOf(CurrProduct);
                this.gridProducts.SelectedIndex = indexP;

                ViewProduct(indexP);
                ViewDeviceGroups(CurrProduct);
                ViewDevices(CurrDeviceGroup);
            }
            modelMgr.NotificationChangeDevice      += NotificationChangeDevice;
            modelMgr.NotificationChangeDeviceGroup += NotificationChangeDeviceGroup;
        }