Пример #1
0
        public static string GetTableName(string key)
        {
            if (key == null)
            {
                return(null);
            }
            string text = RDBResource.GetString(key);

            if (text == null)
            {
                return(null);
            }
            string text2 = null;

            DatabaseManager.KeywordsMap.TryGetValue(text, out text2);
            if (text2 != null)
            {
                text = text2;
            }
            if (DatabaseManager.isExcelExport)
            {
                int num = 30;
                if (text.Length > num)
                {
                    text = text.Substring(0, num);
                }
            }
            return(text);
        }
Пример #2
0
        private void tableDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            string text = string.Format(RDBResource.GetString("tableDataGridView_DataError"), new object[]
            {
                e.RowIndex,
                e.ColumnIndex,
                e.Context,
                e.Exception
            });

            Log.WriteLine(text);
            MessageBox.Show(text);
        }
Пример #3
0
        public static string GetColumnName(string key)
        {
            string @string = RDBResource.GetString(key);

            if (@string == null)
            {
                Log.WriteLine("Value is null for key: {0}", new object[]
                {
                    key
                });
            }
            return(DatabaseManager.GetValidCoumnName(@string));
        }
Пример #4
0
 public ColumnInfo(BuiltInParameter parameterId, DataType dataType) : this()
 {
     this.BuiltInParameter = parameterId;
     this.DataType         = dataType;
     this.ColumnId         = RDBResource.GetColumnId(parameterId);
     this.Name             = RDBResource.GetColumnName(parameterId);
     if (Command.ConfigFile.DebugSQL)
     {
         Log.WriteLine("\t\tName [{0}]", new object[]
         {
             this.Name
         });
     }
 }
Пример #5
0
 public bool Open()
 {
     this.Terminate();
     this.m_connection = new OdbcConnection(this.m_ConnectionString);
     Log.WriteLine("ODBCDriver Opened");
     Log.WriteLine("Conn String = " + this.m_ConnectionString);
     try
     {
         this.m_connection.Open();
     }
     catch (System.Exception ex)
     {
         TaskDialog.Show(RDBResource.GetString("Connect_Database_Failed"), ex.ToString());
         return(false);
     }
     return(true);
 }
Пример #6
0
        private void okButton_Click(object sender, System.EventArgs e)
        {
            CategorySet categorySet = new CategorySet();

            foreach (Category category in this.categoryCheckedListBox.CheckedItems)
            {
                categorySet.Insert(category);
            }
            this.m_parameterInfo.Categories = categorySet;
            string text = this.nameTextBox.Text.Trim();

            if (text == string.Empty)
            {
                MessageBox.Show(RDBResource.GetString("MessageBox_Name_Shoud_Not_Be_Empty"));
                return;
            }
            if (char.IsNumber(text[0]) || text[0] == ' ')
            {
                MessageBox.Show(RDBResource.GetString("MessageBox_Name_Should_Start_With_Letter"));
                return;
            }
            string text2 = text;

            for (int i = 0; i < text2.Length; i++)
            {
                char c = text2[i];
                if (!char.IsLetterOrDigit(c) && c != '_' && c != ' ')
                {
                    MessageBox.Show(string.Format(RDBResource.GetString("MessageBox_Name_Contains_Illegal_Characters"), c));
                    return;
                }
            }
            if (this.categoryCheckedListBox.CheckedItems.Count == 0)
            {
                MessageBox.Show(RDBResource.GetString("MessageBox_Select_One_Category"));
                return;
            }
            this.m_parameterInfo.ParameterIsProject = this.projectParameterRadioButton.Checked;
            this.m_parameterInfo.ParameterForType   = this.typeRadioButton.Checked;
            this.m_parameterInfo.ParameterName      = text;
            this.m_parameterInfo.ParameterGroup     = (BuiltInParameterGroup)this.groupComboBox.SelectedItem;
            this.m_parameterInfo.ParameterType      = (ParameterType)this.typeComboBox.SelectedItem;
            base.Close();
            base.DialogResult = DialogResult.OK;
        }
Пример #7
0
 public TableInfo(string tableId)
 {
     this.m_tableId = tableId;
     if (Command.ConfigFile.DebugSQL)
     {
         Log.WriteLine("TableInfo ctor: tableId [{0}]", new object[]
         {
             this.m_tableId
         });
     }
     this.m_name = RDBResource.GetTableName(this.m_tableId);
     if (Command.ConfigFile.DebugSQL)
     {
         Log.WriteLine("\ttableName [{0}]", new object[]
         {
             this.m_name
         });
     }
 }
