Exemple #1
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);
            }
        }
Exemple #2
0
        public override void Process(opis message)
        {
            opis locSeq   = modelSpec[sequence].Duplicate();
            opis locModel = modelSpec;

            message = message.PartitionKind == "wrapper" ? message.W() : message;


            opis srs = message;

            if (locModel[source].isInitlze || !string.IsNullOrEmpty(locModel[source].PartitionKind))
            {
                srs = locModel[source].Duplicate();
                instanse.ExecActionModel(srs, srs);
            }

            opis idx = new opis();

            SharedContextRoles.SetRole(idx, SharedContextRoles.ProcessIndex, sharedVal);

            string rl = SharedContextRoles.procItem;

            if (locModel[role].isInitlze)
            {
                rl = locModel[role].body;
            }

            bool backward = locModel.OptionActive(move_backward);
            bool procItm  = locModel.OptionActive(models_process_item);

            for (int i = 0; i < srs.listCou; i++)
            {
                int pos = i;
                if (backward)
                {
                    pos = srs.listCou - i - 1;
                }

                if (procItm)
                {
                    instanse.ExecActionResponceModelsList(locSeq.Duplicate(), srs[pos].W());
                }
                else
                {
                    SharedContextRoles.GetRole(SharedContextRoles.ProcessIndex, sharedVal).intVal = pos;
                    SharedContextRoles.SetRole(srs[pos].W(), rl, sharedVal);

                    instanse.ExecActionModelsList(locSeq.Duplicate());
                }

                // повертаємо інстанс в поточний контекст
                instanse.Handle(o); //на випадок коли інстанс може отримувати повідомлення
                // чи відповіді в процесі виконання попереднього циклу
                // отримавши повідомлення змінюється поточний контекст інстанса
                // і через це наступний цикл не має доступу до SDC - виникає збій
            }
        }
Exemple #3
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());
            }
        }
Exemple #4
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");
        }
Exemple #5
0
        public override void Process(opis message)
        {
            opis source = o;

            if (modelSpec[sdc_Role].isInitlze)
            {
                source = SharedContextRoles.GetRole(modelSpec[sdc_Role].body, sharedVal);
            }
            if (source != null)
            {
                opis t = contex.GetHierarchyStub(source);
                message.body = t.body;
                message.CopyArr(t);
            }
        }
        public override void Process(opis message)
        {
            if (message.PartitionKind == name)
            {
                message.PartitionKind += "_done";
            }

            if (message.listCou > 0 && message.getPartitionIdx(Wrap) == -1)
            {
                string name = message[0].PartitionName;
                opis   tmp  = SharedContextRoles.GetRole(name, sharedVal);

                message.body = tmp.body;
                message.CopyArr(tmp);

                if (modelSpec.getPartitionIdx(Wrap) != -1)
                {
                    message.Wrap(tmp);
                }
                else
                {
                    message.body = tmp.body;
                    message.CopyArr(tmp);
                }
            }
            else
            {
                string name = message.body;
                if (!string.IsNullOrEmpty(name))
                {
                    opis tmp = SharedContextRoles.GetRole(name, sharedVal);

                    if (modelSpec.getPartitionIdx(Wrap) != -1)
                    {
                        message.Wrap(tmp);
                    }
                    else
                    {
                        message.body = tmp.body;
                        message.CopyArr(tmp);
                    }
                }
            }
        }
        public override void Process(opis message)
        {
            if (modelSpec.getPartitionIdx(do_not_exec) == -1)
            {
                instanse.ExecActionModelsList(message);
            }

            opis rol = modelSpec[set_role].Duplicate();

            instanse.ExecActionModel(rol, rol);

            if (modelSpec.getPartitionIdx(set_role) != -1)
            {
                SharedContextRoles.SetRole(message, rol.body, sharedVal);
            }
            else
            {
                sharedVal.AddArr(message);
            }
        }
Exemple #8
0
        public override void Process(opis message)
        {
            opis args = modelSpec[word].Duplicate();

            instanse.ExecActionModel(args, args);

            //logopis.WrapByName(args, "word");

            if (args.isInitlze)
            {
                if (modelSpec[Create_instance].isInitlze)
                {
                    instanse.CreateInstance(args.body);
                }


                opis t = instanse.GetWordForm(args.body).Duplicate();

                SharedContextRoles.SetRole(t, modelSpec.isHere(role) ? modelSpec[role].body : "NotionWord", sharedVal);
                message.body = t.body;
                message.CopyArr(t);
            }
        }
