Login3.cpp 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980
  1. // Login3.cpp: implementation of the Login3 class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "YLGL.h"
  6. #include "Login3.h"
  7. #include "DigitalWorkSet2.h"
  8. #include "ShowMsg.h"
  9. #include "ShowBakState.h"
  10. #include "CharacterConvert.h"
  11. #include "SQLite3Interface.h"
  12. #include "NetShareInfo.h"
  13. #ifdef _DEBUG
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #define new DEBUG_NEW
  17. #endif
  18. //////////////////////////////////////////////////////////////////////
  19. // Construction/Destruction
  20. //////////////////////////////////////////////////////////////////////
  21. //extern void WriteClientLog(CString str); // Jeff写客户端日志;
  22. Login3::Login3()
  23. {
  24. m_psw = _T("");
  25. m_bsave = FALSE;
  26. m_account = _T("");
  27. g_pMainWnd->GetSkin();
  28. }
  29. Login3::~Login3()
  30. {
  31. }
  32. void Login3::OnFSCommand(LPCTSTR command, LPCTSTR args)
  33. {
  34. }
  35. // ***********************************************最严重的漏洞后门*********************************************************************//
  36. // Jeff.
  37. // remark by Jeff. 2014.09.04
  38. // 用户登录的验证信息,不可放在客户里做验证。
  39. // 同时,客户端在未验证自身身份时,禁止读取数据库里的用户表;
  40. // 以下代码,有严重的后门可供侵入。
  41. //
  42. // 新建登录处理过程:
  43. // int LoginVerify(__in const TCHAR *pAccount,__in const int &nAccountLen, __in const TCHAR *pPassWord, __in const int &nPassWordLen);
  44. //
  45. // 同理,在未登录前,客户端不能读写数据库的任何信息,即需要对welcome对话框进行处理.
  46. //
  47. // ***********************************************************************************************************************************//
  48. void Login3::Init()
  49. {
  50. m_combobox.Create(WS_VSCROLL | WS_CHILD | CBS_DROPDOWN, m_rcarray.ElementAt(2), this, 100);
  51. m_combobox.ShowWindow(SW_SHOW);
  52. // m_combobox.SetFocus(); // Add by Jeff //无效;
  53. CRect rc = m_rcarray.ElementAt(2);
  54. rc.bottom += 200;
  55. m_combobox.MoveWindow(rc);
  56. m_combobox.GetWindowRect(rc);
  57. int hei = rc.Height();
  58. rc = m_rcarray.ElementAt(3);
  59. rc.bottom = rc.top + hei + 5;
  60. m_edit.Create(ES_AUTOHSCROLL | WS_CHILD | ES_LEFT | WS_BORDER | ES_PASSWORD | WS_EX_WINDOWEDGE, rc, this, 200);
  61. m_edit.ShowWindow(SW_SHOW);
  62. rc = m_rcarray.ElementAt(4);
  63. rc.bottom = rc.top + 13;
  64. rc.right = rc.left + 13;
  65. m_button.Create("", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_FLAT, rc, this, 300);
  66. tpFont.CreatePointFont(180, _T("黑体"));
  67. m_edit.SetFont(&tpFont);
  68. m_combobox.SetFont(&tpFont);
  69. /////////////////////////
  70. #if JEFF_TEST_ON
  71. g_sendhead.bsql = 0;
  72. g_sendhead.code[0] = 24; // Jeff.version表;版本信息;
  73. g_sendhead.code[1] = 29; // Jeff.path表;路径
  74. g_sendhead.code[2] = 5; // Jeff.renyuan表;人员表;
  75. g_sendhead.code[3] = 1; // Jeff.historydb表;历史数据库;
  76. g_sendhead.code[4] = 171; // Jeff.childmsg表;其实就是"资料与相片备份状态"
  77. if (g_branchname == "")
  78. {
  79. g_sendhead.code[5] = 152; // Jeff.不读任何表,读brachinfo.dat文件里的数据;
  80. g_sendhead.tabcount = 6;
  81. }
  82. else
  83. g_sendhead.tabcount = 5;
  84. int g_nYearposTemp = g_nYearpos;
  85. g_nYearpos = -1;
  86. g_pMainWnd->ProcessChatMessageRequest2(";;;;;");
  87. g_nYearpos = g_nYearposTemp;
  88. if (g_bSendOK == 0)
  89. {
  90. CDialog::OnCancel();
  91. return;
  92. }
  93. CArray<CStringArray, CStringArray>patharray;
  94. CArray<CStringArray, CStringArray>userarray;
  95. if (g_branchname == "")
  96. DataToArray( &g_cominfoarray, &patharray, &userarray, &g_hisyeararray, &g_bakstatearray, &g_brancharray);
  97. else
  98. DataToArray( &g_cominfoarray, &patharray, &userarray, &g_hisyeararray, &g_bakstatearray);
  99. #else
  100. g_sendhead.bsql = 0;
  101. g_sendhead.code[0] = 23; // Jeff.accountview视图;用户
  102. g_sendhead.code[1] = 24; // Jeff.version表;版本信息;
  103. g_sendhead.code[2] = 29; // Jeff.path表;路径
  104. g_sendhead.code[3] = 5; // Jeff.renyuan表;人员表;
  105. g_sendhead.code[4] = 1; // Jeff.historydb表;历史数据库;
  106. g_sendhead.code[5] = 171; // Jeff.childmsg表;其实就是"资料与相片备份状态"
  107. if (g_branchname == "")
  108. {
  109. g_sendhead.code[6] = 152; // Jeff.不读任何表,读brachinfo.dat文件里的数据;
  110. g_sendhead.tabcount = 7;
  111. }
  112. else
  113. g_sendhead.tabcount = 6;
  114. int g_nYearposTemp = g_nYearpos;
  115. g_nYearpos = -1;
  116. g_pMainWnd->ProcessChatMessageRequest2("[dimission]<>'离职' or [dimission] is null;;;;;;");
  117. g_nYearpos = g_nYearposTemp;
  118. if (g_bSendOK == 0)
  119. {
  120. CDialog::OnCancel();
  121. return;
  122. }
  123. CArray<CStringArray, CStringArray>patharray;
  124. CArray<CStringArray, CStringArray>userarray;
  125. if (g_branchname == "")
  126. DataToArray(&m_ArrayOfAccountInfo, &g_cominfoarray, &patharray, &userarray, &g_hisyeararray, &g_bakstatearray, &g_brancharray);
  127. else
  128. DataToArray(&m_ArrayOfAccountInfo, &g_cominfoarray, &patharray, &userarray, &g_hisyeararray, &g_bakstatearray);
  129. #endif
  130. // 149 = [version].[original] 是否使用相片原名导入;
  131. g_bOriginal = atoi(g_cominfoarray.ElementAt(0).ElementAt(149));
  132. if (g_branchname == "")
  133. {
  134. g_cominfoarraylocal.SetSize(1, 1);
  135. g_cominfoarraylocal.ElementAt(0).Copy(g_cominfoarray.ElementAt(0));
  136. }
  137. CheckBakState(); // Jeff.启用客户端时,先检测"资料与照片备份状态"
  138. if (g_branchname == "")
  139. {
  140. g_domain = patharray.ElementAt(0).ElementAt(0);
  141. if (g_domain.Find(".ly.com") == -1)g_domain.Empty();
  142. g_bSaveUploadTask1 = atoi(g_cominfoarray.ElementAt(0).ElementAt(67));
  143. g_bSaveUploadTask2 = atoi(g_cominfoarray.ElementAt(0).ElementAt(68));
  144. g_bSaveUploadTask3 = atoi(g_cominfoarray.ElementAt(0).ElementAt(69));
  145. g_bSaveUploadTask4 = atoi(g_cominfoarray.ElementAt(0).ElementAt(70));
  146. }
  147. CString version = _T("Version 1.0");
  148. BOOL bHide = atoi(g_cominfoarray.ElementAt(0).ElementAt(58));
  149. AfxGetApp()->WriteProfileInt(version, "hidewindow2", bHide);
  150. g_userarray.SetSize(userarray.GetSize(), 1);
  151. int count = 0;
  152. for (int ii = 0; ii < userarray.GetSize(); ii++)
  153. {
  154. if (userarray.ElementAt(ii).ElementAt(10) == "在职")
  155. g_userarray.ElementAt(count++).Copy(userarray.ElementAt(ii));
  156. }
  157. g_userarray.SetSize(count, 1);
  158. #ifdef TESTHG
  159. if (0)
  160. #else
  161. // 设置版本;
  162. CString strVersion;
  163. strVersion.Format("%02d%02d", g_arrFileVersion[2], g_arrFileVersion[3]);
  164. if (g_cominfoarray.ElementAt(0).ElementAt(0) != strVersion)
  165. #endif
  166. {
  167. AfxMessageBox("您必须更新软件才能继续使用, 请与系统管理员联系!", MB_ICONINFORMATION);
  168. CDialog::OnCancel();
  169. g_pMainWnd->AutoUpdate();
  170. return;
  171. }
  172. #ifndef ENTERPRISE_VERSION
  173. {
  174. #ifndef CHILD_VERSION
  175. #ifdef BASIC_VERSION
  176. if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="0")
  177. {
  178. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  179. exit(0);return;
  180. }
  181. #else
  182. if(g_cominfoarray.ElementAt(0).ElementAt(46)!="1")
  183. {
  184. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  185. exit(0);return;
  186. }
  187. #endif
  188. #else
  189. #ifdef BASIC_VERSION
  190. if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="2")
  191. {
  192. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  193. exit(0);return;
  194. }
  195. #else
  196. if(g_cominfoarray.ElementAt(0).ElementAt(46)!="3")
  197. {
  198. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  199. exit(0);return;
  200. }
  201. #endif
  202. #endif
  203. }
  204. #else
  205. {
  206. #ifndef CHILD_VERSION
  207. #ifdef BASIC_VERSION
  208. if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="4")
  209. {
  210. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  211. exit(0);return ;
  212. }
  213. #else
  214. if(g_cominfoarray.ElementAt(0).ElementAt(46)!="5")
  215. {
  216. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  217. exit(0);return ;
  218. }
  219. #endif
  220. #else
  221. #ifdef BASIC_VERSION
  222. if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="6")
  223. {
  224. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  225. exit(0);return ;
  226. }
  227. #else
  228. if (g_cominfoarray.ElementAt(0).ElementAt(46) != "7")
  229. {
  230. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  231. exit(0); return;
  232. }
  233. #endif
  234. #endif
  235. }
  236. #endif
  237. g_title = g_cominfoarray.ElementAt(0).ElementAt(10);
  238. WriteTitle(g_cominfoarray.ElementAt(0).ElementAt(10));
  239. g_date = g_cominfoarray.ElementAt(0).ElementAt(1);
  240. if (g_hisyeararray.GetSize())
  241. {
  242. g_pMainWnd->AddHistoryMenu(&g_hisyeararray);
  243. }
  244. if (g_brancharray.GetSize() && g_branchname == "")
  245. {
  246. // WriteClientLog("启动集团版菜单");
  247. g_pMainWnd->AddBranchMenu(&g_brancharray); // 添加操作分店菜单;
  248. }
  249. if (g_branchname == "")
  250. {
  251. #if USE_SHARE_FLORD
  252. // 清空数组,并重新获取NetShareInfo表;
  253. g_aryOfSharePathInfo.RemoveAll();
  254. g_pMainWnd->GetSharePathInfo();
  255. if( CNetShareInfo::GetInstance() )
  256. {
  257. CNetShareInfo::GetInstance()->Initialize(g_domain, g_serverbak, &g_aryOfSharePathInfo);
  258. }
  259. #endif
  260. #ifdef USE_KERNEL_DLL
  261. if (g_pIMGProcess)
  262. g_pIMGProcess->SetEnvInfoEx(g_server, g_domain, &g_cominfoarray, &g_brancharray, &g_aryOfSharePathInfo);
  263. //////////////////////////////////////////////////////////////////////////
  264. // 2015.11.03 设置回访本店的保留信息;
  265. INT nCount = g_cominfoarray.GetSize();
  266. for ( INT i = 0; i < nCount; i++ )
  267. {
  268. sprintf(g_ThisShopVersion.szVersion, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(0));
  269. sprintf(g_ThisShopVersion.szbakServer1, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(20));
  270. sprintf(g_ThisShopVersion.szbakServer2, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(21));
  271. sprintf(g_ThisShopVersion.szbakServer3, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(22));
  272. sprintf(g_ThisShopVersion.szbakServer4, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(23));
  273. sprintf(g_ThisShopVersion.szbakServer5, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(24));
  274. g_ThisShopVersion.bUpLoadCheck1 = _ttoi(g_cominfoarray.ElementAt(0).ElementAt(67));
  275. g_ThisShopVersion.bUpLoadCheck2 = _ttoi(g_cominfoarray.ElementAt(0).ElementAt(68));
  276. g_ThisShopVersion.bUpLoadCheck3 = _ttoi(g_cominfoarray.ElementAt(0).ElementAt(69));
  277. g_ThisShopVersion.bUpLoadCheck4 = _ttoi(g_cominfoarray.ElementAt(0).ElementAt(70));
  278. g_ThisShopVersion.strZiptype1 = g_cominfoarray.ElementAt(0).ElementAt(78);
  279. g_ThisShopVersion.strZiptype2 = g_cominfoarray.ElementAt(0).ElementAt(79);
  280. g_ThisShopVersion.strZiptype3 = g_cominfoarray.ElementAt(0).ElementAt(80);
  281. g_ThisShopVersion.strZiptype4 = g_cominfoarray.ElementAt(0).ElementAt(81);
  282. g_ThisShopVersion.strUploadRule = g_cominfoarray.ElementAt(0).ElementAt(116);
  283. }
  284. //////////////////////////////////////////////////////////////////////////
  285. #endif
  286. CString szFolderName[] =
  287. {
  288. _T("\\客户原片(管理软件)$"),
  289. _T("\\修好的片(管理软件)$"),
  290. _T("\\设计好的片(管理软件)$"),
  291. _T("\\精修好的片(管理软件)$"),
  292. _T("\\礼服图片(管理软件)$"),
  293. _T("\\电话录音(管理软件)$"),
  294. _T("\\客户原片(管理软件)$\\效果图")
  295. };
  296. CString strHead = _T("");
  297. CString strServerName = _T("");
  298. if (g_server == "127.0.0.1")
  299. {
  300. g_sendhead.bsql = 0;
  301. g_sendhead.code[0] = 63;
  302. g_sendhead.tabcount = 1;
  303. g_pMainWnd->ProcessChatMessageRequest2(1);
  304. if (g_bSendOK == 0)
  305. {
  306. CDialog::OnCancel();
  307. return;
  308. }
  309. DataToArray(&g_List1array);
  310. strHead = _T("");
  311. strServerName = g_List1array.ElementAt(0).ElementAt(0);
  312. }
  313. else if (patharray.GetSize())
  314. {
  315. strHead = _T("\\\\");
  316. strServerName = g_serverbak;
  317. }
  318. g_path1bak = g_path1 = strHead + strServerName + szFolderName[0];
  319. g_path2bak = g_path2 = strHead + strServerName + szFolderName[1];
  320. g_path3bak = g_path3 = strHead + strServerName + szFolderName[2];
  321. g_path4bak = g_path4 = strHead + strServerName + szFolderName[3];
  322. g_path5bak = g_path5 = strHead + strServerName + szFolderName[4];
  323. g_path6bak = g_path6 = strHead + strServerName + szFolderName[5];
  324. g_path7bak = g_path7 = strHead + strServerName + szFolderName[6];
  325. }
  326. try
  327. {
  328. CFile fp;
  329. if (fp.Open(g_mainpath + "\\loginuser.dat", CFile::modeRead))
  330. {
  331. DWORD length = fp.GetLength();
  332. if (!length)
  333. return;
  334. CArchive ar(&fp, CArchive::load);
  335. m_userarray.Serialize(ar);
  336. fp.Close();
  337. for (int i = 0; i < m_userarray.GetSize(); i++)
  338. {
  339. m_combobox.AddString(m_userarray.ElementAt(i));
  340. }
  341. if (m_combobox.GetCount()>0)
  342. {
  343. m_combobox.SetCurSel(0);
  344. m_combobox.GetLBText(0, m_account);
  345. }
  346. if (!m_account.IsEmpty())
  347. {
  348. CString version = _T("Version 1.0");
  349. m_psw = AfxGetApp()->GetProfileString(version, _T(m_account));
  350. if (!m_psw.IsEmpty())
  351. m_bsave = TRUE;
  352. }
  353. SetDlgItemText(200, m_psw);
  354. m_button.SetCheck(m_bsave);
  355. }
  356. }
  357. catch (...)
  358. {
  359. }
  360. }
  361. /************************************************************************/
  362. /*
  363. 函数: IsFolderExist
  364. 描述: 判断共享目录是否存在
  365. 参数:
  366. const CString& strDomain 域名
  367. std::vector<CString*>& vPath 共享目录集
  368. 返回: TRUE成功,FALSE失败
  369. */
  370. /************************************************************************/
  371. BOOL Login3::IsShareFolderExist(CString& strSharePath)
  372. {
  373. if(strSharePath == _T(""))
  374. return FALSE;
  375. char szPath[MAX_PATH] = { 0 };
  376. strcpy(szPath, strSharePath.GetBuffer(strSharePath.GetLength()));
  377. if(IsExistFolder(szPath) == -1)
  378. return FALSE;
  379. return TRUE;
  380. }
  381. /************************************************************************/
  382. /*
  383. 函数: ReadBranchFromDomain
  384. 描述: 从域名读取分店信息
  385. 参数:
  386. CString& strDomain 域名
  387. 返回: 0成功,-1失败
  388. */
  389. /************************************************************************/
  390. int Login3::ReadBranchFromDomain(CString& strDBFile, CString& strDomain, std::vector<std::string>& vInfo)
  391. {
  392. if(strDBFile == _T("") || strDomain == _T(""))
  393. return -1;
  394. CSQLiter3Interface db;
  395. char szPath[MAX_PATH] = { 0 };
  396. strcpy(szPath, strDBFile.GetBuffer(strDBFile.GetLength()));
  397. if(db.OpenSQLite3DB(szPath) == -1)
  398. return -1;
  399. /*
  400. Select()
  401. const char* pTableName 表名
  402. const char* pFields, 一个字段或多个字段如:字段1,字段2,字段3...
  403. const char* pLimit, where 条件如:字段1='xx',字段2='xxx'
  404. vector<string>& vValues 返回结果集
  405. CString& strError 如果失败返回错误消息
  406. */
  407. char szDomain[64] = {0};
  408. strcpy(szDomain, strDomain.GetBuffer(strDomain.GetLength()));
  409. char szLimit[256] = {0};
  410. sprintf(szLimit, "domain='%s'", szDomain);
  411. CString strError = _T("");
  412. int nRet = db.Select("remoteinfo", "*", szLimit, vInfo, strError);
  413. db.Close();
  414. return nRet;
  415. }
  416. void Login3::Destory()
  417. {
  418. }
  419. void Login3::BtnClick(WPARAM wParam, LPARAM lParam)
  420. {
  421. int id = lParam;
  422. id -= 99;
  423. switch (id)
  424. {
  425. case 2:
  426. {
  427. MyOnOK();
  428. }
  429. break;
  430. case 1:
  431. CDialog::OnCancel();
  432. break;
  433. }
  434. }
  435. BOOL Login3::PreTransMsg(MSG* pMsg)
  436. {
  437. #if 0 // Add Jeff:使用tab键切换控件;
  438. if (pMsg->message == WM_KEYDOWN && pMsg->message == VK_TAB)
  439. {
  440. // 当前拥有焦点的控件 == m_combobox控件;
  441. if(GetFocus()->GetSafeHwnd() == m_combobox.GetSafeHwnd())
  442. {
  443. // 使m_edit拥有焦点
  444. m_edit.SetFocus();
  445. return TRUE;
  446. }
  447. else if (GetFocus()->GetSafeHwnd() == m_edit.GetSafeHwnd())
  448. {
  449. m_button->SetFocus();
  450. return TRUE;
  451. }
  452. }
  453. else if (pMsg->message == WM_KEYDOWN)
  454. #else
  455. if (pMsg->message == WM_KEYDOWN)
  456. #endif
  457. {
  458. switch (pMsg->wParam)
  459. {
  460. case VK_RETURN:
  461. MyOnOK();
  462. // 回车键登陆时,必须return,否则对话框在debug模式下会报错(对话框已销毁,不应再执行其他代码);
  463. return 1; // break;
  464. case VK_TAB:
  465. {
  466. #if 0
  467. CWnd *pParent = GetParent();
  468. CWnd *pWnd = GetFocus();
  469. //CString strText;
  470. int nCtrlId = pWnd->GetDlgCtrlID();
  471. //m_combobox.m
  472. // LOG4C((LOG_NOTICE,"VK_TAB:%d,%d,%d"),nCtrlId,m_combobox.GetDlgCtrlID(),pParent->GetDlgCtrlID());
  473. #endif
  474. HWND _hwnd = GetFocus()->GetSafeHwnd();
  475. if (_hwnd != m_combobox.m_hWnd && _hwnd != m_edit.m_hWnd && _hwnd != m_button.m_hWnd)
  476. //if( _hwnd == m_combobox.m_hWnd )
  477. {
  478. //LOG4C((LOG_NOTICE,"使m_edit拥有焦点"));
  479. // 使m_edit拥有焦点
  480. m_edit.SetFocus();
  481. // 使密码框的内容清空或者全靠;
  482. //m_combobox.SetFocus();
  483. return TRUE;
  484. }
  485. // else if ( _hwnd == m_combobox.m_hWnd)
  486. // {
  487. // m_edit.SetFocus();
  488. // return TRUE;
  489. // }
  490. else if (_hwnd == m_edit.m_hWnd/*m_edit.GetSafeHwnd()*/)
  491. {
  492. //LOG4C((LOG_NOTICE,"将焦点返回给commbox"));
  493. m_combobox.SetFocus();
  494. return TRUE;
  495. }
  496. }
  497. break;
  498. }
  499. }
  500. else if (pMsg->message == WM_LBUTTONDOWN)
  501. {
  502. g_bNeedDrawParent = 1;
  503. CPoint pt;
  504. ::GetCursorPos(&pt);
  505. ScreenToClient(&pt);
  506. CRect rc;
  507. m_button.GetWindowRect(rc);
  508. ScreenToClient(rc);
  509. if (rc.PtInRect(pt))return CDialog::PreTranslateMessage(pMsg);
  510. if (m_rcarray.ElementAt(4).PtInRect(pt))
  511. {
  512. m_button.SetCheck(!m_button.GetCheck());
  513. }
  514. }
  515. return CDialog::PreTranslateMessage(pMsg);
  516. }
  517. void Login3::SaveLongin()
  518. {
  519. CString version = _T("Version 1.0");
  520. if (m_bsave)
  521. {
  522. AfxGetApp()->WriteProfileString(version, _T(m_account), m_psw);
  523. }
  524. else
  525. {
  526. AfxGetApp()->WriteProfileString(version, _T(m_account), "");
  527. }
  528. if (m_userarray.GetSize())
  529. {
  530. if (m_userarray.ElementAt(0) != m_account)
  531. {
  532. RemoveExist(m_account);
  533. m_userarray.InsertAt(0, m_account);
  534. if (m_userarray.GetSize() > 30)
  535. m_userarray.SetSize(30);
  536. }
  537. }
  538. else
  539. {
  540. m_userarray.Add(m_account);
  541. }
  542. CFile f;
  543. if (!f.Open(g_mainpath + "\\loginuser.dat", CFile::modeWrite | CFile::modeCreate))return;
  544. CArchive ar(&f, CArchive::store);
  545. m_userarray.Serialize(ar);
  546. ar.Close();
  547. f.Close();
  548. }
  549. void Login3::RemoveExist(CString str)
  550. {
  551. for (int i = 0; i < m_userarray.GetSize(); i++)
  552. {
  553. if (str == m_userarray.ElementAt(i))
  554. {
  555. m_userarray.RemoveAt(i);
  556. return;
  557. }
  558. }
  559. }
  560. void Login3::CheckBakState()
  561. {
  562. while (g_bakstatearray.GetSize()>7)
  563. {
  564. g_bakstatearray.RemoveAt(0);
  565. }
  566. int photocount = 0;
  567. int infocount = 0;
  568. for (int i = 0; i < g_bakstatearray.GetSize(); i++)
  569. {
  570. if (g_bakstatearray.ElementAt(i).ElementAt(1) != "1")photocount++;
  571. if (g_bakstatearray.ElementAt(i).ElementAt(2) != "1")infocount++;
  572. }
  573. int size = g_bakstatearray.GetSize();
  574. if (size == 0)return;
  575. if (g_bakstatearray.ElementAt(size - 1).ElementAt(1) == "1" && g_bakstatearray.ElementAt(size - 1).ElementAt(2) == "1")
  576. return;
  577. if (infocount>1 || photocount > 2)
  578. {
  579. // Jeff."资料与照片备份状态"对话框;
  580. ShowBakState dlg;
  581. dlg.m_pArray = &g_bakstatearray;
  582. dlg.DoModal();
  583. }
  584. }
  585. //-------------------------------------------------------------------
  586. // Remark by Jeff - 2014.10.15
  587. // 用户登陆验证方式,转由服务端验证;
  588. // 1.服务端中的客户端SOCKET需添加一布尔变量标识客户端是否通过验证,若没有则断开与客户端的连接;
  589. // 2.验证通过,返回该账号关联的员工信息;
  590. //
  591. //-------------------------------------------------------------------
  592. void Login3::MyOnOK()
  593. {
  594. m_combobox.GetWindowText(m_account);
  595. GetDlgItemText(200, m_psw);
  596. m_bsave = m_button.GetCheck();
  597. if (m_account.IsEmpty())
  598. {
  599. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  600. return;
  601. }
  602. #if JEFF_TEST_ON
  603. // Jeff:使用新的登陆验证方式!
  604. CString strSQL;
  605. BYTE byPsw[50] = {0};
  606. #ifndef UNICODE
  607. memcpy(byPsw, (LPCSTR)m_psw, m_psw.GetLength());
  608. #endif
  609. CMD5 md5;
  610. md5.SetBYTEText(byPsw, strlen((char*)byPsw));
  611. strSQL.Format("account='%s' and psw='%s'", m_account, md5.GetMD5Digest());
  612. g_sendhead.bsql = 0;
  613. g_sendhead.code[0] = 23;
  614. g_sendhead.tabcount = 1;
  615. g_pMainWnd->ProcessChatMessageRequest2(strSQL);
  616. if (!g_bSendOK)
  617. {
  618. MessageBox(_T("提示"),_T("连接服务器失败"),MB_OK | MB_TOPMOST);
  619. }
  620. m_ArrayOfAccountInfo.RemoveAll();
  621. DataToArray(&m_ArrayOfAccountInfo);
  622. if (m_ArrayOfAccountInfo.GetSize() == 0)
  623. {
  624. AfxMessageBox("账号或密码错误");
  625. return;
  626. }
  627. else
  628. {
  629. g_user.bLongin = 1;
  630. g_user.account = m_account;
  631. g_user.name = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(1);
  632. g_user.rights = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(3);
  633. g_user.rights2 = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(4);
  634. g_user.m_discount = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(5);
  635. g_user.m_discount2 = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(6);
  636. g_user.bm = GetBm(g_user.name, g_userarray);
  637. g_user.level = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(7);
  638. SaveLongin();
  639. WriteLog("登陆系统!", "登陆系统!");
  640. if (g_user.rights2.IsEmpty())
  641. g_user.rights2 = "*门市流程;1;拍照;修片;选片;精修;设计;发片/取件;*财务管理;0;*统计查询;0;* 短信群发 ;0;*会员管理;0;*礼服管理;0;*库存管理;0;*客户管理;0;*来电精灵;0;*员工考勤;0;";
  642. g_pMainWnd2->RefreshOutlookBar();
  643. CString str;
  644. str = "当前用户:" + g_user.name;
  645. #ifndef NEW_SKIN
  646. g_pMainWnd->m_wndStatusBar.SetPaneText(1, str, TRUE);
  647. #endif
  648. if (g_pMainWnd2)g_pMainWnd2->DrawLogin();
  649. #ifdef TEST_LOCAL
  650. CString sql;
  651. sql = "update path set path1='" + g_server + "',path2='" + g_server + "',path3='" + g_server + "',path4='" + g_server + "'";
  652. g_sendhead.bsql = 1;
  653. g_pMainWnd->ProcessChatMessageRequest2(sql);
  654. CString path1 = "客户原片(管理软件)$";
  655. CString path2 = "修好的片(管理软件)$";
  656. CString path3 = "设计好的片(管理软件)$";
  657. CString path4 = "精修好的片(管理软件)$";
  658. ::CreateDirectory(g_mainpath + "\\" + path1, NULL);
  659. CString temp;
  660. temp.Format("net share %s=%s\\%s", path1, g_mainpath, path1);
  661. WinExec(temp, SW_HIDE);
  662. ::CreateDirectory(g_mainpath + "\\" + path2, NULL);
  663. temp.Format("net share %s=%s\\%s", path2, g_mainpath, path2);
  664. WinExec(temp, SW_HIDE);
  665. ::CreateDirectory(g_mainpath + "\\" + path3, NULL);
  666. temp.Format("net share %s=%s\\%s", path3, g_mainpath, path3);
  667. WinExec(temp, SW_HIDE);
  668. ::CreateDirectory(g_mainpath + "\\" + path4, NULL);
  669. temp.Format("net share %s=%s\\%s", path4, g_mainpath, path4);
  670. WinExec(temp, SW_HIDE);
  671. #endif
  672. if (1)//g_user.bm=="数码部" || g_user.bm=="摄影部" || g_user.bm=="制作部")
  673. {
  674. DigitalWorkSet2 dlg;
  675. dlg.m_mode = 1;
  676. dlg.m_checkwork = 1;
  677. dlg.DoModal();
  678. }
  679. ///内部消息
  680. str = "%";
  681. str += g_user.name;
  682. str += "%";
  683. CString filter = "[receiver] like '" + str + "'";
  684. g_sendhead.bsql = 0;
  685. g_sendhead.code[0] = 126;
  686. g_sendhead.tabcount = 1;
  687. g_pMainWnd->ProcessChatMessageRequest2(filter);
  688. if (g_bSendOK == 0)return;
  689. DataToArray(&g_List1array);
  690. str = "," + g_user.name + ",";
  691. for (int i = g_List1array.GetSize() - 1; i >= 0; i--)
  692. {
  693. CString receivers2 = g_List1array.ElementAt(i).ElementAt(4);
  694. receivers2.TrimLeft(",");
  695. receivers2.TrimRight(",");
  696. receivers2 = "," + receivers2 + ",";
  697. if (receivers2.Find(str) != -1)
  698. g_List1array.RemoveAt(i);
  699. }
  700. if (g_List1array.GetSize())
  701. {
  702. ShowMsg dlg;
  703. dlg.DoModal();
  704. }
  705. // 登陆局域网;
  706. if ( !g_cominfoarray.ElementAt(0).ElementAt(150).IsEmpty() && !g_cominfoarray.ElementAt(0).ElementAt(151).IsEmpty())
  707. {
  708. // 先关闭之前的连接(关闭之前的连接,可以是IP地址,也可以是计算机名称);
  709. DWORD dwError = 0;
  710. TCHAR szTemp[MAX_PATH] = {0};
  711. sprintf(szTemp, _T("\\\\%s"), g_szHostComputerIP);
  712. if ( ERROR_SUCCESS == (dwError = WNetCancelConnection2(g_szHostComputerIP, CONNECT_UPDATE_PROFILE, TRUE)) )
  713. printf("[%s]关掉局域网共享成功\n", szTemp);
  714. else
  715. printf("[%s]关掉局域网共享失败[%d]\n", szTemp, dwError);
  716. //////////////////////////////////////////////////////////////////////////
  717. sprintf(szTemp, _T("\\\\%s"), g_server);
  718. //////////////////////////////////////////////////////////////////////////
  719. NETRESOURCE net_Resource;
  720. net_Resource.dwDisplayType = RESOURCEDISPLAYTYPE_DIRECTORY;
  721. net_Resource.dwScope = RESOURCE_CONNECTED;
  722. net_Resource.dwType = RESOURCETYPE_ANY;
  723. net_Resource.dwUsage = 0;
  724. net_Resource.lpComment = TEXT("");
  725. net_Resource.lpLocalName = NULL; // 不映射成本地驱动器;
  726. net_Resource.lpProvider= NULL;
  727. net_Resource.lpRemoteName = szTemp;
  728. DWORD dwFlags = CONNECT_UPDATE_PROFILE;
  729. dwError = WNetAddConnection2(&net_Resource, g_cominfoarray.ElementAt(0).ElementAt(151), g_cominfoarray.ElementAt(0).ElementAt(150), dwFlags);
  730. printf("%s, %s, 返回码:%d\n", szTemp, g_szHostComputerIP, dwError);
  731. switch(dwError)
  732. {
  733. case ERROR_SUCCESS:
  734. printf("访问共享目录成功\n");
  735. break;
  736. case ERROR_ACCESS_DENIED:
  737. printf("没有权访问!\n");
  738. break;
  739. case ERROR_ALREADY_ASSIGNED:
  740. printf("共享连接已存在!\n");
  741. break;
  742. case ERROR_INVALID_ADDRESS:
  743. printf("IP地址无效");
  744. break;
  745. case ERROR_NO_NETWORK:
  746. printf("网络不可达!");
  747. break;
  748. }
  749. }
  750. CDialog::OnOK();
  751. }
  752. #else
  753. // Jeff:the follow is passover---------------------------------------------------------------------------------
  754. for (int i = 0; i < m_ArrayOfAccountInfo.GetSize(); i++)
  755. {
  756. if (m_account == m_ArrayOfAccountInfo.ElementAt(i).ElementAt(0))
  757. {
  758. #ifdef TESTHG
  759. if (0)
  760. #else
  761. // if (m_psw != m_ArrayOfAccountInfo.ElementAt(i).ElementAt(2) && m_psw != "xiaozhongbao") // Jeff:被留后门密码了!!!
  762. if (m_psw != m_ArrayOfAccountInfo.ElementAt(i).ElementAt(2))
  763. #endif
  764. {
  765. AfxMessageBox("密码错误, 请重新输入!", MB_ICONINFORMATION); return;
  766. }
  767. else
  768. {
  769. g_user.bLongin = 1;
  770. g_user.account = m_account;
  771. g_user.name = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(1);
  772. g_user.rights = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(3);
  773. g_user.rights2 = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(4);
  774. g_user.m_discount = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(5);
  775. g_user.m_discount2 = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(6);
  776. g_user.bm = GetBm(g_user.name, g_userarray);
  777. g_user.level = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(7);
  778. SaveLongin();
  779. WriteLog("登陆系统!", "登陆系统!");
  780. if (g_user.rights2.IsEmpty())
  781. g_user.rights2 = "*门市流程;1;拍照;修片;选片;精修;设计;发片/取件;*财务管理;0;*统计查询;0;* 短信群发 ;0;*会员管理;0;*礼服管理;0;*库存管理;0;*客户管理;0;*来电精灵;0;*员工考勤;0;";
  782. g_pMainWnd2->RefreshOutlookBar();
  783. CDialog::OnOK();
  784. CString str;
  785. str = "当前用户:" + g_user.name;
  786. #ifndef NEW_SKIN
  787. g_pMainWnd->m_wndStatusBar.SetPaneText(1, str, TRUE);
  788. #endif
  789. if (g_pMainWnd2)g_pMainWnd2->DrawLogin();
  790. #ifdef TEST_LOCAL
  791. CString sql;
  792. sql= "update path set path1='"+g_server+"',path2='"+g_server+"',path3='"+g_server+"',path4='"+g_server+"'";
  793. g_sendhead.bsql=1;
  794. g_pMainWnd->ProcessChatMessageRequest2(sql);
  795. CString path1="客户原片(管理软件)$";
  796. CString path2="修好的片(管理软件)$";
  797. CString path3="设计好的片(管理软件)$";
  798. CString path4="精修好的片(管理软件)$";
  799. ::CreateDirectory (g_mainpath+"\\"+path1, NULL);
  800. CString temp;
  801. temp.Format ("net share %s=%s\\%s", path1, g_mainpath, path1);
  802. WinExec(temp,SW_HIDE);
  803. ::CreateDirectory (g_mainpath+"\\"+path2, NULL);
  804. temp.Format ("net share %s=%s\\%s", path2, g_mainpath, path2);
  805. WinExec(temp,SW_HIDE);
  806. ::CreateDirectory (g_mainpath+"\\"+path3, NULL);
  807. temp.Format ("net share %s=%s\\%s", path3, g_mainpath, path3);
  808. WinExec(temp,SW_HIDE);
  809. ::CreateDirectory (g_mainpath+"\\"+path4, NULL);
  810. temp.Format ("net share %s=%s\\%s", path4, g_mainpath, path4);
  811. WinExec(temp, SW_HIDE);
  812. #endif
  813. if (1)//g_user.bm=="数码部" || g_user.bm=="摄影部" || g_user.bm=="制作部")
  814. {
  815. DigitalWorkSet2 dlg;
  816. dlg.m_mode = 1;
  817. dlg.m_checkwork = 1;
  818. dlg.DoModal();
  819. }
  820. ///内部消息
  821. {
  822. CString str;
  823. str = "%";
  824. str += g_user.name;
  825. str += "%";
  826. CString filter = "[receiver] like '" + str + "'";
  827. g_sendhead.bsql = 0;
  828. g_sendhead.code[0] = 126;
  829. g_sendhead.tabcount = 1;
  830. g_pMainWnd->ProcessChatMessageRequest2(filter);
  831. if (g_bSendOK == 0)return;
  832. DataToArray(&g_List1array);
  833. str = "," + g_user.name + ",";
  834. for (int i = g_List1array.GetSize() - 1; i >= 0; i--)
  835. {
  836. CString receivers2 = g_List1array.ElementAt(i).ElementAt(4);
  837. receivers2.TrimLeft(",");
  838. receivers2.TrimRight(",");
  839. receivers2 = "," + receivers2 + ",";
  840. if (receivers2.Find(str) != -1)
  841. g_List1array.RemoveAt(i);
  842. }
  843. if (g_List1array.GetSize())
  844. {
  845. ShowMsg dlg;
  846. dlg.DoModal();
  847. }
  848. }
  849. return;
  850. }
  851. }
  852. }
  853. AfxMessageBox("没有这个账号, 请重新输入!", MB_ICONINFORMATION);
  854. #endif
  855. }
  856. CString Login3::GetBm(CString &name, CArray<CStringArray, CStringArray>&m_renyuanarray)
  857. {
  858. for (int i = 0; i < m_renyuanarray.GetSize(); i++)
  859. {
  860. if (m_renyuanarray.ElementAt(i).ElementAt(1) == name)
  861. {
  862. return m_renyuanarray.ElementAt(i).ElementAt(2);
  863. }
  864. }
  865. return "";
  866. }
  867. CString GetLogStr(CString str)
  868. {
  869. return "writelog:" + g_user.name + " " + str;
  870. }