Пример #8
0
        public string GetValidCoumnName(string columnName)
        {
            // *** Coyove Patched ***

            if (string.IsNullOrEmpty(columnName))
            {
                throw new System.ArgumentException(RDBResource.GetString("Exception_ColumnNameIsEmpty"), "columnName");
            }
            string databaseName;

            if ((databaseName = this.GetDatabaseName()) != null)
            {
                string text;
                if (!(databaseName == "Microsoft SQL Server"))
                {
                    if (!(databaseName == "ACCESS"))
                    {
                        if (!(databaseName == "EXCEL"))
                        {
                            return(columnName);
                        }
                        text = Regex.Replace(columnName, "['#\\.!`\\[\\]]", (Match m) => string.Empty);
                    }
                    else
                    {
                        text = Regex.Replace(columnName, "[\\.!`\\[\\]']", (Match m) => string.Empty);
                    }
                }
                else
                {
                    text = Regex.Replace(columnName, "^[#'`\\t ]", (Match m) => string.Empty);
                }
                text = text.Trim();
                if (text.Length > 64)
                {
                    text = text.Substring(0, 64);
                }
                return(text);
            }
            return(columnName);
        }
Пример #9
0
 public ColumnInfo(string columnId, DataType dataType) : this()
 {
     this.ColumnId         = columnId;
     this.DataType         = dataType;
     this.BuiltInParameter = (BuiltInParameter)(-1);
     if (Command.ConfigFile.DebugSQL)
     {
         Log.WriteLine("\tColumnInfo ctor [{0}] {1}", new object[]
         {
             this.ColumnId,
             dataType
         });
     }
     this.Name = RDBResource.GetColumnName(this.ColumnId);
     if (Command.ConfigFile.DebugSQL)
     {
         Log.WriteLine("\t\tName [{0}]", new object[]
         {
             this.Name
         });
     }
 }
Пример #10
0
        public override void ExportToDataTable(DataTable dataTable)
        {
            if (dataTable == null)
            {
                return;
            }
            base.DataTable = dataTable;
            string  @string = RDBResource.GetString("ExportedDrawing");
            DataRow dataRow = this.GetDataRow(@string);

            if (dataRow == null)
            {
                dataRow = dataTable.NewRow();
                dataTable.Rows.Add(dataRow);
                Utility.Assign(dataRow, APIObjectList.ColumnRes("ColN_CST_Name"), @string);
            }
            string a = dataRow[APIObjectList.ColumnRes("ColN_CST_Value")] as string;

            if (a != APIObjectList.ActiveDocument.PathName)
            {
                Utility.Assign(dataRow, APIObjectList.ColumnRes("ColN_CST_Value"), APIObjectList.ActiveDocument.PathName);
            }
        }
Пример #11
0
        private void RevitDBLinkForm_Load(object sender, System.EventArgs e)
        {
            if (DatabaseManager.CanExport(DatabaseManager.DatabaseType.MSAccess))
            {
                Log.WriteLine("Load MSAccess2003 connection history to UI");
                this.m_previousHistory = DatabaseManager.GetPreviousConnectionsFor(DatabaseManager.DatabaseType.MSAccess);
                this.LogHistory();
                this.msAccess2003PreviousListBox.Items.Add(RDBResource.GetString("IDS_SELECT_NEW_CONNECTION"));
                foreach (string current in this.m_previousHistory)
                {
                    this.msAccess2003PreviousListBox.Items.Add(current);
                }
                this.msAccess2003PreviousListBox.Tag = this.m_previousHistory;
            }
            else
            {
                this.exportAccess2003Button.Enabled = false;
                this.importAccess2003Button.Enabled = false;
            }
            if (DatabaseManager.CanExport(DatabaseManager.DatabaseType.MSAccess2007))
            {
                Log.WriteLine("Load MSAccess2007 connection history to UI");
                this.m_previousHistory = DatabaseManager.GetPreviousConnectionsFor(DatabaseManager.DatabaseType.MSAccess2007);
                this.LogHistory();
                this.msAccess2007PreviousListBox.Items.Add(RDBResource.GetString("IDS_SELECT_NEW_CONNECTION"));
                foreach (string current2 in this.m_previousHistory)
                {
                    this.msAccess2007PreviousListBox.Items.Add(current2);
                }
                this.msAccess2007PreviousListBox.Tag = this.m_previousHistory;
            }
            else
            {
                this.exportAccess2007Button.Enabled = false;
                this.importAccess2007Button.Enabled = false;
            }
            if (DatabaseManager.CanExport(DatabaseManager.DatabaseType.ODBC))
            {
                Log.WriteLine("Load ODBC connection history to UI");
                this.m_previousHistory = DatabaseManager.GetPreviousConnectionsFor(DatabaseManager.DatabaseType.ODBC);
                this.LogHistory();
                this.odbcPreviousListBox.Items.Add(RDBResource.GetString("IDS_SELECT_NEW_CONNECTION"));
                foreach (string current3 in this.m_previousHistory)
                {
                    this.odbcPreviousListBox.Items.Add(current3);
                }
                this.odbcPreviousListBox.Tag = this.m_previousHistory;
            }
            else
            {
                this.exportOdbcButton.Enabled = false;
                this.importOdbcButton.Enabled = false;
            }
            Log.WriteLine("DatabaseManager.LastDatabaseType = " + DatabaseManager.LastDatabaseType);
            if (DatabaseManager.LastDatabaseType == DatabaseManager.DatabaseType.Invalid)
            {
                if (this.exportAccess2003Button.Enabled)
                {
                    this.tabControl.SelectedTab = this.msAccess2003Tabpage;
                    Log.WriteLine("Access2003 tab is selected");
                    return;
                }
                if (this.exportAccess2007Button.Enabled)
                {
                    this.tabControl.SelectedTab = this.msAccess2007Tabpage;
                    Log.WriteLine("Access2007 tab is selected");
                    return;
                }
                if (this.exportOdbcButton.Enabled)
                {
                    this.tabControl.SelectedTab = this.odbcTabpage;
                    Log.WriteLine("odbc tab set is selected");
                    return;
                }
            }
            else
            {
                switch (DatabaseManager.LastDatabaseType)
                {
                case DatabaseManager.DatabaseType.ODBC:
                    this.tabControl.SelectedTab = this.odbcTabpage;
                    Log.WriteLine("odbc tab set is selected");
                    break;

                case DatabaseManager.DatabaseType.MSAccess:
                    this.tabControl.SelectedTab = this.msAccess2003Tabpage;
                    Log.WriteLine("Access2003 tab is selected");
                    return;

                case DatabaseManager.DatabaseType.MSAccess2007:
                    this.tabControl.SelectedTab = this.msAccess2007Tabpage;
                    Log.WriteLine("Access2007 tab is selected");
                    return;

                default:
                    return;
                }
            }
        }
