OAMDOC.CPP
上传用户:lvjun8202
上传日期:2013-04-30
资源大小:797k
文件大小:4k
源码类别:

SNMP编程

开发平台:

C/C++

  1. // OAMDoc.cpp : implementation of the COAMDoc class
  2. //
  3. #include "stdafx.h"
  4. #include "OAM.h"
  5. #include "OAMDoc.h"
  6. #include "Snmp_cwdmView.h"
  7. #include "MainFrm.h"
  8. #include <io.h>
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. #ifndef _AFX_OLD_EXCEPTIONS
  15. #define DELETE_EXCEPTION(e) do { e->Delete(); } while (0)
  16. #define NO_CPP_EXCEPTION(expr)
  17. #else   //!_AFX_OLD_EXCEPTIONS
  18. #define DELETE_EXCEPTION(e)
  19. #define NO_CPP_EXCEPTION(expr) expr
  20. #endif  //_AFX_OLD_EXCEPTIONS
  21. /////////////////////////////////////////////////////////////////////////////
  22. // COAMDoc
  23. extern void int_to_bcd(int n,BYTE *out1,BYTE *out2);
  24. IMPLEMENT_DYNCREATE(COAMDoc, CDocument)
  25. BEGIN_MESSAGE_MAP(COAMDoc, CDocument)
  26. //{{AFX_MSG_MAP(COAMDoc)
  27. ON_COMMAND(ID_FILE_SAVE, OnFileSave)
  28. //}}AFX_MSG_MAP
  29. END_MESSAGE_MAP()
  30. /////////////////////////////////////////////////////////////////////////////
  31. // COAMDoc construction/destruction
  32. COAMDoc::COAMDoc()
  33. {
  34. // TODO: add one-time construction code here
  35. CGlobalVariable::m_pMainDoc = this;
  36. }
  37. COAMDoc::~COAMDoc()
  38. {
  39. }
  40. BOOL COAMDoc::OnNewDocument()
  41. {
  42. if (!CDocument::OnNewDocument())
  43. return FALSE;
  44. return TRUE;
  45. }
  46. /////////////////////////////////////////////////////////////////////////////
  47. // COAMDoc serialization
  48. void COAMDoc::Serialize(CArchive& ar)
  49. {
  50. if (ar.IsStoring())
  51. {
  52. CGlobalVariable::m_pStationTreeView->WriteTreeViewContent(ar, CGlobalVariable::m_pStationTreeView->GetTreeCtrl());
  53. }
  54. else
  55. {
  56. CGlobalVariable::m_pStationTreeView->ReadTreeViewContent(ar, CGlobalVariable::m_pStationTreeView->GetTreeCtrl());
  57. }
  58. }
  59. /////////////////////////////////////////////////////////////////////////////
  60. // COAMDoc diagnostics
  61. #ifdef _DEBUG
  62. void COAMDoc::AssertValid() const
  63. {
  64. CDocument::AssertValid();
  65. }
  66. void COAMDoc::Dump(CDumpContext& dc) const
  67. {
  68. CDocument::Dump(dc);
  69. }
  70. #endif //_DEBUG
  71. /////////////////////////////////////////////////////////////////////////////
  72. // COAMDoc commands
  73. void gettime(CString & strTime)
  74. {
  75. int year,month,date,hour,minute,second;
  76. CTime timeNow = CTime::GetCurrentTime();
  77. year = timeNow.GetYear();
  78. month = timeNow.GetMonth();
  79. date = timeNow.GetDay();
  80. hour = timeNow.GetHour();
  81. minute = timeNow.GetMinute();
  82. second = timeNow.GetSecond();
  83. strTime.Format(" 时间 %04d-%02d-%02d  %02d:%02d:%02d",year,month,date,hour,minute,second);
  84. }
  85. /*void COAMDoc::OnFileSave() 
  86. {
  87. // TODO: Add your command handler code here
  88. char lpszPathName[150] = "mymib";
  89. CFileException fe;
  90. CFile* pFile = NULL;
  91. pFile = GetFile(lpszPathName, CFile::modeCreate |
  92. CFile::modeReadWrite | CFile::shareExclusive, &fe);
  93. if (pFile == NULL)
  94. {
  95. AfxMessageBox(CString(lpszPathName) + _T(" Open Error"));
  96. return ;
  97. }
  98. CArchive saveArchive(pFile, CArchive::store | CArchive::bNoFlushOnDelete);
  99. saveArchive.m_pDocument = this;
  100. saveArchive.m_bForceFlat = FALSE;
  101. /* TRY
  102. {
  103. CWaitCursor wait;
  104. saveArchive.WriteCount(m_listStation.GetCount());
  105. POSITION pos;
  106. for( pos = m_listStation.GetHeadPosition(); pos != NULL; )    
  107. {
  108. CStation * pStation = m_listStation.GetNext( pos ) ;
  109. pStation->Serialize(saveArchive);     // save me
  110. }
  111. Serialize(saveArchive);     // save me
  112. saveArchive.Close();
  113. ReleaseFile(pFile, FALSE);
  114. }
  115. CATCH_ALL(e)
  116. {
  117. ReleaseFile(pFile, TRUE);
  118. TRY
  119. {
  120. AfxMessageBox(CString(lpszPathName) + _T(" Save Error"));
  121. }
  122. END_TRY
  123. DELETE_EXCEPTION(e);
  124. return ;
  125. }
  126. END_CATCH_ALL
  127. }*/
  128. BOOL COAMDoc::OnOpenDocument(LPCTSTR lpszPathName) 
  129. {
  130. if (!CDocument::OnOpenDocument(lpszPathName))
  131. return FALSE;
  132. return TRUE;
  133. }
  134. bool COAMDoc::LoadMe()
  135. {
  136. char lpszPathName[150] = "mymib";
  137. CFileException fe;
  138. CFile* pFile = GetFile(lpszPathName,
  139. CFile::modeRead|CFile::shareDenyWrite, &fe);
  140. m_strPathName=lpszPathName;
  141. if (pFile == NULL)
  142. {
  143. return TRUE;
  144. }
  145. CArchive loadArchive(pFile, CArchive::load | CArchive::bNoFlushOnDelete);
  146. loadArchive.m_pDocument = this;
  147. Serialize(loadArchive);     // load me
  148. }