//创建curveName字典和数据库及其表 private void createCurveNameDictionaryAndDB() { //创建数据库 if (m_wellConfig_From.getwellcountPath() == "" || m_wellConfig_From.getwellcountPath() == null) { MessageBox.Show("未配置井路径,请配置!"); return; } String wellcountPath = m_wellConfig_From.getwellcountPath(); String wellcount = m_wellConfig_From.getwellcount(); String filename = wellcount + ".db3"; String dbPath = m_wellConfig_From.creatDirectory(wellcountPath, filename); m_realDBHelper = m_wellConfig_From.getRealDBHelper(); m_realDBHelper.CreateDB(dbPath); //m_realDBHelper.InsertWellInfo(dbPath); m_dBHelper = new SQLiteDBHelper(dbPath); m_dBHelper.CreateDB(dbPath); List <String> serverTableList = new List <string>(); List <String> clientTableList = new List <string>(); DataTable curveNameTable = new DataTable(); List <String> curveNameList = new List <string>(); //获取Server和Client所选仪器及对应选择的表号 Dictionary <String, List <String> > selectServerToolDictionary = m_recConfig_Form.getSelectServerToolDictionary(); Dictionary <String, List <String> > selectClientToolDictionary = m_recConfig_Form.getSelectClientToolDictionary(); //创建曲线字典和wits表 if (selectServerToolDictionary != null) { foreach (String toolName in selectServerToolDictionary.Keys) { if (selectServerToolDictionary.TryGetValue(toolName, out serverTableList)) { //根据toolName创建Wits表字典,供查询index对应的curveName(短助记符) Dictionary <String, DataTable> curveNameDictionary = m_CurveNameDictionary.createDictionary(toolName, serverTableList); m_curveNameDictionary.Add(toolName, m_CurveNameDictionary.createDictionary(toolName, serverTableList)); serverTableList.Clear(); //同一个仪器名下的wits表 Dictionary <String, WitsTable> witsTableDic = new Dictionary <string, WitsTable>(); //创建数据库表和WITS表 foreach (String tableNo in curveNameDictionary.Keys) { if (curveNameDictionary.TryGetValue(tableNo, out curveNameTable)) { for (int i = 0; i < curveNameTable.Rows.Count; i++) { curveNameList.Add(curveNameTable.Rows[i][1].ToString()); } m_dBHelper.CreateTabs(toolName, tableNo, curveNameList); WitsTable witsTable = new WitsTable(toolName, tableNo, curveNameList); witsTableDic.Add(tableNo, witsTable); curveNameTable.Clear(); curveNameList.Clear(); } } m_witsTableDictionary.Add(toolName, witsTableDic); } } } if (selectClientToolDictionary != null) { foreach (String toolName in selectClientToolDictionary.Keys) { if (selectClientToolDictionary.TryGetValue(toolName, out clientTableList)) { //根据toolName创建Wits表字典,供查询index对应的curveName(短助记符) Dictionary <String, DataTable> curveNameDictionary = m_CurveNameDictionary.createDictionary(toolName, clientTableList); m_curveNameDictionary.Add(toolName, m_CurveNameDictionary.createDictionary(toolName, clientTableList)); clientTableList.Clear(); //同一个仪器名下的wits表 Dictionary <String, WitsTable> witsTableDic = new Dictionary <string, WitsTable>(); //创建数据库表和WITS表 foreach (String tableNo in curveNameDictionary.Keys) { if (curveNameDictionary.TryGetValue(tableNo, out curveNameTable)) { for (int i = 0; i < curveNameTable.Rows.Count; i++) { curveNameList.Add(curveNameTable.Rows[i][1].ToString()); } m_dBHelper.CreateTabs(toolName, tableNo, curveNameList); WitsTable witsTable = new WitsTable(toolName, tableNo, curveNameList); witsTableDic.Add(tableNo, witsTable); curveNameTable.Clear(); curveNameList.Clear(); } } m_witsTableDictionary.Add(toolName, witsTableDic); } } } }