예제 #1
0
        void test_Mtch_3()
        {
            Log.set(" test_Mtch_3: Rule 5 и Group < C235, Pl30 >");
            rule = new Rule.Rule(5);
            ElmAttSet.ElmAttSet elm = new ElmAttSet.ElmAttSet(
                "ID56A7442F-0000-0D74-3134-353338303236",
                "C235", "Steel", "Pl30", 0, 0, 0, 1001);
            Dictionary <string, ElmAttSet.ElmAttSet> els
                = new Dictionary <string, ElmAttSet.ElmAttSet>();

            els.Add(elm.guid, elm);
            List <string> guids = new List <string>(); guids.Add(elm.guid);
            var           model = new Model.Model();

            model.setElements(els);
            model.getGroups();
            var gr = model.elmGroups[0];
            //6/4/17           TST.Eq(gr.guids.Count, 1);
            //6/4/17           TST.Eq(gr.mat, "c235");
            //6/4/17TST.Eq(gr.prf, "pl30");
            var doc  = Docs.getDoc("Полоса СтальхолдингM");
            var csDP = new Dictionary <SType, string>();

//31/3            csFPs = rule.Parser(FP.type.CompSet, doc.LoadDescription);
// 2/4            Comp comp1 = new Comp(doc, 2, csDP);
// 2/4            Comp comp2 = new Comp(doc, 12, csDP);
// 2/4            List<Comp> comps = new List<Comp> { comp1, comp2 };
// 2/4            CS cs = new CS("test_CS", null, rule, doc.LoadDescription, comps);
// 2/4            TST.Eq(cs.csDP.Count, 4);

            //////////////////////////TST.Eq(comp1.isMatch(gr, rule), false);
            //////////////////////////TST.Eq(comp2.isMatch(gr, rule), true);
            Log.exit();
        }
예제 #2
0
 private void getSavedGroups()
 {
     Docs docRaw = Docs.getDoc(Decl.TSMATCHINFO_RAW, create_if_notexist: false);
     elements.Clear();
     int cnt = docRaw.Body.iEOL();
     for (int i = docRaw.i0; i <= cnt; i++)
     {
         string guid = docRaw.Body.Strng(i, 1);
         string mat = docRaw.Body.Strng(i, 2);
         string mat_type = docRaw.Body.Strng(i, 3);
         string prf = docRaw.Body.Strng(i, 4);
         double lng = docRaw.Body.Double(i, 5);
         double weight = docRaw.Body.Double(i, 6);
         double vol = docRaw.Body.Double(i, 7);
         Elm elm = new Elm(guid, mat, mat_type, prf, lng, weight, vol);
         elements.Add(elm);
     }
     if (elements.Count != elementsCount)
     {
         Msg.F("TSmatchINFO.xlsx inconsystent", name, elementsCount, elements.Count);
         //11/4                GetSavedReport(doRead: true);
     }
     docReport = Docs.getDoc(Decl.TSMATCHINFO_REPORT);
     getGroups();
     int gr_n = docReport.i0;
     foreach (var gr in elmGroups)
     {
         string grPrice = docReport.Body.Strng(gr_n, Decl.REPORT_SUPL_PRICE);
         gr.totalPrice = Lib.ToDouble(grPrice);
         gr.SupplierName = docReport.Body.Strng(gr_n, Decl.REPORT_SUPPLIER);
         gr.CompSetName = docReport.Body.Strng(gr_n, Decl.REPORT_COMPSET);
         gr_n++;
     }
 }
예제 #3
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;
     }
 }
