private void Save(DialogWindow window) { var panelGuid = new Guid("A8E3D03E-28C9-4900-BD48-CEEDEC35E7E6"); try { string customError = string.Empty; List <ValidationResult> results = new List <ValidationResult>(); var validation = Validator.TryValidateObject(Configuration, new ValidationContext(Configuration), results); if (!validation) { results.ForEach((error) => m_service.LogMessage($"[ERROR] => {error.ErrorMessage}", panelGuid)); m_service.LogMessage($"[ERROR] => {customError}", panelGuid); return; } var xmlDump = XmlObjectsHelper.Serialize(Configuration); var fullPath = $"{m_service.PropertiesDirectory}\\AvanadeToolkit.publishSettings"; File.WriteAllText(fullPath, xmlDump); FilePath = fullPath; window.Close(); } catch (Exception ex) { m_service.LogMessage($"[ERROR] => {ex.Message}", panelGuid); m_telemetry.TrackExceptionWithCustomMetrics(ex); } }
private void DeployMenuItemCallback(object sender, EventArgs e) { try { var singleResourceName = e is SingleResourceEventArgs ? (e as SingleResourceEventArgs).File : null; var publishSettigsPath = m_service.GetPublishSettingsFilePathIfExist(); var solutionPath = m_service.GetSolutionRootPath(); var basePath = m_service.GetProjectBasePath(); // Delete settings after breaking update if (!m_service.ReadOnlySettings.GetBoolean(SETTINGS_STORE, SETTINGS_KEY, false) && !string.IsNullOrEmpty(publishSettigsPath)) { File.Delete(publishSettigsPath); publishSettigsPath = string.Empty; m_service.WritableSettings.SetBoolean(SETTINGS_STORE, SETTINGS_KEY, true); } if (string.IsNullOrEmpty(publishSettigsPath)) { var dialog = new NewPublishSettingsPage(m_service, m_telemetry); dialog.ShowDialog(); publishSettigsPath = (dialog.DataContext as NewPublishSettingsPageViewModel)?.FilePath; } // No valid configuration found or provided if (string.IsNullOrEmpty(publishSettigsPath)) { return; } var deployConfiguration = XmlObjectsHelper.Deserialize <DeployConfigurationModelFacade>(publishSettigsPath); var orchestrator = new PublishOrchestrator(); orchestrator.ReportProgress += LogProgress; var task = Async.Task.Factory.StartNew(() => { var projectName = m_service.GetSelectedProjectNameForAnalytics(); orchestrator.Publish(deployConfiguration.InnerObject, m_telemetry, singleResourceName, projectName, solutionPath, basePath); orchestrator.ReportProgress -= LogProgress; }, m_token, Async.TaskCreationOptions.None, Async.TaskScheduler.Current); } catch (Exception ex) { m_service.LogMessage($"[ERROR] => {ex.Message}", m_pane); m_telemetry.TrackExceptionWithCustomMetrics(ex); } }