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; }
public PartEventHandler(ModelDoc2 modDoc, SwAddin addin) : base(modDoc, addin) { doc = (PartDoc)document; string partName = modDoc.GetPathName().Substring( modDoc.GetPathName().LastIndexOf('\\') + 1); GlobalCache.Instance.ComponetName = partName; this.partName = partName; pfr = new ProcessFileRoutingContext(DbConfig.Connection); List <ProcessFileRouting> qlist = null; try { qlist = (from p in pfr.ProcessFileRoutings where p.ProcessFileName == partName select p).ToList <ProcessFileRouting>(); } catch (Exception ex) { MessageBox.Show(ex.Message); } Dictionary <string, bool> featureDic = new Dictionary <string, bool>(); Feature feature = modDoc.FirstFeature(); ModelDocExtension swModelExt = modDoc.Extension; while (feature != null) { string featureTypeName = feature.GetTypeName(); string featureName = feature.Name; if (featureTypeName == "ProfileFeature") { if (!featureDic.ContainsKey(featureName)) { featureDic.Add(featureName, false); } } feature = (Feature)feature.GetNextFeature(); } GlobalCache.Instance.SketchStatusDic = featureDic; List <string> routingIdList = new List <string>(); foreach (var q in qlist) { routingIdList.Add(q.RoutingId); } this.routingIdList = routingIdList; if (routingIdList.Count > 0) { ///Exist the correlation component to routing Routing(modDoc, iSwApp, routingIdList); } }