修改order_info表中的字段doctor_Code,去掉冰箱储物箱等相关提示信息
This commit is contained in:
parent
a4a745e7b8
commit
d582bba6c0
|
@ -37,7 +37,7 @@
|
||||||
<!-- 按处方还药或者按取药记录还药 1:处方(ReturnDrugWindow2)2:药品(ReturnDrugWindow)-->
|
<!-- 按处方还药或者按取药记录还药 1:处方(ReturnDrugWindow2)2:药品(ReturnDrugWindow)-->
|
||||||
<add key="returnDrugMode" value="2" />
|
<add key="returnDrugMode" value="2" />
|
||||||
<!-- 自动退出时间,单位秒,为0时不自动退出 -->
|
<!-- 自动退出时间,单位秒,为0时不自动退出 -->
|
||||||
<add key="autoExit" value="0"/>
|
<add key="autoExit" value="3"/>
|
||||||
|
|
||||||
<!-- 无操作退出录像时间,单位秒,为0时不退出录像 -->
|
<!-- 无操作退出录像时间,单位秒,为0时不退出录像 -->
|
||||||
<add key="stopRecord" value="180"/>
|
<add key="stopRecord" value="180"/>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
|
|
|
@ -252,7 +252,7 @@ namespace DM_Weight.Models
|
||||||
|
|
||||||
|
|
||||||
//麻醉师工号
|
//麻醉师工号
|
||||||
[SugarColumn(ColumnName = "doctorCode")]
|
[SugarColumn(ColumnName = "doctor_Code")]
|
||||||
public string DoctorCode { get; set; }
|
public string DoctorCode { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,7 @@
|
||||||
using Modbus.Device;
|
using DM_Weight.ViewModels;
|
||||||
|
using log4net;
|
||||||
|
using log4net.Repository.Hierarchy;
|
||||||
|
using Modbus.Device;
|
||||||
using Polly;
|
using Polly;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -20,6 +23,7 @@ namespace DM_Weight.Port
|
||||||
private TcpClient client;
|
private TcpClient client;
|
||||||
private static ModbusHelper instance;
|
private static ModbusHelper instance;
|
||||||
private static readonly object objLock = new object();
|
private static readonly object objLock = new object();
|
||||||
|
private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
|
||||||
public ModbusHelper()
|
public ModbusHelper()
|
||||||
{
|
{
|
||||||
socket = MakeKeepALiveSocket();
|
socket = MakeKeepALiveSocket();
|
||||||
|
@ -56,7 +60,8 @@ namespace DM_Weight.Port
|
||||||
.Retry(3, (exception, retryCount) =>
|
.Retry(3, (exception, retryCount) =>
|
||||||
{
|
{
|
||||||
this.Dispose();
|
this.Dispose();
|
||||||
Debug.WriteLine($"获取所有箱子门状态出错,第{retryCount}次重试", exception);
|
//Debug.WriteLine($"获取所有箱子门状态出错,第{retryCount}次重试", exception);
|
||||||
|
logger.Info($"获取所有箱子门状态出错,第{retryCount}次重试, 异常信息{exception}");
|
||||||
this.SetModusIpMaster();
|
this.SetModusIpMaster();
|
||||||
// return TimeSpan.FromSeconds (1);
|
// return TimeSpan.FromSeconds (1);
|
||||||
}).Execute<bool[]>(() =>
|
}).Execute<bool[]>(() =>
|
||||||
|
@ -70,6 +75,7 @@ namespace DM_Weight.Port
|
||||||
{
|
{
|
||||||
flags[i] = r2[17 - i] == '1' ? true : false;
|
flags[i] = r2[17 - i] == '1' ? true : false;
|
||||||
}
|
}
|
||||||
|
logger.Info($"获取所有箱子门状态返回:{string.Join(',',flags)}");
|
||||||
return flags;
|
return flags;
|
||||||
});
|
});
|
||||||
return bools;
|
return bools;
|
||||||
|
@ -80,13 +86,16 @@ namespace DM_Weight.Port
|
||||||
Policy.Handle<Exception>().Retry(3, ((exception, retryCount) =>
|
Policy.Handle<Exception>().Retry(3, ((exception, retryCount) =>
|
||||||
{
|
{
|
||||||
this.Dispose();
|
this.Dispose();
|
||||||
Debug.WriteLine($"打开箱子出错,第{retryCount}次重试", exception);
|
//Debug.WriteLine($"打开箱子出错,第{retryCount}次重试", exception);
|
||||||
|
logger.Info($"打开箱子出错,第{retryCount}次重试,异常信息{exception}");
|
||||||
this.SetModusIpMaster();
|
this.SetModusIpMaster();
|
||||||
//return TimeSpan.FromSeconds (1);
|
//return TimeSpan.FromSeconds (1);
|
||||||
})).Execute(() =>
|
})).Execute(() =>
|
||||||
{
|
{
|
||||||
|
logger.Info($"正在打开{boxNum}号药箱");
|
||||||
master.WriteSingleRegister(1, (ushort)boxNum, 14);
|
master.WriteSingleRegister(1, (ushort)boxNum, 14);
|
||||||
Console.WriteLine($"开门指令已发送{(ushort)boxNum}");
|
logger.Info($"开门指令已发送{(ushort)boxNum}");
|
||||||
|
//Console.WriteLine($"开门指令已发送{(ushort)boxNum}");
|
||||||
bFlag = true;
|
bFlag = true;
|
||||||
});
|
});
|
||||||
return bFlag;
|
return bFlag;
|
||||||
|
|
|
@ -687,52 +687,52 @@ namespace DM_Weight.Port
|
||||||
public PortUtil(IEventAggregator eventAggregator, CHKFunction chkFunction)
|
public PortUtil(IEventAggregator eventAggregator, CHKFunction chkFunction)
|
||||||
{
|
{
|
||||||
_eventAggregator = eventAggregator;
|
_eventAggregator = eventAggregator;
|
||||||
try
|
//try
|
||||||
{
|
//{
|
||||||
string DrawerPortPath = ConfigurationManager.AppSettings["DrawerPortPath"];
|
// string DrawerPortPath = ConfigurationManager.AppSettings["DrawerPortPath"];
|
||||||
logger.Info($"打开抽屉串口【{DrawerPortPath}】");
|
// logger.Info($"打开抽屉串口【{DrawerPortPath}】");
|
||||||
drawerSerial = new SerialPort(DrawerPortPath, 9600, Parity.None, 8);
|
// drawerSerial = new SerialPort(DrawerPortPath, 9600, Parity.None, 8);
|
||||||
drawerSerial.Open();
|
// drawerSerial.Open();
|
||||||
logger.Info($"抽屉串口打开结果【{drawerSerial.IsOpen}】");
|
// logger.Info($"抽屉串口打开结果【{drawerSerial.IsOpen}】");
|
||||||
}
|
//}
|
||||||
catch (Exception e)
|
//catch (Exception e)
|
||||||
{
|
//{
|
||||||
logger.Error("抽屉串口打开错误" + e.Message);
|
// logger.Error("抽屉串口打开错误" + e.Message);
|
||||||
}
|
//}
|
||||||
|
|
||||||
try
|
//try
|
||||||
{
|
//{
|
||||||
string ScanCodePortPath = ConfigurationManager.AppSettings["ScanCodePortPath"];
|
// string ScanCodePortPath = ConfigurationManager.AppSettings["ScanCodePortPath"];
|
||||||
logger.Info($"打开条码枪串口【{ScanCodePortPath}】");
|
// logger.Info($"打开条码枪串口【{ScanCodePortPath}】");
|
||||||
scanCodeSerial = new SerialPort(ScanCodePortPath, 9600, Parity.None, 8);
|
// scanCodeSerial = new SerialPort(ScanCodePortPath, 9600, Parity.None, 8);
|
||||||
scanCodeSerial.DataReceived += (object sender, System.IO.Ports.SerialDataReceivedEventArgs e) =>
|
// scanCodeSerial.DataReceived += (object sender, System.IO.Ports.SerialDataReceivedEventArgs e) =>
|
||||||
{
|
// {
|
||||||
string code = scanCodeSerial.ReadExisting();
|
// string code = scanCodeSerial.ReadExisting();
|
||||||
_eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
|
// _eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
|
||||||
{
|
// {
|
||||||
EventType = util.EventType.CODESCAN,
|
// EventType = util.EventType.CODESCAN,
|
||||||
Code = code,
|
// Code = code,
|
||||||
});
|
// });
|
||||||
};
|
// };
|
||||||
scanCodeSerial.Open();
|
// scanCodeSerial.Open();
|
||||||
logger.Info($"条码枪串口打开结果【{scanCodeSerial.IsOpen}】");
|
// logger.Info($"条码枪串口打开结果【{scanCodeSerial.IsOpen}】");
|
||||||
}
|
//}
|
||||||
catch (Exception e)
|
//catch (Exception e)
|
||||||
{
|
//{
|
||||||
logger.Error("条码枪串口打开错误" + e.Message);
|
// logger.Error("条码枪串口打开错误" + e.Message);
|
||||||
}
|
//}
|
||||||
try
|
//try
|
||||||
{
|
//{
|
||||||
string FridgePortPath = ConfigurationManager.AppSettings["FridgePortPath"];
|
// string FridgePortPath = ConfigurationManager.AppSettings["FridgePortPath"];
|
||||||
logger.Info($"打开冰箱串口【{FridgePortPath}】");
|
// logger.Info($"打开冰箱串口【{FridgePortPath}】");
|
||||||
fridgeSerial = new SerialPort(FridgePortPath, 9600, Parity.None, 8);
|
// fridgeSerial = new SerialPort(FridgePortPath, 9600, Parity.None, 8);
|
||||||
fridgeSerial.Open();
|
// fridgeSerial.Open();
|
||||||
logger.Info($"冰箱串口打开结果【{fridgeSerial.IsOpen}】");
|
// logger.Info($"冰箱串口打开结果【{fridgeSerial.IsOpen}】");
|
||||||
}
|
//}
|
||||||
catch (Exception e)
|
//catch (Exception e)
|
||||||
{
|
//{
|
||||||
logger.Error("冰箱串口打开错误" + e.Message);
|
// logger.Error("冰箱串口打开错误" + e.Message);
|
||||||
}
|
//}
|
||||||
if (_canBusExsit)
|
if (_canBusExsit)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -502,7 +502,7 @@ namespace DM_Weight.ViewModels
|
||||||
for (int j = 0; j < oi.OrderDetailList.Count; j++)
|
for (int j = 0; j < oi.OrderDetailList.Count; j++)
|
||||||
{
|
{
|
||||||
oi._OrderDetail = oi.OrderDetailList[j];
|
oi._OrderDetail = oi.OrderDetailList[j];
|
||||||
int drawerNo= DrawerNo+1;
|
int drawerNo = DrawerNo + 1;
|
||||||
ChannelStock cs = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
ChannelStock cs = SqlSugarHelper.Db.Queryable<ChannelStock>()
|
||||||
.Where(cs => cs.DrugId == oi._OrderDetail.DrugId
|
.Where(cs => cs.DrugId == oi._OrderDetail.DrugId
|
||||||
&& cs.ManuNo == oi._OrderDetail.SetManuNo
|
&& cs.ManuNo == oi._OrderDetail.SetManuNo
|
||||||
|
@ -541,12 +541,12 @@ namespace DM_Weight.ViewModels
|
||||||
#region 记录 注射剂使用与交接记录报表
|
#region 记录 注射剂使用与交接记录报表
|
||||||
//查询发药时间
|
//查询发药时间
|
||||||
//MachineRecord SendMachineRecord = SqlSugarHelper.Db.Queryable<MachineRecord>().Where(mr => mr.DrawerNo == cs.DrawerNo && mr.Type == 2)
|
//MachineRecord SendMachineRecord = SqlSugarHelper.Db.Queryable<MachineRecord>().Where(mr => mr.DrawerNo == cs.DrawerNo && mr.Type == 2)
|
||||||
//.OrderByDescending(mr => mr.OperationTime)
|
//.OrderByDescending(mr => mr.OperationTime)
|
||||||
//.First();
|
//.First();
|
||||||
//string retUser = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5") && cl.DrawerNo == cs.DrawerNo)
|
//string retUser = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5") && cl.DrawerNo == cs.DrawerNo)
|
||||||
//.Select(cl => cl.BelongUser).First();
|
//.Select(cl => cl.BelongUser).First();
|
||||||
|
|
||||||
RejectionReport rejectionReport = SqlSugarHelper.Db.Queryable<RejectionReport>().Where(rp => rp.DrugId == cs.DrugId && rp.DrawerNo == cs.DrawerNo).OrderByDescending(rp=>rp.SendDate).First();
|
RejectionReport rejectionReport = SqlSugarHelper.Db.Queryable<RejectionReport>().Where(rp => rp.DrugId == cs.DrugId && rp.DrawerNo == cs.DrawerNo).OrderByDescending(rp => rp.SendDate).First();
|
||||||
|
|
||||||
//发药信息
|
//发药信息
|
||||||
//RejectionReport rejectionReport = new RejectionReport();
|
//RejectionReport rejectionReport = new RejectionReport();
|
||||||
|
@ -719,22 +719,24 @@ namespace DM_Weight.ViewModels
|
||||||
public async void OpenBoxAction(string strDrawerNo)
|
public async void OpenBoxAction(string strDrawerNo)
|
||||||
{
|
{
|
||||||
DrawerNo = Convert.ToInt32(strDrawerNo);
|
DrawerNo = Convert.ToInt32(strDrawerNo);
|
||||||
|
MachineRecord machineRecord = new MachineRecord();
|
||||||
|
machineRecord.MachineId = "DM5";
|
||||||
|
machineRecord.DrawerNo = DrawerNo;
|
||||||
|
machineRecord.Operator = HomeWindowViewModel.Operator?.Id;
|
||||||
|
machineRecord.OperationTime = DateTime.Now;
|
||||||
|
machineRecord.Type = 55;
|
||||||
|
machineRecord.InvoiceId = $"打开{DrawerNo + 1}号药箱";
|
||||||
|
|
||||||
|
|
||||||
if (DrawerNo > 0)
|
if (DrawerNo > 0)
|
||||||
{
|
{
|
||||||
DrawerNo -= 1;
|
DrawerNo -= 1;
|
||||||
RequestData();
|
RequestData();
|
||||||
Status = 1;
|
Status = 1;
|
||||||
_portUtil.SpeakAsync($"正在打开{DrawerNo + 1}号药箱");
|
_portUtil.SpeakAsync($"正在打开{DrawerNo + 1}号药箱");
|
||||||
|
logger.Info($"正在打开{DrawerNo + 1}号药箱");
|
||||||
//记录开药箱日志
|
//记录开药箱日志
|
||||||
SqlSugarHelper.Db.Insertable(new MachineRecord()
|
SqlSugarHelper.Db.Insertable(machineRecord).ExecuteCommand();
|
||||||
{
|
|
||||||
MachineId = "DM5",
|
|
||||||
DrawerNo = DrawerNo,
|
|
||||||
Operator = HomeWindowViewModel.Operator?.Id,
|
|
||||||
OperationTime = DateTime.Now,
|
|
||||||
Type = 55,
|
|
||||||
InvoiceId = $"打开{DrawerNo + 1}号药箱",
|
|
||||||
}).ExecuteCommand();
|
|
||||||
ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo);
|
ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -755,72 +757,72 @@ namespace DM_Weight.ViewModels
|
||||||
// 取消消息订阅
|
// 取消消息订阅
|
||||||
//_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
|
//_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
|
||||||
}
|
}
|
||||||
void DoMyPrismEvent(DeviceMsg msg)
|
//void DoMyPrismEvent(DeviceMsg msg)
|
||||||
{
|
//{
|
||||||
switch (msg.EventType)
|
// switch (msg.EventType)
|
||||||
{
|
// {
|
||||||
// 药箱打开
|
// // 药箱打开
|
||||||
case EventType.DRAWEROPEN:
|
// case EventType.DRAWEROPEN:
|
||||||
if (Status == 1)
|
// if (Status == 1)
|
||||||
{
|
// {
|
||||||
Status = 2;
|
// Status = 2;
|
||||||
}
|
// }
|
||||||
//记录开药箱日志
|
// //记录开药箱日志
|
||||||
SqlSugarHelper.Db.Insertable(new MachineRecord()
|
// SqlSugarHelper.Db.Insertable(new MachineRecord()
|
||||||
{
|
// {
|
||||||
MachineId = "DM5",
|
// MachineId = "DM5",
|
||||||
DrawerNo = _portUtil.DrawerNo,
|
// DrawerNo = _portUtil.DrawerNo,
|
||||||
Operator = HomeWindowViewModel.Operator?.Id,
|
// Operator = HomeWindowViewModel.Operator?.Id,
|
||||||
OperationTime = DateTime.Now,
|
// OperationTime = DateTime.Now,
|
||||||
Type = 55,
|
// Type = 55,
|
||||||
InvoiceId = $"打开{DrawerNo}号药箱",
|
// InvoiceId = $"打开{DrawerNo}号药箱",
|
||||||
}).ExecuteCommand();
|
// }).ExecuteCommand();
|
||||||
_portUtil.GetBoxStatus();
|
// _portUtil.GetBoxStatus();
|
||||||
break;
|
// break;
|
||||||
// 药箱关闭
|
// // 药箱关闭
|
||||||
case EventType.DRAWERCLOSE:
|
// case EventType.DRAWERCLOSE:
|
||||||
//记录药箱操作日志
|
// //记录药箱操作日志
|
||||||
SqlSugarHelper.Db.Insertable(new MachineRecord()
|
// SqlSugarHelper.Db.Insertable(new MachineRecord()
|
||||||
{
|
// {
|
||||||
MachineId = "DM5",
|
// MachineId = "DM5",
|
||||||
DrawerNo = _portUtil.DrawerNo,
|
// DrawerNo = _portUtil.DrawerNo,
|
||||||
Operator = HomeWindowViewModel.Operator?.Id,
|
// Operator = HomeWindowViewModel.Operator?.Id,
|
||||||
OperationTime = DateTime.Now,
|
// OperationTime = DateTime.Now,
|
||||||
Type = 55,
|
// Type = 55,
|
||||||
InvoiceId = "药箱关闭",
|
// InvoiceId = "药箱关闭",
|
||||||
}).ExecuteCommand();
|
// }).ExecuteCommand();
|
||||||
|
|
||||||
if (Status == 2)
|
// if (Status == 2)
|
||||||
{
|
// {
|
||||||
Status = 3;
|
// Status = 3;
|
||||||
}
|
// }
|
||||||
_portUtil.Operate = false;
|
// _portUtil.Operate = false;
|
||||||
break;
|
// break;
|
||||||
// 打开失败
|
// // 打开失败
|
||||||
case EventType.OPENERROR:
|
// case EventType.OPENERROR:
|
||||||
AlertMsg alertMsg = new AlertMsg
|
// AlertMsg alertMsg = new AlertMsg
|
||||||
{
|
// {
|
||||||
Message = msg.Message,
|
// Message = msg.Message,
|
||||||
Type = MsgType.ERROR
|
// Type = MsgType.ERROR
|
||||||
};
|
// };
|
||||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
|
||||||
Status = 0;
|
// Status = 0;
|
||||||
|
|
||||||
//记录药箱操作日志
|
// //记录药箱操作日志
|
||||||
SqlSugarHelper.Db.Insertable(new MachineRecord()
|
// SqlSugarHelper.Db.Insertable(new MachineRecord()
|
||||||
{
|
// {
|
||||||
MachineId = "DM5",
|
// MachineId = "DM5",
|
||||||
DrawerNo = _portUtil.DrawerNo,
|
// DrawerNo = _portUtil.DrawerNo,
|
||||||
Operator = HomeWindowViewModel.Operator?.Id,
|
// Operator = HomeWindowViewModel.Operator?.Id,
|
||||||
OperationTime = DateTime.Now,
|
// OperationTime = DateTime.Now,
|
||||||
Type = 55,
|
// Type = 55,
|
||||||
InvoiceId = "药箱打开失败",
|
// InvoiceId = "药箱打开失败",
|
||||||
}).ExecuteCommand();
|
// }).ExecuteCommand();
|
||||||
_portUtil.Operate = false;
|
// _portUtil.Operate = false;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
public class TotalDrug
|
public class TotalDrug
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,7 @@ using Newtonsoft.Json.Linq;
|
||||||
using DM_Weight.msg;
|
using DM_Weight.msg;
|
||||||
using DM_Weight.HIKVISION;
|
using DM_Weight.HIKVISION;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace DM_Weight.ViewModels
|
namespace DM_Weight.ViewModels
|
||||||
{
|
{
|
||||||
|
@ -286,10 +287,26 @@ namespace DM_Weight.ViewModels
|
||||||
//}
|
//}
|
||||||
if (SelectedMenu != null && SelectedMenu.PremissionName == "退出")
|
if (SelectedMenu != null && SelectedMenu.PremissionName == "退出")
|
||||||
{
|
{
|
||||||
logger.Info($"用户【{Operator?.Nickname}】退出登录");
|
bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
|
||||||
Operator = null;
|
bool allTrue = Array.TrueForAll(boolArrs, b => b);
|
||||||
Reviewer = null;
|
//false是关着,true是开着
|
||||||
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
if (!allTrue)
|
||||||
|
{
|
||||||
|
logger.Info($"用户【{Operator?.Nickname}】退出登录");
|
||||||
|
Operator = null;
|
||||||
|
Reviewer = null;
|
||||||
|
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//还有药箱开着不能退出
|
||||||
|
AlertMsg alertMsg = new AlertMsg
|
||||||
|
{
|
||||||
|
Message = "请关闭药箱后再退出系统",
|
||||||
|
Type = MsgType.ERROR
|
||||||
|
};
|
||||||
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -349,24 +366,24 @@ namespace DM_Weight.ViewModels
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelegateCommand OpenRecoverCommand
|
//public DelegateCommand OpenRecoverCommand
|
||||||
{
|
//{
|
||||||
get => new DelegateCommand(async () =>
|
// get => new DelegateCommand(async () =>
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
_portUtil.WindowName = "HomeWindow";
|
// _portUtil.WindowName = "HomeWindow";
|
||||||
_portUtil.Operate = true;
|
// _portUtil.Operate = true;
|
||||||
await _portUtil.OpenStorage();
|
// await _portUtil.OpenStorage();
|
||||||
_portUtil.ResetData();
|
// _portUtil.ResetData();
|
||||||
|
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
logger.Info($"OpenRecoverCommand异常{ex.Message}");
|
// logger.Info($"OpenRecoverCommand异常{ex.Message}");
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
//}
|
||||||
|
|
||||||
public DelegateCommand<string> OpenEditPasswordDialog
|
public DelegateCommand<string> OpenEditPasswordDialog
|
||||||
{
|
{
|
||||||
|
@ -406,35 +423,35 @@ namespace DM_Weight.ViewModels
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取温度信息
|
/// 获取温度信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async void GetWD(object sender, ElapsedEventArgs e)
|
//private async void GetWD(object sender, ElapsedEventArgs e)
|
||||||
{
|
//{
|
||||||
if (!_portUtil.FridgeOperate)
|
// if (!_portUtil.FridgeOperate)
|
||||||
{
|
// {
|
||||||
string retStr = string.Empty;
|
// string retStr = string.Empty;
|
||||||
byte[] data = null;
|
// byte[] data = null;
|
||||||
float retT = await _portUtil.GetFridgeTemperature(1);
|
// float retT = await _portUtil.GetFridgeTemperature(1);
|
||||||
Thread.Sleep(80);
|
// Thread.Sleep(80);
|
||||||
WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT - 1.5), 2)}℃";
|
// WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT - 1.5), 2)}℃";
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
private async void GetWD()
|
//private async void GetWD()
|
||||||
{
|
//{
|
||||||
if (!_portUtil.FridgeOperate)
|
// if (!_portUtil.FridgeOperate)
|
||||||
{
|
// {
|
||||||
string retStr = string.Empty;
|
// string retStr = string.Empty;
|
||||||
byte[] data = null;
|
// byte[] data = null;
|
||||||
float retT = await _portUtil.GetFridgeTemperature(1);
|
// float retT = await _portUtil.GetFridgeTemperature(1);
|
||||||
Thread.Sleep(80);
|
// Thread.Sleep(80);
|
||||||
WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT - 1.5), 2)}℃;";
|
// WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT - 1.5), 2)}℃;";
|
||||||
if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 1)
|
// if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 1)
|
||||||
{
|
// {
|
||||||
float retTemp = await _portUtil.GetFridgeTemperature(2);
|
// float retTemp = await _portUtil.GetFridgeTemperature(2);
|
||||||
Thread.Sleep(80);
|
// Thread.Sleep(80);
|
||||||
WD += $"{retTemp}℃";
|
// WD += $"{retTemp}℃";
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
//保存温湿度信息
|
//保存温湿度信息
|
||||||
private async void GetWSD(object sender, ElapsedEventArgs e)
|
private async void GetWSD(object sender, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -494,11 +511,11 @@ namespace DM_Weight.ViewModels
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查看冰箱温度
|
/// 查看冰箱温度
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DelegateCommand CheckWDCommand { get => new DelegateCommand(CheckAction); }
|
//public DelegateCommand CheckWDCommand { get => new DelegateCommand(CheckAction); }
|
||||||
private void CheckAction()
|
//private void CheckAction()
|
||||||
{
|
//{
|
||||||
GetWD();
|
// GetWD();
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
//这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
|
//这个方法用于拦截请求,continuationCallback(true)就是不拦截,continuationCallback(false)拦截本次操作
|
||||||
|
@ -552,16 +569,31 @@ namespace DM_Weight.ViewModels
|
||||||
if (autoExit > 0)
|
if (autoExit > 0)
|
||||||
{
|
{
|
||||||
System.Timers.Timer timer = new System.Timers.Timer();
|
System.Timers.Timer timer = new System.Timers.Timer();
|
||||||
timer.Interval = 1000;
|
timer.Interval = 100;
|
||||||
timer.Elapsed += (sender, e) =>
|
timer.Elapsed += (sender, e) =>
|
||||||
{
|
{
|
||||||
// 串口无人操作
|
// 串口无人操作
|
||||||
if (!_portUtil.Operate)
|
bool[] boolArrs = ModbusHelper.GetInstance().GetAllBoxState();
|
||||||
|
bool allTrue = Array.TrueForAll(boolArrs, b => b==false);
|
||||||
|
logger.Info($"进入自动退出定时方法{allTrue}");
|
||||||
|
//false是关着,true是开着
|
||||||
|
if (allTrue)
|
||||||
{
|
{
|
||||||
|
//PerformanceCounter pc = new PerformanceCounter("System", "% Idle Time", true);
|
||||||
|
//float systemIdleTime = pc.NextValue();
|
||||||
|
//Console.WriteLine($"systemIdleTime:{systemIdleTime}");
|
||||||
|
|
||||||
|
//// 获取系统空闲时间
|
||||||
|
//TimeSpan idleTime = SystemInformation.IdleTime;
|
||||||
|
//// 打印空闲时间
|
||||||
|
//Console.WriteLine("系统空闲时间: " + idleTime.ToString());
|
||||||
|
long lTime = CheckComputerFreeState.GetLastInputTime();
|
||||||
|
logger.Info($"自动退出时间{lTime}");
|
||||||
// 30秒内无人操作鼠标键盘
|
// 30秒内无人操作鼠标键盘
|
||||||
if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
|
//if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
|
||||||
|
if (lTime > autoExit)
|
||||||
{
|
{
|
||||||
logger.Info($"设备30秒内无人操作,用户【{Operator?.Nickname}】自动退出登录");
|
logger.Info($"设备{autoExit}秒内无人操作,用户【{Operator?.Nickname}】自动退出登录");
|
||||||
_chkFunction.HIKStopDVRRecord();
|
_chkFunction.HIKStopDVRRecord();
|
||||||
Operator = null;
|
Operator = null;
|
||||||
Reviewer = null;
|
Reviewer = null;
|
||||||
|
|
|
@ -120,13 +120,13 @@
|
||||||
Header="修改密码" />
|
Header="修改密码" />
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Grid Grid.Column="2">
|
<!--<Grid Grid.Column="2">
|
||||||
<StackPanel Margin="6" Orientation="Horizontal" HorizontalAlignment="Right">
|
<StackPanel Margin="6" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
<Button Content="储物箱" Command="{Binding OpenRecoverCommand}" Visibility="{Binding Is16Drawer, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource MaterialDesignFlatSecondaryLightButton}" />
|
<Button Content="储物箱" Command="{Binding OpenRecoverCommand}" Visibility="{Binding Is16Drawer, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource MaterialDesignFlatSecondaryLightButton}" />
|
||||||
<!--<TextBlock Margin="0,10,10,0" Text="{Binding WD}" Foreground="White" FontWeight="Bold" FontSize="14"/>-->
|
--><!--<TextBlock Margin="0,10,10,0" Text="{Binding WD}" Foreground="White" FontWeight="Bold" FontSize="14"/>--><!--
|
||||||
<Button Content="查看冰箱温度" Visibility="{Binding HasFridge}" Command="{Binding CheckWDCommand}" Style="{StaticResource MaterialDesignFlatSecondaryLightButton}"/>
|
<Button Content="查看冰箱温度" Visibility="{Binding HasFridge}" Command="{Binding CheckWDCommand}" Style="{StaticResource MaterialDesignFlatSecondaryLightButton}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>-->
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@
|
||||||
|
|
||||||
<materialDesign:Card Foreground="{DynamicResource PrimaryHueLightForegroundBrush}" Padding="8">
|
<materialDesign:Card Foreground="{DynamicResource PrimaryHueLightForegroundBrush}" Padding="8">
|
||||||
|
|
||||||
<Button Width="120" Content="{Binding SelfContent}" Command="{Binding OpenBoxDelegate}" CommandParameter="0"
|
<Button Width="180" Height="70" Content="{Binding SelfContent}" Command="{Binding OpenBoxDelegate}" CommandParameter="0" FontSize="30" Foreground="Red"
|
||||||
IsEnabled="{Binding SelfEnable}"
|
IsEnabled="{Binding SelfEnable}"
|
||||||
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding SelfStatus, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding SelfStatus, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||||
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding SelfStatus, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding SelfStatus, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Management;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -49,5 +50,21 @@ namespace DM_Weight.util
|
||||||
return icount;
|
return icount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ulong GetSystemIdleTime()
|
||||||
|
{
|
||||||
|
ulong idleTime = 0;
|
||||||
|
ManagementClass mc = new ManagementClass("Win32_PerfFormattedData_PerfOS_Processor");
|
||||||
|
ManagementObjectCollection moc = mc.GetInstances();
|
||||||
|
|
||||||
|
foreach (ManagementObject mo in moc)
|
||||||
|
{
|
||||||
|
idleTime = (ulong)mo.Properties["IdleTime"].Value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Console.WriteLine(idleTime);
|
||||||
|
return idleTime;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue