コード例 #1
0
        void BuildLevel(opis cont, opis lvl)
        {
            var arr = cont[context.subcon];
            var t   = new opis()
            {
                PartitionKind = cont[context.Organizer].body
            };

            lvl.AddArr(t);
            var id = cont.V(context.ID);

            t.Vset("id", id);

            if (id.Length > 27)
            {
                var idx = id.IndexOfAny(new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' });
                t.PartitionName = id.Substring(0, idx);
            }
            else
            {
                t.PartitionName = t.PartitionKind;
            }

            //  потуши636854239097818000_153121557

            for (int i = 0; i < arr.listCou; i++)
            {
                BuildLevel(arr[i], t);
            }
        }
コード例 #2
0
ファイル: NodesPathInfo.cs プロジェクト: kibitzz/CodeNotion
        bool TracePath(opis treeBranch, opis item, opis trace)
        {
            bool rez        = false;
            bool childFound = false;

            for (int i = 0; i < treeBranch.paramCou; i++)
            {
                if (treeBranch[i] == item)
                {
                    rez = true;
                }
                else
                {
                    childFound = TracePath(treeBranch[i], item, trace);
                }

                if (childFound)
                {
                    trace.AddArr(treeBranch[i]);
                    rez = true;
                    break;
                }
            }

            return(rez);
        }
コード例 #3
0
ファイル: arr_chuncks.cs プロジェクト: kibitzz/CodeNotion
        public override void Process(opis message)
        {
            opis spec = modelSpec.Duplicate();

            instanse.ExecActionModelsList(spec);

            int siz = spec[chunck_size].intVal;

            opis srs = spec[source];
            opis rez = new opis(srs.listCou / siz);

            int idx = 0;

            while (idx < (srs.listCou - siz + 1))
            {
                var itm = new opis(siz)
                {
                    PartitionName = "itm"
                };
                rez.AddArr(itm);
                for (int i = 0; i < siz; i++)
                {
                    itm[i.ToString()] = srs[idx];
                    idx++;
                }
            }


            message.body = "";
            message.CopyArr(rez);
        }
コード例 #4
0
        public override void Process(opis message)
        {
            if (message.PartitionKind != "stringArray")
            {
                logopis["err:"].body = "message is not a stringArray ";
            }

            opis rez = new opis();

            string[] proc = (string[])message.bodyObject;

            for (int i = 0; i < proc.Length; i++)
            {
                if (proc[i].Length > 0)
                {
                    opis d = new opis();
                    d.body          = proc[i];
                    d.PartitionName = i.ToString();

                    rez.AddArr(d);
                }
            }

            message["data"] = rez;
        }
コード例 #5
0
        public override void Process(opis message)
        {
            if (modelSpec.getPartitionIdx(LoadContext) != -1)
            {
                int  idx = SharedContextRoles.GetRole(SharedContextRoles.ProcessIndex, sharedVal).intVal;
                opis currentContextItem = new opis();

                if (contexts.listCou > idx)
                {
                    currentContextItem = contexts[idx];
                }
                else
                {
                    currentContextItem.PartitionName = "currentContextItem";
                    currentContextItem.body          = "ERR: index is out of range";
                }


                SharedContextRoles.SetRole(currentContextItem, "currentContext", sharedVal);
            }

            if (modelSpec.getPartitionIdx(GetCount) != -1)
            {
                message.intVal = contexts.listCou;
            }

            if (modelSpec.isHere(GetAllArray))
            {
                message.AddArr(contexts);
            }
        }
コード例 #6
0
        opis dir(FtpClient client, string path, bool rec = true)
        {
            opis rez = new opis();

            foreach (FtpListItem item in client.GetListing(path))
            {
                opis itm = new opis();

                itm.PartitionName = item.Name;
                var dd = client.GetModifiedTime(item.FullName);
                //  itm.body = dd.ToString();

                if (item.Type == FtpFileSystemObjectType.File)
                {
                    itm.PartitionKind = "file";

                    itm["date"].body       = dd.Date.ToString("dd/MM/yyyy");
                    itm["date_ticks"].body = dd.Date.Ticks.ToString();
                    itm["size"].body       = client.GetFileSize(item.FullName).ToString();
                }

                if (rec && item.Type == FtpFileSystemObjectType.Directory)
                {
                    itm.CopyArr(dir(client, item.FullName));
                }

                // calculate a hash for the file on the server side (default algorithm)
                //FtpHash hash = client.GetHash(item.FullName);

                rez.AddArr(itm);
            }

            return(rez);
        }
コード例 #7
0
        public static opis VerControlCompare(opis now, opis then)
        {
            then.NormalizeNamesForComparison(now);
            then.NormalizeNamesForComparison(then);

            then.CheckForVersionControl(then, now, "added");
            then.CheckForVersionControl(now, then, "deleted");

            then.PartitionKind = "previous";
            now.PartitionKind  = "current";
            opis comp = new opis("comparison result");

            comp.AddArr(now);
            comp.AddArr(then);

            return(comp);
        }
コード例 #8
0
        int MarkByPathesList(opis baza, IEnumerable <string> pl, string marker)
        {
            GetAllPatches(baza, "root", new List <string>());

            int           rez       = 0;
            List <string> allpathes = new List <string>();

            var searchtmpl = baza.Duplicate();

            searchtmpl.PartitionName = "_search_template";

            baza.RunRecursively(x => {
                for (int i = 0; i < x.listCou; i++)
                {
                    var currp = ((opisStatStruct)x[i].bodyObject).path;

                    if (pl.Contains(currp))
                    {
                        allpathes.Add(currp);
                        x[i].PartitionKind = marker;
                        x[i].body          = "??? " + currp;
                    }
                }
            });

            GetAllPatches(searchtmpl, "root", new List <string>());
            searchtmpl.RunRecursively(x => {
                for (int i = 0; i < x.listCou; i++)
                {
                    var currp = ((opisStatStruct)x[i].bodyObject).path;

                    if (pl.Contains(currp))
                    {
                        x[i].body = "??? " + currp;
                    }
                }
            });

            baza.AddArr(new opis()
            {
                PartitionName = "_marker_", PartitionKind = marker
            });
            baza.AddArr(searchtmpl);

            return(allpathes.Distinct().Count());
        }
コード例 #9
0
ファイル: contex.cs プロジェクト: kibitzz/CodeNotion
        public void buildTree(opis b)
        {
            opis term = context.Find(b.PartitionName);

            if (term.isDuplicated_)
            {
                b.PartitionKind = "circular";
                return;
            }

            if (string.IsNullOrEmpty(term.PartitionName) || !term.isInitlze)
            {
                return;
            }

            opis intellection = context.Find(term[ModelNotion.intellection].body.Trim());

            if (!intellection.isInitlze)
            {
                return;
            }

            term.lockThisForDuplication();

            b.PartitionKind = intellection.PartitionName;

            string ontology = term.V(ModelNotion.ontology) + " "
                              + intellection.V(ModelNotion.ontology);

            if (!string.IsNullOrWhiteSpace(ontology))
            {
                string[] ttt = ontology.Split();

                foreach (string n in ttt)
                {
                    if (!string.IsNullOrWhiteSpace(n))
                    {
                        opis tmp = new opis();
                        tmp.PartitionName = context.Find(n).PartitionName;
                        if (string.IsNullOrEmpty(tmp.PartitionName))
                        {
                            tmp.PartitionName = n;
                        }

                        b.AddArr(tmp);

                        buildTree(tmp);
                    }
                }
            }

            term.UnlockThisForDuplication();
        }
コード例 #10
0
        public override void Process(opis message)
        {
            if (message.PartitionKind != "stringArray")
            {
                logopis["err:"].body = "message is not a stringArray ";
            }


            string[] proc = (string[])message.bodyObject;

            opis rez     = new opis();
            opis currSet = new opis();

            for (int i = 0; i < proc.Length; i++)
            {
                if (proc[i].Trim().Length > 2)
                {
                    //JsonObject jrez = JsonParser.Parse(proc[i]);
                    currSet[proc[i]].body = "";
                }
                else
                {
                    if (currSet.listCou > 1)
                    {
                        rez.AddArr(currSet);
                    }

                    currSet = new opis();
                    currSet.PartitionName = DateTime.Now.Ticks.ToString();
                }
            }

            if (currSet.listCou > 1)
            {
                rez.AddArr(currSet);
            }

            message["data"] = rez;
        }
コード例 #11
0
ファイル: PeriodIterator.cs プロジェクト: kibitzz/CodeNotion
        public override void Process(opis message)
        {
            opis spec = modelSpec.Duplicate();

            instanse.ExecActionModelsList(spec);


            var dayz = Dates.DaysInPeriod(Dates.FromStringTicks(spec.V(start)), Dates.FromStringTicks(spec.V(fin)));

            if (Dates.FromStringTicks(spec.V(start)) > Dates.FromStringTicks(spec.V(fin)))
            {
                dayz.Clear();
            }

            var firstW = Dates.FromStringTicks(spec.V(dateForFirstWeek));

            var h = spec[hour].intVal;
            var m = spec[minute].intVal;

            var format = spec[dateFormat].body;

            opis rez = new opis();

            foreach (var date in dayz)
            {
                var  d       = date.AddHours(h).AddMinutes(m);
                opis dayInfo = new opis();
                dayInfo.PartitionName = "d";
                dayInfo.Vset("DayOfYear", d.DayOfYear.ToString());
                dayInfo.Vset("Year", d.Year.ToString());
                dayInfo.Vset("Month", d.Month.ToString());
                dayInfo.Vset("Day", d.Day.ToString());
                dayInfo.Vset("DayOfWeek", ((int)d.DayOfWeek).ToString());
                dayInfo.Vset("Ticks", d.Ticks.ToString());
                dayInfo.Vset("Formatted", d.ToString(format));

                int wnum             = (Dates.WeekNumSince(firstW, d) + 1);
                int week_odd_even    = Dates.WeekForDate(firstW, 1, d);
                int quattro_odd_even = 0;
                dayInfo.Vset("week_num", wnum.ToString());
                dayInfo.Vset("week_1_2", week_odd_even.ToString());

                quattro_odd_even = (wnum + 3) % 4;
                dayInfo.Vset("week_1_2_3_4", quattro_odd_even.ToString());


                rez.AddArr(dayInfo);
            }

            message.CopyArr(rez);
        }
コード例 #12
0
        public void RecurseItems(opis conpar, opis storage)
        {
            string itemz = "items";

            for (int i = 0; i < conpar[itemz].listCou; i++)
            {
                storage.AddArr(conpar[itemz][i]);
            }

            for (int i = 0; i < conpar["subcon"].listCou; i++)
            {
                RecurseItems(conpar["subcon"][i], storage);
            }
        }
コード例 #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";
        }
