Browse Source

优化授权推送

master
胡超1 1 year ago
parent
commit
9bf39cf89b
  1. 5
      CPF_Cef/FrmMain.cs
  2. 58
      CPF_Cef/MainModel.cs
  3. 4
      CPF_Cef/Parame.cs

5
CPF_Cef/FrmMain.cs

@ -72,6 +72,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
); );
} }
private TextBox textBox; private TextBox textBox;
protected override async void OnInitialized() protected override async void OnInitialized()
{ {
//窗体大小 //窗体大小
@ -103,6 +104,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{ {
MainModel.KillProcessByName("AksWebBrowser"); MainModel.KillProcessByName("AksWebBrowser");
} }
bool showDev = false; bool showDev = false;
private void WebBrowser_LoadEnd(object sender, LoadEndEventArgs e) private void WebBrowser_LoadEnd(object sender, LoadEndEventArgs e)
{ {
@ -132,9 +134,12 @@ namespace AKS.EnterpriseLibrary.WebBrowser
private void OnTimedEvent(Object source, ElapsedEventArgs e) private void OnTimedEvent(Object source, ElapsedEventArgs e)
{ {
try try
{
if (!Parame.isCloseHttp)
{ {
//获取授权 //获取授权
GetSQObject(); GetSQObject();
}
//检测服务是否启动 //检测服务是否启动
MainModel.StartShll(); MainModel.StartShll();
} }

58
CPF_Cef/MainModel.cs

@ -11,6 +11,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using SkiaSharp; using SkiaSharp;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
@ -163,6 +164,10 @@ namespace AKS.EnterpriseLibrary.WebBrowser
case "aks100117": case "aks100117":
result = ReadQuestionAnswer(content); result = ReadQuestionAnswer(content);
break; break;
//读取问答:{ "code":"aks100118", "isCloseHttp":true,"data": "{}"}
case "aks100118":
result = SendSQ(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;
@ -1232,7 +1237,8 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{ {
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "获取数据失败" + "\"}"; return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "获取数据失败" + "\"}";
} }
else { else
{
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"" + qwStr + "\"}"; return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"" + qwStr + "\"}";
} }
} }
@ -1244,6 +1250,56 @@ namespace AKS.EnterpriseLibrary.WebBrowser
} }
} }
/// <summary>
/// 获取授权数据
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
public static string SendSQ(string content)
{
try
{
var param = content.ConvertToAnonymousType(new
{
code = default(string),
data = default(string),
isCloseHttp = default(bool)
});
if (param == null)
{
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "参数解析错误" + "\"}";
}
Parame.isCloseHttp = param.isCloseHttp;
List<Func> list = new List<Func>();
JObject jo = (JObject)JsonConvert.DeserializeObject(param.data);
if (jo["IsSucceed"].ToString() == "True")
{
string result = jo["result"].ToString();
if (!string.IsNullOrEmpty("result"))
{
JArray array = (JArray)JsonConvert.DeserializeObject(result);
foreach (JObject item in array)
{
Func func = new Func()
{
Id = item["Id"].ToString(),
Platform = item["Platform"].ToString(),
Interfaceaddress = item["Interfaceaddress"].ToString(),
};
list.Add(func);
}
}
}
Parame.FuncObject = list;
return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"" + "推送成功" + "\"}";
}
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>

4
CPF_Cef/Parame.cs

@ -41,9 +41,11 @@ namespace AksWebBrowser
//打印名字 //打印名字
public static string PrinterName = "Lexmark-MS430-Series"; public static string PrinterName = "Lexmark-MS430-Series";
//是否启用双目 //是否启用双目
public static bool isSM = false; public static bool isSM = true;
//是否开启高拍仪 //是否开启高拍仪
public static bool isGPY = false; public static bool isGPY = false;
//是否关闭授权定时请求
public static bool isCloseHttp = false;
//双目摄像头 //双目摄像头
public static string smWebsocket = "ws://127.0.0.1:22226"; public static string smWebsocket = "ws://127.0.0.1:22226";
//消息推送 //消息推送

Loading…
Cancel
Save