Example #1
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;
 }
Example #2
0
        public void UT_CheckGroups()
        {
            boot.Init();
            model = model.sr.SetModel(boot);
            var gr = new _Group();

            // test 1: проверка наличия разных материалов в одной группе (Msg.W en и ru)
            string s = gr._CheckGroups(ref model, "en", "W");

            var grps     = model.elmGroups;
            int cntUsual = grps.Count(x => x.type == Group.GrType.UsualPrice);
            int cntSpec  = grps.Count(x => x.type == Group.GrType.SpecPrice);
            int cntNo    = grps.Count(x => x.type == Group.GrType.NoPrice);
            int cntWarn  = grps.Count(x => x.type == Group.GrType.Warning);

            Assert.AreEqual(grps.Count(), cntNo + cntSpec + cntUsual + cntWarn);
            if (cntWarn > 0)
            {
                bool w = grps.Any(x => x.type == Group.GrType.Warning);
                Assert.IsTrue(w);
                Assert.AreEqual("various materials in Group [4]\r\nprofile=\"900X900\", materials \"B20\", and \"Concrete_Undefined\"", s);
                s = gr._CheckGroups(ref model, "ru", "W");
                Assert.AreEqual("разные материалы в группе [4]\r\nс профилем \"900X900\", материалы \"B20\" и \"Concrete_Undefined\"", s);
            }

            // test 2: проверка (Msg.F en и ru)
            model.elements.Clear();
            s = gr._CheckGroups(ref model, "en", "F");
            Assert.AreEqual("bad element or group list in model \"ONPZ-RD-ONHP-3314-1075_1.001-CI_3D_Tekla\" ", s);
            s = gr._CheckGroups(ref model, "ru", "F");
            Assert.AreEqual("ошибка списка элементов или списка групп в модели \"ONPZ-RD-ONHP-3314-1075_1.001-CI_3D_Tekla\"", s);

            FileOp.AppQuit();
        }
Example #3
0
            internal static bool checkResource(List <Resource> Resources, R_name name, string arg = "")
            {
                bool ok = false;

                switch (name)
                {
                case R_name.Tekla:
                    ok = TS.isTeklaActive();
                    break;

                case R_name.TSmatch:
                    string TOCdir = arg;
                    if (String.IsNullOrEmpty(TOCdir))
                    {
                        Msg.F(
                            "\n\r\n\r================================================"
                            + "\n\rTSmatch application is not initiated properly:"
                            + "\n\rTSmatch.xlsx not available, because TOCdir=null."
                            + "\n\r================================================\n\r");
                    }
                    ok = FileOp.isFileExist(TOCdir, Decl.F_MATCH);
                    Resource r = Resources.Find(x => x.name == Decl.TSMATCH);

                    //////                     if (!ok) Recover(Decl.RESOURCE_FAULT_REASON.NoFile);
                    //////                     if (!checkTOCdate(TOCdir, this)) Recover(Decl.RESOURCE_FAULT_REASON.Obsolete);
                    break;
                }
                return(ok);

                throw new NotImplementedException();
            }
Example #4
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();
        }
Example #5
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();
        }
