Ejemplo n.º 1
0
        // 30/3 ////////////////public Component(string description, string mat = ""
        ////////////////////////    , double length = 0, double weight = 0, double price = 0
        ////////////////////////    , Dictionary<SType,FP> csFPs = null)
        ////////////////////////void AddPar(SType stype, dynamic obj, FP csFP = null)
        ////////////////////////{
        ////////////////////////    if(csFP != null)
        ////////////////////////    {
        //////30/3//////////////        var sec = new Section.Section((string)obj);
        ////////////////////////        List<Parameter.Parameter> ps = sec.secPars(csFP.parN());
        ////////////////////////        if(ps.Count > 0) return;
        ////////////////////////    }
        ////////////////////////    if (    obj.GetType() == typeof(string) && obj != string.Empty
        ////////////////////////        || obj.GetType() == typeof(double) && (double)obj != 0)
        ////////////////////////    {
        ////////////////////////        fps.Add(stype, new FP(stype, obj));
        ////////////////////////    }
        ////////////////////////}
#endif  // DEBUG -- вариант для тестирования
        /// <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="cs_fps">FP of CompSet</param>
        public Component(Docs doc, int i, Dictionary <SType, FP> cs_fps)
        {
            bool flag = false;

            foreach (var fpD in cs_fps)
            {
                FP     csFP   = fpD.Value;
                string str    = csFP.Int() == -1? "": doc.Body.Strng(i, csFP.Col());
                FP     compFP = new FP(str, csFP, out flag);
                if (flag)
                {
                    fps.Add(csFP.section.type, compFP);
                }
            }
            //////////////////////string[] sections = Lib.ToLat(doc.LoadDescription).ToLower().Split(';');
            //////////////////////bool flag = false;
            //////////////////////foreach (string sec in sections)
            //////////////////////{
            ///// 24/3 ///////////    if (string.IsNullOrEmpty(sec)) continue;
            //////////////////////    ////////////////////////FP csFP = cs_fps.Find(x => x.section == x.RecognyseSection(sec));
            //////////////////////    ////////////////////////if (csFP == null) Msg.F("Component constructor: no CompSet.FP with doc.LoadDescription", sec);
            //////////////////////    /////// 7/7/2017 ///////int col = csFP.Col();
            //////////////////////    ////////////////////////string str = doc.Body.Strng(i, col);
            //////////////////////    ////////////////////////FP compFP = new FP(str, csFP, out flag);
            //////////////////////    ////////////////////////if (flag) fps.Add(compFP);
            //////////////////////}
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
 ////////////////public CompSet(string _name, List<Component.Component> _comps, Supl _supl, Docs _doc, List<FP> _csFPs)
 ////////////////{
 ////////////////    this.name       = _name;
 ////////////////    this.Components = _comps;
 ////////////////    this.Supplier   = _supl;
 ////////////////    this.doc        = _doc;
 ////////////////    this.csFPs      = _csFPs;
 ////////////////}
 public CompSet(string _name, Supl _supl, Rule.Rule _rule)
 {
     name     = _name;
     Supplier = _supl;
     doc      = getCSdoc(Supplier, _name);
     csFPs    = _rule.Parser(FP.type.CompSet, doc.LoadDescription);
     for (int i = doc.i0; i < doc.il; i++)
     {
         Comp comp = new Comp(doc, i, csFPs);
         Components.Add(comp);
     }
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
 private void getSavedGroups()
 {
     docReport = Docs.getDoc(Decl.TSMATCHINFO_REPORT);
     // 9/4/17 для отладки пока берем группы прямо из Tekla
     Read();
     getGroups();
     //////////////elmGroups.Clear();
     //////////////int grCount = docReport.Body.iEOL() - docReport.i0;
     //9/4/17//////for (int i = docReport.i0; i < grCount; i++)
     //////////////{
     //////////////    elmGroups.Add()
     //////////////    string mat = docReport.Body.Strng(i, 2);
     //////////////    string prf = docReport.Body.Strng(i, 3);
     //////////////    string totalPrice = docReport.Body.Strng(i, 11);
     //////////////}
 }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
0
        public bool getSavedReport(bool doRead = false)
        {
//9/4            getModelInfo();
            Docs doc = Docs.getDoc(Decl.TSMATCHINFO_MODELINFO);

            if (isChangedStr(name, doc, 2, 2))
            {
                return(false);
            }
            date = Lib.getDateTime(doc.Body.Strng(5, 2));
            if (doRead)
            {
                Read();
                Handler();
                Report();
            }
            getSavedGroups();
            return(true);
        }
Ejemplo n.º 8
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));
         }
     }
 }
Ejemplo n.º 9
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));
        }