コード例 #14
0
ファイル: contex.cs プロジェクト: kibitzz/CodeNotion
        public void buildTreeAllRelations(opis b)
        {
            opis term = context.Find(b.PartitionName);

            if (term.isDuplicated_)
            {
                b.PartitionKind = "circular";
                return;
            }

            if (string.IsNullOrEmpty(term.PartitionName) || !term.isInitlze)
            {
                return;
            }

            opis intellection = context.Find(term[ModelNotion.intellection].body.Trim());

            if (!intellection.isInitlze)
            {
                return;
            }

            term.lockThisForDuplication();

            b.PartitionKind = intellection.PartitionName;

            var inh = FindAllInheritedFromOrHaveInOntology(term).rootForms;


            foreach (string n in inh)
            {
                if (!string.IsNullOrWhiteSpace(n))
                {
                    var  inhterm = context.Find(n);
                    opis tmp     = new opis();

                    tmp.PartitionName = inhterm.PartitionName;
                    tmp.body          = inhterm.V(ModelNotion.ontology);
                    b.AddArr(tmp);

                    buildTreeAllRelations(tmp);
                }
            }


            term.UnlockThisForDuplication();
        }
コード例 #15
0
ファイル: MySqlQuery.cs プロジェクト: kibitzz/CodeNotion
        public static opis ConnectAndQuery(string connectionString, string queryString, int cap = 10000)
        {
            opis rez = new opis(cap);

            try
            {
                using (var connection = new MySqlConnection(
                           connectionString))
                {
                    var command = new MySqlCommand(queryString, connection);
                    command.CommandTimeout = 600;
                    command.Connection.Open();

                    using (var reader = command.ExecuteReader())
                    {
                        if (!reader.HasRows)
                        {
                            return(rez);
                        }

                        var cn = GetColumnNames(reader);

                        while (reader.Read())
                        {
                            var itm = new opis();
                            for (int i = 0; i < cn.Length; i++)
                            {
                                itm[cn[i]].body = reader[i].ToString();
                            }
                            rez.AddArr(itm);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                rez["Exception"]["Message"].body    = e.Message;
                rez["Exception"]["StackTrace"].body = e.StackTrace;
                //  rez["Exception"]["InnerException"].body = e.InnerException.ToString();
            }

            return(rez);
        }
コード例 #16
0
        public override void Process(opis message)
        {
            if (message.PartitionKind != "stringArray")
            {
                logopis["err:"].body = "message is not a stringArray ";
            }


            string[] proc = (string[])message.bodyObject;

            opis d = new opis();

            opis spl = modelSpec[splitters].Duplicate();


            for (int i = 0; i < proc.Length; i++)
            {
                if (string.IsNullOrEmpty(proc[i]))
                {
                    continue;
                }

                opis el = new opis();
                el.PartitionName = i.ToString();
                string s   = proc[i] + "-";
                int    pos = 0;

                for (int sp = 0; sp < spl.listCou; sp++)
                {
                    int fpos = s.IndexOf(spl[sp].body[0], pos);

                    el[spl[sp].PartitionName].body = s.Substring(pos, fpos - pos);

                    pos = fpos + 1;
                }
                d.AddArr(el);
            }

            message["data"] = d;
        }
コード例 #17
0
ファイル: NodesPathInfo.cs プロジェクト: kibitzz/CodeNotion
        opis PathPoints(opis trace)
        {
            opis rez = new opis();

            for (int i = 0; i < trace.paramCou; i++)
            {
                var itm = new opis()
                {
                    PartitionName = trace[i].PartitionName,
                    body          = trace[i].body,
                    PartitionKind = trace[i].PartitionKind,
                };
                itm.Vset("level_up", i.ToString());
                itm.Vset("level_down", (trace.paramCou - i).ToString());
                itm.Vset("total_depth", (trace.paramCou).ToString());
                itm.WrapByName(trace[i], "branch_ref");

                rez.AddArr(itm);
            }

            return(rez);
        }
コード例 #18
0
ファイル: NodesPathInfo.cs プロジェクト: kibitzz/CodeNotion
        void CommonBranchPthPoints(opis rez)
        {
            opis ci = rez["last_common_parent"]["branch_ref"].W();

            opis PathPoints_from = rez["path_points_from"];

            opis from = new opis();

            for (int i = 0; i < PathPoints_from.listCou; i++)
            {
                if (PathPoints_from[i].W("branch_ref") == ci)
                {
                    break;
                }

                from.AddArr(PathPoints_from[i]);
            }

            //===============
            opis PathPoints_to = rez["path_points_to"];

            opis to = new opis();

            for (int i = 0; i < PathPoints_to.listCou; i++)
            {
                if (PathPoints_to[i].W("branch_ref") == ci)
                {
                    break;
                }

                to.AddArr(PathPoints_to[i]);
            }

            rez["common_parent_path_points_from"] = from;
            rez["common_parent_path_points_to"]   = to;
        }
コード例 #19
0
        public opis FindItem(string type, string pname, bool sub)
        {
            opis   rez   = new opis("ListOf_Fitted_Items");
            string itemz = "items";

            if (sub)
            {
                itemz = "all_items";
                if (!o[itemz].isInitlze)
                {
                    RecurseItems(o, o[itemz]);
                }
            }

            for (int i = 0; i < o[itemz].listCou; i++)
            {
                if (o[itemz][i].V(pname).Contains(type))
                {
                    rez.AddArr(o[itemz][i]);
                }
            }

            return(rez);
        }
コード例 #20
0
        public override void Process(opis message)
        {
            opis trtrt = new opis();

            try
            {
                if (modelSpec.isHere(opis_json))
                {
                    trtrt.load(message.body);
                }
                else
                {
                    trtrt.JsonParce(message.body);
                }
            }
            catch (Exception e)
            {
                trtrt["error parce"].body = e.Message;
            }

            message.body = "";
            if (modelSpec.isHere(opis_json))
            {
                message.body = trtrt.body;
            }

            if (modelSpec.isHere(decode_names))
            {
                trtrt.RunRecursively(x => x.PartitionName = TemplatesMan.UTF8BigEndian_to_Kirill(x.PartitionName));
            }



            message.CopyArr(new opis());
            message.AddArr(trtrt);
        }
コード例 #21
0
        public override void Process(opis message)
        {
            opis specl = modelSpec.Duplicate();

            instanse.ExecActionModelsList(specl);

            var instr = specl[instructions];

            int ln = specl[lock_idx].intVal;

            if (currInstActiveLock > 0)  // lock inside lock is ignored within single instance
            {
#if DEBUG
                var ei = new opis()
                {
                    PartitionName = "WARN: nested lock -- " + spec.PartitionName + " " + ln
                };
                ei.AddArr(instr);
                global_log.log?.AddArr(ei);
#endif
                instanse.ExecActionModelsList(instr);
                return;
            }

            if (ln == 1)
            {
                lock (lock1)
                {
                    currInstActiveLock = ln;
                    instanse.ExecActionModelsList(instr);
                }
            }

            if (ln == 2)
            {
                lock (lock2)
                {
                    currInstActiveLock = ln;
                    instanse.ExecActionModelsList(instr);
                }
            }

            if (ln == 3)
            {
                lock (lock3)
                {
                    currInstActiveLock = ln;
                    instanse.ExecActionModelsList(instr);
                }
            }

            if (ln == 4)
            {
                lock (lock4)
                {
                    currInstActiveLock = ln;
                    instanse.ExecActionModelsList(instr);
                }
            }

            if (ln == 5)
            {
                lock (lock5)
                {
                    currInstActiveLock = ln;
                    instanse.ExecActionModelsList(instr);
                }
            }

            if (ln == 6)
            {
                lock (lock6)
                {
                    currInstActiveLock = ln;
                    instanse.ExecActionModelsList(instr);
                }
            }

            if (ln == 7)
            {
                lock (lock7)
                {
                    currInstActiveLock = ln;
                    instanse.ExecActionModelsList(instr);
                }
            }

            currInstActiveLock = 0;
        }
コード例 #22
0
        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));
        }
