OAMDOC.CPP
上传用户:lvjun8202
上传日期:2013-04-30
资源大小:797k
文件大小:4k
- // OAMDoc.cpp : implementation of the COAMDoc class
- //
- #include "stdafx.h"
- #include "OAM.h"
- #include "OAMDoc.h"
- #include "Snmp_cwdmView.h"
- #include "MainFrm.h"
- #include <io.h>
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #ifndef _AFX_OLD_EXCEPTIONS
- #define DELETE_EXCEPTION(e) do { e->Delete(); } while (0)
- #define NO_CPP_EXCEPTION(expr)
- #else //!_AFX_OLD_EXCEPTIONS
- #define DELETE_EXCEPTION(e)
- #define NO_CPP_EXCEPTION(expr) expr
- #endif //_AFX_OLD_EXCEPTIONS
- /////////////////////////////////////////////////////////////////////////////
- // COAMDoc
- extern void int_to_bcd(int n,BYTE *out1,BYTE *out2);
- IMPLEMENT_DYNCREATE(COAMDoc, CDocument)
- BEGIN_MESSAGE_MAP(COAMDoc, CDocument)
- //{{AFX_MSG_MAP(COAMDoc)
- ON_COMMAND(ID_FILE_SAVE, OnFileSave)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // COAMDoc construction/destruction
- COAMDoc::COAMDoc()
- {
- // TODO: add one-time construction code here
- CGlobalVariable::m_pMainDoc = this;
- }
- COAMDoc::~COAMDoc()
- {
- }
- BOOL COAMDoc::OnNewDocument()
- {
-
- if (!CDocument::OnNewDocument())
- return FALSE;
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // COAMDoc serialization
- void COAMDoc::Serialize(CArchive& ar)
- {
-
- if (ar.IsStoring())
- {
- CGlobalVariable::m_pStationTreeView->WriteTreeViewContent(ar, CGlobalVariable::m_pStationTreeView->GetTreeCtrl());
- }
- else
- {
- CGlobalVariable::m_pStationTreeView->ReadTreeViewContent(ar, CGlobalVariable::m_pStationTreeView->GetTreeCtrl());
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // COAMDoc diagnostics
- #ifdef _DEBUG
- void COAMDoc::AssertValid() const
- {
- CDocument::AssertValid();
- }
- void COAMDoc::Dump(CDumpContext& dc) const
- {
- CDocument::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // COAMDoc commands
- void gettime(CString & strTime)
- {
- int year,month,date,hour,minute,second;
- CTime timeNow = CTime::GetCurrentTime();
- year = timeNow.GetYear();
- month = timeNow.GetMonth();
- date = timeNow.GetDay();
- hour = timeNow.GetHour();
- minute = timeNow.GetMinute();
- second = timeNow.GetSecond();
- strTime.Format(" 时间 %04d-%02d-%02d %02d:%02d:%02d",year,month,date,hour,minute,second);
- }
- /*void COAMDoc::OnFileSave()
- {
- // TODO: Add your command handler code here
- char lpszPathName[150] = "mymib";
- CFileException fe;
- CFile* pFile = NULL;
- pFile = GetFile(lpszPathName, CFile::modeCreate |
- CFile::modeReadWrite | CFile::shareExclusive, &fe);
- if (pFile == NULL)
- {
- AfxMessageBox(CString(lpszPathName) + _T(" Open Error"));
- return ;
- }
- CArchive saveArchive(pFile, CArchive::store | CArchive::bNoFlushOnDelete);
- saveArchive.m_pDocument = this;
- saveArchive.m_bForceFlat = FALSE;
- /* TRY
- {
- CWaitCursor wait;
- saveArchive.WriteCount(m_listStation.GetCount());
- POSITION pos;
- for( pos = m_listStation.GetHeadPosition(); pos != NULL; )
- {
- CStation * pStation = m_listStation.GetNext( pos ) ;
- pStation->Serialize(saveArchive); // save me
- }
- Serialize(saveArchive); // save me
- saveArchive.Close();
- ReleaseFile(pFile, FALSE);
- }
- CATCH_ALL(e)
- {
- ReleaseFile(pFile, TRUE);
- TRY
- {
- AfxMessageBox(CString(lpszPathName) + _T(" Save Error"));
- }
- END_TRY
- DELETE_EXCEPTION(e);
- return ;
- }
- END_CATCH_ALL
-
- }*/
- BOOL COAMDoc::OnOpenDocument(LPCTSTR lpszPathName)
- {
- if (!CDocument::OnOpenDocument(lpszPathName))
-
- return FALSE;
-
- return TRUE;
- }
- bool COAMDoc::LoadMe()
- {
- char lpszPathName[150] = "mymib";
- CFileException fe;
- CFile* pFile = GetFile(lpszPathName,
- CFile::modeRead|CFile::shareDenyWrite, &fe);
- m_strPathName=lpszPathName;
- if (pFile == NULL)
- {
- return TRUE;
- }
- CArchive loadArchive(pFile, CArchive::load | CArchive::bNoFlushOnDelete);
- loadArchive.m_pDocument = this;
- Serialize(loadArchive); // load me
- }