|
|
@ -136,21 +136,11 @@ namespace AksWebBrowser.Common |
|
|
|
{ |
|
|
|
{ |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
string body = await PublicSign(type, typeCode, timeout); |
|
|
|
timeout = timeout == 0 ? Parame.timeout : timeout; |
|
|
|
if (!string.IsNullOrEmpty(body)) |
|
|
|
var client = new HttpClient(); |
|
|
|
|
|
|
|
client.Timeout = TimeSpan.FromSeconds(timeout); |
|
|
|
|
|
|
|
var request = new HttpRequestMessage(HttpMethod.Post, Parame.signUrl); |
|
|
|
|
|
|
|
var content = new StringContent("{\r\n \"command\": \"sign\",\r\n \"command_num\": 111,\r\n \"data\": {\r\n \"operation\": \"" + type + "\",\r\n \"operation_code\": " + typeCode + ",\r\n \"parameters\": {\r\n \"data_type\": 1\r\n }\r\n }\r\n}", null, "application/json"); |
|
|
|
|
|
|
|
request.Content = content; |
|
|
|
|
|
|
|
var response = await client.SendAsync(request); |
|
|
|
|
|
|
|
response.EnsureSuccessStatusCode(); |
|
|
|
|
|
|
|
if (response.StatusCode.ToString() == "OK") |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (type == "open" && typeCode == 1) |
|
|
|
if (type == "open" && typeCode == 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// 读取响应内容 |
|
|
|
|
|
|
|
string body = await response.Content.ReadAsStringAsync(); |
|
|
|
|
|
|
|
JObject jo = (JObject)JsonConvert.DeserializeObject(body); |
|
|
|
JObject jo = (JObject)JsonConvert.DeserializeObject(body); |
|
|
|
string ret = jo["ret_info"].ToString(); |
|
|
|
string ret = jo["ret_info"].ToString(); |
|
|
|
JObject jo2 = (JObject)JsonConvert.DeserializeObject(ret); |
|
|
|
JObject jo2 = (JObject)JsonConvert.DeserializeObject(ret); |
|
|
@ -165,6 +155,56 @@ namespace AksWebBrowser.Common |
|
|
|
string sign_pic = jo4["sign_pic"].ToString(); |
|
|
|
string sign_pic = jo4["sign_pic"].ToString(); |
|
|
|
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"success\",\"code\":200,\"status\":true,\"suffix\":\"png\",\"data\":\"" + sign_pic + "\"}"; |
|
|
|
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"success\",\"code\":200,\"status\":true,\"suffix\":\"png\",\"data\":\"" + sign_pic + "\"}"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if (jo2["code"].ToString() == "1") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Task.Delay(1000).Wait(); |
|
|
|
|
|
|
|
//关闭签字版 |
|
|
|
|
|
|
|
await PublicSign("close", 2, timeout); |
|
|
|
|
|
|
|
Task.Delay(1000).Wait(); |
|
|
|
|
|
|
|
//打开签字版 |
|
|
|
|
|
|
|
body = await PublicSign(type, typeCode, timeout); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(body)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
jo = (JObject)JsonConvert.DeserializeObject(body); |
|
|
|
|
|
|
|
ret = jo["ret_info"].ToString(); |
|
|
|
|
|
|
|
jo2 = (JObject)JsonConvert.DeserializeObject(ret); |
|
|
|
|
|
|
|
if (jo2["code"].ToString() == "0") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//读取data数据 |
|
|
|
|
|
|
|
string data = jo["data"].ToString(); |
|
|
|
|
|
|
|
JObject jo3 = (JObject)JsonConvert.DeserializeObject(data); |
|
|
|
|
|
|
|
//读取parameters数据 |
|
|
|
|
|
|
|
string parameters = jo3["parameters"].ToString(); |
|
|
|
|
|
|
|
JObject jo4 = (JObject)JsonConvert.DeserializeObject(parameters); |
|
|
|
|
|
|
|
string sign_pic = jo4["sign_pic"].ToString(); |
|
|
|
|
|
|
|
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"success\",\"code\":200,\"status\":true,\"suffix\":\"png\",\"data\":\"" + sign_pic + "\"}"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//Log.Error("请求签字失败" + jo["message"].ToString()); |
|
|
|
|
|
|
|
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "签字失败" + "\"}"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (jo2["code"].ToString() == "2") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "用户取消签字" + "\"}"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (type == "open" && typeCode == 1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "签字失败" + "\"}"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "关闭签字失败" + "\"}"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (jo2["code"].ToString() == "2") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "用户取消签字" + "\"}"; |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
//Log.Error("请求签字失败" + jo["message"].ToString()); |
|
|
|
//Log.Error("请求签字失败" + jo["message"].ToString()); |
|
|
@ -201,6 +241,31 @@ namespace AksWebBrowser.Common |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// 签字版公共请求 |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
/// <param name="type"></param> |
|
|
|
|
|
|
|
/// <param name="typeCode"></param> |
|
|
|
|
|
|
|
/// <param name="timeout"></param> |
|
|
|
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
|
|
public static async Task<string> PublicSign(string type, int typeCode, int timeout) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
string body = string.Empty; |
|
|
|
|
|
|
|
timeout = timeout == 0 ? Parame.timeout : timeout; |
|
|
|
|
|
|
|
var client = new HttpClient(); |
|
|
|
|
|
|
|
client.Timeout = TimeSpan.FromSeconds(timeout); |
|
|
|
|
|
|
|
var request = new HttpRequestMessage(HttpMethod.Post, Parame.signUrl); |
|
|
|
|
|
|
|
var content = new StringContent("{\r\n \"command\": \"sign\",\r\n \"command_num\": 111,\r\n \"data\": {\r\n \"operation\": \"" + type + "\",\r\n \"operation_code\": " + typeCode + ",\r\n \"parameters\": {\r\n \"data_type\": 1\r\n }\r\n }\r\n}", null, "application/json"); |
|
|
|
|
|
|
|
request.Content = content; |
|
|
|
|
|
|
|
var response = await client.SendAsync(request); |
|
|
|
|
|
|
|
response.EnsureSuccessStatusCode(); |
|
|
|
|
|
|
|
if (response.StatusCode.ToString() == "OK") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
body = await response.Content.ReadAsStringAsync(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return body; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// 文字转语音 |
|
|
|
/// 文字转语音 |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
@ -316,19 +381,9 @@ namespace AksWebBrowser.Common |
|
|
|
{ |
|
|
|
{ |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
timeout = timeout == 0 ? Parame.timeout : timeout; |
|
|
|
string body = await PublicFinger(type, typeCode, timeout); |
|
|
|
var client = new HttpClient(); |
|
|
|
if (!string.IsNullOrEmpty(body)) |
|
|
|
client.Timeout = TimeSpan.FromSeconds(timeout); |
|
|
|
|
|
|
|
var request = new HttpRequestMessage(HttpMethod.Post, Parame.signUrl); |
|
|
|
|
|
|
|
var content = new StringContent("{\r\n \"command\": \"finger\",\r\n \"command_num\": 121,\r\n \"data\": {\r\n \"operation\": \"open\",\r\n \"operation_code\": 1,\r\n \"parameters\": {\r\n }\r\n }\r\n}", null, "text/plain"); |
|
|
|
|
|
|
|
request.Content = content; |
|
|
|
|
|
|
|
var response = await client.SendAsync(request); |
|
|
|
|
|
|
|
response.EnsureSuccessStatusCode(); |
|
|
|
|
|
|
|
if (response.StatusCode.ToString() == "OK") |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// 读取响应内容 |
|
|
|
|
|
|
|
string body = await response.Content.ReadAsStringAsync(); |
|
|
|
|
|
|
|
// Log.Info("获取指纹:" + body); |
|
|
|
|
|
|
|
JObject jo = (JObject)JsonConvert.DeserializeObject(body); |
|
|
|
JObject jo = (JObject)JsonConvert.DeserializeObject(body); |
|
|
|
string ret = jo["ret_info"].ToString(); |
|
|
|
string ret = jo["ret_info"].ToString(); |
|
|
|
JObject jo2 = (JObject)JsonConvert.DeserializeObject(ret); |
|
|
|
JObject jo2 = (JObject)JsonConvert.DeserializeObject(ret); |
|
|
@ -353,6 +408,45 @@ namespace AksWebBrowser.Common |
|
|
|
return "200"; |
|
|
|
return "200"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if (jo2["code"].ToString() == "1") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Task.Delay(1000).Wait(); |
|
|
|
|
|
|
|
body = await PublicFinger("close", 2, timeout); |
|
|
|
|
|
|
|
Task.Delay(1000).Wait(); |
|
|
|
|
|
|
|
body = await PublicFinger(type, typeCode, timeout); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(body)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
jo = (JObject)JsonConvert.DeserializeObject(body); |
|
|
|
|
|
|
|
ret = jo["ret_info"].ToString(); |
|
|
|
|
|
|
|
jo2 = (JObject)JsonConvert.DeserializeObject(ret); |
|
|
|
|
|
|
|
if (jo2["code"].ToString() == "0") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//读取指纹 |
|
|
|
|
|
|
|
if (typeCode == 1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//读取data数据 |
|
|
|
|
|
|
|
string data = jo["data"].ToString(); |
|
|
|
|
|
|
|
JObject jo3 = (JObject)JsonConvert.DeserializeObject(data); |
|
|
|
|
|
|
|
//读取parameters数据 |
|
|
|
|
|
|
|
string parameters = jo3["parameters"].ToString(); |
|
|
|
|
|
|
|
JObject jo4 = (JObject)JsonConvert.DeserializeObject(parameters); |
|
|
|
|
|
|
|
//读取签字base64 |
|
|
|
|
|
|
|
string fpr_pic = jo4["fpr_pic"].ToString(); |
|
|
|
|
|
|
|
return fpr_pic; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//关闭指纹 |
|
|
|
|
|
|
|
return "200"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return ""; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { return ""; } |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
//Log.Error("请求签字失败" + jo["message"].ToString()); |
|
|
|
//Log.Error("请求签字失败" + jo["message"].ToString()); |
|
|
@ -377,6 +471,31 @@ namespace AksWebBrowser.Common |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// 公共读取指纹 |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
/// <param name="type"></param> |
|
|
|
|
|
|
|
/// <param name="typeCode"></param> |
|
|
|
|
|
|
|
/// <param name="timeout"></param> |
|
|
|
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
|
|
public static async Task<string> PublicFinger(string type, int typeCode, int timeout) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
string body = string.Empty; |
|
|
|
|
|
|
|
timeout = timeout == 0 ? Parame.timeout : timeout; |
|
|
|
|
|
|
|
var client = new HttpClient(); |
|
|
|
|
|
|
|
client.Timeout = TimeSpan.FromSeconds(timeout); |
|
|
|
|
|
|
|
var request = new HttpRequestMessage(HttpMethod.Post, Parame.signUrl); |
|
|
|
|
|
|
|
var content = new StringContent("{\r\n \"command\": \"finger\",\r\n \"command_num\": 121,\r\n \"data\": {\r\n \"operation\": \"" + type + "\",\r\n \"operation_code\": " + typeCode + ",\r\n \"parameters\": {\r\n }\r\n }\r\n}", null, "text/plain"); |
|
|
|
|
|
|
|
request.Content = content; |
|
|
|
|
|
|
|
var response = await client.SendAsync(request); |
|
|
|
|
|
|
|
response.EnsureSuccessStatusCode(); |
|
|
|
|
|
|
|
if (response.StatusCode.ToString() == "OK") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
body = await response.Content.ReadAsStringAsync(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return body; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// 读取身份证 |
|
|
|
/// 读取身份证 |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|