public ProcessLine(IModelDoc2 pDoc, ISldWorks swApp, List <string> routingIds) { _routingIds = routingIds; dicSketchRefProcess = new Dictionary <string, List <CSketchFileProcess> >(); InitializeComponent(); this.AutoSize = true; this.tvProcessLine.Height = Height; this.pDoc = pDoc; this.swApp = swApp; rcontext = new RoutingContext(DbConfig.Connection); rprContext = new RoutingProcessRelationContext(DbConfig.Connection); pfrContext = new ProcessFileRoutingContext(DbConfig.Connection); try { var slist = (from s in pfrContext.SketchFileProcesses where _routingIds.Contains(s.RoutingId) && s.ComponentName == GlobalCache.Instance.ComponetName select s).ToList <CSketchFileProcess>(); List <CSketchFileProcess> cSketchFileProcessList = null; slist.ForEach((x) => { if (dicSketchRefProcess.ContainsKey(x.RoutingId)) { cSketchFileProcessList = dicSketchRefProcess[x.RoutingId]; cSketchFileProcessList.Add(x); dicSketchRefProcess[x.RoutingId] = cSketchFileProcessList; } else { dicSketchRefProcess.Add(x.RoutingId, new List <CSketchFileProcess>() { x }); } }); var qList = (from q in rcontext.Routings where _routingIds.Contains(q.RoutingId) select q).ToList <Routing>(); foreach (var r in qList) { TreeNode tn = new TreeNode(r.Name); tn.Name = r.Code; tn.Tag = r.RoutingId; tn.ImageKey = "Routing"; tn.Expand(); AddChildTreeNode(r.RoutingId, tn); tvProcessLine.Nodes.Add(tn); } } catch { MessageBox.Show("访问数据库失败"); } ///默认第一个选中的Routing TreeNode[] tnodes = tvProcessLine.Nodes.Find(_routingIds.FirstOrDefault(), true); if (tnodes != null) { SelectedCurrentRouting( tnodes.FirstOrDefault <TreeNode>(), _routingIds.FirstOrDefault()); ///初始状态没有 GlobalCache.Instance.OperId = string.Empty; } ///初始化SketchDic //InitSketchDic(pDoc); EventHelper eh = EventHelper.GetInstance(); eh.Testing += new TestEventHandler(SeletedProcessByComponentName); CurrentProcessLine = this; }