Esempio n. 1
0
        public void RandomModel(opis o)
        {
            o.bodyObject = this;
            a_v_lp_rp_fil_iv_vcon_acon = 0;

            if (o.listCou > 0 || o.PartitionKind == "fc" || o.PartitionKind == "fr" || o.PartitionKind == "fill")
            {
                a_v_lp_rp_fil_iv_vcon_acon = 1;

                if (!o.isHere("v", false))
                {
                    o.Vset("v", o.body);
                }
                if (!o.isHere("a", false))
                {
                    o.Vset("a", o.PartitionName);
                }
            }

            if (o.isHere("lp", false))
            {
                a_v_lp_rp_fil_iv_vcon_acon = a_v_lp_rp_fil_iv_vcon_acon | (1 << 1);
            }

            if (o.isHere("rp", false))
            {
                a_v_lp_rp_fil_iv_vcon_acon = a_v_lp_rp_fil_iv_vcon_acon | (1 << 2);
            }
        }
Esempio n. 2
0
        public override void Process(opis message)
        {
            opis spec = modelSpec.Duplicate();

            instanse.ExecActionModelsList(spec);

            if (spec.isHere(to_lower))
            {
                message.body = message.body.ToLower().Trim();
            }

            if (spec.isHere(first_higher))
            {
                message.body = upper(message.body, (x, prev) => char.IsWhiteSpace(x));
            }

            if (spec.isHere(sentence))
            {
                message.body = upper(message.body, (x, prev) => (x == '.' || (char.IsWhiteSpace(x) && prev)));
            }

            //if (spec.isHere(sentence))
            //{
            //    message.body = upper(message.body, (x, prev) => (x == '.' || (char.IsWhiteSpace(x) && prev)));
            //}
        }
Esempio n. 3
0
        public override void Process(opis message)
        {
            opis spec = modelSpec.Duplicate();

            instanse.ExecActionModelsList(spec);
            instanse.ExecActionModelsList(spec[arguments]);

            if (spec.isHere(source))
            {
                eng = new Jint.Engine().Execute(spec.V(source));
            }
            ;

            if (eng != null && spec.isHere(function))
            {
                var pr = new object[spec[arguments].listCou];

                //  spec[arguments].ListValues().ToArray();

                try
                {
                    var res = eng.Invoke(spec.V(function), spec[arguments].ListValues().ToArray());

                    message.body = res.ToString();
                }
                catch (Exception e)
                {
                    message.body = e.Message;
                }
            }

            message.CopyArr(new opis());
        }
Esempio n. 4
0
        public override void Process(opis message)
        {
            opis spec = modelSpec.Duplicate();

            instanse.ExecActionModelsList(spec);

            string csource = spec.V(source);


            var arr = string.IsNullOrEmpty(spec.V(separator)) ? csource.Split() : csource.Split(spec.V(separator)[0]);

            if (spec.isHere(array_source))
            {
                var srs = spec[array_source];
                arr = new string[srs.listCou];
                for (int i = 0; i < srs.listCou; i++)
                {
                    arr[i] = srs[i].body;
                }
            }

            opis word_arr = new opis(arr.Length + 1);

            bool nonempt = spec.isHere(non_empty_only, false);

            for (int i = 0; i < arr.Length; i++)
            {
                if (!nonempt || (nonempt && !string.IsNullOrEmpty(arr[i].Trim())))
                {
                    word_arr.Vset(i.ToString(), arr[i].Trim());
                }
            }

            var rez = "";

            string join_sep = spec[glue_with].isInitlze ? spec.V(glue_with).Replace('_', ' ') : " ";

            if (spec.isHere(last_N))
            {
                int n = 0;
                int.TryParse(spec.V(last_N), out n);
                rez = String.Join(join_sep, arr.Skip(arr.Length > n ? arr.Length - n : 0).ToList());
            }

            if (spec.isHere(first_N))
            {
                int n = 0;
                int.TryParse(spec.V(first_N), out n);
                rez = String.Join(join_sep, arr.Take(arr.Length < n ? arr.Length  : n).ToList());
            }



            message.body          = rez.Trim();
            message.PartitionKind = "";
            message.CopyArr(word_arr);
        }
Esempio n. 5
0
        public override void Process(opis message)
        {
            opis mspec = modelSpec.Duplicate();

            instanse.ExecActionModelsList(mspec);

            exept = mspec[Exceptions];

            Do(message, mspec.isHere(clear_type), mspec.isHere(clear_body));
        }
