Beispiel #1
0
        public void UT_get_pricingMD5()
        {
            Assert.AreEqual(0, mod.elements.Count);
            Assert.AreEqual(0, mod.elmGroups.Count);

            // test empty list of groups pricingMD5
            string       pricingMD5 = mod.get_pricingMD5(mod.elmGroups);
            const string EMPTY_GROUP_LIST_PRICINGMD5 = "5E7AD112B9369E41723DDFD797758E62";

            Assert.AreEqual(EMPTY_GROUP_LIST_PRICINGMD5, pricingMD5);

            // test real model and TSmatchINFO.xlsx
            boot.Init();
            mod          = mod.sr.SetModel(boot, initSupl: true);
            mod.elements = mod.sr.Raw(mod);
            var grp = mod.mh.getGrps(mod.elements);

            pricingMD5 = mod.get_pricingMD5(grp);

            Assert.IsNotNull(pricingMD5);
            Assert.AreEqual(32, pricingMD5.Length);
            Assert.IsTrue(EMPTY_GROUP_LIST_PRICINGMD5 != pricingMD5);

            FileOp.AppQuit();
        }
Beispiel #2
0
        public void UT_getGrps()
        {
            var mh = new MH();
            var sr = new SR();

            if (boot.isTeklaActive)
            {
                mod.dir = TS.GetTeklaDir(TS.ModelDir.model);
            }
            else
            {
                mod.dir = boot.ModelDir;
            }

            mod.elements = sr.Raw(mod);
            string md5 = mod.getMD5(mod.elements);

            Assert.AreEqual(32, md5.Length);

            var grp = mh.getGrps(mod.elements);

            Assert.IsTrue(grp.Count > 0);
            string pricing_md5 = mod.get_pricingMD5(grp);

            Assert.AreEqual(32, pricing_md5.Length);

            FileOp.AppQuit();
        }
Beispiel #3
0
        /// <summary>
        /// Hndl(model) - find matching Components for model and total_price
        /// </summary>
        /// <param name="mod">model to be handled</param>
        public void Hndl(ref Mod mod)
        {
            Log.set("MH.Hndl");
            mod.elmGroups = getGrps(mod.elements);
            if (mod.elmGroups.Count < 1 || mod.Rules.Count < 1) Msg.F("No Rules or element Groups");
            if(testMode) { Log.exit(); return; }

            foreach (var rules in mod.Rules)
                if (rules.CompSet == null) rules.Init();
            // find matching Components with Rules by module Mtch 
            foreach (var gr in mod.elmGroups)
            {
                bool b = false;
                foreach (var rule in mod.Rules)
                {
                    Mtch _match = new Mtch(gr, rule);
                    if (_match.ok == Mtch.OK.Match)
                    {
                        mod.matches.Add(_match);
                        gr.CompSetName = _match.rule.sCS;
                        gr.SupplierName = _match.rule.sSupl;
                        gr.compDescription = _match.component.Str(Section.Section.SType.Description);
                        b = true; break;
                    }
                }
                if (!b) log.Info("No Match Group. mat= " + gr.mat + "\tprf=" + gr.prf);
            }
            // calculate prices for matches      
            mod.total_price = mod.elmGroups.Sum(x => x.totalPrice);
            mod.pricingDate = DateTime.Now;
            mod.pricingMD5 = mod.get_pricingMD5(mod.elmGroups);
            Log.Trace("price date=\t" + mod.pricingDate + "\tMD5=" + mod.pricingMD5);
            log.Info("Model.Hndl set " + mod.matches.Count + " groups. Total price=" + mod.total_price + " rub");
            Log.exit();
        }