예제 #4
0
 public void Recover(string repNm, RecoverToDo to_do)
 {
     Log.set(@"SR.Recover(" + repNm + "\")");
     if (!CheckModelIntegrity(model)) Msg.AskFOK("Recovery impossible");
     switch (to_do)
     {
         case RecoverToDo.CreateRep:
             Msg.AskFOK("В каталоге модели нет TSmatchINFO.xlsx/" + repNm + ". Создать?");
             resetDialog = false;
             Docs.getDoc(repNm, reset: true, create_if_notexist: true);
             if (!Docs.IsDocExist(repNm)) Msg.F("SaveDoc.Recover cannot create ", repNm);
             Recover(repNm, RecoverToDo.ResetRep);
             break;
         case RecoverToDo.ResetRep:
             if (resetDialog) Msg.AskFOK("Вы действительно намерены переписать TSmatchINFO.xlsx/" + repNm + "?");
             var w = new WrMod();
             switch (repNm)
             {
                 case Decl.TSMATCHINFO_MODELINFO:
                     w.wrModel(WrM.ModelINFO, model);
                     break;
                 case Decl.TSMATCHINFO_REPORT:
                     log.Info(">>mod.MD5=" + model.MD5 + " =?= " + model.getMD5(model.elements));
                     mh.Pricing(ref model);
                     log.Info(">>mod.MD5=" + model.MD5 + " =?= " + model.getMD5(model.elements));
                     w.wrModel(WrM.Report, model);
                     break;
             }
             break;
     }
     Log.exit();
 }
예제 #5
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;
 }
예제 #6
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;
        }
예제 #7
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);
        }
예제 #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();
        }
예제 #9
0
        /// <summary>
        /// SupplReport() - Debugging report: output list of Supplier companies in TSmatch.xlsx/Suppliers
        /// </summary>
        public static void SupplReport()
        {
            List <Supplier> Suppliers = new List <Supplier>();
            Docs            docSupl   = Docs.getDoc(Decl.SUPPLIERS);

            for (int i = docSupl.i0; i <= docSupl.il; i++)
            {
                Suppliers.Add(new Supplier(i));
            }
            Docs doc = Docs.getDoc("SupplReport");

            doc.Reset("Now");
            foreach (var s in Suppliers)
            {
                doc.wrDoc(1, s.date, s.name, s.Url, s.City, s.index, s.street, s.telephone, s.CompSets.Count);
                foreach (var cs in s.CompSets)
                {
                    //11.1.17                    cs.getCompSet();
                    //////CmpSet.getCompSet(cs.name, s);
                    //////Docs w = Docs.getDoc(cs.doc.name);
                    //////cs.doc = w;
                    Docs   w  = cs.doc;
                    string nm = w.Wb.Name + "/" + w.Sheet.Name;
                    doc.wrDoc(2, w.name, nm, w.i0, w.il, w.LoadDescription);
                }
                foreach (var cs in s.CompSets)
                {
                    cs.doc.Close();
                }
            }
            doc.saveDoc();
            doc.Close();
        }
예제 #10
0
        public W_Supplier()
        {
            InitializeComponent();
            Title = "TSmatch: выбор поставщика";
            List <Spl> items = new List <Spl>();
            Docs       doc   = Docs.getDoc(Decl.SUPPLIERS);

            for (int i = doc.i0; i <= doc.il; i++)
            {
                Supl s = new Supl(i);
                if (s == null || string.IsNullOrWhiteSpace(s.Name) || string.IsNullOrWhiteSpace(s.City))
                {
                    continue;
                }
                items.Add(new Spl(s.Name, Lib.ToInt(s.Index), s.City, s.Street, s.Url));
                suppliers.Add(s);
            }
            Spl oldSupl = items.Find(x => x.SuplName == MainWindow.SuplName);

            if (oldSupl == null)
            {
                Msg.F("W_Supplier: No Selected SuplName");
            }
            int ind = items.IndexOf(oldSupl);

            items[ind].Flag = true;
            log.Info("Supplier.Count=" + suppliers.Count + "\tInitial Supplier =\"" + oldSupl.SuplName + "\"");
            items.Sort();
            Suppliers.ItemsSource = items;
        }
예제 #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();
        }
