| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005 |
- // Login3.cpp: implementation of the Login3 class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "YLGL.h"
- #include "Login3.h"
- #include "DigitalWorkSet2.h"
- #include "ShowMsg.h"
- #include "ShowBakState.h"
- #include "CharacterConvert.h"
- #include "SQLite3Interface.h"
- #include "NetShareInfo.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- //extern void WriteTextLog(CString str); // Jeff写客户端日志;
- Login3::Login3()
- {
- m_psw = _T("");
- m_bsave = FALSE;
- m_account = _T("");
- g_pMainWnd->GetSkin();
- }
- Login3::~Login3()
- {
- }
- void Login3::OnFSCommand(LPCTSTR command, LPCTSTR args)
- {
- }
- // ***********************************************最严重的漏洞后门*********************************************************************//
- // Jeff.
- // remark by Jeff. 2014.09.04
- // 用户登录的验证信息,不可放在客户里做验证。
- // 同时,客户端在未验证自身身份时,禁止读取数据库里的用户表;
- // 以下代码,有严重的后门可供侵入。
- //
- // 新建登录处理过程:
- // int LoginVerify(__in const TCHAR *pAccount,__in const int &nAccountLen, __in const TCHAR *pPassWord, __in const int &nPassWordLen);
- //
- // 同理,在未登录前,客户端不能读写数据库的任何信息,即需要对welcome对话框进行处理.
- //
- // ***********************************************************************************************************************************//
- void Login3::Init()
- {
- m_combobox.Create(WS_VSCROLL | WS_CHILD | CBS_DROPDOWN, m_rcarray.ElementAt(2), this, 100);
- m_combobox.ShowWindow(SW_SHOW);
- // m_combobox.SetFocus(); // Add by Jeff //无效;
- CRect rc = m_rcarray.ElementAt(2);
- rc.bottom += 200;
- m_combobox.MoveWindow(rc);
- m_combobox.GetWindowRect(rc);
- int hei = rc.Height();
- rc = m_rcarray.ElementAt(3);
- rc.bottom = rc.top + hei + 5;
- m_edit.Create(ES_AUTOHSCROLL | WS_CHILD | ES_LEFT | WS_BORDER | ES_PASSWORD | WS_EX_WINDOWEDGE, rc, this, 200);
- m_edit.ShowWindow(SW_SHOW);
- rc = m_rcarray.ElementAt(4);
- rc.bottom = rc.top + 13;
- rc.right = rc.left + 13;
- m_button.Create("", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_FLAT, rc, this, 300);
- tpFont.CreatePointFont(180, _T("黑体"));
- m_edit.SetFont(&tpFont);
- m_combobox.SetFont(&tpFont);
- /////////////////////////
- #if JEFF_TEST_ON
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 24; // Jeff.version表;版本信息;
- g_sendhead.code[1] = 29; // Jeff.path表;路径
- g_sendhead.code[2] = 5; // Jeff.renyuan表;人员表;
- g_sendhead.code[3] = 1; // Jeff.historydb表;历史数据库;
- g_sendhead.code[4] = 171; // Jeff.childmsg表;其实就是"资料与相片备份状态"
- if (g_branchname == "")
- {
- g_sendhead.code[5] = 152; // Jeff.不读任何表,读brachinfo.dat文件里的数据;
- g_sendhead.tabcount = 6;
- }
- else
- g_sendhead.tabcount = 5;
- int g_nYearposTemp = g_nYearpos;
- g_nYearpos = -1;
- g_pMainWnd->ProcessChatMessageRequest2(";;;;;");
- g_nYearpos = g_nYearposTemp;
- if (g_bSendOK == 0)
- {
- CDialog::OnCancel();
- return;
- }
- CArray<CStringArray, CStringArray>patharray;
- CArray<CStringArray, CStringArray>userarray;
- if (g_branchname == "")
- DataToArray( &g_cominfoarray, &patharray, &userarray, &g_hisyeararray, &g_bakstatearray, &g_brancharray);
- else
- DataToArray( &g_cominfoarray, &patharray, &userarray, &g_hisyeararray, &g_bakstatearray);
- #else
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 23; // Jeff.accountview视图;用户
- g_sendhead.code[1] = 24; // Jeff.version表;版本信息;
- g_sendhead.code[2] = 29; // Jeff.path表;路径
- g_sendhead.code[3] = 5; // Jeff.renyuan表;人员表;
- g_sendhead.code[4] = 1; // Jeff.historydb表;历史数据库;
- g_sendhead.code[5] = 171; // Jeff.childmsg表;其实就是"资料与相片备份状态"
- if (g_branchname == "")
- {
- g_sendhead.code[6] = 152; // Jeff.不读任何表,读brachinfo.dat文件里的数据;
- g_sendhead.tabcount = 7;
- }
- else
- g_sendhead.tabcount = 6;
- int g_nYearposTemp = g_nYearpos;
- g_nYearpos = -1;
- g_pMainWnd->ProcessChatMessageRequest2("[dimission]<>'离职' or [dimission] is null;;;;;;");
- g_nYearpos = g_nYearposTemp;
- if (g_bSendOK == 0)
- {
- CDialog::OnCancel();
- return;
- }
- CArray<CStringArray, CStringArray>patharray;
- CArray<CStringArray, CStringArray>userarray;
- if (g_branchname == "")
- DataToArray(&m_ArrayOfAccountInfo, &g_cominfoarray, &patharray, &userarray, &g_hisyeararray, &g_bakstatearray, &g_brancharray);
- else
- DataToArray(&m_ArrayOfAccountInfo, &g_cominfoarray, &patharray, &userarray, &g_hisyeararray, &g_bakstatearray);
- #endif
- // 149 = [version].[original] 是否使用相片原名导入;
- g_bOriginal = atoi(g_cominfoarray.ElementAt(0).ElementAt(149));
- // 获取N8的配置信息: N8用户目录、N8数据目录、N8产品目录、N8服务器IP地址;
- sprintf(g_szN8ViewUserDir, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(152));
- sprintf(g_szN8ViewStsDir, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(153));
- sprintf(g_szN8ViewProductDir, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(154));
- sprintf(g_szN8SvIP, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(155));
- g_bEnableClound = atoi(g_cominfoarray.ElementAt(0).ElementAt(156));
- g_bExportBarCode = atoi(g_cominfoarray.ElementAt(0).ElementAt(157));
- g_dwSoftRunTime = atol(g_cominfoarray.ElementAt(0).ElementAt(158));
- g_strAntiTheftWarning = g_cominfoarray.ElementAt(0).ElementAt(139); // 盗版提示;
- if ( !g_strAntiTheftWarning.IsEmpty() )
- {
- MessageBox(g_strAntiTheftWarning, _T("温馨提示"), MB_TOPMOST|MB_ICONWARNING);
- }
- if ( lyfzLibrary::LoadWeiXinLibaray() )
- {
- if ( lyfzLibrary::g_PtrShowSoftRunTimeDialog )
- {
- lyfzLibrary::g_PtrShowSoftRunTimeDialog(g_dwSoftRunTime);
- }
- lyfzLibrary::FreeWeiXinLibaray();
- }
- else
- {
- AfxMessageBox(_T("加载微信模板失败"));
- exit(0);
- }
- if (g_branchname == "")
- {
- g_cominfoarraylocal.SetSize(1, 1);
- g_cominfoarraylocal.ElementAt(0).Copy(g_cominfoarray.ElementAt(0));
- }
- CheckBakState(); // Jeff.启用客户端时,先检测"资料与照片备份状态"
- if (g_branchname == "")
- {
- g_domain = patharray.ElementAt(0).ElementAt(0);
- if (g_domain.Find(".ly.com") == -1)g_domain.Empty();
- g_bSaveUploadTask1 = atoi(g_cominfoarray.ElementAt(0).ElementAt(67));
- g_bSaveUploadTask2 = atoi(g_cominfoarray.ElementAt(0).ElementAt(68));
- g_bSaveUploadTask3 = atoi(g_cominfoarray.ElementAt(0).ElementAt(69));
- g_bSaveUploadTask4 = atoi(g_cominfoarray.ElementAt(0).ElementAt(70));
- }
- BOOL bHide = atoi(g_cominfoarray.ElementAt(0).ElementAt(58));
- AfxGetApp()->WriteProfileInt(LYFZVERSION, "hidewindow2", bHide);
- g_userarray.SetSize(userarray.GetSize(), 1);
- int count = 0;
- for (int ii = 0; ii < userarray.GetSize(); ii++)
- {
- if (userarray.ElementAt(ii).ElementAt(10) == "在职")
- g_userarray.ElementAt(count++).Copy(userarray.ElementAt(ii));
- }
- g_userarray.SetSize(count, 1);
- #ifdef TESTHG
- if (0)
- #else
- // 设置版本;
- CString strVersion;
- strVersion.Format("%02d%02d", g_arrFileVersion[2], g_arrFileVersion[3]);
- if (g_cominfoarray.ElementAt(0).ElementAt(0) != strVersion)
- #endif
- {
- AfxMessageBox("您必须更新软件才能继续使用, 请与系统管理员联系!", MB_ICONINFORMATION);
- CDialog::OnCancel();
- g_pMainWnd->AutoUpdate();
- return;
- }
- #ifndef ENTERPRISE_VERSION
- {
- #ifndef CHILD_VERSION
- #ifdef BASIC_VERSION
- if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="0")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0);return;
- }
- #else
- if(g_cominfoarray.ElementAt(0).ElementAt(46)!="1")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0);return;
- }
- #endif
- #else
- #ifdef BASIC_VERSION
- if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="2")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0);return;
- }
- #else
- if(g_cominfoarray.ElementAt(0).ElementAt(46)!="3")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0);return;
- }
- #endif
- #endif
- }
- #else
- {
- #ifndef CHILD_VERSION
- #ifdef BASIC_VERSION
- if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="4")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0);return ;
- }
- #else
- if(g_cominfoarray.ElementAt(0).ElementAt(46)!="5")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0);return ;
- }
- #endif
- #else
- #ifdef BASIC_VERSION
- if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="6")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0);return ;
- }
- #else
- if (g_cominfoarray.ElementAt(0).ElementAt(46) != "7")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0); return;
- }
- #endif
- #endif
- }
- #endif
- g_title = g_cominfoarray.ElementAt(0).ElementAt(10);
- WriteTitle(g_cominfoarray.ElementAt(0).ElementAt(10));
- g_date = g_cominfoarray.ElementAt(0).ElementAt(1);
- if (g_hisyeararray.GetSize())
- {
- g_pMainWnd->AddHistoryMenu(&g_hisyeararray);
- }
- if (g_brancharray.GetSize() && g_branchname == "")
- {
- // WriteTextLog("启动集团版菜单");
- g_pMainWnd->AddBranchMenu(&g_brancharray); // 添加操作分店菜单;
- }
- if (g_branchname == "")
- {
- #if USE_SHARE_FLORD
- // 清空数组,并重新获取NetShareInfo表;
- g_aryOfSharePathInfo.RemoveAll();
- g_pMainWnd->GetSharePathInfo();
- if( CNetShareInfo::GetInstance() )
- {
- CNetShareInfo::GetInstance()->Initialize(g_domain, g_serverbak, &g_aryOfSharePathInfo);
- }
- #endif
- #ifdef USE_KERNEL_DLL
- if (g_pIMGProcess)
- g_pIMGProcess->SetEnvInfoEx(g_server, g_domain, &g_cominfoarray, &g_brancharray, &g_aryOfSharePathInfo);
- //////////////////////////////////////////////////////////////////////////
- // 2015.11.03 设置回访本店的保留信息;
- INT nCount = g_cominfoarray.GetSize();
- for ( INT i = 0; i < nCount; i++ )
- {
- sprintf(g_ThisShopVersion.szVersion, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(0));
- sprintf(g_ThisShopVersion.szbakServer1, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(20));
- sprintf(g_ThisShopVersion.szbakServer2, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(21));
- sprintf(g_ThisShopVersion.szbakServer3, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(22));
- sprintf(g_ThisShopVersion.szbakServer4, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(23));
- sprintf(g_ThisShopVersion.szbakServer5, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(24));
- g_ThisShopVersion.bUpLoadCheck1 = _ttoi(g_cominfoarray.ElementAt(0).ElementAt(67));
- g_ThisShopVersion.bUpLoadCheck2 = _ttoi(g_cominfoarray.ElementAt(0).ElementAt(68));
- g_ThisShopVersion.bUpLoadCheck3 = _ttoi(g_cominfoarray.ElementAt(0).ElementAt(69));
- g_ThisShopVersion.bUpLoadCheck4 = _ttoi(g_cominfoarray.ElementAt(0).ElementAt(70));
- g_ThisShopVersion.strZiptype1 = g_cominfoarray.ElementAt(0).ElementAt(78);
- g_ThisShopVersion.strZiptype2 = g_cominfoarray.ElementAt(0).ElementAt(79);
- g_ThisShopVersion.strZiptype3 = g_cominfoarray.ElementAt(0).ElementAt(80);
- g_ThisShopVersion.strZiptype4 = g_cominfoarray.ElementAt(0).ElementAt(81);
- g_ThisShopVersion.strUploadRule = g_cominfoarray.ElementAt(0).ElementAt(116);
- }
- //////////////////////////////////////////////////////////////////////////
- #endif
- CString szFolderName[] =
- {
- _T("\\客户原片(管理软件)$"),
- _T("\\修好的片(管理软件)$"),
- _T("\\设计好的片(管理软件)$"),
- _T("\\精修好的片(管理软件)$"),
- _T("\\礼服图片(管理软件)$"),
- _T("\\电话录音(管理软件)$"),
- _T("\\客户原片(管理软件)$\\效果图")
- };
- CString strHead = _T("");
- CString strServerName = _T("");
- if (g_server == "127.0.0.1")
- {
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 63;
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(1);
- if (g_bSendOK == 0)
- {
- CDialog::OnCancel();
- return;
- }
- DataToArray(&g_List1array);
- strHead = _T("");
- strServerName = g_List1array.ElementAt(0).ElementAt(0);
- }
- else if (patharray.GetSize())
- {
- strHead = _T("\\\\");
- strServerName = g_serverbak;
- }
- g_path1bak = g_path1 = strHead + strServerName + szFolderName[0];
- g_path2bak = g_path2 = strHead + strServerName + szFolderName[1];
- g_path3bak = g_path3 = strHead + strServerName + szFolderName[2];
- g_path4bak = g_path4 = strHead + strServerName + szFolderName[3];
- g_path5bak = g_path5 = strHead + strServerName + szFolderName[4];
- g_path6bak = g_path6 = strHead + strServerName + szFolderName[5];
- g_path7bak = g_path7 = strHead + strServerName + szFolderName[6];
- }
- try
- {
- CFile fp;
- if (fp.Open(g_mainpath + "\\loginuser.dat", CFile::modeRead))
- {
- DWORD length = fp.GetLength();
- if (!length)
- return;
- CArchive ar(&fp, CArchive::load);
- m_userarray.Serialize(ar);
- fp.Close();
- for (int i = 0; i < m_userarray.GetSize(); i++)
- {
- m_combobox.AddString(m_userarray.ElementAt(i));
- }
- if (m_combobox.GetCount()>0)
- {
- m_combobox.SetCurSel(0);
- m_combobox.GetLBText(0, m_account);
- }
- if (!m_account.IsEmpty())
- {
- m_psw = AfxGetApp()->GetProfileString(LYFZVERSION, _T(m_account));
- if (!m_psw.IsEmpty())
- m_bsave = TRUE;
- }
- SetDlgItemText(200, m_psw);
- m_button.SetCheck(m_bsave);
- }
- }
- catch (...)
- {
- }
- }
- /************************************************************************/
- /*
- 函数: IsFolderExist
- 描述: 判断共享目录是否存在
- 参数:
- const CString& strDomain 域名
- std::vector<CString*>& vPath 共享目录集
- 返回: TRUE成功,FALSE失败
- */
- /************************************************************************/
- BOOL Login3::IsShareFolderExist(CString& strSharePath)
- {
- if(strSharePath == _T(""))
- return FALSE;
- char szPath[MAX_PATH] = { 0 };
- strcpy(szPath, strSharePath.GetBuffer(strSharePath.GetLength()));
- if(IsExistFolder(szPath) == -1)
- return FALSE;
- return TRUE;
- }
- /************************************************************************/
- /*
- 函数: ReadBranchFromDomain
- 描述: 从域名读取分店信息
- 参数:
- CString& strDomain 域名
- 返回: 0成功,-1失败
- */
- /************************************************************************/
- int Login3::ReadBranchFromDomain(CString& strDBFile, CString& strDomain, std::vector<std::string>& vInfo)
- {
- if(strDBFile == _T("") || strDomain == _T(""))
- return -1;
- CSQLiter3Interface db;
- char szPath[MAX_PATH] = { 0 };
- strcpy(szPath, strDBFile.GetBuffer(strDBFile.GetLength()));
- if(db.OpenSQLite3DB(szPath) == -1)
- return -1;
- /*
- Select()
- const char* pTableName 表名
- const char* pFields, 一个字段或多个字段如:字段1,字段2,字段3...
- const char* pLimit, where 条件如:字段1='xx',字段2='xxx'
- vector<string>& vValues 返回结果集
- CString& strError 如果失败返回错误消息
- */
- char szDomain[64] = {0};
- strcpy(szDomain, strDomain.GetBuffer(strDomain.GetLength()));
- char szLimit[256] = {0};
- sprintf(szLimit, "domain='%s'", szDomain);
- CString strError = _T("");
- int nRet = db.Select("remoteinfo", "*", szLimit, vInfo, strError);
- db.Close();
- return nRet;
- }
- void Login3::Destory()
- {
- }
- void Login3::BtnClick(WPARAM wParam, LPARAM lParam)
- {
- int id = lParam;
- id -= 99;
- switch (id)
- {
- case 2:
- {
- MyOnOK();
- }
- break;
- case 1:
- CDialog::OnCancel();
- break;
- }
- }
- BOOL Login3::PreTransMsg(MSG* pMsg)
- {
- #if 0 // Add Jeff:使用tab键切换控件;
- if (pMsg->message == WM_KEYDOWN && pMsg->message == VK_TAB)
- {
- // 当前拥有焦点的控件 == m_combobox控件;
- if(GetFocus()->GetSafeHwnd() == m_combobox.GetSafeHwnd())
- {
- // 使m_edit拥有焦点
- m_edit.SetFocus();
- return TRUE;
- }
- else if (GetFocus()->GetSafeHwnd() == m_edit.GetSafeHwnd())
- {
- m_button->SetFocus();
- return TRUE;
- }
- }
- else if (pMsg->message == WM_KEYDOWN)
- #else
- if (pMsg->message == WM_KEYDOWN)
- #endif
- {
- switch (pMsg->wParam)
- {
- case VK_RETURN:
- MyOnOK();
- // 回车键登陆时,必须return,否则对话框在debug模式下会报错(对话框已销毁,不应再执行其他代码);
- return 1; // break;
- case VK_TAB:
- {
- #if 0
- CWnd *pParent = GetParent();
- CWnd *pWnd = GetFocus();
- //CString strText;
- int nCtrlId = pWnd->GetDlgCtrlID();
- //m_combobox.m
- // LOG4C((LOG_NOTICE,"VK_TAB:%d,%d,%d"),nCtrlId,m_combobox.GetDlgCtrlID(),pParent->GetDlgCtrlID());
- #endif
- HWND _hwnd = GetFocus()->GetSafeHwnd();
- if (_hwnd != m_combobox.m_hWnd && _hwnd != m_edit.m_hWnd && _hwnd != m_button.m_hWnd)
- //if( _hwnd == m_combobox.m_hWnd )
- {
- //LOG4C((LOG_NOTICE,"使m_edit拥有焦点"));
- // 使m_edit拥有焦点
- m_edit.SetFocus();
- // 使密码框的内容清空或者全靠;
- //m_combobox.SetFocus();
- return TRUE;
- }
- // else if ( _hwnd == m_combobox.m_hWnd)
- // {
- // m_edit.SetFocus();
- // return TRUE;
- // }
- else if (_hwnd == m_edit.m_hWnd/*m_edit.GetSafeHwnd()*/)
- {
- //LOG4C((LOG_NOTICE,"将焦点返回给commbox"));
- m_combobox.SetFocus();
- return TRUE;
- }
- }
- break;
- }
- }
- else if (pMsg->message == WM_LBUTTONDOWN)
- {
- g_bNeedDrawParent = 1;
- CPoint pt;
- ::GetCursorPos(&pt);
- ScreenToClient(&pt);
- CRect rc;
- m_button.GetWindowRect(rc);
- ScreenToClient(rc);
- if (rc.PtInRect(pt))return CDialog::PreTranslateMessage(pMsg);
- if (m_rcarray.ElementAt(4).PtInRect(pt))
- {
- m_button.SetCheck(!m_button.GetCheck());
- }
- }
- return CDialog::PreTranslateMessage(pMsg);
- }
- void Login3::SaveLongin()
- {
- if (m_bsave)
- {
- AfxGetApp()->WriteProfileString(LYFZVERSION, _T(m_account), m_psw);
- }
- else
- {
- AfxGetApp()->WriteProfileString(LYFZVERSION, _T(m_account), "");
- }
- if (m_userarray.GetSize())
- {
- if (m_userarray.ElementAt(0) != m_account)
- {
- RemoveExist(m_account);
- m_userarray.InsertAt(0, m_account);
- if (m_userarray.GetSize() > 30)
- m_userarray.SetSize(30);
- }
- }
- else
- {
- m_userarray.Add(m_account);
- }
- CFile f;
- if (!f.Open(g_mainpath + "\\loginuser.dat", CFile::modeWrite | CFile::modeCreate))return;
- CArchive ar(&f, CArchive::store);
- m_userarray.Serialize(ar);
- ar.Close();
- f.Close();
- }
- void Login3::RemoveExist(CString str)
- {
- for (int i = 0; i < m_userarray.GetSize(); i++)
- {
- if (str == m_userarray.ElementAt(i))
- {
- m_userarray.RemoveAt(i);
- return;
- }
- }
- }
- void Login3::CheckBakState()
- {
- while (g_bakstatearray.GetSize()>7)
- {
- g_bakstatearray.RemoveAt(0);
- }
- int photocount = 0;
- int infocount = 0;
- for (int i = 0; i < g_bakstatearray.GetSize(); i++)
- {
- if (g_bakstatearray.ElementAt(i).ElementAt(1) != "1")photocount++;
- if (g_bakstatearray.ElementAt(i).ElementAt(2) != "1")infocount++;
- }
- int size = g_bakstatearray.GetSize();
- if (size == 0)return;
- if (g_bakstatearray.ElementAt(size - 1).ElementAt(1) == "1" && g_bakstatearray.ElementAt(size - 1).ElementAt(2) == "1")
- return;
- if (infocount>1 || photocount > 2)
- {
- // Jeff."资料与照片备份状态"对话框;
- ShowBakState dlg;
- dlg.m_pArray = &g_bakstatearray;
- dlg.DoModal();
- }
- }
- //-------------------------------------------------------------------
- // Remark by Jeff - 2014.10.15
- // 用户登陆验证方式,转由服务端验证;
- // 1.服务端中的客户端SOCKET需添加一布尔变量标识客户端是否通过验证,若没有则断开与客户端的连接;
- // 2.验证通过,返回该账号关联的员工信息;
- //
- //-------------------------------------------------------------------
- void Login3::MyOnOK()
- {
- m_combobox.GetWindowText(m_account);
- GetDlgItemText(200, m_psw);
- m_bsave = m_button.GetCheck();
- if (m_account.IsEmpty())
- {
- AfxMessageBox("资料不全!", MB_ICONINFORMATION);
- return;
- }
- #if JEFF_TEST_ON
- // Jeff:使用新的登陆验证方式!
- CString strSQL;
- BYTE byPsw[50] = {0};
- #ifndef UNICODE
- memcpy(byPsw, (LPCSTR)m_psw, m_psw.GetLength());
- #endif
- CMD5 md5;
- md5.SetBYTEText(byPsw, strlen((char*)byPsw));
- strSQL.Format("account='%s' and psw='%s'", m_account, md5.GetMD5Digest());
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 23;
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strSQL);
- if (!g_bSendOK)
- {
- MessageBox(_T("提示"),_T("连接服务器失败"),MB_OK | MB_TOPMOST);
- }
- m_ArrayOfAccountInfo.RemoveAll();
- DataToArray(&m_ArrayOfAccountInfo);
- if (m_ArrayOfAccountInfo.GetSize() == 0)
- {
- AfxMessageBox("账号或密码错误");
- return;
- }
- else
- {
- g_user.bLongin = 1;
- g_user.account = m_account;
- g_user.name = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(1);
- g_user.rights = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(3);
- g_user.rights2 = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(4);
- g_user.m_discount = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(5);
- g_user.m_discount2 = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(6);
- g_user.bm = GetBm(g_user.name, g_userarray);
- g_user.level = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(7);
- SaveLongin();
- WriteLog("登陆系统!", "登陆系统!");
- if (g_user.rights2.IsEmpty())
- g_user.rights2 = "*门市流程;1;拍照;修片;选片;精修;设计;发片/取件;*财务管理;0;*统计查询;0;* 短信群发 ;0;*会员管理;0;*礼服管理;0;*库存管理;0;*客户管理;0;*来电精灵;0;*员工考勤;0;";
- g_pMainWnd2->RefreshOutlookBar();
- CString str;
- str = "当前用户:" + g_user.name;
- #ifndef NEW_SKIN
- g_pMainWnd->m_wndStatusBar.SetPaneText(1, str, TRUE);
- #endif
- if (g_pMainWnd2)g_pMainWnd2->DrawLogin();
- #ifdef TEST_LOCAL
- CString sql;
- sql = "update path set path1='" + g_server + "',path2='" + g_server + "',path3='" + g_server + "',path4='" + g_server + "'";
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- CString path1 = "客户原片(管理软件)$";
- CString path2 = "修好的片(管理软件)$";
- CString path3 = "设计好的片(管理软件)$";
- CString path4 = "精修好的片(管理软件)$";
- ::CreateDirectory(g_mainpath + "\\" + path1, NULL);
- CString temp;
- temp.Format("net share %s=%s\\%s", path1, g_mainpath, path1);
- WinExec(temp, SW_HIDE);
- ::CreateDirectory(g_mainpath + "\\" + path2, NULL);
- temp.Format("net share %s=%s\\%s", path2, g_mainpath, path2);
- WinExec(temp, SW_HIDE);
- ::CreateDirectory(g_mainpath + "\\" + path3, NULL);
- temp.Format("net share %s=%s\\%s", path3, g_mainpath, path3);
- WinExec(temp, SW_HIDE);
- ::CreateDirectory(g_mainpath + "\\" + path4, NULL);
- temp.Format("net share %s=%s\\%s", path4, g_mainpath, path4);
- WinExec(temp, SW_HIDE);
- #endif
- if (1)//g_user.bm=="数码部" || g_user.bm=="摄影部" || g_user.bm=="制作部")
- {
- DigitalWorkSet2 dlg;
- dlg.m_mode = 1;
- dlg.m_checkwork = 1;
- dlg.DoModal();
- }
- ///内部消息
-
- str = "%";
- str += g_user.name;
- str += "%";
- CString filter = "[receiver] like '" + str + "'";
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 126;
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(filter);
- if (g_bSendOK == 0)return;
- DataToArray(&g_List1array);
- str = "," + g_user.name + ",";
- for (int i = g_List1array.GetSize() - 1; i >= 0; i--)
- {
- CString receivers2 = g_List1array.ElementAt(i).ElementAt(4);
- receivers2.TrimLeft(",");
- receivers2.TrimRight(",");
- receivers2 = "," + receivers2 + ",";
- if (receivers2.Find(str) != -1)
- g_List1array.RemoveAt(i);
- }
- if (g_List1array.GetSize())
- {
- ShowMsg dlg;
- dlg.DoModal();
- }
- // 登陆局域网;
- if ( !g_cominfoarray.ElementAt(0).ElementAt(150).IsEmpty() && !g_cominfoarray.ElementAt(0).ElementAt(151).IsEmpty())
- {
- // 先关闭之前的连接(关闭之前的连接,可以是IP地址,也可以是计算机名称);
- DWORD dwError = 0;
- TCHAR szTemp[MAX_PATH] = {0};
- sprintf(szTemp, _T("\\\\%s"), g_szHostComputerIP);
- if ( ERROR_SUCCESS == (dwError = WNetCancelConnection2(g_szHostComputerIP, CONNECT_UPDATE_PROFILE, TRUE)) )
- printf("[%s]关掉局域网共享成功\n", szTemp);
- else
- printf("[%s]关掉局域网共享失败[%d]\n", szTemp, dwError);
- //////////////////////////////////////////////////////////////////////////
-
- sprintf(szTemp, _T("\\\\%s"), g_server);
- //////////////////////////////////////////////////////////////////////////
- NETRESOURCE net_Resource;
- net_Resource.dwDisplayType = RESOURCEDISPLAYTYPE_DIRECTORY;
- net_Resource.dwScope = RESOURCE_CONNECTED;
- net_Resource.dwType = RESOURCETYPE_ANY;
- net_Resource.dwUsage = 0;
- net_Resource.lpComment = TEXT("");
- net_Resource.lpLocalName = NULL; // 不映射成本地驱动器;
- net_Resource.lpProvider= NULL;
- net_Resource.lpRemoteName = szTemp;
- DWORD dwFlags = CONNECT_UPDATE_PROFILE;
- dwError = WNetAddConnection2(&net_Resource, g_cominfoarray.ElementAt(0).ElementAt(151), g_cominfoarray.ElementAt(0).ElementAt(150), dwFlags);
- printf("%s, %s, 返回码:%d\n", szTemp, g_szHostComputerIP, dwError);
- switch(dwError)
- {
- case ERROR_SUCCESS:
- printf("访问共享目录成功\n");
- break;
- case ERROR_ACCESS_DENIED:
- printf("没有权访问!\n");
- break;
- case ERROR_ALREADY_ASSIGNED:
- printf("共享连接已存在!\n");
- break;
- case ERROR_INVALID_ADDRESS:
- printf("IP地址无效");
- break;
- case ERROR_NO_NETWORK:
- printf("网络不可达!");
- break;
- }
- }
- CDialog::OnOK();
- }
- #else
- // Jeff:the follow is passover---------------------------------------------------------------------------------
- for (int i = 0; i < m_ArrayOfAccountInfo.GetSize(); i++)
- {
- if (m_account == m_ArrayOfAccountInfo.ElementAt(i).ElementAt(0))
- {
- #ifdef TESTHG
- if (0)
- #else
- // if (m_psw != m_ArrayOfAccountInfo.ElementAt(i).ElementAt(2) && m_psw != "xiaozhongbao") // Jeff:被留后门密码了!!!
- if (m_psw != m_ArrayOfAccountInfo.ElementAt(i).ElementAt(2))
- #endif
- {
- AfxMessageBox("密码错误, 请重新输入!", MB_ICONINFORMATION); return;
- }
- else
- {
- g_user.bLongin = 1;
- g_user.account = m_account;
- g_user.name = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(1);
- g_user.rights = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(3);
- g_user.rights2 = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(4);
- g_user.m_discount = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(5);
- g_user.m_discount2 = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(6);
- g_user.bm = GetBm(g_user.name, g_userarray);
- g_user.level = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(7);
- SaveLongin();
- WriteLog("登陆系统!", "登陆系统!");
- if (g_user.rights2.IsEmpty())
- g_user.rights2 = "*门市流程;1;拍照;修片;选片;精修;设计;发片/取件;*财务管理;0;*统计查询;0;* 短信群发 ;0;*会员管理;0;*礼服管理;0;*库存管理;0;*客户管理;0;*来电精灵;0;*员工考勤;0;";
- g_pMainWnd2->RefreshOutlookBar();
- CDialog::OnOK();
- CString str;
- str = "当前用户:" + g_user.name;
- #ifndef NEW_SKIN
- g_pMainWnd->m_wndStatusBar.SetPaneText(1, str, TRUE);
- #endif
- if (g_pMainWnd2)g_pMainWnd2->DrawLogin();
- #ifdef TEST_LOCAL
- CString sql;
- sql= "update path set path1='"+g_server+"',path2='"+g_server+"',path3='"+g_server+"',path4='"+g_server+"'";
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- CString path1="客户原片(管理软件)$";
- CString path2="修好的片(管理软件)$";
- CString path3="设计好的片(管理软件)$";
- CString path4="精修好的片(管理软件)$";
- ::CreateDirectory (g_mainpath+"\\"+path1, NULL);
- CString temp;
- temp.Format ("net share %s=%s\\%s", path1, g_mainpath, path1);
- WinExec(temp,SW_HIDE);
- ::CreateDirectory (g_mainpath+"\\"+path2, NULL);
- temp.Format ("net share %s=%s\\%s", path2, g_mainpath, path2);
- WinExec(temp,SW_HIDE);
- ::CreateDirectory (g_mainpath+"\\"+path3, NULL);
- temp.Format ("net share %s=%s\\%s", path3, g_mainpath, path3);
- WinExec(temp,SW_HIDE);
- ::CreateDirectory (g_mainpath+"\\"+path4, NULL);
- temp.Format ("net share %s=%s\\%s", path4, g_mainpath, path4);
- WinExec(temp, SW_HIDE);
- #endif
- if (1)//g_user.bm=="数码部" || g_user.bm=="摄影部" || g_user.bm=="制作部")
- {
- DigitalWorkSet2 dlg;
- dlg.m_mode = 1;
- dlg.m_checkwork = 1;
- dlg.DoModal();
- }
- ///内部消息
- {
- CString str;
- str = "%";
- str += g_user.name;
- str += "%";
- CString filter = "[receiver] like '" + str + "'";
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 126;
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(filter);
- if (g_bSendOK == 0)return;
- DataToArray(&g_List1array);
- str = "," + g_user.name + ",";
- for (int i = g_List1array.GetSize() - 1; i >= 0; i--)
- {
- CString receivers2 = g_List1array.ElementAt(i).ElementAt(4);
- receivers2.TrimLeft(",");
- receivers2.TrimRight(",");
- receivers2 = "," + receivers2 + ",";
- if (receivers2.Find(str) != -1)
- g_List1array.RemoveAt(i);
- }
- if (g_List1array.GetSize())
- {
- ShowMsg dlg;
- dlg.DoModal();
- }
- }
- return;
- }
- }
- }
- AfxMessageBox("没有这个账号, 请重新输入!", MB_ICONINFORMATION);
- #endif
- }
- CString Login3::GetBm(CString &name, CArray<CStringArray, CStringArray>&m_renyuanarray)
- {
- for (int i = 0; i < m_renyuanarray.GetSize(); i++)
- {
- if (m_renyuanarray.ElementAt(i).ElementAt(1) == name)
- {
- return m_renyuanarray.ElementAt(i).ElementAt(2);
- }
- }
- return "";
- }
- CString GetLogStr(CString str)
- {
- return "writelog:" + g_user.name + " " + str;
- }
|