|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
#include "AuthorityMgr.h"
|
|
|
|
|
#include "MsgBox.h"
|
|
|
|
|
#include "FileMgr.h"
|
|
|
|
|
#include "LogMgr.h"
|
|
|
|
|
#include "PropertieMgr.h"
|
|
|
|
|
#include "Propertie.h"
|
|
|
|
|
#include "CStringFuc.h"
|
|
|
|
|
#include "WorkTime.h"
|
|
|
|
|
#include "ProgramLaserTuiHuo.h"
|
|
|
|
|
|
|
|
|
|
#define LAIPU_NAME "laipu"
|
|
|
|
|
#define LAIPU_PASSWORD "laipu123"
|
|
|
|
|
#define FILE_PATH _T("\\Parameter\\Authority\\Authority.par")
|
|
|
|
|
#define AUTHORITY_PARA_FILE _T("\\CommPar\\Authority.bin")
|
|
|
|
|
#define NEW_LOGIN_FILE_PATH _T("\\LoginRecord\\")
|
|
|
|
|
|
|
|
|
|
bool CompareUser(CAccount Account1,CAccount Account2)
|
|
|
|
|
{
|
|
|
|
|
return Account1.m_Authority>Account2.m_Authority;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CAuthorityMgr *gAuthorityMgr = new CAuthorityMgr;
|
|
|
|
|
CAuthorityMgr::CAuthorityMgr(void)
|
|
|
|
|
{
|
|
|
|
|
m_AutoFactory = false;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԱȨ<D4B1><C8A8>
|
|
|
|
|
m_CurAuthority = _Authority_NoLogin;//<2F><>ǰȨ<C7B0><C8A8>
|
|
|
|
|
m_CurUserName = ACCOUNT_NoLogin;
|
|
|
|
|
m_bLoginDlgOpen = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڴ<DAB4>¼<EFBFBD>Ի<EFBFBD><D4BB><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
CAuthorityMgr::~CAuthorityMgr(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
CMFCPropertyGridProperty *CAuthorityMgr::CreatGridProperty()
|
|
|
|
|
{
|
|
|
|
|
CString PropertyName;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CString Description;//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
CString Path = _T("AuthorityMgr");//<2F>洢·<E6B4A2><C2B7>
|
|
|
|
|
CString Name;
|
|
|
|
|
CString GroupName;
|
|
|
|
|
CString ModuleName;
|
|
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
|
|
PropertyName = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD>");
|
|
|
|
|
GroupName = PropertyName;
|
|
|
|
|
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
|
|
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
|
|
if(gAuthorityMgr->CheckAuthority(_Authority_Factory))
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
|
|
|
|
|
Name = _T("m_AutoFactory");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
|
|
pPropertie->SetpVal((void*)&m_AutoFactory);
|
|
|
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
|
|
|
pPropertie->SetpModule(this);
|
|
|
|
|
pPropertie->SetPath(Path);
|
|
|
|
|
pPropertie->SetName(Name);
|
|
|
|
|
pPropertie->WriteRead(true);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
PropertyName = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD>");
|
|
|
|
|
Description = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
pPropertie->SetGroupName(GroupName);
|
|
|
|
|
pPropertie->SetShowName(PropertyName);
|
|
|
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_AutoFactory, Description);
|
|
|
|
|
pGroup->AddSubItem(p);
|
|
|
|
|
|
|
|
|
|
gDevicePropertieMgr.Insert(p, pPropertie);
|
|
|
|
|
}
|
|
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
|
|
return pGroup;
|
|
|
|
|
}
|
|
|
|
|
void CAuthorityMgr::OnAppInitialize()
|
|
|
|
|
{
|
|
|
|
|
SaveOrLoad(false);//<2F><>ȡ<EFBFBD>ļ<EFBFBD>
|
|
|
|
|
if(m_AutoFactory)
|
|
|
|
|
m_CurAuthority = _Authority_Factory;
|
|
|
|
|
//<2F><>ȡȨ<C8A1><EFBFBD><DEB2><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
ReadAuthorityParaFile();
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>鵱ǰȨ<C7B0><C8A8>
|
|
|
|
|
bool CAuthorityMgr::CheckAuthority(eAuthorityType authority,bool bShowMsgbox)
|
|
|
|
|
{
|
|
|
|
|
if((int)m_CurAuthority >= (int)authority)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(bShowMsgbox)
|
|
|
|
|
{
|
|
|
|
|
CMsgBox MsgBox;
|
|
|
|
|
CString str = "<EFBFBD><EFBFBD>Ҫ["+GetAccountName(authority) + "]Ȩ<><C8A8>!";
|
|
|
|
|
MsgBox.Show(str);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>¼
|
|
|
|
|
bool CAuthorityMgr::IsLogin()
|
|
|
|
|
{
|
|
|
|
|
return m_CurAuthority != _Authority_NoLogin;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ȩ<EFBFBD>ޱ<EFBFBD><DEB1><EFBFBD>δ<EFBFBD><CEB4>¼
|
|
|
|
|
void CAuthorityMgr::Lock()
|
|
|
|
|
{
|
|
|
|
|
//<2F><>¼
|
|
|
|
|
{
|
|
|
|
|
CUserCtrlPar UserCtrlPar;
|
|
|
|
|
UserCtrlPar.m_UserName = m_CurUserName;
|
|
|
|
|
UserCtrlPar.m_UserCtrlType = _UserCtrlType_logout;
|
|
|
|
|
UserCtrlPar.m_AuthorityType = m_CurAuthority;
|
|
|
|
|
SaveUserCtrlHistory(UserCtrlPar);
|
|
|
|
|
}
|
|
|
|
|
SetAuthority(_Authority_NoLogin);
|
|
|
|
|
m_CurUserName = ACCOUNT_NoLogin;
|
|
|
|
|
}
|
|
|
|
|
//<2F><>¼
|
|
|
|
|
bool CAuthorityMgr::Login(CString name,CString PassWord)
|
|
|
|
|
{
|
|
|
|
|
//<2F><>ȡ<EFBFBD>˺<EFBFBD><CBBA><EFBFBD>Ϣ
|
|
|
|
|
SaveOrLoad(false);
|
|
|
|
|
//<2F><>ȡȨ<C8A1><EFBFBD><DEB2><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
ReadAuthorityParaFile();
|
|
|
|
|
|
|
|
|
|
bool ret = false;
|
|
|
|
|
eAuthorityType authority = GetCurAuthority();
|
|
|
|
|
if(name == LAIPU_NAME && PassWord == LAIPU_PASSWORD)
|
|
|
|
|
{
|
|
|
|
|
ret = true;
|
|
|
|
|
authority = _Authority_Factory;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
vector<CAccount>::iterator iter = m_UserVec.begin();
|
|
|
|
|
vector<CAccount>::iterator iter_end = m_UserVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
if((*iter).m_Name == name)
|
|
|
|
|
{
|
|
|
|
|
if((*iter).m_PassWord == PassWord)
|
|
|
|
|
{
|
|
|
|
|
ret = true;
|
|
|
|
|
authority = (*iter).m_Authority;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CMsgBox MsgBox;
|
|
|
|
|
MsgBox.Show("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺Ų<EFBFBD>ƥ<EFBFBD><EFBFBD>");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(iter==iter_end)
|
|
|
|
|
{
|
|
|
|
|
CMsgBox MsgBox;
|
|
|
|
|
MsgBox.Show("<EFBFBD>˺Ż<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(ret)
|
|
|
|
|
{
|
|
|
|
|
SetAuthority(authority);
|
|
|
|
|
m_CurUserName = name;
|
|
|
|
|
|
|
|
|
|
CString log = "CAuthorityMgr::Login::";
|
|
|
|
|
log += GetAccountName(authority);
|
|
|
|
|
log += "->"+name;
|
|
|
|
|
gLogMgr->WriteDebugLog(log);
|
|
|
|
|
|
|
|
|
|
//<2F><>¼
|
|
|
|
|
{
|
|
|
|
|
CUserCtrlPar UserCtrlPar;
|
|
|
|
|
UserCtrlPar.m_UserName = name;
|
|
|
|
|
UserCtrlPar.m_UserCtrlType = _UserCtrlType_login;
|
|
|
|
|
UserCtrlPar.m_AuthorityType = authority;
|
|
|
|
|
SaveUserCtrlHistory(UserCtrlPar);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
CString CAuthorityMgr::GetAccountName(eAuthorityType authority)
|
|
|
|
|
{
|
|
|
|
|
CString s;
|
|
|
|
|
switch(authority)
|
|
|
|
|
{
|
|
|
|
|
case _Authority_NoLogin:
|
|
|
|
|
s = ACCOUNT_NoLogin;
|
|
|
|
|
break;
|
|
|
|
|
case _Authority_Operator:
|
|
|
|
|
s = ACCOUNT_Operator;
|
|
|
|
|
break;
|
|
|
|
|
case _Authority_OperatorAdmin:
|
|
|
|
|
s = ACCOUNT_OperatorAdmin;
|
|
|
|
|
break;
|
|
|
|
|
case _Authority_Engineer:
|
|
|
|
|
s = ACCOUNT_Engineer;
|
|
|
|
|
break;
|
|
|
|
|
case _Authority_Technics:
|
|
|
|
|
s = ACCOUNT_Technics;
|
|
|
|
|
break;
|
|
|
|
|
case _Authority_Factory:
|
|
|
|
|
s = ACCOUNT_Factory;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ǰ<EFBFBD>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CString CAuthorityMgr::GetCurAccountName()
|
|
|
|
|
{
|
|
|
|
|
return GetAccountName(GetCurAuthority());
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD>ȡ<EFBFBD>˻<EFBFBD><CBBB><EFBFBD>Ϣ
|
|
|
|
|
void CAuthorityMgr::SaveOrLoad(bool bSave)
|
|
|
|
|
{
|
|
|
|
|
CFileMgr FileMgr;
|
|
|
|
|
char filepath[1024];
|
|
|
|
|
FileMgr.GetFullFilePath(filepath,FILE_PATH);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
|
|
|
|
|
if(bSave)
|
|
|
|
|
{
|
|
|
|
|
CFile file(filepath,CFile::modeReadWrite|CFile::modeCreate);
|
|
|
|
|
CArchive ar(&file,CArchive::store);
|
|
|
|
|
SaveOrLoadExt(ar);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CFile file;
|
|
|
|
|
if(file.Open(filepath,CFile::modeRead))
|
|
|
|
|
{
|
|
|
|
|
CArchive ar(&file,CArchive::load);
|
|
|
|
|
SaveOrLoadExt(ar);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gLogMgr->WriteDebugLog("Authority File Read Error");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CAuthorityMgr::SaveOrLoadExt(CArchive &ar)
|
|
|
|
|
{
|
|
|
|
|
int size = 0;
|
|
|
|
|
if(ar.IsStoring())
|
|
|
|
|
{
|
|
|
|
|
size = m_UserVec.size();//Account <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ar<<size;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_UserVec.clear();
|
|
|
|
|
ar>>size;
|
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
|
{
|
|
|
|
|
CAccount Account;
|
|
|
|
|
m_UserVec.push_back(Account);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
|
{
|
|
|
|
|
m_UserVec[i].Serialize(ar);
|
|
|
|
|
}
|
|
|
|
|
if(!ar.IsStoring())
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
SortUserVec();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CAuthorityMgr::AddAccount(CAccount Account)
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>
|
|
|
|
|
vector<CAccount>::iterator iter = m_UserVec.begin();
|
|
|
|
|
vector<CAccount>::iterator iter_end = m_UserVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
if((*iter).m_Name == Account.m_Name)
|
|
|
|
|
{
|
|
|
|
|
CMsgBox MsgBox;
|
|
|
|
|
CString str(_T("<EFBFBD>û<EFBFBD>:"));
|
|
|
|
|
str += Account.m_Name + "<EFBFBD>Ѵ<EFBFBD><EFBFBD><EFBFBD>!";
|
|
|
|
|
MsgBox.Show(str);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_UserVec.push_back(Account);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
SortUserVec();
|
|
|
|
|
SaveOrLoad(true);
|
|
|
|
|
|
|
|
|
|
//<2F><>¼
|
|
|
|
|
{
|
|
|
|
|
CUserCtrlPar UserCtrlPar;
|
|
|
|
|
UserCtrlPar.m_UserName = Account.m_Name;
|
|
|
|
|
UserCtrlPar.m_UserCtrlType = _UserCtrlType_AddUser;
|
|
|
|
|
UserCtrlPar.m_AuthorityType = Account.m_Authority;
|
|
|
|
|
SaveUserCtrlHistory(UserCtrlPar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CMsgBox MsgBox;
|
|
|
|
|
MsgBox.Show("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!");
|
|
|
|
|
}
|
|
|
|
|
//ɾ<><C9BE>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>
|
|
|
|
|
void CAuthorityMgr::DelUser(int idx)
|
|
|
|
|
{
|
|
|
|
|
//Engineer <20><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>û<EFBFBD>
|
|
|
|
|
if(gAuthorityMgr->CheckAuthority(_Authority_Engineer,true)==false)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
vector<CAccount>::iterator iter = m_UserVec.begin();
|
|
|
|
|
vector<CAccount>::iterator iter_end = m_UserVec.end();
|
|
|
|
|
for(int i=0;iter!=iter_end;iter++,i++)
|
|
|
|
|
{
|
|
|
|
|
if(i==idx)
|
|
|
|
|
{
|
|
|
|
|
CAccount Account = (*iter);
|
|
|
|
|
CMsgBox MsgBox;
|
|
|
|
|
if((*iter).m_Authority>m_CurAuthority)
|
|
|
|
|
{
|
|
|
|
|
MsgBox.Show(_T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>!"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CString str(_T("ɾ<EFBFBD><EFBFBD>"));
|
|
|
|
|
str += (*iter).m_Name + "?";
|
|
|
|
|
if(MsgBox.ConfirmOkCancel(str))
|
|
|
|
|
{
|
|
|
|
|
m_UserVec.erase(iter);
|
|
|
|
|
SortUserVec();
|
|
|
|
|
SaveOrLoad(true);
|
|
|
|
|
|
|
|
|
|
//<2F><>¼
|
|
|
|
|
{
|
|
|
|
|
CUserCtrlPar UserCtrlPar;
|
|
|
|
|
UserCtrlPar.m_UserName = Account.m_Name;
|
|
|
|
|
UserCtrlPar.m_UserCtrlType = _UserCtrlType_DelUser;
|
|
|
|
|
UserCtrlPar.m_AuthorityType = Account.m_Authority;
|
|
|
|
|
SaveUserCtrlHistory(UserCtrlPar);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CAuthorityMgr::InsertToList(CListCtrl &List)
|
|
|
|
|
{
|
|
|
|
|
int size = m_UserVec.size();
|
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
|
{
|
|
|
|
|
int idx = 0;
|
|
|
|
|
List.InsertItem(i," ");//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
List.SetItemText(i,idx++,GetAccountName(m_UserVec[i].m_Authority));//Ȩ<><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
List.SetItemText(i,idx++,(m_UserVec[i].m_Name));//<2F>û<EFBFBD><C3BB><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void CAuthorityMgr::SortUserVec()
|
|
|
|
|
{
|
|
|
|
|
sort(m_UserVec.begin(),m_UserVec.end(),CompareUser);
|
|
|
|
|
}
|
|
|
|
|
#if 1
|
|
|
|
|
//<2F><>ȡȨ<C8A1><EFBFBD><DEB2><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
void CAuthorityMgr::ReadAuthorityParaFile()
|
|
|
|
|
{
|
|
|
|
|
gLogMgr->WriteDebugLog("Func--->ReadAuthorityParaFile");
|
|
|
|
|
CFileMgr FileMgr;
|
|
|
|
|
CString FilePath;
|
|
|
|
|
FileMgr.GetFullFilePath(FilePath,AUTHORITY_PARA_FILE);//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
vector<vector<CString>> StrVec;
|
|
|
|
|
FileMgr.ReadFileToStrVec(FilePath,StrVec);
|
|
|
|
|
|
|
|
|
|
m_AuthorityParVec.clear();
|
|
|
|
|
int size = StrVec.size();
|
|
|
|
|
for(int k=0;k<size;k++)
|
|
|
|
|
{
|
|
|
|
|
if(StrVec[k].size() == 6)
|
|
|
|
|
{
|
|
|
|
|
CAuthorityPar AuthorityPar;
|
|
|
|
|
AuthorityPar.m_AuthorityName = StrVec[k][0];
|
|
|
|
|
AuthorityPar.m_ShowName = StrVec[k][1];
|
|
|
|
|
AuthorityPar.m_bOperator = (StrVec[k][2]=="1")?true:false;
|
|
|
|
|
AuthorityPar.m_bOperatorAdmin = (StrVec[k][3]=="1")?true:false;
|
|
|
|
|
AuthorityPar.m_bEngineer = (StrVec[k][4]=="1")?true:false;
|
|
|
|
|
AuthorityPar.m_bTechnics = (StrVec[k][5]=="1")?true:false;
|
|
|
|
|
m_AuthorityParVec.push_back(AuthorityPar);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CAuthorityMgr::SaveAuthorityParaFile()
|
|
|
|
|
{
|
|
|
|
|
gLogMgr->WriteDebugLog("Func--->SaveAuthorityParaFile");
|
|
|
|
|
CFileMgr FileMgr;
|
|
|
|
|
CString FilePath;
|
|
|
|
|
FileMgr.GetFullFilePath(FilePath,AUTHORITY_PARA_FILE);//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
|
|
|
|
|
m_AuthorityParVec = m_TmpAuthorityParVec;
|
|
|
|
|
|
|
|
|
|
ofstream FileStream;
|
|
|
|
|
FileStream.open(FilePath);
|
|
|
|
|
int size = m_AuthorityParVec.size();
|
|
|
|
|
for(int k=0;k<size;k++)
|
|
|
|
|
{
|
|
|
|
|
CAuthorityPar &AuthorityPar = m_AuthorityParVec[k];
|
|
|
|
|
FileStream<<AuthorityPar.m_AuthorityName<<",";
|
|
|
|
|
FileStream<<AuthorityPar.m_ShowName<<",";
|
|
|
|
|
FileStream<<Bool2CString(AuthorityPar.m_bOperator)<<",";
|
|
|
|
|
FileStream<<Bool2CString(AuthorityPar.m_bOperatorAdmin)<<",";
|
|
|
|
|
FileStream<<Bool2CString(AuthorityPar.m_bEngineer)<<",";
|
|
|
|
|
FileStream<<Bool2CString(AuthorityPar.m_bTechnics)<<"\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bool CAuthorityMgr::CheckAuthorityByName(CString AuthorityName,bool bShowMsgbox)
|
|
|
|
|
{
|
|
|
|
|
bool Ret = false;
|
|
|
|
|
CString ShowName;
|
|
|
|
|
int size = m_AuthorityParVec.size();
|
|
|
|
|
for(int k=0;k<size;k++)
|
|
|
|
|
{
|
|
|
|
|
CAuthorityPar &AuthorityPar = m_AuthorityParVec[k];
|
|
|
|
|
if(AuthorityName == AuthorityPar.m_AuthorityName)
|
|
|
|
|
{
|
|
|
|
|
if(m_CurAuthority==_Authority_Operator && AuthorityPar.m_bOperator)
|
|
|
|
|
Ret = true;
|
|
|
|
|
if(m_CurAuthority==_Authority_OperatorAdmin && AuthorityPar.m_bOperatorAdmin)
|
|
|
|
|
Ret = true;
|
|
|
|
|
if(m_CurAuthority==_Authority_Engineer && AuthorityPar.m_bEngineer)
|
|
|
|
|
Ret = true;
|
|
|
|
|
if(m_CurAuthority==_Authority_Technics && AuthorityPar.m_bTechnics)
|
|
|
|
|
Ret = true;
|
|
|
|
|
if(m_CurAuthority==_Authority_Factory)
|
|
|
|
|
Ret = true;
|
|
|
|
|
ShowName = AuthorityPar.m_ShowName;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!Ret && bShowMsgbox)
|
|
|
|
|
{
|
|
|
|
|
CMsgBox MsgBox;
|
|
|
|
|
CString str = ShowName + " : Ȩ<><EFBFBD><DEB2><EFBFBD>!";
|
|
|
|
|
MsgBox.Show(str);
|
|
|
|
|
}
|
|
|
|
|
return Ret;
|
|
|
|
|
}
|
|
|
|
|
void CAuthorityMgr::InitAuthorityTypeComb(CComboBox &Combo)
|
|
|
|
|
{
|
|
|
|
|
int idx = 0;
|
|
|
|
|
Combo.InsertString(idx++,GetAccountName(_Authority_Operator));
|
|
|
|
|
Combo.InsertString(idx++,GetAccountName(_Authority_OperatorAdmin));
|
|
|
|
|
Combo.InsertString(idx++,GetAccountName(_Authority_Engineer));
|
|
|
|
|
Combo.InsertString(idx++,GetAccountName(_Authority_Technics));
|
|
|
|
|
Combo.SetCurSel(0);
|
|
|
|
|
}
|
|
|
|
|
void CAuthorityMgr::InitAuthorityParList(CListCtrl &List)
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>
|
|
|
|
|
List.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_CHECKBOXES);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int idx = 0;
|
|
|
|
|
List.InsertColumn(idx,"",LVCFMT_LEFT,25);//checkbox
|
|
|
|
|
idx++;
|
|
|
|
|
List.InsertColumn(idx,"",LVCFMT_LEFT,200,-1);
|
|
|
|
|
idx++;
|
|
|
|
|
|
|
|
|
|
int size = m_AuthorityParVec.size();
|
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
|
{
|
|
|
|
|
CAuthorityPar &AuthorityPar = m_AuthorityParVec[i];
|
|
|
|
|
int idx = 0;
|
|
|
|
|
List.InsertItem(i," ");//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
List.SetItemText(i,idx++,"");//check box
|
|
|
|
|
List.SetItemText(i,idx++,AuthorityPar.m_ShowName);//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|
|
|
|
m_TmpAuthorityParVec = m_AuthorityParVec;
|
|
|
|
|
|
|
|
|
|
UpdateAuthorityParList(List,0);
|
|
|
|
|
}
|
|
|
|
|
void CAuthorityMgr::UpdateAuthorityParList(CListCtrl &List,int AuthorityType)
|
|
|
|
|
{
|
|
|
|
|
for(int i=0;i<List.GetItemCount();i++)
|
|
|
|
|
{
|
|
|
|
|
CAuthorityPar &AuthorityPar = m_TmpAuthorityParVec[i];
|
|
|
|
|
if(AuthorityType==0)
|
|
|
|
|
List.SetCheck(i,AuthorityPar.m_bOperator);
|
|
|
|
|
if(AuthorityType==1)
|
|
|
|
|
List.SetCheck(i,AuthorityPar.m_bOperatorAdmin);
|
|
|
|
|
if(AuthorityType==2)
|
|
|
|
|
List.SetCheck(i,AuthorityPar.m_bEngineer);
|
|
|
|
|
if(AuthorityType==3)
|
|
|
|
|
List.SetCheck(i,AuthorityPar.m_bTechnics);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CAuthorityMgr::UpdateAuthorityPar(CListCtrl &List,int AuthorityType)
|
|
|
|
|
{
|
|
|
|
|
for(int i=0;i<List.GetItemCount();i++)
|
|
|
|
|
{
|
|
|
|
|
CAuthorityPar &AuthorityPar = m_TmpAuthorityParVec[i];
|
|
|
|
|
if(AuthorityType==0)
|
|
|
|
|
AuthorityPar.m_bOperator = List.GetCheck(i);
|
|
|
|
|
if(AuthorityType==1)
|
|
|
|
|
AuthorityPar.m_bOperatorAdmin = List.GetCheck(i);
|
|
|
|
|
if(AuthorityType==2)
|
|
|
|
|
AuthorityPar.m_bEngineer = List.GetCheck(i);
|
|
|
|
|
if(AuthorityType==3)
|
|
|
|
|
AuthorityPar.m_bTechnics = List.GetCheck(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
//<2F><>¼<EFBFBD><C2BC>ǰ<EFBFBD>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
|
|
|
|
|
void CAuthorityMgr::SaveUserCtrlHistory(CUserCtrlPar UserCtrlPar)
|
|
|
|
|
{
|
|
|
|
|
if(UserCtrlPar.m_AuthorityType==_Authority_NoLogin)
|
|
|
|
|
return;
|
|
|
|
|
if(UserCtrlPar.m_UserName==ACCOUNT_NoLogin)
|
|
|
|
|
return;
|
|
|
|
|
CWorkTime WorkTime;
|
|
|
|
|
CString CurDateTime = WorkTime.GetDateTime("/",":");
|
|
|
|
|
|
|
|
|
|
CCsvData CsvData;
|
|
|
|
|
CsvData.AddData("ʱ<EFBFBD><EFBFBD>",false);
|
|
|
|
|
CsvData.AddData(CurDateTime,true);
|
|
|
|
|
|
|
|
|
|
CsvData.AddData("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",false);
|
|
|
|
|
switch(UserCtrlPar.m_UserCtrlType)
|
|
|
|
|
{
|
|
|
|
|
case _UserCtrlType_AddUser:
|
|
|
|
|
{
|
|
|
|
|
CsvData.AddData("Add",true);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case _UserCtrlType_DelUser:
|
|
|
|
|
{
|
|
|
|
|
CsvData.AddData("Delete",true);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case _UserCtrlType_login:
|
|
|
|
|
{
|
|
|
|
|
CsvData.AddData("Login",true);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case _UserCtrlType_logout:
|
|
|
|
|
{
|
|
|
|
|
CsvData.AddData("Logout",true);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CsvData.AddData("<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>",false);
|
|
|
|
|
CsvData.AddData(UserCtrlPar.m_UserName,true);
|
|
|
|
|
CsvData.AddData("Ȩ<EFBFBD><EFBFBD>",false);
|
|
|
|
|
CsvData.AddData(GetAccountName(UserCtrlPar.m_AuthorityType),true);
|
|
|
|
|
CsvData.AddData("",false);
|
|
|
|
|
CsvData.AddData("",true);//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
CFileMgr FileMgr;
|
|
|
|
|
CString DataPath;
|
|
|
|
|
CurDateTime = WorkTime.GetCurDate("_");
|
|
|
|
|
|
|
|
|
|
CString DirPath = gProgramLaserTuiHuo->GetLaipuLaserDataDir(NEW_LOGIN_FILE_PATH);
|
|
|
|
|
DataPath += DirPath;
|
|
|
|
|
|
|
|
|
|
DataPath += WorkTime.GetCurYear();
|
|
|
|
|
DataPath += "\\"+WorkTime.GetCurMonth();
|
|
|
|
|
//DataPath += "\\"+WorkTime.GetCurDay();
|
|
|
|
|
DataPath += "\\";
|
|
|
|
|
CString DataName;
|
|
|
|
|
DataName += "LaipuDrawing_";
|
|
|
|
|
DataName += CurDateTime;
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼
|
|
|
|
|
FileMgr.CreatDir(DataPath);
|
|
|
|
|
|
|
|
|
|
FileMgr.WriteDataToExcel(DataPath,DataName,CsvData,true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endif
|