void test_Mtch_3() { Log.set(" test_Mtch_3: Rule 5 и Group < C235, Pl30 >"); rule = new Rule.Rule(5); ElmAttSet.ElmAttSet elm = new ElmAttSet.ElmAttSet( "ID56A7442F-0000-0D74-3134-353338303236", "C235", "Steel", "Pl30", 0, 0, 0, 1001); Dictionary <string, ElmAttSet.ElmAttSet> els = new Dictionary <string, ElmAttSet.ElmAttSet>(); els.Add(elm.guid, elm); List <string> guids = new List <string>(); guids.Add(elm.guid); var model = new Model.Model(); model.setElements(els); model.getGroups(); var gr = model.elmGroups[0]; //6/4/17 TST.Eq(gr.guids.Count, 1); //6/4/17 TST.Eq(gr.mat, "c235"); //6/4/17TST.Eq(gr.prf, "pl30"); var doc = Docs.getDoc("Полоса СтальхолдингM"); var csDP = new Dictionary <SType, string>(); //31/3 csFPs = rule.Parser(FP.type.CompSet, doc.LoadDescription); // 2/4 Comp comp1 = new Comp(doc, 2, csDP); // 2/4 Comp comp2 = new Comp(doc, 12, csDP); // 2/4 List<Comp> comps = new List<Comp> { comp1, comp2 }; // 2/4 CS cs = new CS("test_CS", null, rule, doc.LoadDescription, comps); // 2/4 TST.Eq(cs.csDP.Count, 4); //////////////////////////TST.Eq(comp1.isMatch(gr, rule), false); //////////////////////////TST.Eq(comp2.isMatch(gr, rule), true); Log.exit(); }
/// <summary> /// Имитация Rule /// </summary> internal Rule.Rule IM_Rule(string str = "M:C245; Prf: Уголок=L*") { CS cs = IM_CompSet(); Rule.Rule r = new Rule.Rule(str, cs); return(r); }
void test_Mtch_2() { Log.set(" test_Mtch_2: Rule 15 и Group < B12,5 , 1900x1600 > "); rule = new Rule.Rule(15); ElmAttSet.ElmAttSet elB = new ElmAttSet.ElmAttSet( "ID56A7442F-0000-0D7B-3134-353338303236", "B12,5", "Concrete", "1900x1600", 0, 0, 0, 1000); Dictionary <string, ElmAttSet.ElmAttSet> els = new Dictionary <string, ElmAttSet.ElmAttSet>(); els.Add(elB.guid, elB); List <string> guids = new List <string>(); guids.Add(elB.guid); var model = new Model.Model(); model.setElements(els); model.getGroups(); var gr = model.elmGroups[0]; TST.Eq(gr.guids.Count, 1); var match = new Mtch(gr, rule); TST.Eq(match.ok == OK.Match, true); var cmp = match.component; //31/3 TST.Eq(cmp.fps[SType.Material].pars[0].par.ToString(), "b12,5"); Log.exit(); }
/// <summary> /// имитация списка синонимов - только для отладки /// </summary> /// <param name="i"></param> internal void IM_setRuleSynonyms(ref Rule.Rule rule, int i = -1) { //24/3 if (i < 0) { rule.synonyms = null; return; } var anglePrf = new List <string> { "l", "Уголок равнопол." }; var synonyms = new Dictionary <SType, List <string> >(); rule.synonyms = synonyms; List <string> syns = new List <string>(); foreach (string syn in anglePrf) { syns.Add(Lib.ToLat(syn).ToLower().Replace(" ", "")); } rule.synonyms.Add(SType.Profile, syns); }
////////////// private void test_getSectionText() ////////////// { ////////////// Log.set("test_getSectionTest(Section.Material, text"); //28/5/////////////// 7/3/2017 ///////////////// TST.Eq(getSectionText(FP.Section.Material, "Профиль: L 20 x 5; M: C245; Price: 2690"), "c245"); ////////////// Log.exit(); ////////////// } //////////////private void test_isSectionMatch() //////////////{ ////////////// Log.set("isSectionMatch(Section.Material, C245, rule.text)"); ////////////// /////// 7/3/2017 //// bool ok = isSectionMatch(FP.Section.Material, "C245", "Профиль: L * x * ст*; длина: * = * м; M: ст *;"); ////////////// Log.exit(); //////////////} private void test_Mtch_1() { Log.set(" test_Mtch_1: Rule 4 и Group<C255, L20x4>"); Rule.Rule rule = new Rule.Rule(4); ElmAttSet.ElmAttSet el = new ElmAttSet.ElmAttSet( "ID56A7442F-0000-0D70-3134-353338303236", "C245", "Steel", "Уголок20X4", 0, 0, 0, 1000); Dictionary <string, ElmAttSet.ElmAttSet> els = new Dictionary <string, ElmAttSet.ElmAttSet>(); els.Add(el.guid, el); List <string> guids = new List <string>(); guids.Add(el.guid); ElmAttSet.Group gr = new ElmAttSet.Group(els, "C245", "Уголок20X4", guids); Mtch match = new Mtch(gr, rule); //6/4/17 TST.Eq(match.ok == OK.Match, true); Log.exit(); }
public Rule.Rule rule; //the rule, which manage the matching /// <summary> /// Mtch(gr, _rule) - check if Group gr is in match with rule /// if Mtch.ok.Match - return Mtch.Component chousen from CompSet.Component /// else ok.NoMatch /// </summary> /// <param name="gr"></param> /// <param name="_rule"></param> public Mtch(ElmAttSet.Group gr, Rule.Rule _rule) { if (gr.prf.Contains("ш2") /* && _rule.text.Contains("д") */) { rule = _rule; } if (gr == null || gr.guids.Count < 1) { return; } ok = OK.NoMatch; group = gr; foreach (var comp in _rule.CompSet.Components) { if (!comp.isMatch(gr, _rule)) { continue; } //-- Component is found - fill Price for all Guids elemets ok = OK.Match; component = comp; gr.match = this; //27/3!! rule = _rule; gr.totalPrice = 0; foreach (var id in gr.guids) { Elm elm = gr.Elements[id]; string priceStr = comp.Str(SType.Price); double price = getPrice(elm, rule.CompSet.csDP, priceStr); gr.Elements[id].price = price; gr.totalPrice += price; } break; } }