예제 #12
0
        public void CheckAll()
        {
            Docs toc = Docs.getDoc();

            //-- Check TSmach.xlsx/Suppliers consystancy
            Docs SupList = Docs.getDoc(Decl.SUPPLIERS);

            for (int i = SupList.i0; i <= SupList.il; i++)
            {
                Supl s         = new Supl(i);
                int  nCompSets = SupList.Body.Int(i, Decl.SUPL_LISTCOUNT);
                for (int n = 0; n < nCompSets; n++)
                {
                    string csName = SupList.Body.Strng(i, Decl.SUPL_LISTCOUNT + n + 1);
                    CS     cs     = null;
                    try { cs = new CS(csName, s); }
                    catch { }
                    var    ruleLst = Rule.Rule.getList(s.Name);
                    string msg     = string.Format("PriceList \"{0}\" "
                                                   + " not awalable from Supplier \"{1}\"", csName, s.Name);
                    if (ruleLst.Count == 0)
                    {
                        msg += ", and no Rule for him";
                    }
                    else
                    {
                        msg += string.Format(", however, available {0} for him", ruleLst.Count);
                    }
                    log.Info(msg);
                    if (cs == null)
                    {
                        continue;
                    }
                    cs.doc.Close();
                }
            }
            return;

            //-- check toc and close open price-lists
            for (int i = toc.i0; i <= toc.il; i++)
            {
                string type = toc.Body.Strng(i, Decl.DOC_TYPE);
                if (!type.Contains("Comp"))
                {
                    continue;
                }
                string doc_name = toc.Body.Strng(i, Decl.DOC_NAME);
                Docs   doc      = Docs.getDoc(doc_name, fatal: false);
                if (doc == null)
                {
                    continue;
                }
                doc.Close();
            }
        }
예제 #13
0
 public bool GetSavedReport()    //11/4 bool doRead = false)
 {
     if (!Docs.IsDocExists(Decl.TSMATCHINFO_MODELINFO)) return false;
     Docs doc = Docs.getDoc(Decl.TSMATCHINFO_MODELINFO);
     if (isChangedStr(ref name, doc, 2, 2)) return false;
     iModJounal = getModJournal(name);
     date = DateTime.Parse(modJournal(iModJounal, Decl.MODEL_DATE));
     if (!isChangedInt(ref elementsCount, doc, 7, 2))
         getSavedGroups();
     return true;
 }
예제 #14
0
 private void getSupplier(int n)
 {
     Docs docSupl = Docs.getDoc(Decl.SUPPLIERS);
     Date = Lib.getDateTime(docSupl.Body[n, Decl.SUPL_DATE]);
     Name = (string)docSupl.Body[n, Decl.SUPL_NAME];
     Url = (string)docSupl.Body[n, Decl.SUPL_URL];
     City = (string)docSupl.Body[n, Decl.SUPL_CITY];
     Street = (string)docSupl.Body[n, Decl.SUPL_STREET];
     Index = (string)docSupl.Body[n, Decl.SUPL_INDEX];
     Telephone = (string)docSupl.Body[n, Decl.SUPL_TEL];
 }
예제 #15
0
 /// <summary>
 /// Model.Start() - начинает работу со списком моделей, инициализирует структуры данных
 /// </summary>
 /// <returns></returns>
 /// <history>12.2.2016<\history>
 public static List<Model> Start()
 {
     Log.set("Model.Start");
     Models.Clear();
     Docs doc = Docs.getDoc(Decl.MODELS);
     for (int i = doc.i0; i <= doc.il; i++)
         if (doc.Body[i, Decl.MODEL_NAME] != null) Models.Add(new Model(doc, i));
     List<string> strLst = new List<string>();
     foreach (var m in Models) strLst.Add(m.name);
     strLst.Sort();
     Log.exit();
     return Models;
 }
