Example #1
0
        bool isMatchGrRule(SType stype, ElmAttSet.Group gr, Rule.Rule rule)
        {
            if (rule == null || !compDP.dpar.ContainsKey(stype))
            {
                return(true);
            }
            var    ruleSyns  = rule.synonyms;
            string comMatPrf = viewComp_(stype);
            string grMatPrf  = stype == SType.Material ? gr.mat : gr.prf;

            if (grMatPrf.Contains("ш2") && comMatPrf.Contains("ш2"))
            {
                log.Info("--");                                                       //5/4
            }
            if (ruleSyns != null && ruleSyns.ContainsKey(stype))
            {
                List <string> Syns = ruleSyns[stype].ToList();
                if (!Lib.IContains(Syns, comMatPrf) || !Lib.IContains(Syns, grMatPrf))
                {
                    return(false);
                }
                string c = strExclude(comMatPrf, Syns);
                string g = strExclude(grMatPrf, Syns);
                if (c == g)
                {
                    return(true);
                }
                return(c.Contains(g));
                ////////////////var p1 = Params(Syns, comMatPrf, );
                //// 27/3 //////var p2 = Params(Syns, grMatPrf);
                ////////////////bool b = p1 != p2  && stype == SType.Material;
                //31/3//////////return Params(Syns, comMatPrf) == Params(Syns, grMatPrf);
            }
            return(comMatPrf == grMatPrf);
        }
Example #2
0
        bool isMatchGrRule(SType stype, ElmAttSet.Group gr, Rule.Rule rule)
        {
            if (rule == null || !fps.ContainsKey(stype))
            {
                return(true);
            }
            var    ruleSyns  = rule.synonyms;
            string comMatPrf = fps[stype].pars[0].par.ToString();
            string grMatPrf  = stype == SType.Material ? gr.mat : gr.prf;

            if (grMatPrf == comMatPrf)
            {
                return(true);
            }
            if (ruleSyns != null && ruleSyns.ContainsKey(stype))
            {
                List <string> Syns = ruleSyns[stype].ToList();
                if (!Lib.IContains(Syns, comMatPrf) || !Lib.IContains(Syns, grMatPrf))
                {
                    return(false);
                }

                string c = strExclude(comMatPrf, Syns);
                string g = strExclude(grMatPrf, Syns);
//27/3                if(c == g) return true;
                return(c.Contains(g));

                ////////////////var p1 = Params(Syns, comMatPrf, );
                //// 27/3 //////var p2 = Params(Syns, grMatPrf);
                ////////////////bool b = p1 != p2  && stype == SType.Material;

                return(Params(Syns, comMatPrf) == Params(Syns, grMatPrf));
            }
            return(false);
        }
Example #3
0
        public string viewComp_(SType stype)
        {
            string str = "";

            try { str = compDP.dpar[stype]; }
            catch { str = "##NOT_AVAILABLE##"; }
            return(str);
        }
Example #4
0
        // for internal use, f.e. for comparision
        public string viewComp_(SType stype)
        {
            string str = "";

            try { str = compDP.dpar[stype]; }
            catch { str = "##NOT_AVAILABLE##"; }
            return(Lib.ToLat(str.ToLower()));
        }
Example #5
0
 //--- FP constructor 1 for Rule and CompSet
 public FingerPrint(type _type, string str)
 {
     typeFP = _type;    
     section = new Sec(str);
     refSection = section.refSection;
     Par p = new Par(str);
     pars.Add(p);
     txs.Add(p.tx);
 }
Example #6
0
            void sub(SType t, params string[] str)
            {
                List <string> lst = new List <string>();

                foreach (string s in str)
                {
                    lst.Add(Lib.ToLat(s).ToLower().Replace(" ", ""));
                }
                SectionTab.Add(t.ToString(), lst);
            }
Example #7
0
        // if field of stype not recognized, return -1
        //.. f.e. it happaned with constant like "M:C245"
        public int Col(SType stype)
        {
            if (stype.ToString().Contains("UNIT_"))
            {
                return(-1);
            }
            string str = string.Empty;

            try { str = dpar[stype]; }
            catch { }
            return(Lib.ToInt(str));
        }
