private async void ExportCertificateDetailsAsync(CertificateSelector sender, CertificateSelector.CertificateDetails certificateData) { MessageBox.Show("Exporting certificate details from the device to Azure storage..."); string targetFileName = certificateData.Hash + ".json"; DeviceMethodReturnValue result = await RequestCertificateDetailsAsync(AzureStorageDesiredConnectionString.Text, AzureStorageContainerName.Text, sender.CertificatesPath, certificateData.Hash, targetFileName); GetCertificateDetailsResponse response = JsonConvert.DeserializeObject <GetCertificateDetailsResponse>(result.Payload); if (response == null || response.Status != 0) { MessageBox.Show("Error: could not schedule certificate export"); return; } CertificateExportDetails.CertificateExportDetailsData certificateExportDetailsData = new CertificateExportDetails.CertificateExportDetailsData(); certificateExportDetailsData.ConnectionString = AzureStorageDesiredConnectionString.Text; certificateExportDetailsData.ContainerName = AzureStorageContainerName.Text; certificateExportDetailsData.BlobName = targetFileName; CertificateExportDetails certificateExportDetails = new CertificateExportDetails(); certificateExportDetails.Owner = this; certificateExportDetails.DataContext = certificateExportDetailsData; certificateExportDetails.Show(); }
private async void UpdateDTReportedAsync() { CancellationToken cancellationToken = new CancellationToken(); DeviceMethodReturnValue result = await _deviceTwin.CallDeviceMethod(CommonDataContract.ReportAllAsync, "{}", new TimeSpan(0, 0, 30), cancellationToken); MessageBox.Show("UpdateDTReportedAsync Result:\nStatus: " + result.Status + "\nReason: " + result.Payload); }
private async void UpdateDTReportedAsync() { CancellationToken cancellationToken = new CancellationToken(); DeviceMethodReturnValue result = await _deviceTwin.CallDeviceMethod("microsoft.management.reportAllDeviceProperties", "{}", new TimeSpan(0, 0, 30), cancellationToken); // ToDo: it'd be nice to show the result in the UI. }
private async void StartDmAppStoreUpdateAsync() { CancellationToken cancellationToken = new CancellationToken(); DeviceMethodReturnValue result = await _deviceTwin.CallDeviceMethod(DmAppStoreUpdateDataContract.StartDmAppStoreUpdateAsync, "{}", new TimeSpan(0, 0, 30), cancellationToken); MessageBox.Show("FactoryReset Command Result:\nStatus: " + result.Status + "\nReason: " + result.Payload); }
private async void RebootSystemAsync() { CancellationToken cancellationToken = new CancellationToken(); DeviceMethodReturnValue result = await _deviceTwin.CallDeviceMethod(RebootCmdDataContract.RebootCmdAsync, "{}", new TimeSpan(0, 0, 30), cancellationToken); MessageBox.Show("Reboot Command Result:\nStatus: " + result.Status + "\nReason: " + result.Payload); }
private async void StartAppSelfUpdate() { CancellationToken cancellationToken = new CancellationToken(); DeviceMethodReturnValue result = await _deviceTwin.CallDeviceMethod("microsoft.management.startAppSelfUpdate", "{}", new TimeSpan(0, 0, 30), cancellationToken); StartAppSelfUpdateResult.Text = result.Payload; }
private async void RebootSystemAsync() { CancellationToken cancellationToken = new CancellationToken(); DeviceMethodReturnValue result = await _deviceTwin.CallDeviceMethod("microsoft.management.immediateReboot", "{}", new TimeSpan(0, 0, 30), cancellationToken); MessageBox.Show("Reboot Command Result:\nStatus: " + result.Status + "\nReason: " + result.Payload); }
private async void OnManageAppLifeCycle(string appLifeCycleAction, string packageFamilyName) { AppxLifeCycleDataContract.ManageAppLifeCycleParams parameters = new AppxLifeCycleDataContract.ManageAppLifeCycleParams(); parameters.action = appLifeCycleAction; parameters.pkgFamilyName = packageFamilyName; CancellationToken cancellationToken = new CancellationToken(); DeviceMethodReturnValue result = await _deviceTwin.CallDeviceMethod(AppxLifeCycleDataContract.ManageAppLifeCycleAsync, parameters.ToJsonString(), new TimeSpan(0, 0, 30), cancellationToken); MessageBox.Show("ManageAppLifeCycle(start) Result:\nStatus: " + result.Status + "\nReason: " + result.Payload); }
private async void StartUsoClientCmdAsync(string cmd) { var cmdParams = new UsoClientCmdDataContract.CmdParams(); cmdParams.cmd = cmd; string cmdParamsString = cmdParams.ToJsonString(); Debug.WriteLine("Cmd params : " + cmdParamsString); CancellationToken cancellationToken = new CancellationToken(); DeviceMethodReturnValue result = await _deviceTwin.CallDeviceMethod(UsoClientCmdDataContract.StartUsoClientCmdAsync, cmdParamsString, new TimeSpan(0, 0, 30), cancellationToken); MessageBox.Show("FactoryReset Command Result:\nStatus: " + result.Status + "\nReason: " + result.Payload); }
private async void FactoryResetAsync() { var resetParams = new FactoryResetDataContract.ResetParams(); resetParams.clearTPM = DesiredClearTPM.IsChecked == true; resetParams.recoveryPartitionGUID = DesiredRecoveryPartitionGUID.Text; string resetParamsString = resetParams.ToJsonString(); Debug.WriteLine("Reset params : " + resetParamsString); CancellationToken cancellationToken = new CancellationToken(); DeviceMethodReturnValue result = await _deviceTwin.CallDeviceMethod(FactoryResetDataContract.StartFactoryResetAsync, resetParamsString, new TimeSpan(0, 0, 30), cancellationToken); MessageBox.Show("FactoryReset Command Result:\nStatus: " + result.Status + "\nReason: " + result.Payload); }
private async void FactoryResetAsync() { var resetParams = new FactorResetParams(); resetParams.clearTPM = DesiredClearTPM.IsChecked == true; resetParams.recoveryPartitionGUID = DesiredRecoveryPartitionGUID.Text; string resetParamsString = JsonConvert.SerializeObject(resetParams); Debug.WriteLine("Reset params : " + resetParamsString); CancellationToken cancellationToken = new CancellationToken(); DeviceMethodReturnValue result = await _deviceTwin.CallDeviceMethod("microsoft.management.factoryReset", resetParamsString, new TimeSpan(0, 0, 30), cancellationToken); // ToDo: it'd be nice to show the result in the UI. }
public async void ExportWifiProfileDetails(string profileName, string storageConnectionString, string storageContainer, string blobName) { var details = new GetWifiProfileDetailsParams(); { details.profileName = profileName; details.connectionString = storageConnectionString; details.containerName = storageContainer; details.blobName = blobName; } var parametersJson = JsonConvert.SerializeObject(details); Debug.WriteLine(parametersJson); var cancellationToken = new CancellationToken(); DeviceMethodReturnValue result = await this._deviceTwin.CallDeviceMethod(DMJSonConstants.DTWindowsIoTNameSpace + ".getWifiDetails", parametersJson, new TimeSpan(0, 0, 30), cancellationToken); System.Windows.MessageBox.Show("Get Wifi Profile Details Command Result:\nStatus: " + result.Status + "\nReason: " + result.Payload); }
private async void DeviceHealthAttestationReportButtonAsync(object sender, RoutedEventArgs e) { DeviceMethodReturnValue result = await _deviceTwin.CallDeviceMethod(DeviceHealthAttestationDataContract.ReportNowMethodName, "{}", new TimeSpan(0, 0, 30), new CancellationToken()); }
private async void AppInstallAsync(object sender, RoutedEventArgs e) { var cxnstr = AppConnectionString.Text; var container = AppContainerName.Text; var pfn = AppPackageFamilyName.Text; var appx = AppAppxPath.Text; var dep1 = AppDep1AppxPath.Text; var dep2 = AppDep2AppxPath.Text; // copy local file to Azure { // Retrieve storage account from connection string. var storageAccount = CloudStorageAccount.Parse(cxnstr); // Create the blob client. var blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve a reference to a container. var containerRef = blobClient.GetContainerReference(container); // Create the container if it doesn't already exist. await containerRef.CreateIfNotExistsAsync(); // Appx { var blob = containerRef.GetBlockBlobReference(new FileInfo(appx).Name); await blob.UploadFromFileAsync(appx); } // Dep1 if (!string.IsNullOrEmpty(dep1)) { var blob = containerRef.GetBlockBlobReference(new FileInfo(dep1).Name); await blob.UploadFromFileAsync(dep1); } // Dep2 if (!string.IsNullOrEmpty(dep2)) { var blob = containerRef.GetBlockBlobReference(new FileInfo(dep2).Name); await blob.UploadFromFileAsync(dep2); } } // Invoke DM App Install CancellationToken cancellationToken = new CancellationToken(); var blobFormat = "{{\"ConnectionString\":\"{0}\",\"ContainerName\":\"{1}\",\"BlobName\":\"{2}\"}}"; var appJson = string.Format(blobFormat, cxnstr, container, new FileInfo(appx).Name); var depsJson = ""; if (!string.IsNullOrEmpty(dep1)) { depsJson += string.Format(blobFormat, cxnstr, container, new FileInfo(dep1).Name); if (!string.IsNullOrEmpty(dep2)) { depsJson += ", "; depsJson += string.Format(blobFormat, cxnstr, container, new FileInfo(dep2).Name); } } var jsonFormat = "{{\"PackageFamilyName\":\"{0}\",\"Appx\":{1},\"Dependencies\":[{2}]}}"; var json = string.Format(jsonFormat, pfn, appJson, depsJson); var jo = JsonConvert.DeserializeObject(json); DeviceMethodReturnValue result = await _deviceTwin.CallDeviceMethod("microsoft.management.appInstall", json, new TimeSpan(0, 0, 30), cancellationToken); }