Exemple #1
0
        /// <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);
        }
Exemple #2
0
 // 27/3/2017 пока - for unit test purpases only
 public Rule(string str, CmpSet cs)
 {
     text     = str;
     synonyms = RuleSynParse(str);
     ruleDP   = new DP(str);
     CompSet  = cs;
 }
Exemple #3
0
        /// <summary>
        /// getNEWcs(Supplier, Group) - return CompSet could be supplied by supl, or null if not available
        /// </summary>
        /// <param name="selSupl"></param>
        /// <param name="grOLD"></param>
        /// <returns></returns>
        internal CmpSet getNEWcs(Supplier supl, Gr group)
        {
            string grCSname = group.CompSetName;
            CmpSet cs;
            try { cs = new CmpSet(grCSname, this); }
            catch { return null; }

            //////////if (CompSets.Count == 0)
            //////////{

            //////////}
            //////////var cs = CompSets.Find(x => x.name == grCSname);
            //////////if (cs != null) return cs; // нашел CS с тем же именем!
            // в дальнейшем тут вставить подбор CompSet по-компонентно с учетом Rule.synonyms
            // это означает, что, хотя у CS другое название, его разрешено использовать Правилами.
            var mod = MainWindow.model;
            if (mod.Rules.Count == 0) return null; // тут надо загрузить Правила из TSmatchINFO.xlsx/Rules
            Rule.Rule rule = null;
            if (group.match != null) rule = group.match.rule;
            cs = CompSets.Find(x => x.name == rule.CompSet.name);
            if (cs != null) return cs;    // true - found CompSet.name from this Suppler
            //.. по крайней мере, имя отличается -- проверим по-компонентно все прайс-листы с Match
            //.. еще не написано
            return cs;
        }
Exemple #4
0
 // 27/3/2017 пока - for unit test purpases only
 public Rule(string str, Supl supplier = null, CmpSet cs = null)
 {
     text     = str;
     synonyms = RuleSynParse(str);
     ruleDP   = new DP(str);
     CompSet  = cs;
     Supplier = supplier;
 }
Exemple #5
0
        public void CheckAll()
        {
            Docs toc = Docs.getDoc();

            //-- Check TSmach.xlsx/Suppliers consystancy
            Docs SupList = Docs.getDoc(Decl.SUPPLIERS);

            for (int i = SupList.i0; i <= SupList.il; i++)
            {
                Supl s         = new Supl(i);
                int  nCompSets = SupList.Body.Int(i, Decl.SUPL_LISTCOUNT);
                for (int n = 0; n < nCompSets; n++)
                {
                    string csName = SupList.Body.Strng(i, Decl.SUPL_LISTCOUNT + n + 1);
                    CS     cs     = null;
                    try { cs = new CS(csName, s); }
                    catch { }
                    var    ruleLst = Rule.Rule.getList(s.Name);
                    string msg     = string.Format("PriceList \"{0}\" "
                                                   + " not awalable from Supplier \"{1}\"", csName, s.Name);
                    if (ruleLst.Count == 0)
                    {
                        msg += ", and no Rule for him";
                    }
                    else
                    {
                        msg += string.Format(", however, available {0} for him", ruleLst.Count);
                    }
                    log.Info(msg);
                    if (cs == null)
                    {
                        continue;
                    }
                    cs.doc.Close();
                }
            }
            return;

            //-- check toc and close open price-lists
            for (int i = toc.i0; i <= toc.il; i++)
            {
                string type = toc.Body.Strng(i, Decl.DOC_TYPE);
                if (!type.Contains("Comp"))
                {
                    continue;
                }
                string doc_name = toc.Body.Strng(i, Decl.DOC_NAME);
                Docs   doc      = Docs.getDoc(doc_name, fatal: false);
                if (doc == null)
                {
                    continue;
                }
                doc.Close();
            }
        }
