public static void Run()
        {
            //FirstMember
            TypeFilter filt = new TypeFilter(DbElementTypeInstance.NOZZLE);
            DbElement nozz1 = filt.FirstMember(Example.Instance.mEqui);
            DbElementType type = nozz1.GetElementType();

            //NextMember
            DbElement nozz2 = filt.Next(nozz1);

            //NextMember
            DbElement[] members = filt.Members(Example.Instance.mEqui);

            //parent
            TypeFilter filt2 = new TypeFilter(DbElementTypeInstance.SITE);
            DbElement site = filt2.Parent(nozz1);
            type = site.GetElementType();

            //Valid
            AndFilter andFilt4 = new AndFilter();
            andFilt4.Add(new TypeFilter(DbElementTypeInstance.EQUIPMENT));
            andFilt4.Add(new TrueFilter());
            bool valid = andFilt4.Valid(Example.Instance.mEqui);

            // attribute true
            AttributeTrueFilter filt1 = new AttributeTrueFilter(DbAttributeInstance.ISNAME);
            //should be true for named element
            bool named = filt1.Valid(Example.Instance.mEqui);
            //for first member it is also true
            named = filt1.Valid(Example.Instance.mEqui.FirstMember());

            //Element type at or below
            BelowOrAtType filt3 = new BelowOrAtType(DbElementTypeInstance.EQUIPMENT);
            bool below = filt3.ScanBelow(Example.Instance.mEqui);
        }
Exemple #2
0
        public void run()
        {
            DbElement Outfit_Elements = MDB.CurrentMDB.GetFirstWorld(Aveva.Pdms.Database.DbType.Design);

            DbElementType[]       dbtype      = new DbElementType[] { DbElementTypeInstance.PIPE };
            TypeFilter            filter      = new TypeFilter(dbtype);
            AndFilter             finalfilter = new AndFilter();
            AttributeStringFilter filter2     = new AttributeStringFilter(DbAttribute.GetDbAttribute("Name"), FilterOperator.Equals, "/babo");

            finalfilter.Add(filter);
            finalfilter.Add(filter2);


            DBElementCollection spwl_collects = new DBElementCollection(Outfit_Elements, finalfilter);

            Console.WriteLine("스펙월드갯수:" + spwl_collects.Cast <DbElement>().Count());

            int speccnt = 0;
            List <DbElement> working_dbelement = new List <DbElement>();


            foreach (DbElement element in spwl_collects)
            {
                //element.Delete();
                DbCopyOption dd = new DbCopyOption();

                //dd.ToName="/bbboa";
                //DbElement de= element.CreateCopyHierarchyAfter(CurrentElement.Element, dd);
                //de.InsertBefore(CurrentElement.Element);
                DbElement xx = DbElement.GetElement("/xx1");

                CurrentElement.Element.InsertAfterLast(xx);
                //de.InsertAfterLast(element.Owner);
                ////Console.WriteLine("스펙월드]" + spwl.GetAsString(DbAttributeInstance.NAME));
                //foreach (DbElement spec in spwl.Members())
                //{


                //    //spec.CreateLast(DbElementType.GetElementType("Sele"));


                //    string specname = spec.GetAsString(DbAttributeInstance.NAME);
                //    if (specname.Substring(1, 2) == "/*")
                //        continue;

                //    working_dbelement.Add(spec);
                //    speccnt++;
                //    //Console.WriteLine("   -->스펙]"+spec.GetAsString(DbAttributeInstance.NAME));
                //}
            }
            //MDB.CurrentMDB.GetWork();
        }
        private DBElementCollection Get_Element_Collection(DbElement Outfit_Elements, DbElementType [] dbtypes, string search_txt, string modulename)
        {
            DBElementCollection result_collection = null;

            try
            {
                TypeFilter filter      = new TypeFilter(dbtypes);
                AndFilter  finalfilter = new AndFilter();

                AttributeStringFilter filter2 = null;
                AttributeRefFilter    filter3 = null;

                if (search_txt.StartsWith("*") && search_txt.EndsWith("*"))
                {
                    filter2 = new AttributeStringFilter(DbAttribute.GetDbAttribute("NamN"), FilterOperator.EndsWith, search_txt.Replace("*", ""));
                }
                else if (search_txt.EndsWith("*") && !search_txt.StartsWith("*"))
                {
                    filter2 = new AttributeStringFilter(DbAttribute.GetDbAttribute("NamN"), FilterOperator.StartsWith, search_txt.Replace("*", ""));
                }
                else if (search_txt.StartsWith("*") && search_txt.EndsWith("*"))
                {
                    filter2 = new AttributeStringFilter(DbAttribute.GetDbAttribute("NamN"), FilterOperator.Contains, search_txt.Replace("*", ""));
                }
                else
                {
                    filter2 = new AttributeStringFilter(DbAttribute.GetDbAttribute("NamN"), FilterOperator.Equals, search_txt.Replace("*", ""));
                }
                if (modulename.Trim() != "")
                {
                    filter3 = new AttributeRefFilter(DbAttributeInstance.OWNER, FilterOperator.Equals, DbElement.GetElement("/" + modulename));
                    finalfilter.Add(filter3);
                }

                finalfilter.Add(filter);
                finalfilter.Add(filter2);


                result_collection = new DBElementCollection(Outfit_Elements, finalfilter);
            }

            catch (Exception ee)
            {
                Console.WriteLine("오류");
            }

            return(result_collection);
        }
