/// <summary>
        /// Restores the internal objects.
        /// </summary>
        /// <param name="workbook">The <see cref="ExcelInterop.Workbook"/> tied to this <see cref="ImportConnectionInfo"/> object.</param>
        public void Restore(ExcelInterop.Workbook workbook)
        {
            if (workbook == null || workbook.GetOrCreateId() != WorkbookGuid)
            {
                return;
            }

            if (_excelTable == null && !string.IsNullOrEmpty(_excelTableName))
            {
                ExcelTable = workbook.GetExcelTableByName(WorksheetName, _excelTableName);
                if (ExcelTable == null)
                {
                    return;
                }
            }

            if (MySqlTable != null)
            {
                return;
            }

            if (_connection != null)
            {
                MySqlTable = _connection.CreateImportMySqlTable(OperationType, TableName, ImportColumnNames, SelectQuery, ProcedureResultSetIndex);
            }
            else
            {
                ConnectionInfoError = ConnectionInfoErrorType.WorkbenchConnectionDoesNotExist;
            }
        }
예제 #2
0
        /// <summary>
        /// Gets the active <see cref="EditConnectionInfo"/> related to a given <see cref="ExcelInterop.Workbook"/>.
        /// </summary>
        /// <param name="connectionInfosList">The <see cref="EditConnectionInfo"/> objects list.</param>
        /// <param name="workbook">The <see cref="ExcelInterop.Workbook"/> related to the active <see cref="EditConnectionInfo"/>.</param>
        /// <param name="tableName">Name of the table being edited in the <see cref="EditConnectionInfo"/>.</param>
        /// <returns>An <see cref="EditConnectionInfo"/> object.</returns>
        public static EditConnectionInfo GetActiveEditConnectionInfo(this List <EditConnectionInfo> connectionInfosList, ExcelInterop.Workbook workbook, string tableName)
        {
            var workBookId = workbook.GetOrCreateId();

            return(connectionInfosList == null ? null : connectionInfosList.FirstOrDefault(connectionInfo => connectionInfo.EditDialog != null &&
                                                                                           string.Equals(connectionInfo.WorkbookGuid, workBookId, StringComparison.InvariantCulture) &&
                                                                                           connectionInfo.TableName == tableName));
        }