📄 mainfrm.h
字号:
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINFRM_H__33D3964B_56BC_11D1_800E_00A0C92E722F__INCLUDED_)
#define AFX_MAINFRM_H__33D3964B_56BC_11D1_800E_00A0C92E722F__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include "tolldef.h"
#include "tollerinfo.h"
#include "afxinet.h"
/*
主框架窗口类,负责处理计费主要工作
*/
class CMainFrame : public CMDIFrameWnd
{
DECLARE_DYNAMIC(CMainFrame)
public:
CMainFrame();
// Attributes
public:
/////////////////////////////////////////////////////////////
//System Configurations
//数字形式的教育网(指不经过国际线路的所有网络)IP地址前缀
//用于作为判断是否收费的依据
CStringList CERNIPPrefixList;
//每日更新计费的时间
int nUpdateAtHour;
//上次更新计费日期,用于控制自动轮询机制,自动完成计费数据收集
//避免计费过程的重复调用
CString sLastDate;
//服务器更新计费信息日志文件的时间,由于日志文件已该时间作
//为文件名的结尾,而本计费系统需要通过FTP访问日志文件
//所以需要知道服务器更新计费信息日志文件的时间,以便生成正确的文件名
int nServerUpdateLogAt;
//每月开始计费的日期,在这一天,计费系统会清空原来的数据库文件
//toller.dbf并生成计费月报表
int m_nTollFromDate;
//更新本地日志文件的日期,日志文件功能尚未提供
int m_nUpdateLocalLogWhen;
//cost per kilobytes(unit:0.1fen)
int m_nCostPerKB;
//save toller setting infomation.
void SaveTollSetting();
public:
//operations for CERN IP prefixes
void LoadCERNIPPrefixList();
void SaveCERNIPPrefixList();
public:
//ftp Get log file from server API and members
//attributes
//用于FTP会话的有关对象
CInternetSession* m_pInetSession;
CFtpConnection* m_pFtpConnection;
//specify the location where the toller to get the logfile
//用FTP方式访问的proxy服务器名字
CString sFTPServerName;
//proxy服务器上计费日志文件所在的目录名
CString sLogFileFTPAddr;
//FTP方式登录proxy服务器时用的用户名和口令
CString m_sUserName;
CString m_sPassword;
public:
//operations
//将数字n转化为字符串形式,如1转化为"1"
CString NumToStr(int n);
//ftp get file API
//根据当前日期自动生成从proxy服务器上所要下载的日志文件名字
CString MakeLogFileName();
//初始化Internet会话
void InitInternetSession();
//登录PROXY sERVER
BOOL ConnectFtpServer();
//从proxy server上获取以sLogFileFTPAddr为目录,sFileName为文件
//名的文件
BOOL FtpGetFile(CString sFileName);
//关闭FTP连接
void CloseFtpConnect();
//Parse and Collect API
public:
CTollerInfo tollerInfo;//current tollerInfo
CStringList SpecialUserList;//the special user's login name list
//字母形式的域名后缀,如".cn"
CStringList SuffixList;
//计费信息链表
CObList tollerList;
//本地日志文件名,还没有使用
CString sLogFileName;
//数据库文件名
CString sDatabaseName;
//toller information database APIs
public:
//载入计费数据库中的信息,这样启动toller时就可以在以前的计费信息
//基础上进行累加
void LoadTollerDatabase();
//clear sub total information
//清除昨日国际流量信息,因为月流量进行累加而昨日流量不作累加,
//因此在收集昨日的计费信息到数据库之前,必须首先清除昨日国际流量
//在Collect被调用前调用
void ClearSubTotal();
//Query used as a test in toller system
BOOL Query(CString sLoginName,
CTollerInfo& tollerInfo);
//database report generating APIs
//report current database info as an HTML report
void ReportAsHTML(CString& sFileName);
//report current database info as an text report
//in which each field is seperated by TAB and each line ends
//with CRLF
void ReportAsText(CString& sFileName);
//format each toller info as a text line with fields seperated
//by TAB
CString FormatTextTabRow(CTollerInfo*);
//format each toller info as a text line
CString FormatHTMLTabRow(CTollerInfo*);
//special user list API
//show progress info on the status line
void StatusText(CString aString);
//show the system error info,uint is the error id,
//char* is the message string form of error function
void Error(UINT);
void Error(char*);
//load and save special user list.the special user is not
//used in this system
void InitSpecialUserList();
void LoadSpecialUserList();
void SaveSpecialUserList();
//load and save Internal domain name suffix
void InitSuffixList();
void LoadSuffixList();
void SaveSuffixList();
//Toller List API
//init and destroy the tollerlist
void InitTollerList();
void FreeTollerList();
//add a tollerInfo to the TollerList,if the username of toller
//has been in the list,just add the toller info to the info
//with the same username.
void AddToTollerList(CTollerInfo& tollerInfo);
//save the tollerinfo list to the toller info database
void UpdateTollerInfoDatabase();
//Line Parse API
//parse a line and store all the fields to tollerInfo structure
BOOL ParseLine(CString aLine);
//is the user need to be tolled(not the special user)
BOOL IsOperationNeedToll(CString sOperation);
//BOOL IsValidUser(CTollerInfo& tollerInfo);
BOOL IsSpecialUser(CString loginName);
//is the digital form IP address a cernet ip addr?
BOOL IsCERNAddr(CString sIPAddr);
//is the string specified by sTimeDate today?
BOOL IsToday(CString& sTimeDate);
//Parse and Collect Toller Info and save to tollerinfo database
void Collect();
//when end of the toller month,If true,generate report and update the toller database.
void CheckIfEndOfTollerMonth();
// Operations
public:
//setting retrieve and store
void LoadSetting();
void SaveSetting();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
int m_nDatePaneNo;
int m_nTimePaneNo;
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
// CToolBar m_wndToolBar;
// Generated message map functions
protected:
CStatusBar m_wndStatusBar;
afx_msg void OnUpdateDate(CCmdUI* pCmdUI);
afx_msg void OnUpdateTime(CCmdUI* pCmdUI);
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnOption();
afx_msg void OnDestroy();
afx_msg void OnClose();
afx_msg void OnSpecialUser();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnTestCollect();
afx_msg void OnTestUpdatedatabase();
afx_msg void OnFtpConnect();
afx_msg void OnDebugQuery();
afx_msg void OnSystemReport();
afx_msg void OnDnloadLogfile();
afx_msg void OnManualUpdate();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
BOOL InitStatusBar(UINT *pIndicators, int nSize, int nSeconds);
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__33D3964B_56BC_11D1_800E_00A0C92E722F__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -