Login3.cpp 28 KB

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