Exemple #4
0
 void AppendFilter(ITestFilter filter)
 {
     if (filter == null)
     {
         throw new ArgumentNullException(nameof(filter));
     }
     if (Filter.IsEmpty)
     {
         Filter = filter;
     }
     else
     {
         AndFilter andFilter;
         if (Filter is AndFilter)
         {
             // add a new filter
             andFilter = Filter as AndFilter;
             andFilter.Add(filter);
         }
         else
         {
             andFilter = new AndFilter(Filter);
             andFilter.Add(filter);
         }
         Filter = andFilter;
     }
 }
Exemple #5
0
        private static TestFilter FromXml(TNode node)
        {
            switch (node.Name)
            {
            case "filter":
            case "and":
                var andFilter = new AndFilter();
                foreach (var childNode in node.ChildNodes)
                {
                    andFilter.Add(FromXml(childNode));
                }
                return(andFilter);

            case "or":
                var orFilter = new OrFilter();
                foreach (var childNode in node.ChildNodes)
                {
                    orFilter.Add(FromXml(childNode));
                }
                return(orFilter);

            case "not":
                return(new NotFilter(FromXml(node.FirstChild)));

            case "id":
                var idFilter = new IdFilter();
                if (node.Value != null)
                {
                    foreach (string id in node.Value.Split(COMMA))
                    {
                        idFilter.Add(id);
                    }
                }
                return(idFilter);

            case "tests":
                var testFilter = new SimpleNameFilter();
                foreach (var childNode in node.SelectNodes("test"))
                {
                    testFilter.Add(childNode.Value);
                }
                return(testFilter);

            case "cat":
                var catFilter = new CategoryFilter();
                if (node.Value != null)
                {
                    foreach (string cat in node.Value.Split(COMMA))
                    {
                        catFilter.AddCategory(cat);
                    }
                }
                return(catFilter);

            default:
                throw new ArgumentException("Invalid filter element: " + node.Name, "xmlNode");
            }
        }
        private ITestFilter GetFilter(TestFilter filter)
        {
            var nUnitFilter = new AndFilter();

            if (filter.names != null && filter.names.Length > 0)
            {
                nUnitFilter.Add(new SimpleNameFilter(filter.names));
            }
            if (filter.categories != null && filter.categories.Length > 0)
            {
                nUnitFilter.Add(new CategoryFilter(filter.categories));
            }
            if (filter.objects != null && filter.objects.Length > 0)
            {
                nUnitFilter.Add(new OrFilter(filter.objects.Where(o => o is TestName).Select(o => new NameFilter(o as TestName)).ToArray()));
            }
            return(nUnitFilter);
        }
        public Hashtable GetVolumeWithinElement(string elementname, Hashtable dbtypeArray, Boolean completelycover)
        {
            
            //DbElementType[] dbtypes = new DbElementType[] { DbElementTypeInstance.PSPOOL };
            string samplerow = ((string)dbtypeArray[1.0]);

            List<DbElementType> dbtypeslist = new List<DbElementType>();
            foreach (var item in dbtypeArray.Keys)
	        {
		        dbtypeslist.Add(DbElementType.GetElementType(dbtypeArray[item].ToString()));
	        }
            DbElementType[] dbtypes = dbtypeslist.ToArray();
            
                
            

            
            DbElement Outfit_Elements = MDB.CurrentMDB.GetFirstWorld(Aveva.Pdms.Database.DbType.Design);                        
            DBElementCollection result_collection = null;
            TypeFilter filter = new TypeFilter(dbtypes);
            AndFilter finalfilter = new AndFilter();

            InVolumeFilter volfilter = new InVolumeFilter(CurrentElement.Element,dbtypes, true);
            
            
            finalfilter.Add(filter);
            finalfilter.Add(volfilter);
            result_collection = new DBElementCollection(Outfit_Elements, finalfilter);
            
            Hashtable resultHs = new Hashtable();

            double idx = 1.0;
            foreach (DbElement item in result_collection)
            {
                resultHs.Add(idx, item.GetAsString(DbAttributeInstance.NAME));
                idx = idx + 1.0;
            }
          
          
            return resultHs;
        }