Exemple #9
0
        public override void Process(opis message)
        {
            opis data      = new opis();
            opis curr_data = data;

            data.PartitionName = "root";

            opis treeStruct = new opis();

            treeStruct["data"].Wrap(curr_data);

            opis curr_value = new opis();

            opis ex = modelSpec.Duplicate();

            instanse.ExecActionModelsList(ex);
            modelSpec = ex;

            string filename = modelSpec.V(file).Replace("<%backslash%>", @"\");

            string[] proc = DataFileUtils.LoadLines(filename);

            string format = "my";

            if (modelSpec[format_type].listCou > 0)
            {
                format = modelSpec[format_type][0].PartitionName;
            }

            if (format != "my")
            {
                opis paramToParser = new opis("stringArray", (object)proc);

                instanse.ExecActionResponceModelsList(modelSpec[format_type], paramToParser);

                data = paramToParser["data"];
            }

            #region  tree structure from 1c (MY format)

            if (format == "my")
            {
                foreach (string s in proc)
                {
                    string ds = s.Trim();
                    if (string.IsNullOrEmpty(ds))
                    {
                        continue;
                    }

                    if (ds == "{" || ds == "}")
                    {
                        if (ds == "{")
                        {
                            opis treeStructProc = new opis();
                            treeStructProc["higher"] = treeStruct;
                            curr_data = curr_value;
                            treeStructProc["data"].Wrap(curr_data);
                            treeStruct = treeStructProc;
                        }

                        if (ds == "}")
                        {
                            treeStruct = treeStruct["higher"];
                            //if (!treeStruct.isInitlze)
                            //    logopis.Vset(curr_data.PartitionName, "err: parent object not found");

                            curr_data = treeStruct["data"].W();
                        }
                    }
                    else
                    {
                        //opis treeStructProc = new opis();
                        //treeStructProc["higher"] = treeStruct;

                        opis vvv = new opis();
                        curr_data[ds] = vvv;
                        curr_value    = vvv;

                        //treeStructProc["data"].Wrap(curr_data);
                        //treeStruct = treeStructProc;
                    }
                }
            }

            #endregion

            SharedContextRoles.SetRole(data, modelSpec.isHere(role) ? modelSpec[role].body : "Data_loaded", sharedVal);

            if (modelSpec.isHere(FillMessage))
            {
                message.CopyArr(data);
            }
        }
        //TODO: find out why filler (in log it is comon bug) return arbitrary values
        //TODO: find out why decode text _ modify its source value

        public override void Process(opis message)
        {
            opis source = null;

            opis currSpec = modelSpec;

            int pnIdx = modelSpec.getPartitionIdx(sdc_item);

            if (pnIdx != -1)
            {
                opis svc = sharedVal;
                opis p   = modelSpec[pnIdx].Duplicate();
                instanse.ExecActionModel(p, p);

                int pos = svc.getPartitionIdx(p.body);
                source = pos != -1 ? svc[pos] : null;

                if (source == null && currSpec.OptionActive(create))
                {
                    source = svc[p.body];
                }
            }
            else

            if (modelSpec.isHere(sdc_Role))
            {
                opis p = modelSpec[sdc_Role].Duplicate();
                instanse.ExecActionModel(p, p);

                source = SharedContextRoles.GetRole(p.body, sharedVal);
                if (source.PartitionKind == "null" && currSpec[create].isInitlze)
                {
                    source = new opis();
                    SharedContextRoles.SetRole(source, p.body, sharedVal);
                }

                if (source.PartitionKind == "null")
                {
                    source = null;
                }
            }
            else

            if (modelSpec.getPartitionIdx(thisins_data) != -1)
            {
                source = thisins;
            }
            else
            if (modelSpec.getPartitionIdx(spec_data) != -1)
            {
                source = spec;
            }

            modelSpec = currSpec;

            if (source != null)
            {
                opis rez = source;

                opis templ = modelSpec.getPartitionNotInitOrigName(template)?.Duplicate();
                if (templ != null)
                {
                    instanse.ExecActionModel(templ, templ);

                    if (templ.listCou > 0)
                    {
                        rez = GetLevelCheck(templ[0], source.W(), modelSpec.OptionActive(templateUnwrap));
                    }
                }


                modelSpec = currSpec;

                if (rez != null)
                {
                    // in case modelSpec and message referencing the same data
                    opis procSpec = modelSpec.getPartitionNotInitOrigName(process)?.Duplicate();

                    rez = rez.W();

                    if (currSpec.OptionActive(duplicate))
                    {
                        rez = rez.Duplicate();
                    }

                    if (!currSpec.OptionActive(do_not_modify))
                    {
                        if (currSpec.OptionActive(do_wrap))
                        {
                            message.CopyArr(new opis());
                            message.Wrap(rez.W());
                        }
                        else
                        {
                            message.body = rez.body;
                            message.CopyArr(rez);
                        }

                        if (message.PartitionKind == name)
                        {
                            message.PartitionKind += "_done";
                        }
                    }

                    if (procSpec != null)
                    {
                        instanse.ExecActionResponceModelsList(procSpec, rez);
                    }
                }
                else if (!currSpec.OptionActive(do_not_modify))
                {
                    message.body = "";
                    message.CopyArr(new opis());
                }
            }
            else
            {
                if (message.PartitionName == "value")
                {
                    message.CopyArr(new opis());
                }
            }
        }
Exemple #11
0
        public override void Process(opis message)
        {
            opis bp     = modelSpec[blueprint].Duplicate();
            var  locmod = modelSpec;

            instanse.ExecActionModel(bp, bp);
            modelSpec = locmod;

            opis vk = sharedVal;

            if (bp.listCou > 0)
            {
                if (modelSpec.isHere(values_container, false))
                {
                    opis t = null;
                    if (modelSpec[values_container].isInitlze ||
                        !string.IsNullOrEmpty(modelSpec[values_container].PartitionKind))
                    {
                        t = modelSpec[values_container].Duplicate();

                        locmod = modelSpec;
                        instanse.ExecActionModel(t, t);
                        modelSpec = locmod;
                    }
                    else
                    {
                        t = SharedContextRoles.GetRole("valuesContainer", sharedVal);
                    }

                    vk = t.W();
                }

                build(bp, null, vk, modelSpec.isHere(func_symbols_ignore, false), modelSpec.isHere(only_body_template_optimization, false));


                if (bp.listCou == 1)
                {
                    if (locmod.isHere(putWholeResult, false))
                    {
                        message.PartitionKind = "";
                        message.CopyArr(bp);
                        return;
                    }

                    if (message.PartitionName == "value")
                    {
                        if (modelSpec.isHere(only_value_body))
                        {
                            message.CopyArr(new opis());
                            message.body = bp[0].body;
                        }
                        else
                        {
                            message.Wrap(bp[0]);
                        }
                    }
                    else
                    {
                        message.body          = bp[0].body;
                        message.PartitionName = string.IsNullOrEmpty(bp[0].PartitionName) ? message.PartitionName : bp[0].PartitionName;
                        message.PartitionKind = bp[0].PartitionKind;
                        if (modelSpec.isHere(only_value_body, false))
                        {
                            message.CopyArr(new opis());
                        }
                        else
                        {
                            message.CopyArr(bp[0]);
                        }
                    }
                }
                else
                {
                    message.PartitionKind = "";
                    message.CopyArr(bp);
                }
            }
        }
Exemple #12
0
        public override void Process(opis message)
        {
            opis args        = modelSpec[arguments].Duplicate();
            opis crit        = modelSpec[range_criterias].Duplicate();
            opis arrPassRole = modelSpec[form_array_of_positively_ranged].Duplicate();

            instanse.ExecActionModelsList(crit);
            instanse.ExecActionModel(crit, crit);

            instanse.ExecActionModelsList(args);
            instanse.ExecActionModel(args, args);

            instanse.ExecActionModel(arrPassRole, arrPassRole);

            opis arrPass = null;

            if (arrPassRole.isInitlze)
            {
                arrPass = new opis();
                SharedContextRoles.SetRole(arrPass, arrPassRole.body, sharedVal);
            }


            //logopis["args"].Wrap( args);
            //logopis["crit"] = crit;

            //instanse.ExecParamModels(curr);

            opis ranging = new opis();

            ranging.PartitionName = "ranging array";
            //logopis.AddArr(ranging);
            bool do_range = modelSpec.isHere(range_func);

            for (int c = 0; c < crit.listCou; c++)
            {
                //instanse.ExecParamModels(crit[c]);
                instanse.ExecActionModelsList(crit[c]);
                for (int i = 0; i < args.listCou; i++)
                {
                    if (do_range)
                    {
                        int vvv = RangeByModel(crit[c], args[i].W());
                        ranging[args[i].PartitionName + "_" + i.ToString()][crit[c].PartitionName].intVal = vvv;

                        if (arrPass != null && vvv > 0)
                        {
                            arrPass.AddArr(args[i].W());
                        }
                    }
                    else
                    {
                        ranging[args[i].PartitionName + "_" + i.ToString()][crit[c].PartitionName].intVal = args[i].CheckConformity(args[i], crit[c]);
                    }
                }
            }

            opis ranges = ranging;

            thisins["Models_log"].AddArr(ranges);

            for (int c = 0; c < crit.listCou; c++)
            {
                int  minDiff = -1;
                int  bestmin = -1;
                uint average = 0;

                for (int i = 0; i < ranges.listCou; i++)
                {
                    int minDiffLoc = 10000000;
                    int currDiff   = 0;
                    int thisval    = ranges[i][crit[c].PartitionName].intVal;
                    for (int k = 0; k < ranges[i].listCou; k++)
                    {
                        if (ranges[i][k].PartitionName != crit[c].PartitionName)
                        {
                            currDiff = thisval - ranges[i][k].intVal;
                            average += (uint)(ranges[i][k].intVal > 0 ? 3 : 0);
                        }
                        else
                        {
                            currDiff = 10000000;
                        }

                        if (currDiff < minDiffLoc)
                        {
                            minDiffLoc = currDiff;
                        }
                    }
                    average += (uint)(thisval > 0 ? 3 : 0);

                    // якщо мінімальна перевага даного параметру над іншими позитивна, і найбільна з наявних
                    // то даний параметр береться як найпідходящий
                    if (minDiffLoc >= 0 && minDiffLoc > minDiff)
                    {
                        minDiff = minDiffLoc;
                        bestmin = i;
                    }
                }

                // average > 0 критерій того, що є позитивно ранжовані обєкти на це місце
                // якщо всі нулі, тоді взагалі не встановлюємо значення
                if (bestmin >= 0 && average > 0)
                {
                    char[] numb = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };

                    string parameterId = crit[c].PartitionName;
                    int    puy         = parameterId.IndexOfAny(numb);
                    if (puy != 0)
                    {
                        opis featest = args[bestmin].W();
                        SharedContextRoles.SetRole(featest, parameterId, sharedVal);
                    }
                }
                else
                {
                    //logopis.Vset(crit[c].PartitionName+"  значення не встановлено", "average " + average.ToString());
                }
            }
        }