コード例 #23
0
ファイル: HtmlParser_HAP.cs プロジェクト: kibitzz/CodeNotion
        void Trace(HtmlNode node, opis rn, bool ignoreattr = false)
        {
            rn.ReinitArr(node.ChildNodes.Count + 2);
            //  rn.ArrResize(node.ChildNodes.Count + 2);

            rn[0] = new opis(node.Attributes.Count + 3)
            {
                PartitionName = "Attributes"
            };

            foreach (var a in node.Attributes)
            {
                rn[0].Vset(a.Name, a.Value);
            }

            if (!ignoreattr && (namesAtrIgnore == null || !namesAtrIgnore.Contains(node.Name)))
            {
                var htmobj = rn[0]["InnerHtml"];

                if (maxHtmlShow != 0)
                {
                    var html = "";

                    try
                    {
                        html = node.InnerHtml;
                    }
                    catch (ArgumentOutOfRangeException e)
                    {
                        html = "";
                    }

                    if (html.Length < maxHtmlShow)
                    {
                        htmobj.body = normalize_spaces.NormalizeSpRemoveControlsSeparators(html);
                    }

                    //htmobj.body = html.Trim()
                    //                                .Replace('\n', ' ')
                    //                                .Replace('\t', ' ');
                }

                rn[0].Vset("InnerText", normalize_spaces.NormalizeSpRemoveControlsSeparators(node.InnerText));

                //rn[0].Vset("InnerText", node.InnerText.Trim().Replace("\n", " ")
                //                                    .Replace("\t", " ").Replace("                ", " ").Replace("     ", " "));
            }
            else
            {
                ignoreattr = !ignoreattr;
            }


            foreach (var n in node.ChildNodes)
            {
                if (n.Name != "#text")
                {
                    opis cn = new opis(-1);
                    cn.PartitionName = n.Name;
                    //cn.PartitionKind = "";
                    //cn.body = "";


                    rn.AddArr(cn);
                    Trace(n, cn, ignoreattr);
                }
            }
        }
