You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
4.4 KiB
C++
141 lines
4.4 KiB
C++
#pragma once
|
|
#include "GlobalDefine.h"
|
|
#include "module.h"
|
|
|
|
#define ACCOUNT_NoLogin "No Login"
|
|
#define ACCOUNT_Operator "Operator"
|
|
#define ACCOUNT_OperatorAdmin "OperatorAdmin"
|
|
#define ACCOUNT_Engineer "Engineer"
|
|
#define ACCOUNT_Technics "Technics"
|
|
#define ACCOUNT_Factory "Factory"
|
|
|
|
enum eAuthorityType
|
|
{
|
|
_Authority_NoLogin = 0,//未登录
|
|
_Authority_Operator,//操作员
|
|
_Authority_OperatorAdmin,//产线管理员
|
|
_Authority_Engineer,//设备工程师
|
|
_Authority_Technics,//工艺工程师
|
|
_Authority_Factory,//厂家
|
|
};
|
|
|
|
|
|
|
|
//账号
|
|
class CAccount
|
|
{
|
|
public:
|
|
CAccount()
|
|
{
|
|
m_Authority = _Authority_NoLogin;
|
|
}
|
|
void Serialize(CArchive& ar)
|
|
{
|
|
if(ar.IsStoring())
|
|
{
|
|
ar<<(int)m_Authority;
|
|
ar<<m_Name;
|
|
ar<<m_PassWord;
|
|
}
|
|
else
|
|
{
|
|
int tmp;
|
|
ar>>tmp;
|
|
m_Authority = (eAuthorityType)tmp;
|
|
ar>>m_Name;
|
|
ar>>m_PassWord;
|
|
}
|
|
}
|
|
public:
|
|
eAuthorityType m_Authority;//权限
|
|
CString m_Name;//用户名
|
|
CString m_PassWord;//密码
|
|
};
|
|
|
|
class CAuthorityPar
|
|
{
|
|
public:
|
|
CAuthorityPar(void)
|
|
{
|
|
m_bOperator = false;//操作员
|
|
m_bOperatorAdmin = false;//产线管理员
|
|
m_bEngineer = false;//设备工程师
|
|
m_bTechnics = false;//工艺工程师
|
|
};
|
|
public:
|
|
CString m_AuthorityName;//参数名称
|
|
CString m_ShowName;//显示用名称
|
|
bool m_bOperator;//操作员
|
|
bool m_bOperatorAdmin;//产线管理员
|
|
bool m_bEngineer;//设备工程师
|
|
bool m_bTechnics;//工艺工程师
|
|
};
|
|
|
|
enum eUserCtrlType
|
|
{
|
|
_UserCtrlType_AddUser = 0,//添加账号
|
|
_UserCtrlType_DelUser,//删除账号
|
|
_UserCtrlType_login,//登录
|
|
_UserCtrlType_logout,//退出登录
|
|
};
|
|
class CUserCtrlPar
|
|
{
|
|
public:
|
|
CUserCtrlPar(void)
|
|
{
|
|
|
|
};
|
|
public:
|
|
eUserCtrlType m_UserCtrlType;//操作类型
|
|
CString m_UserName;//用户名
|
|
eAuthorityType m_AuthorityType;//权限类型
|
|
};
|
|
|
|
//权限管理
|
|
class CAuthorityMgr:public CModule
|
|
{
|
|
public:
|
|
CAuthorityMgr(void);
|
|
~CAuthorityMgr(void);
|
|
virtual void OnAppInitialize();
|
|
virtual MODULE GetModuleType(){return _AUTHORITY_PROP;};
|
|
virtual CMFCPropertyGridProperty *CreatGridProperty();
|
|
|
|
void SetAuthority(eAuthorityType authority){m_CurAuthority = authority;};//设置当前权限
|
|
bool CheckAuthority(eAuthorityType authority,bool bShowMsgbox = false);//检查当前权限
|
|
bool CheckAuthorityByName(CString AuthorityName,bool bShowMsgbox);
|
|
eAuthorityType GetCurAuthority(){return m_CurAuthority;};
|
|
void AddAccount(CAccount Account);
|
|
bool Login(CString name,CString PassWord);
|
|
CString GetAccountName(eAuthorityType authority);
|
|
void SaveOrLoad(bool bSave);
|
|
void InsertToList(CListCtrl &List);
|
|
void DelUser(int idx);
|
|
CString GetCurAccountName();
|
|
CString GetCurUserName(){return m_CurUserName;};
|
|
bool IsAutoFactory(){return m_AutoFactory;};
|
|
void Lock();
|
|
bool IsLogin();
|
|
void InitAuthorityParList(CListCtrl &List);
|
|
void InitAuthorityTypeComb(CComboBox &Combo);
|
|
void UpdateAuthorityPar(CListCtrl &List,int AuthorityType);
|
|
void UpdateAuthorityParList(CListCtrl &List,int AuthorityType);
|
|
void SaveAuthorityParaFile();
|
|
void SetbLoginDlgOpen(bool b){m_bLoginDlgOpen = b;};
|
|
bool IsbLoginDlgOpen(){return m_bLoginDlgOpen;};
|
|
private:
|
|
void SaveOrLoadExt(CArchive &ar);
|
|
void SortUserVec();
|
|
void ReadAuthorityParaFile();
|
|
void SaveUserCtrlHistory(CUserCtrlPar UserCtrlPar);
|
|
private:
|
|
eAuthorityType m_CurAuthority;//当前权限
|
|
CString m_CurUserName;//当前用户名
|
|
vector<CAccount> m_UserVec;//所有的用户
|
|
bool m_AutoFactory;//打开软件自动升级到管理员权限
|
|
bool m_bLoginDlgOpen;//是否正在打开登录对话框
|
|
vector<CAuthorityPar> m_AuthorityParVec;
|
|
vector<CAuthorityPar> m_TmpAuthorityParVec;//当前操作的参数
|
|
};
|
|
|
|
extern CAuthorityMgr *gAuthorityMgr; |