Beispiel #1
0
        /// <summary>
        /// CheckModelIntegrity(model) - Check if model data are consistant
        /// </summary>
        public bool CheckModelIntegrity(Mod mod)
        {
            if (!FileOp.isDirExist(mod.dir)) return false;
            if (mod.date < Decl.OLD || mod.date > DateTime.Now) return false;
            if (mod.pricingDate < Decl.OLD || mod.pricingDate > DateTime.Now) return false;
            if (mod.MD5 == null || mod.MD5.Length != 32) return false;
            if (mod.pricingMD5 == null || mod.pricingMD5.Length != 32) return false;
            if (mod.elements.Count <= 0 || mod.elmGroups.Count <= 0) return false;

            if (FileOp.isFileExist(Path.Combine(mod.dir, Decl.F_TSMATCHINFO)))
            {
                dINFO = Docs.getDoc(sINFO, create_if_notexist: false, fatal: false);
                if (dINFO == null || dINFO.il < 10) return false;
                if (string.IsNullOrWhiteSpace(mod.name)) return false;
                if (isChangedStr(ref mod.name, dINFO, Decl.MODINFO_NAME_R, 2)) return false;
                //20/8/2017                if (isChangedStr(ref mod.dir, dINFO, Decl.MODINFO_DIR_R, 2)) return false;
                if (isChangedStr(ref mod.MD5, dINFO, Decl.MODINFO_MD5_R, 2)) return false;
                if (isChangedStr(ref mod.pricingMD5, dINFO, Decl.MODINFO_PRCMD5_R, 2)) return false;
                if (mod.elements.Count != dINFO.Body.Int(Decl.MODINFO_ELMCNT_R, 2)) return false;
                dRul = Docs.getDoc(sRul, create_if_notexist: false, fatal: false);
                if (dRul == null || dRul.il < dRul.i0 || dRul.il <= 2) return false;
                dRep = Docs.getDoc(sRep, create_if_notexist: false, fatal: false);
                if (dRep == null || dRep.il < dRep.i0 || dRul.il <= 2) return false;
                if (dRep.il - dRep.i0 != mod.elmGroups.Count) return false;
                if (mod.Rules.Count == 0) return false;
            }
            return true;
        }
Beispiel #2
0
 /// <summary>
 /// Raw() - read elements from Raw.xml or re-write it, if necessary 
 ///<para>
 ///re-write reasons could be: Raw.xml not exists, or error found in ModelINFO
 ///</para>
 /// </summary>
 /// <returns>updated list of elements in file and in memory</returns>
 public List<Elm> Raw(Mod mod)
 {
     const string me = "SavedReport__Raw_";
     Log.set("SR.Raw(" + mod.name + ")");
     model = mod;
     List<Elm> elms = new List<Elm>();
     if (!FileOp.isDirExist(model.dir)) Msg.F(me + "No model dir", model.dir);
     string file = Path.Combine(model.dir, Decl.RAWXML);
     if(FileOp.isFileExist(file))
     {                               // Read Raw.xml
         elms = rwXML.XML.ReadFromXmlFile<List<Elm>>(file);
         model.date = File.GetLastWriteTime(file);
     }
     else
     {                               // get from CAD and Write or re-Write Raw.xml 
         Msg.AskFOK(me + "CAD Read");
         model.Read();
         rwXML.XML.WriteToXmlFile(file, model.elements);
         elms = model.elements;
     }
     model.MD5 = model.getMD5(elms);
     log.Info("Raw.xml: { elmCount, MD5} ==" + elms.Count + ", " + model.MD5);
     Log.exit();
     return elms;
 }