Ejemplo n.º 10
0
        public CompSet(string _name, Supl _supl, string LoadDescription = "", List <Comp> comps = null)
        {
            name     = _name;
            Supplier = _supl;
#if DEBUG //--------- 2017.04.02 for Unit Test
            if (!string.IsNullOrEmpty(LoadDescription))
            {
                csDP       = new DP(LoadDescription);
                Components = comps;
            }
            else
#endif //--------- DEBUG for Unit Test
            {
                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));
                }
            }
        }
Ejemplo n.º 11
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))
            {
                Msg.F("CompSet not found price list");
            }
            return(Docs.getDoc(docName));
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
        private bool isChangedStr(string str, Docs doc, int row, int col)
        {
            string strINFO = doc.Body.Strng(row, col);

            return(str == strINFO);
        }
Ejemplo n.º 14
0
        public void wrModel(string doc_name)
        {
            Log.set("Model.wrModel(" + doc_name + ")");
            DateTime t0  = DateTime.Now;
            Docs     doc = Docs.getDoc(doc_name);

            switch (doc_name)
            {
            case WR_MODEL_INFO:         // общая информация о модели: имя, директория, MD5 и др
                doc.wrDocSetForm("HDR_ModelINFO", 1, AutoFit: true);
                doc.wrDocForm(name, dir, "фаза?", date, MD5, Elm.Elements.Count);
                break;

            case WR_MODEL_RAW:          // элементы с атрибутами, как они прочитаны из модели
                doc.wrDocSetForm("FORM_RawLine", 2, AutoFit: true);
                foreach (var elm in elements)
                {
                    double w = elm.weight;     // elm.weight - weight [kg];
                    double v = elm.volume;     // / 1000 / 1000 / 1000;     // elm.volume [mm3] -> [m3]
                    doc.wrDocForm(elm.guid, elm.mat, elm.mat_type, elm.prf, elm.length, w, v);
                }
                break;

            case WR_MODEL_MATERIALS:        // сводка по материалам, их типам (бетон, сталь и др)
                doc.wrDocSetForm("FORM_Materials", 3, AutoFit: true);
                foreach (var mGr in elmMgroups)
                {
                    doc.wrDocForm(mGr.mat, mGr.totalVolume, mGr.totalWeight, mGr.totalPrice);
                }
                break;

            case WR_MODEL_SUPPLIERS:        // сводка по поставщикам проекта (контакты, URL прайс-листа, закупки)
                doc.wrDocSetForm("FORM_ModSupplierLine", 4, AutoFit: true);
                foreach (var s in Suppliers)
                {
                    doc.wrDocForm(s.name, s.Url, s.City, s.index, s.street, s.telephone);
                }
                break;

            case WR_MODEL_RULES:            // перечень Правил, используемых для обработки модели
                doc.wrDocSetForm("HDR_ModRules", 1, AutoFit: true);
                doc.wrDocForm(strListRules);
                doc.wrDocSetForm("FORM_ModRuleLine");
                foreach (var rule in Rules)
                {
                    doc.wrDocForm(rule.Supplier.name, rule.CompSet.name, rule.text);
                }
                break;

            case WR_MODEL_REPORT:           // отчет по сопоставлению групп <материал, профиль> c прайс-листами поставщиков
                doc.wrDocSetForm("FORM_Report", AutoFit: true);
                int n = 1;
                foreach (var gr in elmGroups)
                {
                    string foundDescr = "";
                    if (gr.match != null && gr.match.ok == Mtch.OK.Match)
                    {
                        foundDescr = gr.match.component.Str(SType.Description);
                    }
                    doc.wrDocForm(n++, gr.mat, gr.prf
                                  , gr.totalLength, gr.totalWeight, gr.totalVolume
                                  , foundDescr, 0, 0, 0, gr.totalPrice);
                }
                //--- string - Summary
                double sumWgh = 0, sumPrice = 0;
                int    iGr = doc.i0;
                foreach (var gr in elmGroups)
                {
                    double?w = doc.Body.Double(iGr, Decl.REPORT_SUPL_WGT);
                    double?p = doc.Body.Double(iGr++, Decl.REPORT_SUPL_PRICE);
                    sumWgh   += (w == null) ? 0 : (double)w;
                    sumPrice += (p == null) ? 0 : (double)p;
                }
                doc.wrDocSetForm("FORM_Report_Sum", AutoFit: true);
                doc.wrDocForm(sumWgh, sumPrice);
                break;
            }
            doc.isChanged = true;
            doc.saveDoc();
            log.Info("Время записи в файл \"" + doc_name + "\"\t t= " + (DateTime.Now - t0).ToString() + " сек");
            Log.exit();
        }
Ejemplo n.º 15
0
 public Model(int i, bool doInit = true) : this(Docs.getDoc(Decl.MODELS), i, doInit)
 {
 }