Example #6
0
 /// <summary>
 /// getDoc(name) - get Document name - when nor read yet - from the file. If necessary - Create new Sheet
 /// </summary>
 /// <param name="name">Document name</param>
 /// <param name="fatal">FATAL if this flag = true; else - return null if Document doesnt exists</param>
 /// <returns>Document or null</returns>
 /// <returns>Document</returns>
 /// <history> 25.12.2013 отлажено
 /// 25.12.2013 - чтение из файла, формирование Range Body
 /// 28.12.13 - теперь doc.Sheet и doc.Wb храним в структуре Документа
 /// 5.4.14  - инициализируем docDic, то есть подготавливаем набор данных для Fetch
 /// 22.12.15 - getDoc для нового документа - в Штампе он помечен N
 /// 6.1.16 - NOP если FiliDirectory содержит # - каталог Документа еще будет разворачиваться позже
 ///  5.3.16 - null if Document not found or exist
 /// 30.3.16 - get #template Path from Bootstrap.Template; try-catch rewritten
 ///  5.4.16 - bug fix - SheetReset for "N" Document
 /// 19.4.16 - use Templ.getPath in getDoc()
 /// 27.4.16 - optional flag load - if false -> don't load contents from the file
 /// </history>
 public static Document getDoc(string name = Decl.DOC_TOC, bool fatal = true, bool load = true)
 {
     Log.set("getDoc(" + name + ")");
     Document doc = null;
     string err = "Err getDoc: ", ex= "";
     try { doc = Documents[name]; }
     catch (Exception e) { err += "doc not in TOC"; ex = e.Message; doc = null; }
     if (doc != null && !doc.isOpen)
     {
         if (load)
         {
             if (doc.FileDirectory.Contains("#")) // #Template substitute with Path in Dictionary
                 doc.FileDirectory = Templates[doc.FileDirectory];
             //-------- Load Document from the file or create it ------------
             bool create = !string.IsNullOrEmpty(doc.type) && doc.type[0] == 'N' ? true : false;
             doc.Wb = FileOp.fileOpen(doc.FileDirectory, doc.FileName, create);
             try
             {
                 if (doc.type == Decl.DOC_TYPE_N) FileOp.SheetReset(doc.Wb, doc.SheetN);
                 doc.Sheet = doc.Wb.Worksheets[doc.SheetN];
             }
             catch (Exception e) { err += "no SheetN"; ex = doc.SheetN; doc = null; }
             if (create && doc != null) doc.Reset();
             else if (doc != null) doc.Body = FileOp.getSheetValue(doc.Sheet);
         }
     } // end if(!doc.isOpen)
     if(doc == null && fatal) Msg.F(err, ex, name);
     if(doc != null && doc.Body != null) doc.isOpen = true;
     Log.exit();
     return doc;
 }
Example #7
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;
        }
Example #8
0
 //public void wrDoc(string form_name, params object[] objs)
 //{
 //    wrDoc(form_name, objs);
 //}
 ////////public void wrDoc(int iForm, object[] lst) // List<T> lst)
 ////////{
 ////////    Form frm = forms.Find(x => x.name == forms[iForm].name);
 ////////    string format_name = frm.name + "_F";
 ////////    if (!FileOp.isNamedRangeExist(Wb, format_name)) Msg.F("ERR __!!__.NOFORM_F", frm.name);
 ////////    object[] obj = new object[lst.Count];
 ////////    //!!-- fill obj[]
 ////////    wrDoc(frm.name, obj);
 ////////}
 ////public void wrDoc(string str)
 ////{
 ////    object[] t = { Lib.timeStr() };
 ////    wrDoc(str, t);
 ////    Body[1, 1] = t[0];
 ////}
 public void wrDoc(List<int> rows, List<int> cols, List<int> rFr, List<int> cFr)
 {
     Log.set("wrDoc(List rows, List cols, List rFr, List cFr)");
     Mtr tmpBody = FileOp.getSheetValue(this.Sheet);
     throw new NotImplementedException();
     Log.exit();
 }