Beispiel #3
0
 /// <summary>
 /// GetSavedRules(Mod mod, [init] - read Rules from Rules Sheet in TSmatchINFO.xlsx; Initiate them if init=true
 /// </summary>
 /// <param name="mod"></param>
 /// <param name="init"></param>
 /// <returns></returns>
 public Mod GetSavedRules(Mod mod, bool init = false)
 {
     Log.set("SR.getSavedRules()");
     model = mod;
     dRul = Docs.getDoc(Decl.TSMATCHINFO_RULES, create_if_notexist: false, fatal: false);
     if (dRul == null)
     { // when TXmatchINFO.xlsx/Rules unavailable - initialise them from TSmatch/InitialRules
         Docs ir = Docs.getDoc("InitialRules");
         for (int i = ir.i0; i < ir.il; i++)
             model.Rules.Add(new Rule.Rule(ir, i));
     }
     else
     { // Rules available, read them
         model.Rules.Clear();
         for (int i = dRul.i0; i <= dRul.il; i++)
         {
             try { model.Rules.Add(new Rule.Rule(i)); }
             catch {}
         }
     }
     if (init) foreach (var rule in model.Rules) rule.Init();
     log.Info("GetSavedRules: Rules.Count = " + model.Rules.Count
         + (init ? "" : " NOT") + "Initialized");
     if (!CheckModelIntegrity(model)) error();
     Log.exit();
     return model;
 }
Beispiel #4
0
        public void UT_CheckModelIntegrity()
        {
            boot.Init();
            model = model.sr.SetModel(boot);

            // test 1: текущий режим TSmatch, 2017/12/1 проверял с Tekla

            bool ok = model.sr.CheckModelIntegrity(model);

            Assert.IsTrue(ok);
            Assert.IsTrue(model.dir.Length > 0);
            Assert.IsTrue(FileOp.isDirExist(model.dir));
            Assert.IsTrue(model.date > Decl.OLD && model.date <= DateTime.Now);
            Assert.IsTrue(model.pricingDate > Decl.OLD && model.pricingDate <= DateTime.Now);
            Assert.AreEqual(32, model.MD5.Length);
            Assert.AreEqual(32, model.pricingMD5.Length);
            Assert.IsTrue(model.elements.Count > 0);
            Assert.IsTrue(model.elmGroups.Count > 0);

            // test 2: no Tekla active
            //boot.isTeklaActive = false;
            //boot.ModelDir = @"C:\TeklaStructuresModels\2017\Медиа-центр футбольного стадиона";
            //!! отложил на потом

            FileOp.AppQuit();
        }
Beispiel #5
0
 public Bootstrap()
 {
     init(BootInitMode.Bootstrap);
     model     = new Mod();
     model.dir = ModelDir;
     model.GetModelInfo();
 }
Beispiel #6
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();
        }
Beispiel #7
0
        // сравниваем результат PriceGr с тем, что записано в TSmatchINFO.xlsx/Report
        // группа за группой
        public void UT_PriceGr_Native()
        {
            boot.Init();
            mod = mod.sr.SetModel(boot);
            mod.sr.GetSavedRules(mod, init: true);
            var Rules = mod.Rules.ToList();

            // специально для первой же незаметчиваемой группы --30
            var nomatch = mod.mh.PriceGr(mod, mod.elmGroups[12]);


            //Act
            foreach (var gr in mod.elmGroups)
            {
                double priceExel = gr.totalPrice;
                //             int ind = Rules.FindIndex(x => x.sSupl == gr.SupplierName && x.sCS == gr.CompSetName);
                var mtch = mod.mh.PriceGr(mod, gr);
                Assert.AreEqual(Round(priceExel), Round(mtch.group.totalPrice));
                if (mtch.ok.ToString() != "Match")
                {
                    continue;
                }
                Assert.AreEqual(gr.SupplierName, mtch.rule.sSupl);
                Assert.AreEqual(gr.CompSetName, mtch.rule.sCS);

                Assert.AreEqual(gr.totalPrice, mtch.group.totalPrice);
                Assert.AreEqual(gr.SupplierName, mtch.group.SupplierName);
                Assert.AreEqual(gr.CompSetName, mtch.group.CompSetName);
                Assert.AreEqual(gr.mat, mtch.group.mat);
                Assert.AreEqual(gr, mtch.group);
            }

            FileOp.AppQuit();
        }
