public static bool TableRename(string strOldName, string strNewName) { try { if (string.IsNullOrEmpty(strOldName) || string.IsNullOrEmpty(strNewName) || docTable == null) { return(false); } if (!docTable.dicTableData.ContainsKey(strOldName) || docTable.dicTableData.ContainsKey(strNewName)) { return(false); } foreach (TableData item in docTable.listTableData) { if (item.Name.Equals(strOldName)) { item.Name = strNewName; item.Text = strNewName; docTable.dicTableData.Remove(strOldName); docTable.dicTableData.Add(strNewName, item); TableDriver temp = tableDrivers.dicDrivers[strOldName]; tableDrivers.dicDrivers.Remove(strOldName); temp.strDriverName = strNewName; tableDrivers.dicDrivers.Add(strNewName, temp); } } return(true); } catch (Exception) { return(false); } }
public static void InitTables() { tableDrivers = new TableDrivers(); foreach (KeyValuePair <string, TableData> item in docTable.dicTableData) { TableDriver driver = new TableDriver(); tableDrivers.dicDrivers.Add(item.Value.Name, driver); } foreach (KeyValuePair <string, TableDriver> item in tableDrivers.dicDrivers) { item.Value.Init(docTable.dicTableData[item.Key]); } }
/// <summary> /// 返回指定平台实例 /// </summary> /// <param name="strName">指定平台名称</param> /// <returns></returns> static public TableDriver TableDriver(string strName) { try { return(tableDrivers.drivers[strName]); } catch { MainModule.FormMain.m_formAlarm.InsertAlarmMessage("不存在名字为:" + strName + "的平台"); TableDriver table = new TableDriver(); tableDrivers.drivers.Add(strName, table); return(tableDrivers.drivers[strName]); } }
/// <summary> /// 初始化所有平台 /// </summary> static public void InitTables() { tableDrivers = new TableDrivers(); foreach (KeyValuePair <string, TableData> item in tablesDoc.m_tableDictionary) { TableDriver taDriver = new TableDriver(); tableDrivers.drivers.Add(item.Value.strTableName, taDriver); } foreach (KeyValuePair <string, TableDriver> item in tableDrivers.drivers) { item.Value.Init(tablesDoc.m_tableDictionary[item.Key]); } System.Threading.Thread thread = new System.Threading.Thread(ThreadScanTables); thread.IsBackground = true; thread.Start(); }
public static string AddNewTable() { try { TableData tableData = new TableData(true); tableData.Name = GetNewTableName(); tableData.Text = tableData.Name; docTable.listTableData.Add(tableData); docTable.dicTableData.Add(tableData.Name, tableData); TableDriver driver = new TableDriver(); tableDrivers.dicDrivers.Add(tableData.Name, driver); driver.Init(tableData); return(tableData.Name); } catch { return(null); } }