예제 #16
0
        private static bool readModel(string dir = null, string FileName = "TSmatchINFO.xlsx")
        {
            Log.set("readModel(" + dir + ", " + FileName + ")");
            bool ok = false;
//!!            Docs.setDocTemplate(Decl.TEMPL_TMP, dir);
            Docs tmp = Docs.getDoc(Decl.TMP_RAW);
            Docs tmpINFO = Docs.getDoc(Decl.TMP_MODELINFO);
//!!            List<TS.AttSet> diff = new List<TS.AttSet>();
            throw new NotImplementedException(); //!!!!!!!!!!!!!!!!!!!!!!!!!!!
//!!            elm = diff;
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            Log.exit();
            return ok;
        }
예제 #17
0
 public Supplier(string _name, bool init=true)
 {
     Name = _name;
     if (!init) return;
     Docs docSupl = Docs.getDoc(Decl.SUPPLIERS);
     for (int i = docSupl.i0; i <= docSupl.il; i++)
     {
         string suplName = docSupl.Body.Strng(i, Decl.SUPL_NAME);
         if (suplName != _name) continue;
         getSupplier(i);
         return;
     }
     Msg.W("No such Supplier(" + _name + ")");
 }
예제 #18
0
 /// <summary>
 /// getModJournal(name, dir) - get model from Model Journal in TSmatch.xlsx
 /// </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>line number in TSmatch.xlsx/Models</returns>
 /// <ToDo>10.4.17 реализовать default name и dir </ToDo>
 public int getModJournal(string name = "", string dir = "")
 {
     Docs doc = Docs.getDoc(Decl.MODELS);
     if (name == "") throw new NotImplementedException();
     for (int i = doc.i0; i <= doc.il; i++)
     {
         if (dir != "" && dir != doc.Body.Strng(i, Decl.MODEL_DIR)) continue;
         if (name != doc.Body.Strng(i, Decl.MODEL_NAME)) continue;
         return i;
     }
     throw new NotFiniteNumberException();
     // тут надо записывать в Журнал Моделей
     Msg.I("new record in Model Journul", name, dir);
     return -1;
 }
예제 #19
0
        internal static List <string> getList(string name)
        {
            List <string> result = new List <string>();
            Docs          doc    = Docs.getDoc(Decl.TSMATCHINFO_RULES);

            for (int i = doc.i0; i <= doc.il; i++)
            {
                string suplName = doc.Body.Strng(i, Decl.RULE_SUPPLIERNAME);
                if (suplName != name)
                {
                    continue;
                }
                result.Add(suplName);
            }
            return(result);
        }
예제 #20
0
 /// <summary>
 /// saveModel(Model md)  - записываем измененную модель в файловую систему
 /// </summary>
 /// <param name="name">имя модели для записи.</param>
 /// <history>6.8.16 -- nonstatic method</history>
 public Model saveModel(string name)
 {
     Log.set("saveModel(\"" + name + "\")");
     Docs doc = Docs.getDoc(Decl.MODELS);
     doc.Reset("Now");
     Models.Sort();
     foreach (var m in Models)
     {
         string t = Lib.timeStr(m.date);
         doc.wrDoc(1, t, m.name, m.dir, m.Made, m.Phase, m.MD5, m.strListRules);
     }
     doc.isChanged = true;
     Docs.saveDoc(doc);
     Log.exit();
     return getModel(name);
 }
예제 #21
0
        internal static Model getModelFrTekla()
        {
            string modName = TS.getModInfo();
            Docs   doc     = Docs.getDoc(Decl.MODELS);

            for (int i = doc.i0; i <= doc.il; i++)
            {
                if (doc.Body.Strng(i, Decl.MODEL_NAME) != modName)
                {
                    continue;
                }
                return(new TSmatch.Model.Model(i));
            }
            Msg.F("TEMPORARY: New model in Tekla! Put it in Model Jornal manually");
            return(null);
        }