Beispiel #8
0
        /// <summary>
        /// GetTSmatchINFO(Model) - Main SaveReport method. Read TSmatchINFO.xlsx and Raw.xml
        /// </summary>
        /// <remarks>When no TSmatchINFO.xlsx or Raw.xml files exists, create (or mark to create) them, and check model integrity</remarks>
        protected void GetTSmatchINFO(Mod mod, bool initRules = false)
        {
            Log.set("SR.GetTSmatchINFO(\"" + mod.name + "\")");
            model = mod;
            dINFO = Docs.getDoc(sINFO, fatal: false);
            if (dINFO == null) error();

            model.elements = Raw(model);

            if (model.isChanged)
            { //-- no information available from TSmatchINFO.xlsx or it was changed -- doing re-Pricing
                model.mh.Pricing(ref model, initRules);
            }
            else
            { //- get ModelINFO and pricing from TSmatchINFO.xlsx
                model.name = dINFO.Body.Strng(Decl.MODINFO_NAME_R, 2);
                model.setCity(dINFO.Body.Strng(Decl.MODINFO_ADDRESS_R, 2));
                //20/8/2017                model.dir = dINFO.Body.Strng(Decl.MODINFO_DIR_R, 2).Trim();
                model.date = Lib.getDateTime(dINFO.Body.Strng(Decl.MODINFO_DATE_R, 2));
                model.pricingDate = Lib.getDateTime(dINFO.Body.Strng(Decl.MODINFO_PRCDAT_R, 2));
                model.pricingMD5 = dINFO.Body.Strng(Decl.MODINFO_PRCMD5_R, 2);
                GetSavedReport();
                GetSavedRules(model, initRules);
            }
            if (!CheckModelIntegrity(model)) error();
            Log.exit();
        }
Beispiel #9
0
        public void UT_ModHandler_geGroup_Native()
        {
            var boot  = new Boot();
            var model = new Mod();

            model.SetModel(boot);
        }
Beispiel #10
0
        /// <summary>
        /// getModJournal(name, dir) - get model from Model Journal in TSmatch.xlsx
        ///
        /// When new model found, f.e. open in CAD - re-write whole Model Journal.
        /// </summary>
        /// <param name="name">name of model in Journal. If empty - most recent</param>
        /// <param name="dir">directory of model in Journal. If empty - by name</param>
        /// <returns>Mod in List<Mod></Mod>models</returns>
        /// <ToDo>10.4.17 реализовать default name и dir </ToDo>
        public Mod getModJournal(string name = "", string dir = "")
        {
            Docs doc = Docs.getDoc(Decl.MODELS);

            if (name == "")
            {
                throw new NotImplementedException();
            }
            Mod m = models.Find(x => x.name == name && x.dir == dir);

            if (m != null)
            {
                return(m);
            }
            // new Model - add to ModJournal and save
            Mod mod = new Mod();

            mod.name          = name;
            mod.dir           = dir;
            mod.date          = DateTime.Now;
            mod.elementsCount = elementsCount;
            models.Add(mod);
            //3/5            Msg.I("new record in Model Journul", name, dir);
            SavModJournal();
            return(mod);
        }
Beispiel #11
0
        public void UT_Rule_InitSupplier()
        {
            boot.Init();
            mod.sr.SetModel(boot);
            Doc dRul = Doc.getDoc("Rules");

            Assert.IsNotNull(dRul);

            // test 1: Init one Rule
            Rule r = new Rule(4 + 3);

            r.Init();
            var csDP = r.CompSet.csDP;

            Assert.IsNotNull(csDP);
            bool b = csDP.dpStr.ContainsKey(SType.UNIT_Weight);

            // test 2: Check if all Rules have CompSet with Section Unit_
            mod = mod.sr.SetModel(boot, initSupl: true);
            Assert.IsTrue(mod.Rules.Count > 0);
            foreach (var rule in mod.Rules)
            {
                csDP = rule.CompSet.csDP;
                bool bw = csDP.dpStr.ContainsKey(SType.UNIT_Weight);
                bool bv = csDP.dpStr.ContainsKey(SType.UNIT_Vol);
                Assert.IsTrue(bw || bv);
            }

            FileOp.AppQuit();
        }
Beispiel #12
0
        public void UT_getMD5()
        {
            boot.Init();
            Assert.AreEqual(0, mod.elements.Count);

            // test empty list of elements MD5
            string md5 = mod.getMD5(mod.elements);

            Assert.AreEqual("4F76940A4522CE97A52FFEE1FBE74DA2", md5);

            // test getMD5 with Raw()
            mod          = mod.sr.SetModel(boot);
            mod.elements = mod.sr.Raw(mod);
            Assert.IsTrue(mod.elements.Count > 0);
            string MD5 = mod.getMD5(mod.elements);

            Assert.AreEqual(32, MD5.Length);
            Assert.IsTrue(MD5 != md5);

            // test -- проверка повторного вычисления MD5
            string MD5_1 = mod.getMD5(mod.elements);

            Assert.AreEqual(MD5_1, MD5);

            FileOp.AppQuit();
        }
