Search in sources :

Example 76 with Callback

use of zipkin2.Callback in project Gradle-demo by Arisono.

the class testUASApi method getFormandGridDetail.

/**
 * 接口 获取动态表单数据--请假单
 *
 * @throws UnsupportedEncodingException
 *             Workovertime Ask4Leave
 */
public static void getFormandGridDetail(final String caller) {
    String url = baseurl + "mobile/getformandgriddetail.action?caller=" + caller + "&condition=1=1" + "&sessionId=" + sessionId + "&id=-1";
    OkhttpUtils.println(url);
    Request request = new Request.Builder().url(url).header("cookie", "JSESSIONID=" + sessionId).addHeader("sessionUser", emcode).addHeader("content-type", "text/html;charset:utf-8").build();
    OkhttpUtils.client.newCall(request).enqueue(new Callback() {

        @Override
        public void onResponse(Call call, Response response) throws IOException {
            OkhttpUtils.println(caller + ":" + OkhttpUtils.getResponseString(response));
        }

        @Override
        public void onFailure(Call call, IOException e) {
            OkhttpUtils.onFailurePrintln(e);
        }
    });
}
Also used : Response(okhttp3.Response) Call(okhttp3.Call) Callback(okhttp3.Callback) Request(okhttp3.Request) IOException(java.io.IOException)

Example 77 with Callback

use of zipkin2.Callback in project Gradle-demo by Arisono.

the class testUASApi method getStringCode.

public static void getStringCode(String method) {
    // master=USOFTSYS, sessionUser=U0316, sessionId=29DB60DE6E40D859B9169FE5013A8520, caller=CardLog, type=2
    String url = baseurl + "common/getCodeString.action";
    RequestBody formBody = new FormBody.Builder().add("master", master).add("type", "2").add("caller", "CardLog").add("sessionId", sessionId).build();
    Request request = new Request.Builder().url(url).header("Cookie", "JSESSIONID=" + sessionId).post(formBody).build();
    OkhttpUtils.client.newCall(request).enqueue(new Callback() {

        @Override
        public void onResponse(Call call, Response response) throws IOException {
            String result = OkhttpUtils.getResponseString(response);
            OkhttpUtils.println(result, OkhttpUtils.typeMiddle, method);
            code = JSON.parseObject(result).getString("code");
            saveCardLog("32.12", code, "saveCardLog");
        }

        @Override
        public void onFailure(Call call, IOException e) {
            OkhttpUtils.onFailurePrintln(e);
        }
    });
}
Also used : Response(okhttp3.Response) Call(okhttp3.Call) Callback(okhttp3.Callback) FormBody(okhttp3.FormBody) Request(okhttp3.Request) IOException(java.io.IOException) RequestBody(okhttp3.RequestBody)

Example 78 with Callback

use of zipkin2.Callback in project Gradle-demo by Arisono.

the class testUASApi method getDBFindData.

/**
 * @category 多选接口
 */
public static void getDBFindData() {
    String url = baseurl + "common/dbfind.action";
    RequestBody formBody = new FormBody.Builder().add("master", master).add("which", "form").add("pageSize", "5").add("condition", "1=1").add("field", "va_emname").add("caller", "Ask4Leave").add("sessionId", sessionId).add("page", "1").build();
    Request request = new Request.Builder().url(url).header("cookie", "JSESSIONID=" + sessionId).addHeader("sessionUser", emcode).addHeader("content-type", "text/html;charset:utf-8").post(formBody).build();
    OkhttpUtils.client.newCall(request).enqueue(new Callback() {

        @Override
        public void onResponse(Call call, Response response) throws IOException {
            String json = OkhttpUtils.getResponseString(response);
            OkhttpUtils.println(json);
            String dataStr = JSON.parseObject(json).getString("data");
            // values
            JSONArray datas = JSON.parseArray(dataStr);
            System.out.println(datas.getJSONObject(0).getString("em_name"));
            JSONArray dbfinds = JSON.parseObject(json).getJSONArray("dbfinds");
            String fieldkey = "";
            for (int i = 0; i < dbfinds.size(); i++) {
                JSONObject item = dbfinds.getJSONObject(i);
                String key = item.getString("field");
                if (key.equals("va_emname")) {
                    System.out.println(item.getString("dbGridField"));
                    fieldkey = item.getString("dbGridField");
                }
            }
            System.out.println("url:" + url);
            System.out.println("master:" + master);
            System.out.println("emcode:" + emcode);
            for (int i = 0; i < datas.size(); i++) {
                System.out.println("value" + i + ":" + datas.getJSONObject(i).getString(fieldkey));
            }
        }

        @Override
        public void onFailure(Call call, IOException e) {
            OkhttpUtils.onFailurePrintln(e);
        }
    });
}
Also used : Call(okhttp3.Call) FormBody(okhttp3.FormBody) Request(okhttp3.Request) JSONArray(com.alibaba.fastjson.JSONArray) IOException(java.io.IOException) Response(okhttp3.Response) Callback(okhttp3.Callback) JSONObject(com.alibaba.fastjson.JSONObject) RequestBody(okhttp3.RequestBody)