예제 #22
0
        public void Init(bool init = true)
        {
            Log.set("Bootstrap");
            desktop_path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            debug_path = desktop_path;
            if (isTeklaActive)
            {   // if Tekla is active - get Path of TSmatch
                classCAD = new TS();
                _TOCdir = TS.GetTeklaDir(TS.ModelDir.exceldesign);
                ModelDir = TS.GetTeklaDir(TS.ModelDir.model);
                //6/4/17                        macroDir = TS.GetTeklaDir(TS.ModelDir.macro);
                classCAD = new TS();
            }
            else
            {   // if not active - Windows Environment Variable value
                _TOCdir = Environment.GetEnvironmentVariable(Decl.WIN_TSMATCH_DIR,
                    EnvironmentVariableTarget.User);
                ModelDir = desktop_path;
                classCAD = ifc;
            }
            DebugDir = Path.Combine(TOCdir, "TSmatch_DebugData");
            ComponentsDir = TOCdir + @"\База комплектующих";        // all price-lists directory

            if (!init) return;
            CheckResx(Path.Combine(_TOCdir, "TSmatch.xlsx"), Resx.TSmatch_xlsx);
            //--- initiate Docs with #Templates          
            Dictionary <string, string> Templates = new Dictionary<string, string>
                    {
                        {"#TOC",    TOCdir },
                        {"#Model",  ModelDir},
                        {"#Components", ComponentsDir},
                        {"#TMP",    TMPdir},
                        {"#DEBUG",  DebugDir},
                        {"#Macros", macroDir},
                        {"#Envir",  IFCschema}
                    };
            Docs.Start(Templates);
            docTSmatch = Docs.getDoc();
            //--- iniciate Ifc
            IFCschema = Path.Combine(_TOCdir, @"..\inp\IFC2X3.exp");
            ifc.init(IFCschema);        // инициируем IFC, используя файл схемы IFC - обычно из Tekla
            //--check other Resources and we're in air
            CheckResx("Forms", Resx.Forms);
            Log.exit();
        }
예제 #23
0
 /// <summary>
 /// error() - SavedReport error handler method
 /// </summary>
 protected void error(bool errRep = false)
 {
     const string me = "SavedReport__error_";
     Log.set("SR.error()");
     log.Info("error() model.errRecover = " + model.errRecover.ToString());
     if (model.errRecover)
     {
         Msg.AskFOK(me + "Corrupted saved report TSmatchINFO");
         model.elements = Raw(model);
         dRep = Docs.getDoc(sRep);
         if (dRep == null || errRep) Msg.F(me + "recover impossible");
         GetSavedReport();
         Recover(sINFO, RecoverToDo.ResetRep);
         //21/7           Recover(mod, sRep,  RecoverToDo.ResetRep);
     }
     else model.isChanged = true;  // say, that TSmatchINFO.xlsx should be re-written
     Log.exit();
 }
예제 #24
0
        private static void testFP_constuctor2(FingerPrint fp)
        {
            Log.set("testFP_constructor2 - constructor Component.FP");

            FingerPrint csMonolit = new FingerPrint(type.CompSet, "M:B{1};");
            TST.Eq(csMonolit.pars.Count, 1);
            TST.Eq(csMonolit.Col(), 1);
            TST.Eq(csMonolit.txs.Count, 1);
            TST.Eq(csMonolit.txs[0], "b");
            List<FingerPrint> csFPs = new List<FingerPrint>();
            csFPs.Add(csMonolit);
            bool flag = false;
            FingerPrint comp = new FingerPrint("В12,5", csMonolit, out flag);
            TST.Eq(flag, true);
            TST.Eq(comp.pars.Count, 1);
            TST.Eq(comp.pars[0], "12,5");

            comp = new FingerPrint("", csMonolit, out flag);
            TST.Eq(flag, false);

            string sL = "Угoлoк cтaльнoй paвнoпoл. 100 x 8 cт3cп / пc5";
            Docs doc = Docs.getDoc("Уголок Стальхолдинг");
            FingerPrint csAngle = new FingerPrint(type.CompSet, doc.LoadDescription);
            comp = new FingerPrint(sL, csAngle, out flag);

            //////////////////string sL = "Профиль: L=Уголок*{1}x{2}{материал уголков};";
            //////////////////FingerPrint LoadDescriptor = new FingerPrint(type.CompSet, sL);
            //////////////////bool ok = false;
            //////////////////string sComp = "Угoлoк cтaльнoй paвнoпoл. 100 x 7 cт3cп/пc5";
            //////////////////FingerPrint comp = new FingerPrint(sComp, LoadDescriptor, ref ok);

            //           xr1 = new FingerPrint("L18x24", Section.Profile, csFPs);
            //            xr1 = new FingerPrint("B20", csFPs);
            //////////////////////////csFPs.Add(LoadDescriptor);
            //////////////////////////TST.Eq(xr1.typeFP.ToString(), "Component");
            //////////////////////////TST.Eq(xr1.section.ToString(), "Material");
            /// 21/1 /////////////////TST.Eq(xr1.txs.Count, 1);
            //////////////////////////TST.Eq(xr1.txs[0], "b");
            //////////////////////////TST.Eq(xr1.pars.Count, 1);
            //////////////////////////TST.Eq(xr1.pars[0], "20");

            //            throw new NotImplementedException();
            Log.exit();
        }
