ShowPic3.cpp 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  1. // ShowPic3.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "ShowPic3.h"
  6. #include "ShowPic22.h"
  7. #include "JPEG.h"
  8. #include "MyLock.h"
  9. #define THUMBNAIL_WIDTH 100
  10. #define THUMBNAIL_HEIGHT 90
  11. ShowPic3::ShowPic3(CWnd* pParent /*=NULL*/) : CDialog(ShowPic3::IDD, pParent)
  12. {
  13. m_bTerminate = false;
  14. m_hThread = NULL;
  15. m_hEvent = NULL;
  16. }
  17. void ShowPic3::DoDataExchange(CDataExchange* pDX)
  18. {
  19. CDialog::DoDataExchange(pDX);
  20. //{{AFX_DATA_MAP(ShowPic3)
  21. DDX_Control(pDX, IDC_LIST2, m_List2);
  22. DDX_Control(pDX, IDC_LIST1, m_List1);
  23. //}}AFX_DATA_MAP
  24. DDX_Control(pDX, IDC_COMBO1, m_combobox);
  25. }
  26. BEGIN_MESSAGE_MAP(ShowPic3, CDialog)
  27. //{{AFX_MSG_MAP(ShowPic3)
  28. ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
  29. ON_WM_DESTROY()
  30. ON_BN_CLICKED(IDC_BUTdelall, OnBUTdelall)
  31. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  32. ON_LBN_SELCHANGE(IDC_LIST2, OnSelchangeList2)
  33. ON_BN_CLICKED(IDC_BTNshow1, OnBTNshow1)
  34. ON_BN_CLICKED(IDC_BTNshow2, OnBTNshow2)
  35. ON_BN_CLICKED(IDC_BTNshow3, OnBTNshow3)
  36. ON_BN_CLICKED(IDC_BTNshow4, OnBTNshow4)
  37. ON_BN_CLICKED(IDC_BUTdel1, OnBUTdel1)
  38. ON_BN_CLICKED(IDC_BUTdel2, OnBUTdel2)
  39. ON_BN_CLICKED(IDC_BUTdel3, OnBUTdel3)
  40. ON_BN_CLICKED(IDC_BUTdel4, OnBUTdel4)
  41. //}}AFX_MSG_MAP
  42. ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
  43. ON_BN_CLICKED(Btn_NextOne, OnBnClickedNextone)
  44. ON_MESSAGE(OWNER_MSG_SHOWPHOTO, ShowPhoto2Found)
  45. END_MESSAGE_MAP()
  46. /////////////////////////////////////////////////////////////////////////////
  47. // ShowPic3 message handlers
  48. BOOL ShowPic3::OnInitDialog()
  49. {
  50. CDialog::OnInitDialog();
  51. CRect rc, rc2;
  52. GetWindowRect(rc2);
  53. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  54. GetClientRect(rc);
  55. m_List2.GetWindowRect(rc2);
  56. ScreenToClient(rc2);
  57. int dt = rc2.left;
  58. rc2.bottom = rc.bottom - dt;
  59. m_List2.MoveWindow(rc2);
  60. m_List1.GetWindowRect(rc2);
  61. ScreenToClient(rc2);
  62. rc2.bottom = rc.bottom - dt;
  63. rc2.right = rc.right - dt;
  64. m_List1.MoveWindow(rc2);
  65. #if JEFF_TEST_ON
  66. CString strFilters = _T("[status3] = 'OK'");
  67. g_sendhead.bsql = 0;
  68. g_sendhead.code[0] = 217; // case 217:dindan表;
  69. g_sendhead.tabcount = 1;
  70. g_pMainWnd->ProcessChatMessageRequest2(strFilters);
  71. #else
  72. g_sendhead.bsql = 0;
  73. g_sendhead.code[0] = 217; // case 217:dindan表;
  74. g_sendhead.tabcount = 1;
  75. g_pMainWnd->ProcessChatMessageRequest2(1);
  76. #endif
  77. if (g_bSendOK == 0)
  78. {
  79. CDialog::OnCancel();
  80. return 0;
  81. }
  82. DataToArray(&g_List1array);
  83. LoadPhotos();// Jeff.获取客户原片里的所有订单文件夹名称;
  84. CString str;
  85. for (int i = 0; i < g_List1array.GetSize(); i++)
  86. {
  87. str = g_List1array.ElementAt(i).ElementAt(0); // Jeff.nIndex==0,为订单号id;
  88. if (FindArray(&m_dirarray1, str) == -1)
  89. {
  90. if (FindArray(&m_dirarray2, str) == -1)
  91. {
  92. if (FindArray(&m_dirarray3, str) == -1)
  93. {
  94. if (FindArray(&m_dirarray4, str) == -1)
  95. {
  96. continue;
  97. }
  98. }
  99. }
  100. }
  101. str += "\r\n";
  102. str += g_List1array.ElementAt(i).ElementAt(1); // Jeff.nIndex==1,为订单客户1;
  103. str += g_List1array.ElementAt(i).ElementAt(2); // Jeff.nIndex==2,为订单客户2;
  104. m_strArrayName.Add(str);
  105. m_combobox.AddString(g_List1array.ElementAt(i).ElementAt(1) + g_List1array.ElementAt(i).ElementAt(2));
  106. if (m_List2.GetCount() % 2)
  107. m_List2.AddEntry(str, g_gridcol1, m_List2.GetCount());
  108. else
  109. m_List2.AddEntry(str, g_gridcol2, m_List2.GetCount());
  110. }
  111. m_List2.Invalidate();
  112. m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  113. m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
  114. return TRUE;
  115. }
  116. /************************************************************************/
  117. /*
  118. 显示相片时,相片路径订单号以上的字符串去除,只留下景点名;
  119. */
  120. /************************************************************************/
  121. DWORD ShowPic3::LoadThumbNail20(LPVOID lpParam)
  122. {
  123. try
  124. {
  125. ShowPic3 *pDlg = (ShowPic3*)lpParam;
  126. CListCtrl *ListCtrl = &pDlg->m_List1;
  127. CImageList* pImgList = &pDlg->m_ImageListThumb;
  128. for (int i = 0; i < pImgList->GetImageCount(); i++)
  129. pImgList->Remove(i);
  130. ListCtrl->DeleteAllItems();
  131. ListCtrl->Invalidate();
  132. pImgList->SetImageCount(pDlg->m_vFileName.GetSize());
  133. TCHAR path[MAX_PATH];
  134. vector<CString>::iterator iter;
  135. // Set redraw to FALSE to avoid flickering during adding new items
  136. ListCtrl->SetRedraw(FALSE);
  137. int nIndex = 0;
  138. INT xIndex = 0;
  139. for (nIndex = 0;!pDlg->m_bTerminate && nIndex < pDlg->m_vFileName.GetSize(); nIndex++)
  140. {
  141. CString str, spath; // 这两个变量放在for外面,会有内存泄漏,但在for内部就不会有;
  142. #ifdef USE_KERNEL_DLL
  143. str = pDlg->m_vFileName.ElementAt(nIndex);
  144. xIndex = str.Find(pDlg->m_strOrderNumber);
  145. if ( xIndex != -1 )
  146. {
  147. str = str.Mid( xIndex + pDlg->m_strOrderNumber.GetLength() + 1);
  148. xIndex = str.ReverseFind(_T('.'));
  149. if ( xIndex != -1 )
  150. str = str.Left(xIndex);
  151. }
  152. #else
  153. str = *iter;
  154. spath.Empty();
  155. if (str.Left(str.ReverseFind('\\') + 1) != pDlg->m_path)
  156. {
  157. spath = str.Left(str.ReverseFind('\\') + 1);
  158. spath = spath.Right(spath.GetLength() - pDlg->m_path.GetLength());
  159. }
  160. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  161. str = spath + str.Left(str.GetLength() - 4);
  162. #endif
  163. ListCtrl->InsertItem(nIndex, str, nIndex);
  164. }
  165. if ( pDlg->m_bTerminate )
  166. {
  167. pDlg->m_bTerminate = false;
  168. return 0;
  169. }
  170. ListCtrl->SetRedraw(TRUE);
  171. ListCtrl->Invalidate();
  172. const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;
  173. int XDest, YDest, nDestWidth, nDestHeight;
  174. nIndex = 0;
  175. SolidBrush whitebrush(Color(255, 255, 255, 255));
  176. for ( nIndex = 0; !pDlg->m_bTerminate && nIndex < pDlg->m_vFileName.GetSize(); nIndex++ )
  177. {
  178. CString str, spath;
  179. // Load Image File
  180. Image *image = NULL;
  181. Bitmap *pBmp = NULL;
  182. //str = *iter;
  183. str = pDlg->m_vFileName.ElementAt(nIndex);
  184. if ( !PathFileExists(str) )
  185. continue;
  186. spath = str.Left(str.ReverseFind('\\') + 1);
  187. spath += "s";
  188. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  189. if (PathFileExists(spath))
  190. ::LoadImageFromBuf(&image, spath);
  191. else
  192. {
  193. str.MakeLower();
  194. if (str.Right(3) != "jpg")continue;
  195. ::LoadImageFromBuf(&image, str);
  196. }
  197. if (image == NULL)continue;
  198. int orientation = GetOrientation(image);
  199. if (orientation == 8)
  200. image->RotateFlip(Rotate270FlipNone);
  201. else if (orientation == 6)
  202. image->RotateFlip(Rotate90FlipNone);
  203. if (image->GetWidth() == 0)
  204. continue;
  205. // Calculate Rect to fit to canvas
  206. const float fImgRatio = (float)image->GetHeight() / image->GetWidth();
  207. if (fImgRatio > fRatio)
  208. {
  209. nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
  210. XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
  211. YDest = 0;
  212. nDestHeight = THUMBNAIL_HEIGHT;
  213. }
  214. else
  215. {
  216. XDest = 0;
  217. nDestWidth = THUMBNAIL_WIDTH;
  218. nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
  219. YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
  220. }
  221. pBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
  222. Graphics graph2(pBmp);
  223. graph2.Clear(Color(255, 192, 192, 192));
  224. graph2.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH - 2, THUMBNAIL_HEIGHT - 2);
  225. Graphics graph(pBmp);
  226. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  227. // Draw Image
  228. graph.DrawImage(image, desRect, 0, 0, image->GetWidth(), image->GetHeight(), UnitPixel);
  229. if (image)
  230. delete image;
  231. // Attach to Bitmap and Replace image in CImageList
  232. CBitmap bitmap;
  233. HBITMAP hbmp;
  234. pBmp->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
  235. bitmap.Attach(hbmp);
  236. pImgList->Replace(nIndex, &bitmap, NULL);
  237. if (pBmp)
  238. delete pBmp;
  239. // Redraw only a current item for removing flickering and fast speed.
  240. ListCtrl->RedrawItems(nIndex, nIndex);
  241. // Release used DC and Object
  242. }
  243. if ( !pDlg->m_bTerminate )ListCtrl->Invalidate();
  244. pDlg->m_bTerminate = false;
  245. return 0;
  246. }
  247. catch (...)
  248. {
  249. }
  250. return 0;
  251. }
  252. void ShowPic3::LoadThumbImages()
  253. {
  254. TerminateThread();
  255. WriteTextLog(_T("开始线程"));
  256. if ( m_hThread == NULL )
  257. {
  258. m_bTerminate = false;
  259. m_hThread = CreateThread(NULL, 0, LoadThumbNail20, this, 0, NULL);
  260. }
  261. }
  262. BOOL ShowPic3::TerminateThread()
  263. {
  264. #ifdef USE_KERNEL_DLL
  265. if ( m_hThread )
  266. {
  267. // 标记退出窗口;
  268. m_bTerminate = TRUE;
  269. // 不能INFINITE,因为主窗口线程死等,子线程控件就无法响应操作;
  270. while (WaitForSingleObject(m_hThread, 100) == WAIT_OBJECT_0)
  271. {
  272. CloseHandle(m_hThread);
  273. WriteTextLog(_T("线程结束"));
  274. }
  275. m_hThread = NULL;
  276. }
  277. return TRUE;
  278. #else
  279. if (!m_bRunning)
  280. return TRUE;
  281. m_bTerminate = true;
  282. for (;;)
  283. {
  284. if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
  285. break;
  286. MSG msg;
  287. while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  288. {
  289. if (!AfxGetApp()->PumpMessage())
  290. break;
  291. }
  292. }
  293. ::CloseHandle(m_hThread);
  294. return TRUE;
  295. #endif
  296. }
  297. void ShowPic3::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
  298. {
  299. POSITION pos;
  300. pos = m_List1.GetFirstSelectedItemPosition();
  301. if (pos == NULL)
  302. {
  303. return;
  304. }
  305. int iItem = m_List1.GetNextSelectedItem(pos);
  306. ShowPic22 dlg;
  307. dlg.m_nCurImgPos = iItem;
  308. dlg.m_pAryImgPath = &m_patharray1;
  309. dlg.DoModal();
  310. *pResult = 0;
  311. }
  312. void ShowPic3::OnDestroy()
  313. {
  314. TerminateThread();
  315. //m_vFileName.clear();
  316. m_vFileName.RemoveAll();
  317. CDialog::OnDestroy();
  318. }
  319. void ShowPic3::LoadPhotos()
  320. {
  321. CString str;
  322. #ifdef USE_KERNEL_DLL
  323. HGLOBAL hMemery;
  324. DWORD dwMemSize = 0;
  325. if ( g_pIMGProcess == NULL )
  326. return;
  327. hMemery = g_pIMGProcess->GetBranchAllOrderDirectory(OImgtype, g_domain.IsEmpty() ? g_branchname : g_domain, dwMemSize);
  328. if ( hMemery )
  329. {
  330. BYTE *pData = (BYTE*)GlobalLock(hMemery);
  331. CMemFile mf;
  332. mf.Attach(pData, dwMemSize);
  333. CArchive ar(&mf, CArchive::load);
  334. CStringArray Arypath;
  335. Arypath.Serialize(ar);
  336. ar.Close();
  337. mf.Detach();
  338. GlobalUnlock(hMemery);
  339. GlobalFree(hMemery);
  340. INT nCount = Arypath.GetSize();
  341. for ( int i = 0; i < nCount; i++ )
  342. {
  343. str = Arypath.ElementAt(i);
  344. str.TrimRight(_T("\\"));
  345. str = str.Mid(str.ReverseFind(_T('\\'))+1);
  346. m_dirarray1.Add(str);
  347. }
  348. }
  349. #else
  350. if (1)
  351. {
  352. // printf("Jeff:g_path1=%s\n\n",g_path1);//Jeff.获取客户原片里的所有订单文件夹名称;
  353. using namespace helper_coffs;
  354. ffsco o;
  355. o.dirs(0);
  356. o.find(LPCSTR(g_path1), LPCSTR("*.*"));
  357. ffsco::typeT coo;
  358. ffsco::typeT::iterator it;
  359. coo = o.co_dir();
  360. for (it = coo.begin(); coo.end() != it; it++)
  361. {
  362. str = (*it).c_str();
  363. if (str == g_path1 + "\\")continue;
  364. str.TrimRight("\\");
  365. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  366. // printf("Jeff:str=%s\n\n",str);
  367. m_dirarray1.Add(str);
  368. }
  369. }
  370. #endif
  371. return;
  372. }
  373. void ShowPic3::OnBUTdel()
  374. {
  375. }
  376. void ShowPic3::OnSelchangeList2()
  377. {
  378. UpdateData();
  379. int pos = m_List2.GetCurSel();
  380. if (pos == -1)return;
  381. CString str;
  382. m_List2.GetText(pos, str);
  383. pos = str.Find("\r\n");
  384. if (pos == -1)return;;
  385. m_strOrderNumber = str.Left(pos);
  386. m_strOrderNumber.MakeLower();
  387. ShowPhoto1();
  388. if (m_patharray1.GetSize() == 0)OnBTNshow2();
  389. if (m_patharray1.GetSize() == 0)OnBTNshow3();
  390. if (m_patharray1.GetSize() == 0)OnBTNshow4();
  391. }
  392. void ShowPic3::ShowPhoto1() // 查看原片;
  393. {
  394. if (m_strOrderNumber == _T(""))
  395. {
  396. AfxMessageBox(_T("请先选中客人!"), MB_ICONINFORMATION); return;
  397. }
  398. #ifdef USE_KERNEL_DLL
  399. ShowOrderImg(OImgtype);
  400. #else
  401. CString str;
  402. m_path = g_path1 + "\\" + m_strOrderNumber + "\\";
  403. m_patharray1.RemoveAll();
  404. if (1)
  405. {
  406. using namespace helper_coffs;
  407. ffsco o;
  408. o.dirs(1);
  409. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  410. ffsco::typeT coo;
  411. ffsco::typeT::iterator it;
  412. coo = o.co_file();
  413. for (it = coo.begin(); coo.end() != it; it++)
  414. {
  415. str = (*it).c_str();
  416. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  417. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  418. str.MakeLower();
  419. m_patharray1.Add(str);
  420. }
  421. }
  422. if (m_bRunning)return;
  423. CStringArray *pArray = &m_patharray1;
  424. m_vFileName.clear();
  425. for (int i = 0; i < pArray->GetSize(); i++)
  426. {
  427. CString filePath = pArray->ElementAt(i);
  428. filePath.MakeLower();
  429. m_vFileName.push_back(filePath);
  430. }
  431. LoadThumbImages();
  432. #endif
  433. }
  434. void ShowPic3::ShowPhoto2() // 查看初修片;
  435. {
  436. #ifdef USE_KERNEL_DLL
  437. ShowOrderImg(EImgtype);
  438. #else
  439. if (m_strOrderNumber == "")
  440. {
  441. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  442. }
  443. CString str;
  444. m_path = g_path2 + "\\" + m_strOrderNumber + "\\";
  445. m_patharray1.RemoveAll();
  446. if (1)
  447. {
  448. using namespace helper_coffs;
  449. ffsco o;
  450. o.dirs(1);
  451. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  452. ffsco::typeT coo;
  453. ffsco::typeT::iterator it;
  454. coo = o.co_file();
  455. for (it = coo.begin(); coo.end() != it; it++)
  456. {
  457. str = (*it).c_str();
  458. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  459. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  460. str.MakeLower();
  461. m_patharray1.Add(str);
  462. }
  463. }
  464. if (m_bRunning)return;
  465. CStringArray *pArray = &m_patharray1;
  466. m_vFileName.clear();
  467. for (int i = 0; i < pArray->GetSize(); i++)
  468. {
  469. CString filePath = pArray->ElementAt(i);
  470. filePath.MakeLower();
  471. m_vFileName.push_back(filePath);
  472. }
  473. LoadThumbImages();
  474. #endif
  475. }
  476. void ShowPic3::ShowPhoto3() // 查看精修片;
  477. {
  478. #ifdef USE_KERNEL_DLL
  479. ShowOrderImg(FImgtype);
  480. #else
  481. if (m_strOrderNumber == "")
  482. {
  483. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  484. }
  485. CString str;
  486. m_path = g_path3 + "\\" + m_strOrderNumber + "\\";
  487. m_patharray1.RemoveAll();
  488. if (1)
  489. {
  490. using namespace helper_coffs;
  491. ffsco o;
  492. o.dirs(1);
  493. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  494. ffsco::typeT coo;
  495. ffsco::typeT::iterator it;
  496. coo = o.co_file();
  497. for (it = coo.begin(); coo.end() != it; it++)
  498. {
  499. str = (*it).c_str();
  500. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  501. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  502. str.MakeLower();
  503. m_patharray1.Add(str);
  504. }
  505. }
  506. if (m_bRunning)return;
  507. CStringArray *pArray = &m_patharray1;
  508. m_vFileName.clear();
  509. for (int i = 0; i < pArray->GetSize(); i++)
  510. {
  511. CString filePath = pArray->ElementAt(i);
  512. filePath.MakeLower();
  513. m_vFileName.push_back(filePath);
  514. }
  515. LoadThumbImages();
  516. #endif
  517. }
  518. void ShowPic3::ShowPhoto4() // 查看设计片;
  519. {
  520. #ifdef USE_KERNEL_DLL
  521. ShowOrderImg(DImgtype);
  522. #else
  523. if (m_strOrderNumber == "")
  524. {
  525. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  526. }
  527. CString str;
  528. m_path = g_path4 + "\\" + m_strOrderNumber + "\\";
  529. m_patharray1.RemoveAll();
  530. if (1)
  531. {
  532. using namespace helper_coffs;
  533. ffsco o;
  534. o.dirs(1);
  535. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  536. ffsco::typeT coo;
  537. ffsco::typeT::iterator it;
  538. coo = o.co_file();
  539. for (it = coo.begin(); coo.end() != it; it++)
  540. {
  541. str = (*it).c_str();
  542. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  543. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  544. str.MakeLower();
  545. m_patharray1.Add(str);
  546. }
  547. }
  548. if (m_bRunning)return;
  549. CStringArray *pArray = &m_patharray1;
  550. m_vFileName.clear();
  551. for (int i = 0; i < pArray->GetSize(); i++)
  552. {
  553. CString filePath = pArray->ElementAt(i);
  554. filePath.MakeLower();
  555. m_vFileName.push_back(filePath);
  556. }
  557. LoadThumbImages();
  558. #endif
  559. }
  560. void ShowPic3::OnBTNshow1()
  561. {
  562. ShowPhoto1();
  563. }
  564. void ShowPic3::OnBTNshow2()
  565. {
  566. ShowPhoto2();
  567. }
  568. void ShowPic3::OnBTNshow3()
  569. {
  570. ShowPhoto3();
  571. }
  572. void ShowPic3::OnBTNshow4()
  573. {
  574. ShowPhoto4();
  575. }
  576. void ShowPic3::OnBUTdelall() // 全部删除;
  577. {
  578. if (m_strOrderNumber == _T(""))
  579. {
  580. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  581. }
  582. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  583. WriteLog(_T("客照删除"), _T(" 客照管理中心:") + m_strOrderNumber + _T(":全部相片被删除"));
  584. #ifdef USE_KERNEL_DLL
  585. CStringArray AryOrderpath;
  586. GetOrderpathByOrderNum(OImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  587. GetOrderpathByOrderNum(EImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  588. GetOrderpathByOrderNum(FImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  589. GetOrderpathByOrderNum(DImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  590. for ( int i = 0; i < AryOrderpath.GetSize(); i++ )
  591. {
  592. DeleteDirectory(AryOrderpath.ElementAt(i));
  593. }
  594. OnBTNshow1();
  595. #else
  596. DeleteDirectory(g_path1 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单原片;
  597. DeleteDirectory(g_path2 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单初修;
  598. DeleteDirectory(g_path3 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单精修;
  599. DeleteDirectory(g_path4 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单设计;
  600. OnBTNshow1();
  601. #endif
  602. }
  603. void ShowPic3::OnBUTdel1() // 原片删除按钮;
  604. {
  605. if (m_strOrderNumber == "")
  606. {
  607. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  608. }
  609. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  610. WriteLog(_T("原片删除"), _T(" 客照管理中心:") + m_strOrderNumber + _T(":原片被删除"));
  611. #ifdef USE_KERNEL_DLL
  612. CStringArray AryOrderpath;
  613. GetOrderpathByOrderNum(OImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  614. for ( int i = 0; i < AryOrderpath.GetSize(); i++ )
  615. {
  616. DeleteDirectory(AryOrderpath.ElementAt(i));
  617. }
  618. #else
  619. DeleteDirectory(g_path1 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单原片;
  620. #endif
  621. OnBTNshow1();
  622. }
  623. void ShowPic3::OnBUTdel2() // 初修删除按钮;
  624. {
  625. if (m_strOrderNumber == "")
  626. {
  627. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  628. }
  629. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  630. WriteLog(_T("初修删除"), _T(" 客照管理中心:") + m_strOrderNumber + _T(":初修片被删除"));
  631. #ifdef USE_KERNEL_DLL
  632. CStringArray AryOrderpath;
  633. GetOrderpathByOrderNum(EImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  634. for ( int i = 0; i < AryOrderpath.GetSize(); i++ )
  635. {
  636. DeleteDirectory(AryOrderpath.ElementAt(i));
  637. }
  638. #else
  639. DeleteDirectory(g_path2 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单初修;
  640. #endif
  641. OnBTNshow2();
  642. }
  643. void ShowPic3::OnBUTdel3() // 精修删除按钮;
  644. {
  645. if (m_strOrderNumber == "")
  646. {
  647. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  648. }
  649. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  650. WriteLog(_T("精修删除"), _T(" 客照管理中心:") + m_strOrderNumber + _T(":精修片被删除"));
  651. #ifdef USE_KERNEL_DLL
  652. CStringArray AryOrderpath;
  653. GetOrderpathByOrderNum(FImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  654. for ( int i = 0; i < AryOrderpath.GetSize(); i++ )
  655. {
  656. DeleteDirectory(AryOrderpath.ElementAt(i));
  657. }
  658. #else
  659. DeleteDirectory(g_path4 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单精修;
  660. #endif
  661. OnBTNshow3();
  662. }
  663. void ShowPic3::OnBUTdel4() // 设计片删除按钮;
  664. {
  665. if (m_strOrderNumber == "")
  666. {
  667. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  668. }
  669. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  670. WriteLog(_T("设计片删除"), _T(" 客照管理中心:") + m_strOrderNumber + _T(":设计片被删除"));
  671. #ifdef USE_KERNEL_DLL
  672. CStringArray AryOrderpath;
  673. GetOrderpathByOrderNum(DImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  674. for ( int i = 0; i < AryOrderpath.GetSize(); i++ )
  675. {
  676. DeleteDirectory(AryOrderpath.ElementAt(i));
  677. }
  678. #else
  679. DeleteDirectory(g_path3 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单设计;
  680. #endif
  681. OnBTNshow4();
  682. }
  683. void ShowPic3::OnCbnSelchangeCombo1()
  684. {
  685. static int nIndex = 0;
  686. if (nIndex)
  687. m_List2.SetSel(nIndex, FALSE);
  688. int i = 0;
  689. int nSelCount = m_List2.GetSelCount();
  690. for (i = 0; i < nSelCount; i++)//去除还处于选择状态的项;
  691. {
  692. int nSelItem;
  693. m_List2.GetSelItems(nSelCount, &nSelItem);
  694. m_List2.SetSel(nSelItem, FALSE);
  695. }
  696. int nPos = m_combobox.GetCurSel();
  697. CString strName;
  698. //m_combobox.GetWindowText(strName);
  699. m_combobox.GetLBText(nPos, strName);
  700. // printf("Jeff:****当前查找内容=%s\n\n",strName);
  701. int nSize = m_strArrayName.GetSize();
  702. for (i = 0; i < nSize; i++)
  703. {
  704. CString str = m_strArrayName.ElementAt(i);
  705. if (str.Find(strName) != -1)
  706. {
  707. // printf("Jeff:****当前查找内容=%s\n\n",str);
  708. //nIndex = m_List2.SelectString(-1,str);
  709. nIndex = i;
  710. if (nIndex == LB_ERR)
  711. {
  712. break;
  713. }
  714. m_List2.SetSel(nIndex, TRUE);
  715. PostMessage(OWNER_MSG_SHOWPHOTO, nIndex);
  716. break;
  717. }
  718. }
  719. }
  720. void ShowPic3::OnBnClickedNextone()
  721. {
  722. static int nIndex = 0;
  723. static CString strOld = "";
  724. m_List2.SetSel(nIndex - 1, FALSE);
  725. int i = 0;
  726. int nSelCount = m_List2.GetSelCount();
  727. for (i = 0; i < nSelCount; i++)//去除还处于选择状态的项;
  728. {
  729. int nSelItem;
  730. m_List2.GetSelItems(nSelCount, &nSelItem);
  731. m_List2.SetSel(nSelItem, FALSE);
  732. }
  733. CString strFind = "";
  734. m_combobox.GetWindowText(strFind);
  735. if ( strFind.IsEmpty() )
  736. {
  737. return;
  738. }
  739. if (strOld != strFind)
  740. {
  741. strOld = strFind;
  742. nIndex = 0;
  743. }
  744. // printf("Jeff:当前查找内容=%s\n\n",strFind);
  745. CString str;
  746. BOOL bFind = FALSE;
  747. int nSize = m_strArrayName.GetSize();
  748. for (i = nIndex; i < nSize; i++)
  749. {
  750. str = m_strArrayName.ElementAt(i);
  751. // printf("Jeff:匹配内容=%s\n\n",str);
  752. if (str.Find(strFind) != -1)
  753. {
  754. nIndex = i;
  755. // printf("Jeff:nIndex=%d,找到内容=%s\n\n",i,str);
  756. bFind = TRUE;
  757. break;
  758. }
  759. }
  760. if (bFind == FALSE)
  761. {
  762. nIndex = 0;
  763. AfxMessageBox("未找到查找匹配的内容,将再次从头开始查找");
  764. }
  765. else
  766. {
  767. m_List2.SetSel(nIndex++, TRUE);
  768. PostMessage(OWNER_MSG_SHOWPHOTO, -1);
  769. }
  770. }
  771. #ifdef VC60
  772. void ShowPic3::ShowPhoto2Found(WPARAM wParam, LPARAM lParam)
  773. {
  774. UpdateData();
  775. int nPos = m_List2.GetCurSel();
  776. if (wParam != -1)
  777. nPos = wParam;
  778. if (nPos == -1) return;
  779. CString str;
  780. m_List2.GetText(nPos, str);
  781. nPos = str.Find("\r\n");
  782. if (nPos == -1)return;;
  783. m_strOrderNumber = str.Left(nPos);
  784. // printf("Jeff:欲显示的订单号=%s\n\n",m_strOrderNumber);
  785. ShowPhoto1();
  786. if (m_patharray1.GetSize() == 0)OnBTNshow2();
  787. if (m_patharray1.GetSize() == 0)OnBTNshow3();
  788. if (m_patharray1.GetSize() == 0)OnBTNshow4();
  789. }
  790. #else
  791. LRESULT ShowPic3::ShowPhoto2Found(WPARAM wParam, LPARAM lParam)
  792. {
  793. UpdateData();
  794. int nPos = m_List2.GetCurSel();
  795. if (wParam != -1)
  796. nPos = wParam;
  797. if (nPos == -1) return 0;
  798. CString str;
  799. m_List2.GetText(nPos, str);
  800. nPos = str.Find("\r\n");
  801. if (nPos == -1)return 0;
  802. m_strOrderNumber = str.Left(nPos);
  803. // printf("Jeff:欲显示的订单号=%s\n\n",m_strOrderNumber);
  804. ShowPhoto1();
  805. if (m_patharray1.GetSize() == 0)OnBTNshow2();
  806. if (m_patharray1.GetSize() == 0)OnBTNshow3();
  807. if (m_patharray1.GetSize() == 0)OnBTNshow4();
  808. return 0;
  809. }
  810. #endif
  811. #ifdef USE_KERNEL_DLL
  812. void ShowPic3::ShowOrderImg(IN CONST INT& nImgType)
  813. {
  814. CString str = _T("");
  815. DWORD dwMemSize = 0;
  816. m_patharray1.RemoveAll();
  817. //m_vFileName.clear();
  818. m_vFileName.RemoveAll();
  819. CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname);
  820. ImgLoadOrderpathInterface *pOrderLoader = NULL;
  821. if ( g_pIMGProcess == NULL )
  822. return ;
  823. g_pIMGProcess->QueryInterface(IID_ImgLoadOrderpathInterface,(void**)&pOrderLoader);
  824. if ( pOrderLoader )
  825. {
  826. pOrderLoader->Release();
  827. HGLOBAL hMemery = pOrderLoader->LoadOrderImages( nImgType, strBranchId, m_strOrderNumber, _T("*.jpg|*.jpeg"), dwMemSize);
  828. if ( hMemery )
  829. {
  830. BYTE *pData = (BYTE*)GlobalLock(hMemery);
  831. if ( pData == NULL )
  832. {
  833. GlobalUnlock(hMemery);
  834. GlobalFree(hMemery);
  835. return ;
  836. }
  837. CMemFile mf;
  838. mf.Attach(pData, dwMemSize);
  839. CArchive ar(&mf, CArchive::load);
  840. CStringArray Arypath;
  841. Arypath.Serialize(ar);
  842. ar.Close();
  843. mf.Detach();
  844. GlobalUnlock(hMemery);
  845. GlobalFree(hMemery);
  846. INT i = 0;
  847. INT nCount = Arypath.GetSize();
  848. for ( i = 0; i < nCount; i++ )
  849. {
  850. str = Arypath.ElementAt(i);
  851. if (str.Mid(str.ReverseFind(_T('\\')) + 1) == _T("ok")) continue;
  852. if (str.Mid(str.ReverseFind(_T('\\')) + 1) == _T("modifytime")) continue;
  853. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  854. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  855. if (str.ReverseFind(_T('.')) == -1 ) continue;
  856. str.MakeLower();
  857. m_patharray1.Add(str);
  858. }
  859. Arypath.RemoveAll();
  860. CStringArray *pArray = &m_patharray1;
  861. nCount = pArray->GetSize();
  862. for ( i = 0; i < nCount; i++)
  863. {
  864. CString filePath = pArray->ElementAt(i);
  865. filePath.MakeLower();
  866. m_vFileName.Add(filePath);
  867. }
  868. }
  869. }
  870. // LoadThumbImages存在CString内存泄漏;
  871. if (m_vFileName.GetSize())
  872. {
  873. LoadThumbImages();
  874. }
  875. else
  876. {
  877. for (int i = 0; i < m_ImageListThumb.GetImageCount(); i++)
  878. m_ImageListThumb.Remove(i);
  879. m_List1.DeleteAllItems();
  880. m_List1.Invalidate();
  881. }
  882. }
  883. #endif
  884. void ShowPic3::OnOK()
  885. {
  886. // TODO: 在此添加专用代码和/或调用基类
  887. OnBnClickedNextone();
  888. }