初始化
This commit is contained in:
365
Face.Web/Areas/App/Controllers/SendmessageController.cs
Normal file
365
Face.Web/Areas/App/Controllers/SendmessageController.cs
Normal file
@@ -0,0 +1,365 @@
|
||||
|
||||
using Face.Domain.Application.FaceAll;
|
||||
using Face.Domain.Entities;
|
||||
using Face.Web.Areas.App.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using System.Web.Mvc;
|
||||
using WebSocketToolsConsole;
|
||||
|
||||
namespace Face.Web.Areas.App.Controllers
|
||||
{
|
||||
public class SendmessageController : Controller
|
||||
{
|
||||
// GET: App/Sendmessage
|
||||
/// <summary>
|
||||
/// 新命令获取设备信息
|
||||
/// </summary>
|
||||
/// <param name="Serial">人脸机编号</param>
|
||||
/// <returns></returns>
|
||||
public ActionResult GetModelInfosas(string Serial)
|
||||
{
|
||||
|
||||
Entity.Rootinfo info = new Entity.Rootinfo();
|
||||
info.pmsid = -1;
|
||||
Entity.msgx msgx = new Entity.msgx();
|
||||
|
||||
StringBuilder sbperson = new StringBuilder();
|
||||
sbperson.Append("key=abcdef");
|
||||
msgx.msgid = Guid.NewGuid().ToString();
|
||||
msgx.sn = Serial;
|
||||
msgx.cmd = "GetModelInfo";//得到设备信息
|
||||
msgx.msg = System.Web.HttpUtility.HtmlDecode(sbperson.ToString());
|
||||
info.msgx = msgx;
|
||||
info.pmsid = -1;
|
||||
string sendMsg = Newtonsoft.Json.JsonConvert.SerializeObject(info);
|
||||
UdpCommunication.QueueSend(sendMsg);
|
||||
using (var db = SqlSugarBase.GesmartDb())
|
||||
{
|
||||
string sn = Serial;
|
||||
var dbt = db.Queryable<Domain.Application.FaceAll.DeviceManage>().First(x => x.SerialNo == sn);
|
||||
Domain.Application.FaceAll.ULog uLog = new Domain.Application.FaceAll.ULog
|
||||
{
|
||||
Uname = Session["username"].ToString(),
|
||||
faceSN = Serial,
|
||||
operatetype = "得到设备基本信息",
|
||||
hotelcode = int.Parse(Session["hotelCode"].ToString()),
|
||||
roomid = dbt.RoomId,
|
||||
Creationtime = DateTime.Now
|
||||
};
|
||||
SqlSugarBase.Db.Insertable(uLog).ExecuteCommand();
|
||||
}
|
||||
|
||||
return Json("成功", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
/// <summary>
|
||||
/// 恢复出厂设置命令
|
||||
/// </summary>
|
||||
/// <param name="Serial">人脸机编号</param>
|
||||
/// <returns></returns>
|
||||
public ActionResult RestoreFactorySettinginfo(string Serial)
|
||||
{
|
||||
Entity.Rootinfo info = new Entity.Rootinfo();
|
||||
info.pmsid = -1;
|
||||
Entity.msgx msgx = new Entity.msgx();
|
||||
|
||||
StringBuilder sbperson = new StringBuilder();
|
||||
sbperson.Append("key=abcdef");
|
||||
msgx.msgid = Guid.NewGuid().ToString();
|
||||
msgx.sn = Serial;
|
||||
msgx.cmd = "RestoreFactorySetting";//恢复出场设置
|
||||
msgx.msg = System.Web.HttpUtility.HtmlDecode(sbperson.ToString());
|
||||
info.msgx = msgx;
|
||||
info.pmsid = -1;
|
||||
string sendMsg = Newtonsoft.Json.JsonConvert.SerializeObject(info);
|
||||
UdpCommunication.QueueSend(sendMsg);
|
||||
using (var db = SqlSugarBase.GesmartDb())
|
||||
{
|
||||
string sn = Serial;
|
||||
var dbt = db.Queryable<Domain.Application.FaceAll.DeviceManage>().First(x => x.SerialNo == sn);
|
||||
Domain.Application.FaceAll.ULog uLog = new Domain.Application.FaceAll.ULog
|
||||
{
|
||||
Uname = Session["username"].ToString(),
|
||||
faceSN = Serial,
|
||||
operatetype = "恢复出场设置",
|
||||
hotelcode = int.Parse(Session["hotelCode"].ToString()),
|
||||
roomid = dbt.RoomId,
|
||||
Creationtime = DateTime.Now
|
||||
};
|
||||
SqlSugarBase.Db.Insertable(uLog).ExecuteCommand();
|
||||
}
|
||||
|
||||
return Json("成功", JsonRequestBehavior.AllowGet);
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 下发固件命令
|
||||
/// </summary>
|
||||
/// <param name="ApkName">固件名称</param>
|
||||
/// <param name="RoomidList">房间集合</param>
|
||||
/// <param name="DomainNmae">域名</param>
|
||||
/// <param name="FTPPort">端口</param>
|
||||
/// <param name="UserNmae">用户名称</param>
|
||||
/// <param name="pwd">密码</param>
|
||||
/// <param name="foder">路径</param>
|
||||
/// <returns></returns>
|
||||
public ActionResult UpdateApk(string ApkName, string RoomidList, string DomainNmae, string FTPPort, string UserNmae, string pwd, string foder)
|
||||
{
|
||||
List<string> arrlist = new List<string>();
|
||||
Domain.Application.FaceAll.DeviceManage hotel = SqlSugarBase.Db.Queryable<Domain.Application.FaceAll.DeviceManage>().First(x => x.RoomId == int.Parse(RoomidList));
|
||||
Entity.Rootinfo rootinfo = new Entity.Rootinfo();
|
||||
Entity.msgx msgx = new Entity.msgx();
|
||||
msgx.msgid = Guid.NewGuid().ToString();
|
||||
if (!arrlist.Contains(msgx.msgid)) { arrlist.Add(msgx.msgid); }
|
||||
msgx.sn = hotel.SerialNo;
|
||||
msgx.cmd = "updateAPK2";//操作
|
||||
StringBuilder sbperson = new StringBuilder();
|
||||
sbperson.Append("key=abcdef");
|
||||
sbperson.Append("&url=" + foder+"/"+ ApkName);
|
||||
sbperson.Append("&Hast=" + DomainNmae);
|
||||
sbperson.Append("&UserName=" + UserNmae);
|
||||
sbperson.Append("&Port=" + FTPPort);
|
||||
sbperson.Append("&PW=" + pwd);
|
||||
//sbperson.Append("&Folder=" + foder);
|
||||
msgx.msg = System.Web.HttpUtility.HtmlDecode(sbperson.ToString());
|
||||
rootinfo.msgx = msgx;
|
||||
rootinfo.pmsid = -1;
|
||||
string sendMsg = Newtonsoft.Json.JsonConvert.SerializeObject(rootinfo);
|
||||
UdpCommunication.QueueSend(sendMsg);
|
||||
return Json(new { isok = true, arr = arrlist });
|
||||
}
|
||||
/// <summary>
|
||||
/// 上传日志api
|
||||
/// </summary>
|
||||
/// <param name="Serial">人脸机编号</param>
|
||||
/// <param name="DomainNmae">域名</param>
|
||||
/// <param name="FTPPort">端口</param>
|
||||
/// <param name="UserNmae">用户名</param>
|
||||
/// <param name="pwd">密码</param>
|
||||
/// <param name="foder">路径</param>
|
||||
/// <returns></returns>
|
||||
public ActionResult UploadLogData(string Serial,string DomainNmae,string FTPPort,string UserNmae,string pwd,string foder)
|
||||
{
|
||||
|
||||
Entity.Rootinfo info = new Entity.Rootinfo();
|
||||
info.pmsid = -1;
|
||||
Entity.msgx msgx = new Entity.msgx();
|
||||
|
||||
StringBuilder sbperson = new StringBuilder();
|
||||
sbperson.Append("key=abcdef");
|
||||
msgx.msgid = Guid.NewGuid().ToString();
|
||||
msgx.sn = Serial;
|
||||
msgx.cmd = "UploadLogData";//上传日志
|
||||
sbperson.Append("&Hast="+ DomainNmae);
|
||||
sbperson.Append("&UserName=" + UserNmae);
|
||||
sbperson.Append("&Port=" + FTPPort);
|
||||
sbperson.Append("&PW=" + pwd);
|
||||
sbperson.Append("&Folder=" + foder);
|
||||
msgx.msg = System.Web.HttpUtility.HtmlDecode(sbperson.ToString());
|
||||
info.msgx = msgx;
|
||||
info.pmsid = -1;
|
||||
string sendMsg = Newtonsoft.Json.JsonConvert.SerializeObject(info);
|
||||
UdpCommunication.QueueSend(sendMsg);
|
||||
return Json("成功", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public ActionResult setPeopleinfov19(string Serial, string HotelID, string RoomID, string IC_NO, string Groupid, string npeople,string id,string kshitime,string jieshutime)
|
||||
{
|
||||
Entity.Rootinfo info = new Entity.Rootinfo();
|
||||
info.pmsid = -1;
|
||||
Entity.msgx msgx = new Entity.msgx();
|
||||
msgx.msgid = Guid.NewGuid().ToString();
|
||||
msgx.sn = Serial;
|
||||
msgx.cmd = "setPerson";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("key=abc");
|
||||
if (npeople == "1")
|
||||
{
|
||||
sb.Append("&datatype=2");
|
||||
sb.Append("&id=432156782341123429");
|
||||
sb.Append("&name=KevinLu");
|
||||
sb.Append("&IC_NO=" + IC_NO);
|
||||
sb.Append("&ID_NO=432156782341123429");
|
||||
sb.Append("&photo=<http://face.blv-oa.com/upload/testimages/432156782341123429_661497.png>");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append("&datatype=2");
|
||||
sb.Append("&id="+ id);
|
||||
sb.Append("&name=VellaLiu");
|
||||
sb.Append("&IC_NO="+ IC_NO);
|
||||
sb.Append("&ID_NO="+id);
|
||||
sb.Append("&photo=<http://face.blv-oa.com/upload/testimages/123456782341127777_612497.jpg>");
|
||||
}
|
||||
sb.Append("&startTs="+kshitime);
|
||||
sb.Append("&endTs="+jieshutime);
|
||||
sb.Append("&passCount=10000");
|
||||
sb.Append("&HotelID=" + HotelID);
|
||||
sb.Append("&RoomID=" + RoomID);
|
||||
sb.Append("&Groupid=" + Groupid);
|
||||
msgx.msg = System.Web.HttpUtility.HtmlDecode(sb.ToString());
|
||||
info.msgx = msgx;
|
||||
string sendMsg = Newtonsoft.Json.JsonConvert.SerializeObject(info);
|
||||
UdpCommunication.QueueSend(sendMsg);
|
||||
return Json("成功", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public ActionResult getPeopleData19(string Serial, string number, string offset, string Groupid)
|
||||
{
|
||||
Entity.Rootinfo info = new Entity.Rootinfo();
|
||||
info.pmsid = -1;
|
||||
Entity.msgx msgx = new Entity.msgx();
|
||||
StringBuilder sbperson = new StringBuilder();
|
||||
sbperson.Append("key=abc");
|
||||
sbperson.Append("&number=" + number);
|
||||
sbperson.Append("&offset="+ offset);
|
||||
sbperson.Append("&Groupid=" + Groupid);
|
||||
msgx.msgid = Guid.NewGuid().ToString();
|
||||
msgx.sn = Serial;
|
||||
msgx.cmd = "listPersonByNumber";//获取人员列表
|
||||
msgx.msg = System.Web.HttpUtility.HtmlDecode(sbperson.ToString());
|
||||
info.msgx = msgx;
|
||||
info.pmsid = -1;
|
||||
string sendMsg = Newtonsoft.Json.JsonConvert.SerializeObject(info);
|
||||
UdpCommunication.QueueSend(sendMsg);
|
||||
using (var db = SqlSugarBase.GesmartDb())
|
||||
{
|
||||
string sn = Serial;
|
||||
var dbt = db.Queryable<Domain.Application.FaceAll.DeviceManage>().First(x => x.SerialNo == sn);
|
||||
Domain.Application.FaceAll.ULog uLog = new Domain.Application.FaceAll.ULog
|
||||
{
|
||||
Uname = Session["username"].ToString(),
|
||||
faceSN = Serial,
|
||||
operatetype = "获取人员列表",
|
||||
hotelcode = int.Parse(Session["hotelCode"].ToString()),
|
||||
roomid = dbt.RoomId,
|
||||
Creationtime = DateTime.Now
|
||||
};
|
||||
SqlSugarBase.Db.Insertable(uLog).ExecuteCommand();
|
||||
}
|
||||
|
||||
return Json("成功", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public ActionResult selectPeopleData191(string Serial, string id, string Groupid)
|
||||
{
|
||||
Entity.Rootinfo info = new Entity.Rootinfo();
|
||||
info.pmsid = -1;
|
||||
Entity.msgx msgx = new Entity.msgx();
|
||||
msgx.msgid = Guid.NewGuid().ToString();
|
||||
msgx.sn = Serial;
|
||||
msgx.cmd = "getPerson";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("key=abc");
|
||||
sb.Append("&id="+ id);
|
||||
sb.Append("&Groupid=" + Groupid);
|
||||
msgx.msg = System.Web.HttpUtility.HtmlDecode(sb.ToString());
|
||||
info.msgx = msgx;
|
||||
|
||||
|
||||
string sendMsg = Newtonsoft.Json.JsonConvert.SerializeObject(info);
|
||||
UdpCommunication.QueueSend(sendMsg);
|
||||
return Json("成功", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
public ActionResult rebootface191(string Serial, string id, string HotelID, string RoomID, string Groupid)
|
||||
{
|
||||
Entity.Rootinfo info = new Entity.Rootinfo();
|
||||
info.pmsid = -1;
|
||||
|
||||
Entity.msgx msgx = new Entity.msgx();
|
||||
msgx.msgid = Guid.NewGuid().ToString();
|
||||
msgx.sn = Serial;
|
||||
msgx.cmd = "removePerson";
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.Append("key=abc");
|
||||
builder.Append("&id="+id);
|
||||
builder.Append("&HotelID=" + HotelID);
|
||||
builder.Append("&RoomID=" + RoomID);
|
||||
builder.Append("&Groupid=" + Groupid);
|
||||
//if (isNew1Point6)
|
||||
//{
|
||||
// if (npeople == "1")
|
||||
// {
|
||||
// builder.Append("&id=[432156782341123429]");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// builder.Append("&id=[123456782341127777]");
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// if (npeople == "1")
|
||||
// {
|
||||
// builder.Append("&id=432156782341123429");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// builder.Append("&id=123456782341127777");
|
||||
// }
|
||||
//}
|
||||
|
||||
msgx.msg = System.Web.HttpUtility.HtmlDecode(builder.ToString());
|
||||
info.msgx = msgx;
|
||||
|
||||
string sendMsg = Newtonsoft.Json.JsonConvert.SerializeObject(info);
|
||||
UdpCommunication.QueueSend(sendMsg);
|
||||
return Json("成功", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public ActionResult removePeopleDataByGroup19(string Serial,string Groupid)
|
||||
{
|
||||
Entity.Rootinfo info = new Entity.Rootinfo();
|
||||
info.pmsid = -1;
|
||||
|
||||
Entity.msgx msgx = new Entity.msgx();
|
||||
msgx.msgid = Guid.NewGuid().ToString();
|
||||
msgx.sn = Serial;
|
||||
msgx.cmd = "removeGroup";
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.Append("key=abc");
|
||||
builder.Append("&Group=" + Groupid);
|
||||
msgx.msg = System.Web.HttpUtility.HtmlDecode(builder.ToString());
|
||||
info.msgx = msgx;
|
||||
|
||||
string sendMsg = Newtonsoft.Json.JsonConvert.SerializeObject(info);
|
||||
UdpCommunication.QueueSend(sendMsg);
|
||||
return Json("成功", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
public ActionResult GetSetAPKSandProgressData(List<string> ApkName)
|
||||
{
|
||||
Dictionary<String, List<Face.Domain.Application.FaceAll.facedevicerxtxinfo>> listdevprog = new Dictionary<String, List<Face.Domain.Application.FaceAll.facedevicerxtxinfo>>();
|
||||
|
||||
using (var db = SqlSugarBase.GesmartDb())
|
||||
{
|
||||
List<Face.Domain.Application.FaceAll.facedevicerxtxinfo> matchedList = db.Queryable<Face.Domain.Application.FaceAll.facedevicerxtxinfo>()
|
||||
.Where(x => x.msgid== ApkName[0] && x.direction == "Rx")
|
||||
.ToList();
|
||||
List<Face.Domain.Application.FaceAll.facedevicerxtxinfo> currMsgList = matchedList.Where(x => x.msgid == ApkName[0]).ToList();
|
||||
listdevprog.Add(ApkName[0], currMsgList);
|
||||
}
|
||||
return Json(listdevprog);
|
||||
}
|
||||
}
|
||||
public class GetDeviceinfo
|
||||
{
|
||||
public string Token { get; set; }
|
||||
public string ProtocolVersion { get; set; }
|
||||
|
||||
public string MsgID { get; set; }
|
||||
|
||||
public string DateTime { get; set; }
|
||||
public string Brand { get; set; }
|
||||
public string SN { get; set; }
|
||||
|
||||
public string CMD { get; set; }
|
||||
public Parainfo Para { get; set; }
|
||||
}
|
||||
public class Parainfo
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user