Example #9
0
 /// <summary>
 /// List<Form> Init(int toc_line) - initiate all Forms for Document in toc_line.
 /// </summary>
 /// <param name="toc_line">line number in TOC</param>
 /// <returns>form list</returns>
 public static List<Form> Init(int toc_line)
 {
     Log.set("Init(" + toc_line + ")");
     //------------------------------------------------------------------------------
     language = true; //en-US for Englisg Debug. Remove or comment this line later  !
     //------------------------------------------------------------------------------
     List<Form> Forms = new List<Form>();
     for (int col = Decl.DOC_FORMS, i = 0; i < 10; i++)
     {
         string s = Lang(tocMtr.Strng(toc_line, col++));
         if (string.IsNullOrEmpty(s)) continue;
         if (FileOp.isNamedRangeExist(Wb, s))
         {
             List<int> _r = new List<int>();
             List<int> _c = new List<int>();
             string sf = s + "_F";
             if (FileOp.isNamedRangeExist(Wb, sf))
             {
                 Mtr format = new Mtr(Wb.Names.Item(sf).RefersToRange.Value);
                 for (int c = 1; c <= format.iEOC(); c++)
                     for (int r = 1; r <= format.iEOL(); r++)
                     {
                         string f = format.Strng(r, c);
                         if (f.Contains("{") & f.Contains("}")) { _r.Add(r); _c.Add(c); }
                     }
             }
             Forms.Add(new Form(s, _r, _c));
         }
     }
     Log.exit();
     return Forms;
 }
Example #10
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();
        }
Example #11
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();
        }
Example #12
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();
        }
Example #13
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();
        }
Example #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();
        }
Example #15
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();
        }
Example #16
0
 protected void CheckResx(string rName, string rValue)
 {
     ResType type = ResType.Err;
     foreach (var x in ResTab)
     {
         if (!rValue.Contains(x.Value)) continue;
         type = x.Key;
         break;
     }
     int indx = rValue.IndexOf(':') + 1;
     string v = rValue.Substring(indx).Trim();
     switch (type)
     {
         case ResType.Doc:
             if (!Docs.IsDocExist(rName)) resxError(ResErr.NoDoc, rName);
             break;
         case ResType.File:
             if (!FileOp.isFileExist(rName)) resxError(ResErr.NoFile, rName);
             break;
         case ResType.Date:
             DateTime d = Lib.getDateTime(v);
             Docs doc = Docs.getDoc(rName, fatal: false);
             if (doc == null) resxError(ResErr.NoDoc, rName);
             string sdd = doc.Body.Strng(1, 1);
             DateTime dd = Lib.getDateTime(sdd);
             if (dd < d) resxError(ResErr.Obsolete, rName);
             break;
         case ResType.Resx:
             break;
         default: resxError(ResErr.ErrResource, rName); break;
     }
 }
Example #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();
        }
Example #18
0
        public static List <Elms> Read(string ifcFileName)
        {
            var manager = new IfcManager.Core.IfcManager();

            if (!FileOp.isFileExist(ifcFileName))
            {
                Message.Message Msg = new Message.Message(); Msg.F("IFC.Read: no file", ifcFileName);
            }

            log.Info("TRACE: Read(\"" + ifcFileName + "\"");

            manager.init(ifcFileName, schemaName);

            List <IfcManager.Core.IfcManager.IfcElement> elements = new List <IfcManager.Core.IfcManager.IfcElement>();

            elements = manager.getElementsByProperty("NetVolume");
            IFC.MergeIfcToElmAttSet(elements);

            elements.Clear();
            elements = manager.getElementsByProperty("Weight");
            IFC.MergeIfcToElmAttSet(elements);

            elements.Clear();
            elements = manager.getElementsByMaterials();
            IFC.MergeIfcToElmAttSet(elements);

            elements.Clear();
            elements = manager.getElementsByProperty("Profile");
            IFC.MergeIfcToElmAttSet(elements);

            List <ElmAttributes.ElmAttSet> result = new List <ElmAttributes.ElmAttSet>();

            result = ElmAttributes.ElmAttSet.Elements.Values.ToList();
            foreach (var elm in result)
            {
                string[] matToSplit = elm.mat.Split('/');
                switch (matToSplit.Count())
                {
                case 2:
                    elm.mat_type = matToSplit[0];
                    elm.mat      = matToSplit[1];
                    break;

                case 1:
                    elm.mat_type = "STEEL";
                    elm.prf      = elm.mat; // А400 - это арматура; почемуто ее марку указывают как материал
                                            //..здесь еще надо разобраться с ГОСТ-5781
                                            //..и присвоить значения элемента mat, prf и др
                    break;

                default:
                    Message.Message Msg = new Message.Message(); Msg.F("IFC error Material Parse", elm.mat);
                    break;
                }
            }
            result.Sort();
            return(result);
        }
