Login3.cpp 28 KB

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