コード例 #24
0
        public override void Process(opis message)
        {
            opis locOpis    = modelSpec;
            long integerVal = 0;

            string oper   = modelSpec.V(operation);
            string opSpec = locOpis.V(operationSpec);

            long lv = 0;

            #region what to process

            opis val = locOpis[value].Duplicate();

            bool unwr = !locOpis.OptionActive(do_not_value_Unwrap);
            if (unwr)
            {
                val = val.W();
            }

            if (!locOpis.OptionActive(do_not_exec_value))
            {
                // obsolete functionality, remove if use fresh context
                if (string.IsNullOrEmpty(val.PartitionKind) && val.listCou > 0)
                {
                    instanse.ExecActionModelsList(val);
                }

                instanse.ExecActionModel(val, val);
            }
            modelSpec = locOpis;

            if (unwr)
            {
                val = val.W();
            }

            if (modelSpec.isHere(clear_func, false))
            {
                val.PartitionKind = "";
                for (int i = 0; i < val.listCou; i++)
                {
                    val[i].PartitionKind = "";
                }
            }

            opis processThis = message;
            opis templ       = modelSpec.getPartitionNotInitOrigName(partition)?.Duplicate();
            if (templ != null)
            {
                if (templ.PartitionKind != "template")
                {
                    instanse.ExecActionModel(templ, templ);
                }
                else if (templ.listCou > 0)
                {
                    instanse.ExecActionModelsList(templ);
                }

                if (templ.listCou > 0)
                {
                    processThis = opis.GetLevelByTemplate(templ[0], processThis, true);
                }
            }

            #endregion

            switch (oper)
            {
            case "rename":
                opis ft = locOpis[operationSpec].Duplicate();
                instanse.ExecActionModel(ft, ft);
                processThis.PartitionName = ft.body;
                break;

            case "setmodel":
                opis pv = locOpis[value].Duplicate();
                instanse.ExecActionModel(pv, pv);
                processThis.PartitionKind = pv.body;
                break;

            case "conc ower":
                for (int i = 0; i < val.listCou; i++)
                {
                    processThis[val[i].PartitionName] = val[i];
                }
                break;

            case "conc stay":
                processThis.AddArrMissing(val);
                break;

            case "dec":
                lv               = StrUtils.LongFromString(processThis.body);
                integerVal       = StrUtils.LongFromString(val.body);
                processThis.body = (lv - integerVal > 0 ? lv - integerVal : 0).ToString();
                break;

            case "inc":
                lv               = StrUtils.LongFromString(processThis.body);
                integerVal       = StrUtils.LongFromString(val.body);
                processThis.body = (lv + (integerVal > 0 ? integerVal : 1)).ToString();
                break;


            case "add_arr_i":
                integerVal = opSpec == "all" ? 1 : (opSpec == "new" ? 2 : 0);
                for (int i = 0; i < val.listCou; i++)
                {
                    if (integerVal == 1)
                    {
                        processThis.AddArr(val[i]);
                    }
                    else
                    {
                        if (processThis.getPartitionIdx(val[i].PartitionName) == -1)
                        {
                            processThis.AddArr(val[i]);
                        }
                        else
                        if (!(integerVal == 2))
                        {
                            if (processThis[val[i].PartitionName].body != val[i].body ||
                                processThis[val[i].PartitionName].listCou != val[i].listCou)
                            {
                                processThis.AddArr(val[i]);
                            }
                        }
                    }
                }
                break;

            case "add_arr":
                if (!(opSpec == "uniq"))
                {
                    processThis.AddArr(val);
                }
                else
                {
                    if (processThis.getPartitionIdx(val.PartitionName) == -1 ||
                        processThis[val.PartitionName].body != val.body ||
                        processThis[val.PartitionName].listCou != val.listCou)
                    {
                        processThis.AddArr(val);
                    }
                }
                break;

            case "set":
                if (opSpec == "w")
                {
                    processThis.Wrap(val.W());
                }
                else
                {
                    processThis.body = val.body;
                    processThis.CopyArr(val);
                }
                break;

            case "set b":
                processThis.body = val.body;

                break;
            }
        }