Esempio n. 6
0
        public override void Process(opis message)
        {
            opis spec = modelSpec.Duplicate();

            instanse.ExecActionModelsList(spec);

            if (spec.isHere(InnerHtmlLengthLimit))
            {
                int.TryParse(spec.V(InnerHtmlLengthLimit), out maxHtmlShow);
            }

            if (spec.isHere(ignore_names_attr))
            {
                namesAtrIgnore = new List <string>();
                for (int i = 0; i < spec[ignore_names_attr].listCou; i++)
                {
                    namesAtrIgnore.Add(spec[ignore_names_attr][i].PartitionName);
                }
            }

            var htmltext = spec.V(HtmlText);

            if (spec.isHere(fix_html))
            {
                fixes = spec[fix_html];
                return;
            }

            if (fixes != null)
            {
                for (int i = 0; i < fixes.listCou; i++)
                {
                    htmltext = htmltext.Replace(fixes[i]["bad"].body, fixes[i]["good"].body);
                }
            }


            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(htmltext);

            var rez = new opis();

            var docRoot = rez["DocumentNode"];

            Trace(doc.DocumentNode, docRoot);

            message.CopyArr(docRoot);
        }
Esempio n. 7
0
        public override void Process(opis message)
        {
            opis surc = message;
            opis ex   = modelSpec.Duplicate();

            instanse.ExecActionModelsList(ex);

            if (ex.isHere(source))
            {
                surc = ex[source];
            }

            opis ptt = modelSpec[partition].Duplicate();

            instanse.ExecActionModelsList(ptt);

            string pn = ex.V(partName);
            string vl = ex.V(value);

            for (int i = 0; i < surc.listCou; i++)
            {
                opis processThis = opis.GetLevelByTemplate(ptt[0], surc[i], true);
                if (processThis != null)
                {
                    processThis.Vset(pn, vl);
                }
            }
        }
