Browse Source

优化

master
胡超1 1 year ago
parent
commit
a222e365f9
  1. 30
      CPF_Cef/AksVideoPlayer.cs
  2. 44
      CPF_Cef/Common/ChunkedUpload.cs
  3. 1
      CPF_Cef/Devices/PrintPJ.cs
  4. 78
      CPF_Cef/MainModel.cs

30
CPF_Cef/AksVideoPlayer.cs

@ -11,6 +11,7 @@ using CPF.Animation;
using CPF.Svg; using CPF.Svg;
using CPF.Input; using CPF.Input;
using static System.Net.Mime.MediaTypeNames; using static System.Net.Mime.MediaTypeNames;
using LibVLCSharp.Shared;
namespace AksWebBrowser namespace AksWebBrowser
{ {
@ -41,13 +42,13 @@ namespace AksWebBrowser
window.Children.Add(mask); window.Children.Add(mask);
window.Children.Add(this); window.Children.Add(this);
mask.TransitionValue(a => a.Background, "0,0,0,100", TimeSpan.FromSeconds(0.3), null, AnimateMode.Linear); mask.TransitionValue(a => a.Background, "0,0,0,100", TimeSpan.FromSeconds(0.3), null, AnimateMode.Linear);
//this.TransitionValue(a => a.MarginTop, 100, TimeSpan.FromSeconds(0.3), new PowerEase { }, AnimateMode.EaseOut);
} }
private Window window; private Window window;
protected override void OnInitialized() protected override void OnInitialized()
{ {
base.OnInitialized(); base.OnInitialized();
//@"http://192.168.0.34:92/CaseFile/card/2024-06-03/20240603120112952.mp4" //@"http://192.168.0.34:92/CaseFile/card/2024-06-03/20240603120112952.mp4"
vplayer.Play(new Uri(url));//播放 vplayer.Play(new Uri(url));//播放
} }
@ -55,8 +56,8 @@ namespace AksWebBrowser
{ {
IsAntiAlias = true; IsAntiAlias = true;
CornerRadius = "3,3,3,3"; CornerRadius = "3,3,3,3";
Height = "600"; Height = "360";
Width = "800"; Width = "640";
Background = "#2c2c2c"; Background = "#2c2c2c";
ZIndex = 100; ZIndex = 100;
Children.Add(new TextBlock Children.Add(new TextBlock
@ -65,7 +66,7 @@ namespace AksWebBrowser
MarginTop = 10f, MarginTop = 10f,
Classes = "imgAndText", Classes = "imgAndText",
FontFamily = "微软雅黑",//Alibaba PuHuiTi FontFamily = "微软雅黑",//Alibaba PuHuiTi
Text = "关闭", Text = "Close",
FontSize = 16, FontSize = 16,
Cursor = CPF.Cursors.Hand, Cursor = CPF.Cursors.Hand,
Foreground = Color.White, Foreground = Color.White,
@ -88,17 +89,16 @@ namespace AksWebBrowser
} }
}); });
Children.Add(new TextBlock //Children.Add(new TextBlock
{ //{
FontSize = 16f, // FontSize = 16f,
MarginLeft = 12.6f, // MarginLeft = 12.6f,
MarginTop = 9.6f, // MarginTop = 9.6f,
Classes = "imgAndText", // Classes = "imgAndText",
Foreground = Color.White, // Foreground = Color.White,
Text = videoTitle, // // Text = videoTitle,
FontFamily = "微软雅黑", // FontFamily = "微软雅黑",
}); //});
Children.Add(vplayer); Children.Add(vplayer);
} }

44
CPF_Cef/Common/ChunkedUpload.cs