Exemple #8
0
        private static TestFilter FromXml(XmlNode xmlNode)
        {
            switch (xmlNode.Name)
            {
            case "filter":
            case "and":
                var andFilter = new AndFilter();
                foreach (XmlNode childNode in xmlNode.ChildNodes)
                {
                    andFilter.Add(FromXml(childNode));
                }
                return(andFilter);

            case "or":
                var orFilter = new OrFilter();
                foreach (System.Xml.XmlNode childNode in xmlNode.ChildNodes)
                {
                    orFilter.Add(FromXml(childNode));
                }
                return(orFilter);

            case "not":
                return(new NotFilter(FromXml(xmlNode.FirstChild)));

            case "id":
                var idFilter = new IdFilter();
                foreach (string id in xmlNode.InnerText.Split(COMMA))
                {
                    idFilter.Add(int.Parse(id));
                }
                return(idFilter);

            case "tests":
                var testFilter = new SimpleNameFilter();
                foreach (XmlNode childNode in xmlNode.SelectNodes("test"))
                {
                    testFilter.Add(childNode.InnerText);
                }
                return(testFilter);

            case "cat":
                var catFilter = new CategoryFilter();
                foreach (string cat in xmlNode.InnerText.Split(COMMA))
                {
                    catFilter.AddCategory(cat);
                }
                return(catFilter);

            default:
                throw new ArgumentException("Invalid filter element: " + xmlNode.Name, "xmlNode");
            }
        }
Exemple #9
0
        public static void Run()
        {
            //FirstMember
            TypeFilter    filt  = new TypeFilter(DbElementTypeInstance.NOZZLE);
            DbElement     nozz1 = filt.FirstMember(Example.Instance.mEqui);
            DbElementType type  = nozz1.GetElementType();

            //NextMember
            DbElement nozz2 = filt.Next(nozz1);

            //NextMember
            DbElement[] members = filt.Members(Example.Instance.mEqui);

            //parent
            TypeFilter filt2 = new TypeFilter(DbElementTypeInstance.SITE);
            DbElement  site  = filt2.Parent(nozz1);

            type = site.GetElementType();

            //Valid
            AndFilter andFilt4 = new AndFilter();

            andFilt4.Add(new TypeFilter(DbElementTypeInstance.EQUIPMENT));
            andFilt4.Add(new TrueFilter());
            bool valid = andFilt4.Valid(Example.Instance.mEqui);

            // attribute true
            AttributeTrueFilter filt1 = new AttributeTrueFilter(DbAttributeInstance.ISNAME);
            //should be true for named element
            bool named = filt1.Valid(Example.Instance.mEqui);

            //for first member it is also true
            named = filt1.Valid(Example.Instance.mEqui.FirstMember());

            //Element type at or below
            BelowOrAtType filt3 = new BelowOrAtType(DbElementTypeInstance.EQUIPMENT);
            bool          below = filt3.ScanBelow(Example.Instance.mEqui);
        }
Exemple #10
0
        private TestFilter GetTerm()
        {
            TestFilter primitive = GetPrimitive();

            if (token != "+" && token != "-")
            {
                return(primitive);
            }
            AndFilter andFilter = new AndFilter(primitive);

            while (token == "+" || token == "-")
            {
                string text = token;
                GetToken();
                primitive = GetPrimitive();
                andFilter.Add((text == "-") ? new NotFilter(primitive) : primitive);
            }
            return(andFilter);
        }
Exemple #11
0
        private TestFilter GetTerm()
        {
            TestFilter prim = GetPrimitive();

            if (token != "+" && token != "-")
            {
                return(prim);
            }

            AndFilter filter = new AndFilter(prim);

            while (token == "+" || token == "-")
            {
                string tok = token;
                GetToken();
                prim = GetPrimitive();
                filter.Add(tok == "-" ? new NotFilter(prim) : prim);
            }

            return(filter);
        }
