Browse Source

提交数据文档接口

master
胡超1 1 year ago
parent
commit
f2ed12518f
  1. 49
      CPF_Cef/Common/ChunkedUpload.cs
  2. 12
      CPF_Cef/FrmMain.cs
  3. 70
      CPF_Cef/MainModel.cs
  4. 2
      CPF_Cef/Parame.cs
  5. 3
      CPF_Cef/Ramark.txt

49
CPF_Cef/Common/ChunkedUpload.cs

@ -497,6 +497,8 @@ namespace AksWebBrowser.Common
public async Task<string> PublicFinger(string type, int typeCode, int timeout) public async Task<string> PublicFinger(string type, int typeCode, int timeout)
{ {
string body = string.Empty; string body = string.Empty;
try
{
timeout = timeout == 0 ? Parame.timeout : timeout; timeout = timeout == 0 ? Parame.timeout : timeout;
var client = new HttpClient(); var client = new HttpClient();
client.Timeout = TimeSpan.FromSeconds(timeout); client.Timeout = TimeSpan.FromSeconds(timeout);
@ -509,6 +511,12 @@ namespace AksWebBrowser.Common
{ {
body = await response.Content.ReadAsStringAsync(); body = await response.Content.ReadAsStringAsync();
} }
}
catch (Exception)
{
return "";
}
return body; return body;
} }
@ -604,6 +612,8 @@ namespace AksWebBrowser.Common
public async Task<string> PublicIdcard(string type, int typeCode, int timeout) public async Task<string> PublicIdcard(string type, int typeCode, int timeout)
{ {
string body = string.Empty; string body = string.Empty;
try
{
timeout = timeout == 0 ? Parame.timeout : timeout; timeout = timeout == 0 ? Parame.timeout : timeout;
var client = new HttpClient(); var client = new HttpClient();
client.Timeout = TimeSpan.FromSeconds(timeout); client.Timeout = TimeSpan.FromSeconds(timeout);
@ -616,7 +626,46 @@ namespace AksWebBrowser.Common
{ {
body = await response.Content.ReadAsStringAsync(); body = await response.Content.ReadAsStringAsync();
} }
}
catch (Exception)
{
return "";
}
return body; return body;
} }
/// <summary>
/// 获取问题
/// </summary>
/// <param name="PetitionId"></param>
/// <param name="PId"></param>
/// <param name="Name"></param>
/// <param name="PageIndex"></param>
/// <param name="PageSize"></param>
/// <returns></returns>
public async Task<string> GetQuestionAnswer(string PetitionId, string PId, string Name, int PageIndex, int PageSize)
{
string body = string.Empty;
try
{
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, Parame.qwUrl + "/api/QuestionAnswer/Query");
var content = new StringContent("{\r\n \"PetitionId\": \"" + PetitionId + "\",\r\n \"PId\": \"" + PId + "\",\r\n \"Name\": \"" + Name + "\",\r\n \"PageIndex\": " + PageIndex + ",\r\n \"PageSize\": " + PageSize + "\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();
}
}
catch (Exception)
{
return "";
}
return body;
}
} }
} }

12
CPF_Cef/FrmMain.cs