Beispiel #13
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 #14
0
        public void UT_getSavedRules()
        {
            init();

            // test no Rules Init
            model = U._GetSavedRules(model, init_mode: false);

            Assert.IsTrue(model.Rules.Count > 0);
            foreach (var rule in model.Rules)
            {
                Assert.IsNull(rule.Supplier);
                Assert.IsNull(rule.CompSet);
            }

            // test with Rules Init = true
            model = U._GetSavedRules(model, init_mode: true);

            Assert.IsTrue(model.Rules.Count > 0);
            foreach (var rule in model.Rules)
            {
                Assert.IsNotNull(rule.Supplier);
                Assert.IsNotNull(rule.CompSet);
                Assert.IsTrue(rule.CompSet.Components.Count > 0);
            }

            FileOp.AppQuit();
        }
Beispiel #15
0
        public void UT_Hndl()
        {
            var boot  = new Boot();
            var model = new Mod();

            model.SetModel(boot);

            var mh = new ModHandler();

            mh.Hndl(model);
            int cnt = 0;

            foreach (var gr in model.elmGroups)
            {
                cnt += gr.guids.Count();
            }
            Assert.AreEqual(model.elements.Count(), cnt);

            //Hndl performance test -- 180 sec for 100 cycles
            DateTime t0 = DateTime.Now;

            for (int i = 0; i < 100; i++)
            {
                mh.Hndl(model);
            }
            TimeSpan ts = DateTime.Now - t0;

            Assert.IsTrue(ts.TotalSeconds > 0.0);
        }
Beispiel #16
0
        public void UT_GetTSmatchINFO_NoFile()
        {
            // GetModelINFO() - базовый метод, вызываемый в SetModel.
            //..поэтому пользоваться обычным init() для этого UT_ нельзя
            const string defaultModName = "MyTestName";

            boot      = new Boot(); boot.Init();
            model     = new Mod();
            model.dir = boot.ModelDir;
            if (string.IsNullOrEmpty(model.dir))
            {
                model.dir = boot.DebugDir;
            }
            Assert.IsTrue(model.dir.Length > 0);
            bool isModelINFOexists = FileOp.isFileExist(model.dir, "TSmatchINFO.xlsx");

            if (isModelINFOexists)
            {
                goto exit;
            }

            U._GetTSmatchINFO(model);

            bool ok = model.sr.CheckModelIntegrity(model);

            if (isModelINFOexists)
            {
                Assert.IsTrue(model.isChanged);
            }
            Assert.IsTrue(ok);
            exit : FileOp.AppQuit();
        }
