コード例 #1
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++;
     }
 }
コード例 #2
0
        private double getPrice(Elm elm, DPar.DPar csDP, string priceStr)
        {
            double price = Lib.ToDouble(priceStr);

            foreach (var sec in csDP.dpar)
            {
                if (!sec.Key.ToString().Contains("UNIT_"))
                {
                    continue;
                }
                switch (sec.Key)
                {
                case SType.UNIT_Weight:     // kg -> tonn
                    return(elm.weight / 1000 * price);

                case SType.UNIT_Vol:        // mm3 -> m3
                    return(elm.volume / 1000 / 1000 / 1000 * price);

                case SType.UNIT_Length:
                    return(elm.length * price);

                case SType.UNIT_Qty:
                    return(price);
                }
            }
            return(0);
        }
コード例 #3
0
ファイル: ElmAttSet.cs プロジェクト: PavelKhrapkin/TSmatch
 public Mgroup(List<ElmAttSet> elements, string material, List<string> guids)
 {
     this.mat = material;
     this.guids = guids;
     totalWeight = totalVolume = totalPrice = 0.0;
     foreach (string id in guids)
     {
         ElmAttSet elm = elements.Find(x => x.guid == id);
         if (elm == null) Msg.F("ElmAttSet: Mgroup(wrong guid)", id);
         totalWeight += elm.weight;
         totalVolume += elm.volume;
         totalPrice += elm.price;
     }
 }
コード例 #4
0
ファイル: IFC.cs プロジェクト: PavelKhrapkin/TSmatch
        private static List <ElmAttributes.ElmAttSet> MergeIfcToElmAttSet(List <IfcManager.Core.IfcManager.IfcElement> elements)
        {
            foreach (var ifc_elm in elements)
            {
                string guid = ifc_elm.guid;
                if (!ElmAttSet.ElmAttSet.Elements.ContainsKey(guid))
                {
                    ElmAttSet.ElmAttSet new_elm = new ElmAttSet.ElmAttSet(ifc_elm);
//                    new_elm = new ElmAttSet.ElmAttSet(ifcElemOrg);
                }
                else
                {
                    ElmAttributes.ElmAttSet elm = null;
                    ElmAttSet.ElmAttSet.Elements.TryGetValue(guid, out elm);
                    if (!String.IsNullOrEmpty(ifc_elm.material))
                    {
                        elm.mat = ifc_elm.material;
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.type_material))
                    {
                        elm.mat_type = ifc_elm.type_material;
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.profile))
                    {
                        elm.prf = ifc_elm.profile;
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.length))
                    {
                        elm.length = Lib.ToDouble(ifc_elm.length);
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.weight))
                    {
                        elm.weight = Lib.ToDouble(ifc_elm.weight);
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.volume))
                    {
                        elm.volume = Lib.ToDouble(ifc_elm.volume);
                    }
                    if (!String.IsNullOrEmpty(ifc_elm.price))
                    {
                        elm.price = Lib.ToDouble(ifc_elm.price);
                    }
                }
            }
            return(ElmAttSet.ElmAttSet.Elements.Values.ToList());
        }
コード例 #5
0
        public Rule.Rule rule;                  //the rule, which manage the matching

        /// <summary>
        /// Mtch(gr, _rule) - check if Group gr is in match with rule
        ///    if Mtch.ok.Match - return Mtch.Component chousen from CompSet.Component
        ///    else ok.NoMatch
        /// </summary>
        /// <param name="gr"></param>
        /// <param name="_rule"></param>
        public Mtch(ElmAttSet.Group gr, Rule.Rule _rule)
        {
            if (gr.prf.Contains("ш2") /* && _rule.text.Contains("д") */)
            {
                rule = _rule;
            }


            if (gr == null || gr.guids.Count < 1)
            {
                return;
            }
            ok    = OK.NoMatch;
            group = gr;
            foreach (var comp in _rule.CompSet.Components)
            {
                if (!comp.isMatch(gr, _rule))
                {
                    continue;
                }
                //-- Component is found - fill Price for all Guids elemets
                ok            = OK.Match;
                component     = comp;
                gr.match      = this; //27/3!!
                rule          = _rule;
                gr.totalPrice = 0;
                foreach (var id in gr.guids)
                {
                    Elm    elm      = gr.Elements[id];
                    string priceStr = comp.Str(SType.Price);
                    double price    = getPrice(elm, rule.CompSet.csDP, priceStr);
                    gr.Elements[id].price = price;
                    gr.totalPrice        += price;
                }
                break;
            }
        }