⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 remoteupgrade.cpp

📁 SDK DVR/DVS HIKVISION
💻 CPP
字号:
// RemoteUpgrade.cpp : implementation file
//

#include "stdafx.h"
#include "newclient.h"
#include "RemoteUpgrade.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CRemoteUpgrade dialog


CRemoteUpgrade::CRemoteUpgrade(CWnd* pParent /*=NULL*/)
	: CDialog(CRemoteUpgrade::IDD, pParent)
{
	//{{AFX_DATA_INIT(CRemoteUpgrade)
	m_sUpgradeFile = _T("");
	m_static = _T("");
	//}}AFX_DATA_INIT
}


void CRemoteUpgrade::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CRemoteUpgrade)
	DDX_Text(pDX, IDC_UPGRADEFILE, m_sUpgradeFile);
	DDX_Text(pDX, IDC_UPGRADESTATIC, m_static);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CRemoteUpgrade, CDialog)
	//{{AFX_MSG_MAP(CRemoteUpgrade)
	ON_BN_CLICKED(IDC_BUTTONBROWSEFILE, OnButtonbrowsefile)
	ON_BN_CLICKED(IDC_BUTTONBUPGRADE, OnButtonbupgrade)
	ON_BN_CLICKED(IDC_BUTTONBEXIT, OnButtonbexit)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRemoteUpgrade message handlers

void CRemoteUpgrade::OnButtonbrowsefile() 
{
	// TODO: Add your control notification handler code here
	
	static char szFilter[]="All File(*.*)|*.*||";
	CFileDialog dlg(TRUE,"*.*","digicap",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
		szFilter);
	if(dlg.DoModal()==IDOK)
	{
		m_sUpgradeFile = dlg.GetPathName();
		UpdateData(FALSE);
	}	
}


void CRemoteUpgrade::OnButtonbupgrade() 
{
	// TODO: Add your control notification handler code here
	char filename[100];
	
	UpdateData(TRUE);
	strcpy(filename,m_sUpgradeFile);
	CFile file;
	if(!file.Open(filename,NULL))
	{
		AfxMessageBox("File open failed or file not exist!");
		return;
	}
	DWORD dwFileSize = file.GetLength();
	if(dwFileSize == 0)
		AfxMessageBox("File size is zero!");
	file.Close();
	m_lUpgrade = NET_DVR_Upgrade(m_lServerID, filename);
	if(m_lUpgrade < 0)
	{
		AfxMessageBox("Upgrade failed!");
	}
	else
	{
		GetDlgItem(IDC_UPGRADESTATIC)->ShowWindow(SW_SHOW);
		GetDlgItem(IDC_BUTTONBUPGRADE)->EnableWindow(FALSE);
		GetDlgItem(IDC_BUTTONBEXIT)->EnableWindow(FALSE);
		GetDlgItem(IDC_BUTTONBROWSEFILE)->EnableWindow(FALSE);
		m_static = "Staus: Upgrading the firmware, please wait......";
		m_bUpgrade = TRUE;
		m_nTime = SetTimer(UPGRADE_TIMER,1000,NULL);
		UpdateData(FALSE);
	}	
}

void CRemoteUpgrade::OnButtonbexit() 
{
	// TODO: Add your control notification handler code here
	if(m_nTime)
	{
		KillTimer(UPGRADE_TIMER);
	}
	CDialog::OnCancel();
}

void CRemoteUpgrade::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	if(nIDEvent == UPGRADE_TIMER)
	{
		if(m_bUpgrade)
		{
			int UpgradeStatic = NET_DVR_GetUpgradeState(m_lUpgrade);
			if(UpgradeStatic == 2)
			{
				m_static = "Staus: Upgrading the firmware, please wait......";
				UpdateData(FALSE);
			}
			else
			{
				switch(UpgradeStatic) {
				case -1:
					AfxMessageBox("Upgrade failed!");				
					break;
				case 1:
					m_static = "Status: Upgrade succeed!";
					break;			
				case 3:
					m_static = "Status: Upgrade failed!";				
					break;
				case 4:
					m_static = "Status: Network broken!";				
					break;
				case 5:
					m_static = "Status: the upgrade file language not match!";				
					break;
				default:
					break;
				}
				UpdateData(FALSE);
				m_bUpgrade = FALSE;
				GetDlgItem(IDC_BUTTONBUPGRADE)->EnableWindow(TRUE);	
				GetDlgItem(IDC_BUTTONBEXIT)->EnableWindow(TRUE);
				GetDlgItem(IDC_BUTTONBROWSEFILE)->EnableWindow(TRUE);
				NET_DVR_CloseUpgradeHandle(m_lUpgrade);
			}
		}		
	}
	CDialog::OnTimer(nIDEvent);
}

BOOL CRemoteUpgrade::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_sUpgradeFile.Format("c:\\digicap");
	UpdateData(FALSE);
	m_bUpgrade = FALSE;
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CRemoteUpgrade::OnCancel() 
{
	// TODO: Add extra cleanup here
	
//	CDialog::OnCancel();
}

void CRemoteUpgrade::OnOK() 
{
	// TODO: Add extra cleanup here
	
	//	CDialog::OnOK();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -