Пример #1
0
        int cutByPathesList(opis baza, IEnumerable <string> pl)
        {
            GetAllPatches(baza, "root", new List <string>());

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

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

                    if (pl.Contains(currp))
                    {
                        allpathes.Add(currp);
                        ok.Add(x[i]);
                    }
                }

                x.SetArr(ok.ToArray());
            });


            return(allpathes.Distinct().Count());
        }
Пример #2
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;

            var sb = new StringBuilder(proc.Length);

            for (int i = 0; i < proc.Length; i++)
            {
                //if (proc[i].Length > 0)
                //{
                sb.Append(proc[i] + "\n");
                //}
            }

            rez.body = sb.ToString();

            message["data"] = rez;
        }
Пример #3
0
        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
        bool check(opis p)
        {
            bool rez = false;


            return(rez);
        }
Пример #5
0
        public override void Process(opis message)
        {
            //bool pass = message["original_msg_context"].V("ID") == o.V("ID");

            //if (pass)
            message["run_on_this_context"].body = "yepp";
        }
        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);
            }
        }
Пример #7
0
        public override void Process(opis message)
        {
            if (modelSpec[clear_models_log].isInitlze)
            {
                thisins["Models_log"].CopyArr(new opis());
            }

            if (modelSpec[messageBanner].isInitlze)
            {
                SysInstance.messageBannertext = "paused to debug : " + modelSpec[messageBanner].body;
                instanse.updateGui();
            }
            else
            {
                SysInstance.messageBannertext = "paused to debug";
                instanse.updateGui();
            }

            if (modelSpec.V(do_not_build_debug) == "y")
            {
                opis.do_not_build_debug = true;
            }
            if (modelSpec.V(do_not_build_debug) == "n")
            {
                opis.do_not_build_debug = false;
            }

            instanse.PauseThread();
        }
Пример #8
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);
                }
            }
        }
Пример #9
0
        public override void Process(opis message)
        {
            opis arg = message.W("arg");

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

            if (ptt.PartitionKind == "template")
            {
                instanse.ExecActionResponceModelsList(ptt, ptt);
            }
            else
            {
                instanse.ExecActionModel(ptt, ptt);
            }

            //logopis["debug_template"] = ptt;
            //logopis.WrapByName( arg, "arg");

            int cf = arg.CheckConformity(arg, ptt);

            if ((ptt.listCou == cf && !modelSpec.isHere(NOT)) ||
                (cf == 0 && modelSpec.isHere(NOT)))
            {
                //logopis["debug_pass"].body = "y";
                message["pass"].body = "y";
                message["passCou"].intVal++;
                message["range"].intVal++;
            }
        }
Пример #10
0
        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);
        }
Пример #11
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);
            }
        }
Пример #12
0
        opis LastCommonItem(opis trace1, opis trace2)
        {
            opis rez = new opis();

            var  re2 = trace2.arr.Reverse().Where(x => x != null);
            int  pos = 0;
            opis b   = new opis()
            {
                PartitionName = "no data"
            };

            foreach (var ti1 in trace1.arr.Reverse().Where(x => x != null))
            {
                if (re2.ElementAt(pos) == ti1)
                {
                    b = ti1;
                    rez.Vset("level_split", (pos + 1).ToString());
                }

                pos++;
            }

            rez.Vset("branch_kind", b.PartitionKind);
            rez.Vset("branch_name", b.PartitionName);
            rez.WrapByName(b, "branch_ref");

            return(rez);
        }
Пример #13
0
        public override void Process(opis message)
        {
            opis ms     = SpecLocalRunAll();
            var  rez    = new opis();
            int  rezcou = 0;

            var txt = ms.V(text);
            var ptn = ms[patterns].ListValues();;

            foreach (var p in ptn)
            {
                if (string.IsNullOrEmpty(p))
                {
                    continue;
                }
                Regex           regex   = new Regex(p.Replace("_", " "));
                MatchCollection matches = regex.Matches(txt);
                if (matches.Count > 0)
                {
                    foreach (Match match in matches)
                    {
                        rezcou++;
                        rez.Vset(rezcou.ToString(), match.Value);
                        txt = txt.Replace(match.Value, "");
                    }
                }
            }

            message.body = txt;
            message.CopyArr(rez);
        }
