Login.cpp 15 KB

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