Exemple #12
0
        /// <summary>
        /// Create filter by arguments.
        /// </summary>
        public Filter Create()
        {
            BinaryCompoundFilter filter = new AndFilter();

            foreach (KeyValuePair <string, ValueObject> argument in arguments)
            {
                // Get filter factory.
                FilterFactory factory;
                if ((argument.Value == null) || !FilterFactories.TryGetValue(argument.Key, out factory))
                {
                    continue;
                }
                Logger.Trace("{0}: {1}", argument.Key, factory);
                // Check argument type.
                List <string> values = new List <string>();
                if (!argument.Value.IsList)
                {
                    values.Add(argument.Value.ToString());
                }
                else
                {
                    values.AddRange(argument.Value
                                    .AsList
                                    .Cast <object>()
                                    .Select(value => value.ToString()));
                }
                // Add all.
                if (values.Count != 0)
                {
                    CompoundFilter innerFilter = new OrFilter();
                    foreach (string value in values)
                    {
                        innerFilter.Add(factory(GetParameterName, value));
                    }
                    filter.Add(innerFilter);
                }
            }
            return(filter);
        }
        public void OnAdjustFilterSelection()
        {
            var flp    = new WfiRecordFilterListProvider();
            var wfiset = Cache.ServiceLocator.GetInstance <IWfiWordSetFactory>().Create();

            Cache.LangProject.MorphologicalDataOA.TestSetsOC.Add(wfiset);
            var wf1 = Cache.ServiceLocator.GetInstance <IWfiWordformFactory>().Create();

            wf1.Form.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("kick", Cache.DefaultVernWs);
            wfiset.CasesRC.Add(wf1);
            var andFilter = new AndFilter();
            var wsf       = new WordSetFilter(wfiset);

            using (var mediator = new Mediator())
            {
                mediator.PropertyTable.SetProperty("cache", Cache);
                flp.Init(mediator, null);
                wsf.Cache = Cache;
                andFilter.Add(wsf);
                flp.Filters.Add(wsf);
                flp.OnAdjustFilterSelection(andFilter);
            }
        }