@ -173,6 +173,8 @@ namespace AksWebBrowser.Common
jo2 = (JObject)JsonConvert.DeserializeObject(ret); jo2 = (JObject)JsonConvert.DeserializeObject(ret);
if (jo2["code"].ToString() == "0") if (jo2["code"].ToString() == "0")
{ {
//关闭签字版
await PublicSign("close", 2, timeout);
//读取data数据 //读取data数据
string data = jo["data"].ToString(); string data = jo["data"].ToString();
JObject jo3 = (JObject)JsonConvert.DeserializeObject(data); JObject jo3 = (JObject)JsonConvert.DeserializeObject(data);
@ -184,16 +186,22 @@ namespace AksWebBrowser.Common
} }
else else
{ {
//关闭签字版
await PublicSign("close", 2, timeout);
//Log.Error("请求签字失败" + jo["message"].ToString()); //Log.Error("请求签字失败" + jo["message"].ToString());
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "签字失败" + "\"}"; return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "签字失败" + "\"}";
} }
} }
else if (jo2["code"].ToString() == "2") else if (jo2["code"].ToString() == "2")
{ {
//关闭签字版
await PublicSign("close", 2, timeout);
return "{\"timestamp\":\"" + "" + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "取消签字" + "\"}"; return "{\"timestamp\":\"" + "" + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "取消签字" + "\"}";
} }
else else
{ {
//关闭签字版
await PublicSign("close", 2, timeout);
if (type == "open" && typeCode == 1) if (type == "open" && typeCode == 1)
{ {
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "签字失败" + "\"}"; return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "签字失败" + "\"}";
@ -206,21 +214,29 @@ namespace AksWebBrowser.Common
} }
else if (jo2["code"].ToString() == "2") else if (jo2["code"].ToString() == "2")
{ {
//关闭签字版
await PublicSign("close", 2, timeout);
return "{\"timestamp\":\"" + "" + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "取消签字" + "\"}"; return "{\"timestamp\":\"" + "" + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "取消签字" + "\"}";
} }
else else
{ {
//关闭签字版
await PublicSign("close", 2, timeout);
//Log.Error("请求签字失败" + jo["message"].ToString()); //Log.Error("请求签字失败" + jo["message"].ToString());
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "签字失败" + "\"}"; return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "签字失败" + "\"}";
} }
} }
else else
{ {
//关闭签字版
await PublicSign("close", 2, timeout);
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"png\",\"data\":\"" + "关闭成功" + "\"}"; return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"png\",\"data\":\"" + "关闭成功" + "\"}";
} }
} }
else else
{ {
//关闭签字版
await PublicSign("close", 2, timeout);
if (type == "open" && typeCode == 1) if (type == "open" && typeCode == 1)
{ {
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "签字失败" + "\"}"; return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "签字失败" + "\"}";
@ -233,6 +249,8 @@ namespace AksWebBrowser.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
//关闭签字版
await PublicSign("close", 2, timeout);
if (ex.Message.Contains("HttpClient.Timeout")) if (ex.Message.Contains("HttpClient.Timeout"))
{ {
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "在规定时间内未签字" + "\"}"; return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "在规定时间内未签字" + "\"}";
@ -295,7 +313,6 @@ namespace AksWebBrowser.Common
JObject jo2 = (JObject)JsonConvert.DeserializeObject(ret); JObject jo2 = (JObject)JsonConvert.DeserializeObject(ret);
if (jo2["code"].ToString() == "0") if (jo2["code"].ToString() == "0")
{ {
//读取data数据
//读取data数据 //读取data数据
string data = jo["data"].ToString(); string data = jo["data"].ToString();
JObject jo3 = (JObject)JsonConvert.DeserializeObject(data); JObject jo3 = (JObject)JsonConvert.DeserializeObject(data);
@ -341,7 +358,6 @@ namespace AksWebBrowser.Common
JObject jo2 = (JObject)JsonConvert.DeserializeObject(ret); JObject jo2 = (JObject)JsonConvert.DeserializeObject(ret);
if (jo2["code"].ToString() == "0") if (jo2["code"].ToString() == "0")
{ {
//读取data数据
//读取data数据 //读取data数据
string data = jo["data"].ToString(); string data = jo["data"].ToString();
JObject jo3 = (JObject)JsonConvert.DeserializeObject(data); JObject jo3 = (JObject)JsonConvert.DeserializeObject(data);
@ -400,6 +416,7 @@ namespace AksWebBrowser.Common
//读取指纹 //读取指纹
if (typeCode == 1) if (typeCode == 1)
{ {
await PublicFinger("close", 2, timeout);
//读取data数据 //读取data数据
string data = jo["data"].ToString(); string data = jo["data"].ToString();
JObject jo3 = (JObject)JsonConvert.DeserializeObject(data); JObject jo3 = (JObject)JsonConvert.DeserializeObject(data);
@ -412,12 +429,14 @@ namespace AksWebBrowser.Common
} }
else else
{ {
await PublicFinger("close", 2, timeout);
//关闭指纹 //关闭指纹
return "200"; return "200";
} }
} }
else else
{ {
await PublicFinger("close", 2, timeout);
//关闭指纹 //关闭指纹
return "200"; return "200";
} }
@ -436,6 +455,7 @@ namespace AksWebBrowser.Common
jo2 = (JObject)JsonConvert.DeserializeObject(ret); jo2 = (JObject)JsonConvert.DeserializeObject(ret);
if (jo2["code"].ToString() == "0") if (jo2["code"].ToString() == "0")
{ {
await PublicFinger("close", 2, timeout);
//读取指纹 //读取指纹
if (typeCode == 1) if (typeCode == 1)
{ {
@ -457,13 +477,15 @@ namespace AksWebBrowser.Common
} }
else else
{ {
await PublicFinger("close", 2, timeout);
return ""; return "";
} }
} }
else { return ""; } else { await PublicFinger("close", 2, timeout); return ""; }
} }
else else
{ {
await PublicFinger("close", 2, timeout);
//Log.Error("请求签字失败" + jo["message"].ToString()); //Log.Error("请求签字失败" + jo["message"].ToString());
return ""; return "";
} }
@ -471,11 +493,13 @@ namespace AksWebBrowser.Common
} }
else else
{ {
await PublicFinger("close", 2, timeout);
return ""; return "";
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
await PublicFinger("close", 2, timeout);
if (ex.Message.Contains("HttpClient.Timeout")) if (ex.Message.Contains("HttpClient.Timeout"))
{ {
return "HttpClient.Timeout"; return "HttpClient.Timeout";
@ -529,7 +553,7 @@ namespace AksWebBrowser.Common
try try
{ {
//关闭身份证 //关闭身份证
await PublicIdcard(type, typeCode, timeout); await PublicIdcard(timeout);
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);
@ -549,6 +573,8 @@ namespace AksWebBrowser.Common
{ {
if (typeCode == 1) if (typeCode == 1)
{ {
//关闭身份证
await PublicIdcard(timeout);
//读取data数据 //读取data数据
string data = jo["data"].ToString(); string data = jo["data"].ToString();
JObject jo3 = (JObject)JsonConvert.DeserializeObject(data); JObject jo3 = (JObject)JsonConvert.DeserializeObject(data);
@ -575,23 +601,31 @@ namespace AksWebBrowser.Common
} }
else else
{ {
//关闭身份证
await PublicIdcard(timeout);
//关闭 //关闭
return "200"; return "200";
} }
} }
else else
{ {
//关闭身份证
await PublicIdcard(timeout);
//Log.Error("请求签字失败" + jo["message"].ToString()); //Log.Error("请求签字失败" + jo["message"].ToString());
return ""; return "";
} }
} }
else else
{ {
//关闭身份证
await PublicIdcard(timeout);
return ""; return "";
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
//关闭身份证
await PublicIdcard(timeout);
if (ex.Message.Contains("HttpClient.Timeout")) if (ex.Message.Contains("HttpClient.Timeout"))
{ {
return "HttpClient.Timeout"; return "HttpClient.Timeout";
@ -610,7 +644,7 @@ namespace AksWebBrowser.Common
/// <param name="typeCode"></param> /// <param name="typeCode"></param>
/// <param name="timeout"></param> /// <param name="timeout"></param>
/// <returns></returns> /// <returns></returns>
public async Task<string> PublicIdcard(string type, int typeCode, int timeout) public async Task<string> PublicIdcard(int timeout)
{ {
string body = string.Empty; string body = string.Empty;
try try

1
CPF_Cef/Devices/PrintPJ.cs

@ -1,4 +1,5 @@
 
using AksWebBrowser.Common;
using AKSWebBrowser.Commen; using AKSWebBrowser.Commen;
using CPF.Windows; using CPF.Windows;
using System; using System;

78
CPF_Cef/MainModel.cs

@ -66,6 +66,7 @@ namespace AksWebBrowser
{ {
try try
{ {
Log.Info("接受参数:" + content);
var json = content.ConvertToAnonymousType(new var json = content.ConvertToAnonymousType(new
{ {
code = default(string) code = default(string)
@ -164,7 +165,8 @@ namespace AksWebBrowser
case "aks100117": case "aks100117":
result = ReadQuestionAnswer(content); result = ReadQuestionAnswer(content);
break; break;
//读取问答:{ "code":"aks100118", "isCloseHttp":true,"data": "{}"} //读取问答:{ "code":"
//", "isCloseHttp":true,"data": "{}"}
case "aks100118": case "aks100118":
result = SendSQ(content); result = SendSQ(content);
break; break;
@ -342,20 +344,14 @@ namespace AksWebBrowser
} }
else else
{ {
PrintPJ print = new PrintPJ(Parame.pritPj, Parame.pritPjPort); Task.Run(() =>
var data = print.SendPrint(ph, ddrs, qrcode, ywmc);
if (data == 0)
{ {
string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"" + "打印成功" + "\"}"; PrintPJ print = new PrintPJ(Parame.pritPj, Parame.pritPjPort);
SubmitLogs(result, "SendByPrint"); print.SendPrint(ph, ddrs, qrcode, ywmc);
return result; });
} string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"" + "已推送打印" + "\"}";
else SubmitLogs(result, "SendByPrint");
{ return result;
string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + (data == 1 ? "打印失败" : (data == 2 ? "打印机未连接" : "打印机初始化失败")) + "\"}";
SubmitLogs(result, "SendByPrint");
return result;
}
} }
} }
catch (Exception ex) catch (Exception ex)
@ -415,6 +411,7 @@ namespace AksWebBrowser
Directory.CreateDirectory(dirpath); Directory.CreateDirectory(dirpath);
} }
var tempFile = dirpath + $"/{ywid}.wav"; var tempFile = dirpath + $"/{ywid}.wav";
//Log.Info("aks100103文字语音播报:" + tempFile);
string result = string.Empty; string result = string.Empty;
if (!File.Exists(tempFile)) if (!File.Exists(tempFile))
{ {
@ -427,7 +424,13 @@ namespace AksWebBrowser
} }
else else
{ {
Task.Run(() => { string command = $"sox {ttsStr} -d"; ShllCommad(command); }); Task.Run(() =>
{
string command = $"pkill sox";
ShllCommad(command);
command = $"sox {ttsStr} -d";
ShllCommad(command);
});
if (!string.IsNullOrEmpty(ywid)) if (!string.IsNullOrEmpty(ywid))
{ {
string filename = Path.GetFileName(ttsStr); string filename = Path.GetFileName(ttsStr);
@ -1072,8 +1075,10 @@ namespace AksWebBrowser
{ {
try try
{ {
// 在你的窗口或应用程序需要时调用 Task.Run(() => {
Bash("/usr/bin/python3 /usr/bin/onboard"); // 在你的窗口或应用程序需要时调用
Bash("/usr/bin/python3 /usr/bin/onboard");
});
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"" + "唤醒键盘成功" + "\"}"; return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"" + "唤醒键盘成功" + "\"}";
} }
catch (Exception ex) catch (Exception ex)
@ -1702,9 +1707,9 @@ namespace AksWebBrowser
{ {
var httpClient = new HttpClient(); var httpClient = new HttpClient();
var uploader = new ChunkedUpload(httpClient); var uploader = new ChunkedUpload(httpClient);
await uploader.PublicSign("close", 2, 5); await uploader.PublicSign("close", 2, 50);
await uploader.PublicFinger("close", 2, 5); await uploader.PublicFinger("close", 2, 50);
await uploader.PublicIdcard("close", 2, 5); await uploader.PublicIdcard(50);
@event8.Set(); @event8.Set();
} }
catch (Exception ex) catch (Exception ex)
@ -2183,7 +2188,7 @@ namespace AksWebBrowser
string zxjg = Bash(commod); string zxjg = Bash(commod);
if (string.IsNullOrEmpty(zxjg)) if (string.IsNullOrEmpty(zxjg))
{ {
commod = "chmod -R 777 /data/home/aks/lhtserver/lhtserver && cd /data/home/aks/lhtserver/lhtserver && nohup ./LhtCamServer.sh &"; commod = "chmod -R 777 /opt/lhtserver/files/bin && cd /opt/lhtserver/files/bin && nohup ./LhtCamServer.sh &";
Bash(commod); Bash(commod);
Task.Delay(3000).Wait(); Task.Delay(3000).Wait();
} }
@ -2192,5 +2197,36 @@ namespace AksWebBrowser
catch { } catch { }
finally { } finally { }
} }
/// <summary>
/// 播放文件
/// </summary>
/// <param name="filePath"></param>
public static void PlayMedia(string filePath)
{
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = "mplayer",
Arguments = $"{filePath} -slave -quiet",
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
CreateNoWindow = true
};
using (Process process = Process.Start(startInfo))
{
using (var sw = process.StandardInput)
{
if (sw.BaseStream.CanWrite)
{
sw.WriteLine("loadfile \"your_media_file.mp3\"");
sw.WriteLine("play");
}
}
process.WaitForExit();
}
}
} }
} }

Loading…
Cancel
Save