示例#1
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();
        }
示例#2
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;
     }
 }
示例#3
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;
 }
示例#4
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;
        }
示例#5
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();
            }
示例#6
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);
        }
示例#7
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;
 }
示例#8
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;
 }
示例#9
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();
        }
示例#10
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();
        }
示例#11
0
 /// <summary>
 /// Read() - получение модели (списка элементов с атрибутами) из Tekla или IFC
 /// </summary>
 /// <returns>Model со списком прочитанных элементов в model.elements</returns>
 public Model Read()
 {
     elements.Clear();
     if (TS.isTeklaActive()) elements = ts.Read();
     else elements = Ifc.Read(ifcPath);
     string newMD5 = getMD5(elements);
     string fileRaw = Path.Combine(dir, Decl.RAWXML);
     if (newMD5 != MD5 || !FileOp.isFileExist(fileRaw))
     {
         isChanged = true;
         MD5 = newMD5;
         date = DateTime.Now;
         rwXML.XML.WriteToXmlFile(fileRaw, elements);
     }
     return this;
 }
示例#12
0
        /// <summary>
        /// newModelOpenDialog(models) -- run when new Model must be open not exists in Model Journal models
        /// </summary>
        /// <param name="models">List<Models> to be updated after dialog</param>
        /// <returns>List<Model></Model>sorted models list -- models[0] - just opened Model</returns>
        /// <history>6.08.2016</history>
        internal static Model newModelOpenDialog(out List <Model> models)
        {
            Model  result = null;
            string newFileDir = "", newFileName = "";

            throw new NotImplementedException();

            while (result != null)
            {
                if (FileOp.isFileExist(newFileDir, newFileName))
                {
                }
                models = Start();
//TODO                models.savModelJournal();
            }
            return(result);
        }