ShowPic3.cpp 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  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();// 获取客户原片里的所有订单文件夹名称;
  84. CString str;
  85. for (int i = 0; i < g_List1array.GetSize(); i++)
  86. {
  87. str = g_List1array.ElementAt(i).ElementAt(0); // 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); // nIndex==1,为订单客户1;
  103. str += g_List1array.ElementAt(i).ElementAt(2); // 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. // 获取原片;
  328. hMemery = g_pIMGProcess->GetBranchAllOrderDirectory(OImgtype, g_domain.IsEmpty() ? g_branchname : g_domain, dwMemSize);
  329. if ( hMemery )
  330. {
  331. BYTE *pData = (BYTE*)GlobalLock(hMemery);
  332. CMemFile mf;
  333. mf.Attach(pData, dwMemSize);
  334. CArchive ar(&mf, CArchive::load);
  335. CStringArray Arypath;
  336. Arypath.Serialize(ar);
  337. ar.Close();
  338. mf.Detach();
  339. GlobalUnlock(hMemery);
  340. GlobalFree(hMemery);
  341. INT nCount = Arypath.GetSize();
  342. for ( int i = 0; i < nCount; i++ )
  343. {
  344. str = Arypath.ElementAt(i);
  345. str.TrimRight(_T("\\"));
  346. str = str.Mid(str.ReverseFind(_T('\\'))+1);
  347. m_dirarray1.Add(str);
  348. }
  349. }
  350. // 获取初修;
  351. hMemery = g_pIMGProcess->GetBranchAllOrderDirectory(EImgtype, g_domain.IsEmpty() ? g_branchname : g_domain, dwMemSize);
  352. if ( hMemery )
  353. {
  354. BYTE *pData = (BYTE*)GlobalLock(hMemery);
  355. CMemFile mf;
  356. mf.Attach(pData, dwMemSize);
  357. CArchive ar(&mf, CArchive::load);
  358. CStringArray Arypath;
  359. Arypath.Serialize(ar);
  360. ar.Close();
  361. mf.Detach();
  362. GlobalUnlock(hMemery);
  363. GlobalFree(hMemery);
  364. INT nCount = Arypath.GetSize();
  365. for ( int i = 0; i < nCount; i++ )
  366. {
  367. str = Arypath.ElementAt(i);
  368. str.TrimRight(_T("\\"));
  369. str = str.Mid(str.ReverseFind(_T('\\'))+1);
  370. m_dirarray2.Add(str);
  371. }
  372. }
  373. // 获取精修;
  374. hMemery = g_pIMGProcess->GetBranchAllOrderDirectory(FImgtype, g_domain.IsEmpty() ? g_branchname : g_domain, dwMemSize);
  375. if ( hMemery )
  376. {
  377. BYTE *pData = (BYTE*)GlobalLock(hMemery);
  378. CMemFile mf;
  379. mf.Attach(pData, dwMemSize);
  380. CArchive ar(&mf, CArchive::load);
  381. CStringArray Arypath;
  382. Arypath.Serialize(ar);
  383. ar.Close();
  384. mf.Detach();
  385. GlobalUnlock(hMemery);
  386. GlobalFree(hMemery);
  387. INT nCount = Arypath.GetSize();
  388. for ( int i = 0; i < nCount; i++ )
  389. {
  390. str = Arypath.ElementAt(i);
  391. str.TrimRight(_T("\\"));
  392. str = str.Mid(str.ReverseFind(_T('\\'))+1);
  393. m_dirarray3.Add(str);
  394. }
  395. }
  396. // 获取设计;
  397. hMemery = g_pIMGProcess->GetBranchAllOrderDirectory(DImgtype, g_domain.IsEmpty() ? g_branchname : g_domain, dwMemSize);
  398. if ( hMemery )
  399. {
  400. BYTE *pData = (BYTE*)GlobalLock(hMemery);
  401. CMemFile mf;
  402. mf.Attach(pData, dwMemSize);
  403. CArchive ar(&mf, CArchive::load);
  404. CStringArray Arypath;
  405. Arypath.Serialize(ar);
  406. ar.Close();
  407. mf.Detach();
  408. GlobalUnlock(hMemery);
  409. GlobalFree(hMemery);
  410. INT nCount = Arypath.GetSize();
  411. for ( int i = 0; i < nCount; i++ )
  412. {
  413. str = Arypath.ElementAt(i);
  414. str.TrimRight(_T("\\"));
  415. str = str.Mid(str.ReverseFind(_T('\\'))+1);
  416. m_dirarray4.Add(str);
  417. }
  418. }
  419. #else
  420. if (1)
  421. {
  422. // printf("Jeff:g_path1=%s\n\n",g_path1);//Jeff.获取客户原片里的所有订单文件夹名称;
  423. using namespace helper_coffs;
  424. ffsco o;
  425. o.dirs(0);
  426. o.find(LPCSTR(g_path1), LPCSTR("*.*"));
  427. ffsco::typeT coo;
  428. ffsco::typeT::iterator it;
  429. coo = o.co_dir();
  430. for (it = coo.begin(); coo.end() != it; it++)
  431. {
  432. str = (*it).c_str();
  433. if (str == g_path1 + "\\")continue;
  434. str.TrimRight("\\");
  435. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  436. // printf("Jeff:str=%s\n\n",str);
  437. m_dirarray1.Add(str);
  438. }
  439. }
  440. #endif
  441. return;
  442. }
  443. void ShowPic3::OnBUTdel()
  444. {
  445. }
  446. void ShowPic3::OnSelchangeList2()
  447. {
  448. UpdateData();
  449. int pos = m_List2.GetCurSel();
  450. if (pos == -1)return;
  451. CString str;
  452. m_List2.GetText(pos, str);
  453. pos = str.Find("\r\n");
  454. if (pos == -1)return;;
  455. m_strOrderNumber = str.Left(pos);
  456. m_strOrderNumber.MakeLower();
  457. ShowPhoto1();
  458. if (m_patharray1.GetSize() == 0)OnBTNshow2();
  459. if (m_patharray1.GetSize() == 0)OnBTNshow3();
  460. if (m_patharray1.GetSize() == 0)OnBTNshow4();
  461. }
  462. void ShowPic3::ShowPhoto1() // 查看原片;
  463. {
  464. if (m_strOrderNumber == _T(""))
  465. {
  466. AfxMessageBox(_T("请先选中客人!"), MB_ICONINFORMATION); return;
  467. }
  468. #ifdef USE_KERNEL_DLL
  469. ShowOrderImg(OImgtype);
  470. #else
  471. CString str;
  472. m_path = g_path1 + "\\" + m_strOrderNumber + "\\";
  473. m_patharray1.RemoveAll();
  474. if (1)
  475. {
  476. using namespace helper_coffs;
  477. ffsco o;
  478. o.dirs(1);
  479. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  480. ffsco::typeT coo;
  481. ffsco::typeT::iterator it;
  482. coo = o.co_file();
  483. for (it = coo.begin(); coo.end() != it; it++)
  484. {
  485. str = (*it).c_str();
  486. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  487. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  488. str.MakeLower();
  489. m_patharray1.Add(str);
  490. }
  491. }
  492. if (m_bRunning)return;
  493. CStringArray *pArray = &m_patharray1;
  494. m_vFileName.clear();
  495. for (int i = 0; i < pArray->GetSize(); i++)
  496. {
  497. CString filePath = pArray->ElementAt(i);
  498. filePath.MakeLower();
  499. m_vFileName.push_back(filePath);
  500. }
  501. LoadThumbImages();
  502. #endif
  503. }
  504. void ShowPic3::ShowPhoto2() // 查看初修片;
  505. {
  506. #ifdef USE_KERNEL_DLL
  507. ShowOrderImg(EImgtype);
  508. #else
  509. if (m_strOrderNumber == "")
  510. {
  511. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  512. }
  513. CString str;
  514. m_path = g_path2 + "\\" + m_strOrderNumber + "\\";
  515. m_patharray1.RemoveAll();
  516. if (1)
  517. {
  518. using namespace helper_coffs;
  519. ffsco o;
  520. o.dirs(1);
  521. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  522. ffsco::typeT coo;
  523. ffsco::typeT::iterator it;
  524. coo = o.co_file();
  525. for (it = coo.begin(); coo.end() != it; it++)
  526. {
  527. str = (*it).c_str();
  528. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  529. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  530. str.MakeLower();
  531. m_patharray1.Add(str);
  532. }
  533. }
  534. if (m_bRunning)return;
  535. CStringArray *pArray = &m_patharray1;
  536. m_vFileName.clear();
  537. for (int i = 0; i < pArray->GetSize(); i++)
  538. {
  539. CString filePath = pArray->ElementAt(i);
  540. filePath.MakeLower();
  541. m_vFileName.push_back(filePath);
  542. }
  543. LoadThumbImages();
  544. #endif
  545. }
  546. void ShowPic3::ShowPhoto3() // 查看精修片;
  547. {
  548. #ifdef USE_KERNEL_DLL
  549. ShowOrderImg(FImgtype);
  550. #else
  551. if (m_strOrderNumber == "")
  552. {
  553. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  554. }
  555. CString str;
  556. m_path = g_path3 + "\\" + m_strOrderNumber + "\\";
  557. m_patharray1.RemoveAll();
  558. if (1)
  559. {
  560. using namespace helper_coffs;
  561. ffsco o;
  562. o.dirs(1);
  563. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  564. ffsco::typeT coo;
  565. ffsco::typeT::iterator it;
  566. coo = o.co_file();
  567. for (it = coo.begin(); coo.end() != it; it++)
  568. {
  569. str = (*it).c_str();
  570. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  571. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  572. str.MakeLower();
  573. m_patharray1.Add(str);
  574. }
  575. }
  576. if (m_bRunning)return;
  577. CStringArray *pArray = &m_patharray1;
  578. m_vFileName.clear();
  579. for (int i = 0; i < pArray->GetSize(); i++)
  580. {
  581. CString filePath = pArray->ElementAt(i);
  582. filePath.MakeLower();
  583. m_vFileName.push_back(filePath);
  584. }
  585. LoadThumbImages();
  586. #endif
  587. }
  588. void ShowPic3::ShowPhoto4() // 查看设计片;
  589. {
  590. #ifdef USE_KERNEL_DLL
  591. ShowOrderImg(DImgtype);
  592. #else
  593. if (m_strOrderNumber == "")
  594. {
  595. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  596. }
  597. CString str;
  598. m_path = g_path4 + "\\" + m_strOrderNumber + "\\";
  599. m_patharray1.RemoveAll();
  600. if (1)
  601. {
  602. using namespace helper_coffs;
  603. ffsco o;
  604. o.dirs(1);
  605. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  606. ffsco::typeT coo;
  607. ffsco::typeT::iterator it;
  608. coo = o.co_file();
  609. for (it = coo.begin(); coo.end() != it; it++)
  610. {
  611. str = (*it).c_str();
  612. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  613. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  614. str.MakeLower();
  615. m_patharray1.Add(str);
  616. }
  617. }
  618. if (m_bRunning)return;
  619. CStringArray *pArray = &m_patharray1;
  620. m_vFileName.clear();
  621. for (int i = 0; i < pArray->GetSize(); i++)
  622. {
  623. CString filePath = pArray->ElementAt(i);
  624. filePath.MakeLower();
  625. m_vFileName.push_back(filePath);
  626. }
  627. LoadThumbImages();
  628. #endif
  629. }
  630. void ShowPic3::OnBTNshow1()
  631. {
  632. ShowPhoto1();
  633. }
  634. void ShowPic3::OnBTNshow2()
  635. {
  636. ShowPhoto2();
  637. }
  638. void ShowPic3::OnBTNshow3()
  639. {
  640. ShowPhoto3();
  641. }
  642. void ShowPic3::OnBTNshow4()
  643. {
  644. ShowPhoto4();
  645. }
  646. void ShowPic3::OnBUTdelall() // 全部删除;
  647. {
  648. if (m_strOrderNumber == _T(""))
  649. {
  650. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  651. }
  652. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  653. WriteLog(_T("客照删除"), _T(" 客照管理中心:") + m_strOrderNumber + _T(":全部相片被删除"));
  654. #ifdef USE_KERNEL_DLL
  655. CStringArray AryOrderpath;
  656. GetOrderpathByOrderNum(OImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  657. GetOrderpathByOrderNum(EImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  658. GetOrderpathByOrderNum(FImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  659. GetOrderpathByOrderNum(DImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  660. for ( int i = 0; i < AryOrderpath.GetSize(); i++ )
  661. {
  662. DeleteDirectory(AryOrderpath.ElementAt(i));
  663. }
  664. OnBTNshow1();
  665. #else
  666. DeleteDirectory(g_path1 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单原片;
  667. DeleteDirectory(g_path2 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单初修;
  668. DeleteDirectory(g_path3 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单精修;
  669. DeleteDirectory(g_path4 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单设计;
  670. OnBTNshow1();
  671. #endif
  672. }
  673. void ShowPic3::OnBUTdel1() // 原片删除按钮;
  674. {
  675. if (m_strOrderNumber == "")
  676. {
  677. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  678. }
  679. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  680. WriteLog(_T("原片删除"), _T(" 客照管理中心:") + m_strOrderNumber + _T(":原片被删除"));
  681. #ifdef USE_KERNEL_DLL
  682. CStringArray AryOrderpath;
  683. GetOrderpathByOrderNum(OImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  684. for ( int i = 0; i < AryOrderpath.GetSize(); i++ )
  685. {
  686. DeleteDirectory(AryOrderpath.ElementAt(i));
  687. }
  688. #else
  689. DeleteDirectory(g_path1 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单原片;
  690. #endif
  691. OnBTNshow1();
  692. }
  693. void ShowPic3::OnBUTdel2() // 初修删除按钮;
  694. {
  695. if (m_strOrderNumber == "")
  696. {
  697. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  698. }
  699. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  700. WriteLog(_T("初修删除"), _T(" 客照管理中心:") + m_strOrderNumber + _T(":初修片被删除"));
  701. #ifdef USE_KERNEL_DLL
  702. CStringArray AryOrderpath;
  703. GetOrderpathByOrderNum(EImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  704. for ( int i = 0; i < AryOrderpath.GetSize(); i++ )
  705. {
  706. DeleteDirectory(AryOrderpath.ElementAt(i));
  707. }
  708. #else
  709. DeleteDirectory(g_path2 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单初修;
  710. #endif
  711. OnBTNshow2();
  712. }
  713. void ShowPic3::OnBUTdel3() // 精修删除按钮;
  714. {
  715. if (m_strOrderNumber == "")
  716. {
  717. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  718. }
  719. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  720. WriteLog(_T("精修删除"), _T(" 客照管理中心:") + m_strOrderNumber + _T(":精修片被删除"));
  721. #ifdef USE_KERNEL_DLL
  722. CStringArray AryOrderpath;
  723. GetOrderpathByOrderNum(FImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  724. for ( int i = 0; i < AryOrderpath.GetSize(); i++ )
  725. {
  726. DeleteDirectory(AryOrderpath.ElementAt(i));
  727. }
  728. #else
  729. DeleteDirectory(g_path4 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单精修;
  730. #endif
  731. OnBTNshow3();
  732. }
  733. void ShowPic3::OnBUTdel4() // 设计片删除按钮;
  734. {
  735. if (m_strOrderNumber == "")
  736. {
  737. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  738. }
  739. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  740. WriteLog(_T("设计片删除"), _T(" 客照管理中心:") + m_strOrderNumber + _T(":设计片被删除"));
  741. #ifdef USE_KERNEL_DLL
  742. CStringArray AryOrderpath;
  743. GetOrderpathByOrderNum(DImgtype, g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname), m_strOrderNumber, AryOrderpath);
  744. for ( int i = 0; i < AryOrderpath.GetSize(); i++ )
  745. {
  746. DeleteDirectory(AryOrderpath.ElementAt(i));
  747. }
  748. #else
  749. DeleteDirectory(g_path3 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单设计;
  750. #endif
  751. OnBTNshow4();
  752. }
  753. void ShowPic3::OnCbnSelchangeCombo1()
  754. {
  755. static int nIndex = 0;
  756. if (nIndex)
  757. m_List2.SetSel(nIndex, FALSE);
  758. int i = 0;
  759. int nSelCount = m_List2.GetSelCount();
  760. for (i = 0; i < nSelCount; i++)//去除还处于选择状态的项;
  761. {
  762. int nSelItem;
  763. m_List2.GetSelItems(nSelCount, &nSelItem);
  764. m_List2.SetSel(nSelItem, FALSE);
  765. }
  766. int nPos = m_combobox.GetCurSel();
  767. CString strName;
  768. //m_combobox.GetWindowText(strName);
  769. m_combobox.GetLBText(nPos, strName);
  770. // printf("Jeff:****当前查找内容=%s\n\n",strName);
  771. int nSize = m_strArrayName.GetSize();
  772. for (i = 0; i < nSize; i++)
  773. {
  774. CString str = m_strArrayName.ElementAt(i);
  775. if (str.Find(strName) != -1)
  776. {
  777. // printf("Jeff:****当前查找内容=%s\n\n",str);
  778. //nIndex = m_List2.SelectString(-1,str);
  779. nIndex = i;
  780. if (nIndex == LB_ERR)
  781. {
  782. break;
  783. }
  784. m_List2.SetSel(nIndex, TRUE);
  785. PostMessage(OWNER_MSG_SHOWPHOTO, nIndex);
  786. break;
  787. }
  788. }
  789. }
  790. void ShowPic3::OnBnClickedNextone()
  791. {
  792. static int nIndex = 0;
  793. static CString strOld = "";
  794. m_List2.SetSel(nIndex - 1, FALSE);
  795. int i = 0;
  796. int nSelCount = m_List2.GetSelCount();
  797. for (i = 0; i < nSelCount; i++)//去除还处于选择状态的项;
  798. {
  799. int nSelItem;
  800. m_List2.GetSelItems(nSelCount, &nSelItem);
  801. m_List2.SetSel(nSelItem, FALSE);
  802. }
  803. CString strFind = "";
  804. m_combobox.GetWindowText(strFind);
  805. if ( strFind.IsEmpty() )
  806. {
  807. return;
  808. }
  809. if (strOld != strFind)
  810. {
  811. strOld = strFind;
  812. nIndex = 0;
  813. }
  814. // printf("Jeff:当前查找内容=%s\n\n",strFind);
  815. CString str;
  816. BOOL bFind = FALSE;
  817. int nSize = m_strArrayName.GetSize();
  818. for (i = nIndex; i < nSize; i++)
  819. {
  820. str = m_strArrayName.ElementAt(i);
  821. // printf("Jeff:匹配内容=%s\n\n",str);
  822. if (str.Find(strFind) != -1)
  823. {
  824. nIndex = i;
  825. // printf("Jeff:nIndex=%d,找到内容=%s\n\n",i,str);
  826. bFind = TRUE;
  827. break;
  828. }
  829. }
  830. if (bFind == FALSE)
  831. {
  832. nIndex = 0;
  833. AfxMessageBox("未找到查找匹配的内容,将再次从头开始查找");
  834. }
  835. else
  836. {
  837. m_List2.SetSel(nIndex++, TRUE);
  838. PostMessage(OWNER_MSG_SHOWPHOTO, -1);
  839. }
  840. }
  841. #ifdef VC60
  842. void ShowPic3::ShowPhoto2Found(WPARAM wParam, LPARAM lParam)
  843. {
  844. UpdateData();
  845. int nPos = m_List2.GetCurSel();
  846. if (wParam != -1)
  847. nPos = wParam;
  848. if (nPos == -1) return;
  849. CString str;
  850. m_List2.GetText(nPos, str);
  851. nPos = str.Find("\r\n");
  852. if (nPos == -1)return;;
  853. m_strOrderNumber = str.Left(nPos);
  854. // printf("Jeff:欲显示的订单号=%s\n\n",m_strOrderNumber);
  855. ShowPhoto1();
  856. if (m_patharray1.GetSize() == 0)OnBTNshow2();
  857. if (m_patharray1.GetSize() == 0)OnBTNshow3();
  858. if (m_patharray1.GetSize() == 0)OnBTNshow4();
  859. }
  860. #else
  861. LRESULT ShowPic3::ShowPhoto2Found(WPARAM wParam, LPARAM lParam)
  862. {
  863. UpdateData();
  864. int nPos = m_List2.GetCurSel();
  865. if (wParam != -1)
  866. nPos = wParam;
  867. if (nPos == -1) return 0;
  868. CString str;
  869. m_List2.GetText(nPos, str);
  870. nPos = str.Find("\r\n");
  871. if (nPos == -1)return 0;
  872. m_strOrderNumber = str.Left(nPos);
  873. // printf("Jeff:欲显示的订单号=%s\n\n",m_strOrderNumber);
  874. ShowPhoto1();
  875. if (m_patharray1.GetSize() == 0)OnBTNshow2();
  876. if (m_patharray1.GetSize() == 0)OnBTNshow3();
  877. if (m_patharray1.GetSize() == 0)OnBTNshow4();
  878. return 0;
  879. }
  880. #endif
  881. #ifdef USE_KERNEL_DLL
  882. void ShowPic3::ShowOrderImg(IN CONST INT& nImgType)
  883. {
  884. CString str = _T("");
  885. DWORD dwMemSize = 0;
  886. m_patharray1.RemoveAll();
  887. //m_vFileName.clear();
  888. m_vFileName.RemoveAll();
  889. CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname);
  890. ImgLoadOrderpathInterface *pOrderLoader = NULL;
  891. if ( g_pIMGProcess == NULL )
  892. return ;
  893. g_pIMGProcess->QueryInterface(IID_ImgLoadOrderpathInterface,(void**)&pOrderLoader);
  894. if ( pOrderLoader )
  895. {
  896. pOrderLoader->Release();
  897. HGLOBAL hMemery = pOrderLoader->LoadOrderImages( nImgType, strBranchId, m_strOrderNumber, _T("*.jpg|*.jpeg"), dwMemSize);
  898. if ( hMemery )
  899. {
  900. BYTE *pData = (BYTE*)GlobalLock(hMemery);
  901. if ( pData == NULL )
  902. {
  903. GlobalUnlock(hMemery);
  904. GlobalFree(hMemery);
  905. return ;
  906. }
  907. CMemFile mf;
  908. mf.Attach(pData, dwMemSize);
  909. CArchive ar(&mf, CArchive::load);
  910. CStringArray Arypath;
  911. Arypath.Serialize(ar);
  912. ar.Close();
  913. mf.Detach();
  914. GlobalUnlock(hMemery);
  915. GlobalFree(hMemery);
  916. INT i = 0;
  917. INT nCount = Arypath.GetSize();
  918. for ( i = 0; i < nCount; i++ )
  919. {
  920. str = Arypath.ElementAt(i);
  921. if (str.Mid(str.ReverseFind(_T('\\')) + 1) == _T("ok")) continue;
  922. if (str.Mid(str.ReverseFind(_T('\\')) + 1) == _T("modifytime")) continue;
  923. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  924. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  925. if (str.ReverseFind(_T('.')) == -1 ) continue;
  926. str.MakeLower();
  927. m_patharray1.Add(str);
  928. }
  929. Arypath.RemoveAll();
  930. CStringArray *pArray = &m_patharray1;
  931. nCount = pArray->GetSize();
  932. for ( i = 0; i < nCount; i++)
  933. {
  934. CString filePath = pArray->ElementAt(i);
  935. filePath.MakeLower();
  936. m_vFileName.Add(filePath);
  937. }
  938. }
  939. }
  940. // LoadThumbImages存在CString内存泄漏;
  941. if (m_vFileName.GetSize())
  942. {
  943. LoadThumbImages();
  944. }
  945. else
  946. {
  947. for (int i = 0; i < m_ImageListThumb.GetImageCount(); i++)
  948. m_ImageListThumb.Remove(i);
  949. m_List1.DeleteAllItems();
  950. m_List1.Invalidate();
  951. }
  952. }
  953. #endif
  954. void ShowPic3::OnOK()
  955. {
  956. // TODO: 在此添加专用代码和/或调用基类
  957. OnBnClickedNextone();
  958. }