private async void CompileConfigurationButton_Click(object sender, RoutedEventArgs e) { try { CompileConfigurationButton.IsEnabled = false; processedStreamIDs.Clear(); cancelOutput = true; refreshTimer.Stop(); DscCompilationJobCreateResponse response = await createDSCJob(); if (response != null) { OutputTextBlockParagraph.Inlines.Clear(); JobDetails.FontWeight = FontWeights.Regular; JobDetails.Content = configurationName + " compilation job created at " + response.DscCompilationJob.Properties.CreationTime.LocalDateTime; JobStatus.Content = response.DscCompilationJob.Properties.Status; } else { CompileConfigurationButton.IsEnabled = true; } } catch (Exception exception) { System.Windows.Forms.MessageBox.Show(exception.Message, "Compilation Job Start Failure", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } finally { refreshTimer.Start(); } }
private async Task <DscCompilationJobCreateResponse> createDSCJob() { DscConfiguration draft = await AutomationDSCManager.GetConfigurationDraft(configurationName, iseClient.automationManagementClient, iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name); Dictionary <string, string> filePathForRunbook = new Dictionary <string, string>(); if (Directory.Exists(iseClient.currWorkspace)) { foreach (string path in localRunbookFilePaths) { if (path.EndsWith(Constants.nodeConfigurationIdentifier + ".ps1")) { filePathForRunbook.Add(System.IO.Path.GetFileNameWithoutExtension(path), path); } } } var jobCreationParams = new DscCompilationJobCreateParameters() { Properties = new DscCompilationJobCreateProperties() { Configuration = new DscConfigurationAssociationProperty() { Name = configurationName }, Parameters = null } }; jobCreationParams.Name = configurationName; if ((draft.Properties.Parameters.Count > 0) || filePathForRunbook.Count > 0) { /* User needs to specify some things */ var existingParams = await GetLastCompilationJobParams(); DSCConfigurationParamDialog paramDialog = new DSCConfigurationParamDialog(draft.Properties.Parameters, existingParams, filePathForRunbook); string configData = null; if (paramDialog.ShowDialog() == true) { if (!String.IsNullOrEmpty(paramDialog.configDataSelection) && !paramDialog.configDataSelection.Equals("None")) { configData = getConfigurationData(paramDialog.configDataSelection); } jobCreationParams.Properties.Parameters = GetDSCParameters(paramDialog.paramValues, configData); } else { return(null); } } /* start the compilation job */ CancellationTokenSource cts = new CancellationTokenSource(); cts.CancelAfter(TIMEOUT_MS); DscCompilationJobCreateResponse jobResponse = await iseClient.automationManagementClient.CompilationJobs.CreateAsync( iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name, jobCreationParams, cts.Token); if (jobResponse == null || jobResponse.StatusCode != System.Net.HttpStatusCode.Created) { throw new Exception("The DSC compilation job could not be created: received HTTP status code " + jobResponse.StatusCode); } lastJobID = jobResponse.DscCompilationJob.Properties.JobId; return(jobResponse); }