📄 searchrecord.cpp
字号:
// SearchRecord.cpp : implementation file
//
#include "stdafx.h"
#include "NetSDKDemo.h"
#include "SearchRecord.h"
#include "NetSDKDemoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define ISQUERYTYPE2 0 //是否采用单记录查询模式
/////////////////////////////////////////////////////////////////////////////
// CSearchRecord dialog
CPtrList *g_ptrfilelist;
CFileListProtector fl(&g_ptrfilelist);
CSearchRecord::CSearchRecord(CWnd* pParent /*=NULL*/)
: CDialog(CSearchRecord::IDD, pParent)
{
//{{AFX_DATA_INIT(CSearchRecord)
m_cardinput = _T("");
m_channelsel = 1;
m_enddate = CTime::GetCurrentTime();
m_endtime = CTime::GetCurrentTime();
m_startdate = CTime::GetCurrentTime();
m_start_day = 0;
m_new_start_time = _T(" 0:00:00");
m_new_end_time = _T("23:59:59");
//}}AFX_DATA_INIT
}
void CSearchRecord::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSearchRecord)
DDX_Control(pDX, IDC_SCH_ENDDATE, m_date_end);
DDX_Control(pDX, IDC_SCH_RESULTLIST, m_resultlist);
DDX_Control(pDX, IDC_PROGRESS_DOWNLOAD, m_download_pos);
DDX_Control(pDX, IDC_SCH_TYPE, m_sch_type);
DDX_Control(pDX, IDC_SCH_DEVICESEL, m_devicesel);
DDX_Text(pDX, IDC_SCH_CARDINPUT, m_cardinput);
DDX_Text(pDX, IDC_SCH_CHANNELSEL, m_channelsel);
DDV_MinMaxInt(pDX, m_channelsel, 1, MAX_CHANNUM);
DDX_DateTimeCtrl(pDX, IDC_SCH_ENDDATE, m_enddate);
DDX_DateTimeCtrl(pDX, IDC_SCH_ENDTIME, m_endtime);
DDX_DateTimeCtrl(pDX, IDC_SCH_STARTDATE, m_startdate);
DDX_DateTimeCtrl(pDX, IDC_SCH_STARTTIME, m_starttime);
DDX_Text(pDX, IDC_EDIT_STARTDATE, m_start_day);
DDX_Text(pDX, IDC_EDIT_STARTTIME, m_new_start_time);
DDX_Text(pDX, IDC_EDIT_ENDTIME, m_new_end_time);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSearchRecord, CDialog)
//{{AFX_MSG_MAP(CSearchRecord)
ON_BN_CLICKED(IDC_SCH_STARTSEARCH, OnSchStartsearch)
ON_BN_CLICKED(IDC_SCH_DOWNLOAD, OnSchDownload)
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_SCH_PLAYBACK, OnPlayback)
ON_BN_CLICKED(IDC__SCH_CLEAR_LIST, OnSchClearList)
ON_WM_TIMER()
ON_NOTIFY(NM_DBLCLK, IDC_SCH_RESULTLIST, OnDblclkSchResultlist)
ON_BN_CLICKED(IDC_BUTTON2, OnButtonTest)
ON_BN_CLICKED(IDC_BUTTON_LAST, OnButtonLast)
ON_BN_CLICKED(IDC_BTN_RIGHT, OnBtnRight)
ON_BN_CLICKED(IDC_BTN_DOWN, OnBtnDown)
ON_BN_CLICKED(IDC_BUTTON_LEFT, OnButtonLeft)
ON_BN_CLICKED(IDC_BUTTON8, OnButtonUp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSearchRecord message handlers
void CSearchRecord::AddOneFileToList(NET_RECORDFILE_INFO *pfileinfo, int index)
{
CString nStr;
CString strST;
CString strET;
CTime stime, etime;
POSITION nPos;
FileInfoNode *plistinfo = new FileInfoNode;
strST = g_TimeOutString(&pfileinfo->starttime);
strET = g_TimeOutString(&pfileinfo->endtime);
m_resultlist.InsertItem(index, pfileinfo->filename);
m_resultlist.SetItemText(index, 1, strST);
m_resultlist.SetItemText(index, 2, strET);
nStr.Format("%d", pfileinfo->size);
m_resultlist.SetItemText(index, 3, nStr.GetBuffer(0));
memcpy(&plistinfo->fileinfo, pfileinfo, sizeof(NET_RECORDFILE_INFO));
plistinfo->pDevice = (DeviceNode *)m_devicesel.GetItemData(m_devicesel.GetCurSel());
nPos = g_ptrfilelist->AddTail(plistinfo);
m_resultlist.SetItemData(index, (DWORD)plistinfo);
}
void CSearchRecord::AddFileListInfo( NET_RECORDFILE_INFO *pfileinfo, int iMaxNum)
{
for(int i = 0; i < iMaxNum; i++)
{
AddOneFileToList(&pfileinfo[i], i);
}
}
void CSearchRecord::OnSchStartsearch()
{
NET_RECORDFILE_INFO ifileinfo[2000];
DeviceNode *pInfo;
int nSchType;
SYSTEMTIME systime;
NET_TIME stime, etime;
int nMaxNum;
int nMaxLen = 2000 * sizeof(NET_RECORDFILE_INFO);
if(!UpdateData(true))
{
return;
}
if(m_devicesel.GetCount() <= 0 || m_devicesel.GetCurSel() < 0)
{
//MessageBox(MSG_SCHRECORD_NODEVICE,MSG_SCHRECORD_CHOOSEDEVICE);
return;
}
if(m_channelsel <= 0 || m_channelsel > MAX_CHANNUM)
{
//MessageBox(MSG_SCHRECORD_CHLNO_INVALID,MSG_SCHRECORD_CHLNO);
return;
}
nSchType = m_sch_type.GetCurSel();
CTime time = CTime(m_startdate.GetYear(),m_startdate.GetMonth(),m_startdate.GetDay(),
m_starttime.GetHour(), m_starttime.GetMinute(), m_starttime.GetSecond());
if(!time.GetAsSystemTime(systime) || !time.GetAsSystemTime(systime))
{
//MessageBox(MSG_SCHRECORD_TIMEINPUT_ERR,MSG_SCHRECORD_TIMEINPUT);
return;
}
g_systimetodhtime(&systime,&stime);
time = CTime(m_enddate.GetYear(),m_enddate.GetMonth(),m_enddate.GetDay(),
m_endtime.GetHour(), m_endtime.GetMinute(), m_endtime.GetSecond());
if(!time.GetAsSystemTime(systime) || !time.GetAsSystemTime(systime))
{
//MessageBox(MSG_SCHRECORD_TIMEINPUT_ERR,MSG_SCHRECORD_TIMEINPUT);
return;
}
g_systimetodhtime(&systime,&etime);
pInfo = (DeviceNode *)m_devicesel.GetItemData(m_devicesel.GetCurSel());
/*查询接口有两种实现方式,这里使用第一种*/
if (!ISQUERYTYPE2)
{
LONG ret = CLIENT_QueryRecordFile(pInfo->LoginID,
m_channelsel -1,
nSchType,
&stime,
&etime,
NULL,
ifileinfo,
nMaxLen,
&nMaxNum,
2000);
if(!ret)
{
((CNetSDKDemoDlg *)GetParent())->LastError();//Zhengdh 06.11.24
//MessageBox(MSG_SCHRECORD_QUERYFAILED);
return;
}
if(nMaxNum == 0)
{
//MessageBox(MSG_SCHRECORD_NORECORD);
return;
}
for(int i = 0; i < nMaxNum; i++)
{
sprintf(ifileinfo[i].filename,"%s channel%02d" ,pInfo->Name, m_channelsel );
}
OnSchClearList();
AddFileListInfo(ifileinfo, nMaxNum);
}
//第二种接口实现
else
{
LONG lHandle;
lHandle = CLIENT_FindFile(pInfo->LoginID,
m_channelsel -1,
nSchType,
NULL,
&stime,
&etime,
false,
2000);
if (!lHandle)
{
((CNetSDKDemoDlg *)GetParent())->LastError();//Zhengdh 06.11.24
//MessageBox(MSG_SCHRECORD_QUERYFAILED);
return;
}
NET_RECORDFILE_INFO *ptempfileinfo = new(NET_RECORDFILE_INFO);
BOOL ret;
ret = CLIENT_FindNextFile(lHandle, ptempfileinfo);
if (!ret)
{
((CNetSDKDemoDlg *)GetParent())->LastError();//Zhengdh 06.11.24
//MessageBox(MSG_SCHRECORD_NORECORD);
return;
}
//刷新列表
OnSchClearList();
int i = 0;
while (ret == 1) {
sprintf(ptempfileinfo->filename,"%s channel%02d" ,pInfo->Name, m_channelsel);
AddOneFileToList(ptempfileinfo, i);
i++;
ret = CLIENT_FindNextFile(lHandle, ptempfileinfo);
if (!ret)
{
((CNetSDKDemoDlg *)GetParent())->LastError();//Zhengdh 06.11.24
}
}
}
}
int InitComboxSRCallback(const DeviceNode& node, DWORD dwUser)
{
CSearchRecord* pThis = (CSearchRecord*)dwUser;
if(!pThis)
{
return 1;
}
return pThis->InitComboxCallback_Imp(node);
}
int CSearchRecord::InitComboxCallback_Imp(const DeviceNode& node)
{
//设备显示
CString strDev;
strDev.Format(" %s ",node.Name);
int nIndex = m_devicesel.GetCount();
m_devicesel.InsertString(nIndex,strDev);
m_devicesel.SetItemData(nIndex, (DWORD)(&node)); //设置保存当前设备指针值
return 0;
}
BOOL CSearchRecord::OnInitDialog()
{
CDialog::OnInitDialog();
g_SetWndStaticText(this);
m_channelsel=this->m_channelNo+1;
//DeviceNode *nDev;
//CString strDev;
//POSITION nPos;
m_devicesel.Clear();
CString strDev;
strDev.Format(" %s ",this->m_Device->Name);
int nIndex = m_devicesel.GetCount();
m_devicesel.InsertString(nIndex,strDev);
m_devicesel.SetItemData(nIndex, (DWORD)this->m_Device); //设置保存当前设备指针值
m_devicesel.SetCurSel(0);
//CDevMgr::GetDevMgr().For_EachDev(InitComboxSRCallback, (DWORD)this);//SUN MODIFY
/*
//初始化可选择的设备
nPos = g_ptrdevicelist->GetHeadPosition();
for(int i = 0; i < g_ptrdevicelist->GetCount(); i ++ )
{
//设备显示格式
nDev = (DeviceNode *)g_ptrdevicelist->GetNext(nPos);
//设备显示
strDev.Format(" %s ",nDev->Name);
m_devicesel.InsertString(i,strDev);
m_devicesel.SetItemData(i, (DWORD)nDev); //设置保存当前设备指针值
}
*/
if (m_devicesel.GetCount() > 0)
{
m_devicesel.SetCurSel(0);
}
//初始化其他控件
m_sch_type.Clear();
m_sch_type.InsertString(0, MSG_SCHRECORD_QUERYTYPE_LIST);
m_sch_type.InsertString(1, MSG_SCHRECORD_QUERYTYPE_ALARM);
m_sch_type.InsertString(2, MSG_SCHRECORD_QUERYTYPE_CARD);
m_sch_type.SetCurSel(0);
m_pdownloadfile = NULL;
m_download_pos.SetRange(0,100);
m_resultlist.SetExtendedStyle
(m_resultlist.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -