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(); }
/// <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; }
/// <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; }
public void UT_CheckModelIntegrity_native() { boot = new Boot(); boot.Init(); model = new Mod(); model = model.sr.SetModel(boot); 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); FileOp.AppQuit(); }
protected void SetModDir(Boot boot) { const string me = "SavedReport__SetModelDir_"; Msg = boot.Msg; if (boot.isTeklaActive) { // if Tekla is active - get Path of TSmatch model.name = Path.GetFileNameWithoutExtension(TS.ModInfo.ModelName); model.dir = TS.GetTeklaDir(TS.ModelDir.model); model.phase = TS.ModInfo.CurrentPhase.ToString(); //6/4/17 macroDir = TS.GetTeklaDir(TS.ModelDir.macro); model.HighLightClear(); } else { // if Tekla not active - get model attributes from TSmatchINFO.xlsx in ModelDir model.dir = boot.ModelDir; if (!FileOp.isDirExist(model.dir)) Msg.F(me + "No Model Directory", model.dir); if (!Docs.IsDocExist(Decl.TSMATCHINFO_MODELINFO)) Msg.F(me + "No_TSmatchINFO", model.dir); dINFO = Docs.getDoc(sINFO, fatal: false); if (dINFO == null || dINFO.il < 10 || !FileOp.isDirExist(model.dir)) error(); model.name = dINFO.Body.Strng(Decl.MODINFO_NAME_R, 2); model.phase = dINFO.Body.Strng(Decl.MODINFO_PHASE_R, 2); } }