Exemple #13
0
        public override void Process(opis message)
        {
            if (hc == null)
            {
                hc = new httpClient();
            }

            hc.ClearAdditionHeaders();

            opis ex = modelSpec.Duplicate();

            instanse.ExecActionModelsList(ex);

            opis headerz = ex[Headers];

            for (int i = 0; i < headerz.listCou; i++)
            {
                if (!headerz[i].PartitionName.StartsWith("not header format"))
                {
                    hc.AddHeader(headerz[i].PartitionName + ":" + headerz[i].body);
                }
            }

            hc.AcceptAllCertificates = ex[AcceptAllCertificate][AcceptAllCertificate].isInitlze;
            hc.allowAutoRedrect      = ex.isHere(allowAutoRedrect);

            bool rez = false;

            instanse.ExecActionModel(ex[dataToPost], ex[dataToPost]);

            string data = ex.V(dataToPost);

            if (ex.V(post_data_encoding) == "Kirill_to_UTF")
            {
                data = TemplatesMan.Kirill_to_UTF(data);
            }

            if (ex.V(post_data_encoding) == "url_encode")
            {
                data = TemplatesMan.Url_encode(data);
            }

            //if (ex[ProxySettings].isInitlze)// PROXY
            hc.proxySettings = ex[ProxySettings].W();

            opis t = new opis();

            t["request"] = ex;

            if ((ex.isHere(POST) && string.IsNullOrEmpty(ex.V(POST))) ||
                (ex.isHere(GET) && string.IsNullOrEmpty(ex.V(GET))))
            {
                t[webResponceModel.Status].body = "fail";
                t.Vset("Error", "you pass empty url");
                SharedContextRoles.SetRole(t, ex.isHere(role) ? ex[role].body : "responce", sharedVal);
                return;
            }

            try
            {
                if (ex.isHere(POST))
                {
                    rez = hc.Post(ex.V(POST), data);
                }

                if (ex.isHere(GET))
                {
                    rez = hc.Get(ex.V(GET));
                }


                if (ex.isHere(DownloadResource))
                {
                    var fi = hc.DownloadData(ex.V(DownloadResource), ex[DownloadResource].V(upLoadFileSpecs.CompiledFilename));
                    rez = fi == null ? false : fi.Exists && fi.Length > 100;
                }

                if (ex.isHere(DownloadBytes))
                {
                    var fi = hc.DownloadBytes(ex.V(DownloadBytes));
                    rez = fi == null ? false : fi.Length > 0;
                    t[webResponceModel.responseData]["data"].bodyObject = fi;
                    t[webResponceModel.responseData].Vset("length", (fi == null ? 0 : fi.Length).ToString());
                }


                if (ex.isHere(UP_loadResource))
                {
                    t[webResponceModel.Status].body = hc.UploadData(ex.V(UP_loadResource), ex[UP_loadResource].V(upLoadFileSpecs.CompiledFilename));
                    SharedContextRoles.SetRole(t, ex.isHere(role) ? ex[role].body : "responce", sharedVal);
                    return;
                }

                if (ex.isHere(UP_loadResource_put))
                {
                    t[webResponceModel.Status].body = hc.UploadFilePut(ex.V(UP_loadResource_put), ex[UP_loadResource_put].V(upLoadFileSpecs.CompiledFilename));
                    SharedContextRoles.SetRole(t, ex.isHere(role) ? ex[role].body : "responce", sharedVal);
                    return;
                }
            }
            catch (NullReferenceException e)
            {
                t.Vset("internal error", e.Message);
            }


            t[webResponceModel.Status].body = rez.ToString();

            if (!string.IsNullOrEmpty(hc.RedirectLocation))
            {
                t.Vset("RedirectLocation", hc.RedirectLocation);
            }

            if (ex.isHere(DownloadResource))
            {
                t["filename"].body = ex[DownloadResource].V(upLoadFileSpecs.CompiledFilename);
            }
            //t.Vset(webResponceModel.responseData, hc.responseData);

            if (!ex.isHere(DownloadBytes) && !ex.isHere(DownloadResource))
            {
                t[webResponceModel.responseHeaders] = hc.responceHeaders;

                t.Vset(webResponceModel.responseData, hc.responseData.Replace("\n", " "));
                var NewCookies = hc.NewCookies;
                t.Vset(webResponceModel.NewCookies, NewCookies);

                #region NewCookies

                if (NewCookies != null)
                {
                    string[] cookarr = NewCookies.Split(';');
                    foreach (string s in cookarr)
                    {
                        //opis o = new opis();
                        int spi = s.IndexOf('=');
                        if (spi > 0)
                        {
                            string name = s.Substring(0, spi);
                            string val  = s.Substring(spi + 1);

                            //o.Vset(name, val);
                            t[webResponceModel.NewCookies].Vset(name.Trim(), val);;
                        }
                    }
                }

                #endregion

                if (hc.responseData != null &&
                    !hc.responseData.StartsWith("<!DOCTYPE html") &&
                    !hc.responseData.StartsWith("<") &&
                    hc.contentType != null &&
                    hc.contentType.Contains("application/json"))
                {
                    if (hc.responseData.Contains("\n"))
                    {
                        hc.responseData = hc.responseData.Replace('\n', ' ');
                    }

                    opis trtrt = new opis();
                    trtrt.JsonParce(hc.responseData);
                    t[webResponceModel.responseDataParsed]["jsonObj"] = trtrt;
                }
            }

            hc.responseData = null;


            SharedContextRoles.SetRole(t, ex.isHere(role) ? ex[role].body : "responce", sharedVal);
        }