private void Search_Element(string findstr, bool replace_mode) { findindex = 0; string searchname = "*" + findstr + "*"; string replacestr = txtreplace.Text; //트리에서 Element Type을 선택할수 있게 함. List <DbElementType> dbtype_list = new List <DbElementType>(); foreach (TreeNode firstnode in tree_type.Nodes) { if (firstnode.Checked) { dbtype_list.Add((DbElementType)firstnode.Tag); } foreach (TreeNode secondnode in firstnode.Nodes) { if (secondnode.Checked) { dbtype_list.Add((DbElementType)secondnode.Tag); } foreach (TreeNode thirdnode in secondnode.Nodes) { if (thirdnode.Checked) { dbtype_list.Add((DbElementType)thirdnode.Tag); } foreach (TreeNode forthnode in thirdnode.Nodes) { if (forthnode.Checked) { dbtype_list.Add((DbElementType)forthnode.Tag); } } } } } dbtypes = dbtype_list.ToArray(); if (radio_3dview.Checked) { DrawList drawlist = DrawListManager.Instance.CurrentDrawList; DrawListMember[] drawlistmems = drawlist.Members(); DrawListMember [] FindDrawElements = drawlistmems.Cast <DrawListMember>() .Where(item => item.DbElement.GetAsString(DbAttributeInstance.NAMN).Contains(txt_search.Text) && dbtypes.Contains(item.DbElement.GetElementType())) .ToArray(); FindElements = FindDrawElements.Select(x => x.DbElement).ToArray(); //Highlight시 색은 General Colours에서 Visible의 색을 따라감. drawlist.Highlight(FindElements); foreach (DbElement item in FindElements) { string type = item.GetAsString(DbAttributeInstance.TYPE); string pos = ""; if (type == "BRAN") { pos = item.GetAsString(DbAttributeInstance.HPOS); } else { pos = item.GetAsString(DbAttributeInstance.POS); } string name = item.GetAsString(DbAttributeInstance.NAMN); Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("AID TEXT number 9898 |{0}| at {1}", name, pos)).RunInPdms(); } } else { //Root가 CE일때 if (radio_ce.Checked) { root = CurrentElement.Element; } else if (radio_entire.Checked) { if (ServiceManager.Instance.ApplicationName == "Outfitting") { root = MDB.CurrentMDB.GetFirstWorld(Aveva.Pdms.Database.DbType.Design); } if (ServiceManager.Instance.ApplicationName == "Paragon") { root = MDB.CurrentMDB.GetFirstWorld(Aveva.Pdms.Database.DbType.Catalogue); } if (ServiceManager.Instance.ApplicationName == "MarineDrafting") { root = MDB.CurrentMDB.GetFirstWorld(Aveva.Pdms.Database.DbType.Draft); } } TypeFilter typefilter = new TypeFilter(dbtypes); AndFilter finalfilter = new AndFilter(); AttributeLikeFilter xfilter = new AttributeLikeFilter(DbAttributeInstance.NAMN, searchname); finalfilter.Add(typefilter); finalfilter.Add(xfilter); result = new DBElementCollection(root, finalfilter); FindElements = result.Cast <DbElement>().ToArray(); } //Item 들이 가지고 속해있는 DB리스트생성 List <Db> dblist = new List <Db>(); foreach (DbElement item in FindElements) { if (!dblist.Contains(item.Db)) { dblist.Add(item.Db); } } //Partial Getwork수행 MDB.CurrentMDB.GetWork(dblist.ToArray()); int replace_count = 0; if (replace_mode == true) { foreach (DbElement item in FindElements) { try { //listView_searchresult.Items.Add(new ListViewItem(new string[]{"1","2","3","4"})); string element_name = item.GetAsString(DbAttributeInstance.NAME); string name = element_name.Replace(findstr, replacestr); DbElement exsititem = DbElement.GetElement(name); if (!exsititem.IsNull) { MessageBox.Show(string.Format("바꿀려는 이름 {0}은 존재하므로 바꿀수 없습니다.", name)); return; continue; } item.SetAttribute(DbAttributeInstance.NAME, name); replace_count++; mDesExpCtrl.RefreshNodes(item); } catch (Exception ee) { Console.WriteLine(item.ToString()); Console.WriteLine("오류발생"); } } //Tree View 업데이트 부분 아래 구문이 없으면 화면이 업데이트 안됨. try { var windows = Aveva.ApplicationFramework.Presentation.WindowManager.Instance.Windows.OfType <Presentation.DockedWindow>().Where(x => x.Key == "DesignExplorer").ToArray(); if (windows.Count() > 0) { MessageBox.Show(replace_count + "개 항목의 이름 바꾸기 완료!"); } } catch (Exception ee) { } } else { if (!radio_3dview.Checked) { if (FindElements.Count() != 0) { string refno = FindElements[0].GetAsString(DbAttributeInstance.REF); Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(refno).RunInPdms(); } } int idx = 1; //listView_searchresult.ColumnClick -= listView_searchresult_ColumnClick; listView_searchresult.Items.Clear(); foreach (DbElement item in FindElements) { string elementname = item.GetAsString(DbAttributeInstance.FLNN); string elementtype = item.GetAsString(DbAttributeInstance.TYPE); string marptype = "0"; if (elementtype == "SHEE") { marptype = item.GetAsString(DbAttributeInstance.MARPTY); } bool lclm = item.GetBool(DbAttributeInstance.LCLM); string userclaim = item.GetAsString(DbAttributeInstance.USERC); string islock = "X"; if (lclm == true) { islock = "X"; } else { if (userclaim == "unset") { islock = "X"; } else { islock = "O"; } } listView_searchresult.Items.Add(new ListViewItem(new string[] { idx.ToString(), elementname, elementtype, islock, marptype })); idx++; } //listView_searchresult.ColumnClick += listView_searchresult_ColumnClick; lbl_result.Text = "검색결과 : " + FindElements.Count().ToString() + " 건"; } }