Exemple #14
0
        public void PersistMatchersEtc()
        {
            // BaseMatcher is abstract
            // IntMatcher is abstract
            RangeIntMatcher rangeIntMatch = new RangeIntMatcher(5, 23);

            rangeIntMatch.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
            ITsString tssLabel = m_cache.MakeAnalysisTss("label1");

            rangeIntMatch.Label = tssLabel;
            OwnIntPropFinder    ownIntFinder   = new OwnIntPropFinder(m_sda, 551);
            FilterBarCellFilter rangeIntFilter = new FilterBarCellFilter(ownIntFinder, rangeIntMatch);
            AndFilter           andFilter      = new AndFilter();

            andFilter.Add(rangeIntFilter);

            ITsStrFactory tsf       = TsStrFactoryClass.Create();
            int           ws        = m_cache.DefaultAnalWs;
            IVwPattern    m_pattern = VwPatternClass.Create();

            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;

            andFilter.Add(new FilterBarCellFilter(ownIntFinder, new NotEqualIntMatcher(77)));

            OwnMlPropFinder mlPropFinder = new OwnMlPropFinder(m_cache.MainCacheAccessor, 788, 23);

            m_pattern.Pattern = tsf.MakeString("hello", ws);
            andFilter.Add(new FilterBarCellFilter(mlPropFinder, new ExactMatcher(m_pattern)));

            OwnMonoPropFinder monoPropFinder = new OwnMonoPropFinder(m_cache.MainCacheAccessor, 954);

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("goodbye", ws);
            andFilter.Add(new FilterBarCellFilter(monoPropFinder, new BeginMatcher(m_pattern)));

            OneIndirectMlPropFinder oneIndMlPropFinder =
                new OneIndirectMlPropFinder(m_cache.MainCacheAccessor, 221, 222, 27);

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("exit", ws);
            andFilter.Add(new FilterBarCellFilter(oneIndMlPropFinder, new EndMatcher(m_pattern)));

            MultiIndirectMlPropFinder mimlPropFinder = new MultiIndirectMlPropFinder(
                m_cache.MainCacheAccessor, new int[] { 444, 555 }, 666, 87);

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("whatever", ws);
            andFilter.Add(new FilterBarCellFilter(mimlPropFinder, new AnywhereMatcher(m_pattern)));

            OneIndirectAtomMlPropFinder oneIndAtomFinder =
                new OneIndirectAtomMlPropFinder(m_cache.MainCacheAccessor, 543, 345, 43);

            andFilter.Add(new FilterBarCellFilter(oneIndAtomFinder, new BlankMatcher()));

            andFilter.Add(new FilterBarCellFilter(oneIndAtomFinder, new NonBlankMatcher()));

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("pattern", ws);
            andFilter.Add(new FilterBarCellFilter(oneIndAtomFinder,
                                                  new InvertMatcher(new RegExpMatcher(m_pattern))));

            andFilter.Add(new NullFilter());

            XmlDocument docPaf = new XmlDocument();

            docPaf.LoadXml("<root targetClasses=\"LexEntry, LexSense\"></root>");
            ProblemAnnotationFilter paf = new ProblemAnnotationFilter();

            paf.Init(m_cache, docPaf.DocumentElement);
            andFilter.Add(paf);

            // Save and restore!
            string xml = DynamicLoader.PersistObject(andFilter, "filter");

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            // And check all the pieces...
            AndFilter andFilterOut =
                DynamicLoader.RestoreObject(doc.DocumentElement) as AndFilter;

            andFilterOut.Cache = m_cache;

            Assert.IsNotNull(andFilterOut);

            FilterBarCellFilter rangeIntFilterOut =
                andFilterOut.Filters[0] as FilterBarCellFilter;                 // todo

            Assert.IsNotNull(rangeIntFilterOut);

            OwnIntPropFinder ownIntFinderOut = rangeIntFilterOut.Finder as OwnIntPropFinder;

            Assert.IsNotNull(ownIntFinderOut);
            Assert.AreEqual(551, ownIntFinderOut.Flid);

            RangeIntMatcher rangeIntMatchOut = rangeIntFilterOut.Matcher as RangeIntMatcher;

            Assert.IsNotNull(rangeIntMatchOut);
            Assert.AreEqual(5, rangeIntMatchOut.Min);
            Assert.AreEqual(23, rangeIntMatchOut.Max);
            Assert.IsTrue(tssLabel.Equals(rangeIntMatchOut.Label));

            NotEqualIntMatcher notEqualMatchOut = GetMatcher(andFilter, 1) as NotEqualIntMatcher;

            Assert.IsNotNull(notEqualMatchOut);
            Assert.AreEqual(77, notEqualMatchOut.NotEqualValue);

            ExactMatcher exactMatchOut = GetMatcher(andFilter, 2) as ExactMatcher;

            Assert.IsNotNull(exactMatchOut);
            Assert.AreEqual("hello", exactMatchOut.Pattern.Pattern.Text);

            BeginMatcher beginMatchOut = GetMatcher(andFilter, 3) as BeginMatcher;

            Assert.IsNotNull(beginMatchOut);
            Assert.AreEqual("goodbye", beginMatchOut.Pattern.Pattern.Text);

            EndMatcher endMatchOut = GetMatcher(andFilter, 4) as EndMatcher;

            Assert.IsNotNull(endMatchOut);
            Assert.AreEqual("exit", endMatchOut.Pattern.Pattern.Text);

            AnywhereMatcher anywhereMatchOut = GetMatcher(andFilter, 5) as AnywhereMatcher;

            Assert.IsNotNull(anywhereMatchOut);
            Assert.AreEqual("whatever", anywhereMatchOut.Pattern.Pattern.Text);

            BlankMatcher blankMatchOut = GetMatcher(andFilter, 6) as BlankMatcher;

            Assert.IsNotNull(blankMatchOut);

            NonBlankMatcher nonBlankMatchOut = GetMatcher(andFilter, 7) as NonBlankMatcher;

            Assert.IsNotNull(nonBlankMatchOut);

            InvertMatcher invertMatchOut = GetMatcher(andFilter, 8) as InvertMatcher;

            Assert.IsNotNull(invertMatchOut);

            OwnMlPropFinder mlPropFinderOut = GetFinder(andFilter, 2) as OwnMlPropFinder;

            Assert.AreEqual(m_cache.MainCacheAccessor, mlPropFinderOut.DataAccess);
            Assert.AreEqual(788, mlPropFinderOut.Flid);
            Assert.AreEqual(23, mlPropFinderOut.Ws);

            OwnMonoPropFinder monoPropFinderOut = GetFinder(andFilter, 3) as OwnMonoPropFinder;

            Assert.AreEqual(m_cache.MainCacheAccessor, monoPropFinderOut.DataAccess);
            Assert.AreEqual(954, monoPropFinderOut.Flid);

            OneIndirectMlPropFinder oneIndMlPropFinderOut =
                GetFinder(andFilter, 4) as OneIndirectMlPropFinder;

            Assert.AreEqual(m_cache.MainCacheAccessor, oneIndMlPropFinderOut.DataAccess);
            Assert.AreEqual(221, oneIndMlPropFinderOut.FlidVec);
            Assert.AreEqual(222, oneIndMlPropFinderOut.FlidString);
            Assert.AreEqual(27, oneIndMlPropFinderOut.Ws);

            MultiIndirectMlPropFinder mimlPropFinderOut =
                GetFinder(andFilter, 5) as MultiIndirectMlPropFinder;

            Assert.AreEqual(m_cache.MainCacheAccessor, mimlPropFinderOut.DataAccess);
            Assert.AreEqual(444, mimlPropFinderOut.VecFlids[0]);
            Assert.AreEqual(555, mimlPropFinderOut.VecFlids[1]);
            Assert.AreEqual(666, mimlPropFinderOut.FlidString);
            Assert.AreEqual(87, mimlPropFinderOut.Ws);

            OneIndirectAtomMlPropFinder oneIndAtomFinderOut =
                GetFinder(andFilter, 6) as OneIndirectAtomMlPropFinder;

            Assert.AreEqual(m_cache.MainCacheAccessor, oneIndAtomFinderOut.DataAccess);
            Assert.AreEqual(543, oneIndAtomFinderOut.FlidAtom);
            Assert.AreEqual(345, oneIndAtomFinderOut.FlidString);
            Assert.AreEqual(43, oneIndAtomFinderOut.Ws);

            // 7, 8 are duplicates

            NullFilter nullFilterOut = andFilter.Filters[9] as NullFilter;

            Assert.IsNotNull(nullFilterOut);

            ProblemAnnotationFilter pafOut = andFilter.Filters[10] as ProblemAnnotationFilter;

            Assert.IsNotNull(pafOut);
            Assert.AreEqual(5002, pafOut.ClassIds[0]);
            Assert.AreEqual(5016, pafOut.ClassIds[1]);
        }
