12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010 |
- // ShowPic3.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "ShowPic3.h"
- #include "ShowPic22.h"
- #include "JPEG.h"
- #include "MyLock.h"
- #define THUMBNAIL_WIDTH 100
- #define THUMBNAIL_HEIGHT 90
- ShowPic3::ShowPic3(CWnd* pParent /*=NULL*/) : CDialog(ShowPic3::IDD, pParent)
- {
- m_bTerminate = false;
- m_hThread = NULL;
- m_hEvent = NULL;
- }
- void ShowPic3::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(ShowPic3)
- DDX_Control(pDX, IDC_LIST2, m_List2);
- DDX_Control(pDX, IDC_LIST1, m_List1);
- //}}AFX_DATA_MAP
- DDX_Control(pDX, IDC_COMBO1, m_combobox);
- }
- BEGIN_MESSAGE_MAP(ShowPic3, CDialog)
- //{{AFX_MSG_MAP(ShowPic3)
- ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
- ON_WM_DESTROY()
- ON_BN_CLICKED(IDC_BUTdelall, OnBUTdelall)
- ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
- ON_LBN_SELCHANGE(IDC_LIST2, OnSelchangeList2)
- ON_BN_CLICKED(IDC_BTNshow1, OnBTNshow1)
- ON_BN_CLICKED(IDC_BTNshow2, OnBTNshow2)
- ON_BN_CLICKED(IDC_BTNshow3, OnBTNshow3)
- ON_BN_CLICKED(IDC_BTNshow4, OnBTNshow4)
- ON_BN_CLICKED(IDC_BUTdel1, OnBUTdel1)
- ON_BN_CLICKED(IDC_BUTdel2, OnBUTdel2)
- ON_BN_CLICKED(IDC_BUTdel3, OnBUTdel3)
- ON_BN_CLICKED(IDC_BUTdel4, OnBUTdel4)
- //}}AFX_MSG_MAP
- ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
- ON_BN_CLICKED(Btn_NextOne, OnBnClickedNextone)
- ON_MESSAGE(OWNER_MSG_SHOWPHOTO, ShowPhoto2Found)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // ShowPic3 message handlers
- BOOL ShowPic3::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CRect rc, rc2;
- GetWindowRect(rc2);
- ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
- GetClientRect(rc);
- m_List2.GetWindowRect(rc2);
- ScreenToClient(rc2);
- int dt = rc2.left;
- rc2.bottom = rc.bottom - dt;
- m_List2.MoveWindow(rc2);
- m_List1.GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.bottom = rc.bottom - dt;
- rc2.right = rc.right - dt;
- m_List1.MoveWindow(rc2);
- #if JEFF_TEST_ON
- CString strFilters = _T("[status3] = 'OK'");
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 217; // case 217:dindan表;
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strFilters);
- #else
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 217; // case 217:dindan表;
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(1);
- #endif
- if (g_bSendOK == 0)
- {
- CDialog::OnCancel();
- return 0;
- }
- DataToArray(&g_List1array);
- LoadPhotos();// Jeff.获取客户原片里的所有订单文件夹名称;
- CString str;
- for (int i = 0; i < g_List1array.GetSize(); i++)
- {
- str = g_List1array.ElementAt(i).ElementAt(0); // Jeff.nIndex==0,为订单号id;
- if (FindArray(&m_dirarray1, str) == -1)
- {
- if (FindArray(&m_dirarray2, str) == -1)
- {
- if (FindArray(&m_dirarray3, str) == -1)
- {
- if (FindArray(&m_dirarray4, str) == -1)
- {
- continue;
- }
- }
- }
- }
- str += "\r\n";
- str += g_List1array.ElementAt(i).ElementAt(1); // Jeff.nIndex==1,为订单客户1;
- str += g_List1array.ElementAt(i).ElementAt(2); // Jeff.nIndex==2,为订单客户2;
- m_strArrayName.Add(str);
- m_combobox.AddString(g_List1array.ElementAt(i).ElementAt(1) + g_List1array.ElementAt(i).ElementAt(2));
- if (m_List2.GetCount() % 2)
- m_List2.AddEntry(str, g_gridcol1, m_List2.GetCount());
- else
- m_List2.AddEntry(str, g_gridcol2, m_List2.GetCount());
- }
- m_List2.Invalidate();
- m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
- m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
- return TRUE;
- }
- /************************************************************************/
- /*
- 显示相片时,相片路径订单号以上的字符串去除,只留下景点名;
- */
- /************************************************************************/
- DWORD ShowPic3::LoadThumbNail20(LPVOID lpParam)
- {
- try
- {
- ShowPic3 *pDlg = (ShowPic3*)lpParam;
- CListCtrl *ListCtrl = &pDlg->m_List1;
- CImageList* pImgList = &pDlg->m_ImageListThumb;
- for (int i = 0; i < pImgList->GetImageCount(); i++)
- pImgList->Remove(i);
- ListCtrl->DeleteAllItems();
- ListCtrl->Invalidate();
- pImgList->SetImageCount(pDlg->m_vFileName.GetSize());
- 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;
- INT xIndex = 0;
- for (nIndex = 0;!pDlg->m_bTerminate && nIndex < pDlg->m_vFileName.GetSize(); nIndex++)
- {
- CString str, spath; // 这两个变量放在for外面,会有内存泄漏,但在for内部就不会有;
- #ifdef USE_KERNEL_DLL
- str = pDlg->m_vFileName.ElementAt(nIndex);
- xIndex = str.Find(pDlg->m_strOrderNumber);
- if ( xIndex != -1 )
- {
- str = str.Mid( xIndex + pDlg->m_strOrderNumber.GetLength() + 1);
- xIndex = str.ReverseFind(_T('.'));
- if ( xIndex != -1 )
- str = str.Left(xIndex);
- }
- #else
- 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);
- #endif
- ListCtrl->InsertItem(nIndex, str, nIndex);
- }
- if ( pDlg->m_bTerminate )
- {
- pDlg->m_bTerminate = false;
- return 0;
- }
- 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 ( nIndex = 0; !pDlg->m_bTerminate && nIndex < pDlg->m_vFileName.GetSize(); nIndex++ )
- {
- CString str, spath;
- // Load Image File
- Image *image = NULL;
- Bitmap *pBmp = NULL;
- //str = *iter;
- str = pDlg->m_vFileName.ElementAt(nIndex);
- if ( !PathFileExists(str) )
- continue;
- 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);
- if (image)
- 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);
- if (pBmp)
- delete pBmp;
- // Redraw only a current item for removing flickering and fast speed.
- ListCtrl->RedrawItems(nIndex, nIndex);
- // Release used DC and Object
- }
- if ( !pDlg->m_bTerminate )ListCtrl->Invalidate();
- pDlg->m_bTerminate = false;
- return 0;
- }
- catch (...)
- {
- }
- return 0;
- }
- void ShowPic3::LoadThumbImages()
- {
- TerminateThread();
- WriteTextLog(_T("开始线程"));
- if ( m_hThread == NULL )
- {
- m_bTerminate = false;
- m_hThread = CreateThread(NULL, 0, LoadThumbNail20, this, 0, NULL);
- }
- }
- BOOL ShowPic3::TerminateThread()
- {
- #ifdef USE_KERNEL_DLL
- if ( m_hThread )
- {
- // 标记退出窗口;
- m_bTerminate = TRUE;
- // 不能INFINITE,因为主窗口线程死等,子线程控件就无法响应操作;
- while (WaitForSingleObject(m_hThread, 100) == WAIT_OBJECT_0)
- {
- CloseHandle(m_hThread);
- WriteTextLog(_T("线程结束"));
- }
- m_hThread = NULL;
- }
- return TRUE;
- #else
- 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;
- #endif
- }
- void ShowPic3::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
- {
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- return;
- }
- int iItem = m_List1.GetNextSelectedItem(pos);
- ShowPic22 dlg;
- dlg.m_nCurImgPos = iItem;
- dlg.m_pAryImgPath = &m_patharray1;
- dlg.DoModal();
- *pResult = 0;
- }
- void ShowPic3::OnDestroy()
- {
- TerminateThread();
- //m_vFileName.clear();
- m_vFileName.RemoveAll();
- CDialog::OnDestroy();
- }
- void ShowPic3::LoadPhotos()
- {
- CString str;
- #ifdef USE_KERNEL_DLL
- HGLOBAL hMemery;
- DWORD dwMemSize = 0;
- if ( g_pIMGProcess == NULL )
- return;
- hMemery = g_pIMGProcess->GetBranchAllOrderDirectory(OImgtype, g_domain.IsEmpty() ? g_branchname : g_domain, dwMemSize);
- if ( hMemery )
- {
- BYTE *pData = (BYTE*)GlobalLock(hMemery);
- CMemFile mf;
- mf.Attach(pData, dwMemSize);
- CArchive ar(&mf, CArchive::load);
- CStringArray Arypath;
- Arypath.Serialize(ar);
- ar.Close();
- mf.Detach();
- GlobalUnlock(hMemery);
- GlobalFree(hMemery);
- INT nCount = Arypath.GetSize();
- for ( int i = 0; i < nCount; i++ )
- {
- str = Arypath.ElementAt(i);
- str.TrimRight(_T("\\"));
- str = str.Mid(str.ReverseFind(_T('\\'))+1);
- m_dirarray1.Add(str);
- }
- }
- #else
- if (1)
- {
- // printf("Jeff:g_path1=%s\n\n",g_path1);//Jeff.获取客户原片里的所有订单文件夹名称;
- using namespace helper_coffs;
- ffsco o;
- o.dirs(0);
- o.find(LPCSTR(g_path1), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (str == g_path1 + "\\")continue;
- str.TrimRight("\\");
- str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- // printf("Jeff:str=%s\n\n",str);
- m_dirarray1.Add(str);
- }
- }
- #endif
- return;
- }
- void ShowPic3::OnBUTdel()
- {
- }
- void ShowPic3::OnSelchangeList2()
- {
- UpdateData();
- int pos = m_List2.GetCurSel();
- if (pos == -1)return;
- CString str;
- m_List2.GetText(pos, str);
- pos = str.Find("\r\n");
- if (pos == -1)return;;
- m_strOrderNumber = str.Left(pos);
- m_strOrderNumber.MakeLower();
- ShowPhoto1();
- if (m_patharray1.GetSize() == 0)OnBTNshow2();
- if (m_patharray1.GetSize() == 0)OnBTNshow3();
- if (m_patharray1.GetSize() == 0)OnBTNshow4();
- }
- void ShowPic3::ShowPhoto1() // 查看原片;
- {
- if (m_strOrderNumber == _T(""))
- {
- AfxMessageBox(_T("请先选中客人!"), MB_ICONINFORMATION); return;
- }
- #ifdef USE_KERNEL_DLL
- ShowOrderImg(OImgtype);
- #else
- CString str;
- m_path = g_path1 + "\\" + m_strOrderNumber + "\\";
- m_patharray1.RemoveAll();
- if (1)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- 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();
- 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();
- #endif
- }
- void ShowPic3::ShowPhoto2() // 查看初修片;
- {
- #ifdef USE_KERNEL_DLL
- ShowOrderImg(EImgtype);
- #else
- if (m_strOrderNumber == "")
- {
- AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
- }
- CString str;
- m_path = g_path2 + "\\" + m_strOrderNumber + "\\";
- m_patharray1.RemoveAll();
- if (1)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- 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();
- 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();
- #endif
- }
- void ShowPic3::ShowPhoto3() // 查看精修片;
- {
- #ifdef USE_KERNEL_DLL
- ShowOrderImg(FImgtype);
- #else
- if (m_strOrderNumber == "")
- {
- AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
- }
- CString str;
- m_path = g_path3 + "\\" + m_strOrderNumber + "\\";
- m_patharray1.RemoveAll();
- if (1)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- 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();
- 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();
- #endif
- }
- void ShowPic3::ShowPhoto4() // 查看设计片;
- {
- #ifdef USE_KERNEL_DLL
- ShowOrderImg(DImgtype);
- #else
- if (m_strOrderNumber == "")
- {
- AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
- }
- CString str;
- m_path = g_path4 + "\\" + m_strOrderNumber + "\\";
- m_patharray1.RemoveAll();
- if (1)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- 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();
- 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();
- #endif
- }
- void ShowPic3::OnBTNshow1()
- {
- ShowPhoto1();
- }
- void ShowPic3::OnBTNshow2()
- {
- ShowPhoto2();
- }
- void ShowPic3::OnBTNshow3()
- {
- ShowPhoto3();
- }
- void ShowPic3::OnBTNshow4()
- {
- ShowPhoto4();
- }
- void ShowPic3::OnBUTdelall() // 全部删除;
- {
- if (m_strOrderNumber == _T(""))
- {
- AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
- }
- if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
- WriteLog(_T("客照删除"), _T(" 客照管理中心:") + m_strOrderNumber + _T(":全部相片被删除"));
- #ifdef USE_KERNEL_DLL
- CStringArray AryOrderpath;
- GetOrderpathByOrderNum(OImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
- GetOrderpathByOrderNum(EImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
- GetOrderpathByOrderNum(FImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
- GetOrderpathByOrderNum(DImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
- for ( int i = 0; i < AryOrderpath.GetSize(); i++ )
- {
- DeleteDirectory(AryOrderpath.ElementAt(i));
- }
- OnBTNshow1();
- #else
- DeleteDirectory(g_path1 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单原片;
- DeleteDirectory(g_path2 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单初修;
- DeleteDirectory(g_path3 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单精修;
- DeleteDirectory(g_path4 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单设计;
- OnBTNshow1();
- #endif
- }
- void ShowPic3::OnBUTdel1() // 原片删除按钮;
- {
- if (m_strOrderNumber == "")
- {
- AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
- }
- if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
- WriteLog(_T("原片删除"), _T(" 客照管理中心:") + m_strOrderNumber + _T(":原片被删除"));
- #ifdef USE_KERNEL_DLL
- CStringArray AryOrderpath;
- GetOrderpathByOrderNum(OImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
- for ( int i = 0; i < AryOrderpath.GetSize(); i++ )
- {
- DeleteDirectory(AryOrderpath.ElementAt(i));
- }
- #else
- DeleteDirectory(g_path1 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单原片;
- #endif
- OnBTNshow1();
- }
- void ShowPic3::OnBUTdel2() // 初修删除按钮;
- {
- if (m_strOrderNumber == "")
- {
- AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
- }
- if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
- WriteLog(_T("初修删除"), _T(" 客照管理中心:") + m_strOrderNumber + _T(":初修片被删除"));
- #ifdef USE_KERNEL_DLL
- CStringArray AryOrderpath;
- GetOrderpathByOrderNum(EImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
- for ( int i = 0; i < AryOrderpath.GetSize(); i++ )
- {
- DeleteDirectory(AryOrderpath.ElementAt(i));
- }
- #else
- DeleteDirectory(g_path2 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单初修;
- #endif
- OnBTNshow2();
- }
- void ShowPic3::OnBUTdel3() // 精修删除按钮;
- {
- if (m_strOrderNumber == "")
- {
- AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
- }
- if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
- WriteLog(_T("精修删除"), _T(" 客照管理中心:") + m_strOrderNumber + _T(":精修片被删除"));
- #ifdef USE_KERNEL_DLL
- CStringArray AryOrderpath;
- GetOrderpathByOrderNum(FImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
- for ( int i = 0; i < AryOrderpath.GetSize(); i++ )
- {
- DeleteDirectory(AryOrderpath.ElementAt(i));
- }
- #else
- DeleteDirectory(g_path4 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单精修;
- #endif
- OnBTNshow3();
- }
- void ShowPic3::OnBUTdel4() // 设计片删除按钮;
- {
- if (m_strOrderNumber == "")
- {
- AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
- }
- if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
- WriteLog(_T("设计片删除"), _T(" 客照管理中心:") + m_strOrderNumber + _T(":设计片被删除"));
- #ifdef USE_KERNEL_DLL
- CStringArray AryOrderpath;
- GetOrderpathByOrderNum(DImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
- for ( int i = 0; i < AryOrderpath.GetSize(); i++ )
- {
- DeleteDirectory(AryOrderpath.ElementAt(i));
- }
- #else
- DeleteDirectory(g_path3 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单设计;
- #endif
- OnBTNshow4();
- }
- void ShowPic3::OnCbnSelchangeCombo1()
- {
- static int nIndex = 0;
- if (nIndex)
- m_List2.SetSel(nIndex, FALSE);
- int i = 0;
- int nSelCount = m_List2.GetSelCount();
- for (i = 0; i < nSelCount; i++)//去除还处于选择状态的项;
- {
- int nSelItem;
- m_List2.GetSelItems(nSelCount, &nSelItem);
- m_List2.SetSel(nSelItem, FALSE);
- }
- int nPos = m_combobox.GetCurSel();
- CString strName;
- //m_combobox.GetWindowText(strName);
- m_combobox.GetLBText(nPos, strName);
- // printf("Jeff:****当前查找内容=%s\n\n",strName);
- int nSize = m_strArrayName.GetSize();
- for (i = 0; i < nSize; i++)
- {
- CString str = m_strArrayName.ElementAt(i);
- if (str.Find(strName) != -1)
- {
- // printf("Jeff:****当前查找内容=%s\n\n",str);
- //nIndex = m_List2.SelectString(-1,str);
- nIndex = i;
- if (nIndex == LB_ERR)
- {
- break;
- }
- m_List2.SetSel(nIndex, TRUE);
- PostMessage(OWNER_MSG_SHOWPHOTO, nIndex);
- break;
- }
- }
- }
- void ShowPic3::OnBnClickedNextone()
- {
- static int nIndex = 0;
- static CString strOld = "";
- m_List2.SetSel(nIndex - 1, FALSE);
- int i = 0;
- int nSelCount = m_List2.GetSelCount();
- for (i = 0; i < nSelCount; i++)//去除还处于选择状态的项;
- {
- int nSelItem;
- m_List2.GetSelItems(nSelCount, &nSelItem);
- m_List2.SetSel(nSelItem, FALSE);
- }
- CString strFind = "";
- m_combobox.GetWindowText(strFind);
- if ( strFind.IsEmpty() )
- {
- return;
- }
- if (strOld != strFind)
- {
- strOld = strFind;
- nIndex = 0;
- }
- // printf("Jeff:当前查找内容=%s\n\n",strFind);
- CString str;
- BOOL bFind = FALSE;
- int nSize = m_strArrayName.GetSize();
- for (i = nIndex; i < nSize; i++)
- {
- str = m_strArrayName.ElementAt(i);
- // printf("Jeff:匹配内容=%s\n\n",str);
- if (str.Find(strFind) != -1)
- {
- nIndex = i;
- // printf("Jeff:nIndex=%d,找到内容=%s\n\n",i,str);
- bFind = TRUE;
- break;
- }
- }
- if (bFind == FALSE)
- {
- nIndex = 0;
- AfxMessageBox("未找到查找匹配的内容,将再次从头开始查找");
- }
- else
- {
- m_List2.SetSel(nIndex++, TRUE);
- PostMessage(OWNER_MSG_SHOWPHOTO, -1);
- }
- }
- #ifdef VC60
- void ShowPic3::ShowPhoto2Found(WPARAM wParam, LPARAM lParam)
- {
- UpdateData();
- int nPos = m_List2.GetCurSel();
- if (wParam != -1)
- nPos = wParam;
- if (nPos == -1) return;
- CString str;
- m_List2.GetText(nPos, str);
- nPos = str.Find("\r\n");
- if (nPos == -1)return;;
- m_strOrderNumber = str.Left(nPos);
- // printf("Jeff:欲显示的订单号=%s\n\n",m_strOrderNumber);
- ShowPhoto1();
- if (m_patharray1.GetSize() == 0)OnBTNshow2();
- if (m_patharray1.GetSize() == 0)OnBTNshow3();
- if (m_patharray1.GetSize() == 0)OnBTNshow4();
- }
- #else
- LRESULT ShowPic3::ShowPhoto2Found(WPARAM wParam, LPARAM lParam)
- {
- UpdateData();
- int nPos = m_List2.GetCurSel();
- if (wParam != -1)
- nPos = wParam;
- if (nPos == -1) return 0;
- CString str;
- m_List2.GetText(nPos, str);
- nPos = str.Find("\r\n");
- if (nPos == -1)return 0;
- m_strOrderNumber = str.Left(nPos);
- // printf("Jeff:欲显示的订单号=%s\n\n",m_strOrderNumber);
- ShowPhoto1();
- if (m_patharray1.GetSize() == 0)OnBTNshow2();
- if (m_patharray1.GetSize() == 0)OnBTNshow3();
- if (m_patharray1.GetSize() == 0)OnBTNshow4();
- return 0;
- }
- #endif
- #ifdef USE_KERNEL_DLL
- void ShowPic3::ShowOrderImg(IN CONST INT& nImgType)
- {
- CString str = _T("");
- DWORD dwMemSize = 0;
- m_patharray1.RemoveAll();
- //m_vFileName.clear();
- m_vFileName.RemoveAll();
- CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname);
- ImgLoadOrderpathInterface *pOrderLoader = NULL;
- if ( g_pIMGProcess == NULL )
- return ;
- g_pIMGProcess->QueryInterface(IID_ImgLoadOrderpathInterface,(void**)&pOrderLoader);
- if ( pOrderLoader )
- {
- pOrderLoader->Release();
- HGLOBAL hMemery = pOrderLoader->LoadOrderImages( nImgType, strBranchId, m_strOrderNumber, _T("*.jpg|*.jpeg"), dwMemSize);
- if ( hMemery )
- {
- BYTE *pData = (BYTE*)GlobalLock(hMemery);
- if ( pData == NULL )
- {
- GlobalUnlock(hMemery);
- GlobalFree(hMemery);
- return ;
- }
- CMemFile mf;
- mf.Attach(pData, dwMemSize);
- CArchive ar(&mf, CArchive::load);
- CStringArray Arypath;
- Arypath.Serialize(ar);
- ar.Close();
- mf.Detach();
- GlobalUnlock(hMemery);
- GlobalFree(hMemery);
- INT i = 0;
- INT nCount = Arypath.GetSize();
- for ( i = 0; i < nCount; i++ )
- {
- str = Arypath.ElementAt(i);
- if (str.Mid(str.ReverseFind(_T('\\')) + 1) == _T("ok")) continue;
- if (str.Mid(str.ReverseFind(_T('\\')) + 1) == _T("modifytime")) continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- if (str.ReverseFind(_T('.')) == -1 ) continue;
- str.MakeLower();
- m_patharray1.Add(str);
- }
- Arypath.RemoveAll();
- CStringArray *pArray = &m_patharray1;
- nCount = pArray->GetSize();
- for ( i = 0; i < nCount; i++)
- {
- CString filePath = pArray->ElementAt(i);
- filePath.MakeLower();
- m_vFileName.Add(filePath);
- }
- }
- }
- // LoadThumbImages存在CString内存泄漏;
- if (m_vFileName.GetSize())
- {
- LoadThumbImages();
- }
- else
- {
- for (int i = 0; i < m_ImageListThumb.GetImageCount(); i++)
- m_ImageListThumb.Remove(i);
- m_List1.DeleteAllItems();
- m_List1.Invalidate();
- }
- }
- #endif
- void ShowPic3::OnOK()
- {
- // TODO: 在此添加专用代码和/或调用基类
- OnBnClickedNextone();
- }
|