Пример #12
0
 public TableInfo With(Action <TableInfo, string, string, string, string> wfunction, string refTableId1, string refColumnId1, string refTableId2, BuiltInParameter refColumnId2)
 {
     wfunction(this, refTableId1, refColumnId1, refTableId2, RDBResource.GetColumnId(refColumnId2));
     return(this);
 }
Пример #13
0
 private void addButton_Click(object sender, System.EventArgs e)
 {
     using (ParameterPropertyForm parameterPropertyForm = new ParameterPropertyForm(this.m_revitUiApp))
     {
         if (parameterPropertyForm.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 if (!this.m_parameterCreation.CreateUserDefinedParameter(parameterPropertyForm.ParameterInfo))
                 {
                     MessageBox.Show(RDBResource.GetString("MessageBox_Import_CreateParameterFailed"));
                 }
                 else
                 {
                     ParameterInfo parameterInfo = parameterPropertyForm.ParameterInfo;
                     this.parameterListBox.Items.Add(parameterInfo.ParameterName);
                     this.parameterListBox.SelectedItem = parameterInfo.ParameterName;
                     foreach (Category category in parameterInfo.Categories)
                     {
                         if (category != null)
                         {
                             string tableKey  = RDBResource.GetTableKey(category.Id.IntegerValue, parameterInfo.ParameterForType);
                             string tableName = RDBResource.GetTableName(tableKey);
                             if (tableName != null && !Command.ColumnExists(tableName, parameterInfo.ParameterName))
                             {
                                 bool flag = Command.AddColumn(parameterInfo.ParameterName, DatabaseManager.GetDataType(parameterInfo.ParameterType), tableName);
                                 if (flag)
                                 {
                                     bool      flag2     = true;
                                     TableInfo tableInfo = this.m_tableInfoSet[tableKey];
                                     foreach (ColumnInfo current in tableInfo.Values)
                                     {
                                         if (current.Name == parameterInfo.ParameterName)
                                         {
                                             flag2 = false;
                                             break;
                                         }
                                     }
                                     if (flag2)
                                     {
                                         tableInfo.AddColumn(new CustomColumnInfo(parameterInfo.ParameterName, DatabaseManager.GetDataType(parameterInfo.ParameterType)));
                                     }
                                     if (this.m_dataSet.Tables.Contains(tableName))
                                     {
                                         Log.WriteLine("Refresh data table " + tableName + " after addding column");
                                         Command.RefreshDataTable(this.m_dataSet.Tables[tableName]);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             catch (System.Exception ex)
             {
                 MessageBox.Show(ex.Message);
                 Log.WriteLine(ex.ToString());
             }
         }
     }
 }
Пример #14
0
        public bool CreateDatabase(TableInfoSet tableinfoset, out string errorMessage)
        {
            errorMessage = string.Empty;
            Log.WriteLine("Create tables ...");
            Log.Indent();
            foreach (TableInfo current in tableinfoset.Values)
            {
                if (current.PrimaryKeys.Count > 1)
                {
                    Log.WriteLine("{0},{1}", new object[]
                    {
                        current.TableId,
                        current.Name
                    });
                    Log.Indent();
                    foreach (string current2 in current.PrimaryKeys)
                    {
                        Log.WriteLine("primaryKey:" + current2);
                    }
                    Log.Unindent();
                }
                if (this.TableExist(current.Name))
                {
                    if (DatabaseManager.isExcelExport)
                    {
                        MessageBox.Show(RDBResource.GetString("MessageBox_CanNotUpdateExcelTable"), RDBResource.GetString("MessageBox_CanNotUpdateExcelTable_Title"), MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        bool result = false;
                        return(result);
                    }
                    System.Collections.Generic.List <ColumnInfo> list = new System.Collections.Generic.List <ColumnInfo>();
                    foreach (ColumnInfo current3 in current.Values)
                    {
                        if (!this.ColumnExist(current.Name, current3.Name))
                        {
                            list.Add(current3);
                        }
                    }
                    if (list.Count > 0)
                    {
                        string addColumnSqlStmt = this.GetAddColumnSqlStmt(current.Name, list);
                        bool   flag             = this.ExecuteSQL(addColumnSqlStmt);
                        if (Command.ConfigFile.DebugSQL && !flag)
                        {
                            Log.WriteWarning("Update table '" + current.Name + "' failed, statement: " + addColumnSqlStmt);
                        }
                    }
                }
                else
                {
                    string tableCreationSqlStmt = this.GetTableCreationSqlStmt(current);

                    if (Command.ConfigFile.DebugSQL)
                    {
                        Log.WriteLine("Create table: (" + current.Name + ") " + tableCreationSqlStmt);
                    }
                    if (!this.ExecuteSQL(tableCreationSqlStmt))
                    {
                        Log.WriteError("Failed: " + tableCreationSqlStmt);
                        errorMessage = tableCreationSqlStmt;
                        bool result = false;
                        return(result);
                    }
                }
                this.ProgressStep();
            }
            Log.Unindent();
            Log.WriteLine("Create tables Finished");
            Log.WriteLine("Add foreign keys ...");
            Log.Indent();
            if (!DatabaseManager.isExcelExport)
            {
                foreach (TableInfo current4 in tableinfoset.Values)
                {
                    string[] tableForeignKeysSqlStmt = this.GetTableForeignKeysSqlStmt(current4);
                    string[] array = tableForeignKeysSqlStmt;
                    for (int i = 0; i < array.Length; i++)
                    {
                        string sqlStmt = array[i];
                        this.ExecuteSQL(sqlStmt);
                    }
                    this.ProgressStep();
                }
            }
            Log.Unindent();
            Log.WriteLine("Add foreign keys Finished");
            return(true);
        }
Пример #15
0
 public TableInfo WithPrimaryKey(BuiltInParameter parameterId)
 {
     return(this.WithPrimaryKey(RDBResource.GetColumnId(parameterId)));
 }
Пример #16
0
 public TableInfo WithForeignKey(string columnId, string refTableId, BuiltInParameter refColumnId)
 {
     return(this.WithForeignKey(columnId, refTableId, RDBResource.GetColumnId(refColumnId)));
 }
Пример #17
0
 protected static string ColumnRes(string key)
 {
     return(RDBResource.GetColumnName(key));
 }
Пример #18
0
 private void groupComboBox_Format(object sender, ListControlConvertEventArgs e)
 {
     e.Value = RDBResource.GetString("IDS_" + e.ListItem.ToString());
 }
Пример #19
0
 protected static string ColumnRes(BuiltInParameter key)
 {
     return(RDBResource.GetColumnName(key));
 }
Пример #20
0
 public ConfigFile()
 {
     this.m_revitIniFileName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(typeof(ConfigFile).Assembly.Location), RDBResource.GetString("ConfigurationFileName"));
     this.DebugProgressBar   = this.GetBoolean("DebugMode", "DebugProgressBar");
     this.DebugSQL           = this.GetBoolean("DebugMode", "DebugSQL");
     this.Debug = this.GetBoolean("DebugMode", "Debug");
     this.IgnoreSpecificTables = this.GetBoolean("DebugMode", "IgnoreSpecificTables");
 }
Пример #21
0
 public RevitDBLinkForm()
 {
     this.InitializeComponent();
     this.m_contextualHelp = new ContextualHelp((ContextualHelpType)1, RDBResource.GetString("Form_RevitDBLinkForm_ContextId_Overview"));
     base.HelpButton       = true;
 }