?? ccamsdoc.cpp
字號:
// CCAMSDoc.cpp : implementation of the CCCAMSDoc class
//
#include "stdafx.h"
#include "CCAMS.h"
#include "CCAMSDoc.h"
#include "MainFrm.h"
#include "DataToDB.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCCAMSDoc
IMPLEMENT_DYNCREATE(CCCAMSDoc, CDocument)
BEGIN_MESSAGE_MAP(CCCAMSDoc, CDocument)
//{{AFX_MSG_MAP(CCCAMSDoc)
ON_CBN_SELENDOK(ID_TOOL_CATEGORY, OnSelectCategory)
ON_COMMAND(ID_DELETE_RECORD, OnDeleteRecord)
ON_UPDATE_COMMAND_UI(ID_DELETE_RECORD, OnUpdateDeleteRecord)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCCAMSDoc construction/destruction
CCCAMSDoc::CCCAMSDoc():
m_strCurClient(""),
m_strCurDiagramClient("")
{
m_nDiaRefTime = 10; // 10 seconds
m_nHisTime = 60; // 60 minutes
m_nCurView = 0; //默認顯示 History List
m_nCategory = 0;
m_bClientEmpty = true;
}
CCCAMSDoc::~CCCAMSDoc()
{
}
BOOL CCCAMSDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CCCAMSDoc serialization
void CCCAMSDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CCCAMSDoc diagnostics
#ifdef _DEBUG
void CCCAMSDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CCCAMSDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCCAMSDoc commands
void CCCAMSDoc::OnSelectCategory()
{
CMainFrame *pWnd = (CMainFrame *)AfxGetMainWnd( );
m_nCategory = pWnd->m_wndCategory.GetCurSel();
this->UpdateAllViews( 0 );
// AfxMessageBox("OnSetCategory");
}
void CCCAMSDoc::OnDeleteRecord()
{
// TODO: Add your command handler code here
CString prom("Are you sure to delete\nthe records of ");
if ( m_strCurClient.IsEmpty() )
prom += "all clients?";
else
prom = prom + "client: " + m_strCurClient;
if (AfxMessageBox(prom, MB_OKCANCEL) != IDOK)
return;
CWaitCursor wait;
extern CRITICAL_SECTION g_criClientAccess;
extern CRITICAL_SECTION g_criCpuAccess;
extern CRITICAL_SECTION g_criFileAccess;
extern CRITICAL_SECTION g_criMailAccess;
extern CRITICAL_SECTION g_criNetAccess;
extern CRITICAL_SECTION g_criProcAccess;
EnterCriticalSection( &g_criClientAccess );
EnterCriticalSection( &g_criCpuAccess );
EnterCriticalSection( &g_criFileAccess );
EnterCriticalSection( &g_criMailAccess );
EnterCriticalSection( &g_criNetAccess );
EnterCriticalSection( &g_criProcAccess );
DeleteCPU();
DeleteFile();
DeleteMail();
DeleteNet();
DeleteProc();
DeleteClient(); // 涉及到外碼的問題, 所以,應該放到最后
LeaveCriticalSection( &g_criProcAccess );
LeaveCriticalSection( &g_criNetAccess );
LeaveCriticalSection( &g_criMailAccess );
LeaveCriticalSection( &g_criFileAccess );
LeaveCriticalSection( &g_criCpuAccess );
LeaveCriticalSection( &g_criClientAccess );
UpdateAllViews(0);
}
void CCCAMSDoc::OnUpdateDeleteRecord(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
CMainFrame *pWnd = (CMainFrame *)AfxGetMainWnd( );
// pWnd->m_wndCategory.EnableWindow( true );
pCmdUI->Enable( !m_bClientEmpty && !pWnd->m_bStart );
}
void CCCAMSDoc::DeleteClient() // client
{
extern CSetClient gm_setClient;
try
{
if ( !gm_setClient.IsOpen() )
gm_setClient.Open();
if ( !gm_setClient.CanUpdate() )
{
gm_setClient.Close();
return;
}
while ( !gm_setClient.IsEOF() )
{
if ( m_strCurClient.IsEmpty() )
{
gm_setClient.Delete();
//gm_setClient.Update();
}
else
{
if ( gm_setClient.m_ip == m_strCurClient )
{
gm_setClient.Delete();
//gm_setClient.Update();
}
}
gm_setClient.MoveNext();
}
gm_setClient.Close();
}catch(...){}
}
void CCCAMSDoc::DeleteCPU() // CPU
{
extern CSetCPU gm_setCpu;
try
{
if ( !gm_setCpu.IsOpen() )
gm_setCpu.Open();
if ( !gm_setCpu.CanUpdate() )
{
gm_setCpu.Close();
return;
}
while ( !gm_setCpu.IsEOF() )
{
if ( m_strCurClient.IsEmpty() )
{
gm_setCpu.Delete();
//gm_setCpu.Update();
}
else
{
if ( gm_setCpu.m_client == m_strCurClient )
{
gm_setCpu.Delete();
//gm_setCpu.Update();
}
}
gm_setCpu.MoveNext();
}
gm_setCpu.Close();
}catch(...){}
}
void CCCAMSDoc::DeleteFile() // File
{
extern CSetFile gm_setFile;
try
{
if ( !gm_setFile.IsOpen() )
gm_setFile.Open();
if ( !gm_setFile.CanUpdate() )
{
gm_setFile.Close();
return;
}
while ( !gm_setFile.IsEOF() )
{
if ( m_strCurClient.IsEmpty() )
{
gm_setFile.Delete();
//gm_setFile.Update();
}
else
{
if ( gm_setFile.m_client == m_strCurClient )
{
gm_setFile.Delete();
//gm_setFile.Update();
}
}
gm_setFile.MoveNext();
}
gm_setFile.Close();
}catch(...){}
}
void CCCAMSDoc::DeleteMail() // Mail
{
extern CSetMail gm_setMail;
try
{
if ( !gm_setMail.IsOpen() )
gm_setMail.Open();
if ( !gm_setMail.CanUpdate() )
{
gm_setMail.Close();
return;
}
while ( !gm_setMail.IsEOF() )
{
if ( m_strCurClient.IsEmpty() )
{
gm_setMail.Delete();
//gm_setMail.Update();
}
else
{
if ( gm_setMail.m_client == m_strCurClient )
{
gm_setMail.Delete();
//gm_setMail.Update();
}
}
gm_setMail.MoveNext();
}
gm_setMail.Close();
}catch(...){}
}
void CCCAMSDoc::DeleteNet() // Net
{
extern CSetNet gm_setNet;
try
{
if ( !gm_setNet.IsOpen() )
gm_setNet.Open();
if ( !gm_setNet.CanUpdate() )
{
gm_setNet.Close();
return;
}
while ( !gm_setNet.IsEOF() )
{
if ( m_strCurClient.IsEmpty() )
{
gm_setNet.Delete();
//gm_setNet.Update();
}
else
{
if ( gm_setNet.m_client == m_strCurClient )
{
gm_setNet.Delete();
//gm_setNet.Update();
}
}
gm_setNet.MoveNext();
}
gm_setNet.Close();
}catch(...){}
}
void CCCAMSDoc::DeleteProc() // Process
{
extern CSetProc gm_setProc;
try
{
if ( !gm_setProc.IsOpen() )
gm_setProc.Open();
if ( !gm_setProc.CanUpdate() )
{
gm_setProc.Close();
return;
}
while ( !gm_setProc.IsEOF() )
{
if ( m_strCurClient.IsEmpty() )
{
gm_setProc.Delete();
//gm_setProc.Update();
}
else
{
if ( gm_setProc.m_client == m_strCurClient )
{
gm_setProc.Delete();
//gm_setProc.Update();
}
}
gm_setProc.MoveNext();
}
gm_setProc.Close();
}catch(...){}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -