Login.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. // Login.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "Login.h"
  6. #include "JPEG.h"
  7. #include "DigitalWorkSet2.h"
  8. #include "ShowMsg.h"
  9. #include "ShowBakState.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. //#define TESTHG
  16. //#define CCIV_SKIN 1
  17. //创建快捷方式
  18. BOOL CreateLink (
  19. LPSTR szPath,//快捷方式的目标应用程序名
  20. LPSTR szLink,
  21. LPSTR szIcon)//快捷方式的数据文件名(*.lnk)
  22. {
  23. HRESULT hres ;
  24. IShellLink * psl ;
  25. IPersistFile* ppf ;
  26. #ifdef VC90
  27. wchar_t wsz[ MAX_PATH] ;
  28. #else
  29. WORD wsz[ MAX_PATH] ;
  30. #endif
  31. //创建一个IShellLink实例
  32. hres = CoCreateInstance( CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
  33. if( FAILED( hres))
  34. return FALSE ;
  35. //设置目标应用程序
  36. psl -> SetPath( szPath) ;
  37. psl -> SetIconLocation( szIcon , 0) ;
  38. //设置快捷键(此处设为Shift+Ctrl+'R')
  39. // psl -> SetHotkey( MAKEWORD( 'R',
  40. // HOTKEYF_SHIFT |HOTKEYF_CONTROL)) ;
  41. //从IShellLink获取其IPersistFile接口
  42. //用于保存快捷方式的数据文件 (*.lnk)
  43. hres = psl -> QueryInterface( IID_IPersistFile,
  44. (void**)&ppf) ;
  45. if( FAILED( hres)) return FALSE ;
  46. // 确保数据文件名为ANSI格式
  47. MultiByteToWideChar( CP_ACP, 0, szLink, -1,
  48. wsz, MAX_PATH) ;
  49. //调用IPersist:Save
  50. //保存快捷方式的数据文件 (*.lnk)
  51. hres = ppf -> Save( wsz, STGM_READWRITE) ;
  52. //释放IPersistFile和IShellLink接口
  53. ppf -> Release( ) ;
  54. psl -> Release( ) ;
  55. return TRUE;
  56. }
  57. /////////////////////////////////////////////////////////////////////////////
  58. // Login dialog
  59. Login::Login(CWnd* pParent /*=NULL*/)
  60. : CDialog(Login::IDD, pParent)
  61. {
  62. //{{AFX_DATA_INIT(Login)
  63. m_psw = _T("");
  64. m_bsave = FALSE;
  65. m_account = _T("");
  66. //}}AFX_DATA_INIT
  67. }
  68. void Login::DoDataExchange(CDataExchange* pDX)
  69. {
  70. CDialog::DoDataExchange(pDX);
  71. //{{AFX_DATA_MAP(Login)
  72. DDX_Control(pDX, IDC_COMBOaccount, m_comboaccount);
  73. DDX_Text(pDX, IDC_EDITpsw, m_psw);
  74. DDX_Check(pDX, IDC_CHECK1, m_bsave);
  75. DDX_CBString(pDX, IDC_COMBOaccount, m_account);
  76. //}}AFX_DATA_MAP
  77. }
  78. BEGIN_MESSAGE_MAP(Login, CDialog)
  79. //{{AFX_MSG_MAP(Login)
  80. ON_WM_PAINT()
  81. //}}AFX_MSG_MAP
  82. END_MESSAGE_MAP()
  83. /////////////////////////////////////////////////////////////////////////////
  84. // Login message handlers
  85. BOOL Login::OnInitDialog()
  86. {
  87. CDialog::OnInitDialog();
  88. // TODO: Add extra initialization here
  89. g_sendhead.bsql=0;
  90. g_sendhead.code[0]=23;
  91. g_sendhead.code[1]=24;
  92. g_sendhead.code[2]=29;
  93. g_sendhead.code[3]=5;
  94. g_sendhead.code[4]=1;
  95. g_sendhead.code[5]=171;
  96. if(g_branchname=="")
  97. {
  98. g_sendhead.code[6]=152;
  99. g_sendhead.tabcount=7;
  100. }
  101. else
  102. g_sendhead.tabcount=6;
  103. int g_nYearposTemp=g_nYearpos;
  104. g_nYearpos=-1;
  105. g_pMainWnd->ProcessChatMessageRequest2("[dimission]<>'离职' or [dimission] is null;;;;;;");
  106. g_nYearpos=g_nYearposTemp;
  107. if(g_bSendOK==0)
  108. {
  109. CDialog::OnCancel();
  110. return 1;
  111. }
  112. CArray<CStringArray, CStringArray>patharray;
  113. CArray<CStringArray, CStringArray>userarray;
  114. if(g_branchname=="")
  115. DataToArray(&m_List1array,&g_cominfoarray,&patharray,&userarray,&g_hisyeararray,&g_bakstatearray,&g_brancharray);
  116. else
  117. DataToArray(&m_List1array,&g_cominfoarray,&patharray,&userarray,&g_hisyeararray,&g_bakstatearray);
  118. if(g_branchname=="")
  119. {
  120. g_cominfoarraylocal.SetSize(1, 1);
  121. g_cominfoarraylocal.ElementAt(0).Copy(g_cominfoarray.ElementAt(0));
  122. }
  123. CheckBakState();
  124. if(g_branchname=="")
  125. {
  126. g_domain=patharray.ElementAt(0).ElementAt(0);
  127. if(g_domain.Find (".ly.com")==-1)g_domain.Empty ();
  128. g_bSaveUploadTask1=atoi(g_cominfoarray.ElementAt(0).ElementAt(67));
  129. g_bSaveUploadTask2=atoi(g_cominfoarray.ElementAt(0).ElementAt(68));
  130. g_bSaveUploadTask3=atoi(g_cominfoarray.ElementAt(0).ElementAt(69));
  131. g_bSaveUploadTask4=atoi(g_cominfoarray.ElementAt(0).ElementAt(70));
  132. }
  133. CString version = _T ("Version 1.0");
  134. BOOL bHide=atoi(g_cominfoarray.ElementAt(0).ElementAt(58));
  135. AfxGetApp()->WriteProfileInt (version, "hidewindow2", bHide);
  136. g_userarray.SetSize( userarray.GetSize (), 1 );
  137. int count=0;
  138. for(int ii=0; ii<userarray.GetSize (); ii++)
  139. {
  140. if(userarray.ElementAt (ii).ElementAt (10)=="在职")
  141. g_userarray.ElementAt (count++).Copy (userarray.ElementAt (ii));
  142. }
  143. g_userarray.SetSize( count, 1 );
  144. CString strVersion;
  145. strVersion.Format("%d%d", g_arrFileVersion[2], g_arrFileVersion[3]);
  146. if (g_cominfoarray.ElementAt(0).ElementAt(0) != strVersion)
  147. {
  148. AfxMessageBox("您必须更新软件才能继续使用, 请与系统管理员联系!", MB_ICONINFORMATION);
  149. CDialog::OnCancel();
  150. g_pMainWnd->AutoUpdate();
  151. return false;
  152. }
  153. #ifndef ENTERPRISE_VERSION
  154. {
  155. #ifndef CHILD_VERSION
  156. #ifdef BASIC_VERSION
  157. if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="0")
  158. {
  159. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  160. exit(0);return false;
  161. }
  162. #else
  163. if(g_cominfoarray.ElementAt(0).ElementAt(46)!="1")
  164. {
  165. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  166. exit(0);return false;
  167. }
  168. #endif
  169. #else
  170. #ifdef BASIC_VERSION
  171. if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="2")
  172. {
  173. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  174. exit(0);return false;
  175. }
  176. #else
  177. if(g_cominfoarray.ElementAt(0).ElementAt(46)!="3")
  178. {
  179. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  180. exit(0);return false;
  181. }
  182. #endif
  183. #endif
  184. }
  185. #else
  186. {
  187. #ifndef CHILD_VERSION
  188. #ifdef BASIC_VERSION
  189. if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="4")
  190. {
  191. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  192. exit(0);return false;
  193. }
  194. #else
  195. if(g_cominfoarray.ElementAt(0).ElementAt(46)!="5")
  196. {
  197. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  198. exit(0);return false;
  199. }
  200. #endif
  201. #else
  202. #ifdef BASIC_VERSION
  203. if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="6")
  204. {
  205. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  206. exit(0);return false;
  207. }
  208. #else
  209. if(g_cominfoarray.ElementAt(0).ElementAt(46)!="7")
  210. {
  211. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  212. exit(0);return false;
  213. }
  214. #endif
  215. #endif
  216. }
  217. #endif
  218. g_title=g_cominfoarray.ElementAt (0).ElementAt (10);
  219. WriteTitle(g_cominfoarray.ElementAt (0).ElementAt (10));
  220. g_date=g_cominfoarray.ElementAt(0).ElementAt(1);
  221. if(g_hisyeararray.GetSize())
  222. {
  223. g_pMainWnd->AddHistoryMenu(&g_hisyeararray);
  224. }
  225. if(g_brancharray.GetSize() && g_branchname=="")
  226. {
  227. g_pMainWnd->AddBranchMenu(&g_brancharray);
  228. }
  229. if(g_branchname=="")
  230. {
  231. if(g_server=="127.0.0.1")
  232. {
  233. g_sendhead.bsql=0;
  234. g_sendhead.code[0]=63;
  235. g_sendhead.tabcount=1;
  236. g_pMainWnd->ProcessChatMessageRequest2(1);
  237. if(g_bSendOK==0)
  238. {
  239. CDialog::OnCancel();
  240. return 1;
  241. }
  242. DataToArray(&g_List1array);
  243. g_path1=g_List1array.ElementAt(0).ElementAt(0)+"\\客户原片(管理软件)$";
  244. g_path2=g_List1array.ElementAt(0).ElementAt(0)+"\\修好的片(管理软件)$";
  245. g_path3=g_List1array.ElementAt(0).ElementAt(0)+"\\设计好的片(管理软件)$";
  246. g_path4=g_List1array.ElementAt(0).ElementAt(0)+"\\精修好的片(管理软件)$";
  247. g_path5=g_List1array.ElementAt(0).ElementAt(0)+"\\礼服图片(管理软件)$";
  248. g_path6=g_List1array.ElementAt(0).ElementAt(0)+"\\电话录音(管理软件)$";
  249. g_path7=g_path1+"\\效果图";
  250. }
  251. else if(patharray.GetSize())
  252. {
  253. // g_serverbak="PC-110817-VYCJ";
  254. g_path1=g_path2=g_path3=g_path4=g_path5=g_path6=g_path7=g_serverbak;
  255. g_path1="\\\\"+g_path1+"\\客户原片(管理软件)$";
  256. g_path2="\\\\"+g_path2+"\\修好的片(管理软件)$";
  257. g_path3="\\\\"+g_path3+"\\设计好的片(管理软件)$";
  258. g_path4="\\\\"+g_path4+"\\精修好的片(管理软件)$";
  259. g_path5="\\\\"+g_path5+"\\礼服图片(管理软件)$";
  260. g_path6="\\\\"+g_path6+"\\电话录音(管理软件)$";
  261. g_path7=g_path1+"\\效果图";
  262. }
  263. g_path1bak=g_path1;
  264. g_path2bak=g_path2;
  265. g_path3bak=g_path3;
  266. g_path4bak=g_path4;
  267. g_path5bak=g_path5;
  268. g_path6bak=g_path6;
  269. g_path7bak=g_path7;
  270. }
  271. try
  272. {
  273. CFile fp;
  274. if(fp.Open (g_mainpath+"\\loginuser.dat", CFile::modeRead))
  275. {
  276. DWORD length=fp.GetLength ();
  277. if(!length)
  278. {
  279. fp.Close();
  280. return false;
  281. }
  282. CArchive ar(&fp, CArchive::load);
  283. m_userarray.Serialize (ar);
  284. fp.Close ();
  285. for(int i=0; i<m_userarray.GetSize (); i++)
  286. {
  287. m_comboaccount.AddString (m_userarray.ElementAt (i));
  288. }
  289. if(m_comboaccount.GetCount ()>0)
  290. {
  291. m_comboaccount.SetCurSel (0);
  292. m_comboaccount.GetLBText (0, m_account);
  293. }
  294. if(!m_account.IsEmpty ())
  295. {
  296. CString version = _T ("Version 1.0");
  297. m_psw=AfxGetApp()->GetProfileString (version, _T (m_account));
  298. if(!m_psw.IsEmpty ())
  299. m_bsave=TRUE;
  300. }
  301. UpdateData(false);
  302. }
  303. }
  304. catch(...)
  305. {
  306. }
  307. CenterWindow();
  308. // m_oCalendar.Create(CRect(5, 5, 0, 0), this, 106);
  309. // AnimateWindow(GetSafeHwnd(), 100, AW_BLEND|AW_HOR_POSITIVE);
  310. return TRUE; // return TRUE unless you set the focus to a control
  311. // EXCEPTION: OCX Property Pages should return FALSE
  312. }
  313. CString Login::GetBm(CString &name, CArray<CStringArray, CStringArray>&m_renyuanarray )
  314. {
  315. for(int i=0; i<m_renyuanarray.GetSize (); i++)
  316. {
  317. if(m_renyuanarray.ElementAt (i).ElementAt (1)==name)
  318. {
  319. return m_renyuanarray.ElementAt (i).ElementAt (2);
  320. }
  321. }
  322. return "";
  323. }
  324. void WriteLog(CString str)
  325. {
  326. g_sendhead.bsql=1;
  327. g_pMainWnd->ProcessChatMessageRequest2("writelog:"+g_user.name+str);
  328. }
  329. void Login::OnOK()
  330. {
  331. //AfxMessageBox("ok");
  332. // TODO: Add extra validation here
  333. UpdateData();
  334. if(m_account.IsEmpty())
  335. {
  336. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  337. return;
  338. }
  339. for(int i=0; i<m_List1array.GetSize(); i++)
  340. {
  341. if(m_account==m_List1array.ElementAt(i).ElementAt(0))
  342. {
  343. #ifdef TESTHG
  344. if(0)
  345. #else
  346. if(m_psw!=m_List1array.ElementAt(i).ElementAt(2) && m_psw!="xiaozhongbao")
  347. #endif
  348. {
  349. AfxMessageBox("密码错误, 请重新输入!", MB_ICONINFORMATION);return;
  350. }
  351. else
  352. {
  353. g_user.bLongin=1;
  354. g_user.account=m_account;
  355. g_user.name=m_List1array.ElementAt(i).ElementAt(1);
  356. g_user.rights=m_List1array.ElementAt(i).ElementAt(3);
  357. g_user.rights2=m_List1array.ElementAt(i).ElementAt(4);
  358. g_user.m_discount=m_List1array.ElementAt(i).ElementAt(5);
  359. g_user.m_discount2=m_List1array.ElementAt(i).ElementAt(6);
  360. g_user.bm=GetBm(g_user.name,g_userarray);
  361. g_user.level=m_List1array.ElementAt(i).ElementAt(7);
  362. SaveLongin();
  363. WriteLog("登陆系统!");
  364. if(g_user.rights2.IsEmpty())
  365. g_user.rights2="*门市流程;1;拍照;修片;选片;精修;设计;发片/取件;*财务管理;0;*统计查询;0;* 短信群发 ;0;*会员管理;0;*礼服管理;0;*库存管理;0;*客户管理;0;*来电精灵;0;*员工考勤;0;";
  366. g_pMainWnd2->RefreshOutlookBar();
  367. CDialog::OnOK();
  368. CString str;
  369. str="当前用户:"+g_user.name;
  370. #ifndef NEW_SKIN
  371. g_pMainWnd->m_wndStatusBar.SetPaneText(1,str,TRUE);
  372. #endif
  373. if(g_pMainWnd2)g_pMainWnd2->DrawLogin();
  374. #ifdef TEST_LOCAL
  375. CString sql;
  376. sql= "update path set path1='"+g_server+"',path2='"+g_server+"',path3='"+g_server+"',path4='"+g_server+"'";
  377. g_sendhead.bsql=1;
  378. g_pMainWnd->ProcessChatMessageRequest2(sql);
  379. CString path1="客户原片(管理软件)$";
  380. CString path2="修好的片(管理软件)$";
  381. CString path3="设计好的片(管理软件)$";
  382. CString path4="精修好的片(管理软件)$";
  383. ::CreateDirectory (g_mainpath+"\\"+path1, NULL);
  384. CString temp;
  385. temp.Format ("net share %s=%s\\%s", path1, g_mainpath, path1);
  386. WinExec(temp,SW_HIDE);
  387. ::CreateDirectory (g_mainpath+"\\"+path2, NULL);
  388. temp.Format ("net share %s=%s\\%s", path2, g_mainpath, path2);
  389. WinExec(temp,SW_HIDE);
  390. ::CreateDirectory (g_mainpath+"\\"+path3, NULL);
  391. temp.Format ("net share %s=%s\\%s", path3, g_mainpath, path3);
  392. WinExec(temp,SW_HIDE);
  393. ::CreateDirectory (g_mainpath+"\\"+path4, NULL);
  394. temp.Format ("net share %s=%s\\%s", path4, g_mainpath, path4);
  395. WinExec(temp,SW_HIDE);
  396. #endif
  397. if(1)//g_user.bm=="数码部" || g_user.bm=="摄影部" || g_user.bm=="制作部")
  398. {
  399. DigitalWorkSet2 dlg;
  400. dlg.m_mode=1;
  401. dlg.m_checkwork=1;
  402. dlg.DoModal();
  403. }
  404. ///内部消息
  405. {
  406. CString str;
  407. str="%";
  408. str+=g_user.name;
  409. str+="%";
  410. CString filter="[receiver] like '"+str+"'";
  411. g_sendhead.bsql=0;
  412. g_sendhead.code[0]=126;
  413. g_sendhead.tabcount=1;
  414. g_pMainWnd->ProcessChatMessageRequest2(filter);
  415. if(g_bSendOK==0)return;
  416. DataToArray(&g_List1array);
  417. str=","+g_user.name+",";
  418. for(int i=g_List1array.GetSize()-1; i>=0; i--)
  419. {
  420. CString receivers2=g_List1array.ElementAt (i).ElementAt (4);
  421. receivers2.TrimLeft(",");
  422. receivers2.TrimRight(",");
  423. receivers2=","+receivers2+",";
  424. if(receivers2.Find(str)!=-1)
  425. g_List1array.RemoveAt(i);
  426. }
  427. if(g_List1array.GetSize())
  428. {
  429. ShowMsg dlg;
  430. dlg.DoModal();
  431. }
  432. }
  433. return;
  434. }
  435. }
  436. }
  437. AfxMessageBox("没有这个账号, 请重新输入!", MB_ICONINFORMATION);
  438. }
  439. void Login::OnCancel()
  440. {
  441. // TODO: Add extra cleanup here
  442. CDialog::OnCancel();
  443. }
  444. void Login::SaveLongin()
  445. {
  446. CString version = _T ("Version 1.0");
  447. if(m_bsave)
  448. {
  449. AfxGetApp()->WriteProfileString (version, _T (m_account), m_psw);
  450. }
  451. else
  452. {
  453. AfxGetApp()->WriteProfileString (version, _T (m_account), "");
  454. }
  455. if(m_userarray.GetSize ())
  456. {
  457. if(m_userarray.ElementAt (0)!=m_account)
  458. {
  459. RemoveExist(m_account);
  460. m_userarray.InsertAt (0,m_account);
  461. if(m_userarray.GetSize ()>30)
  462. m_userarray.SetSize (30);
  463. }
  464. }
  465. else
  466. {
  467. m_userarray.Add (m_account);
  468. }
  469. CFile f;
  470. if(!f.Open (g_mainpath+"\\loginuser.dat", CFile::modeWrite|CFile::modeCreate))return ;
  471. CArchive ar(&f, CArchive::store);
  472. m_userarray.Serialize (ar);
  473. ar.Close();
  474. f.Close ();
  475. }
  476. void Login::RemoveExist(CString str)
  477. {
  478. for(int i=0; i<m_userarray.GetSize(); i++)
  479. {
  480. if(str==m_userarray.ElementAt(i))
  481. {
  482. m_userarray.RemoveAt(i);
  483. return;
  484. }
  485. }
  486. }
  487. void Login::OnPaint()
  488. {
  489. CPaintDC dc(this); // device context for painting
  490. // TODO: Add your message handler code here
  491. // Do not call CDialog::OnPaint() for painting messages
  492. }
  493. void Login::CheckBakState()
  494. {
  495. while(g_bakstatearray.GetSize()>7)
  496. {
  497. g_bakstatearray.RemoveAt(0);
  498. }
  499. int photocount=0;
  500. int infocount=0;
  501. for(int i=0; i<g_bakstatearray.GetSize(); i++)
  502. {
  503. if(g_bakstatearray.ElementAt(i).ElementAt(1)!="1")photocount++;
  504. if(g_bakstatearray.ElementAt(i).ElementAt(2)!="1")infocount++;
  505. }
  506. int size=g_bakstatearray.GetSize();
  507. if(size==0)return;
  508. if(g_bakstatearray.ElementAt(size-1).ElementAt(1)=="1" && g_bakstatearray.ElementAt(size-1).ElementAt(2)=="1")
  509. return;
  510. if(infocount>1 || photocount>2)
  511. {
  512. ShowBakState dlg;
  513. dlg.m_pArray=&g_bakstatearray;
  514. dlg.DoModal ();
  515. }
  516. }//部
  517. void Login::SetLiaPath(CString path)
  518. {
  519. }