Example #19
0
        public void UT_Mtch()
        {
            boot.Init();
            var model = mod.sr.SetModel(boot, initSupl: false);

            Assert.IsTrue(model.elmGroups.Count > 0);
            Assert.IsTrue(model.Rules.Count > 0);
            var Rules = model.Rules.ToList();
            var grps  = model.elmGroups.ToList();

            // test 1 Уголок L50x5 -> цена 7 209 руб
            Rule.Rule   rule = Rules.Find(x => x.sCS.Contains("Уголок"));
            Group.Group gr   = grps.Find(x => x.Prf.Contains("L"));
            if (rule != null && gr != null)
            {
                rule.Init();
                var m = new Mtch(gr, rule);
                Assert.IsTrue(gr.totalPrice > 7000);
                double rubPerKg = gr.totalPrice / gr.totalWeight;
                Assert.IsTrue(rubPerKg > 20);
            }

            // test 2 Полоса -30 из Листа ЛСС
            rule = Rules.Find(x => x.sCS.Contains("Лист"));
            gr   = grps.Find(x => x.Prf.Contains("—"));
            if (rule != null && gr != null)
            {
                rule.Init();
                var m = new Mtch(gr, rule);
                Assert.IsTrue(gr.totalPrice > 7000);
                double rubPerKg = gr.totalPrice / gr.totalWeight;
                Assert.IsTrue(rubPerKg > 20);
            }

            // test 3 Бетон
            rule = Rules.Find(x => x.sCS.Contains("бетон"));
            gr   = grps.Find(x => x.mat.Contains("b"));
            if (rule != null && gr != null)
            {
                rule.Init();
                var m = new Mtch(gr, rule);
                Assert.IsTrue(gr.totalPrice > 7000);
                double rubPerM3 = gr.totalPrice / gr.totalVolume; //.totalWeight;
                Assert.IsTrue(rubPerM3 > 2000);
            }
            //foreach (var gr in model.elmGroups)
            //{
            //    Assert.IsTrue(model.Rules.Count > 0);
            //    foreach (var rule in model.Rules)
            //    {
            //        Assert.IsNotNull(rule.CompSet.Supplier);
            //        Assert.IsTrue(rule.CompSet.Components.Count > 0);
            //        Mtch _match = new Mtch(gr, rule);
            //    }
            //}
            FileOp.AppQuit();
        }
Example #20
0
 public static bool IsDocExists(string name)
 {
     if (!Documents.ContainsKey(name)) return false;
     Document doc = Documents[name];
     if (doc.FileDirectory.Contains("#")) // #Template substitute with Path in Dictionary
         doc.FileDirectory = Templates[doc.FileDirectory];
     bool ok = FileOp.isFileExist(doc.FileDirectory, doc.FileName);
     return ok;
 }
Example #21
0
        public void UT_DocMsg()
        {
            boot.Init();
// не написано, отложил на потом!!!!!!!!!!!!!!!!
            // test 1: getDoc("No File")
            // test 2: getDoc("No SheetN")
            //         Assert.Fail();

            FileOp.AppQuit();
        }
Example #22
0
        public void UT_Reset()
        {
            boot.Init();
            Document doc = Document.getDoc("ModelINFO", reset: true, create_if_notexist: true);

            Assert.IsNotNull(doc);
            Assert.IsTrue(doc.il > doc.i0);

            FileOp.AppQuit();
        }
Example #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();
        }
