|
|
@ -22,6 +22,7 @@ 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 static System.Net.Mime.MediaTypeNames; |
|
|
|
|
|
|
|
|
|
|
|
namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
{ |
|
|
|
{ |
|
|
@ -80,6 +81,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
//停止播放:{ "code":"aks100104","text":"","ispaye":true} |
|
|
|
//停止播放:{ "code":"aks100104","text":"","ispaye":true} |
|
|
|
case "aks100103": |
|
|
|
case "aks100103": |
|
|
|
result = payleText(content); |
|
|
|
result = payleText(content); |
|
|
|
|
|
|
|
Log.Info("文字语音播报返回:" + result); |
|
|
|
break; |
|
|
|
break; |
|
|
|
//aks100104 |
|
|
|
//aks100104 |
|
|
|
//打开高拍仪并且进行快速扫描文件 {"code":"aks100104"} |
|
|
|
//打开高拍仪并且进行快速扫描文件 {"code":"aks100104"} |
|
|
@ -90,6 +92,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
//打开签字版 {"code":"aks100105"} |
|
|
|
//打开签字版 {"code":"aks100105"} |
|
|
|
case "aks100105": |
|
|
|
case "aks100105": |
|
|
|
result = OpenSign(content); |
|
|
|
result = OpenSign(content); |
|
|
|
|
|
|
|
Log.Info("签字版数据返回:" + result); |
|
|
|
break; |
|
|
|
break; |
|
|
|
//aks100112 |
|
|
|
//aks100112 |
|
|
|
//关闭签字版 {"code":"aks100112"} |
|
|
|
//关闭签字版 {"code":"aks100112"} |
|
|
@ -107,6 +110,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
// 结束录音: { "code":"aks100107","url":"http://127.0.0.1/Upload","isopen":false} |
|
|
|
// 结束录音: { "code":"aks100107","url":"http://127.0.0.1/Upload","isopen":false} |
|
|
|
case "aks100107": |
|
|
|
case "aks100107": |
|
|
|
result = SoundRecording(content); |
|
|
|
result = SoundRecording(content); |
|
|
|
|
|
|
|
Log.Info("开始录音、取消录音、结束录音返回:" + result); |
|
|
|
break; |
|
|
|
break; |
|
|
|
//aks100108 |
|
|
|
//aks100108 |
|
|
|
//根据文件地址在线打印 { "code":"aks100108","url":"http://127.0.0.1/test.doc","ext":"doc"} |
|
|
|
//根据文件地址在线打印 { "code":"aks100108","url":"http://127.0.0.1/test.doc","ext":"doc"} |
|
|
@ -129,9 +133,12 @@ namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
case "aks100111": |
|
|
|
case "aks100111": |
|
|
|
result = openKey(keycode); |
|
|
|
result = openKey(keycode); |
|
|
|
break; |
|
|
|
break; |
|
|
|
//aks100113 指纹 {"code":"aks100113"} |
|
|
|
//aks100113 |
|
|
|
|
|
|
|
//读取指纹 {"code":"aks100113","isclose":false} |
|
|
|
|
|
|
|
//关闭指纹 {"code":"aks100113","isclose":true} |
|
|
|
case "aks100113": |
|
|
|
case "aks100113": |
|
|
|
result = ReadFingerData(keycode); |
|
|
|
result = ReadFingerData(content); |
|
|
|
|
|
|
|
Log.Info("指纹返回:" + result); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
result = "{\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"无效指令\"}"; |
|
|
|
result = "{\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"无效指令\"}"; |
|
|
@ -364,16 +371,19 @@ namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
Task.Run(() => |
|
|
|
Task.Run(() => { HttpPostResponseByTTS("text_to_wav", 1, text); }); |
|
|
|
|
|
|
|
event2.WaitOne(); |
|
|
|
|
|
|
|
string result = string.Empty; |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(ttsStr)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//形成语音 |
|
|
|
result = "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "播放失败" + "\"}"; |
|
|
|
tempWav = GenerateWavFromText(text); |
|
|
|
SubmitLogs(result, "payleText"); |
|
|
|
//////开始播放 |
|
|
|
} |
|
|
|
string command = $"sox {tempWav} -d"; |
|
|
|
else |
|
|
|
ShllCommad(command); |
|
|
|
{ |
|
|
|
//AutoAudio(true, tempWav); |
|
|
|
Task.Run(() => { string command = $"sox {ttsStr} -d"; ShllCommad(command); }); |
|
|
|
}); |
|
|
|
result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "开始播放" + "\"}"; |
|
|
|
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "开始播放" + "\"}"; |
|
|
|
} |
|
|
|
SubmitLogs(result, "payleText"); |
|
|
|
SubmitLogs(result, "payleText"); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -470,6 +480,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
Task.Run(() => { HttpPostResponseBySign("open", 1, param.code); }); |
|
|
|
Task.Run(() => { HttpPostResponseBySign("open", 1, param.code); }); |
|
|
|
event2.WaitOne(); |
|
|
|
event2.WaitOne(); |
|
|
|
string result = sginStr; |
|
|
|
string result = sginStr; |
|
|
|
|
|
|
|
Log.Info("签字版数据返回:" + result); |
|
|
|
SubmitLogs(result, "OpenSign"); |
|
|
|
SubmitLogs(result, "OpenSign"); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -519,28 +530,63 @@ namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
/// <param name="paramsString"></param> |
|
|
|
/// <param name="paramsString"></param> |
|
|
|
/// <returns></returns> |
|
|
|
/// <returns></returns> |
|
|
|
public static string ReadFingerData(string code) |
|
|
|
public static string ReadFingerData(string content) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var param = content.ConvertToAnonymousType(new |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
code = default(string), |
|
|
|
|
|
|
|
isclose = default(bool) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (false)//!isFuncisFuncObject("Finger") |
|
|
|
if (!isFuncisFuncObject("ReadFingerData")) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Utils.MessagesBox("指纹设备未授权使用"); |
|
|
|
Utils.MessagesBox("指纹设备未授权使用"); |
|
|
|
return "{\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "指纹设备未授权使用" + "\"}"; |
|
|
|
return "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "指纹设备未授权使用" + "\"}"; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (param.isclose) |
|
|
|
string result = Fingerprint.LIVESCANFinger(code); |
|
|
|
{ |
|
|
|
SubmitLogs(result, "Finger"); |
|
|
|
Task.Run(() => { HttpPostResponseByFinger("close", 2); }); |
|
|
|
|
|
|
|
event2.WaitOne(); |
|
|
|
|
|
|
|
string result = string.Empty; |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(fingerStr)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
result = "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "关闭失败" + "\"}"; |
|
|
|
|
|
|
|
SubmitLogs(result, "ReadFingerData"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "关闭成功" + "\"}"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SubmitLogs(result, "ReadFingerData"); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
Task.Run(() => { HttpPostResponseByFinger("open", 1); }); |
|
|
|
|
|
|
|
event2.WaitOne(); |
|
|
|
|
|
|
|
string result = string.Empty; |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(fingerStr)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
result = "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "读取失败" + "\"}"; |
|
|
|
|
|
|
|
SubmitLogs(result, "ReadFingerData"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + fingerStr + "\"}"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SubmitLogs(result, "ReadFingerData"); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//Log.Error("指纹异常: " + ex.Message + ""); |
|
|
|
//Log.Error("指纹异常: " + ex.Message + ""); |
|
|
|
string result = "{\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}"; |
|
|
|
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}"; |
|
|
|
SubmitLogs(result, "Finger"); |
|
|
|
SubmitLogs(result, "ReadFingerData"); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -577,7 +623,9 @@ namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
//结束录音上传文件 |
|
|
|
//结束录音上传文件 |
|
|
|
if (!string.IsNullOrEmpty(url) && !isopen) |
|
|
|
if (!string.IsNullOrEmpty(url) && !isopen) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (StopRecording()) |
|
|
|
Task.Run(() => { HttpPostResponseByRecord("stop_record", 3, ""); }); |
|
|
|
|
|
|
|
event2.WaitOne(); |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(srpath)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Task.Run(async () => |
|
|
|
Task.Run(async () => |
|
|
|
{ |
|
|
|
{ |
|
|
@ -601,7 +649,16 @@ namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
} |
|
|
|
} |
|
|
|
else if (isopen)//开始录音 |
|
|
|
else if (isopen)//开始录音 |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (StartRecording()) |
|
|
|
string time = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); |
|
|
|
|
|
|
|
string dirpath = Utils.getSystemPaht() + @"/wwwroot/Record"; |
|
|
|
|
|
|
|
if (!Directory.Exists(dirpath)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Directory.CreateDirectory(dirpath); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
string path = dirpath + "/" + time + ".wav"; |
|
|
|
|
|
|
|
Task.Run(() => { HttpPostResponseByRecord("start_record", 2, path); }); |
|
|
|
|
|
|
|
event2.WaitOne(); |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(srpath)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"wav\",\"data\":\"" + "开始录音" + "\"}"; |
|
|
|
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"wav\",\"data\":\"" + "开始录音" + "\"}"; |
|
|
|
SubmitLogs(result, "SoundRecording"); |
|
|
|
SubmitLogs(result, "SoundRecording"); |
|
|
@ -616,7 +673,9 @@ namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
} |
|
|
|
} |
|
|
|
else //取消录音 |
|
|
|
else //取消录音 |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (StopRecording()) |
|
|
|
Task.Run(() => { HttpPostResponseByRecord("stop_record", 3, ""); }); |
|
|
|
|
|
|
|
event2.WaitOne(); |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(srpath)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
srpath = string.Empty; |
|
|
|
srpath = string.Empty; |
|
|
|
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"wav\",\"data\":\"" + "取消录音" + "\"}"; |
|
|
|
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"wav\",\"data\":\"" + "取消录音" + "\"}"; |
|
|
@ -1182,6 +1241,66 @@ namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static string ttsStr = string.Empty; |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// 文字转语音 |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
private static async void HttpPostResponseByTTS(string type, int typeCode, string tts_text) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var httpClient = new HttpClient(); |
|
|
|
|
|
|
|
var uploader = new ChunkedUpload(httpClient); |
|
|
|
|
|
|
|
ttsStr = await uploader.PostTTS(type, typeCode, tts_text); |
|
|
|
|
|
|
|
@event2.Set(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//Log.Error("签字版异常:" + ex.Message); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static string fingerStr = string.Empty; |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// 指紋 |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
private static async void HttpPostResponseByFinger(string type, int typeCode) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var httpClient = new HttpClient(); |
|
|
|
|
|
|
|
var uploader = new ChunkedUpload(httpClient); |
|
|
|
|
|
|
|
fingerStr = await uploader.PostFinger(type, typeCode); |
|
|
|
|
|
|
|
@event2.Set(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//Log.Error("签字版异常:" + ex.Message); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static string RecordStr = string.Empty; |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// 录音与停止 |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
private static async void HttpPostResponseByRecord(string type, int typeCode, string path) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var httpClient = new HttpClient(); |
|
|
|
|
|
|
|
var uploader = new ChunkedUpload(httpClient); |
|
|
|
|
|
|
|
RecordStr = await uploader.PostRecord(type, typeCode, path); |
|
|
|
|
|
|
|
@event2.Set(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//Log.Error("签字版异常:" + ex.Message); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// 初始文件上传 |
|
|
|
/// 初始文件上传 |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
@ -1394,6 +1513,47 @@ namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
return tempFile; |
|
|
|
return tempFile; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// 开源文字转语音 |
|
|
|
|
|
|
|
/// sudo apt-get install espeak |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
/// <param name="text"></param> |
|
|
|
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
|
|
static string GenerateWavFromText2(string text) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
string time = DateTime.Now.ToString( |
|
|
|
|
|
|
|
"yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); |
|
|
|
|
|
|
|
string dirpath = Utils.getSystemPaht() + @"/wwwroot/WavFile"; |
|
|
|
|
|
|
|
// Log.Info(dirpath); |
|
|
|
|
|
|
|
if (!Directory.Exists(dirpath)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Directory.CreateDirectory(dirpath); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var tempFile = dirpath + "/" + time + ".wav"; |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
text = text.Replace("(", "").Replace(")", "、"); |
|
|
|
|
|
|
|
ProcessStartInfo startInfo = new ProcessStartInfo |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
FileName = "espeak", |
|
|
|
|
|
|
|
Arguments = $" -vzh -s 150 \"{text}\" -w {tempFile}", // 设置语速为150,输出为WAV文件 |
|
|
|
|
|
|
|
UseShellExecute = false, |
|
|
|
|
|
|
|
RedirectStandardOutput = true, |
|
|
|
|
|
|
|
CreateNoWindow = true |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
using (Process process = Process.Start(startInfo)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
process.WaitForExit(); // 等待进程结束 |
|
|
|
|
|
|
|
process.Close(); |
|
|
|
|
|
|
|
process.Dispose(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//Log.Error("文字转语音失败:" + ex.Message); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return tempFile; |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// 是否已获取收取 |
|
|
|
/// 是否已获取收取 |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|