public override void DoubleClick(Action <string> showMsg) { Tuple <DataSet, string> tp = AccessAndExcelOp.GetDataFromExcelByConn(NamesManage.ConTactorTbName, NamesManage.RelayTbName, NamesManage.IndicatorTbName); if (tp != null) { TerminalRelationsDao dao = new TerminalRelationsDao();//Table到实体类的映射工具 /*接触器库*/ DataTable table = tp.Item1.Tables[NamesManage.ConTactorTbName]; config.ContactorPins = dao.getRelayPins(table); showMsg(String.Format("加载接触器端子信息{0}条。\r\n", config.ContactorPins.Count)); base.Itemvms.Add(new ConTactorLibDisplay(this)); /*继电器库*/ table = tp.Item1.Tables[NamesManage.RelayTbName]; config.RelayPins = dao.getRelayPins(table); showMsg(String.Format("加载继电器端子信息{0}条。\r\n", config.RelayPins.Count)); base.Itemvms.Add(new RelayLibDisplay(this)); /*指示灯模块库*/ table = tp.Item1.Tables[NamesManage.IndicatorTbName]; config.IndicatorPins = dao.getIndicatorPins(table); showMsg(String.Format("加载指示灯模块端子信息{0}条。\r\n", config.IndicatorPins.Count)); base.Itemvms.Add(new IndicatorLibDisplay(this)); /*保存本地*/ SerializeData <Configuration> .T_WriteBinary(config, NamesManage.ConfigFileName); } }
/// <summary> /// 保存转化成的表格到Excel中 /// </summary> protected DataView SaveBranchesToExcel(string tbName) { AppProject pro = AppProject.GetInstance(); if (nets.Count() == 0) { return(null); } int columns = getColumnCount(); string cmd = "CREATE TABLE " + tbName + " ("; cmd += "网络号 VARCHAR(100),"; for (int i = 0; i < columns; i++) { cmd += string.Format("部位{0} VARCHAR(100),端子号{1} VARCHAR(100),端口类型{2} VARCHAR(100),", i, i, i); } cmd = cmd.Substring(0, cmd.Length - 1) + ")"; using (OleDbConnection cnn = AccessAndExcelOp.GetExcelConnect(pro.OriginFileName + "(测试支路).xls")) { List <string> tbnames = AccessAndExcelOp.GetTableNames(cnn); string deleteCmd = "Drop Table " + tbName; if (tbnames.Contains(tbName)) { AccessAndExcelOp.ExecuteNoQueryCmd(cnn, deleteCmd); } AccessAndExcelOp.CreateTable(cnn, cmd); DataTable table = AccessAndExcelOp.GetTable(cnn, tbName); fillTable(table); AccessAndExcelOp.UpdateSourceTable(cnn, table); return(table.AsDataView()); } }
/// <summary> /// 保存到excel /// </summary> public System.Data.DataView SaveBranchesToExcel() { AppProject pro = AppProject.GetInstance(); string tbName = "接口配置"; if (linkerRelation.Count() == 0) { return(null); } string cmd = "CREATE TABLE 接口配置 (连接器 VARCHAR(100),连接器端口 VARCHAR(100),测试箱 VARCHAR(100),测试箱端口 VARCHAR(100),线号 VARCHAR(100))"; using (OleDbConnection cnn = AccessAndExcelOp.GetExcelConnect(pro.OriginFileName + "(测试支路).xls")) { List <string> tbnames = AccessAndExcelOp.GetTableNames(cnn); if (tbnames.Contains(tbName)) { string deleteCmd = "Drop Table " + tbName; AccessAndExcelOp.ExecuteNoQueryCmd(cnn, deleteCmd); } AccessAndExcelOp.CreateTable(cnn, cmd); DataTable table = AccessAndExcelOp.GetTable(cnn, tbName); foreach (var link in linkerRelation) { DataRow row = table.NewRow(); row[0] = link.Key.LinkerName; row[1] = link.Key.LinkerPort; row[2] = link.Value.TestBoxNum; row[3] = link.Value.TestBoxPort; row[4] = link.Value.LineNum; table.Rows.Add(row); } AccessAndExcelOp.UpdateSourceTable(cnn, table); return(table.AsDataView()); } }
public override void DoubleClick(Action <string> showMsg) { base.Itemvms.Clear(); Tuple <DataSet, string> tp = AccessAndExcelOp.GetDataFromExcelByConn(NamesManage.VoltTbName, NamesManage.CptTbName, NamesManage.TBTbName); if (tp != null) { ComponentConfigDao dao = new ComponentConfigDao();//元件配置表实体转换类 /*电压给定表*/ DataTable table = tp.Item1.Tables[NamesManage.VoltTbName]; config.Vsets = dao.getVccConfig(table); showMsg(String.Format("加载电压给定表{0}条。\r\n", config.Vsets.Count)); base.Itemvms.Add(new VoltDisplay(this)); /*元件配置表*/ table = tp.Item1.Tables[NamesManage.CptTbName]; config.Cptlib = dao.getComponentInfo(table); showMsg(String.Format("加载元件名称表{0}条。\r\n", config.Cptlib.Count)); base.Itemvms.Add(new CptDisplay(this)); /*端子排短接表*/ table = tp.Item1.Tables[NamesManage.TBTbName]; config.Tblib = dao.getTermialRelations(table); showMsg(String.Format("加载端子排短接表{0}条。\r\n", config.Tblib.Count)); base.Itemvms.Add(new TBDisplay(this)); } /*保存本地*/ try { SerializeData <Configuration> .T_WriteBinary(Configuration.GetInstance(), NamesManage.ConfigFileName); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); } }
public override void DoubleClick(Action <string> showMsg) { Tuple <DataSet, string> tp = AccessAndExcelOp.GetDataFromExcelByConn(NamesManage.OriginTbName); Action waitForFinish = () => { if (tp != null) { GraphDao dao = new GraphDao(); DataTable table = tp.Item1.Tables[NamesManage.OriginTbName]; pro.Cells = dao.getComponentRelations(table); pro.OriginFileName = tp.Item2; showMsg(String.Format("加载元件清单信息{0}条。\r\n", pro.Cells.Count)); pro.BuildGraphData(); showMsg(String.Format("电路图拓扑结构导入完成,共包含{0}个节点。\r\n", pro.Nodes.Count)); } }; Messenger.Default.Send <Action>(waitForFinish, "WaitForFinish"); base.Itemvms.Add(new CptRelationDisplay(this)); }