录像机登录失败会在登录界面显示提示信息
This commit is contained in:
parent
e3054d0d28
commit
c9de968c55
|
@ -7,11 +7,14 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using DM_Weight.Port;
|
||||||
|
using log4net;
|
||||||
|
|
||||||
namespace DM_Weight.HIKVISION
|
namespace DM_Weight.HIKVISION
|
||||||
{
|
{
|
||||||
public class CHKFunction
|
public class CHKFunction
|
||||||
{
|
{
|
||||||
|
private readonly ILog logger = LogManager.GetLogger(typeof(CHKFunction));
|
||||||
private bool m_bInitSDK = false;
|
private bool m_bInitSDK = false;
|
||||||
|
|
||||||
private Int32 m_lRealHandle = -1;
|
private Int32 m_lRealHandle = -1;
|
||||||
|
@ -38,6 +41,7 @@ namespace DM_Weight.HIKVISION
|
||||||
{
|
{
|
||||||
//MessageBox.Show("NET_DVR_Init error!");
|
//MessageBox.Show("NET_DVR_Init error!");
|
||||||
//return;
|
//return;
|
||||||
|
logger.Info("NET_DVR_Init error!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -90,12 +94,13 @@ namespace DM_Weight.HIKVISION
|
||||||
{
|
{
|
||||||
iLastErr = CHCNetSDK.NET_DVR_GetLastError();
|
iLastErr = CHCNetSDK.NET_DVR_GetLastError();
|
||||||
str = "NET_DVR_Login_V40 failed, error code= " + iLastErr; //登录失败,输出错误号
|
str = "NET_DVR_Login_V40 failed, error code= " + iLastErr; //登录失败,输出错误号
|
||||||
MessageBox.Show(str);
|
logger.Info(str);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//登录成功
|
//登录成功
|
||||||
//MessageBox.Show("Login Success!");
|
//MessageBox.Show("Login Success!");
|
||||||
|
logger.Info("Login Success!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -105,12 +110,14 @@ namespace DM_Weight.HIKVISION
|
||||||
if (m_lRealHandle >= 0)
|
if (m_lRealHandle >= 0)
|
||||||
{
|
{
|
||||||
//MessageBox.Show("Please stop live view firstly");
|
//MessageBox.Show("Please stop live view firstly");
|
||||||
|
logger.Info("Please stop live view firstly");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CHCNetSDK.NET_DVR_Logout(HKUserId))
|
if (!CHCNetSDK.NET_DVR_Logout(HKUserId))
|
||||||
{
|
{
|
||||||
iLastErr = CHCNetSDK.NET_DVR_GetLastError();
|
iLastErr = CHCNetSDK.NET_DVR_GetLastError();
|
||||||
str = "NET_DVR_Logout failed, error code= " + iLastErr;
|
str = "NET_DVR_Logout failed, error code= " + iLastErr;
|
||||||
|
logger.Info(str);
|
||||||
}
|
}
|
||||||
HKUserId = -1;
|
HKUserId = -1;
|
||||||
}
|
}
|
||||||
|
@ -121,46 +128,51 @@ namespace DM_Weight.HIKVISION
|
||||||
{
|
{
|
||||||
if (m_lRealHandle >= 0)
|
if (m_lRealHandle >= 0)
|
||||||
{
|
{
|
||||||
CHCNetSDK.NET_DVR_StopRealPlay(m_lRealHandle);
|
bool stopRealPlay= CHCNetSDK.NET_DVR_StopRealPlay(m_lRealHandle);
|
||||||
|
logger.Info($"录像机NET_DVR_StopRealPlay接口返回{stopRealPlay}");
|
||||||
}
|
}
|
||||||
if (HKUserId >= 0)
|
if (HKUserId >= 0)
|
||||||
{
|
{
|
||||||
CHCNetSDK.NET_DVR_Logout(HKUserId);
|
bool logout= CHCNetSDK.NET_DVR_Logout(HKUserId);
|
||||||
|
logger.Info($"录像机NET_DVR_Logout接口返回{logout}");
|
||||||
}
|
}
|
||||||
if (m_bInitSDK == true)
|
if (m_bInitSDK == true)
|
||||||
{
|
{
|
||||||
CHCNetSDK.NET_DVR_Cleanup();
|
bool cleanUp= CHCNetSDK.NET_DVR_Cleanup();
|
||||||
|
logger.Info($"录像机NET_DVR_Cleanup接口返回{cleanUp}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HIKStartDVRRecord()
|
public bool HIKStartDVRRecord()
|
||||||
{
|
{
|
||||||
bool isStart= CHCNetSDK.NET_DVR_StartDVRRecord(HKUserId, 0xffff, 0);
|
bool isStart= CHCNetSDK.NET_DVR_StartDVRRecord(HKUserId, 0xffff, 0);
|
||||||
|
logger.Info($"录像机NET_DVR_StartDVRRecord接口返回{isStart}");
|
||||||
return isStart;
|
return isStart;
|
||||||
}
|
}
|
||||||
public bool HIKStopDVRRecord()
|
public bool HIKStopDVRRecord()
|
||||||
{
|
{
|
||||||
bool isStart = CHCNetSDK.NET_DVR_StopDVRRecord(HKUserId, 0xffff);
|
bool isStop = CHCNetSDK.NET_DVR_StopDVRRecord(HKUserId, 0xffff);
|
||||||
return isStart;
|
logger.Info($"录像机NET_DVR_StopDVRRecord接口返回{isStop}");
|
||||||
|
return isStop;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理所有正在使用的资源。
|
/// 清理所有正在使用的资源。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
//public void Dispose()
|
||||||
{
|
//{
|
||||||
if (m_lRealHandle >= 0)
|
// if (m_lRealHandle >= 0)
|
||||||
{
|
// {
|
||||||
CHCNetSDK.NET_DVR_StopRealPlay(m_lRealHandle);
|
// bool stopRealPlay= CHCNetSDK.NET_DVR_StopRealPlay(m_lRealHandle);
|
||||||
}
|
// }
|
||||||
if (HKUserId >= 0)
|
// if (HKUserId >= 0)
|
||||||
{
|
// {
|
||||||
CHCNetSDK.NET_DVR_Logout(HKUserId);
|
// CHCNetSDK.NET_DVR_Logout(HKUserId);
|
||||||
}
|
// }
|
||||||
if (m_bInitSDK == true)
|
// if (m_bInitSDK == true)
|
||||||
{
|
// {
|
||||||
CHCNetSDK.NET_DVR_Cleanup();
|
// CHCNetSDK.NET_DVR_Cleanup();
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ using Microsoft.Win32;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using DM_Weight.HIKVISION;
|
using DM_Weight.HIKVISION;
|
||||||
|
using System.Security.AccessControl;
|
||||||
|
|
||||||
namespace DM_Weight.ViewModels
|
namespace DM_Weight.ViewModels
|
||||||
{
|
{
|
||||||
|
@ -75,13 +76,21 @@ namespace DM_Weight.ViewModels
|
||||||
get => _portUtil._canBusExsit && !_portUtil.canBusSerial.IsOpen;
|
get => _portUtil._canBusExsit && !_portUtil.canBusSerial.IsOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _fingerMsg;
|
private bool _fingerMsg= CHKFunction.HKUserId>=0;
|
||||||
|
|
||||||
public bool FingerMsg
|
public bool FingerMsg
|
||||||
{
|
{
|
||||||
get => _fingerMsg;
|
get => _fingerMsg;
|
||||||
set => SetProperty(ref _fingerMsg, value);
|
set => SetProperty(ref _fingerMsg, value);
|
||||||
}
|
}
|
||||||
|
//录像机登录状态
|
||||||
|
private bool _hikMsg;
|
||||||
|
public bool HIKMsg
|
||||||
|
{
|
||||||
|
get=>_hikMsg;
|
||||||
|
set=>SetProperty(ref _hikMsg, value);
|
||||||
|
}
|
||||||
|
|
||||||
//public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil, FingerprintUtil fingerprintUtil)
|
//public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil, FingerprintUtil fingerprintUtil)
|
||||||
//{
|
//{
|
||||||
// _fingerprintUtil = fingerprintUtil;
|
// _fingerprintUtil = fingerprintUtil;
|
||||||
|
@ -289,7 +298,7 @@ _exitCommand ??= new DelegateCommand(Exit);
|
||||||
|
|
||||||
void Exit()
|
void Exit()
|
||||||
{
|
{
|
||||||
_chkFunction.Dispose();
|
_chkFunction.HIKLoginOut();
|
||||||
Process.GetCurrentProcess().Kill();
|
Process.GetCurrentProcess().Kill();
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,10 +194,11 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</materialDesign:Card>
|
</materialDesign:Card>
|
||||||
<StackPanel Orientation="Vertical" Grid.Row="3" Grid.Column="2">
|
<StackPanel Orientation="Vertical" Grid.Row="4" Grid.Column="2">
|
||||||
<TextBlock Visibility="{Binding DrawerPortMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="抽屉串口连接失败" />
|
<TextBlock Visibility="{Binding DrawerPortMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="抽屉串口连接失败" />
|
||||||
<TextBlock Visibility="{Binding CanBusPortMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="can总线串口连接失败" />
|
<TextBlock Visibility="{Binding CanBusPortMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="can总线串口连接失败" />
|
||||||
<TextBlock Visibility="{Binding FingerMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="指纹机连接失败" />
|
<TextBlock Visibility="{Binding FingerMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="指纹机连接失败" />
|
||||||
|
<TextBlock Visibility="{Binding HIKMsg, Converter={StaticResource BooleanToVisibilityConverter}}" Text="录像机登录失败" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
Loading…
Reference in New Issue