@ -18,10 +18,10 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{ {
public class FrmMain : Window public class FrmMain : Window
{ {
//public int w = 1080; public int w = 1080;
//public int h = 1920; public int h = 1920;
public int h = 1080; //public int h = 1080;
public int w = 1920; //public int w = 1920;
protected override void InitializeComponent() protected override void InitializeComponent()
{ {
@ -32,8 +32,8 @@ namespace AKS.EnterpriseLibrary.WebBrowser
Title = "控申业务专用浏览器"; Title = "控申业务专用浏览器";
CanResize = false; CanResize = false;
ShowInTaskbar = true; ShowInTaskbar = true;
//WindowState = WindowState.FullScreen; WindowState = WindowState.FullScreen;
WindowState = WindowState.Maximized; //WindowState = WindowState.Maximized;
Children.Add( Children.Add(
new Border new Border

70
CPF_Cef/MainModel.cs

@ -20,11 +20,13 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Net.WebSockets; using System.Net.WebSockets;
using System.Reflection.Metadata; using System.Reflection.Metadata;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web; using System.Web;
using System.Xml.Linq;
using static System.Net.Mime.MediaTypeNames; using static System.Net.Mime.MediaTypeNames;
namespace AKS.EnterpriseLibrary.WebBrowser namespace AKS.EnterpriseLibrary.WebBrowser
@ -159,6 +161,10 @@ namespace AKS.EnterpriseLibrary.WebBrowser
case "aks100116": case "aks100116":
result = BurnFile(content); result = BurnFile(content);
break; break;
//读取问答:{ "code":"aks100117", "PetitionId": "34", "PId": "", "Name": "", "PageIndex": 1,"PageSize": 10}
case "aks100117":
result = ReadQuestionAnswer(content);
break;
default: default:
result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"无效指令\"}"; result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"无效指令\"}";
break; break;
@ -1194,6 +1200,52 @@ namespace AKS.EnterpriseLibrary.WebBrowser
} }
} }
/// <summary>
/// aks100117 读取问答 (已国产化)
/// </summary>
/// <param name="filename"></param>
/// <returns></returns>
public static string ReadQuestionAnswer(string content)
{
try
{
var param = content.ConvertToAnonymousType(new
{
code = default(string),
PetitionId = default(string),
PId = default(string),
Name = default(string),
PageIndex = default(int),
PageSize = default(int)
});
if (param == null)
{
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "参数解析错误" + "\"}";
}
else
{
Task.Run(async () =>
{
QuestionAnswer(param.PetitionId, param.PId, param.Name, param.PageIndex, param.PageSize);
});
@event10.WaitOne();
if (string.IsNullOrEmpty(qwStr))
{
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "获取数据失败" + "\"}";
}
else {
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"" + qwStr + "\"}";
}
}
}
catch (Exception ex)
{
//Log.Error("唤醒键盘异常: " + ex.Message + "");
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}";
}
}
/// <summary> /// <summary>
/// 执行文件 /// 执行文件
/// </summary> /// </summary>
@ -1680,6 +1732,24 @@ namespace AKS.EnterpriseLibrary.WebBrowser
} }
} }
//读取问答
private static string qwStr = string.Empty;
private static AutoResetEvent @event10 = new AutoResetEvent(false);
private static async void QuestionAnswer(string PetitionId, string PId, string Name, int PageIndex, int PageSize)
{
try
{
var httpClient = new HttpClient();
var uploader = new ChunkedUpload(httpClient);
qwStr = await uploader.GetQuestionAnswer(PetitionId, PId, Name, PageIndex, PageSize);
@event10.Set();
}
catch (Exception ex)
{
//Log.Error("上传本地文件中转异常:" + ex.Message);
}
}
//根据程序名称杀死进程 //根据程序名称杀死进程
public static void KillProcessByName(string processName) public static void KillProcessByName(string processName)
{ {

2
CPF_Cef/Parame.cs

@ -52,6 +52,8 @@ namespace AksWebBrowser
public static int score = 65; public static int score = 65;
//人脸比对阈值 //人脸比对阈值
public static string ImgBase64 = string.Empty; public static string ImgBase64 = string.Empty;
//获取问答
public static string qwUrl = "http://116.205.231.210:82";
} }
public struct Func public struct Func
{ {

3
CPF_Cef/Ramark.txt

@ -10,8 +10,7 @@ sudo apt install libsox-fmt-all
sudo apt-get install libgdiplus sudo apt-get install libgdiplus
sudo apt-get install alsa-utils sudo apt-get install alsa-utils
sudo apt-get install espeak sudo apt-get install espeak
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install imagemagick sudo apt-get install imagemagick
sudo apt-get install libvlc-dev sudo apt-get install libvlc-dev
sudo apt-get install vlc sudo apt-get install vlc

Loading…
Cancel
Save