Пример #1
0
        static void UploadTransaction(CancellationTokenSource waker, SessionClient client, string p)
        {
            // string p = Path.get(filename);
            byte[] f   = File.ReadAllBytes(p);
            string b64 = AESHelper.Encode64(f);

            AnsonMsg    jmsg = client.Update(uri, "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(uri, null, "a_attaches")
                  .WhereEq("busiTbl", "a_users")
                  .WhereEq("busiId", "admin")
                  .Post((AnInsertReq.formatInsertReq(null, "a_attaches", "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 );
                          new OnUploadError());

            succeed = true;
            waker.Cancel();
        }
Пример #2
0
        // [TestMethod()]
        public void TestMenu(string s, string roleId)
        {
            AnDatasetReq req = new AnDatasetReq(uri, null);

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

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

            jmsg.Header(header);

            client.Console(jmsg);

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