Ejemplo n.º 1
0
        public Component(Dictionary <SType, string> comp
                         , Dictionary <SType, FP> cs_fps)
        {
            bool flag = false;

            foreach (var fpD in cs_fps)
            {
                FP     csFP   = fpD.Value;
                FP     compFP = new FP();
                string str    = comp[fpD.Key];
                Sec    s      = new Sec(str);
                string ld     = csFP.parN();
                if (ld.Contains('*'))       // * template
                {
                    compFP.pars = s.secPars(ld);
//30/3                    s.txs =
                    break;
                }
                if (ld.Contains('{'))       // {2} Col() Parameter
                {
                    compFP.pars.Add(new Parameter.Parameter(ld));
                    break;
                }
                fps.Add(fpD.Key, compFP);
            }
        }
Ejemplo n.º 2
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.º 3
0
        public void UT_FP_Component_constr2()
        {
            var Im = new IMIT();
            var rule = Im.IM_Rule("M:*;Проф:Уголок равнопол.=Уголок *x*c*");
            var sec = new Sec("M:");

            var fpMat = new FP("Уголок 75х6 6м Ст3пс/сп5", rule, sec);

            //////////////////var csFPmat = new FP(FPtype.CompSet, "M:{2}");
            // 27/3 //////////var csFPprf = new FP(FPtype.CompSet, "Prf:Уголок {1}");
            //////////////////var csFPs = new List<FP> { csFPmat, csFPprf };
            
            // 23.3.2017 пока решил не позволять использовать несколько параметров в строке
            //xr1 = new FP(FPtype.CompSet, "Цена: {4} НДС {12}{14}%");
            //Assert.AreEqual(xr1.pars.Count, 3);
            //Assert.AreEqual(xr1.txs[3], "%");
            //Assert.AreEqual(xr1.Col(2), 14);
            //Assert.AreEqual(xr1.txs.Count, 4);
            //Assert.AreEqual(xr1.typeFP.ToString(), "CompSet");
            //Assert.AreEqual(xr1.section.type.ToString(), "Price");
            //Assert.AreEqual(xr1.Col(), 4);
            //var sec = new Sec("Prf: L12x5");
            //19/3            FP fp = new FP(sec);
            Assert.Fail();
        }
Ejemplo n.º 4
0
        public void UT_FP_constr1_Test()
        {
            // * тест: Уголок constructor1 FP(type.Rule, Проф: L * x *)
            FP xr2 = new FP(FPtype.Rule, "Проф: L * x *");
            Assert.AreEqual(xr2.section.type.ToString(), "Profile");
            Assert.AreEqual(xr2.pars.Count, 1);
            Assert.AreEqual(xr2.pars[0].ToString(), "l*x*");
            Assert.AreEqual(xr2.txs.Count, 0);

            // * Уголок с материалом constructor1 FP(type.Rule, Проф: L * x * cт *)");
            xr2 = new FP(FPtype.Rule, "Проф: L * x * cт *");
            Assert.AreEqual(xr2.section.type.ToString(), "Profile");
            Assert.AreEqual(xr2.pars.Count, 1);
            Assert.AreEqual(xr2.pars[0].ToString(), "l*x*cт*");
            Assert.AreEqual(xr2.txs.Count, 0);

            // * тест: Бетон -монолит constructor1 FP(type.Rule, М:В*)");
            FP rule = new FP(FPtype.Rule, "M:B*;");
            Assert.AreEqual(rule.pars.Count, 1);
            Assert.AreEqual(rule.typeFP.ToString(), "Rule");
            Assert.AreEqual(rule.section.type.ToString(), "Material");
            Assert.AreEqual(rule.pars[0], "b*");
            Assert.AreEqual(rule.txs.Count, 0);

            xr2 = new FP(FPtype.Rule, "Профиль:");
            Assert.AreEqual(xr2.section.type.ToString(), "Profile");

            FP xr1 = new FP(FPtype.CompSet, "Описание: {3}");
            Assert.AreEqual(xr1.pars.Count, 1);
            Assert.AreEqual(xr1.typeFP.ToString(), "CompSet");
            Assert.AreEqual(xr1.section.type.ToString(), "Description");
            Assert.AreEqual(xr1.Col(), 3);

            //-- CompSet tests
            xr1 = new FP(FPtype.CompSet, "Цена: {4} если нет другого материала в описании");
            Assert.AreEqual(xr1.pars.Count, 1);
            Assert.AreEqual(xr1.typeFP.ToString(), "CompSet");
            Assert.AreEqual(xr1.section.type.ToString(), "Price");
            Assert.AreEqual(xr1.Col(), 4);
            Assert.AreEqual(xr1.txs.Count, 2);
            Assert.AreEqual(xr1.txs[0], "");
//13/3            Assert.AreEqual(xr1.txs[1].Length > 10, true); - не распознается остаток строки справа!!

            xr1 = new FP(FPtype.CompSet, "Цена: {4} НДС {12}{14}%");
            Assert.AreEqual(xr1.pars.Count, 3);
            //13/3            Assert.AreEqual(xr1.txs[3], "%");      -- то же
            Assert.AreEqual(xr1.Col(2), 14);
            Assert.AreEqual(xr1.txs.Count, 4);
            Assert.AreEqual(xr1.typeFP.ToString(), "CompSet");
            Assert.AreEqual(xr1.section.type.ToString(), "Price");
            Assert.AreEqual(xr1.Col(), 4);
        }