Exemple #15
0
        /// <summary>
        /// Create a TestFilter from it's TNode representation
        /// </summary>
        public static TestFilter FromXml(TNode node)
        {
            bool isRegex = node.Attributes["re"] == "1";

            switch (node.Name)
            {
            case "filter":
            case "and":
                var andFilter = new AndFilter();
                foreach (var childNode in node.ChildNodes)
                {
                    andFilter.Add(FromXml(childNode));
                }
                return(andFilter);

            case "or":
                var orFilter = new OrFilter();
                foreach (var childNode in node.ChildNodes)
                {
                    orFilter.Add(FromXml(childNode));
                }
                return(orFilter);

            case "not":
                return(new NotFilter(FromXml(node.FirstChild)));

            case "id":
                return(new IdFilter(node.Value));

            case "test":
                return(new FullNameFilter(node.Value)
                {
                    IsRegex = isRegex
                });

            case "name":
                return(new TestNameFilter(node.Value)
                {
                    IsRegex = isRegex
                });

            case "method":
                return(new MethodNameFilter(node.Value)
                {
                    IsRegex = isRegex
                });

            case "class":
                return(new ClassNameFilter(node.Value)
                {
                    IsRegex = isRegex
                });

            case "namespace":
                return(new NamespaceFilter(node.Value)
                {
                    IsRegex = isRegex
                });

            case "cat":
                return(new CategoryFilter(node.Value)
                {
                    IsRegex = isRegex
                });

            case "prop":
                string name = node.Attributes["name"];
                if (name != null)
                {
                    return new PropertyFilter(name, node.Value)
                           {
                               IsRegex = isRegex
                           }
                }
                ;
                break;
            }

            throw new ArgumentException("Invalid filter element: " + node.Name, "xmlNode");
        }
Exemple #16
0
        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() + " 건";
            }
        }