コード例 #25
0
        public void buildCool(opis template, opis partition)
        {
            for (int i = 0; i < template.listCou; i++)
            {
                opis tt   = template[i];
                opis srch = new opis();

                srch.body          = getChemaVal(tt.body, "?", "");
                srch.PartitionName = getChemaVal(tt.PartitionName, "?", "");
                srch.PartitionKind = getChemaVal(tt.PartitionKind, "?", "");

                opis found = new opis();

                partition.FindTreePartitions(srch, "", found, false);

                if (found.listCou > 0)
                {
                    opis fop = found[0][0];

                    // = operate duplicated object
                    if (tt.PartitionName.Contains("="))
                    {
                        fop = fop.Duplicate();
                    }

                    // ^ operate unwrapped object
                    if (tt.PartitionName.Contains("^"))
                    {
                        fop = fop.W();
                    }

                    // * fill array
                    if (tt.PartitionName.Contains("*"))
                    {
                        string apn = getChemaVal(tt.PartitionName, "*", srch.PartitionName);
                        opis   itm = new opis();
                        itm.PartitionName = apn;
                        itm.CopyArr(fop);
                        roleObject.AddArr(itm);
                    }

                    // @ wrap partition
                    if (tt.PartitionName.Contains("@"))
                    {
                        string apn = getChemaVal(tt.PartitionName, "@", srch.PartitionName);
                        opis   itm = new opis();
                        itm.PartitionName = apn;
                        itm.Wrap(fop);
                        roleObject.AddArr(itm);
                    }

                    // # put as is
                    if (tt.PartitionName.Contains("#"))
                    {
                        roleObject.AddArr(fop);
                    }

                    // $ put body value as (usable in body )
                    if (tt.body.Contains("$"))
                    {
                        string apn = getChemaVal(tt.body, "$", srch.PartitionName);
                        opis   itm = new opis();
                        itm.PartitionName = apn;
                        itm.body          = fop.body;
                        roleObject.AddArr(itm);
                    }

                    //recurce
                    if (tt.listCou > 0)
                    {
                        buildCool(tt, fop);
                    }
                }
            }
        }
コード例 #26
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());
            }
        }