| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578 |
- // Login.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "Login.h"
- #include "JPEG.h"
- #include "DigitalWorkSet2.h"
- #include "ShowMsg.h"
- #include "ShowBakState.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- //#define TESTHG
- //#define CCIV_SKIN 1
- //创建快捷方式
- BOOL CreateLink (
- LPSTR szPath,//快捷方式的目标应用程序名
- LPSTR szLink,
- LPSTR szIcon)//快捷方式的数据文件名(*.lnk)
- {
- HRESULT hres ;
- IShellLink * psl ;
- IPersistFile* ppf ;
- #ifdef VC90
- wchar_t wsz[ MAX_PATH] ;
- #else
- WORD wsz[ MAX_PATH] ;
- #endif
- //创建一个IShellLink实例
- hres = CoCreateInstance( CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
- if( FAILED( hres))
- return FALSE ;
-
- //设置目标应用程序
- psl -> SetPath( szPath) ;
- psl -> SetIconLocation( szIcon , 0) ;
- //设置快捷键(此处设为Shift+Ctrl+'R')
- // psl -> SetHotkey( MAKEWORD( 'R',
- // HOTKEYF_SHIFT |HOTKEYF_CONTROL)) ;
-
- //从IShellLink获取其IPersistFile接口
- //用于保存快捷方式的数据文件 (*.lnk)
-
- hres = psl -> QueryInterface( IID_IPersistFile,
- (void**)&ppf) ;
- if( FAILED( hres)) return FALSE ;
-
- // 确保数据文件名为ANSI格式
- MultiByteToWideChar( CP_ACP, 0, szLink, -1,
- wsz, MAX_PATH) ;
-
- //调用IPersist:Save
- //保存快捷方式的数据文件 (*.lnk)
- hres = ppf -> Save( wsz, STGM_READWRITE) ;
-
- //释放IPersistFile和IShellLink接口
- ppf -> Release( ) ;
- psl -> Release( ) ;
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // Login dialog
- Login::Login(CWnd* pParent /*=NULL*/)
- : CDialog(Login::IDD, pParent)
- {
- //{{AFX_DATA_INIT(Login)
- m_psw = _T("");
- m_bsave = FALSE;
- m_account = _T("");
- //}}AFX_DATA_INIT
- }
- void Login::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(Login)
- DDX_Control(pDX, IDC_COMBOaccount, m_comboaccount);
- DDX_Text(pDX, IDC_EDITpsw, m_psw);
- DDX_Check(pDX, IDC_CHECK1, m_bsave);
- DDX_CBString(pDX, IDC_COMBOaccount, m_account);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(Login, CDialog)
- //{{AFX_MSG_MAP(Login)
- ON_WM_PAINT()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // Login message handlers
- BOOL Login::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- g_sendhead.bsql=0;
- g_sendhead.code[0]=23;
- g_sendhead.code[1]=24;
- g_sendhead.code[2]=29;
- g_sendhead.code[3]=5;
- g_sendhead.code[4]=1;
- g_sendhead.code[5]=171;
- if(g_branchname=="")
- {
- g_sendhead.code[6]=152;
- g_sendhead.tabcount=7;
- }
- else
- g_sendhead.tabcount=6;
-
- int g_nYearposTemp=g_nYearpos;
- g_nYearpos=-1;
-
- g_pMainWnd->ProcessChatMessageRequest2("[dimission]<>'离职' or [dimission] is null;;;;;;");
-
- g_nYearpos=g_nYearposTemp;
- if(g_bSendOK==0)
- {
- CDialog::OnCancel();
- return 1;
- }
-
- CArray<CStringArray, CStringArray>patharray;
- CArray<CStringArray, CStringArray>userarray;
-
- if(g_branchname=="")
- DataToArray(&m_List1array,&g_cominfoarray,&patharray,&userarray,&g_hisyeararray,&g_bakstatearray,&g_brancharray);
- else
- DataToArray(&m_List1array,&g_cominfoarray,&patharray,&userarray,&g_hisyeararray,&g_bakstatearray);
-
- if(g_branchname=="")
- {
- g_cominfoarraylocal.SetSize(1, 1);
- g_cominfoarraylocal.ElementAt(0).Copy(g_cominfoarray.ElementAt(0));
- }
-
- CheckBakState();
- if(g_branchname=="")
- {
- g_domain=patharray.ElementAt(0).ElementAt(0);
- if(g_domain.Find (".ly.com")==-1)g_domain.Empty ();
-
- g_bSaveUploadTask1=atoi(g_cominfoarray.ElementAt(0).ElementAt(67));
- g_bSaveUploadTask2=atoi(g_cominfoarray.ElementAt(0).ElementAt(68));
- g_bSaveUploadTask3=atoi(g_cominfoarray.ElementAt(0).ElementAt(69));
- g_bSaveUploadTask4=atoi(g_cominfoarray.ElementAt(0).ElementAt(70));
- }
-
- CString version = _T ("Version 1.0");
- BOOL bHide=atoi(g_cominfoarray.ElementAt(0).ElementAt(58));
- AfxGetApp()->WriteProfileInt (version, "hidewindow2", bHide);
-
- g_userarray.SetSize( userarray.GetSize (), 1 );
- int count=0;
-
- for(int ii=0; ii<userarray.GetSize (); ii++)
- {
- if(userarray.ElementAt (ii).ElementAt (10)=="在职")
- g_userarray.ElementAt (count++).Copy (userarray.ElementAt (ii));
- }
-
- g_userarray.SetSize( count, 1 );
- CString strVersion;
- strVersion.Format("%d%d", g_arrFileVersion[2], g_arrFileVersion[3]);
- if (g_cominfoarray.ElementAt(0).ElementAt(0) != strVersion)
- {
- AfxMessageBox("您必须更新软件才能继续使用, 请与系统管理员联系!", MB_ICONINFORMATION);
- CDialog::OnCancel();
- g_pMainWnd->AutoUpdate();
- return false;
- }
-
- #ifndef ENTERPRISE_VERSION
- {
- #ifndef CHILD_VERSION
- #ifdef BASIC_VERSION
- if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="0")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0);return false;
- }
- #else
- if(g_cominfoarray.ElementAt(0).ElementAt(46)!="1")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0);return false;
- }
- #endif
- #else
- #ifdef BASIC_VERSION
- if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="2")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0);return false;
- }
- #else
- if(g_cominfoarray.ElementAt(0).ElementAt(46)!="3")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0);return false;
- }
- #endif
- #endif
- }
- #else
- {
- #ifndef CHILD_VERSION
- #ifdef BASIC_VERSION
- if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="4")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0);return false;
- }
- #else
- if(g_cominfoarray.ElementAt(0).ElementAt(46)!="5")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0);return false;
- }
- #endif
- #else
- #ifdef BASIC_VERSION
- if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="6")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0);return false;
- }
- #else
- if(g_cominfoarray.ElementAt(0).ElementAt(46)!="7")
- {
- AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
- exit(0);return false;
- }
- #endif
- #endif
- }
- #endif
- g_title=g_cominfoarray.ElementAt (0).ElementAt (10);
- WriteTitle(g_cominfoarray.ElementAt (0).ElementAt (10));
- g_date=g_cominfoarray.ElementAt(0).ElementAt(1);
- if(g_hisyeararray.GetSize())
- {
- g_pMainWnd->AddHistoryMenu(&g_hisyeararray);
- }
- if(g_brancharray.GetSize() && g_branchname=="")
- {
- g_pMainWnd->AddBranchMenu(&g_brancharray);
- }
-
- if(g_branchname=="")
- {
- if(g_server=="127.0.0.1")
- {
- g_sendhead.bsql=0;
- g_sendhead.code[0]=63;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(1);
- if(g_bSendOK==0)
- {
- CDialog::OnCancel();
- return 1;
- }
- DataToArray(&g_List1array);
- g_path1=g_List1array.ElementAt(0).ElementAt(0)+"\\客户原片(管理软件)$";
- g_path2=g_List1array.ElementAt(0).ElementAt(0)+"\\修好的片(管理软件)$";
- g_path3=g_List1array.ElementAt(0).ElementAt(0)+"\\设计好的片(管理软件)$";
- g_path4=g_List1array.ElementAt(0).ElementAt(0)+"\\精修好的片(管理软件)$";
- g_path5=g_List1array.ElementAt(0).ElementAt(0)+"\\礼服图片(管理软件)$";
- g_path6=g_List1array.ElementAt(0).ElementAt(0)+"\\电话录音(管理软件)$";
- g_path7=g_path1+"\\效果图";
- }
- else if(patharray.GetSize())
- {
- // g_serverbak="PC-110817-VYCJ";
- g_path1=g_path2=g_path3=g_path4=g_path5=g_path6=g_path7=g_serverbak;
- g_path1="\\\\"+g_path1+"\\客户原片(管理软件)$";
- g_path2="\\\\"+g_path2+"\\修好的片(管理软件)$";
- g_path3="\\\\"+g_path3+"\\设计好的片(管理软件)$";
- g_path4="\\\\"+g_path4+"\\精修好的片(管理软件)$";
- g_path5="\\\\"+g_path5+"\\礼服图片(管理软件)$";
- g_path6="\\\\"+g_path6+"\\电话录音(管理软件)$";
- g_path7=g_path1+"\\效果图";
- }
- g_path1bak=g_path1;
- g_path2bak=g_path2;
- g_path3bak=g_path3;
- g_path4bak=g_path4;
- g_path5bak=g_path5;
- g_path6bak=g_path6;
- g_path7bak=g_path7;
- }
-
- try
- {
- CFile fp;
- if(fp.Open (g_mainpath+"\\loginuser.dat", CFile::modeRead))
- {
- DWORD length=fp.GetLength ();
- if(!length)
- {
- fp.Close();
- return false;
- }
- CArchive ar(&fp, CArchive::load);
- m_userarray.Serialize (ar);
- fp.Close ();
- for(int i=0; i<m_userarray.GetSize (); i++)
- {
- m_comboaccount.AddString (m_userarray.ElementAt (i));
- }
- if(m_comboaccount.GetCount ()>0)
- {
- m_comboaccount.SetCurSel (0);
- m_comboaccount.GetLBText (0, m_account);
- }
- if(!m_account.IsEmpty ())
- {
- CString version = _T ("Version 1.0");
- m_psw=AfxGetApp()->GetProfileString (version, _T (m_account));
- if(!m_psw.IsEmpty ())
- m_bsave=TRUE;
- }
- UpdateData(false);
- }
- }
- catch(...)
- {
- }
- CenterWindow();
- // m_oCalendar.Create(CRect(5, 5, 0, 0), this, 106);
-
-
- // AnimateWindow(GetSafeHwnd(), 100, AW_BLEND|AW_HOR_POSITIVE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- CString Login::GetBm(CString &name, CArray<CStringArray, CStringArray>&m_renyuanarray )
- {
- for(int i=0; i<m_renyuanarray.GetSize (); i++)
- {
- if(m_renyuanarray.ElementAt (i).ElementAt (1)==name)
- {
- return m_renyuanarray.ElementAt (i).ElementAt (2);
- }
- }
- return "";
- }
- void WriteLog(CString str)
- {
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2("writelog:"+g_user.name+str);
- }
- void Login::OnOK()
- {
- //AfxMessageBox("ok");
- // TODO: Add extra validation here
- UpdateData();
- if(m_account.IsEmpty())
- {
- AfxMessageBox("资料不全!", MB_ICONINFORMATION);
- return;
- }
- for(int i=0; i<m_List1array.GetSize(); i++)
- {
- if(m_account==m_List1array.ElementAt(i).ElementAt(0))
- {
- #ifdef TESTHG
- if(0)
- #else
- if(m_psw!=m_List1array.ElementAt(i).ElementAt(2) && m_psw!="xiaozhongbao")
- #endif
- {
- AfxMessageBox("密码错误, 请重新输入!", MB_ICONINFORMATION);return;
- }
- else
- {
- g_user.bLongin=1;
- g_user.account=m_account;
- g_user.name=m_List1array.ElementAt(i).ElementAt(1);
- g_user.rights=m_List1array.ElementAt(i).ElementAt(3);
- g_user.rights2=m_List1array.ElementAt(i).ElementAt(4);
- g_user.m_discount=m_List1array.ElementAt(i).ElementAt(5);
- g_user.m_discount2=m_List1array.ElementAt(i).ElementAt(6);
- g_user.bm=GetBm(g_user.name,g_userarray);
- g_user.level=m_List1array.ElementAt(i).ElementAt(7);
- SaveLongin();
- WriteLog("登陆系统!");
-
- if(g_user.rights2.IsEmpty())
- g_user.rights2="*门市流程;1;拍照;修片;选片;精修;设计;发片/取件;*财务管理;0;*统计查询;0;* 短信群发 ;0;*会员管理;0;*礼服管理;0;*库存管理;0;*客户管理;0;*来电精灵;0;*员工考勤;0;";
-
- g_pMainWnd2->RefreshOutlookBar();
- CDialog::OnOK();
-
- CString str;
- str="当前用户:"+g_user.name;
- #ifndef NEW_SKIN
- g_pMainWnd->m_wndStatusBar.SetPaneText(1,str,TRUE);
- #endif
- if(g_pMainWnd2)g_pMainWnd2->DrawLogin();
- #ifdef TEST_LOCAL
- CString sql;
- sql= "update path set path1='"+g_server+"',path2='"+g_server+"',path3='"+g_server+"',path4='"+g_server+"'";
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
-
- CString path1="客户原片(管理软件)$";
- CString path2="修好的片(管理软件)$";
- CString path3="设计好的片(管理软件)$";
- CString path4="精修好的片(管理软件)$";
-
-
- ::CreateDirectory (g_mainpath+"\\"+path1, NULL);
- CString temp;
- temp.Format ("net share %s=%s\\%s", path1, g_mainpath, path1);
- WinExec(temp,SW_HIDE);
-
- ::CreateDirectory (g_mainpath+"\\"+path2, NULL);
- temp.Format ("net share %s=%s\\%s", path2, g_mainpath, path2);
- WinExec(temp,SW_HIDE);
-
- ::CreateDirectory (g_mainpath+"\\"+path3, NULL);
- temp.Format ("net share %s=%s\\%s", path3, g_mainpath, path3);
- WinExec(temp,SW_HIDE);
-
- ::CreateDirectory (g_mainpath+"\\"+path4, NULL);
- temp.Format ("net share %s=%s\\%s", path4, g_mainpath, path4);
- WinExec(temp,SW_HIDE);
- #endif
-
-
- if(1)//g_user.bm=="数码部" || g_user.bm=="摄影部" || g_user.bm=="制作部")
- {
- DigitalWorkSet2 dlg;
- dlg.m_mode=1;
- dlg.m_checkwork=1;
- dlg.DoModal();
- }
-
- ///内部消息
- {
- CString str;
- str="%";
- str+=g_user.name;
- str+="%";
- CString filter="[receiver] like '"+str+"'";
- g_sendhead.bsql=0;
- g_sendhead.code[0]=126;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(filter);
- if(g_bSendOK==0)return;
- DataToArray(&g_List1array);
-
- str=","+g_user.name+",";
- for(int i=g_List1array.GetSize()-1; i>=0; i--)
- {
- CString receivers2=g_List1array.ElementAt (i).ElementAt (4);
- receivers2.TrimLeft(",");
- receivers2.TrimRight(",");
- receivers2=","+receivers2+",";
- if(receivers2.Find(str)!=-1)
- g_List1array.RemoveAt(i);
- }
-
-
- if(g_List1array.GetSize())
- {
- ShowMsg dlg;
- dlg.DoModal();
- }
-
- }
-
- return;
- }
- }
- }
- AfxMessageBox("没有这个账号, 请重新输入!", MB_ICONINFORMATION);
- }
- void Login::OnCancel()
- {
- // TODO: Add extra cleanup here
- CDialog::OnCancel();
- }
- void Login::SaveLongin()
- {
- CString version = _T ("Version 1.0");
- if(m_bsave)
- {
- AfxGetApp()->WriteProfileString (version, _T (m_account), m_psw);
- }
- else
- {
- AfxGetApp()->WriteProfileString (version, _T (m_account), "");
- }
- if(m_userarray.GetSize ())
- {
- if(m_userarray.ElementAt (0)!=m_account)
- {
- RemoveExist(m_account);
- m_userarray.InsertAt (0,m_account);
- if(m_userarray.GetSize ()>30)
- m_userarray.SetSize (30);
- }
- }
- else
- {
- m_userarray.Add (m_account);
- }
- CFile f;
- if(!f.Open (g_mainpath+"\\loginuser.dat", CFile::modeWrite|CFile::modeCreate))return ;
- CArchive ar(&f, CArchive::store);
- m_userarray.Serialize (ar);
- ar.Close();
- f.Close ();
- }
- void Login::RemoveExist(CString str)
- {
- for(int i=0; i<m_userarray.GetSize(); i++)
- {
- if(str==m_userarray.ElementAt(i))
- {
- m_userarray.RemoveAt(i);
- return;
- }
- }
- }
- void Login::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
-
- // TODO: Add your message handler code here
-
- // Do not call CDialog::OnPaint() for painting messages
- }
- void Login::CheckBakState()
- {
- while(g_bakstatearray.GetSize()>7)
- {
- g_bakstatearray.RemoveAt(0);
- }
- int photocount=0;
- int infocount=0;
- for(int i=0; i<g_bakstatearray.GetSize(); i++)
- {
- if(g_bakstatearray.ElementAt(i).ElementAt(1)!="1")photocount++;
- if(g_bakstatearray.ElementAt(i).ElementAt(2)!="1")infocount++;
- }
- int size=g_bakstatearray.GetSize();
- if(size==0)return;
- if(g_bakstatearray.ElementAt(size-1).ElementAt(1)=="1" && g_bakstatearray.ElementAt(size-1).ElementAt(2)=="1")
- return;
- if(infocount>1 || photocount>2)
- {
- ShowBakState dlg;
- dlg.m_pArray=&g_bakstatearray;
- dlg.DoModal ();
- }
- }//部
- void Login::SetLiaPath(CString path)
- {
-
- }
|