Exemple #17
0
        private void CreateSpecification(string connstr, string query, string dept)
        {
            OdbcConnection  conn = new OdbcConnection(connstr);
            OdbcCommand     cmd  = new OdbcCommand(query, conn);
            DataTable       dt   = new DataTable();
            OdbcDataAdapter da   = new OdbcDataAdapter(cmd);

            da.Fill(dt);

            string comp_ref_query = "select * from STD_PDST_COMP_REF_AM";

            cmd.CommandText = comp_ref_query;
            DataTable comp_ref_dt = new DataTable();

            da.SelectCommand = cmd;
            da.Fill(comp_ref_dt);



            DbElement Outfit_Elements = MDB.CurrentMDB.GetFirstWorld(Aveva.Pdms.Database.DbType.Catalogue);

            DbElementType[] dbtype      = new DbElementType[] { DbElementTypeInstance.SPWLD };
            TypeFilter      filter      = new TypeFilter(dbtype);
            AndFilter       finalfilter = new AndFilter();

            AttributeStringFilter filter2 = new AttributeStringFilter(DbAttribute.GetDbAttribute("Description"), FilterOperator.Equals, "HMD_PIPE_SPEC");


            finalfilter.Add(filter);
            finalfilter.Add(filter2);



            DBElementCollection spwl_collects = new DBElementCollection(Outfit_Elements, finalfilter);


            Console.WriteLine("스펙갯수:" + spwl_collects.Cast <DbElement>().Count());

            //dt.Rows.OfType<DataRow>().Where(x => x[1].ToString() == "WB").Count();
            //dt.Rows.OfType<DataRow>().GroupBy(x=>x[11].ToString())
            //var xx =spwl_collects.Cast<DbElement>().Where(x => x.GetAsString(DbAttributeInstance.NAME).Substring(0, 2) == "AA");
            int speccnt = 0;
            List <DbElement> working_dbelement = new List <DbElement>();


            var system_analysis = dt.Rows.OfType <DataRow>().GroupBy(x => x["LINE_NO"], x => x["NOM_DIA"], (lineno, nomdia) => new { lineno, nomdia }).OrderBy(x => x.lineno.ToString());
            int cnt             = 0;

            foreach (var lineno in system_analysis)
            {
                cnt++;
                //if (cnt == 3)
                //    break;
                //스펙생성부분
                //DbElement spec_element = DbElement.GetElement("/PROJ_SPWL").CreateAfter(DbElementTypeInstance.SPECIFICATION);
                string    specname     = dept + "." + lineno.lineno.ToString().Replace(' ', '.');
                DbElement spec_element = null;

                if (DbElement.GetElement("/" + specname).IsNull)
                {
                    spec_element = DbElement.GetElement("/PROJ_SPWL").CreateLast(DbElementTypeInstance.SPECIFICATION);
                    spec_element.SetAttribute(DbAttributeInstance.NAME, "/" + specname);
                    spec_element.SetAttribute(DbAttributeInstance.QUES, "TYPE");
                    spec_element.SetAttribute(DbAttributeInstance.PURP, "PIPE");
                    spec_element.SetAttribute(DbAttributeInstance.DESC, "PROJ.SPEC");
                }

                try
                {
                    //SPEC TEXT 추가
                    DbElement spectext_element = spec_element.CreateLast(DbElementTypeInstance.TEXT);
                    spectext_element.SetAttribute(DbAttributeInstance.NAME, "/" + specname + "." + "PIPINGTEXT");
                    spectext_element.SetAttribute(DbAttributeInstance.STEX, "PIPING");
                    spectext_element.SetAttribute(DbAttributeInstance.RTEX, "PIPING");
                }
                catch (Exception ee) { }

                try
                {
                    foreach (var nomdia in lineno.nomdia)
                    {
                        //Aveva.Pdms.Utilities.Messaging.PdmsException.


                        Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |size: {0} |", nomdia.ToString())).RunInPdms();
                        DataRow[] targetrow = dt.Rows.OfType <DataRow>().Where(row => row["LINE_NO"].ToString() == lineno.lineno.ToString() && row["NOM_DIA"].ToString() == nomdia.ToString()).ToArray();

                        string press = targetrow[0]["PRESS"].ToString();
                        string temp  = targetrow[0]["TEMP"].ToString();

                        string matlspec = targetrow[0]["MATL_SPEC"].ToString();
                        string connspec = targetrow[0]["PIPE_C_TYPE"].ToString() + "/" + targetrow[0]["PIPE_C_STD"].ToString() + "/" + targetrow[0]["PIPE_C_MATL"].ToString();
                        connspec = connspec.Replace("\n", "");
                        string valvespec = targetrow[0]["VALVE_C_TYPE"].ToString();

                        DataRow[] matl_datarow  = comp_ref_dt.Rows.Cast <DataRow>().Where(row => row[0].ToString() == matlspec).ToArray();
                        DataRow[] conn_datarow  = comp_ref_dt.Rows.Cast <DataRow>().Where(row => row[0].ToString() == connspec).ToArray();
                        DataRow[] valve_datarow = comp_ref_dt.Rows.Cast <DataRow>().Where(row => row[0].ToString() == valvespec).ToArray();


                        List <int> diameters = get_dias(nomdia.ToString());

                        //Material Spec생성
                        if (matl_datarow.Count() == 0)
                        {
                            //Aveva.Pdms.Utilities.CommandLine.Command.OutputAndClearError();
                            Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |{0} material ref 없음|", matlspec)).RunInPdms();
                        }
                        else
                        {
                            //Aveva.Pdms.Utilities.CommandLine.Command.OutputAndClearError();
                            DbElement material_spec = DbElement.GetElement(matl_datarow[0][1].ToString());
                            string[]  allowtype     = new string[] { "ELBO" };//
                            foreach (DbElement element in material_spec.Members())
                            {
                                if (element.GetElementType().ToString() != "TEXT")
                                {
                                    //if (!allowtype.Contains(element.GetAsString(DbAttributeInstance.TANS)))
                                    //    continue;
                                    //Aveva.Pdms.Utilities.CommandLine.Command.OutputAndClearError();
                                    reculsive_copy_spec(spec_element, element, specname, diameters);
                                }
                            }
                        }
                        //Conn spec 생성
                        if (conn_datarow.Count() == 0)
                        {
                            Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |{0} conn ref 없음|", connspec)).RunInPdms();
                        }
                        else
                        {
                            //Gasket 생성
                            DbElement gask_spec = null;
                            if (connspec.Contains("5K"))
                            {
                                gask_spec = DbElement.GetElement("/POGASASF05/HMDP_SPEC");
                            }
                            else if (connspec.Contains("10K"))
                            {
                                gask_spec = DbElement.GetElement("/POGASASF10/HMDP_SPEC");
                            }
                            else if (connspec.Contains("16K"))
                            {
                                gask_spec = DbElement.GetElement("/POGASASF16/HMDP_SPEC");
                            }
                            else if (connspec.Contains("20K"))
                            {
                                gask_spec = DbElement.GetElement("/POGASASF20/HMDP_SPEC");
                            }
                            else if (connspec.Contains("30K"))
                            {
                                gask_spec = DbElement.GetElement("/POGASASF30/HMDP_SPEC");
                            }
                            foreach (DbElement element in gask_spec.Members())
                            {
                                reculsive_copy_spec(spec_element, element, specname, diameters);
                            }
                            //Flange Spec
                            DbElement conn_spec = DbElement.GetElement(conn_datarow[0][1].ToString());
                            foreach (DbElement element in conn_spec.Members())
                            {
                                reculsive_copy_spec(spec_element, element, specname, diameters);
                            }
                        }
                        //Valve Spec생성
                        if (valve_datarow.Count() == 0)
                        {
                            Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |{0} valve ref 없음|", valvespec).Replace("\n", "")).RunInPdms();
                        }
                        else
                        {
                            DbElement valve_spec = DbElement.GetElement(valve_datarow[0][1].ToString());
                            foreach (DbElement element in valve_spec.Members())
                            {
                                reculsive_copy_spec(spec_element, element, specname, diameters);
                            }
                        }

                        //DbElement conn_spec = DbElement.GetElement("/PFSF30/HMDP_SPEC");
                        //DbElement valve_spec = DbElement.GetElement("/PVVVV10/HMDP_SPEC");


                        //Select 생성
                    }
                }
                catch (Exception ee)
                {
                    Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |{0} 오륭", "11")).RunInPdms();
                    Console.WriteLine("오류:" + ee.Message);
                }
                //break;
            }
            Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |뻥뻥2|")).RunInPdms();
            //MDB.CurrentMDB.SaveWork("스펙생성");

            //CurrentElement.Element.Copy(DbElement.GetElement("/ACCOM.(DF)"));
            //DbElement de = CurrentElement.Element.Clone();

            //지정된 Element 뒤에 object생성하는 부분
            //DbElement xx= CurrentElement.Element.CreateAfter(DbElementTypeInstance.SPECIFICATION);
            //xx.SetAttribute(DbAttributeInstance.NAME, "/바보야4");



            //새로운 Element를 만들고 다른object의 하위구조를 모두 복사하는 부분.

            //DbElement xx = CurrentElement.Element.CreateAfter(DbElementTypeInstance.SPECIFICATION);
            //DbCopyOption op=new DbCopyOption();
            //op.ToName="vvd";

            ////DbElement yy= DbElement.GetElement("/ALDJSAFKL");
            //xx.CopyHierarchy(DbElement.GetElement("/ALDJSAFKL"),op);

            //DbCopyOption op = new DbCopyOption();


            // ALDJSAFKL을 복사하는데 /xxx 다음에 만들어서 복사한다.
            //DbElement yy= DbElement.GetElement("/ALDJSAFKL").CreateCopyHierarchyAfter(DbElement.GetElement("/xxx"), op);
            //테스트가 필요하네요

            //삭제
            //DbElement.GetElement("/xxx").Delete();

            //Rename
            //DbElement.GetElement("/보바").SetAttribute(DbAttributeInstance.NAME, "/보바1");

            //CurrentElement.Element.Copy(DbElement.GetElement("/보바1"));
            //MDB.CurrentMDB.SaveWork("여기는 테스트1");
            //



            //foreach (DbElement element in spwl_collects)
            //{
            //    //element.Delete();
            //    DbCopyOption dd= new DbCopyOption();

            //    //dd.ToName="/bbboa";
            //    //DbElement de= element.CreateCopyHierarchyAfter(CurrentElement.Element, dd);
            //    //de.InsertBefore(CurrentElement.Element);
            //    //DbElement xx=DbElement.GetElement("/ACCOM.(DF)");

            //    CurrentElement.Element.InsertAfterLast(xx);
            //    //de.InsertAfterLast(element.Owner);
            //    ////Console.WriteLine("스펙월드]" + spwl.GetAsString(DbAttributeInstance.NAME));
            //    //foreach (DbElement spec in spwl.Members())
            //    //{


            //    //    //spec.CreateLast(DbElementType.GetElementType("Sele"));


            //    //    string specname = spec.GetAsString(DbAttributeInstance.NAME);
            //    //    if (specname.Substring(1, 2) == "/*")
            //    //        continue;

            //    //    working_dbelement.Add(spec);
            //    //    speccnt++;
            //    //    //Console.WriteLine("   -->스펙]"+spec.GetAsString(DbAttributeInstance.NAME));
            //    //}
            //}
            //MDB.CurrentMDB.GetWork();
        }