Exemple #1
0
        static void UploadTransaction(CancellationTokenSource waker, AnsonClient client, string p)
        {
            // string p = Path.get(filename);
            byte[] f   = File.ReadAllBytes(p);
            string b64 = AESHelper.Encode64(f);

            AnsonMsg    jmsg = client.Update(null, "a_users");
            AnUpdateReq upd  = (AnUpdateReq)jmsg.Body(0);

            upd.Nv("nationId", "CN")
            .WhereEq("userId", "admin")
            // .post(((UpdateReq) new UpdateReq(null, "a_attach")
            .Post(AnUpdateReq.formatDelReq(null, null, "a_attaches")
                  .WhereEq("busiTbl", "a_users")
                  .WhereEq("busiId", "admin")
                  .Post((AnInsertReq.formatInsertReq(null, null, "a_attaches")
                         .Cols("attName", "busiId", "busiTbl", "uri")
                         .Nv("attName", "-Anclient.cs Test")
                         // The parent pk can't be resulved, we must provide the value.
                         // See https://odys-z.github.io/notes/semantics/best-practices.html#fk-ins-cate
                         .Nv("busiId", "admin")
                         .Nv("busiTbl", "a_users")
                         .Nv("uri", b64))));

            jmsg.Header(client.Header());

            client.Console(jmsg);

            client.Commit(jmsg,
                          (code, data) => {
                if (MsgCode.ok == code.code)
                {
                    Utils.Logi(code.ToString());
                }
                else
                {
                    Utils.Warn(data.ToString());
                }
            },
                          onErr: (c, err) => {
                Assert.Fail(string.Format(@"code: {0}, error: {1}", c, err.Msg()));
            },
                          waker);
        }
Exemple #2
0
        public void TestMenu(string s, string roleId)
        {
            AnDatasetReq req = new AnDatasetReq(null, "sys-sqlite");

            string      t      = "menu";
            AnsonHeader header = client.Header()
                                 .UsrAct("SemanticClientTest", "init", t,
                                         "test jclient.java loading menu from menu.sample");

            AnsonMsg jmsg = client.UserReq(new Port(Port.echo), null, req);

            jmsg.Header(header);

            client.Console(jmsg);

            client.Commit(jmsg, (code, data) => {
                IList rses = (IList)((AnDatasetResp)data.Body()?[0]).Forest();
                Utils.Logi(rses);;
            });
        }