123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509 |
- // Welcome.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "Welcome.h"
- //extern void WriteClientLog(CString str); // Jeff写客户端日志;
- /////////////////////////////////////////////////////////////////////////////
- // Welcome dialog
- Welcome::Welcome(CWnd* pParent /*=NULL*/)
- : CDialog(Welcome::IDD, pParent)
- {
- //{{AFX_DATA_INIT(Welcome)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- m_pBk=NULL;
- g_bNoConnDlg=1;
- m_bFirst=1;
- }
- void Welcome::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(Welcome)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(Welcome, CDialog)
- //{{AFX_MSG_MAP(Welcome)
- ON_WM_PAINT()
- ON_WM_DESTROY()
- ON_WM_ERASEBKGND()
- ON_WM_TIMER()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // Welcome message handlers
- BOOL Welcome::OnEraseBkgnd(CDC* pDC)
- {
- // TODO: Add your message handler code here and/or call default
- if(m_pBk)
- {
- Graphics graph(pDC->GetSafeHdc ());
- CRect rc;
- GetClientRect (rc);
- Rect destinationRect(0,0,rc.Width (), rc.Height ());
- graph.DrawImage(m_pBk, destinationRect, rc.left , rc.top ,rc.Width (), rc.Height (),UnitPixel);
- }
- if(m_bFirst)
- {
- m_bFirst=0;
- m_nticks=::GetTickCount ();
- SetTimer(1, 10, NULL);
- }
- return 1;
- }
- void Welcome::OnCancel()
- {
- // TODO: Add extra cleanup here
- }
- void Welcome::OnOK()
- {
- // TODO: Add extra validation here
- }
- void Welcome::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
- // TODO: Add your message handler code here
- if(m_pBk)
- {
- Graphics graph(dc.GetSafeHdc ());
- CRect rc;
- GetClientRect (rc);
- Rect destinationRect(0,0,rc.Width (), rc.Height ());
- graph.DrawImage(m_pBk, destinationRect, rc.left , rc.top ,rc.Width (), rc.Height (),UnitPixel);
- }
- if(m_bFirst)
- {
- m_bFirst=0;
- m_nticks=::GetTickCount ();
- SetTimer(1, 10, NULL);
- }
- // Do not call CDialog::OnPaint() for painting messages
- }
- void Welcome::OnDestroy()
- {
- // TODO: Add your message handler code here
- if(m_pBk)delete m_pBk;g_bNoConnDlg=0;
- CDialog::OnDestroy();
- }
- BOOL Welcome::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- CString picdir=g_mainpath+"\\图片\\";
- if(g_bRedSkin)
- picdir=g_mainpath+"\\图片-红色风格\\";
- //MessageBox(picdir+"欢迎.jpg");
- // .Jeff加载欢迎图片,作为欢迎界面;
- if(::PathFileExists(picdir+"欢迎.jpg")==0)
- {
- if(0)//::PathFileExists (g_mainpath+"\\zx.dll"))
- {
- HINSTANCE hinst=::LoadLibrary (g_mainpath+"\\zx.dll");
- if(hinst==NULL)
- {
- ::LoadImageFromRes (&m_pBk, MAKEINTRESOURCE(IDR_JPG4), "JPG");
- }
- else
- {
- AfxSetResourceHandle(hinst);
- ::LoadImageFromRes (&m_pBk, MAKEINTRESOURCE(2009), "ZX");
- AfxSetResourceHandle(AfxGetInstanceHandle());
- FreeLibrary(hinst);
- }
- }
- else if(::PathFileExists (g_mainpath+"\\zwj.dll"))
- {
- HINSTANCE hinst=::LoadLibrary (g_mainpath+"\\zwj.dll");
- if(hinst==NULL)
- {
- ::LoadImageFromRes (&m_pBk, MAKEINTRESOURCE(IDR_JPG4), "JPG");
- }
- else
- {
- AfxSetResourceHandle(hinst);
- ::LoadImageFromRes (&m_pBk, MAKEINTRESOURCE(2009), "ZWJ");
- AfxSetResourceHandle(AfxGetInstanceHandle());
- FreeLibrary(hinst);
- }
- }
- else
- ::LoadImageFromRes (&m_pBk, MAKEINTRESOURCE(IDR_JPG4), "JPG");
- }
- else
- ::LoadImageFromBuf (&m_pBk, picdir+"欢迎.jpg");
- if(m_pBk)
- {
- // MessageBox("draw");
- CRect rc;
- GetWindowRect(rc);
- rc.right =rc.left +m_pBk->GetWidth();
- rc.bottom =rc.top +m_pBk->GetHeight();
- MoveWindow(rc);
- CenterWindow();
- CString str;
- int version=625;
- //str.Format ("00%d", version);
- str.Format("%d%d%d%d", g_arrFileVersion[0], g_arrFileVersion[1], g_arrFileVersion[2], g_arrFileVersion[3]);
- Graphics graph(m_pBk);
- if(0)// !g_bRedSkin)
- {
- Rect destinationRect(325,161, 59,15);
- SolidBrush *Brush2=new SolidBrush(Color(255,37,85,147));
- graph.FillRectangle (Brush2, destinationRect);
- delete Brush2;
- }
- StringFormat format;
- format.SetAlignment(StringAlignmentNear );
- RectF layoutRect(325,161, 59,15);
- SolidBrush *Brush=new SolidBrush(Color(255,255,255,255));
- int leng=str.GetLength ();
- BSTR bstr= str.AllocSysString();
- Font *g_TimerFont;
- g_TimerFont=new Font(L"黑体", 16);
- graph.SetTextRenderingHint(TextRenderingHintAntiAlias);
- //PointF pointF(325,161);
- ///graph.DrawString(L"Hello", -1, g_TimerFont, pointF, Brush);
- graph.DrawString(
- bstr,
- leng,
- g_TimerFont,
- layoutRect,
- &format,
- Brush);
- delete Brush;
- delete g_TimerFont;
- SysFreeString(bstr);
- }
- AnimateWindow(GetSafeHwnd(), 300, AW_BLEND);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- CString GetFileSize(CString path)
- {
- CString str="0";
- try
- {
- CFile fp;
- if( fp.Open(path, CFile::modeRead) )
- {
- str.Format("%d", fp.GetLength());
- fp.Close();
- }
- }
- catch(...)
- {
- }
- return str;
- }
- void Welcome::OnTimer(UINT nIDEvent)
- {
- if(nIDEvent==1)
- {
- KillTimer(1);
- if(g_bGenBranchData)
- {
- WriteClientLog("启动分店操作");
- // 1.Jeff.获取存储在本地服务器目录下的branchinfo.dat文件内容;
- CArray<CStringArray, CStringArray>brancharray;
- g_sendhead.bsql=0;
- g_sendhead.code[0]=152; // Jeff.152获取DBServer.exe所在目录的branchinfo.dat里保存的分店内容;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(1);
- if(g_bSendOK==0)//Jeff.通信失败;
- {
- exit(0);
- return;
- }
- DataToArray(&brancharray);
- // 2.Jeff.若branchinfo.dat里有多家分店信息,则遍历全部分店信息;
- CString branch,domain;
- CArray<CStringArray, CStringArray>tagList1array; // Jeff.不规范的变量名称!!!
- for(int i=-1; i<brancharray.GetSize ()-1; i++)
- {
- //printf("Jeff:branchinfo.dat分店数量=%d,i=%d\n\n",brancharray.GetSize(),i);
- if(i!=-1)
- {
- WriteClientLog("只有单店,无分店");
- domain=brancharray.ElementAt (i).ElementAt (2); // Jeff.本店的*.ly.com信息;
- branch=brancharray.ElementAt (i).ElementAt (0); // Jeff.本店做为分店的名称;
- g_branchip=brancharray.ElementAt (i).ElementAt (1); // Jeff.本店外网IP地址;
- g_pMainWnd->OnDisconnect();
- g_branchname=branch;
- g_bBranchModify=1;
- }
- else
- {
- domain=brancharray.ElementAt (brancharray.GetSize ()-1).ElementAt (2);
- branch=brancharray.ElementAt (brancharray.GetSize ()-1).ElementAt (0);
- }
- // 2.1.获取本机数据库的dindan表信息:订单号、取件时间, 发送到本店服务器中;
- // 本店服务器会将这些信息存储在服务目录下branchdindan.dat文件中;
- //
- CString filter="status3='OK' and time5 is not null and time5<>''";
- g_sendhead.bsql=0;
- g_sendhead.code[0]=231; // Jeff.case 231->获取db数据库以及所有历史数据库中已完成取件的定单;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)continue;
- CArray<CStringArray, CStringArray>List1array;
- DataToArray(&List1array);
- int size=tagList1array.GetSize ();
- for(int j=0; j<List1array.GetSize (); j++)
- {
- size++;
- tagList1array.SetSize(size , 1 );
- size--;
- tagList1array.ElementAt (size).Copy (List1array.ElementAt (j));
- tagList1array.ElementAt (size).InsertAt (0, domain); // Jeff.*.ly.com
- size++;
- }
- }
- g_pMainWnd->OnDisconnect();
- g_bBranchModify=0;
- g_branchip=g_branchname="";
- // 3.将domain、订单号、取件时间 存储在tagList1array;
- // 存储在内存中,发送到本机服务器中,由服务器生成branchdindan.dat文件中,待用;
- CMemFile memfile;
- CArchive ar(&memfile, CArchive::store);
- for(int ii=0; ii<tagList1array.GetSize (); ii++)
- {
- tagList1array.ElementAt (ii).Serialize (ar);
- }
- ar.Close();
- int length=memfile.GetLength ();
- BYTE *pData = memfile.Detach();
- int size=tagList1array.GetSize ();
- BYTE *pData2=new BYTE[length+sizeof(int)];
- memcpy(pData2, pData, length);
- memcpy(pData2+length, &size, sizeof(int));
- delete []pData;
- length+=sizeof(int);
- g_nSendCode=41; // dwToUserID==41 处理 branchdindan.dat 文件;
- g_pMainWnd->ProcessChatMessageRequest2(pData2, length);
- g_nSendCode=0;
- delete []pData2;
- exit(0);
- return;
- }
-
- BOOL bSuccess=1;
- CStringArray filesarray;
- filesarray.Add ("AutoUpdate.exe");
- filesarray.Add ("skin\\1.lia");
- filesarray.Add ("skin\\2.lia");
- filesarray.Add ("skin\\3.lia");
- filesarray.Add ("skin\\4.lia");
- filesarray.Add ("skin\\5.lia");
- filesarray.Add ("skin\\10.lia");
- filesarray.Add ("skin\\5-red.lia");
- filesarray.Add ("skin\\10-red.lia");
- filesarray.Add ("图片\\logo.jpg"); // .10.
- filesarray.Add ("图片\\标题-选片.jpg");
- filesarray.Add ("图片\\标题-看设计.jpg");
- filesarray.Add ("图片\\选片.jpg");
- filesarray.Add ("图片\\看设计.jpg");
- filesarray.Add ("图片\\欢迎.jpg");
- filesarray.Add ("图片\\连接.jpg");
- filesarray.Add ("图片\\标题.jpg");
- filesarray.Add ("图片\\背景.jpg");
- filesarray.Add ("图片-红色风格\\欢迎.jpg");
- filesarray.Add ("图片-红色风格\\连接.jpg"); // .20.
- filesarray.Add ("图片-红色风格\\标题.jpg");
- filesarray.Add ("图片-红色风格\\背景.jpg");
- filesarray.Add ("skin\\6.lia");
- filesarray.Add ("图片\\掌中宝.jpg");
- filesarray.Add ("regsvr32.exe"); // .25.
- ::CreateDirectory (g_mainpath+"\\skin", NULL);
- ::CreateDirectory (g_mainpath+"\\图片", NULL);
- ::CreateDirectory (g_mainpath+"\\图片-红色风格", NULL);
- // 1.Jeff.array分上下两部分,前半部分保存着文件路径名,后半部分保存着上半部分文件的大小;
- CStringArray array;
- array.Copy(filesarray);
- for(int i=0; i<filesarray.GetSize(); i++)
- {
- // array.Add (GetModifyTime (g_mainpath+"\\"+filesarray.ElementAt (i)));
- array.Add (GetFileSize(g_mainpath+"\\"+filesarray.ElementAt(i)));
- // if(filesarray.ElementAt (i).Find("5.lia")!=-1)
- // AfxMessageBox(GetFileSize (g_mainpath+"\\"+filesarray.ElementAt (i)));
- }
- // 2.将array用内存文件处理,作为二进制数据与服务端通信;
- {
- CMemFile memfile;
- CArchive ar(&memfile, CArchive::store);
- array.Serialize(ar);
- ar.Close();
- DWORD length=memfile.GetLength ();
- BYTE *pData = memfile.Detach();
- #if 0 // Jeff.原
- ll: g_nSendCode=211;//Jeff.已经没用到这个goto了;
- #else
- g_nSendCode = 211;//g_nSendCode=211: 更新 \服务端\skin\ 文件夹下的大小变更的文件到客户端去;
- #endif
- g_pMainWnd->ProcessChatMessageRequest2(pData, length);
- if(g_bSendOK==0)
- { //AfxMessageBox("2");
- exit(0);
- return;
- }
- g_nSendCode=0;
- delete []pData;
- if(g_bSendOK==0) // Jeff.前面都exit和return了,后面还有用么????
- {
- bSuccess=0;
- CDialog::OnCancel();
- g_pMainWnd->m_pMainFrimDlg2=new MainFrimDlg2;
- g_pMainWnd->m_pMainFrimDlg2->SetLiaPath("10.lia");
- // Jeff.remak.2014.06.26
- // MainFrimDlg2::Create调用了MyDlg::OnInitDialog(),接着调用LoadLia()
- // LoadLia()再调用GetPos(),GetPost()调用了ProcessChatMessageRequest2:code[0]=105
- g_pMainWnd->m_pMainFrimDlg2->Create(IDD_DLGmydlg, g_pMainWnd);
- return;
- }
- }
- // Jeff.g_pData2里保存的是更新的数据;
- BYTE *pData[40]={NULL};
- DWORD nDataLeng[40]={0};
- BYTE *pSumData=g_pData2;
- DWORD sumleng=g_nLeng2;
- CStringArray filedatearray;
- DWORD nArrayLength;
- memcpy(&nArrayLength, pSumData, sizeof(DWORD));
- CMemFile memfile;
- memfile.Attach (pSumData+sizeof(DWORD), nArrayLength);
- CArchive ar(&memfile, CArchive::load);
- filedatearray.Serialize (ar);
- ar.Close();
- memfile.Detach ();
- // Jeff.
- DWORD bytesread=0;
- DWORD a;
- int pos=0;
- CString stime;
- for( i=0; i<40; i++)
- {
- memcpy(&a, pSumData+sizeof(DWORD)*i+nArrayLength+sizeof(DWORD), sizeof(DWORD));
- nDataLeng[i]=a;
- if(a)
- {
- CFile fp;
- if(fp.Open (g_mainpath+"\\"+filesarray.ElementAt(i), CFile::modeCreate|CFile::modeWrite))
- {
- fp.Write (pSumData+sizeof(DWORD)*40+bytesread+nArrayLength+sizeof(DWORD), a);
- bytesread+=a;
- fp.Close ();
- stime=filedatearray.ElementAt (pos);
- pos++;
- /* if(stime.GetLength ()==32)
- {
- FILETIME localtime;
- FILETIME localtime2;
- localtime.dwHighDateTime =atol(stime.Left (16));
- localtime.dwLowDateTime =atol(stime.Right (16));
- HANDLE hFile = CreateFile(g_mainpath+"\\"+filesarray.ElementAt (i), GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_DELETE,NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
- LocalFileTimeToFileTime(&localtime, &localtime2);
- SetFileTime(hFile, NULL, NULL,&localtime2);
- CloseHandle(hFile);
- }*/
- }
- else
- {
- bSuccess=0;
- break;
- }
- }
- }
- //if( g_server.Find ("192.168.10.")!=-1 )::Sleep(3000);
- if(g_pData2)
- delete []g_pData2;
- g_pData2=NULL;
- g_pMainWnd->m_pMainFrimDlg2=new MainFrimDlg2;
- g_pMainWnd->m_pMainFrimDlg2->SetLiaPath ("10.lia");
- // Jeff.remak.2014.06.26
- // MainFrimDlg2::Create调用了MyDlg::OnInitDialog(),接着调用LoadLia()
- // LoadLia()再调用GetPos(),GetPost()调用了ProcessChatMessageRequest2:code[0]=105
- // case 105:界面;
- // case 218:client表;
- g_pMainWnd->m_pMainFrimDlg2->Create(IDD_DLGmydlg, g_pMainWnd);
- g_sendhead.bsql=0;
- // AfxMessageBox("6");
- g_sendhead.code[0]=218;
- g_sendhead.tabcount=1;
- // if( g_server.Find ("192.168.10.")!=-1 )::Sleep(3000);
- g_pMainWnd->ProcessChatMessageRequest2(1);
- if(g_bSendOK==0)
- { //AfxMessageBox("7");
- exit(0);
- return;
- }
- //AfxMessageBox("8");
- DataToArray(&g_oldclientarray);
- if(::GetTickCount ()-m_nticks<2000)
- ::Sleep (2000-(::GetTickCount ()-m_nticks));
- CDialog::OnCancel ();
- }
- else if (nIDEvent == 0)
- {
- CRect dlgRect;
- CRect DesktopRect;
- GetWindowRect(dlgRect);
- GetDesktopWindow()->GetWindowRect(DesktopRect);
- if (dlgRect.Width() >= (dlgWidth - dlgDx) ) dlgDx = dlgWidth - dlgRect.Width();
- if (dlgRect.Height() >= (dlgHeight - dlgDy) ) dlgDy = dlgHeight - dlgRect.Height();
- MoveWindow
- (
- ( -dlgDx+DesktopRect.Width() - dlgRect.Width() )/2,
- ( -dlgDy+DesktopRect.Height() - dlgRect.Height() )/2,
- +dlgDx+dlgRect.Width(),
- +dlgDy+dlgRect.Height()
- );
- if ( ( dlgRect.Width() >= (dlgWidth - dlgDx) ) && ( dlgRect.Height() >= (dlgHeight - dlgDy) ) )
- ::KillTimer(this->m_hWnd, 0);
- }
- }
|