Пример #14
0
 public override void Process(opis message)
 {
     if (modelSpec.getPartitionIdx(Send) != -1)
     {
         SendMsg(modelSpec[Send]);
     }
 }
Пример #15
0
        public opis RecurseFindItem(opis conpar, opis item)
        {
            opis   rez   = new opis();
            string itemz = "items";

            if (conpar[itemz].getPartitionIdx(item.PartitionName) != -1)
            {
                return(conpar);
            }

            if (conpar["subcon"].listCou == 0)
            {
                return(new opis());
            }
            else
            {
                for (int i = 0; i < conpar["subcon"].listCou; i++)
                {
                    if (!rez.isInitlze)
                    {
                        rez = RecurseFindItem(conpar["subcon"][i], item);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return(rez);
        }
Пример #16
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)));
            //}
        }
Пример #17
0
        public override void Process(opis message)
        {
            var Root = new opis();

            BuildLevel(o, Root);
            message.CopyArr(Root);
        }
Пример #18
0
        public override void Process(opis message)
        {
            opis arg = message.W("arg");

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

            instanse.ExecActionResponceModelsList(ptt, ptt);


            opis processThis = arg;

            if (ptt.isInitlze)
            {
                processThis = opis.GetLevelByTemplate(ptt[0], arg, true);
            }

            if (
                processThis != null &&
                (
                    (IsOdd(processThis.intVal) && !modelSpec.isHere(NOT))
                    ||
                    (!IsOdd(processThis.intVal) && modelSpec.isHere(NOT))
                )
                )
            {
                message["pass"].body = "y";
                message["passCou"].intVal++;
                message["range"].intVal++;
            }
        }
Пример #19
0
        public void Run(List <string> prefixes)
        {
            var listener = new HttpListener();

            foreach (var p in prefixes)
            {
                listener.Prefixes.Add(p);
            }

            listener.Start();

            serve = true;

            while (serve)
            {
                try
                {
                    var context = listener.GetContext();
                    HandleRequest(context);
                    //  ThreadPool.QueueUserWorkItem(o => HandleRequest(context));
                }
                catch (Exception)
                {
                    // Ignored for this example
                }
            }

            listener.Stop();

            opis err = new opis();

            err.PartitionName = "http listener stopped ";
            global_log.log.AddArr(err);
        }
Пример #20
0
        opis GetLevelCheck(opis templ, opis srs, bool unwrap)
        {
            opis rez = null;

            if (srs.getPartitionIdx(templ.PartitionName) != -1)
            {
                rez = srs[templ.PartitionName];

                if (unwrap && rez.PartitionKind == "wrapper")
                {
                    rez = rez.W();
                }

                bool haveSubitems  = templ.listCou > 0;
                bool foundSubitems = false;
                for (int i = 0; i < templ.listCou; i++)
                {
                    opis tmp = GetLevelCheck(templ[i], rez, unwrap);
                    if (tmp != null && tmp.isInitlze)
                    {
                        foundSubitems = true;
                        rez           = tmp;
                        break;
                    }
                }

                if (haveSubitems && !foundSubitems)
                {
                    rez = null;
                }
            }

            return(rez);
        }
Пример #21
0
        public override void Process(opis message)
        {
            opis arg = message.W("arg");

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

            instanse.ExecActionResponceModelsList(ptt, ptt);

            //logopis["debug_template"] = ptt;
            //logopis.WrapByName(arg, "arg");

            opis processThis = arg;

            if (ptt.isInitlze)
            {
                processThis = opis.GetLevelByTemplate(ptt[0], arg, true);
            }

            bool pass = check(processThis);

            if (processThis != null &&
                (pass ||
                 (!pass && modelSpec.isHere(NOT))))
            {
                //logopis["debug_pass"].body = "y";
                message["pass"].body = "y";
                message["passCou"].intVal++;
                message["range"].intVal++;
            }

            //if (processThis == null)
            //    logopis["partition not found"].body = "";
        }
Пример #22
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);
        }
Пример #23
0
        public override void Process(opis message)
        {
            //CTX.Handle(CTX.GoUp());
            //message.body = CTX.organizer;

            message.body = CTX.GoUp().V(context.Organizer);
        }
