private async void btnDeactivate_Click(object sender, EventArgs e) { if (!this.IsLoggedOn) { MessageBox.Show("You have to be logged on in order to deactivate the device."); return; } this.DisableUI(); try { IStoreOperationsManager storeOperationsManager = this.currentManagerFactory.GetManager <IStoreOperationsManager>(); await storeOperationsManager.DeactivateDevice("testDevice.DeviceId"); this.appStorage.Remove(this.currentDeviceActivationInfo); this.currentDeviceActivationInfo = null; this.Log("Deactivation succeeded."); } catch (Exception ex) { this.Log(ex.ToString()); } finally { this.RefreshActivationStorageInformation(); this.RefreshLogOnInformation(); this.RefreshUI(); this.btnLogOff_Click(sender, e); } }
private async void btnActivate_Click(object sender, EventArgs e) { try { string aadToken = AzureActiveDirectoryHelper.GetAADHeaderWithPrompt(); this.textBoxRetailServerUrl.Text = this.retailServerUrl; RetailServerContext context = Helpers.CreateNewRetailServerContext(this.retailServerUrl); ManagerFactory managerFactory = ManagerFactory.Create(context); managerFactory.Context.SetUserToken(new AADToken(aadToken)); managerFactory.Context.SetDeviceToken(null); DeviceActivationResult result = null; IStoreOperationsManager storeOperationsManager = managerFactory.GetManager <IStoreOperationsManager>(); result = await storeOperationsManager.ActivateDevice(this.textBoxDeviceId.Text, this.textBoxRegisterId.Text, "testDevice.DeviceId", forceActivate : true, deviceType : 2 /*testDevice.DeviceType*/); this.AppInfo = new DeviceActivationInformation(this.retailServerUrl, result.Device.TerminalId, result.Device.ChannelName, result.Device.Token, result.Device.DeviceNumber, DateTime.Now); this.mainForm.Log("Activation succeeded."); } catch (Exception ex) { this.mainForm.Log(ex.ToString()); } this.Close(); }
/// <summary> /// Removes a DeviceActivationInformation from the application storage. /// </summary> /// <param name="information">A DeviceActivationInformation to be removed.</param> public void Remove(DeviceActivationInformation information) { if (information == null) { throw new ArgumentNullException("information"); } this.allActivations.Remove(information.UniqueActivationId); Helpers.ToXml(MainForm.AppStorageXmlFilePath, this); }
private void btnSelectActivated_Click(object sender, EventArgs e) { if (this.comboRetailServerUrl.SelectedItem != null) { this.btnLogOff_Click(sender, e); this.currentDeviceActivationInfo = (DeviceActivationInformation)this.comboRetailServerUrl.SelectedItem; this.RefreshActivationStorageInformation(); this.RefreshLogOnInformation(); this.RefreshUI(); } }
/// <summary> /// Adds a new DeviceActivationInformation to the application storage. /// </summary> /// <param name="information">A DeviceActivationInformation to be added.</param> /// <returns>The DeviceActivationInformation instance that was added.</returns> public DeviceActivationInformation Add(DeviceActivationInformation information) { if (information == null) { throw new ArgumentNullException("information"); } this.allActivations[information.UniqueActivationId] = information; Helpers.ToXml(MainForm.AppStorageXmlFilePath, this); return(information); }
private void btnActivate_Click(object sender, EventArgs e) { this.DisableUI(); try { using (ActivationForm f = new ActivationForm(this.txtNewRetailServerUrl.Text)) { f.ShowDialog(); if (f.AppInfo != null) { this.currentDeviceActivationInfo = this.appStorage.Add(f.AppInfo); } } } finally { this.RefreshActivationStorageInformation(); this.RefreshLogOnInformation(); this.RefreshUI(); } }