123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335 |
- // ShowPic.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "ShowPic.h"
- #include "ShowPic22.h"
- #include "ImportPhoto.h"
- #include "JPEG.h"
- #include "MyLock.h"
- #include "ZipTypeDlg.h"
- #include "SetDesignNo.h"
- #define THUMBNAIL_WIDTH 100
- #define THUMBNAIL_HEIGHT 90
- /////////////////////////////////////////////////////////////////////////////
- // ShowPic dialog IDC_BU IDC_COMBO2
- ShowPic::ShowPic(CWnd* pParent /*=NULL*/)
- : CDialog(ShowPic::IDD, pParent)
- {
- //{{AFX_DATA_INIT(ShowPic)
- m_branchname = _T("");
- //}}AFX_DATA_INIT
- m_bTerminate = false;
- m_bRunning = false;
- m_hThread = NULL;
- m_mode = 0;
- m_bdelall = 0;
- }
- void ShowPic::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(ShowPic)
- DDX_Control(pDX, IDC_COMBO2, m_combobranch);
- DDX_Control(pDX, IDC_LIST1, m_List1);
- DDX_Control(pDX, IDC_COMBO1, m_combo1);
- DDX_CBString(pDX, IDC_COMBO2, m_branchname);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(ShowPic, CDialog)
- //{{AFX_MSG_MAP(ShowPic)
- ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
- ON_WM_DESTROY()
- ON_BN_CLICKED(IDC_BUTdelall, OnBUTdelall)
- ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
- ON_BN_CLICKED(IDC_BUTupload, OnBUTupload)
- ON_BN_CLICKED(IDC_BUTselall, OnBUTselall)
- ON_CBN_SELCHANGE(IDC_COMBO2, OnSelchangeCombo2)
- ON_BN_CLICKED(IDC_BUTSetDesignNo, OnBUTSetDesignNo)
- ON_BN_CLICKED(IDC_BUTexport, OnBUTexport)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // ShowPic message handlers
- BOOL ShowPic::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CRect rc2;
- GetWindowRect(rc2);
- ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
- EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
- GetDlgItem(IDOK)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- int hei = rc2.Height();
- GetClientRect(rc2);
- rc2.top = hei + 10;
- m_List1.MoveWindow(rc2);
- int right = rc2.right;
- GetDlgItem(IDOK)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- int dtx = right - rc2.right - 5;
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- rc2.left += dtx;
- rc2.right += dtx;
- GetDlgItem(IDOK)->MoveWindow(rc2);
- GetDlgItem(IDC_BUTdel)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- rc2.left += dtx;
- rc2.right += dtx;
- GetDlgItem(IDC_BUTdel)->MoveWindow(rc2);
- GetDlgItem(IDC_BUTdelall)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- rc2.left += dtx;
- rc2.right += dtx;
- GetDlgItem(IDC_BUTdelall)->MoveWindow(rc2);
- GetDlgItem(IDC_BUTSetDesignNo)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- rc2.left += dtx;
- rc2.right += dtx;
- GetDlgItem(IDC_BUTSetDesignNo)->MoveWindow(rc2);
- GetDlgItem(IDC_BUTexport)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- rc2.left += dtx;
- rc2.right += dtx;
- GetDlgItem(IDC_BUTexport)->MoveWindow(rc2);
- //////////////////////////////////////////////////////////
- GetDlgItem(IDC_BUTupload)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- GetDlgItem(IDC_BUTupload)->MoveWindow(rc2);
- GetDlgItem(IDC_BUTselall)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- GetDlgItem(IDC_BUTselall)->MoveWindow(rc2);
- GetDlgItem(IDC_COMBO2)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei + 300;
- GetDlgItem(IDC_COMBO2)->MoveWindow(rc2);
- m_combobranch.ShowWindow(0);
- if (g_branchname == "")
- {
- GetDlgItem(IDC_BUTupload)->ShowWindow(0);
- GetDlgItem(IDC_BUTselall)->ShowWindow(0);
- }
- // else
- // GetDlgItem(IDC_BUTupload)->SetWindowText("上传至"+g_branchname);
- #ifdef ENTERPRISE_VERSION
- if (1)//g_branchname=="")
- {
- m_combobranch.ShowWindow(1);
- for (int i = 0; i < g_brancharray.GetSize() - 1; i++)
- {
- if (m_iparray.GetSize())
- {
- if (g_brancharray.ElementAt(i).ElementAt(2) == m_iparray.ElementAt(m_iparray.GetSize() - 1))continue;
- }
- m_combobranch.AddString(g_brancharray.ElementAt(i).ElementAt(0));
- m_iparray.Add(g_brancharray.ElementAt(i).ElementAt(2));
- }
- GetDlgItem(IDC_BUTupload)->ShowWindow(1);
- GetDlgItem(IDC_BUTselall)->ShowWindow(1);
- }
- #endif
- if (m_mode == 1 && IsHasRights2new(4) == 0)//拍照
- {
- GetDlgItem(IDC_BUTupload)->ShowWindow(0);
- GetDlgItem(IDC_BUTselall)->ShowWindow(0);
- }
- if (m_mode == 2 && IsHasRights2new(5) == 0)
- {
- GetDlgItem(IDC_BUTupload)->ShowWindow(0);
- GetDlgItem(IDC_BUTselall)->ShowWindow(0);
- }
- if (m_mode == 3 && IsHasRights2new(6) == 0)
- {
- GetDlgItem(IDC_BUTupload)->ShowWindow(0);
- GetDlgItem(IDC_BUTselall)->ShowWindow(0);
- }
- if (m_mode == 5 && IsHasRights2new(7) == 0)
- {
- GetDlgItem(IDC_BUTupload)->ShowWindow(0);
- GetDlgItem(IDC_BUTselall)->ShowWindow(0);
- }
- if (m_mode == 4)//礼服
- {
- GetDlgItem(IDC_BUTupload)->ShowWindow(0);
- GetDlgItem(IDC_BUTselall)->ShowWindow(0);
- }
- if (m_mode == 1)//拍照
- {
- GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(34));
- GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(34));
- }
- else if (m_mode == 2)//初修
- {
- GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(35));
- GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(35));
- }
- else if (m_mode == 3)//精修
- {
- GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(36));
- GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(36));
- }
- else if (m_mode == 5)//设计
- {
- GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(37));
- GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(37));
- GetDlgItem(IDC_BUTSetDesignNo)->EnableWindow(IsHasRights2new(7));
- GetDlgItem(IDC_BUTSetDesignNo)->ShowWindow(SW_SHOW);
- GetDlgItem(IDC_BUTexport)->EnableWindow(IsHasRights2new(12));
- GetDlgItem(IDC_BUTexport)->ShowWindow(SW_SHOW);
- }
- else if (m_mode == 4)//礼服
- {
- SetWindowText("礼服查看");
- GetDlgItem(IDC_BUTdelall)->EnableWindow(0);
- GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(43));
- m_combobranch.ShowWindow(1);
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 72;
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(0);
- if (g_bSendOK == 0)
- {
- CDialog::OnCancel();
- return 0;
- }
- int i = 0;
- DataToArray(&m_List1array);
- CStringArray typearray;
- for ( i = 0; i < m_List1array.GetSize(); i++)
- {
- if (-1 == ::FindArray(&typearray, m_List1array.ElementAt(i).ElementAt(0)))
- typearray.Add(m_List1array.ElementAt(i).ElementAt(0));
- }
- m_combobranch.AddString("全部");
- for (i = 0; i < typearray.GetSize(); i++)
- {
- m_combobranch.AddString(typearray.ElementAt(i));
- }
- m_combobranch.SetCurSel(0);
- }
- m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
- m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
- LoadPhotos();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- unsigned __stdcall LoadThumbNail(LPVOID lpParam)
- {
- try
- {
- ShowPic *pDlg = (ShowPic*)lpParam;
- CListCtrl *ListCtrl = &pDlg->m_List1;
- CImageList* pImgList = &pDlg->m_ImageListThumb;
- // reset our image list
- for (int i = 0; i < pImgList->GetImageCount(); i++)
- pImgList->Remove(i);
- // remove all items from list view
- ListCtrl->DeleteAllItems();
- pImgList->SetImageCount(pDlg->m_vFileName.size());
- TCHAR path[MAX_PATH];
- vector<CString>::iterator iter;
- // Set redraw to FALSE to avoid flickering during adding new items
- ListCtrl->SetRedraw(FALSE);
- int nIndex = 0;
- CString str, spath;
- for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
- {
- str = *iter;
- spath.Empty();
- if (str.Left(str.ReverseFind('\\') + 1) != pDlg->m_path)
- {
- spath = str.Left(str.ReverseFind('\\') + 1);
- spath = spath.Right(spath.GetLength() - pDlg->m_path.GetLength());
- }
- str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- str = spath + str.Left(str.GetLength() - 4);
- ListCtrl->InsertItem(nIndex, str, nIndex);
- }
- ListCtrl->SetRedraw(TRUE);
- ListCtrl->Invalidate();
- const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;
- int XDest, YDest, nDestWidth, nDestHeight;
- nIndex = 0;
- SolidBrush whitebrush(Color(255, 255, 255, 255));
- for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
- {
- // Load Image File
- Image *image = NULL;
- Bitmap *pBmp = NULL;
- str = *iter;
- spath = str.Left(str.ReverseFind('\\') + 1);
- spath += "s";
- spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- if (PathFileExists(spath))
- ::LoadImageFromBuf(&image, spath);
- else
- {
- str.MakeLower();
- if (str.Right(3) != "jpg")continue;
- ::LoadImageFromBuf(&image, str);
- }
- if (image == NULL)continue;
- int orientation = GetOrientation(image);
- if (orientation == 8)
- image->RotateFlip(Rotate270FlipNone);
- else if (orientation == 6)
- image->RotateFlip(Rotate90FlipNone);
- if (image->GetWidth() == 0)
- continue;
- // Calculate Rect to fit to canvas
- const float fImgRatio = (float)image->GetHeight() / image->GetWidth();
- if (fImgRatio > fRatio)
- {
- nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
- XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
- YDest = 0;
- nDestHeight = THUMBNAIL_HEIGHT;
- }
- else
- {
- XDest = 0;
- nDestWidth = THUMBNAIL_WIDTH;
- nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
- YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
- }
- pBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
- Graphics graph2(pBmp);
- graph2.Clear(Color(255, 192, 192, 192));
- graph2.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH - 2, THUMBNAIL_HEIGHT - 2);
- Graphics graph(pBmp);
- Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
- // Draw Image
- graph.DrawImage(image, desRect, 0, 0, image->GetWidth(), image->GetHeight(), UnitPixel);
- delete image;
- // Attach to Bitmap and Replace image in CImageList
- CBitmap bitmap;
- HBITMAP hbmp;
- pBmp->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
- bitmap.Attach(hbmp);
- pImgList->Replace(nIndex, &bitmap, NULL);
- delete pBmp;
- // Redraw only a current item for removing flickering and fast speed.
- ListCtrl->RedrawItems(nIndex, nIndex);
- // Release used DC and Object
- }
- ListCtrl->Invalidate();
- pDlg->m_bRunning = false;
- pDlg->m_bTerminate = false;
- _endthreadex(0);
- return 0;
- }
- catch (...)
- {
- }
- return 0;
- }
- void ShowPic::LoadThumbImages()
- {
- TerminateThread();
- m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
- m_bRunning = true;
- }
- BOOL ShowPic::TerminateThread()
- {
- if (!m_bRunning)
- return TRUE;
- m_bTerminate = true;
- for (;;)
- {
- if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
- break;
- MSG msg;
- while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
- {
- if (!AfxGetApp()->PumpMessage())
- break;
- }
- }
- ::CloseHandle(m_hThread);
- return TRUE;
- }
- void ShowPic::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- return;
- }
- int iItem = m_List1.GetNextSelectedItem(pos);
- ShowPic22 dlg;
- dlg.m_pos = iItem;
- dlg.m_pPathArray = &m_patharray1;
- dlg.DoModal();
- *pResult = 0;
- }
- void ShowPic::OnDestroy()
- {
- TerminateThread();
- CDialog::OnDestroy();
- // TODO: Add your message handler code here
- }
- void ShowPic::LoadPhotos()
- {
- m_patharray1.RemoveAll();
- m_path.MakeLower();
- CStringArray dirarray;
- CString str;
- if (m_mode == 4)//礼服
- {
- CString savepath = g_path5 + "\\";
- for (int i = 0; i < m_List1array.GetSize(); i++)
- {
- if (m_type != "" && m_type != "全部" && m_type != m_List1array.ElementAt(i).ElementAt(0))
- continue;
- // str=savepath+"s"+m_List1array.ElementAt (i).ElementAt (1)+".jpg";
- str = savepath + m_List1array.ElementAt(i).ElementAt(1) + ".jpg";
- if (::PathFileExists(str))
- m_patharray1.Add(str);
- }
- }
- else
- {
- if (1)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(m_path), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- // 1.获得所有子文件夹;
- coo = o.co_dir();
- for (it = coo.begin();coo.end() != it;it++)
- {
- str = (*it).c_str();
- if (FindArray(&dirarray, str) == -1)
- {
- dirarray.Add(str);
- }
- }
- }
- if (1)
- {
- CString filename;
- for (int i = 0; i < dirarray.GetSize(); i++)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(0);
- if (m_mode == 1)//拍照
- o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.*"));
- else
- o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- // 2.获得所有子文件夹下的文件;
- coo = o.co_file();
- for (it = coo.begin();coo.end() != it;it++)
- {
- str = (*it).c_str();
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- str.MakeLower();
- if (m_mode == 1)//拍照
- {
- filename = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- if (filename.Find(".") != -1)
- filename = filename.Left(filename.Find("."));
- if (!myisdigit(filename))continue;
- }
- m_patharray1.Add(str);
- }
- }
- }
- }
- if (m_bRunning)return;
- CStringArray *pArray = &m_patharray1;
- m_vFileName.clear();
- for (int i = 0; i < pArray->GetSize(); i++)
- {
- CString filePath = pArray->ElementAt(i);
- filePath.MakeLower();
- m_vFileName.push_back(filePath);
- }
- LoadThumbImages();
- }
- void ShowPic::OnBUTdelall() // 全部删除按钮;
- {
- // TODO: Add your control notification handler code here
- if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
- CString path = m_path;
- path.TrimRight('\\');
- DeleteDirectory(path);
- LoadPhotos();
- if (m_mode == 1)
- {
- CString sql;
- sql = "update dindan set [curno]='1' where [id]='" + m_id + "'";
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- m_bdelall = 1;
- }
- #if 0
- CString str;
- str="清除客人";
- str+=m_name;
- str+=m_id;
- if(m_mode==1)
- str+="原片";
- else if(m_mode==2)
- str+="初修片";
- else if(m_mode==3)
- str+="精修片";
- else if(m_mode==5)
- str+="设计片";
- WriteLog(str);
- #else
- CString str;
- str = "清除";
- str += m_name;
- str += m_id;
- str += "全部";//Jeff.add;
- if (m_mode == 1)
- str += "原片";
- else if (m_mode == 2)
- str += "初修片";
- else if (m_mode == 3)
- str += "精修片";
- else if (m_mode == 5)
- str += "设计片";
- WriteLog(_T("普通日志"), _T("清除相片"), g_user.name, str);
- #endif
- if (g_branchname != "")
- {
- str.Format("是否同步删除分店 %s 的照片?", g_branchname);
- if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
- CString sql = "deletephotos";
- if (m_mode == 1)//拍照
- sql += "0";
- else if (m_mode == 2)//初修
- sql += "1";
- else if (m_mode == 3)//精修
- sql += "2";
- else if (m_mode == 5)//设计
- sql += "3";
- sql += m_id;
- sql += ";";
- CString jd;
- if (m_mode == 1)
- { //拍照,加景点
- CString file2 = m_path;
- int pos = file2.Find(m_id);
- pos += m_id.GetLength();
- int pos2 = file2.ReverseFind('\\');
- if (pos2 > pos)
- {
- jd = file2.Mid(pos + 1, pos2 - pos - 1);
- }
- }
- sql += "all";
- sql += jd;
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
- AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
- #if 1//Jeff add;
- CString strDelContent;
- if (m_mode == 1)
- str += "原片";
- else if (m_mode == 2)
- str += "初修片";
- else if (m_mode == 3)
- str += "精修片";
- else if (m_mode == 5)
- str += "设计片";
- strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
- WriteLog(_T("普通日志"), _T("远程删片"), g_user.name, str);
- #endif
- }
- else if (m_branch != "")
- {
- if (GetBranchPhotoPath(m_branch) == "")return;
- str.Format("是否同步删除分店 %s 的照片?", m_branch);
- if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
- CString sql = "deletephotos";
- if (m_mode == 1)//拍照
- sql += "0";
- else if (m_mode == 2)//初修
- sql += "1";
- else if (m_mode == 3)//精修
- sql += "2";
- else if (m_mode == 5)//设计
- sql += "3";
- sql += m_id;
- sql += ";";
- CString jd;
- if (m_mode == 1)
- { //拍照,加景点
- CString file2 = m_path;
- int pos = file2.Find(m_id);
- pos += m_id.GetLength();
- int pos2 = file2.ReverseFind('\\');
- if (pos2 > pos)
- {
- jd = file2.Mid(pos + 1, pos2 - pos - 1);
- }
- }
- sql += "all";
- sql += jd;
- g_sendhead.bsql = 1;
- g_branchip = GetIP(m_branch);
- g_pMainWnd->OnDisconnect();
- g_branchname = m_branch;
- g_bBranchModify = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
- if (g_bSendOK == 0)return;
- AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
- #if 1//Jeff add;
- CString strDelContent;
- if (m_mode == 1)
- str += "原片";
- else if (m_mode == 2)
- str += "初修片";
- else if (m_mode == 3)
- str += "精修片";
- else if (m_mode == 5)
- str += "设计片";
- strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
- WriteLog(_T("普通日志"), _T("远程删片"), g_user.name, str);
- #endif
- }
- }
- void ShowPic::OnBUTdel() // 删除按钮;
- {
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- AfxMessageBox("请先选中您要删除的照片!", MB_ICONINFORMATION);
- return;
- }
- if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
- CStringArray delarray;
- int nDelCount = 0; // Jeff add:被删除的相片数量;
- CString strDelContent; // Jeff add:删除操作的日志内容;
- //CStringArray strDelArray; // Jeff add:被删除的相片名称;
- while (pos)
- {
- int iItem = m_List1.GetNextSelectedItem(pos);
- CString title = m_List1.GetItemText(iItem, 0);
- #if 0// Jeff.
- ::DeleteFile(m_path+title+".jpg");
- ::DeleteFile(m_path+title+".NEF");
- ::DeleteFile(m_path+title+".CR2");
- ::DeleteFile(m_path+title+".raw");
- #else
- // log的内容字段长度有限,写不下这么多文字;
- // 被删除的文件名不记录,只记录删除的张数;
- /* if(::DeleteFile(m_path+title+".jpg"))
- strDelArray.Add(title+".jpb");
- if(::DeleteFile(m_path+title+".NEF"))
- strDelArray.Add(title+".NEF");
- if(::DeleteFile(m_path+title+".CR2"))
- strDelArray.Add(title+".CR2");
- if(::DeleteFile(m_path+title+".raw"))
- strDelArray.Add(title+".raw");*/
- ::DeleteFile(m_path + title + ".jpg");
- ::DeleteFile(m_path + title + ".NEF");
- ::DeleteFile(m_path + title + ".CR2");
- ::DeleteFile(m_path + title + ".raw");
- nDelCount++;
- #endif
- int pos = title.ReverseFind('\\');
- if (pos != -1)
- {
- ::DeleteFile(m_path + title.Left(pos + 1) + "s" + title.Right(title.GetLength() - pos - 1) + ".jpg");
- ::DeleteFile(m_path + title.Left(pos + 1) + "m" + title.Right(title.GetLength() - pos - 1) + ".jpg");
- }
- else
- {
- ::DeleteFile(m_path + "s" + title + ".jpg");
- ::DeleteFile(m_path + "m" + title + ".jpg");
- }
- if (m_mode == 1 && g_branchname != "")
- { //拍照,加景点
- CString file2 = m_path + title;
- int pos = file2.Find(m_id);
- pos += m_id.GetLength();
- int pos2 = file2.ReverseFind('\\');
- CString jd;
- if (pos2 > pos)
- {
- jd = file2.Mid(pos + 1, pos2 - pos - 1);
- }
- CString task;
- if (jd != "")
- task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
- else
- task = file2.Right(file2.GetLength() - pos2 - 1);
- delarray.Add(task);
- }
- else
- {
- delarray.Add(title);
- }
- }
- LoadPhotos();
- #if 0//Jeff.
- CString str;
- str="删除客人";
- str+=m_name;
- str+=m_id;
- if(m_mode==1)
- str+="原片";
- else if(m_mode==2)
- str+="初修片";
- else if(m_mode==3)
- str+="精修片";
- else if(m_mode==5)
- str+="设计片";
- WriteLog(str);
- #else
- CString str;
- if (m_mode == 1)
- str += "原片";
- else if (m_mode == 2)
- str += "初修片";
- else if (m_mode == 3)
- str += "精修片";
- else if (m_mode == 5)
- str += "设计片";
- strDelContent.Format("删除%s, 订单号%s的%s:共删除%d张", m_name, m_id, str, nDelCount);
- WriteLog(_T("普通日志"), _T("删除相片"), g_user.name, str);
- strDelContent = str;
- #endif
- if (delarray.GetSize() && g_branchname != "")
- {
- str.Format("是否同步删除分店 %s 的照片?", g_branchname);
- if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
- CString sql = "deletephotos";
- if (m_mode == 1)//拍照
- sql += "0";
- else if (m_mode == 2)//初修
- sql += "1";
- else if (m_mode == 3)//精修
- sql += "2";
- else if (m_mode == 5)//设计
- sql += "3";
- sql += m_id;
- sql += ";";
- for (int i = 0; i < delarray.GetSize(); i++)
- {
- sql += delarray.ElementAt(i);
- sql += ",";
- }
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
- AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
- #if 1//Jeff add;
- if (m_mode == 1)
- str += "原片";
- else if (m_mode == 2)
- str += "初修片";
- else if (m_mode == 3)
- str += "精修片";
- else if (m_mode == 5)
- str += "设计片";
- strDelContent.Format("客人%s,订单号%s的分店%s的%s被同步删除", m_name, m_id, g_branchname, str);
- WriteLog(_T("普通日志"), _T("删除相片"), g_user.name, str);
- #endif
- }
- else if (delarray.GetSize() && m_branch != "")
- {
- if (GetBranchPhotoPath(m_branch) == "")return;
- str.Format("是否同步删除分店 %s 的照片?", m_branch);
- if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
- CString sql = "deletephotos";
- if (m_mode == 1)//拍照
- sql += "0";
- else if (m_mode == 2)//初修
- sql += "1";
- else if (m_mode == 3)//精修
- sql += "2";
- else if (m_mode == 5)//设计
- sql += "3";
- sql += m_id;
- sql += ";";
- for (int i = 0; i < delarray.GetSize(); i++)
- {
- sql += delarray.ElementAt(i);
- sql += ",";
- }
- g_sendhead.bsql = 1;
- g_branchip = GetIP(m_branch);
- g_pMainWnd->OnDisconnect();
- g_branchname = m_branch;
- g_bBranchModify = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
- if (g_bSendOK == 0)return;
- AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
- #if 1//Jeff add;
- if (m_mode == 1)
- str += "原片";
- else if (m_mode == 2)
- str += "初修片";
- else if (m_mode == 3)
- str += "精修片";
- else if (m_mode == 5)
- str += "设计片";
- strDelContent.Format("客人%s,订单号%s的分店%s的%s被同步删除", m_name, m_id, g_branchname, str);
- WriteLog(_T("普通日志"), _T("远程删片"), g_user.name, str);
- #endif
- }
- }
- extern void SaveTaskPath(CString path);
- void ShowPic::OnBUTupload() //上传照片;
- {
- if (1)//g_branchname=="")
- {
- OnBUTupload2();
- return;
- }
- // ZipTypeDlg dlg;
- // dlg.DoModal ();
- CString m_sel;
- if (m_mode == 1)//拍照
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
- }
- else if (m_mode == 2)//初修
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
- }
- else if (m_mode == 3)//精修
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
- }
- else if (m_mode == 5)//设计
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
- }
- CStringArray m_uploadtaskarray;
- m_uploadtaskarray.Add(m_id + ";" + m_name);
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add(m_sel);
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- MyLock lock("uploadtaskaccess");
- CFile fp;
- CString pathdir = m_path + "uploadtask";
- {
- int pos = pathdir.Find(m_id);
- pos += m_id.GetLength();
- int pos2 = pathdir.ReverseFind('\\');
- pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
- }
- CString path;
- int taskpos = 1;
- CStringArray m_olduploadtaskarray;
- for (int i = 0; i < 200; i++)
- {
- path.Format("%s%d.dat", pathdir, i + 1);
- if (PathFileExists(path))
- {
- CFile fp;
- if (fp.Open(path, CFile::modeRead))
- {
- DWORD length = fp.GetLength();
- if (!length)continue;
- CStringArray m_array;
- CArchive ar(&fp, CArchive::load);
- m_array.Serialize(ar);
- fp.Close();
- for (int j = 10; j < m_array.GetSize(); j += 2)
- {
- m_olduploadtaskarray.Add(m_array.ElementAt(j));
- }
- }
- }
- }
- BOOL bexist = 0;
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- AfxMessageBox("请选择您要上传的文件!"); return;
- }
- else
- {
- while (pos)
- {
- int iItem = m_List1.GetNextSelectedItem(pos);
- CString title = m_List1.GetItemText(iItem, 0);
- CString file2 = m_path + title + ".jpg";
- if (m_mode == 1)
- { //拍照,加景点
- int pos = file2.Find(m_id);
- pos += m_id.GetLength();
- int pos2 = file2.ReverseFind('\\');
- CString jd;
- if (pos2 > pos)
- {
- jd = file2.Mid(pos + 1, pos2 - pos - 1);
- }
- CString task;
- if (jd != "")
- task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
- else
- task = file2.Right(file2.GetLength() - pos2 - 1);
- if (::FindArray(&m_olduploadtaskarray, task) == -1)
- {
- m_uploadtaskarray.Add(task);
- m_uploadtaskarray.Add("");
- }
- else
- bexist = 1;
- }
- else
- {
- if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
- {
- m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
- m_uploadtaskarray.Add("");
- }
- else
- bexist = 1;
- }
- }
- }
- if (m_uploadtaskarray.GetSize() > 10)
- {
- CFile fp;
- CString path;
- int taskpos = 1;
- path.Format("%s%d.dat", pathdir, taskpos);
- CString dir = path.Left(path.ReverseFind('\\') + 1);
- pathdir = g_path1 + "\\上传任务\\";
- ::CreateDirectory(pathdir, NULL);
- path.Format("%s%d.dat", pathdir, taskpos);
- while (PathFileExists(path))
- {
- taskpos++;
- path.Format("%s%d.dat", pathdir, taskpos);
- }
- fp.Open(path, CFile::modeCreate | CFile::modeWrite);
- CArchive ar(&fp, CArchive::store);
- m_uploadtaskarray.SetAt(4, dir);
- m_uploadtaskarray.Serialize(ar);
- ar.Close();
- fp.Close();
- // SaveTaskPath(path);
- }
- if (bexist)
- AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
- else
- AfxMessageBox("保存上传任务成功!");
- }
- void ShowPic::OnBUTselall()
- {
- for (int i = 0; i < m_List1.GetItemCount(); i++)
- m_List1.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
- }
- void ShowPic::OnSelchangeCombo2()
- {
- int pos = m_combobranch.GetCurSel();
- if (pos == -1)return;
- CString str;
- m_combobranch.GetLBText(pos, str);
- if (m_mode == 4)//礼服
- {
- m_type = str;
- LoadPhotos();
- return;
- }
- GetDlgItem(IDC_BUTupload)->SetWindowText("上传至" + str);
- GetDlgItem(IDC_BUTupload)->Invalidate();
- }
- void ShowPic::OnBUTupload2()
- {
- int combopos = m_combobranch.GetCurSel();
- if (combopos == -1)
- {
- AfxMessageBox("请选择您要上传到的分店!");
- return;
- }
- CString domain = m_iparray.ElementAt(combopos);
- CString savedomain;
- if (m_branch != "")
- {
- savedomain = GetDomainFromBranch(m_branch);
- }
- else
- {
- savedomain = GetDomainFromBranch(g_branchname);
- if (g_branchname == "")
- savedomain = g_brancharray.ElementAt(g_brancharray.GetSize() - 1).ElementAt(2);
- }
- // ZipTypeDlg dlg;
- // dlg.DoModal ();
- CString m_sel;
- if (m_mode == 1)//拍照
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
- }
- else if (m_mode == 2)//初修
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
- }
- else if (m_mode == 3)//精修
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
- }
- else if (m_mode == 5)//设计
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
- }
- CStringArray m_uploadtaskarray;
- m_uploadtaskarray.Add(m_id + ";" + m_name);
- m_uploadtaskarray.Add(domain);
- m_uploadtaskarray.Add(savedomain);
- m_uploadtaskarray.Add(m_sel);
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- MyLock lock("uploadtaskaccess");
- CFile fp;
- CString pathdir = m_path + "uploadtask";
- {
- int pos = pathdir.Find(m_id);
- pos += m_id.GetLength();
- int pos2 = pathdir.ReverseFind('\\');
- pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
- }
- CString path;
- int taskpos = 1;
- CStringArray m_olduploadtaskarray;
- for (int i = 0; i < 200; i++)
- {
- path.Format("%s%d.dat", pathdir, i + 1);
- if (PathFileExists(path))
- {
- CFile fp;
- if (fp.Open(path, CFile::modeRead))
- {
- DWORD length = fp.GetLength();
- if (!length)continue;
- CStringArray m_array;
- CArchive ar(&fp, CArchive::load);
- m_array.Serialize(ar);
- fp.Close();
- if (domain != m_array.ElementAt(1))continue;
- for (int j = 10; j < m_array.GetSize(); j += 2)
- {
- m_olduploadtaskarray.Add(m_array.ElementAt(j));
- }
- }
- }
- }
- BOOL bexist = 0;
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- AfxMessageBox("请选择您要上传的文件!"); return;
- }
- else
- {
- while (pos)
- {
- int iItem = m_List1.GetNextSelectedItem(pos);
- CString title = m_List1.GetItemText(iItem, 0);
- CString file2 = m_path + title + ".jpg";
- if (m_mode == 1)
- { //拍照,加景点
- int pos = file2.Find(m_id);
- pos += m_id.GetLength();
- int pos2 = file2.ReverseFind('\\');
- CString jd;
- if (pos2 > pos)
- {
- jd = file2.Mid(pos + 1, pos2 - pos - 1);
- }
- CString task;
- if (jd != "")
- task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
- else
- task = file2.Right(file2.GetLength() - pos2 - 1);
- if (::FindArray(&m_olduploadtaskarray, task) == -1)
- {
- m_uploadtaskarray.Add(task);
- m_uploadtaskarray.Add("");
- }
- else
- bexist = 1;
- }
- else
- {
- if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
- {
- m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
- m_uploadtaskarray.Add("");
- }
- else
- bexist = 1;
- }
- }
- }
- if (m_uploadtaskarray.GetSize() > 10)
- {
- CFile fp;
- CString path;
- int taskpos = 1;
- path.Format("%s%d.dat", pathdir, taskpos);
- CString dir = path.Left(path.ReverseFind('\\') + 1);
- pathdir = g_path1 + "\\上传任务\\";
- ::CreateDirectory(pathdir, NULL);
- path.Format("%s%d.dat", pathdir, taskpos);
- while (PathFileExists(path))
- {
- taskpos++;
- path.Format("%s%d.dat", pathdir, taskpos);
- }
- fp.Open(path, CFile::modeCreate | CFile::modeWrite);
- CArchive ar(&fp, CArchive::store);
- m_uploadtaskarray.SetAt(4, dir);
- m_uploadtaskarray.Serialize(ar);
- ar.Close();
- fp.Close();
- // SaveTaskPath(path);
- }
- if (bexist)
- AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
- else
- AfxMessageBox("保存上传任务成功!");
- }
- void ShowPic::OnBUTSetDesignNo()
- {
- SetDesignNo dlg;
- dlg.m_id = m_id;
- dlg.DoModal();
- }
- void ShowPic::OnBUTexport() // 只有在设计时,才会有这个导出相片按钮;
- {
- if (IsHasRights2new(12) == 0)return;
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- AfxMessageBox("请先选中您要导出的照片!", MB_ICONINFORMATION);
- return;
- }
- CStringArray saExportImage; // 被导出的相片路径数组;
- CString strExportDirectory; // 相片导出的路径;
- GetSavePath(strExportDirectory);
- if (strExportDirectory.IsEmpty())
- {
- return;
- }
- strExportDirectory.TrimRight('\\');
- strExportDirectory += "\\";
- strExportDirectory += m_id;
- strExportDirectory += m_name2;
- strExportDirectory += "设计好的片修";
- strExportDirectory += "\\";
- ::CreateDirectory(strExportDirectory, NULL);
- CStringArray desarray;
- CStringArray dirarray;
- CString str, str2;
- int pos2;
- while (pos)
- {
- int iItem = m_List1.GetNextSelectedItem(pos);
- str = m_List1.GetItemText(iItem, 0);
- str = m_path + str + ".jpg";
- saExportImage.Add(str);
- str2 = strExportDirectory + m_List1.GetItemText(iItem, 0) + ".jpg";
- desarray.Add(str2);
- str2 = "";
- str = m_List1.GetItemText(iItem, 0);
- pos2 = str.Find("\\");
- while (pos2 != -1)
- {
- str2 += str.Left(pos2) + "\\";
- if (::FindArray(&dirarray, str2) == -1)
- {
- dirarray.Add(str2);
- ::CreateDirectory(strExportDirectory + str2, NULL);
- }
- str = str.Right(str.GetLength() - pos2 - 1);
- pos2 = str.Find("\\");
- }
- }
- CStdioFile fp;
- fp.Open(strExportDirectory + "客户要求.txt", CFile::modeCreate | CFile::modeWrite);
- fp.WriteString(remark);
- fp.Close();
- //----------------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------------
- // 在设计时,导出查看的设计片;
- //----------------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------------
- ImportPhoto dlg;
- dlg.m_mode = 1; // 1.未知;
- dlg.m_pArray = &saExportImage; // 2.作为导出源的设计片的路径集合;
- dlg.m_pDesArray = &desarray; // 3.作为导出目标的设计片的路径集合;
- dlg.m_savepath = strExportDirectory; // 4.保存导出查看的设计片的目录;
- dlg.DoModal();
- AfxMessageBox("导片成功!", MB_ICONINFORMATION);
- // CString str;
- str = " 导出设计片 ";
- str += "客人:";
- str += m_name + m_id;
- WriteLog(_T("普通日志"), _T("导出设计片"), g_user.name, str);
- }
|