private async void menuitemImages_Click(object sender, RoutedEventArgs e) { var model = gridDeployments.SelectedItem as DeploymentModel; var imageModels = new List <ImageModel>(); Cursor = Cursors.Wait; try { ModelManager modelManager = ModelManager.GetInstance(); imageModels = await modelManager.GetImageModels(this.CurrentTenantModel, model); } finally { Cursor = null; } var dialog = new ImagesWindow(); dialog.Owner = this; dialog.imageModels = imageModels; var dialogResult = dialog.ShowDialog(); dialog = null; }
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; } }
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 menuitemDeviceGroupDeployments_Click(object sender, RoutedEventArgs e) { var model = gridDeviceGroups.SelectedItem as DeviceGroupModel; List <DeploymentModel> deploymentModels = new List <DeploymentModel>(); if (model == null) { return; } Cursor = Cursors.Wait; try { ModelManager modelManager = ModelManager.GetInstance(); deploymentModels = await modelManager.GetDeploymentModels(CurrentTenantModel, model); } finally { Cursor = null; } var dialog = new DeploymentsWindow(); dialog.Owner = this; dialog.Title += $" - {model.Product},{model.DeviceGroup}"; dialog.CurrentTenantModel = this.CurrentTenantModel; dialog.DeploymentModels = deploymentModels; dialog.SelectDeviceGroupModel = model; var dialogResult = dialog.ShowDialog(); dialog = null; }
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 NotificationChangeProduct(object sender, EventArgs e) { ModelManager modelMgr = ModelManager.GetInstance(); Console.Write("called NotificationCreateProduct()"); List <ProductModel> productModel = await modelMgr.GetProductModels(CurrentTenantModel, false); this.gridProducts.ItemsSource = productModel; this.gridProducts.Items.Refresh(); }
private async void NotificationChangeDevice(object sender, EventArgs e) { ModelManager modelMgr = ModelManager.GetInstance(); Console.Write("called NotificationChangeDevice()"); List <DeviceModel> deviceModels = await modelMgr.GetDeviceModels(CurrentTenantModel, false); this.gridDevices.ItemsSource = deviceModels; this.gridDevices.Items.Refresh(); }
private async void Window_Loaded(object sender, RoutedEventArgs e) { ModelManager modelManager = ModelManager.GetInstance(); ProductModels = await modelManager.GetProductModels(CurrentTenantModel, true); // プロダクトのリストを作成 foreach (ProductModel product in ProductModels) { ProductBox.Items.Add(product.Product); } }
private async void Window_Loaded(object sender, RoutedEventArgs e) { ModelManager modelMgr = ModelManager.GetInstance(); if (!await modelMgr.Initialize()) { MessageBox.Show("Failed to authenticate.", null, MessageBoxButton.OK, MessageBoxImage.Error); Close(); return; } List <TenantModel> tenantModels = await modelMgr.GetTenantModels(); if (tenantModels.Count <= 0) { MessageBox.Show("No azure sphere tenant found.", null, MessageBoxButton.OK, MessageBoxImage.Error); Close(); return; } else if (tenantModels.Count == 1) { CurrentTenantModel = tenantModels[0]; } else { var dialog = new TenantsWindow(); dialog.Owner = this; dialog.TenantModels = tenantModels; var dialogResult = dialog.ShowDialog(); if (!dialogResult.Value) { Close(); return; } CurrentTenantModel = dialog.SelectedTenantModel; } // EventHandler var roles = await modelMgr.GetRolesAsync(CurrentTenantModel.Context, modelMgr.GetUsername()); if (roles.Contains("Administrator")) { menuitemUsers.IsEnabled = true; } modelMgr.NotificationChangeProduct += NotificationChangeProduct; modelMgr.NotificationChangeDeviceGroup += NotificationChangeDeviceGroup; modelMgr.NotificationChangeDevice += NotificationChangeDevice; await RefreshAllGrids(); }
private void Upload_Click(object sender, RoutedEventArgs e) { var dialog = new UploadImageWindow(); ModelManager modelManager = ModelManager.GetInstance(); modelManager.NotificationChangeDeployment += NotificationChangeDeployment; dialog.Owner = this; dialog.Title += $" - {SelectDeviceGroupModel.DeviceGroup}"; var dialogResult = dialog.ShowDialog(); dialog = null; }
private async void NotificationChangeDeployment(object sender, EventArgs e) { ModelManager modelMgr = ModelManager.GetInstance(); Console.Write("called NotificationChangeDeployment()"); List <DeploymentModel> deploymentModels = await modelMgr.GetDeploymentModels(CurrentTenantModel, this.SelectDeviceGroupModel); this.gridDeployments.ItemsSource = deploymentModels; var viewDeployments = CollectionViewSource.GetDefaultView(this.gridDeployments.ItemsSource); this.gridDeployments.Columns[0].SortDirection = ListSortDirection.Descending; viewDeployments.SortDescriptions.Add(new SortDescription("CurrentDeploymentDate", ListSortDirection.Descending)); this.gridDeployments.Items.Refresh(); }
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; }
private async void Create_Click(object sender, RoutedEventArgs e) { ModelManager modelManager = ModelManager.GetInstance(); JObject newObj = new JObject(); newObj.Add("CreateDefaultGroups", new JValue(DefaultGroupToggleBotton.IsChecked)); newObj.Add("Description", new JValue(DescriptionBox.Text)); newObj.Add("Name", new JValue(ProductNameBox.Text)); List <ProductModel> products = await modelManager.GetProductModels(this.CurrentTenantModel, false); foreach (ProductModel model in products) { if (model.Product == ProductNameBox.Text) { MessageBox.Show("Product is already exists", "Error", MessageBoxButtons.OK); return; } } Cursor = System.Windows.Input.Cursors.Wait; this.CreateButton.IsEnabled = false; this.CloseButton.IsEnabled = false; if (await modelManager.CreateProductGroup(CurrentTenantModel, newObj.ToString())) { MessageBox.Show("Create Product is success.", "Ok", MessageBoxButtons.OK); } else { MessageBox.Show("Create Product is failure.", "Error", MessageBoxButtons.OK); } Cursor = null; this.CreateButton.IsEnabled = true; this.CloseButton.IsEnabled = true; }
private async void Upload_Click(object sender, RoutedEventArgs e) { Cursor = System.Windows.Input.Cursors.Wait; this.SelectButton.IsEnabled = false; this.UploadButton.IsEnabled = false; this.DeployButton.IsEnabled = false; this.CloseButton.IsEnabled = false; try { ModelManager modelManager = ModelManager.GetInstance(); System.IO.FileStream fs = new System.IO.FileStream(FilePath.Text, System.IO.FileMode.Open, System.IO.FileAccess.Read); byte[] bs = new byte[fs.Length]; fs.Read(bs, 0, bs.Length); fs.Close(); if (await modelManager.ImageUpload(deployWindow.CurrentTenantModel, bs)) { MessageBox.Show("Upload image is success.", "Ok", MessageBoxButtons.OK); } else { MessageBox.Show("Image is already upload.", "Ok", MessageBoxButtons.OK); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); return; } Cursor = null; this.SelectButton.IsEnabled = true; this.UploadButton.IsEnabled = true; this.DeployButton.IsEnabled = true; this.CloseButton.IsEnabled = true; }
private async void menuitemUsers_Click(object sender, RoutedEventArgs e) { List <UserModel> users; Cursor = Cursors.Wait; try { ModelManager modelManager = ModelManager.GetInstance(); users = await modelManager.GetUsersModels(this.CurrentTenantModel); } finally { Cursor = null; } var dialog = new UsersWindow(); dialog.Owner = this; dialog.UsersModels = users; var dialogResult = dialog.ShowDialog(); dialog = null; }
private async void Deploy_Click(object sender, RoutedEventArgs e) { bool isUploadButtonChecked = this.UploadButton.IsEnabled; Cursor = System.Windows.Input.Cursors.Wait; this.SelectButton.IsEnabled = false; this.UploadButton.IsEnabled = false; this.DeployButton.IsEnabled = false; this.CloseButton.IsEnabled = false; try { ModelManager modelManager = ModelManager.GetInstance(); DeviceGroupModel dev = deployWindow.SelectDeviceGroupModel; string req = ImageIdList.Text; if (await modelManager.Deployment(deployWindow.CurrentTenantModel, dev, req)) { MessageBox.Show("Deployment is success.", "Ok", MessageBoxButtons.OK); } else { MessageBox.Show("Deployment is failure.", "Error", MessageBoxButtons.OK); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } Cursor = null; this.SelectButton.IsEnabled = true; this.UploadButton.IsEnabled = isUploadButtonChecked; this.DeployButton.IsEnabled = true; this.CloseButton.IsEnabled = true; }
private async void menuitemDeviceGroupDelete_Click(object sender, RoutedEventArgs e) { var model = gridDeviceGroups.SelectedItem as DeviceGroupModel; if (model == null) { return; } var mboxResult = MessageBox.Show(this, $"Do you want to delete the device group \"{model.DeviceGroup}\"?", "Delete Device Group", MessageBoxButton.OKCancel, MessageBoxImage.Question); if (mboxResult != MessageBoxResult.OK) { return; } Cursor = Cursors.Wait; try { ModelManager modelManager = ModelManager.GetInstance(); if (await modelManager.DeleteDeviceGroup(this.CurrentTenantModel, model)) { MessageBox.Show("DeviceGroup delete is success", "OK", MessageBoxButton.OK); } else { MessageBox.Show("DeviceGroup delete is failure", "Error", MessageBoxButton.OK); } } finally { Cursor = null; } Cursor = null; }
private async void menuitemErrorReports_Click(object sender, RoutedEventArgs e) { List <DeviceInsightModel> deviceInsightModels = new List <DeviceInsightModel>(); Cursor = Cursors.Wait; try { ModelManager modelManager = ModelManager.GetInstance(); deviceInsightModels = await modelManager.GetDeviceInsightModels(this.CurrentTenantModel); } finally { Cursor = null; } var dialog = new ErrorReportsWindow(); dialog.Owner = this; dialog.DeviceInsightModels = deviceInsightModels; var dialogResult = dialog.ShowDialog(); dialog = null; }
private async void Change_Click(object sender, RoutedEventArgs e) { List <DeviceModel> changeDeviceModels = new List <DeviceModel>(); ModelManager modelManager = ModelManager.GetInstance(); var index = DeviceGroupBox.SelectedIndex; var targetDeviceGroup = DeviceGroupModels[index]; var req = "\"" + targetDeviceGroup.Context.Id + "\""; bool changed = false; Cursor = System.Windows.Input.Cursors.Wait; this.ChangeButton.IsEnabled = false; this.LoadButton.IsEnabled = false; this.CloseButton.IsEnabled = false; foreach (DeviceModelEx model in this.DeviceModelIces) { if (model.IsChecked) { changeDeviceModels.Add(model.DeviceModel); } } if (changeDeviceModels.Count >= 1) { if (await modelManager.ChangeDeviceGroup(CurrentTenantModel, targetDeviceGroup, changeDeviceModels, req)) { changed = true; } } else { Cursor = null; this.ChangeButton.IsEnabled = true; this.LoadButton.IsEnabled = true; this.CloseButton.IsEnabled = true; return; } if (changed) { this.DeviceModels = await modelManager.GetDeviceModels(CurrentTenantModel, false); foreach (DeviceModel model in this.DeviceModels) { DeviceModelEx newObj = GetDeviceModelEx(model.Id); if (newObj != null) { DeviceModelIces.Remove(newObj); newObj.Product = model.Product; newObj.DeviceGroup = model.DeviceGroup; newObj.DeviceModel = model; DeviceModelIces.Add(newObj); } } gridDeviceGroups.ItemsSource = this.DeviceModelIces; this.gridDeviceGroups.Items.Refresh(); } Cursor = null; this.ChangeButton.IsEnabled = true; this.LoadButton.IsEnabled = true; this.CloseButton.IsEnabled = true; }