Ejemplo n.º 5
0
        private static void testFP_Equals(FingerPrint fp)
        {
            Log.set("testFP_Equals");
            FingerPrint A = new FingerPrint(type.Rule, "M:ABCD");
            FingerPrint B = null;
            TST.Eq(A.Equals(B), false);

            FingerPrint C = new TSmatch.FingerPrint.FingerPrint(type.Rule, "M:C");
            TST.Eq(A.Equals(C), false);
            TST.Eq(C.Equals(A), false);
            TST.Eq(C.Equals(B), false);

            Log.exit();
        }
Ejemplo n.º 6
0
        public void UT_FP_constr1_Test()
        {
            // * тест: Уголок constructor1 FP(type.Rule, Проф: L * x *)
            FP xr2 = new FP(FPtype.Rule, "Проф: L * x *");
            Assert.AreEqual(xr2.section.type.ToString(), "Profile");
            Assert.AreEqual(xr2.pars.Count, 1);
            Assert.AreEqual(xr2.pars[0].par.ToString(), "l*x*");
            Assert.AreEqual(xr2.txs.Count, 0);

            // * Уголок с материалом constructor1 FP(type.Rule, Проф: L * x * cт *)");
            xr2 = new FP(FPtype.Rule, "Проф: L * x * cт *");
            Assert.AreEqual(xr2.section.type.ToString(), "Profile");
            Assert.AreEqual(xr2.pars.Count, 1);
            Assert.AreEqual(xr2.pars[0].par.ToString(), "l*x*cт*");
            Assert.AreEqual(xr2.txs.Count, 0);

            // * тест: Бетон -монолит constructor1 FP(type.Rule, М:В*)");
            FP rule = new FP(FPtype.Rule, "M:B*;");
            Assert.AreEqual(rule.pars.Count, 1);
            Assert.AreEqual(rule.typeFP.ToString(), "Rule");
            Assert.AreEqual(rule.section.type.ToString(), "Material");
            Assert.AreEqual(rule.pars[0].par.ToString(), "b*");
            Assert.AreEqual(rule.txs.Count, 0);

            xr2 = new FP(FPtype.Rule, "Профиль:");
            Assert.AreEqual(xr2.section.type.ToString(), "Profile");
            Assert.AreEqual(xr2.pars[0].par.ToString(), string.Empty);

            //-- CompSet tests
            FP xr1 = new FP(FPtype.CompSet, "Описание: {3}");
            Assert.AreEqual(xr1.pars.Count, 1);
            Assert.AreEqual(xr1.typeFP.ToString(), "CompSet");
            Assert.AreEqual(xr1.section.type.ToString(), "Description");
            Assert.AreEqual(xr1.Col(), 3);

            xr1 = new FP(FPtype.CompSet, "Цена: {4} если нет другого материала в описании");
            Assert.AreEqual(xr1.pars.Count, 1);
            Assert.AreEqual(xr1.typeFP.ToString(), "CompSet");
            Assert.AreEqual(xr1.section.type.ToString(), "Price");
            Assert.AreEqual(xr1.Col(), 4);
            Assert.AreEqual(xr1.txs.Count, 0);  // решил tx справа от параметра игнорировать
        }