/// <summary> /// Event delegate method fired when <see cref="AppendDataHotLabel"/> is clicked. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="e">Event arguments.</param> private void AppendDataHotLabel_Click(object sender, EventArgs e) { var selectedNode = DBObjectList.SelectedNode; if (selectedNode == null || selectedNode.Type != MySqlListViewNode.MySqlNodeType.DbObject || !(selectedNode.DbObject is DbTable) || _wbConnection == null) { return; } var passwordFlags = _wbConnection.TestConnectionAndRetryOnWrongPassword(); if (!passwordFlags.ConnectionSuccess) { return; } try { ExportDataToTable(selectedNode.DbObject as DbTable); } catch (Exception ex) { MiscUtilities.ShowCustomizedErrorDialog(Resources.AppendDataErrorTitle, ex.Message, true); MySqlSourceTrace.WriteAppErrorToLog(ex); } finally { if (Cursor == Cursors.WaitCursor) { Cursor = Cursors.Default; } } }
/// <summary> /// Event delegate method fired when <see cref="NextButton"/> is clicked. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="e">Event arguments.</param> private void NextButton_Click(object sender, EventArgs e) { var selectedNode = SchemasList.SelectedNode; if (selectedNode == null || selectedNode.Type == MySqlListViewNode.MySqlNodeType.Header || string.IsNullOrEmpty(selectedNode.DbObject.Name)) { return; } var passwordFlags = _wbConnection.TestConnectionAndRetryOnWrongPassword(); if (!passwordFlags.ConnectionSuccess) { return; } try { if (Parent is ExcelAddInPane excelAddInPane) { excelAddInPane.OpenSchema(selectedNode.DbObject.Name, true); } } catch (Exception ex) { Logger.LogException(ex, true, Resources.SchemaOpeningErrorTitle); } }
/// <summary> /// Event delegate method fired when <see cref="NextButton"/> is clicked. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="e">Event arguments.</param> private void NextButton_Click(object sender, EventArgs e) { var selectedNode = SchemasList.SelectedNode; if (selectedNode == null || selectedNode.Type == MySqlListViewNode.MySqlNodeType.Header || string.IsNullOrEmpty(selectedNode.DbObject.Name)) { return; } var passwordFlags = _wbConnection.TestConnectionAndRetryOnWrongPassword(); if (!passwordFlags.ConnectionSuccess) { return; } try { var excelAddInPane = Parent as ExcelAddInPane; if (excelAddInPane != null) { excelAddInPane.OpenSchema(selectedNode.DbObject.Name, true); } } catch (Exception ex) { MiscUtilities.ShowCustomizedErrorDialog(Resources.SchemaOpeningErrorTitle, ex.Message, true); MySqlSourceTrace.WriteAppErrorToLog(ex); } }
/// <summary> /// Sets and opens the current active connection used to browse schemas and DB objects. /// </summary> /// <param name="connection">A <see cref="MySqlWorkbenchConnection"/> object representing the connection to a MySQL server instance selected by users.</param> /// <param name="givePanelFocus">Flag indicating whether the <see cref="SchemaSelectionPanel"/> is given focus.</param> public PasswordDialogFlags OpenConnection(MySqlWorkbenchConnection connection, bool givePanelFocus) { WbConnection = connection; var passwordFlags = WbConnection.TestConnectionAndRetryOnWrongPassword(); if (passwordFlags.ConnectionSuccess && SchemaSelectionPanel2.SetConnection(WbConnection) && givePanelFocus) { RefreshWbConnectionTimeouts(); SchemaSelectionPanel2.BringToFront(); } return(passwordFlags); }
/// <summary> /// Creates a new schema with the given name. /// </summary> /// <returns><c>true</c> if the schema was created successfully, <c>false</c> otherwise.</returns> private bool CreateSchema() { var passwordFlags = _wbConnection.TestConnectionAndRetryOnWrongPassword(); if (!passwordFlags.ConnectionSuccess) { return(false); } Cursor = Cursors.WaitCursor; string createSql = _wbConnection.GetCreateSchemaSql(SchemaName, CharSet, Collation, false); var operationInfoText = string.Format(Resources.ScriptCreatingSchemaText, SchemaName); List <IMySqlDataRow> results; using (var sqlScriptDialog = new MySqlScriptDialog(_wbConnection, createSql, operationInfoText)) { if (Settings.Default.GlobalSqlQueriesPreviewQueries) { sqlScriptDialog.ShowDialog(); } else { sqlScriptDialog.ApplyScript(); } var erroredOutRow = sqlScriptDialog.ErroredOutDataRow; results = sqlScriptDialog.ScriptResult == MySqlStatement.StatementResultType.ErrorThrown ? erroredOutRow != null ? new List <IMySqlDataRow>(1) { erroredOutRow } : null : sqlScriptDialog.ActualStatementRowsList; } if (results == null) { Cursor = Cursors.Default; return(false); } string operationSummary; bool success = true; bool warningsFound = false; var operationDetails = new StringBuilder(); var warningStatementDetails = new StringBuilder(); foreach (var statement in results.Select(statementRow => statementRow.Statement)) { // Create details text for the schema creation. switch (statement.StatementType) { case MySqlStatement.SqlStatementType.CreateSchema: break; case MySqlStatement.SqlStatementType.GrantAll: break; } if (Settings.Default.GlobalSqlQueriesShowQueriesWithResults) { operationDetails.AppendFormat(Resources.NewSchemaExecutedQuery, SchemaName); operationDetails.AddNewLine(2); operationDetails.Append(statement.SqlQuery); operationDetails.AddNewLine(2); } switch (statement.StatementResult) { case MySqlStatement.StatementResultType.Successful: operationDetails.AppendFormat(Resources.NewSchemaCreatedSuccessfullyText, SchemaName); break; case MySqlStatement.StatementResultType.WarningsFound: warningsFound = true; operationDetails.AppendFormat(Resources.NewSchemaCreatedWithWarningsText, SchemaName, statement.WarningsQuantity); operationDetails.AddNewLine(); operationDetails.Append(statement.ResultText); break; case MySqlStatement.StatementResultType.ErrorThrown: success = false; operationDetails.AppendFormat(Resources.NewSchemaCreationErrorText, SchemaName); operationDetails.AddNewLine(); operationDetails.Append(statement.ResultText); break; } } InfoDialog.InfoType operationsType; if (success) { operationSummary = string.Format(Resources.NewSchemaOperationSuccessSummaryText, SchemaName); operationsType = warningsFound ? InfoDialog.InfoType.Warning : InfoDialog.InfoType.Success; } else { operationSummary = string.Format(Resources.NewSchemaOperationErrorSummaryText, SchemaName); operationsType = InfoDialog.InfoType.Error; } Cursor = Cursors.Default; MiscUtilities.ShowCustomizedInfoDialog(operationsType, operationSummary, operationDetails.ToString(), false); operationDetails.Clear(); warningStatementDetails.Clear(); return(success); }