Example #24
0
 /// <summary>
 /// Close([save_flag])   - Close document, save it when saveflag=true, default - false;
 /// </summary>
 /// <param name="save_flag">saveDoc if true. This case all rest parameters as in saveDoc</param>
 public void Close(bool save_flag = false, bool BodySave = true, string MD5 = "", int EOL = 0)
 {
     Log.set("Close(" + name + ")");
     if (save_flag) saveDoc(this, BodySave, MD5, EOL);
     this.isOpen = false;
     FileOp.DisplayAlert(false);
     try { this.Wb.Close(); }
     catch {  }
     FileOp.DisplayAlert(true);
     Log.exit();
 }
Example #25
0
 public static bool IsDocExist(string name = "TOC")
 {
     if (!Documents.ContainsKey(name)) return false;
     Document doc = Documents[name];
     if (doc.FileDirectory.Contains("#")) // #Template substitute with Path in Dictionary
         doc.FileDirectory = Templates[doc.FileDirectory];
     if( !FileOp.isFileExist(doc.FileDirectory, doc.FileName) ) return false;
     if (!doc.isOpen) getDoc(name, fatal: false);
     if (!FileOp.isSheetExist(doc.Wb, doc.SheetN)) return false;
     return true;
 }
Example #26
0
        /// <summary>
        /// CheckIfcGuids() - read Ifc file and check GUIDs of elements in it for Werfau needs
        /// </summary>
        internal void CheckIfcGuids(string ifcFile)
        {
            if (!FileOp.isFileExist(ifcFile))
            {
                Msg.F("No Ifc input file", ifcFile);
            }
            List <Elms> elements = new List <Elms>();

            elements = Read(ifcFile);
            throw new NotImplementedException();
        }
Example #27
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();
        }
Example #28
0
        public void UT_EOL()
        {
            boot.Init();
            string sIR = "InitialRules";

            var doc = Document.getDoc(sIR);

            Assert.AreEqual(sIR, doc.name);
            Assert.AreEqual(4, doc.i0);
            Assert.AreEqual(15, doc.il);

            FileOp.AppQuit();
        }
Example #29
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();
        }
Example #30
0
        public void openModel(string name = RECENT_MODEL)
        {
            Log.set("openModel(\"" + name + "\")");
            Model mod = null;
            bool ok = false;
            if (TS.isTeklaActive())
            {
                //!! here we could upload over API in Tekla another model it differ from requested name
                //!! if (TS.isTeklaModel(mod.name))
                //!! implement it later on 23/6/2016
                UpdateFrTekla();
            }
            if (name == RECENT_MODEL) mod = RecentModel();
                                 else mod = getModel(name);

            string dir = mod.dir;
            string FileName = "TSmatchINFO.xlsx";
            if (mod.Made == "IFC") FileName = "out.ifc";
            if (mod != null) ok = FileOp.isFileExist(dir, FileName);

            if (!ok)
            {           //-- Folder or File Browth dialog
                FolderBrowserDialog ffd = new FolderBrowserDialog();
                dir = ffd.SelectedPath = mod.dir;
                DialogResult result = ffd.ShowDialog();
                if (result == DialogResult.OK) dir = ffd.SelectedPath;
                do
                {
                    if (!FileOp.isFileExist(dir, FileName))
                    {
                        Msg.W("W20.4_opMod_NO_TSmINFO", dir);
                        OpenFileDialog ofd = new OpenFileDialog();
                        ofd.InitialDirectory = dir;
                        if (ofd.ShowDialog() == DialogResult.OK)
                        {
                            FileName = ofd.FileName;
                            // !!!!!!                       dir = ofd.Sel
                        }
                    }
                    ok = readModel(dir, FileName);
                    //!!!                if(!ok) Msg.Ask(Еще раз?) break;
                } while (!ok);
            }
            else
            {
                string ext = Path.GetExtension(FileName);
                if ( ext == ".ifc") Ifc.Read(dir, FileName); //!!
                if (ext == ".xlsx") dir= "";//!! readModel();
            }
            Log.exit();
        }