use of retrofit2.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);
}
});
}
use of retrofit2.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);
}
});
}
use of retrofit2.Callback in project Gradle-demo by Arisono.
the class testUASApi method saveCardLog.
public static void saveCardLog(String dis, String code, String method) {
//master=USOFTSYS, sessionUser=U0316, sessionId=29DB60DE6E40D859B9169FE5013A8520, caller=CardLog, type=2
String formStore = "" + "{\"cl_emname\":\"刘杰\"," + "\"cl_distance\":" + dis + "," + "\"cl_time\":" + "2017-05-22 08:22:10" + "," + "\"cl_emcode\":\"U0316\"," + "\"cl_phone\":\"13266699268\"," + "\"cl_code\":\"" + code + "\"," + "\"cl_location\":\"在英唐大厦附近\"," + "\"cl_address\":\"中国广东省深圳市南山区科技南五路5\"}";
OkhttpUtils.println(formStore);
String url = baseurl + "mobile/saveCardLog.action";
RequestBody formBody = new FormBody.Builder().add("master", master).add("caller", "CardLog").add("formStore", formStore).add("sessionId", sessionId).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 result = OkhttpUtils.getResponseString(response);
OkhttpUtils.println(result, OkhttpUtils.typeMiddle, method);
RxBus.getInstance().send(new DownloadRepoMessageEvent("保存成功!"));
}
@Override
public void onFailure(Call call, IOException e) {
OkhttpUtils.onFailurePrintln(e);
}
});
}
use of retrofit2.Callback in project Gradle-demo by Arisono.
the class testUASApi method selectCardLog.
public static void selectCardLog(String date, String method) {
//{master=USOFTSYS, emcode=U0316, pageSize=100, sessionUser=U0316,
//condition=cl_emcode='U0316' and to_char(cl_time,'yyyy-MM-dd')='2017-03-03',
//sessionId=29DB60DE6E40D859B9169FE5013A8520, caller=CardLog, page=1, currentMaster=USOFTSYS}
String url = baseurl + "/mobile/oa/workdata.action";
RequestBody formBody = new FormBody.Builder().add("currentMaster", master).add("master", master).add("emcode", emcode).add("condition", "cl_emcode='U0316' and to_char(cl_time,'yyyy-MM-dd')='" + date + "'").add("caller", "CardLog").add("page", "1").add("sessionId", sessionId).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 result = OkhttpUtils.getResponseString(response);
OkhttpUtils.println(result, OkhttpUtils.typeMiddle, method);
}
@Override
public void onFailure(Call call, IOException e) {
OkhttpUtils.onFailurePrintln(e);
}
});
}
use of retrofit2.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);
}
});
}
Aggregations