Example #8
0
 /// <summary>
 /// Str(SType stype) - return Sec stype of Component for Viewer
 /// </summary>
 /// <param name="stype">SType Section of Component representation</param>
 /// <returns>representation of Component as a string</returns>
 public string Str(SType stype)
 {
     if (!compDP.dpStr.ContainsKey(stype))
     {
         if (stype == SType.Price)
         {
             throw new KeyNotFoundException();
         }
         Msg.W("CompSet wrong LoadDescriptor", stype);
         return(string.Empty);
     }
     return(compDP.dpStr[stype]);
 }
Example #9
0
        //--- FP constructor 2 for Component
#if DEBUG   //--- 29-Mar-2017 Вариант конструктора для UT
        public FingerPrint(SType stype, dynamic obj)
        {
            typeFP = type.Component;
            if (stype == SType.Description)
            {
                Par p = new Par(obj);
                p.par = p.tx = obj;
                pars.Add(p);
                return;
            }
            section = new Sec(stype.ToString() + ":");
            string str = "";
            if (obj.GetType() == typeof(string)) str = (string)obj;
            if (obj.GetType() == typeof(double)) str = ((double)obj).ToString();
            pars.Add(new Par(str));
        }
Example #10
0
        public string viewComp(SType stype)
        {
            string str = "";
            FP     fp;

            try { fp = fps[stype]; }
            catch { return(string.Empty); }
            int i = 0;

            foreach (Parameter.Parameter p in fp.pars)
            {
                if (i++ > 1)
                {
                    str += "x";
                }
                str += p.par.ToString();
            }
            return(str);
        }
Example #11
0
        bool isMatchGrRule(SType stype, Group.Group gr, Rule.Rule rule)
        {
            if (rule == null || !compDP.dpar.ContainsKey(stype))
            {
                return(true);
            }
            string sb = new Sec(rule.text, stype).body;

            if (sb == "")
            {
                return(true);
            }
            var    ruleSyns  = rule.synonyms;
            string comMatPrf = viewComp_(stype);
            string grMatPrf  = stype == SType.Material ? gr.mat : gr.prf;

            if (ruleSyns != null && ruleSyns.ContainsKey(stype))
            {
                List <string> Syns = ruleSyns[stype].ToList();
                if (!Lib.IContains(Syns, comMatPrf) || !Lib.IContains(Syns, grMatPrf))
                {
                    return(false);
                }
                string c = strExclude(comMatPrf, Syns);
                string g = strExclude(grMatPrf, Syns);
                if (c == g)
                {
                    return(true);
                }
                string pattern = new Sec(rule.text, stype).body.Replace("=", "");
                foreach (var s in Syns)
                {
                    pattern = strExclude(pattern, Syns);
                }
                return(isOK(pattern, c, g));
            }
            return(comMatPrf == grMatPrf);
        }
Example #12
0
        ////////////////public FingerPrint(Sec.SType stype, string str, ParType parType = ParType.String)
        ////////////////{
        // 21/3 ////////    Param par = new Param(str, parType);
        ////////////////    pars.Add(par);
        ////////////////}

        public FingerPrint(string str, Rule.Rule rule, Sec sec)
        {
            FingerPrint ruleFP = rule.ruleFPs[sec.type];
            //        FingerPrint csFP = rule.CompSet.csFPs.Find(x => x.section.type == sec.type);
            SType stype = sec.type;
            var vv = rule.CompSet.csFPs;

//20/3 ЗАГЛУШКА!!            FingerPrint csFP = rule.CompSet.csFPs[stype];
            section = sec;
            string ruleText = sec.body;
            List<string> sPars = ReverseFomat(str, ruleText);
            int i = 0;
            foreach(var p in sPars)
            {
                //20/3 ЗАГЛУШКА!!                 Parameter.Parameter csPar = (Parameter.Parameter)csFP.pars[i++];
                //20/3 ЗАГЛУШКА!!                 Parameter.Parameter par = new Parameter.Parameter(str, csPar.ptype);
                //20/3 ЗАГЛУШКА!! pars.Add(par);
            }

            // str = Section.body в строке прайс-листа
            // template - Section.body в Rule.text
            // заполняет pars в FP для Component
            //12/3            foreach (var par in ReverseFormat(str, ruleText)) pars.Add(par);
        }
Example #13
0
 public void Ad(SType stype, string str)
 {
     dpStr.Add(stype, str);
     str = Lib.ToLat(str).ToLower().Replace(" ", "");
     dpar.Add(stype, str);
 }
Example #14
0
 public string Str(SType stype)
 {
     return(compDP.dpStr[stype]);
 }