/// <summary> /// implement the disposable pattern /// </summary> /// <param name="disposing">If dispose is already triggered</param> protected virtual void Dispose(bool disposing) { if (!this.disposedValue) { if (disposing) { crmConnection = null; } this.disposedValue = true; } }
/// <summary> /// Loads the selected Connection /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="SelectionChangedEventArgs"/> instance containing the event data.</param> private void Cbx_CRMConnections_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (this.Cbx_CRMConnections.SelectedItem != null) { string connectionName = this.Cbx_CRMConnections.SelectedItem.ToString(); this.crmConnection = this.crmConnections.Find(x => x.Name == connectionName); Tbx_ConnectionName.Text = this.crmConnection.Name; Tbx_ConnectionString.Text = this.crmConnection.ConnectionString; Btn_SaveConnection.IsEnabled = false; } }
/// <summary> /// Button Click Action, Connect and add a CRM Organization /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void Button_Click(object sender, RoutedEventArgs e) { try { crmConnection = null; using (Core.Xrm.ToolingConnector toolingConnector = new Core.Xrm.ToolingConnector()) { CrmServiceClient crmServiceClient = toolingConnector.GetCrmServiceClient(tbx_connectionString.Text); if (crmServiceClient != null && crmServiceClient.IsReady) { this.crmConnection = new Core.Xrm.CrmConnection { ConnectionID = Guid.NewGuid(), ConnectionString = this.tbx_connectionString.Text, Name = crmServiceClient.ConnectedOrgFriendlyName }; this.tbx_connectionName.IsReadOnly = false; this.tbx_connectionName.Text = this.crmConnection.Name; this.tbx_connectionName.Text = this.crmConnection.Name; this.Lbl_ConnectionName.Visibility = Visibility.Visible; this.tbx_connectionName.Visibility = Visibility.Visible; btn_save.IsEnabled = true; } else { MessageBox.Show((string)Application.Current.FindResource("ConnectionManager_Code_UnableToOpenCRM"), (string)Application.Current.FindResource("ConnectionManager_Code_UnableToOpenCRM_Caption"), MessageBoxButton.OK, MessageBoxImage.Error); } } } catch (Exception ex) { if (!Properties.Settings.Default.DisableErrorReports) { Diagnostics.ErrorReport errorReport = new Diagnostics.ErrorReport(ex); errorReport.Show(); } ConnectionManger.Log.Error(ex.Message, ex); } }
/// <summary> /// Initializes a new instance of the <see cref="DownloadMultiple"/> class. /// </summary> /// <param name="crmConnection"><see cref="Xrm.CrmConnection"/> for the XRM Connector</param> /// <param name="crmSolutions"><see cref="List{Xrm.CrmSolution}"/> of all Solutions to Download</param> public DownloadMultiple(Core.Xrm.CrmConnection crmConnection, List <Core.Xrm.CrmSolution> crmSolutions) { this.InitializeComponent(); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us"); DownloadMultiple.statusTextBox = this.tbx_status; DownloadMultiple.LogToUI("Started Form"); this.Btn_close.IsEnabled = false; this.CRMConnection = crmConnection; DownloadMultiple.LogToUI($"CRM Connection: {this.CRMConnection.Name}", true); this.CRMSolutions = crmSolutions; foreach (Core.Xrm.CrmSolution crmSolution in this.CRMSolutions) { DownloadMultiple.LogToUI($"Added Solution: { crmSolution.UniqueName} to Download List", true); } this.tbx_download.Text = crmConnection.LocalPath; DownloadMultiple.LogToUI($"Pulled Path form config: {crmConnection.LocalPath}", true); this.Owner = App.Current.MainWindow; }
/// <summary> /// Button Action, Download /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void Button_Click(object sender, RoutedEventArgs e) { if (this.tbx_download.Text != string.Empty) { this.loadingPanel.IsLoading = true; this.selectedPath = tbx_download.Text; Core.Xrm.CrmConnection crmConnection = new Core.Xrm.CrmConnection { ConnectionID = Core.Data.StorageExtensions.FindConnectionIDByName(this.CRMConnection.Name), ConnectionString = this.CRMConnection.ConnectionString, LocalPath = this.selectedPath, Name = this.CRMConnection.Name }; this.CRMConnection = crmConnection; if ((bool)Cbx_ExportLables.IsChecked) { this.localizeSupport = true; } else { this.localizeSupport = false; } // Update Connection Core.Data.StorageExtensions.Update(crmConnection, MainWindow.EncryptionKey); // Background Worker this.worker.DoWork += this.Worker_DoWork; this.worker.RunWorkerCompleted += this.Worker_RunWorkerCompleted; this.worker.WorkerReportsProgress = true; this.worker.RunWorkerAsync(); } else { MessageBox.Show("Path can not be empty", "Path empty", MessageBoxButton.OK, MessageBoxImage.Error); } }