예제 #25
0
        ////////////////Docs doc = Docs.getDoc(Decl.SUPPLIERS);
        ////////////////this.date = Lib.getDateTime(doc.Body[n, Decl.SUPL_DATE]);
        ////////////////this.name = (string)doc.Body[n, Decl.SUPL_NAME];
        ////////////////this.Url = (string)doc.Body[n, Decl.SUPL_URL];
        ////////////////this.City = (string)doc.Body[n, Decl.SUPL_CITY];
        ////////////////this.street = (string)doc.Body[n, Decl.SUPL_STREET];
        ////////////////this.index = (string)doc.Body[n, Decl.SUPL_INDEX];
        ////////////////this.telephone = (string)doc.Body[n, Decl.SUPL_TEL];
        ////////////////    // get doc_names list from TOC
        ////////////////Docs toc = Docs.getDoc(Decl.DOC_TOC);
        ////////////////for(int i= toc.i0; i < toc.il; i++)
        ////////////////{
        ////////////////    string str = toc.Body.Strng(i, Decl.DOC_SUPPLIER);
        ////////////////    if (name != str) continue;
        ////////////////    string cs_name = toc.Body.Strng(i, Decl.DOC_SHEET);
        ////////////////    string doc_name = toc.Body.Strng(i, Decl.DOC_NAME);
        ////////////////    CmpSet cs = CmpSet.setCompSet(cs_name, doc_name, this);
        ////////////////    this.CompSets.Add(cs);
        ////////////////}

        public Supplier(string _name)
        {
            Docs docSupl = Docs.getDoc(Decl.SUPPLIERS);

            for (int i = docSupl.i0; i <= docSupl.il; i++)
            {
                string suplName = docSupl.Body.Strng(i, Decl.SUPL_NAME);
                if (suplName != _name)
                {
                    continue;
                }
                getSupplier(i);
                break;
            }
            if (this.name == "")
            {
                Msg.F("No Supplier(" + _name + ")");
            }
        }
예제 #26
0
 public static Model RecentModel()
 {
     string date = "1.1.52";
     int iMod = 0;
     Docs doc = Docs.getDoc(Decl.MODELS);
     for (int i = doc.i0; i <= doc.il; i++)
     {
         if (doc.Body[i, Decl.MODEL_NAME] != null)
         {
             string modDate = doc.Body.Strng(i, Decl.MODEL_DATE);
             if (Lib.getDateTime(modDate) > Lib.getDateTime(date))
             {
                 date = modDate;
                 iMod = i;
             }
         }
     }
     return new Model(iMod, doInit: false);
 }