Beispiel #17
0
        public void UT_Recover()
        {
            init();

            model.date        = new DateTime(2015, 6, 12, 14, 15, 16);
            model.MD5         = "-- моя имитация MD5 --";
            model.pricingMD5  = "-- моя имитация MD5 --";
            model.pricingDate = new DateTime(2017, 4, 4, 20, 19, 18);
            model.setCity("Санкт-Петербург, Зенит-Арена");
            sr.resetDialog = false;

            // проверяем создание TSmatchINFO.xlsx/ModelINFO
            string repNm = Decl.TSMATCHINFO_MODELINFO;

            sr.Recover(repNm, SR.RecoverToDo.ResetRep);

            //закрываем модель и открываем ее заново для чистоты проверки
            Assert.IsTrue(Docs.IsDocExists(repNm));
            Docs modINFO = Docs.getDoc(Decl.TSMATCHINFO_MODELINFO);

            modINFO.Close();
            model = new Mod();
            Assert.IsNull(model.name);

            var      m          = Docs.getDoc(repNm).Body;
            string   modName    = m.Strng(Decl.MODINFO_NAME_R, 2);
            string   dir        = m.Strng(Decl.MODINFO_DIR_R, 2);
            string   dat        = m.Strng(Decl.MODINFO_DATE_R, 2);
            DateTime date       = Lib.getDateTime(dat);
            string   adr        = m.Strng(Decl.MODINFO_ADDRESS_R, 2);
            int      cnt        = m.Int(Decl.MODINFO_ELMCNT_R, 2);
            string   MD5        = m.Strng(Decl.MODINFO_MD5_R, 2);
            string   pricingMD5 = m.Strng(Decl.MODINFO_PRCMD5_R, 2);

            Assert.IsTrue(modName.Length > 0);
            Assert.IsTrue(dir.Length > 0);
            Assert.IsTrue(dir.Contains(@"\"));
            Assert.IsTrue(dir.Contains(":"));
            Assert.IsFalse(dir.Contains("."));
            Assert.IsTrue(dat.Length > 0);
            Assert.IsTrue(date > Decl.OLD && date < DateTime.Now);
            Assert.AreEqual("-- моя имитация MD5 --", MD5);
            Assert.AreEqual("-- моя имитация MD5 --", pricingMD5);
            Assert.AreEqual("Санкт-Петербург, Зенит-Арена", adr);

            //-- Raw теперь - отдельный xml файл, его не надо проверять 27.05.2017
            //// проверяем создание TSmatchINFO.xlsx/Raw
            //string raw = Decl.TSMATCHINFO_RAW;
            //// 4/5 долго: 2 мин            sr.Recover(raw, SR.RecoverToDo.ResetRep);
            //Assert.IsTrue(Docs.IsDocExists(raw));

            // проверяем создание TSmatchINFO.xlsx/Report
            string report = Decl.TSMATCHINFO_REPORT;

            //14/7            sr.Recover(report, SR.RecoverToDo.ResetRep);
            Assert.IsTrue(Docs.IsDocExists(report));

            FileOp.AppQuit();
        }
Beispiel #18
0
        public Mod SetFromModJournal(string name, string dir)
        {
            Mod m = getModJournal(name, dir);

            date         = m.date;
            strListRules = m.strListRules;
            return(m);
        }
Beispiel #19
0
        public void ChangeModJournal(Mod mod)
        {
            Mod m = models.Find(x => x.name == mod.name && x.dir == mod.dir);

            throw new NotFiniteNumberException();
            //ToDo: отдельно разбираться, когда изменилось только имя или только dir
            SavModJournal();
        }
Beispiel #20
0
 /// <summary>
 /// Save(model) - save means write model in file TSmatchINFO.xlsx
 /// </summary>
 /// <remarks>
 /// Write Documents
 /// - ModelINFO
 /// - Report
 /// - Rules
 /// as the Sheets in Excel file TSmatchINFO.xlsx
 /// </remarks>
 /// <param name="model"></param>
 public void Save(Mod model)
 {
     if (!CheckModelIntegrity(model)) model.mh.Pricing(ref model);
     var w = new WrMod();
     w.wrModel(WrM.ModelINFO, model);
     w.wrModel(WrM.Report, model);
     if (model.Rules.Count == 0) GetSavedRules(model, init: false);
     w.wrModel(WrM.Rules, model);
 }
Beispiel #21
0
 /// <summary>
 /// SetModel(boot) - initialize model by reading from TSmatchINFO.xlsx ans Raw.xml or from scratch
 /// </summary>
 /// <remarks>
 /// With unit_test_mode = true not full model initializing happened.
 /// It is used for testing methods are used on initialization stade.
 /// </remarks>
 /// <param name="boot"></param>
 /// <returns>initialized Model</returns>
 public Mod SetModel(Boot boot, bool initSupl = false)
 {
     Log.set("SR.Model(boot)");
     model = new Mod();
     SetModDir(boot);
     GetTSmatchINFO(model, initSupl);
     Log.exit();
     return model;
 }
Beispiel #22
0
 public void Pricing(ref Mod m)
 {
     if (m.Rules == null || m.Rules.Count == 0)
     {
         if (sr == null) sr = new SaveReport.SavedReport();
         sr.getSavedRules();
         m.Rules = sr.Rules;
     }
     foreach (var rule in m.Rules) { rule.Init(); }
     matches = Hndl(m);
 }
Beispiel #23
0
        public void UT_SetMod_native()
        {
            boot = new Boot(); boot.Init();
            var sr = new SR();

            model = sr.SetModel(boot);

            Assert.IsTrue(sr.CheckModelIntegrity(model));

            FileOp.AppQuit();
        }
Beispiel #24
0
        public void UT_Pricing()
        {
            var boot  = new Boot();
            var model = new Mod();

            model.SetModel(boot);

            var mh = new ModHandler();

            mh.Pricing(ref model);
            Assert.IsTrue(model.matches.Count > 0);
        }
Beispiel #25
0
        public void UT_Save()
        {
            init();
            model = model.sr.SetModel(boot, initSupl: false);   // with Rule Initialization

            model.sr.Save(model);

            bool ok = model.sr.CheckModelIntegrity(model);

            Assert.IsTrue(ok);

            FileOp.AppQuit();
        }
Beispiel #26
0
 private void Form1_Load(object sender, EventArgs e)
 {
     boot  = new Boot("init");
     model = boot.model;
     if (model.getSavedReport())
     {
         // тут надо спросить пользователя "Будем читать из САПР?"
         //..пока читаю всегда..
         model.getSavedReport(true);
     }
     WrForm(wrForm.modelINFO);
     WrForm(wrForm.modelReport);
 }
Beispiel #27
0
        public void UT_Pricing()
        {
            boot.Init();
            mod = mod.sr.SetModel(boot);
            double priceExcel = mod.total_price;    // price from Excel

            // test 0: по одной или более групп match найден.
            mod.mh.Pricing(ref mod);
            Assert.IsTrue(mod.matches.Count > 0);
            if (mod.name == "Chasovnya+lepestok")
            {
                bool c235found = false;
                foreach (var r in mod.Rules)
                {
                    if (!r.text.Contains("235"))
                    {
                        continue;
                    }
                    c235found = true;
                    break;
                }
                Assert.IsTrue(c235found);
            }

            // test 1: посчитана общая цена проекта
            double totalPrice = 0;

            foreach (var match in mod.matches)
            {
                totalPrice += match.group.totalPrice;
            }
            Assert.IsTrue(totalPrice > 1000);
            priceExcel = Math.Round(priceExcel / 1000000, 1);
            totalPrice = Math.Round(totalPrice / 1000000, 1);
            Assert.AreEqual(totalPrice, priceExcel);

            if (mod.name == "ONPZ-RD-ONHP-3314-1075_1.001-CI_3D_Tekla")
            {
                Assert.AreEqual(21, mod.matches.Count);
                // в Excel 8117835,38862033 rub
                double x = Math.Round(8117835.38862033 / 1000000, 1);
                Assert.AreEqual(8.1, x);
                double p = Math.Round(mod.total_price / 1000000, 1);
                Assert.AreEqual(6.1, p);
            }

            FileOp.AppQuit();
        }
Beispiel #28
0
        private void Form1_Load(object sender, EventArgs e)
        {
            boot  = new Boot();
            model = boot.model;
            WrForm(wrForm.modelINFO);
            WrForm(wrForm.modelReport);
            List <Gr> grLst = new List <Gr>();

            foreach (var gr in model.elmGroups)
            {
                if (gr.totalPrice == 0)
                {
                    grLst.Add(gr);
                }
            }
            model.Highlight(grLst);
        }
Beispiel #29
0
        public void UT_GetSavedReport()
        {
            init();
            U._GetTSmatchINFO(model);

            model = U._GetSavedReport();

            bool ok = model.sr.CheckModelIntegrity(model);

            Assert.IsTrue(ok);

            var total_price = model.elmGroups.Sum(x => x.totalPrice);

            Assert.IsTrue(model.elmGroups.Sum(x => x.totalPrice) > 0);

            FileOp.AppQuit();
        }
Beispiel #30
0
        public void Pricing(ref Mod m, bool unit_test_mode = false)
        {
            Log.set("mh.Pricing");
#if DEBUG
            testMode = unit_test_mode;
            var x = new Mtch(m);
#endif
            if (m.Rules == null || m.Rules.Count == 0)
            {
                m = sr._GetSavedRules(m);
            }
            log.Info(">m.MD5=" + m.MD5 + " =?= " + m.getMD5(m.elements));
            Hndl(ref m);
            log.Info(">m.MD5=" + m.MD5 + " =?= " + m.getMD5(m.elements));
            Log.Trace("      date=\t" + m.date + "\tMD5=" + m.MD5 + "\telements.Count=" + m.elements.Count);
            Log.Trace("price date=\t" + m.pricingDate + "\tMD5=" + m.pricingMD5 + "\ttotal price" + m.total_price);
            Log.exit();
        }