Example 79 with Callback

use of zipkin2.Callback in project Gradle-demo by Arisono.

the class testUASApi method loginB2B.

// 登录 B2BString user, String password
public static void loginB2B() {
    String url = "https://account.ubtob.com/sso/login";
    RequestBody formBody = new FormBody.Builder().add("appId", "sso").add("username", "13266703535").add("spaceId", "81744").add("password", "1").build();
    Request request = new Request.Builder().url(url).addHeader("content-type", "text/html;charset:utf-8").post(formBody).build();
    OkhttpUtils.println(url);
    OkhttpUtils.client.newCall(request).enqueue(new Callback() {

        @Override
        public void onResponse(Call call, Response response) throws IOException {
            OkhttpUtils.println("size:" + JSON.toJSONString(response.headers().size()));
            OkhttpUtils.println("size 4:" + JSON.toJSONString(response.headers().name(4)));
            OkhttpUtils.println("size 5:" + JSON.toJSONString(response.headers().name(5)));
            // 打印完整的cookie
            OkhttpUtils.println("all hearders:" + JSON.toJSONString(response.headers().toString()));
            // 打印完整的json格式数据
            OkhttpUtils.println("all hearders:" + JSON.toJSONString(response.headers().toMultimap()));
            // 打印多个key为 Set-Cookie的值
            OkhttpUtils.println("set-cookie:" + JSON.toJSONString(response.headers("Set-Cookie")));
            // 打印多个key,多个key会自动放入数组里面
            OkhttpUtils.println("set-cookie:" + JSON.toJSONString(response.header("Set-Cookie")));
            OkhttpUtils.println("set-cookie 5:" + JSON.toJSONString(response.headers().value(5)));
            OkhttpUtils.println("set-cookie 6:" + JSON.toJSONString(response.headers().value(6)));
            OkhttpUtils.println(JSON.toJSONString(response));
            String json = OkhttpUtils.getResponseString(response);
            OkhttpUtils.println("b2b登录:" + json);
            cookies = response.headers().value(5) + ";" + response.headers().value(6);
            checkLoginAtB2B(cookies);
        }

        @Override
        public void onFailure(Call call, IOException e) {
            OkhttpUtils.onFailurePrintln(e);
        }
    });
}
Also used : Response(okhttp3.Response) Call(okhttp3.Call) Callback(okhttp3.Callback) FormBody(okhttp3.FormBody) Request(okhttp3.Request) IOException(java.io.IOException) RequestBody(okhttp3.RequestBody)

Example 80 with Callback

use of zipkin2.Callback in project Gradle-demo by Arisono.

the class testUASApi method getStagePoints.

public static void getStagePoints() {
    String url = baseurl + "mobile/crm/getStagePoints.action";
    RequestBody formBody = new FormBody.Builder().add("bccode", "2016120035").add("currentStep", "testpoints").add("master", master).build();
    OkhttpUtils.println(url);
    Request request = new Request.Builder().url(url).header("cookie", "JSESSIONID=" + sessionId).addHeader("sessionUser", emcode).addHeader("content-type", "text/html;charset:utf-8").post(formBody).build();
    OkhttpUtils.client.newCall(request).enqueue(new Callback() {

        @Override
        public void onResponse(Call call, Response response) throws IOException {
            String json = OkhttpUtils.getResponseString(response);
            OkhttpUtils.println("getStagePoints():" + json);
        }

        @Override
        public void onFailure(Call call, IOException e) {
            OkhttpUtils.onFailurePrintln(e);
        }
    });
}
Also used : Response(okhttp3.Response) Call(okhttp3.Call) Callback(okhttp3.Callback) Request(okhttp3.Request) IOException(java.io.IOException) RequestBody(okhttp3.RequestBody)

Aggregations

Callback (okhttp3.Callback)173 IOException (java.io.IOException)137 Call (okhttp3.Call)132 Response (okhttp3.Response)132 Request (okhttp3.Request)110 Callback (retrofit2.Callback)42 Call (retrofit2.Call)41 Test (org.junit.Test)39 Response (retrofit2.Response)39 RequestBody (okhttp3.RequestBody)37 OkHttpClient (okhttp3.OkHttpClient)34 File (java.io.File)27 Context (android.content.Context)24 JSONObject (org.json.JSONObject)20 FormBody (okhttp3.FormBody)19 ArrayList (java.util.ArrayList)18 View (android.view.View)16 Intent (android.content.Intent)14 TextView (android.widget.TextView)14 GsonBuilder (com.google.gson.GsonBuilder)14