Пример #24
0
        public opis GetModel(string name)
        {
            ModelInfo m;

            if (models.TryGetValue(name.Trim(), out m))
            {
                opis dm = m.DataModel;

                for (int i = 0; i < dm.listCou; i++)
                {
                    if (!string.IsNullOrEmpty(dm[i].PartitionKind) &&
                        dm[i].PartitionKind != name)   // to avoid recursive infinite construction
                    {
                        opis pmdl = GetModel(dm[i].PartitionKind);
                        if (pmdl.isInitlze)
                        {
                            dm[dm[i].PartitionName] = pmdl;
                        }
                    }
                }

                return(dm);
            }
            else
            {
                return(new opis());
            }
        }
Пример #25
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;
        }
Пример #26
0
        public void initInstances(opis o)
        {
            global_log.log.CopyArr(new opis());
            CTX.Handle(o);

            var sentence = context.Find("sentence_context");

            StartPreparationMessages = sentence["preparation messages"].DuplicateA();

            ModelFactory.hotkeys = sentence["hotkeys"].DuplicateA();

            CTX.AddRootElem(sentence);
            SysInstance.Words = context;

            o["globalcomm"] = new opisEventsSubscription();
            o["globalcomm"].PartitionKind = "communicator";

            for (int i = 0; i < o["sys"].listCou; i++)
            {
                opis curr = o["sys"][i];

                opis p = context.Find(curr.PartitionName.Trim()).DuplicateA();
                if (!p.isInitlze)
                {
                    continue;
                }

                p.InitFuncObj2();
                o["sys_instances"].AddArr(p);
                p.Process("bind", o);
            }
        }
Пример #27
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();

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

                int spi = proc[i].IndexOf("\t");
                if (spi > 0)
                {
                    string name = proc[i].Substring(0, spi);
                    string val  = proc[i].Substring(spi + 1);

                    d.Vset(name, val);
                }
                else
                {
                    d.Vset("not header format " + i.ToString(), proc[i]);
                }
            }

            message["data"] = d;
        }
Пример #28
0
        public void igniteTree()
        {
            for (int i = 0; i < StartPreparationMessages.paramCou; i++)
            {
                contextToIgnite["globalcomm"][StartPreparationMessages[i].PartitionName] = StartPreparationMessages[i].DuplicateA();
            }


            //contextToIgnite["globalcomm"]["контекстречення"] = new opis("message", "body GenerateTags");
            //contextToIgnite["globalcomm"]["all"] = new opis("message", "body GenerateTags");

            if (contextParameterizeMessages != null)
            {
                for (int i = 0; i < contextParameterizeMessages.listCou; i++)
                {
                    contextToIgnite["globalcomm"].AddArr(contextParameterizeMessages[i]);
                }
            }

            contextToIgnite["globalcomm"]["all"] = new opis("message", "body start");

            if (messagesToSend != null)
            {
                for (int i = 0; i < messagesToSend.listCou; i++)
                {
                    contextToIgnite["globalcomm"].AddArr(messagesToSend[i]);
                }
            }

            contextToIgnite["globalcomm"]["контекстречення"] = new opis("message", "body NotifyFinished");
        }
Пример #29
0
 public void GetLogForThisins()
 {
     logopis = new opis(name);
     thisins["Models_log"].AddArr(logopis);
     logopis.CopyArr(modelSpec);
     logopis.body = modelSpec.V("_path_");
 }
Пример #30
0
        public opis SendMsg(string receiverClass, opis message)
        {
            lock (scriptLocker)
            {
                if (ScriptContext != null)
                {
                    try
                    {
                        //var gk = ScriptContext[OntologyTreeBuilder.globalcomm];
                        //gk[receiverClass] = message;
                        ScriptContext[OntologyTreeBuilder.globalcomm][receiverClass] = message;
                    }
                    catch (Exception e)
                    {
                        opis rez = message[MsgTemplate.p];
                        rez.Vset("Exception", e.Message);
                        rez.Vset("InnerException", e.InnerException?.Message);
                        rez.Vset("StackTrace", e.StackTrace);
                        rez.Vset("InnerException StackTrace", e.InnerException?.StackTrace);
                    }
                }
            }

            return(message[MsgTemplate.p]); // receiverClass put responce back via the received message, responce data is placed in the partition 'p' where was parameter of the message
        }