Esempio n. 8
0
        public static readonly string flag = "break further code exec";  //TODO: optimize by index

        public override void Process(opis message)
        {
            opis surc = message;

            if (modelSpec.isHere(condition))
            {
                bool prop = modelSpec[setLdcExitOnCondition].isInitlze;

                surc = modelSpec[condition].Duplicate();
                instanse.ExecActionModel(surc, surc);
                if (surc.body == "exit" || surc.isHere("exit"))
                {
                    SetFlag(modelSpec);

                    if (prop)
                    {
                        instanse.GetLocalDataContextVal("exit", true);
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(instanse.GetLocalDataContextVal("exit").PartitionName))
                {
                    SetFlag(modelSpec);
                }
            }
        }
Esempio n. 9
0
        public override void Process(opis message)
        {
            opis surc = message;
            opis svc  = sharedVal;

            opis iter = SharedContextRoles.GetRole(modelSpec[Iterator].body, svc);

            if (iter.PartitionKind == "null" || !iter.isInitlze ||
                (modelSpec.isHere(reinit_iterator) &&
                 iter[source].listCou == iter["pos"].intVal &&
                 iter["pos"].intVal > 0))
            {
                opis ex = modelSpec.Duplicate();
                instanse.ExecActionModelsList(ex);

                if (ex.isHere(source))
                {
                    surc = ex[source];
                }

                iter             = new opis("iterator");
                iter[source]     = surc;
                iter["pos"].body = "0";

                SharedContextRoles.SetRole(iter, modelSpec[Iterator].body, svc);
            }

            if (modelSpec.isHere(loop) && iter[source].listCou == iter["pos"].intVal)
            {
                iter["pos"].body = "0";
            }


            opis itm = null;

            if (iter[source].listCou > iter["pos"].intVal)
            {
                itm = iter[source][iter["pos"].intVal];
                iter["pos"].intVal++;
                SharedContextRoles.SetRole(itm, modelSpec.V(role), svc);
            }
            else
            {
                SharedContextRoles.SetRole(new opis(), modelSpec.V(role), svc);
            }


            if (itm != null)
            {
                instanse.ExecActionResponceModelsList(modelSpec[responce][ConditionResponceModel.yess], itm);
            }
            else
            {
                instanse.ExecActionResponceModelsList(modelSpec[responce][ConditionResponceModel.no], new opis());
            }
        }
Esempio n. 10
0
        public override void Process(opis message)
        {
            opis ms = SpecLocalRunAll();

            var srs = ms[source];

            message.CopyArr(new opis());

            if (ms.isHere(car, false))
            {
                message.Wrap(srs.listCou > 0 ? srs[0] : new opis());
            }

            if (ms.isHere(cdr, false))
            {
                message.CopyArr(srs);
                message.RemoveArrElem(0);
            }
        }
Esempio n. 11
0
        //[info("")]
        //[model("")]
        //public static readonly string Connection = "Connection";

        public override void Process(opis message)
        {
            opis spec = modelSpec.Duplicate();

            instanse.ExecActionModelsList(spec);

            if (spec.isHere(Connection) && !string.IsNullOrWhiteSpace(spec.V(Connection)))
            {
                curr_conn = spec.V(Connection);
            }


            opis trtrt = ConnectAndQuery(curr_conn, spec.V(Query_text), spec.isHere(Capasity) && spec[Capasity].isInitlze ? spec[Capasity].intVal : 10000);


            message.body = "";
            message.CopyArr(trtrt);
            //message.AddArr(trtrt);
        }
Esempio n. 12
0
        public override void Process(opis message)
        {
            opis ms  = SpecLocalRunAll();
            var  rez = new opis();

            if (ms.isHere(start) && !serve)
            {
                instanse.ExecActionModelsList(ms[start]);
                code = ms[func];
                Run(ms[prefixes].ListValues());
            }


            if (ms.isHere(stop))
            {
                serve = false;
                instanse.ExecActionModelsList(ms[stop]);
            }
        }
Esempio n. 13
0
        public override void Process(opis message)
        {
            opis ms = modelSpec.Duplicate();

            instanse.ExecActionModelsList(ms);
            opis rez = new opis();

            if (ms.isHere(VerControlAlgorithm))
            {
                opis r = VerControlCompare(ms[first].Duplicate(), ms[second].Duplicate());
                message.CopyArr(new opis());
                message.AddArr(r);
                return;
            }

            var sec = ms[second].Duplicate();

            ms[first].Difference(sec, true, false,
                                 ms.isHere(deep_is_prior),
                                 ms.isHere(range_body),

                                 ms.isHere(koef) ? ms[koef].intVal : 1,
                                 ms.isHere(koef_mult) ? ms[koef_mult].intVal : 1
                                 );


            var fir = ms[first].Duplicate();

            ms[second].Difference(fir, true, false,
                                  ms.isHere(deep_is_prior),
                                  ms.isHere(range_body),

                                  ms.isHere(koef) ? ms[koef].intVal : 1,
                                  ms.isHere(koef_mult) ? ms[koef_mult].intVal : 1
                                  );



            message.CopyArr(new opis());

            message["sec"] = sec;
            message["fir"] = fir;

            message["compare_b"].PartitionKind         = "different body";
            message["compare_not_f"].PartitionKind     = "node not found";
            message["compare_listCou"].PartitionKind   = "different listCou";
            message["compare_b+listCou"].PartitionKind = "different body different listCou";
        }
Esempio n. 14
0
        public override void Process(opis message)
        {
            opis ms = modelSpec.Duplicate();

            instanse.ExecActionModelsList(ms);
            opis rez = new opis();

            bool retdata        = ms.isHere(returnItemsNotBranches);
            bool exactOnly      = ms.isHere(exact_structure);
            bool onlyItemsLevel = ms.isHere(only_top_level, false);

            ms[source].FindByTemplateValue(ms[template], rez, exactOnly, retdata, true, false, !onlyItemsLevel);

            message.CopyArr(rez, true);
            if (!ms.isHere(all) && rez.listCou > 0)
            {
                message.CopyArr(rez[0], true);
                message.body = rez[0].body;
            }
        }
Esempio n. 15
0
        public override void Process(opis message)
        {
            opis ms  = SpecLocalRunAll();
            var  rez = new opis();

            if (ms.isHere(UTF8BigEndian_to_Kirill, false))
            {
                message.body = TemplatesMan.UTF8BigEndian_to_Kirill(ms.V(text));
            }

            if (ms.isHere(UTF8Codes_to_Kirill, false)) //&#1040;
            {
                message.body = TemplatesMan.UTF8Codes_to_Kirill(ms.V(text));
            }

            if (ms.isHere(UTF_to_win1251, false)) //%3E%3C;
            {
                message.body = TemplatesMan.UTF_to_win1251(ms.V(text));
            }



            if (ms.isHere(blocks, false) && ms.isHere(substitution, false) && ms[blocks].listCou == ms[substitution].listCou)
            {
                var bl    = ms[blocks].ListValues();
                var subst = ms[substitution].ListValues();
                if (ms.isHere(underline_in_blocks_to_space, false))
                {
                    bl    = bl.Select(x => x.Replace("_", " ")).ToList();
                    subst = subst.Select(x => x.Replace("_", " ")).ToList();
                }

                message.body = Replace(ms.V(text), bl.ToArray(), subst.ToArray());
            }
        }
Esempio n. 16
0
        public override void Process(opis message)
        {
            roleObject = new opis("valuesContainer");
            opis locModSp = modelSpec.Duplicate();
            opis locShVal = sharedVal;

            instanse.ExecActionModelsList(locModSp);

            string rolename = locModSp[containerRole].isInitlze? locModSp.V(containerRole) : "valuesContainer";

            if (SharedContextRoles.GetRole(rolename, locShVal).PartitionKind != "null" &&
                locModSp.getPartitionIdx(appendContainer) != -1)
            {
                roleObject = SharedContextRoles.GetRole(rolename, locShVal);
            }

            SharedContextRoles.SetRole(roleObject, rolename, locShVal);

            opis srs = message;

            if (locModSp.getPartitionIdx(source) != -1)
            {
                srs = locModSp[source];
                //instanse.ExecActionModel(srs, srs);
            }

            srs = srs.W();

            opis bp = locModSp[blueprint];

            if (!locModSp.isHere(do_not_add_metadata))
            {
                roleObject.Vset("list_cou", srs.listCou.ToString());
                roleObject.Vset("name", srs.PartitionName);
                roleObject.Vset("val", srs.body);
            }
            //logopis.WrapByName(srs.Duplicate(), "srs_debug");

            modelSpec = locModSp;

            if (modelSpec.isHere(new_template_type))
            {
                buildCool(bp, srs);
            }
            else
            {
                build(bp, srs);
            }

            //logopis["srs"].Wrap( srs);
            //logopis.WrapByName(roleObject, "roleObject");
        }
Esempio n. 17
0
        public override void Process(opis message)
        {
            opis ms = SpecLocalRunAll();

            if (ms.isHere(open_write))
            {
                var path = ms.V(open_write);
                fs = File.OpenWrite(path);
            }

            if (ms.isHere(write))
            {
                var data = (byte[])ms[write]["data"].bodyObject;
                ms[write]["data"].bodyObject = null;

                if (data != null && data.Length > 0)
                {
                    try
                    {
                        fs.Write(data, 0, data.Length);
                        fs.Flush();
                    }
                    catch (Exception ex)
                    {
                        if (fs != null)
                        {
                            fs.Close();
                        }
                    }
                }
            }

            if (ms.isHere(close) && fs != null)
            {
                fs.Close();
                fs.Dispose();
            }
        }
Esempio n. 18
0
        public override void Process(opis message)
        {
            string defP = Application.StartupPath;
            opis   ex   = modelSpec.Duplicate();

            instanse.ExecActionModelsList(ex);

            string CompFilename = ex.V(Directory) + @"\" + ex.V(Filename) + ex.V(Extention);

            if (ex.isHere(SaveToCurrDir))
            {
                CompFilename = defP + @"\" + ex.V(Filename);
            }

            if (ex.isHere(url) && ex[url].isInitlze)
            {
                message.body = ex.V(url);
            }

            if (modelSpec.isHere(FillMessageBody))
            {
                message.body = CompFilename;
            }
            else
            {
                if (!modelSpec.isHere(CompiledFilename))
                {
                    message[CompiledFilename].body = CompFilename;
                }
                else
                {
                    message[CompiledFilename].body = ex.V(CompiledFilename);
                }
            }

            //logopis.AddArr(ex);
        }
Esempio n. 19
0
        public override void Process(opis message)
        {
            opis spec = modelSpec.Duplicate();

            instanse.ExecActionModelsList(spec);

            if (spec.isHere(replace_underline_by_space))
            {
                var repl = string.IsNullOrEmpty(spec.V(to_replace)) ? " " : spec.V(to_replace).Replace('_', ' ');
                message.body = message.body.Replace(repl, spec.V(by_this).Replace('_', ' '));
            }
            else
            {
                var repl = string.IsNullOrEmpty(spec.V(to_replace)) ? " " : spec.V(to_replace);
                message.body = message.body.Replace(repl, spec.V(by_this));
            }
        }
Esempio n. 20
0
        int RangeByModel(opis crit, opis arg)
        {
            int  rez = 0;
            opis mmm = new opis();

            mmm.PartitionName = "range arg";
            mmm.WrapByName(arg, "arg");

            instanse.ExecActionResponceModelsList(crit, mmm);

            if (mmm["passCou"].intVal == crit.listCou || crit.isHere(RangingList.only_range))
            {
                rez = mmm["range"].intVal;
            }

            return(rez);
        }
Esempio n. 21
0
        public override void Process(opis message)
        {
            opis spec = modelSpec.Duplicate();

            instanse.ExecActionModelsList(spec);


            var p = spec.V(pname);

            if (spec.isHere(val))
            {
                Set(p, spec[val]);
            }
            else
            {
                message.PartitionKind = "";
                message.CopyArr(storage[p]);
                message.body = storage[p].body;
            }
        }
Esempio n. 22
0
        public override void Process(opis message)
        {
            opis spec = modelSpec.Duplicate();

            instanse.ExecActionModelsList(spec);

            var srs = spec[source];

            if (spec.isHere(sort_source))
            {
                srs = message;
            }

            int sortt = (spec.isHere(sort_type)) ? spec[sort_type].intVal : 1;

            if (!string.IsNullOrEmpty(spec.V(order)))
            {
                var pnm = spec.V(order_by_partition);
                if (pnm.Length > 0)
                {
                    srs.SortArrayBy_pname_body(pnm, sortt, spec.V(order) != "desc");
                }
                else if (sortt == 3 || sortt == 4)
                {
                    srs.SortArrayBy_items_body(sortt, spec.V(order) != "desc");
                }
                else
                {
                    srs.SortThisArrayBy_items_pname(sortt, spec.V(order) != "desc");
                }
            }

            if (spec.isHere(sort_source))
            {
                return;
            }

            // ========================
            //   document composing

            var rez = "";
            var pn  = spec[part_names];

            for (int i = 0; i < srs.listCou; i++)
            {
                var line = "";
                if (pn.listCou > 0)
                {
                    for (int k = 0; k < pn.listCou; k++)
                    {
                        line += srs[i][pn[k].PartitionName].body + "\t";
                    }
                }
                else
                {
                    line += srs[i].PartitionName + "\t " + srs[i].body;
                }

                rez += line + " \n";
            }


            message.body          = rez;
            message.PartitionKind = "";
            message.CopyArr(new opis());
        }
Esempio n. 23
0
        public override void Process(opis message)
        {
            opis mspec = modelSpec.Duplicate();

            instanse.ExecActionModelsList(mspec);

            DateTime r = new DateTime();

            if (mspec.isHere(override_actual_date, false))
            {
                if (mspec[override_actual_date].isInitlze)
                {
                    overrideActual = Dates.FromStringTicks(mspec.V(override_actual_date));
                }
                else
                {
                    overrideActual = new DateTime(2);
                }
            }

            if (mspec.isHere(from_ticks, false) && mspec[from_ticks].isInitlze)
            {
                r = Dates.FromStringTicks(mspec.V(from_ticks));
                if (mspec.isHere(hour) || mspec.isHere(day))
                {
                    TimeSpan sp = new TimeSpan(mspec[day].intVal, mspec[hour].intVal, mspec[minute].intVal, 0);
                    r = r.Add(sp);
                }
            }

            if (mspec.isHere(from_unix, false) && mspec[from_unix].isInitlze)
            {
                r = Dates.FromEpochTime(mspec.V(from_unix));
                if (mspec.isHere(hour) || mspec.isHere(day))
                {
                    TimeSpan sp = new TimeSpan(mspec[day].intVal, mspec[hour].intVal, mspec[minute].intVal, 0);
                    r = r.Add(sp);
                }
            }

            if (mspec.isHere(return_actual_date, false))
            {
                r = DateTime.Now;

                if (overrideActual.Year > 2000)
                {
                    r = overrideActual;
                }

                if (mspec.isHere(hour) || mspec.isHere(day))
                {
                    TimeSpan sp = new TimeSpan(mspec[day].intVal, mspec[hour].intVal, mspec[minute].intVal, 0);
                    r = r.Add(sp);
                }
            }

            if (mspec.isHere(return_system_date, false))
            {
                r = DateTime.Now;

                if (mspec.isHere(hour) || mspec.isHere(day))
                {
                    TimeSpan sp = new TimeSpan(mspec[day].intVal, mspec[hour].intVal, mspec[minute].intVal, 0);
                    r = r.Add(sp);
                }
            }

            if (mspec.isHere(month, false))
            {
                try
                {
                    var yr = !string.IsNullOrEmpty(mspec.V(year)) ? mspec[year].intVal : DateTime.Now.Year;
                    yr = yr < 100 ? 2000 + yr : yr;
                    r  = new DateTime(yr, mspec[month].intVal, mspec[day].intVal, mspec[hour].intVal, mspec[minute].intVal, 0);
                }
                catch
                {
                }
            }

            if (mspec.isHere(set_curr, false))
            {
                curr = r;
            }


            if (mspec.isHere(Get_next_Week_monday, false))
            {
                r = Dates.MondayForDate(Dates.MondayForDate(curr).AddDays((mspec[Get_next_Week_monday].intVal > 0 ||
                                                                           mspec[Get_next_Week_monday].PartitionKind != "spec_tag")
                                                                         ? mspec[Get_next_Week_monday].intVal : 7));
                if (mspec.isHere(hour))
                {
                    TimeSpan sp = new TimeSpan(mspec[hour].intVal, mspec[minute].intVal, 0);
                    r = r.Add(sp);
                }
            }

            if (mspec.isHere(Get_This_Week_Sunday, false))
            {
                r = Dates.SundayForDate(curr);
            }


            message.body = mspec.OptionActive(format, false) ? r.ToString(mspec.V(format)) : r.Ticks.ToString();


            if (mspec.isHere(epoch_value, false))
            {
                message.body = Dates.EpochTime(r).ToString();
            }
            else if (mspec.isHere(week_num, false))
            {
                message.body = new GregorianCalendar(GregorianCalendarTypes.Localized).GetWeekOfYear(r, CalendarWeekRule.FirstFullWeek, DayOfWeek.Monday).ToString();
            }

            message.CopyArr(new opis());
        }
        public override void Process(opis message)
        {
            opis spec = modelSpec.Duplicate();

            instanse.ExecActionModelsList(spec);
            var srs = spec[source];

            var typesCou = srs.listCou;

            if (srs.listCou == 0)
            {
                message.body = "empty array of variants";
                return;
            }

            addsubnames = spec.isHere(add_subnames_to_path);

            var allPathes = new List <string>();

            for (int i = 0; i < srs.listCou; i++)
            {
                List <string> itemPathes = new List <string>();
                GetAllPatches(srs[i], "root", itemPathes);

                allPathes.AddRange(itemPathes);
            }

            var distinct = allPathes.Distinct();

            List <opisStatStruct> uniquePathesStat = new List <opisStatStruct>();

            foreach (var p in distinct)
            {
                Predicate <string> fff = delegate(string x) { return(x == p); };
                uniquePathesStat.Add(new opisStatStruct()
                {
                    path = p, countPath = allPathes.FindAll(fff).Count()
                });
            }


            var strictlyOneForItem        = uniquePathesStat.Where(x => x.countPath == typesCou);
            var pathes_strictlyOneForItem = strictlyOneForItem.Select(x => x.path);

            var fewTimesInitem        = uniquePathesStat.Where(x => x.countPath >= typesCou);
            var pathes_fewTimesInitem = fewTimesInitem.Select(x => x.path);

            opis baza = srs[0].Duplicate();

            cutByPathesList(baza, pathes_strictlyOneForItem);

            baza.PartitionName = "strictly One For Item";
            message.AddArr(baza);

            //----------------------

            baza = srs[0].Duplicate();
            cutByPathesList(baza, pathes_fewTimesInitem);

            baza.PartitionName = "few Times In Item";
            message.AddArr(baza);

            //----------------------

            message.AddArr(GetPercentageBase(srs.Duplicate(), uniquePathesStat, typesCou, 0.95));
            message.AddArr(GetPercentageBase(srs.Duplicate(), uniquePathesStat, typesCou, 0.9));
            message.AddArr(GetPercentageBase(srs.Duplicate(), uniquePathesStat, typesCou, 0.8));
            message.AddArr(GetPercentageBase(srs.Duplicate(), uniquePathesStat, typesCou, 0.7));
            message.AddArr(GetPercentageBase(srs.Duplicate(), uniquePathesStat, typesCou, 0.6));
            message.AddArr(GetPercentageBase(srs.Duplicate(), uniquePathesStat, typesCou, 0.5));
            message.AddArr(GetPercentageBase(srs.Duplicate(), uniquePathesStat, typesCou, 0.4));

            double rarely = 0.1;

            double.TryParse(spec.V(rarely_found_pecent), out rarely);

            message.AddArr(GetPercentageBase(srs.Duplicate(), uniquePathesStat, typesCou, 0.6, false));
            message.AddArr(GetPercentageBase(srs.Duplicate(), uniquePathesStat, typesCou, 0.5, false));
            message.AddArr(GetPercentageBase(srs.Duplicate(), uniquePathesStat, typesCou, 0.4, false));
            message.AddArr(GetPercentageBase(srs.Duplicate(), uniquePathesStat, typesCou, 0.3, false));
            message.AddArr(GetPercentageBase(srs.Duplicate(), uniquePathesStat, typesCou, 0.2, false));
            message.AddArr(GetPercentageBase(srs.Duplicate(), uniquePathesStat, typesCou, 0.1, false));

            message.AddArr(GetPercentageBase(srs.Duplicate(), uniquePathesStat, typesCou, rarely, false));
        }
Esempio n. 25
0
 bool IsException(opis curr)
 {
     return(exept.isHere(curr.PartitionName));
 }
Esempio n. 26
0
        public override void Process(opis message)
        {
            opis locModel = modelSpec.Duplicate();

            instanse.ExecActionModelsList(locModel);

            if (locModel.isHere(setContext))
            {
                pcont = locModel[pcontext].W();
                pcont["text"].body          = pcont.V("text").Replace("\n", "").Replace("\t", "").Replace("\r", "");
                pcont["text_length"].intVal = pcont.V("text").Length;

                text = pcont["text"].body;
                pcont["text"].body = "";

                serviceSymb = new char[pcont["service"].listCou];

                for (int i = 0; i < serviceSymb.Length; i++)
                {
                    string v = pcont["service"][i].body;

                    if (v.Length > 0)
                    {
                        serviceSymb[i] = v[0];
                    }
                    else
                    {
                        serviceSymb[i] = ' ';
                    }
                }

                char h = '"';
                qconst = h.ToString();
            }

            if (locModel.isHere(skipTo))
            {
                int pos   = pcont["pos"].intVal;
                int found = text.IndexOf(locModel.V(skipTo), pos);
                if (found != -1)
                {
                    string rez = text.Substring(pos, found - pos);

                    pcont["pos"].intVal = found + locModel.V(skipTo).Length;

                    pcont["quoted"].body = rez;
                }
            }

            if (locModel.isHere(read_quoted))
            {
                string p   = text;
                int    pos = pcont["pos"].intVal;
                string q   = locModel.V(read_quoted);

                int found = p.IndexOf((string.IsNullOrEmpty(q)? qconst : q), pos);
                if (found != -1)
                {
                    string rez = p.Substring(pos, found - pos);

                    pcont["pos"].intVal = found + 1;

                    pcont["quoted"].body = rez;
                }
                else
                {
                    pcont["pos"].intVal = pcont["text_length"].intVal;
                    pcont["symb"].body  = "end";
                }
            }


            if (locModel.isHere(read_till_service))
            {
                string p   = text;
                int    pos = pcont["pos"].intVal;

                int found = p.IndexOfAny(serviceSymb, pos);
                if (found != -1)
                {
                    string rez = p.Substring(pos, found - pos);

                    pcont["pos"].intVal = found + 1;

                    //* pcont["prev tsrv"].body = pcont["tillservice"].body;
                    //if(!string.IsNullOrEmpty(rez))
                    pcont["tillservice"].body = rez;
                    pcont["prev_symb"].body   = pcont["symb"].body;
                    pcont["symb"].body        = p[found].ToString();
                    if (p[found] == ' ')
                    {
                        pcont["symb"].body = "space";
                    }
                }
                else
                {
                    pcont["pos"].intVal = pcont["text_length"].intVal;
                    pcont["symb"].body  = "end";
                }
            }
        }
Esempio n. 27
0
        public override void Process(opis message)
        {
            opis ms  = SpecLocalRunAll();
            var  rez = new opis();

            opis vfrom = ms[from];
            opis vto   = ms[to];

            if (vfrom.PartitionKind == "wrapper")
            {
                vfrom = vfrom.W();
            }
            else
            {
                vfrom = vfrom.listCou == 1 ? vfrom[0] : null;
            }

            if (vto.PartitionKind == "wrapper")
            {
                vto = vto.W();
            }
            else
            {
                vto = vto.listCou == 1 ? vto[0] : null;
            }

            if (vfrom == null || vto == null || ms[tree].listCou == 0)
            {
                message.body = "some params are empty";
                return;
            }

            var foundFrom = Search(ms[tree], vfrom, ms.isHere(by_value));
            var foundTo   = Search(ms[tree], vto, ms.isHere(by_value));

            if (foundFrom == null || foundTo == null)
            {
                message.body = "branch not found in tree";
                return;
            }

            opis tracef = new opis();

            TracePath(ms[tree], foundFrom, tracef);

            opis tracet = new opis();

            TracePath(ms[tree], foundTo, tracet);

            if (ms.isHere(remove_1st))
            {
                tracef.RemoveArrElem(tracef[0]);
                tracet.RemoveArrElem(tracet[0]);

                tracef.arr[tracef.listCou] = null;
                tracet.arr[tracet.listCou] = null;
            }


            rez["path_points_from"] = PathPoints(tracef);
            rez["path_points_to"]   = PathPoints(tracet);

            rez["last_common_parent"] = LastCommonItem(tracef, tracet);

            related_as(rez);
            CommonBranchPthPoints(rez);


            message.CopyArr(rez);
        }
Esempio n. 28
0
        public override void Process(opis message)
        {
            opis p        = new opis();
            opis locModel = modelSpec;

            if (locModel.isHere(Args))
            {
                p = modelSpec[Args].Duplicate();
                if (p.listCou > 0)
                {
                    instanse.ExecActionModelsList(p);
                }
                else
                {
                    instanse.ExecActionModel(p, p);
                }
            }
            else
            {
                p.AddArr(message);
            }


            bool one_check = locModel.isHere(OneCheckIsEnough);

            bool rez = false;

            opis left  = p.listCou == 2? p[0]: new opis();
            opis right = p.listCou == 2 ? p[1] : new opis();


            //logopis.AddArr(sharedVal);
            //logopis.AddArr(left);
            //logopis.AddArr(right);


            switch (locModel[oprator].body)
            {
            case "#":
                opis chekers = locModel[Checks].Duplicate();
                instanse.ExecActionModel(chekers, chekers);

                bool notEqualRez = false;
                rez = !one_check;
                for (int i = 0; i < p.listCou; i++)
                {
                    opis mmm = new opis();
                    mmm.WrapByName(p[i].W(), "arg");
                    mmm.PartitionName = "mmmmmk";

                    instanse.ExecActionResponceModelsList(chekers, mmm);

                    if (one_check && mmm["passCou"].intVal > 0)
                    {
                        rez         = true;
                        notEqualRez = true;    //do not stop, run other checkers- they can do some job in this loop, so simply break loop is wrong
                    }
                    else
                    if (mmm["passCou"].intVal != chekers.listCou)
                    {
                        rez = notEqualRez;
                    }
                }
                //rez = ;
                break;

            case "<":
                rez = left.intVal < right.intVal;
                break;

            case "<l":
                long leftL = 0;
                long.TryParse(left.body.Trim(), out leftL);
                long rightL = 0;
                long.TryParse(right.body.Trim(), out rightL);
                rez = leftL < rightL;
                break;

            case ">l":
                leftL = 0;
                long.TryParse(left.body.Trim(), out leftL);
                rightL = 0;
                long.TryParse(right.body.Trim(), out rightL);
                rez = leftL > rightL;
                break;

            case ">":
                rez = left.intVal > right.intVal;
                break;

            case "<=":
                rez = left.intVal <= right.intVal;
                break;

            case ">=":
                rez = left.intVal >= right.intVal;
                break;

            case "!=":
                rez = left.body != right.body;
                break;

            case "=":
                rez = left.body == right.body;
                break;
            }

            if (rez)
            {
                instanse.ExecActionResponceModelsList(locModel[responce][ConditionResponceModel.yess], new opis());
            }
            else
            {
                instanse.ExecActionResponceModelsList(locModel[responce][ConditionResponceModel.no], new opis());
            }
        }
Esempio n. 29
0
        public override void Process(opis message)
        {
            opis spec = modelSpec.Duplicate();

            instanse.ExecActionModelsList(spec);

            if (spec.isHere(source))
            {
                csource = spec.V(source);
            }

            if (spec.isHere(pos))
            {
                cpos = spec[pos].intVal;
            }

            bool startCloser_to_end  = spec.isHere(start_closer_to_end);
            bool endingCloser_to_end = spec.isHere(fin_closer_to_end);

            string st = string.IsNullOrEmpty(spec.V(start)) ? spec.V(alt_start) : spec.V(start);

            var rez = GetEnclosed("###" + csource + "###", st, spec.V(fin), ref cpos, startCloser_to_end, endingCloser_to_end);

            var enclfound = spec.V(fin);

            if (string.IsNullOrEmpty(rez) && spec.isHere(alt_fin))
            {
                rez       = GetEnclosed("###" + csource + "###", st, spec.V(alt_fin), ref cpos, startCloser_to_end, endingCloser_to_end);
                enclfound = spec.V(alt_fin);
            }

            if (string.IsNullOrEmpty(rez) && spec.isHere(alt_fin2))
            {
                rez       = GetEnclosed("###" + csource + "###", st, spec.V(alt_fin2), ref cpos, startCloser_to_end, endingCloser_to_end);
                enclfound = spec.V(alt_fin2);
            }

            if (!string.IsNullOrWhiteSpace(rez))
            {
                if (spec.isHere(fin_as_separator))
                {
                    cpos -= enclfound.Length;
                }

                if (spec.isHere(add_closures))
                {
                    switch (spec.V(add_closures))
                    {
                    case "sf":
                        rez = st + rez + enclfound;
                        break;

                    case "s":
                        rez = st + rez;
                        break;

                    case "f":
                        rez = rez + enclfound;
                        break;
                    }
                }

                if (spec.isHere(if_not_empty))
                {
                    var par = new opis()
                    {
                        body = rez, PartitionName = "rez"
                    };
                    instanse.ExecActionResponceModelsList(spec[if_not_empty], par);
                }
            }


            message.body          = rez.Trim();
            message.PartitionKind = "";
            message.CopyArr(new opis());
        }
Esempio n. 30
0
        public override void Process(opis message)
        {
            opis spec = modelSpec.Duplicate();

            instanse.ExecActionModelsList(spec);

            if (spec[ftp_setting].isInitlze)
            {
                sett = spec[ftp_setting];
            }

            int p = sett[ftp_settings.Port].intVal;

            port = p > 0 ? p : port;

            opis rez = new opis();

            try
            {
                var       cr     = new NetworkCredential(sett.V(ftp_settings.username), sett.V(ftp_settings.password));
                FtpClient client = new FtpClient(sett.V(ftp_settings.FtpServer), port, cr);


                if (spec.isHere(encoding))
                {
                    client.Encoding = Encoding.GetEncoding(spec[encoding].intVal);
                }
                //client.ListingCulture = new CultureInfo("ru-RU");
                client.Connect();


                if (spec.isHere(delete))
                {
                    client.DeleteFile(spec.V(remote_file));
                }

                if (spec.isHere(rename))
                {
                    rez[rename].body = client.MoveFile(spec.V(local_file), spec.V(remote_file)).ToString();
                }

                if (spec.isHere(upload))
                {
                    rez[upload].body = client.UploadFile(spec.V(local_file), spec.V(remote_file), FtpRemoteExists.Overwrite).ToString();
                }

                if (spec.isHere(compres_upload))
                {
                    //using (FileStream originalFileStream = File.OpenRead(spec.V(local_file)))
                    //{
                    //        using (FileStream compressedFileStream = File.Create(spec.V(remote_file)))
                    //        {
                    //            using (GZipStream compressionStream = new GZipStream(compressedFileStream,
                    //               CompressionMode.Compress))
                    //            {
                    //                originalFileStream.CopyTo(compressionStream);
                    //            }
                    //        }
                    //}


                    using (FileStream originalFileStream = File.OpenRead(spec.V(local_file)))
                    {
                        using (MemoryStream mso = new MemoryStream())
                        {
                            using (Stream compressedFTPFileStream = client.OpenWrite(spec.V(remote_file), FtpDataType.Binary))
                                //using (FileStream compressedFileStream = File.OpenWrite(spec.V(remote_file)))
                                using (GZipStream compressionStream = new GZipStream(compressedFTPFileStream, CompressionMode.Compress))
                                {
                                    originalFileStream.CopyTo(compressionStream);
                                    //originalFileStream.Flush();  makes archive broken in the end
                                }
                        }
                    }
                }

                if (spec.isHere(delete_local))
                {
                    File.Delete(spec.V(local_file));
                }

                if (spec.isHere(download))
                {
                    rez[download].body = client.DownloadFile(spec.V(local_file), spec.V(remote_file), FtpLocalExists.Overwrite).ToString();
                }

                if (spec.isHere(scan))
                {
                    rez[scan] = spec.V(scan) == "ALL" ? dir(client, spec.V(remote_file)) : dir(client, spec.V(remote_file), false);
                }

                client.Disconnect();
            }
            catch (Exception e)
            {
                rez["Exception"].body = e.Message;
            }


            message.CopyArr(rez);
        }