예제 #27
0
        /// <summary>
        /// Start() - Multilanguage Message system initialize from TSmatch.xlsx/Messages
        /// </summary>
        /// <history> 7.3.2016 P.Khrapkin
        /// 12.3.16 - bootstrap error handling</history>
        public static void Start()
        {
            int iLanguage = 3;   //iLanguage =2 - ru-Ru; iLanguage = 3 - en-US

            if (getLanguage() == Decl.RUSSIAN)
            {
                iLanguage = 2;
            }

            Docs doc = Docs.getDoc(Decl.MESSAGES);

            for (int i = doc.i0; i <= doc.il; i++)
            {
                string id = doc.Body.Strng(i, 1);
                if (string.IsNullOrWhiteSpace(id))
                {
                    continue;                                   // ignore messages without ID
                }
                string txt = doc.Body.Strng(i, iLanguage);
                while (i < doc.il)
                {                                               // multiline messages
                    if (!string.IsNullOrWhiteSpace(doc.Body.Strng(i + 1, 1).ToString()))
                    {
                        break;
                    }
                    string line = doc.Body.Strng(++i, iLanguage);
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        continue;                                   //go toll empty line
                    }
                    txt += "\n" + line;
                }
                foreach (var v in Messages)                     // healthchech for unique MessageID
                {
                    if (id == v.MessageID)
                    {
                        F("ERR_02_START_FAULT", id);
                    }
                }
                Messages.Add(new Message(id, txt));
            }
        } // end Start()
예제 #28
0
        public void SavModJournal()
        {
            if (models == null || models.Count < 1)
            {
                Msg.F("ModJournal internal error");
            }
            models.Sort();
            Docs doc = Docs.getDoc(Decl.MODELS);

            doc.Reset("Now");
            doc.wrDocSetForm("FORM_Models_in_TSmatch.xlsx");
            foreach (var mod in models)
            {
                string dt     = mod.date.ToString("d.MM.yy H:mm");
                string sPhase = "'" + mod.phase;
                doc.wrDocForm(dt, mod.name, mod.dir, ifcPath,
                              mod.made, sPhase, mod.MD5, mod.strListRules);
            }
            doc.isChanged = true;
            doc.saveDoc();
        }
예제 #29
0
        //-- get cs doc from TOC by cs_name and Supplier in TSmatch.xlsx/Rule
        private Docs getCSdoc(Supl supplier, string _name)
        {
            string docName = string.Empty;
            Docs   toc     = Docs.getDoc();

            for (int i = toc.i0; i <= toc.il; i++)
            {
                string suplName = toc.Body.Strng(i, Decl.DOC_SUPPLIER);
                string csSheet  = toc.Body.Strng(i, Decl.DOC_SHEET);
                if (suplName != Supplier.Name || csSheet != name)
                {
                    continue;
                }
                docName = toc.Body.Strng(i, Decl.DOC_NAME);
                break;
            }
            if (string.IsNullOrEmpty(docName))
            {
                throw new Exception("CompSet not found price list");                                // 22.5.17            Msg.F("CompSet not found price list");
            }
            return(Docs.getDoc(docName));
        }
예제 #30
0
        public void GetModelInfo()
        {
            if (TS.isTeklaActive())
            {
                name = Path.GetFileNameWithoutExtension(TS.ModInfo.ModelName);
                dir = TS.ModInfo.ModelPath;
                elementsCount = ts.elementsCount();
                // getModInfo from Journal by name and dir
                iModJounal = getModJournal(name, dir);
                date = DateTime.Parse(modJournal(iModJounal, Decl.MODEL_DATE));
                getSavedGroups();
//12/4                getSavedRules();
            }
            else //if no Tekla active get name and dir from IFC or from INFO file if exists
            {
                if (!GetSavedReport()) Msg.F("No Tekla no saved TSmatchINFO");
            }
            // 12/4 //Docs doc = Docs.getDoc(Decl.TSMATCHINFO_MODELINFO);
            //////////doc.Close();
           var  doc = Docs.getDoc();
            doc.Close();
        }