Beispiel #1
0
        public static Docs UpgradeFrExcel(Docs doc, string strToDo)
        {
            Log.set("UpgradeFrExcel(" + doc.name + ", " + strToDo + ")");
            if (strToDo != "DelEqPar1")
            {
                Log.FATAL("не написано!");
            }
//!!            List<string> Comp = getComp(doc);
            //////int i = doc.i0;
            //////foreach (string s in Comp)
            //////{
            //////    string str = Lib.ToLat(s);
            //////    List<int> pars = Mtch.GetPars(s);
            //////    if (pars[0] == pars[1])
            //////    {
            //////        string toDel = pars[0].ToString() + " x ";
            //////        str = str.Replace(toDel + toDel, toDel);
            //////    }
            //////    doc.Body[i++, 1] = str;
            //////}
            //////doc.isChanged = true;
            //////Docs.saveDoc(doc);

            //for (int i = doc.i0, iComp = 0; i <= doc.il; i++)
            //{
            //    // doc.Body.Strng(i, 1) = Copm;
            //}
            Log.exit();
            return(doc);
        }
Beispiel #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++;
     }
 }
Beispiel #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;
     }
 }
Beispiel #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();
 }
Beispiel #5
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();
        }
Beispiel #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;
        }
Beispiel #7
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 #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
 /// <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 #10
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();
        }
Beispiel #11
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;
        }
Beispiel #12
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 #13
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();
            }
        }
Beispiel #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];
 }
Beispiel #15
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;
 }
Beispiel #16
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;
 }
Beispiel #17
0
 /// <summary>
 /// constructor Component(doc, i, List<FP>cs_fps, List<FP>rule_fps) - get Component from price-list in doc line i
 /// </summary>
 /// <param name="doc">document - price-list</param>
 /// <param name="i">line number in doc</param>
 /// <param name="csDP">DP - parsed LoadDescroption from CompSet</param>
 public Component(Docs doc, int i, DP csDP)
 {
     compDP = new DP("");
     foreach (SType sec in csDP.dpar.Keys)
     {
         var II  = csDP.Col(SType.UNIT_Weight);
         int col = csDP.Col(sec);
         if (col > 0 && col <= doc.Body.iEOC())
         {
             compDP.Ad(sec, doc.Body.Strng(i, col));
         }
     }
 }
Beispiel #18
0
        public double RuleRedundencyPerCent = 0.0;  //коэффициент избыточности, требуемый запас по данному материалу/профилю/Правилу

        public Rule(Docs doc, int i)
        {
            name     = (string)doc.Body[i, Decl.RULE_NAME];
            type     = (string)doc.Body[i, Decl.RULE_TYPE];
            text     = Lib.ToLat((string)doc.Body[i, Decl.RULE_RULE]);
            synonyms = RuleSynParse(text);
            ruleDP   = new DP(text); // template for identification
            string csName   = (string)doc.Body[i, Decl.RULE_COMPSETNAME];
            string suplName = (string)doc.Body[i, Decl.RULE_SUPPLIERNAME];

            Supplier = new Suppliers.Supplier(suplName);
            CompSet  = new CmpSet(csName, Supplier);
        }
Beispiel #19
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 + ")");
 }
Beispiel #20
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;
        }
Beispiel #21
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;
 }
Beispiel #22
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);
        }
Beispiel #23
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);
 }
Beispiel #24
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);
        }
Beispiel #25
0
 public Model(Docs doc, int i, bool doInit = true)
 {
     this.date = Lib.getDateTime(doc.Body[i, Decl.MODEL_DATE]);
     this.name = doc.Body.Strng(i, Decl.MODEL_NAME);
     this.dir = doc.Body.Strng(i, Decl.MODEL_DIR);
     this.ifcPath = doc.Body.Strng(i, Decl.MODEL_IFCPATH);
     this.Made = doc.Body.Strng(i, Decl.MODEL_MADE);
     this.Phase = doc.Body.Strng(i, Decl.MODEL_PHASE);
     this.MD5 = doc.Body.Strng(i, Decl.MODEL_MD5);
     // преобразуем список Правил из вида "5,6,8" в List<Rule>
     strListRules = doc.Body.Strng(i, Decl.MODEL_R_LIST);
     if (doInit)
     {
         foreach (int n in Lib.GetPars(strListRules))
             Rules.Add(new Rule.Rule(n));
     }
 }
Beispiel #26
0
 public Rule(Docs doc, int i)
 {
     date     = Lib.getDateTime(doc.Body.Strng(i, Decl.RULE_DATE));
     Text     = doc.Body.Strng(i, Decl.RULE_RULETEXT);
     text     = Lib.ToLat(Text.ToLower());
     synonyms = RuleSynParse(text);
     ruleDP   = new DP(text);
     sSupl    = doc.Body.Strng(i, Decl.RULE_SUPPLIERNAME);
     sCS      = doc.Body.Strng(i, Decl.RULE_COMPSETNAME);
     if (date > DateTime.Now || date < Decl.OLD ||
         string.IsNullOrWhiteSpace(Text) ||
         string.IsNullOrWhiteSpace(sSupl) ||
         string.IsNullOrWhiteSpace(sCS))
     {
         throw new InvalidCastException("Rule line " + i);
     }
 }
Beispiel #27
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();
        }
Beispiel #28
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();
 }
Beispiel #29
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();
        }
Beispiel #30
0
 public CompSet(string _name, Supl _supl, string LoadDescription = "", List <Comp> comps = null)
 {
     name     = _name;
     Supplier = _supl;
     if (!string.IsNullOrEmpty(LoadDescription))
     {
         csDP       = new DP(LoadDescription);
         Components = comps;
     }
     else
     {
         doc  = getCSdoc(Supplier, _name);
         csDP = new DP(doc.LoadDescription);
         for (int i = doc.i0; i < doc.il; i++)
         {
             Components.Add(new Comp(doc, i, csDP));
         }
     }
 }