Exemple #6
0
        public double RuleRedundencyPerCent = 0.0;  //коэффициент избыточности, требуемый запас по данному материалу/профилю/Правилу

        public Rule(Docs doc, int i)
        {
            name     = (string)doc.Body[i, Decl.RULE_NAME];
            type     = (string)doc.Body[i, Decl.RULE_TYPE];
            text     = Lib.ToLat((string)doc.Body[i, Decl.RULE_RULE]);
            synonyms = RuleSynParse(text);
            ruleDP   = new DP(text); // template for identification
            string csName   = (string)doc.Body[i, Decl.RULE_COMPSETNAME];
            string suplName = (string)doc.Body[i, Decl.RULE_SUPPLIERNAME];

            Supplier = new Suppliers.Supplier(suplName);
            CompSet  = new CmpSet(csName, Supplier);
        }
Exemple #7
0
        /// <summary>
        /// Имитация CompSet
        /// </summary>
        internal CS IM_CompSet(string str = "M:1;Prf:2;Des:3;Price:4")
        {
            var         c1    = Im_Comp("C245", "Уголок 18x3", price: "832");
            var         c2    = Im_Comp("C245", "Уголок 20x5", price: "1010");
            var         c3    = Im_Comp("C245", "Уголок 25x8", price: "1234.56");
            var         c4    = Im_Comp("C245", "Уголок 35x12", price: "2541.23");
            List <Comp> comps = new List <Comp> {
                c1, c2, c3, c4
            };
            CS cs = new CS("Пример уголков", null, str, comps: comps);

            return(cs);
        }
Exemple #8
0
        public void UT_PriceGr_Msg()
        {
            // Assign
            boot.Init();
            Rule.Rule rule = new Rule.Rule();
            rule.sSupl = "СтальХолдинг";
            rule.sCS   = "Полоса";
            rule.text  = "М: C245=C255 ; Профиль: Полоса горячекатаная = PL = — *x*;";
            ElmGr gr = new ElmGr();

            gr.SupplierName = rule.sSupl;
            gr.guids        = new List <string>()
            {
                "guid1", "guid2"
            };

            // test 1: Msg.F("Rules not initialyzed") English
            string s = sub_PriceGr(mod, gr, "en");

            Assert.AreEqual("Rules in Model were not initialyzed", s);

            // test 2: Msg.F("Rules not initialyzed") Russian
            s = sub_PriceGr(mod, gr, "ru");
            Assert.AreEqual("Не инциированы правила модели", s);

            // test 3: Rules initialyzed, works with CompSet and Components, Rule, MsgF Wrong LoadDescriptor
            gr.Prf    = "I20"; gr.prf = "i20";
            rule.text = "Профиль: Балка =I*";
            string comp_txt = "Балка 20";

            rule.ruleDP   = new DPar.DPar(rule.text);
            rule.synonyms = rule.RuleSynParse(rule.text);
            //           var syns = rule.synonyms[Section.Section.SType.Profile].ToList();
            List <Comp> comps = new List <Comp>()
            {
                new Comp(new DP("Prf:I10; Price:23456")),
                new Comp(new DP("Prf:I20; Price:34567"))
            };
            Supl   supl           = new Supl("СтальХолдинг", init: false);
            string LoadDescriptor = "M:1; опис:3; профиль:2; цена: 4; Ед: руб/т";
            CS     cs             = new CS("Балка", supl, LoadDescriptor, comps);
            Comp   comp           = new Comp();

            comp.compDP = new DP("Prf: " + comp_txt);
            mod.Rules.Add(rule);
            rule.CompSet = cs;
            s            = sub_PriceGr(mod, gr, "en", _prefix: "Msg.W: ");
            Assert.AreEqual("CompSet_wrong_LoadDescriptor", s);

            FileOp.AppQuit();
        }
Exemple #9
0
 public void Init()
 {
     Supplier = new Supl(sSupl);
     CompSet  = new CmpSet(sCS, Supplier);
     CompSet.doc.Close();
 }