ShowPic.cpp 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763
  1. // ShowPic.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "ShowPic.h"
  6. #include "ShowPic22.h"
  7. #include "ImportPhoto.h"
  8. #include "JPEG.h"
  9. #include "MyLock.h"
  10. #include "ZipTypeDlg.h"
  11. #include "SetDesignNo.h"
  12. #include "NetShareInfo.h"
  13. #define THUMBNAIL_WIDTH 100
  14. #define THUMBNAIL_HEIGHT 90
  15. unsigned __stdcall RefreshWork(LPVOID lpParam);
  16. /////////////////////////////////////////////////////////////////////////////
  17. // ShowPic dialog IDC_BU IDC_COMBO2
  18. ShowPic::ShowPic(CWnd* pParent /*=NULL*/): CDialog(ShowPic::IDD, pParent)
  19. {
  20. m_branchname = _T("");
  21. m_bRunning = false;
  22. m_bExit = FALSE;
  23. m_hThread = NULL;
  24. m_mode = 0;
  25. m_bdelall = 0;
  26. m_nDelCount = 0;
  27. m_hRefExitEvent = NULL;
  28. m_hThreadRef = NULL;
  29. //m_hEvent = NULL;
  30. }
  31. void ShowPic::DoDataExchange(CDataExchange* pDX)
  32. {
  33. CDialog::DoDataExchange(pDX);
  34. //{{AFX_DATA_MAP(ShowPic)
  35. DDX_Control(pDX, IDC_COMBO2, m_combobranch);
  36. DDX_Control(pDX, IDC_LIST1, m_List1);
  37. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  38. DDX_CBString(pDX, IDC_COMBO2, m_branchname);
  39. //}}AFX_DATA_MAP
  40. }
  41. BEGIN_MESSAGE_MAP(ShowPic, CDialog)
  42. //{{AFX_MSG_MAP(ShowPic)
  43. ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
  44. ON_WM_DESTROY()
  45. ON_BN_CLICKED(IDC_BUTdelall, OnBUTdelall)
  46. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  47. ON_BN_CLICKED(IDC_BUTupload, OnBUTupload)
  48. ON_BN_CLICKED(IDC_BUTselall, OnBUTselall)
  49. ON_CBN_SELCHANGE(IDC_COMBO2, OnSelchangeCombo2)
  50. ON_BN_CLICKED(IDC_BUTSetDesignNo, OnBUTSetDesignNo)
  51. ON_BN_CLICKED(IDC_BUTexport, OnBUTexport)
  52. ON_BN_CLICKED(IDC_BUT_RefreshPhotos, OnButRefreshPhotos)
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. /////////////////////////////////////////////////////////////////////////////
  56. // ShowPic message handlers
  57. BOOL ShowPic::OnInitDialog()
  58. {
  59. CDialog::OnInitDialog();
  60. m_id.MakeLower();
  61. CRect rc2;
  62. GetWindowRect(rc2);
  63. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  64. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  65. GetDlgItem(IDOK)->GetWindowRect(rc2);
  66. ScreenToClient(rc2);
  67. int hei = rc2.Height();
  68. GetClientRect(rc2);
  69. rc2.top = hei + 10;
  70. m_List1.MoveWindow(rc2);
  71. int right = rc2.right;
  72. //关闭
  73. GetDlgItem(IDOK)->GetWindowRect(rc2);
  74. ScreenToClient(rc2);
  75. int dtx = right - rc2.right - 5;
  76. rc2.top = 5;
  77. rc2.bottom = rc2.top + hei;
  78. rc2.left += dtx;
  79. rc2.right += dtx;
  80. GetDlgItem(IDOK)->MoveWindow(rc2);
  81. //删除
  82. GetDlgItem(IDC_BUTdel)->GetWindowRect(rc2);
  83. ScreenToClient(rc2);
  84. rc2.top = 5;
  85. rc2.bottom = rc2.top + hei;
  86. rc2.left += dtx;
  87. rc2.right += dtx;
  88. GetDlgItem(IDC_BUTdel)->MoveWindow(rc2);
  89. //全部删除
  90. GetDlgItem(IDC_BUTdelall)->GetWindowRect(rc2);
  91. ScreenToClient(rc2);
  92. rc2.top = 5;
  93. rc2.bottom = rc2.top + hei;
  94. rc2.left += dtx;
  95. rc2.right += dtx;
  96. GetDlgItem(IDC_BUTdelall)->MoveWindow(rc2);
  97. CRect tmpRt(rc2);
  98. GetDlgItem(IDC_BUTSetDesignNo)->GetWindowRect(rc2);
  99. ScreenToClient(rc2);
  100. rc2.top = 5;
  101. rc2.bottom = rc2.top + hei;
  102. rc2.left += dtx;
  103. rc2.right += dtx;
  104. GetDlgItem(IDC_BUTSetDesignNo)->MoveWindow(rc2);
  105. GetDlgItem(IDC_BUTexport)->GetWindowRect(rc2);
  106. ScreenToClient(rc2);
  107. rc2.top = 5;
  108. rc2.bottom = rc2.top + hei;
  109. rc2.left += dtx;
  110. rc2.right += dtx;
  111. GetDlgItem(IDC_BUTexport)->MoveWindow(rc2);
  112. //刷新按钮
  113. CRect refeshRt(0, 0, 0, 0);
  114. GetDlgItem(IDC_BUT_RefreshPhotos)->GetWindowRect(refeshRt);
  115. //设计
  116. if(m_mode == 5)
  117. tmpRt = rc2;
  118. int nWide = refeshRt.right - refeshRt.left;
  119. tmpRt.left = tmpRt.left - nWide - 5;
  120. tmpRt.right = tmpRt.left + nWide;
  121. GetDlgItem(IDC_BUT_RefreshPhotos)->MoveWindow(tmpRt);
  122. //////////////////////////////////////////////////////////
  123. GetDlgItem(IDC_BUTupload)->GetWindowRect(rc2);
  124. ScreenToClient(rc2);
  125. rc2.top = 5;
  126. rc2.bottom = rc2.top + hei;
  127. GetDlgItem(IDC_BUTupload)->MoveWindow(rc2);
  128. GetDlgItem(IDC_BUTselall)->GetWindowRect(rc2);
  129. ScreenToClient(rc2);
  130. rc2.top = 5;
  131. rc2.bottom = rc2.top + hei;
  132. GetDlgItem(IDC_BUTselall)->MoveWindow(rc2);
  133. GetDlgItem(IDC_COMBO2)->GetWindowRect(rc2);
  134. ScreenToClient(rc2);
  135. rc2.top = 5;
  136. rc2.bottom = rc2.top + hei + 300;
  137. GetDlgItem(IDC_COMBO2)->MoveWindow(rc2);
  138. m_combobranch.ShowWindow(0);
  139. if (g_branchname == "")
  140. {
  141. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  142. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  143. }
  144. // else
  145. // GetDlgItem(IDC_BUTupload)->SetWindowText("上传至"+g_branchname);
  146. int i = 0;
  147. #ifdef ENTERPRISE_VERSION
  148. if (1)//g_branchname=="")
  149. {
  150. m_combobranch.ShowWindow(1);
  151. for ( i = 0; i < g_brancharray.GetSize() - 1; i++)
  152. {
  153. if (m_iparray.GetSize())
  154. {
  155. if (g_brancharray.ElementAt(i).ElementAt(2) == m_iparray.ElementAt(m_iparray.GetSize() - 1))continue;
  156. }
  157. m_combobranch.AddString(g_brancharray.ElementAt(i).ElementAt(0));
  158. m_iparray.Add(g_brancharray.ElementAt(i).ElementAt(2));
  159. }
  160. GetDlgItem(IDC_BUTupload)->ShowWindow(1);
  161. GetDlgItem(IDC_BUTselall)->ShowWindow(1);
  162. }
  163. #endif
  164. if (m_mode == 1 && IsHasRights2new(4) == 0)//拍照
  165. {
  166. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  167. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  168. }
  169. if (m_mode == 2 && IsHasRights2new(5) == 0)
  170. {
  171. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  172. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  173. }
  174. if (m_mode == 3 && IsHasRights2new(6) == 0)
  175. {
  176. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  177. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  178. }
  179. if (m_mode == 5 && IsHasRights2new(7) == 0)
  180. {
  181. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  182. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  183. }
  184. if (m_mode == 4)//礼服
  185. {
  186. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  187. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  188. }
  189. if (m_mode == 1)//拍照
  190. {
  191. GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(34));
  192. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(34));
  193. }
  194. else if (m_mode == 2)//初修
  195. {
  196. GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(35));
  197. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(35));
  198. }
  199. else if (m_mode == 3)//精修
  200. {
  201. GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(36));
  202. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(36));
  203. }
  204. else if (m_mode == 5)//设计
  205. {
  206. GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(37));
  207. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(37));
  208. GetDlgItem(IDC_BUTSetDesignNo)->EnableWindow(IsHasRights2new(7));
  209. GetDlgItem(IDC_BUTSetDesignNo)->ShowWindow(SW_SHOW);
  210. GetDlgItem(IDC_BUTexport)->EnableWindow(IsHasRights2new(12));
  211. GetDlgItem(IDC_BUTexport)->ShowWindow(SW_SHOW);
  212. }
  213. else if (m_mode == 4)//礼服
  214. {
  215. SetWindowText("礼服查看");
  216. GetDlgItem(IDC_BUTdelall)->EnableWindow(0);
  217. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(43));
  218. m_combobranch.ShowWindow(1);
  219. g_sendhead.bsql = 0;
  220. g_sendhead.code[0] = 72;
  221. g_sendhead.tabcount = 1;
  222. g_pMainWnd->ProcessChatMessageRequest2(0);
  223. if (g_bSendOK == 0)
  224. {
  225. CDialog::OnCancel();
  226. return 0;
  227. }
  228. DataToArray(&m_List1array);
  229. CStringArray typearray;
  230. for ( i = 0; i < m_List1array.GetSize(); i++)
  231. {
  232. if (-1 == ::FindArray(&typearray, m_List1array.ElementAt(i).ElementAt(0)))
  233. typearray.Add(m_List1array.ElementAt(i).ElementAt(0));
  234. }
  235. m_combobranch.AddString("全部");
  236. for (i = 0; i < typearray.GetSize(); i++)
  237. {
  238. m_combobranch.AddString(typearray.ElementAt(i));
  239. }
  240. m_combobranch.SetCurSel(0);
  241. }
  242. m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  243. m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
  244. LoadPhotos();
  245. return TRUE; // return TRUE unless you set the focus to a control
  246. // EXCEPTION: OCX Property Pages should return FALSE
  247. }
  248. DWORD ShowPic::LoadThumbNail(LPVOID lpParam)
  249. {
  250. try
  251. {
  252. ShowPic *pDlg = (ShowPic*)lpParam;
  253. CListCtrl *ListCtrl = &pDlg->m_List1;
  254. CImageList* pImgList = &pDlg->m_ImageListThumb;
  255. for (int i = 0; !pDlg->m_bExit && i < pImgList->GetImageCount(); i++)
  256. pImgList->Remove(i);
  257. ListCtrl->DeleteAllItems();
  258. pImgList->SetImageCount(pDlg->m_vFileName.GetSize());
  259. TCHAR path[MAX_PATH] = {0};
  260. vector<CString>::iterator iter;
  261. // Set redraw to FALSE to avoid flickering during adding new items
  262. ListCtrl->SetRedraw(FALSE);
  263. int nIndex = 0;
  264. INT xIndex = 0;
  265. for (nIndex = 0; !pDlg->m_bExit && nIndex < pDlg->m_vFileName.GetSize(); nIndex++)
  266. {
  267. // str和spath放在线程的for循环外面,会内存泄漏,原因未明;
  268. CString str = pDlg->m_vFileName.ElementAt(nIndex);
  269. CString spath = _T("");
  270. #ifdef USE_KERNEL_DLL
  271. xIndex = str.Find(pDlg->m_id);
  272. if ( xIndex != -1 )
  273. {
  274. str = str.Mid( xIndex + pDlg->m_id.GetLength() + 1);
  275. xIndex = str.ReverseFind(_T('.'));
  276. if ( xIndex != -1 )
  277. str = str.Left(xIndex);
  278. }
  279. #else
  280. int nPos = str.Find(pDlg->m_id);
  281. if(nPos == -1)
  282. continue;
  283. CString strLeft = str.Left(nPos + pDlg->m_id.GetLength() + 1);
  284. str = str.Right((str.GetLength() - strLeft.GetLength()));
  285. str = str.Left(str.ReverseFind('.'));
  286. #endif
  287. ListCtrl->InsertItem(nIndex, str, nIndex);
  288. }
  289. if ( pDlg->m_bExit )
  290. {
  291. pDlg->m_bRunning = false;
  292. pDlg->m_bExit = false;
  293. return 0;
  294. }
  295. ListCtrl->SetRedraw(TRUE);
  296. ListCtrl->Invalidate();
  297. const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;
  298. int XDest, YDest, nDestWidth, nDestHeight;
  299. nIndex = 0;
  300. SolidBrush whitebrush(Color(255, 255, 255, 255));
  301. for (nIndex = 0; !pDlg->m_bExit && nIndex < pDlg->m_vFileName.GetSize(); nIndex++)
  302. {
  303. // Load Image File
  304. Image *image = NULL;
  305. Bitmap *pBmp = NULL;
  306. CString str = pDlg->m_vFileName.ElementAt(nIndex);
  307. CString spath = str.Left(str.ReverseFind('\\') + 1);
  308. spath += "s";
  309. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  310. if (PathFileExists(spath))
  311. ::LoadImageFromBuf(&image, spath);
  312. else
  313. {
  314. str.MakeLower();
  315. if (str.Right(3) != "jpg")continue;
  316. ::LoadImageFromBuf(&image, str);
  317. }
  318. if (image == NULL)continue;
  319. int orientation = GetOrientation(image);
  320. if (orientation == 8)
  321. image->RotateFlip(Rotate270FlipNone);
  322. else if (orientation == 6)
  323. image->RotateFlip(Rotate90FlipNone);
  324. if (image->GetWidth() == 0)
  325. continue;
  326. // Calculate Rect to fit to canvas
  327. const float fImgRatio = (float)image->GetHeight() / image->GetWidth();
  328. if (fImgRatio > fRatio)
  329. {
  330. nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
  331. XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
  332. YDest = 0;
  333. nDestHeight = THUMBNAIL_HEIGHT;
  334. }
  335. else
  336. {
  337. XDest = 0;
  338. nDestWidth = THUMBNAIL_WIDTH;
  339. nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
  340. YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
  341. }
  342. pBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
  343. Graphics graph2(pBmp);
  344. graph2.Clear(Color(255, 192, 192, 192));
  345. graph2.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH - 2, THUMBNAIL_HEIGHT - 2);
  346. Graphics graph(pBmp);
  347. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  348. // Draw Image
  349. graph.DrawImage(image, desRect, 0, 0, image->GetWidth(), image->GetHeight(), UnitPixel);
  350. delete image;
  351. // Attach to Bitmap and Replace image in CImageList
  352. CBitmap bitmap;
  353. HBITMAP hbmp;
  354. pBmp->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
  355. bitmap.Attach(hbmp);
  356. pImgList->Replace(nIndex, &bitmap, NULL);
  357. delete pBmp;
  358. // Redraw only a current item for removing flickering and fast speed.
  359. ListCtrl->RedrawItems(nIndex, nIndex);
  360. }
  361. if (!pDlg->m_bExit)
  362. ListCtrl->Invalidate();
  363. pDlg->m_bRunning = false;
  364. pDlg->m_bExit = false;
  365. return 0;
  366. }
  367. catch (...)
  368. {
  369. }
  370. return 0;
  371. }
  372. /************************************************************************/
  373. /*
  374. 函数:TerminateRefreshTh
  375. 描述:结束刷新图片线程
  376. 参数:
  377. 返回:
  378. */
  379. /************************************************************************/
  380. BOOL ShowPic::TerminateRefreshTh()
  381. {
  382. //设为有信号
  383. if(m_hRefExitEvent)
  384. SetEvent(m_hRefExitEvent);
  385. //等待线程结束
  386. if(m_hThreadRef)
  387. WaitForSingleObject(m_hThreadRef, INFINITE);
  388. if(m_hRefExitEvent)
  389. {
  390. ::CloseHandle(m_hRefExitEvent);
  391. m_hRefExitEvent = NULL;
  392. }
  393. if(m_hThreadRef)
  394. {
  395. ::CloseHandle(m_hThreadRef);
  396. m_hThreadRef = NULL;
  397. }
  398. return TRUE;
  399. }
  400. /************************************************************************/
  401. /*
  402. 函数:RefreshThFun
  403. 描述:刷新
  404. 参数:
  405. 返回:
  406. */
  407. /************************************************************************/
  408. void ShowPic::RefreshWork()
  409. {
  410. BOOL bFinish = TRUE;
  411. for(int i=0; i<m_patharray1.GetSize(); i++)
  412. {
  413. // 等待退出信号;
  414. if(m_hRefExitEvent && WaitForSingleObject(m_hRefExitEvent, 0) == WAIT_OBJECT_0)
  415. {
  416. bFinish = FALSE;
  417. break;
  418. }
  419. CString str = m_patharray1.ElementAt(i);
  420. CString spath = str.Left(str.ReverseFind('\\') + 1);
  421. spath += "s";
  422. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  423. if(!::PathFileExists(spath))
  424. ImgThumbnail(m_patharray1.ElementAt(i), SET_PIX(100, 76), spath, 100);
  425. spath = str.Left(str.ReverseFind('\\') + 1);
  426. spath += "m";
  427. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  428. if(!::PathFileExists(spath))
  429. ImgThumbnail(m_patharray1.ElementAt(i), SET_PIX(2000, 1500), spath, 100);
  430. }
  431. if(bFinish)
  432. {
  433. MessageBox(_T("刷新完成"));
  434. LoadThumbImages();
  435. }
  436. }
  437. /************************************************************************/
  438. /*
  439. 函数:RefreshThFun
  440. 描述:线程函数
  441. 参数:
  442. 返回:
  443. */
  444. /************************************************************************/
  445. unsigned __stdcall RefreshThFun(LPVOID lpParam)
  446. {
  447. ShowPic* p = (ShowPic*)lpParam;
  448. try
  449. {
  450. p->RefreshWork();
  451. return 0;
  452. }
  453. catch (CException* e)
  454. {
  455. return 0;
  456. }
  457. }
  458. void ShowPic::LoadThumbImages()
  459. {
  460. ExitLoadThread();
  461. m_hThread = CreateThread(NULL, 0, LoadThumbNail, this, 0, NULL);
  462. if( m_hThread )
  463. {
  464. m_bRunning = true;
  465. }
  466. }
  467. BOOL ShowPic::ExitLoadThread()
  468. {
  469. if ( m_bRunning ) m_bExit = true;
  470. if ( m_hThread )
  471. {
  472. while( WaitForSingleObject(m_hThread,0) == WAIT_OBJECT_0 )
  473. {
  474. Sleep(100); // 由于该线程内容调用到各种主线程的窗口事件,所以不能死等,必须Sleep以保持主窗口线程鲜活;
  475. break;
  476. }
  477. CloseHandle(m_hThread);
  478. m_hThread = NULL;
  479. }
  480. return TRUE;
  481. }
  482. void ShowPic::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
  483. {
  484. POSITION pos;
  485. pos = m_List1.GetFirstSelectedItemPosition();
  486. if (pos == NULL)
  487. {
  488. return;
  489. }
  490. int iItem = m_List1.GetNextSelectedItem(pos);
  491. ShowPic22 dlg;
  492. dlg.m_nCurImgPos = iItem;
  493. dlg.m_AryOfImgPath = &m_patharray1;
  494. dlg.DoModal();
  495. *pResult = 0;
  496. }
  497. void ShowPic::OnDestroy()
  498. {
  499. m_bExit = true;
  500. ExitLoadThread();
  501. TerminateRefreshTh();
  502. CDialog::OnDestroy();
  503. }
  504. void ShowPic::LoadPhotos()
  505. {
  506. #ifdef USE_KERNEL_DLL
  507. if ( m_mode == 4 )
  508. {// 礼服;
  509. CString str = _T("");
  510. CString savepath = g_path5 + _T("\\");
  511. for (int i = 0; i < m_List1array.GetSize(); i++)
  512. {
  513. if (m_type != _T("") && m_type != _T("全部") && m_type != m_List1array.ElementAt(i).ElementAt(0))
  514. continue;
  515. CString str = savepath + m_List1array.ElementAt(i).ElementAt(1) + _T(".jpg");
  516. if ( PathFileExists(str) )
  517. m_patharray1.Add(str);
  518. }
  519. return;
  520. }
  521. // 非礼服,原片、初修片、精修片、设计片;
  522. INT nImgType = m_mode;
  523. if ( m_mode == 5)
  524. nImgType--;
  525. CStringArray AryLoadExtImgpath;
  526. CStringArray AryWithExtImgpath;
  527. CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname);
  528. if ( GetOrderImgpathEx(nImgType, strBranchId, m_id, TRUE, _T("*.jpg|*.jpeg"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, m_aryOfShareDirectory))
  529. {
  530. INT i = 0;
  531. CString str;
  532. m_patharray1.RemoveAll();
  533. CString strfilename;
  534. INT nSize = AryLoadExtImgpath.GetSize();
  535. for (i = 0; i < nSize; i++ )
  536. {
  537. str = AryLoadExtImgpath.ElementAt(i);
  538. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  539. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  540. str.MakeLower();
  541. if (!g_bOriginal && m_mode == 1) // 拍照;
  542. {
  543. strfilename = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  544. if (strfilename.Find(_T(".")) != -1)
  545. strfilename = strfilename.Left(strfilename.Find(_T(".")));
  546. // 若只是用于系统数字编号的,可以使用Isdigit来判断相片编号是否为数字编号;
  547. if ( !myisdigit(strfilename) )
  548. continue;
  549. }
  550. m_patharray1.Add(str);
  551. }
  552. if (m_bRunning)return;
  553. CStringArray *pArray = &m_patharray1;
  554. m_vFileName.RemoveAll();
  555. for ( i = 0; i < pArray->GetSize(); i++)
  556. {
  557. CString filePath = pArray->ElementAt(i);
  558. filePath.MakeLower();
  559. m_vFileName.Add(filePath);
  560. }
  561. LoadThumbImages();
  562. }
  563. #else
  564. m_patharray1.RemoveAll();
  565. m_path.MakeLower();
  566. CStringArray dirarray;
  567. CString str;
  568. if (m_mode == 4)//礼服
  569. {
  570. CString savepath = g_path5 + "\\";
  571. for (int i = 0; i < m_List1array.GetSize(); i++)
  572. {
  573. if (m_type != "" && m_type != "全部" && m_type != m_List1array.ElementAt(i).ElementAt(0))
  574. continue;
  575. // str=savepath+"s"+m_List1array.ElementAt (i).ElementAt (1)+".jpg";
  576. str = savepath + m_List1array.ElementAt(i).ElementAt(1) + ".jpg";
  577. if (::PathFileExists(str))
  578. m_patharray1.Add(str);
  579. }
  580. }
  581. else
  582. {
  583. #if USE_SHARE_FLORD // 多级共享目录查看相片;
  584. int nPhotoType = m_mode;
  585. if ( m_mode == 5)
  586. nPhotoType--;
  587. // 根据域名,相片类型,订单号查找相片;
  588. //LoadPhotos(nPhotoType, m_id, m_branch);
  589. m_aryOfShareDirectory.RemoveAll();
  590. CNetShareInfo::GetInstance()->LoadOrderImages(nPhotoType, m_id, m_branch, m_patharray1, &m_aryOfShareDirectory);
  591. #else
  592. if (1)
  593. {
  594. using namespace helper_coffs;
  595. ffsco o;
  596. o.dirs(1);
  597. o.find(LPCSTR(m_path), LPCSTR("*.*"));
  598. ffsco::typeT coo;
  599. ffsco::typeT::iterator it;
  600. // 1.获得所有子文件夹;
  601. coo = o.co_dir();
  602. for (it = coo.begin();coo.end() != it;it++)
  603. {
  604. str = (*it).c_str();
  605. if (FindArray(&dirarray, str) == -1)
  606. {
  607. dirarray.Add(str);
  608. }
  609. }
  610. }
  611. if (1)
  612. {
  613. CString filename;
  614. for (int i = 0; i < dirarray.GetSize(); i++)
  615. {
  616. using namespace helper_coffs;
  617. ffsco o;
  618. o.dirs(0);
  619. if (m_mode == 1)//拍照
  620. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.*"));
  621. else
  622. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  623. ffsco::typeT coo;
  624. ffsco::typeT::iterator it;
  625. // 2.获得所有子文件夹下的文件;
  626. coo = o.co_file();
  627. for (it = coo.begin();coo.end() != it;it++)
  628. {
  629. str = (*it).c_str();
  630. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  631. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  632. str.MakeLower();
  633. if (m_mode == 1)//拍照
  634. {
  635. filename = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  636. if (filename.Find(".") != -1)
  637. filename = filename.Left(filename.Find("."));
  638. if (!myisdigit(filename))continue;
  639. }
  640. m_patharray1.Add(str);
  641. }
  642. }
  643. }
  644. #endif
  645. }
  646. if (m_bRunning)return;
  647. CStringArray *pArray = &m_patharray1;
  648. m_vFileName.clear();
  649. for (int i = 0; i < pArray->GetSize(); i++)
  650. {
  651. CString filePath = pArray->ElementAt(i);
  652. filePath.MakeLower();
  653. m_vFileName.push_back(filePath);
  654. }
  655. LoadThumbImages();
  656. #endif
  657. }
  658. void ShowPic::OnBUTdelall() // 全部删除按钮;
  659. {
  660. // TODO: Add your control notification handler code here
  661. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  662. #if USE_SHARE_FLORD // 2015.04.13
  663. // 删除多级共享目录下的全部订单相片;
  664. int nSize = m_aryOfShareDirectory.GetSize();
  665. for ( int i = 0; i < nSize; i++)
  666. {
  667. DeleteDirectory(m_aryOfShareDirectory.ElementAt(i));
  668. }
  669. LoadPhotos();
  670. #else
  671. CString path = m_path;
  672. path.TrimRight('\\');
  673. DeleteDirectory(path); // 递归删除全部查看的jpg:
  674. LoadPhotos();
  675. #endif
  676. if (m_mode == 1)
  677. {
  678. CString sql;
  679. sql = "update dindan set [curno]='1' where [id]='" + m_id + "'";
  680. g_sendhead.bsql = 1;
  681. g_pMainWnd->ProcessChatMessageRequest2(sql);
  682. m_bdelall = 1;
  683. }
  684. #if 1
  685. CString str;
  686. str = "清除";
  687. str += m_name;
  688. str += m_id;
  689. str += "全部";//Jeff.add;
  690. if (m_mode == 1)
  691. str += "原片";
  692. else if (m_mode == 2)
  693. str += "初修片";
  694. else if (m_mode == 3)
  695. str += "精修片";
  696. else if (m_mode == 5)
  697. str += "设计片";
  698. WriteLog("清除订单相片", str);
  699. #endif
  700. if (g_branchname != "")
  701. {
  702. str.Format("是否同步删除分店 %s 的照片?", g_branchname);
  703. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  704. CString sql = "deletephotos";
  705. if (m_mode == 1)//拍照
  706. sql += "0";
  707. else if (m_mode == 2)//初修
  708. sql += "1";
  709. else if (m_mode == 3)//精修
  710. sql += "2";
  711. else if (m_mode == 5)//设计
  712. sql += "3";
  713. sql += m_id;
  714. sql += ";";
  715. CString jd;
  716. if (m_mode == 1)
  717. { //拍照,加景点
  718. CString file2 = m_path;
  719. int pos = file2.Find(m_id);
  720. pos += m_id.GetLength();
  721. int pos2 = file2.ReverseFind('\\');
  722. if (pos2 > pos)
  723. {
  724. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  725. }
  726. }
  727. sql += "all";
  728. sql += jd;
  729. g_sendhead.bsql = 1;
  730. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  731. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  732. #if 1//Jeff add;
  733. CString strDelContent;
  734. if (m_mode == 1)
  735. str += "原片";
  736. else if (m_mode == 2)
  737. str += "初修片";
  738. else if (m_mode == 3)
  739. str += "精修片";
  740. else if (m_mode == 5)
  741. str += "设计片";
  742. strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
  743. WriteLog("删除分店照片", strDelContent);
  744. #endif
  745. }
  746. else if (m_branch != "")
  747. {
  748. if (GetBranchPhotoPath(m_branch) == "")return;
  749. str.Format("是否同步删除分店 %s 的照片?", m_branch);
  750. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  751. CString sql = "deletephotos";
  752. if (m_mode == 1)//拍照
  753. sql += "0";
  754. else if (m_mode == 2)//初修
  755. sql += "1";
  756. else if (m_mode == 3)//精修
  757. sql += "2";
  758. else if (m_mode == 5)//设计
  759. sql += "3";
  760. sql += m_id;
  761. sql += ";";
  762. CString jd;
  763. if (m_mode == 1)
  764. { //拍照,加景点
  765. CString file2 = m_path;
  766. int pos = file2.Find(m_id);
  767. pos += m_id.GetLength();
  768. int pos2 = file2.ReverseFind('\\');
  769. if (pos2 > pos)
  770. {
  771. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  772. }
  773. }
  774. sql += "all";
  775. sql += jd;
  776. g_sendhead.bsql = 1;
  777. g_branchip = GetIP(m_branch);
  778. g_pMainWnd->OnDisconnect();
  779. g_branchname = m_branch;
  780. g_bBranchModify = 1;
  781. g_pMainWnd->ProcessChatMessageRequest2(sql);
  782. g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
  783. if (g_bSendOK == 0)return;
  784. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  785. #if 1//Jeff add;
  786. CString strDelContent;
  787. if (m_mode == 1)
  788. str += "原片";
  789. else if (m_mode == 2)
  790. str += "初修片";
  791. else if (m_mode == 3)
  792. str += "精修片";
  793. else if (m_mode == 5)
  794. str += "设计片";
  795. strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
  796. WriteLog("删除分店照片", strDelContent);
  797. #endif
  798. }
  799. }
  800. void ShowPic::OnBUTdel() // 删除按钮;
  801. {
  802. #if USE_SHARE_FLORD
  803. // 获取list列表中选中的相片集合;
  804. CStringArray delarray;
  805. GetAllSelectImage(delarray);
  806. int nPhotoType = m_mode;
  807. if ( m_mode == 5)
  808. {
  809. nPhotoType--;
  810. }
  811. CString strDomain;
  812. CStringArray strAryOfDeleted;
  813. if ( !m_branch.IsEmpty() )
  814. {
  815. strDomain = GetDomainFromBranch(m_branch);
  816. }
  817. else
  818. {
  819. strDomain = g_branchname;
  820. }
  821. int i = 0;
  822. for(i = 0; i<delarray.GetSize(); i++)
  823. {
  824. for ( int nIndex = 0; nIndex < m_vFileName.GetSize(); nIndex++)
  825. {
  826. CString str = m_vFileName.ElementAt(nIndex);
  827. if(str != _T(""))
  828. {
  829. CString strdel = delarray.ElementAt(i);
  830. strdel.TrimLeft(_T("\\"));
  831. strdel.TrimRight(_T("\\"));
  832. strdel = strdel.Right(strdel.GetLength() - strdel.ReverseFind('\\') - 1);
  833. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  834. str = str.Left(str.Find(_T(".")));
  835. if(str.CompareNoCase(strdel) == 0)
  836. strAryOfDeleted.Add(m_vFileName.ElementAt(nIndex));
  837. }
  838. }
  839. }
  840. int nDelCount = strAryOfDeleted.GetSize();
  841. //////////////////////////////////////////////////////////////////////////
  842. // 删除已找到的相片文件;
  843. CString strTemp;
  844. for ( int n = 0; n < nDelCount; n++)
  845. {
  846. // 删除原相片;
  847. strTemp = strAryOfDeleted.ElementAt(n);
  848. DeleteFile(strTemp);
  849. strTemp.MakeLower();
  850. strTemp.Replace(_T(".jpg"),_T(".nef"));
  851. DeleteFile(strTemp);
  852. strTemp.Replace(_T(".nef"),_T(".cr2"));
  853. DeleteFile(strTemp);
  854. strTemp.Replace(_T(".cr2"),_T(".raw"));
  855. DeleteFile(strTemp);
  856. strTemp.Replace(_T(".raw"),_T(".jpg"));
  857. // 再删除s+m缩略图;
  858. CString strAblum;
  859. CString strLeft, strRight;
  860. int nIndex = strTemp.ReverseFind('\\');
  861. strLeft = strTemp.Left( nIndex + 1 );
  862. strRight = strTemp.Mid( nIndex + 1);
  863. strAblum.Format("%ss%s",strLeft,strRight);
  864. DeleteFile(strAblum);
  865. strAblum.Format("%sm%s",strLeft,strRight);
  866. DeleteFile(strAblum);
  867. // 若是原片,则要删除原片目录下的上传任务;
  868. if ( m_mode == 1 && !g_branchname.IsEmpty() )
  869. {
  870. // 暂时空处理,此处逻辑未明确;
  871. }
  872. }
  873. // 重新加载相片;
  874. LoadPhotos();
  875. // 写删除日志;
  876. switch( m_mode )
  877. {
  878. case 1:
  879. strTemp.Format("删除<%s>订单<%s>的原片%d张",m_name,m_id,nDelCount);
  880. break;
  881. case 2:
  882. strTemp.Format("删除<%s>订单<%s>的初修片%d张",m_name,m_id,nDelCount);
  883. break;
  884. case 3:
  885. strTemp.Format("删除<%s>订单<%s>的精修片%d张",m_name,m_id,nDelCount);
  886. break;
  887. case 5:
  888. strTemp.Format("删除<%s>订单<%s>的设计片%d张",m_name,m_id,nDelCount);
  889. break;
  890. default:
  891. break;
  892. }
  893. WriteLog("删除订单相片", strTemp);
  894. // 当连接分店时,除了删除本店的相片外,还要删除外网分店的相片;
  895. if ( !g_branchname.IsEmpty() && strAryOfDeleted.GetSize() )
  896. {
  897. strTemp.Format("是否同步删除分店 %s 的照片?", g_branchname);
  898. if( AfxMessageBox(strTemp, MB_YESNO|MB_ICONSTOP) != IDYES )
  899. return;
  900. strTemp = "deletephotos";
  901. if( m_mode == 1 )
  902. strTemp += "0";
  903. else if( m_mode == 2 )
  904. strTemp += "1";
  905. else if( m_mode == 3 )
  906. strTemp += "2";
  907. else if( m_mode == 5 )
  908. strTemp += "3";
  909. strTemp += m_id;
  910. strTemp += ":";
  911. for(int i = 0; i < delarray.GetSize(); i++)
  912. {
  913. strTemp += delarray.ElementAt(i);
  914. strTemp += ",";
  915. }
  916. g_sendhead.bsql = 1;
  917. g_pMainWnd->ProcessChatMessageRequest2(strTemp);
  918. if( g_bSendOK == 0 )
  919. return;
  920. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  921. // 日志记录;
  922. if(m_mode==1)
  923. strTemp.Format("<%s>订单<%s>分店<%s>的原片被同步删除",m_name, m_id, g_branchname);
  924. else if(m_mode==2)
  925. strTemp.Format("<%s>订单<%s>分店<%s>的初修片被同步删除",m_name, m_id, g_branchname);
  926. else if(m_mode==3)
  927. strTemp.Format("<%s>订单<%s>分店<%s>的精修片被同步删除",m_name, m_id, g_branchname);
  928. else if(m_mode==5)
  929. strTemp.Format("<%s>订单<%s>分店<%s>的设计片被同步删除",m_name, m_id, g_branchname);
  930. WriteLog("分店相片同步删除", strTemp);
  931. }
  932. // 当多店汇总时,通过分店名得到分店域名,再删除分店的相片;
  933. if ( !m_branch.IsEmpty() && strAryOfDeleted.GetSize() )
  934. {
  935. if ( strDomain.IsEmpty() )
  936. return;
  937. strTemp.Format( "是否同步删除分店 %s 的照片?", m_branch );
  938. if( AfxMessageBox(strTemp, MB_YESNO|MB_ICONSTOP) != IDYES )
  939. return;
  940. strTemp = "deletephotos";
  941. if( m_mode == 1 )
  942. strTemp += "0";
  943. else if( m_mode == 2 )
  944. strTemp += "1";
  945. else if( m_mode == 3 )
  946. strTemp += "2";
  947. else if( m_mode == 5 )
  948. strTemp += "3";
  949. strTemp += m_id;
  950. strTemp += ":";
  951. for(int i = 0; i < delarray.GetSize(); i++)
  952. {
  953. strTemp += delarray.ElementAt(i);
  954. strTemp += ",";
  955. }
  956. g_sendhead.bsql = 1;
  957. g_pMainWnd->ProcessChatMessageRequest2(strTemp);
  958. if( g_bSendOK == 0 )
  959. return;
  960. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  961. // 日志记录;
  962. if(m_mode==1)
  963. strTemp.Format("<%s>订单<%s>分店<%s>的原片被同步删除",m_name, m_id, g_branchname);
  964. else if(m_mode==2)
  965. strTemp.Format("<%s>订单<%s>分店<%s>的初修片被同步删除",m_name, m_id, g_branchname);
  966. else if(m_mode==3)
  967. strTemp.Format("<%s>订单<%s>分店<%s>的精修片被同步删除",m_name, m_id, g_branchname);
  968. else if(m_mode==5)
  969. strTemp.Format("<%s>订单<%s>分店<%s>的设计片被同步删除",m_name, m_id, g_branchname);
  970. WriteLog("分店相片同步删除", strTemp);
  971. }
  972. // 直接返回,不执行旧过程;
  973. return ;
  974. #else
  975. // TODO: Add your control notification handler code here
  976. POSITION pos;
  977. pos = m_List1.GetFirstSelectedItemPosition();
  978. if (pos == NULL)
  979. {
  980. AfxMessageBox("请先选中您要删除的照片!", MB_ICONINFORMATION);
  981. return;
  982. }
  983. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  984. CStringArray delarray;
  985. //int nDelCount = 0; // Jeff add:被删除的相片数量;// 使用m_nDelCount成员变量;
  986. CString strDelContent; // Jeff add:删除操作的日志内容;
  987. //CStringArray strDelArray; // Jeff add:被删除的相片名称;
  988. while (pos)
  989. {
  990. int iItem = m_List1.GetNextSelectedItem(pos);
  991. CString title = m_List1.GetItemText(iItem, 0);
  992. // log的内容字段长度有限,写不下这么多文字;
  993. // 被删除的文件名不记录,只记录删除的张数;
  994. ::DeleteFile(m_path + title + ".jpg"); // 删除jpg;
  995. ::DeleteFile(m_path + title + ".NEF"); // 删除NEF;
  996. ::DeleteFile(m_path + title + ".CR2"); // 删除CR2;
  997. ::DeleteFile(m_path + title + ".raw"); // 删除raw;
  998. m_nDelCount++;
  999. int pos = title.ReverseFind('\\');
  1000. if (pos != -1)
  1001. {
  1002. ::DeleteFile(m_path + title.Left(pos + 1) + "s" + title.Right(title.GetLength() - pos - 1) + ".jpg"); // 删除s小图;
  1003. ::DeleteFile(m_path + title.Left(pos + 1) + "m" + title.Right(title.GetLength() - pos - 1) + ".jpg"); // 删除m小图;
  1004. }
  1005. else
  1006. {
  1007. ::DeleteFile(m_path + "s" + title + ".jpg"); // 删除s小图
  1008. ::DeleteFile(m_path + "m" + title + ".jpg"); // 删除m小图;
  1009. }
  1010. if (m_mode == 1 && g_branchname != "")
  1011. { //拍照,加景点
  1012. CString file2 = m_path + title;
  1013. int pos = file2.Find(m_id);
  1014. pos += m_id.GetLength();
  1015. int pos2 = file2.ReverseFind('\\');
  1016. CString jd;
  1017. if (pos2 > pos)
  1018. {
  1019. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  1020. }
  1021. CString task;
  1022. if (jd != "")
  1023. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  1024. else
  1025. task = file2.Right(file2.GetLength() - pos2 - 1);
  1026. delarray.Add(task);
  1027. }
  1028. else
  1029. {
  1030. delarray.Add(title);
  1031. }
  1032. }
  1033. LoadPhotos();
  1034. #if 1
  1035. CString str;
  1036. if (m_mode == 1)
  1037. str += "原片";
  1038. else if (m_mode == 2)
  1039. str += "初修片";
  1040. else if (m_mode == 3)
  1041. str += "精修片";
  1042. else if (m_mode == 5)
  1043. str += "设计片";
  1044. strDelContent.Format("删除%s, 订单号%s的%s:共删除%d张", m_name, m_id, str, m_nDelCount);
  1045. WriteLog("删除相片", strDelContent);
  1046. strDelContent = str;
  1047. #endif
  1048. if (delarray.GetSize() && g_branchname != "")
  1049. {
  1050. str.Format("是否同步删除分店 %s 的照片?", g_branchname);
  1051. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  1052. CString sql = "deletephotos";
  1053. if (m_mode == 1)//拍照
  1054. sql += "0";
  1055. else if (m_mode == 2)//初修
  1056. sql += "1";
  1057. else if (m_mode == 3)//精修
  1058. sql += "2";
  1059. else if (m_mode == 5)//设计
  1060. sql += "3";
  1061. sql += m_id;
  1062. sql += ";";
  1063. for (int i = 0; i < delarray.GetSize(); i++)
  1064. {
  1065. sql += delarray.ElementAt(i);
  1066. sql += ",";
  1067. }
  1068. g_sendhead.bsql = 1;
  1069. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  1070. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  1071. #if 1//Jeff add;
  1072. if (m_mode == 1)
  1073. str += "原片";
  1074. else if (m_mode == 2)
  1075. str += "初修片";
  1076. else if (m_mode == 3)
  1077. str += "精修片";
  1078. else if (m_mode == 5)
  1079. str += "设计片";
  1080. strDelContent.Format("客人%s,订单号%s的分店%s的%s被同步删除", m_name, m_id, g_branchname, str);
  1081. WriteLog("分店相片同步删除", strDelContent);
  1082. #endif
  1083. }
  1084. else if (delarray.GetSize() && m_branch != "")
  1085. {
  1086. if (GetBranchPhotoPath(m_branch) == "")return;
  1087. str.Format("是否同步删除分店 %s 的照片?", m_branch);
  1088. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  1089. CString sql = "deletephotos";
  1090. if (m_mode == 1)//拍照
  1091. sql += "0";
  1092. else if (m_mode == 2)//初修
  1093. sql += "1";
  1094. else if (m_mode == 3)//精修
  1095. sql += "2";
  1096. else if (m_mode == 5)//设计
  1097. sql += "3";
  1098. sql += m_id;
  1099. sql += ";";
  1100. for (int i = 0; i < delarray.GetSize(); i++)
  1101. {
  1102. sql += delarray.ElementAt(i);
  1103. sql += ",";
  1104. }
  1105. g_sendhead.bsql = 1;
  1106. g_branchip = GetIP(m_branch);
  1107. g_pMainWnd->OnDisconnect();
  1108. g_branchname = m_branch;
  1109. g_bBranchModify = 1;
  1110. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1111. g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
  1112. if (g_bSendOK == 0)return;
  1113. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  1114. #if 1//Jeff add;
  1115. if (m_mode == 1)
  1116. str += "原片";
  1117. else if (m_mode == 2)
  1118. str += "初修片";
  1119. else if (m_mode == 3)
  1120. str += "精修片";
  1121. else if (m_mode == 5)
  1122. str += "设计片";
  1123. strDelContent.Format("客人%s,订单号%s的分店%s的%s被同步删除", m_name, m_id, g_branchname, str);
  1124. WriteLog("分店相片同步删除", strDelContent);
  1125. #endif
  1126. }
  1127. #endif
  1128. }
  1129. extern void SaveTaskPath(CString path);
  1130. void ShowPic::OnBUTupload() //上传照片;
  1131. {
  1132. if (1)//g_branchname=="")
  1133. {
  1134. OnBUTupload2();
  1135. return;
  1136. }
  1137. // ZipTypeDlg dlg;
  1138. // dlg.DoModal ();
  1139. CString m_sel;
  1140. if (m_mode == 1)//拍照
  1141. {
  1142. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
  1143. }
  1144. else if (m_mode == 2)//初修
  1145. {
  1146. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
  1147. }
  1148. else if (m_mode == 3)//精修
  1149. {
  1150. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
  1151. }
  1152. else if (m_mode == 5)//设计
  1153. {
  1154. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
  1155. }
  1156. CStringArray m_uploadtaskarray;
  1157. m_uploadtaskarray.Add(m_id + ";" + m_name);
  1158. m_uploadtaskarray.Add("");
  1159. m_uploadtaskarray.Add("");
  1160. m_uploadtaskarray.Add(m_sel);
  1161. m_uploadtaskarray.Add("");
  1162. m_uploadtaskarray.Add("");
  1163. m_uploadtaskarray.Add("");
  1164. m_uploadtaskarray.Add("");
  1165. m_uploadtaskarray.Add("");
  1166. m_uploadtaskarray.Add("");
  1167. MyLock lock("uploadtaskaccess");
  1168. CFile fp;
  1169. CString pathdir = m_path + "uploadtask";
  1170. {
  1171. int pos = pathdir.Find(m_id);
  1172. pos += m_id.GetLength();
  1173. int pos2 = pathdir.ReverseFind('\\');
  1174. pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
  1175. }
  1176. CString path;
  1177. int taskpos = 1;
  1178. CStringArray m_olduploadtaskarray;
  1179. for (int i = 0; i < 200; i++)
  1180. {
  1181. path.Format("%s%d.dat", pathdir, i + 1);
  1182. if (PathFileExists(path))
  1183. {
  1184. CFile fp;
  1185. if (fp.Open(path, CFile::modeRead))
  1186. {
  1187. DWORD length = fp.GetLength();
  1188. if (!length)continue;
  1189. CStringArray m_array;
  1190. CArchive ar(&fp, CArchive::load);
  1191. m_array.Serialize(ar);
  1192. fp.Close();
  1193. for (int j = 10; j < m_array.GetSize(); j += 2)
  1194. {
  1195. m_olduploadtaskarray.Add(m_array.ElementAt(j));
  1196. }
  1197. }
  1198. }
  1199. }
  1200. BOOL bexist = 0;
  1201. POSITION pos;
  1202. pos = m_List1.GetFirstSelectedItemPosition();
  1203. if (pos == NULL)
  1204. {
  1205. AfxMessageBox("请选择您要上传的文件!"); return;
  1206. }
  1207. else
  1208. {
  1209. while (pos)
  1210. {
  1211. int iItem = m_List1.GetNextSelectedItem(pos);
  1212. CString title = m_List1.GetItemText(iItem, 0);
  1213. CString file2 = m_path + title + ".jpg";
  1214. if (m_mode == 1)
  1215. { //拍照,加景点
  1216. int pos = file2.Find(m_id);
  1217. pos += m_id.GetLength();
  1218. int pos2 = file2.ReverseFind('\\');
  1219. CString jd;
  1220. if (pos2 > pos)
  1221. {
  1222. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  1223. }
  1224. CString task;
  1225. if (jd != "")
  1226. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  1227. else
  1228. task = file2.Right(file2.GetLength() - pos2 - 1);
  1229. if (::FindArray(&m_olduploadtaskarray, task) == -1)
  1230. {
  1231. m_uploadtaskarray.Add(task);
  1232. m_uploadtaskarray.Add("");
  1233. }
  1234. else
  1235. bexist = 1;
  1236. }
  1237. else
  1238. {
  1239. if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
  1240. {
  1241. m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
  1242. m_uploadtaskarray.Add("");
  1243. }
  1244. else
  1245. bexist = 1;
  1246. }
  1247. }
  1248. }
  1249. if (m_uploadtaskarray.GetSize() > 10)
  1250. {
  1251. CFile fp;
  1252. CString path;
  1253. int taskpos = 1;
  1254. path.Format("%s%d.dat", pathdir, taskpos);
  1255. CString dir = path.Left(path.ReverseFind('\\') + 1);
  1256. pathdir = g_path1 + "\\上传任务\\";
  1257. ::CreateDirectory(pathdir, NULL);
  1258. path.Format("%s%d.dat", pathdir, taskpos);
  1259. while (PathFileExists(path))
  1260. {
  1261. taskpos++;
  1262. path.Format("%s%d.dat", pathdir, taskpos);
  1263. }
  1264. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  1265. CArchive ar(&fp, CArchive::store);
  1266. m_uploadtaskarray.SetAt(4, dir);
  1267. m_uploadtaskarray.Serialize(ar);
  1268. ar.Close();
  1269. fp.Close();
  1270. }
  1271. if (bexist)
  1272. AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
  1273. else
  1274. AfxMessageBox("保存上传任务成功!");
  1275. }
  1276. void ShowPic::OnBUTselall()
  1277. {
  1278. for (int i = 0; i < m_List1.GetItemCount(); i++)
  1279. m_List1.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
  1280. }
  1281. void ShowPic::OnSelchangeCombo2()
  1282. {
  1283. int pos = m_combobranch.GetCurSel();
  1284. if (pos == -1)return;
  1285. CString str;
  1286. m_combobranch.GetLBText(pos, str);
  1287. if (m_mode == 4)//礼服
  1288. {
  1289. m_type = str;
  1290. LoadPhotos();
  1291. return;
  1292. }
  1293. GetDlgItem(IDC_BUTupload)->SetWindowText("上传至" + str);
  1294. GetDlgItem(IDC_BUTupload)->Invalidate();
  1295. }
  1296. void ShowPic::OnBUTupload2()
  1297. {
  1298. int combopos = m_combobranch.GetCurSel();
  1299. if (combopos == -1)
  1300. {
  1301. AfxMessageBox("请选择您要上传到的分店!");
  1302. return;
  1303. }
  1304. CString domain = m_iparray.ElementAt(combopos);
  1305. CString savedomain;
  1306. if (m_branch != "")
  1307. {
  1308. savedomain = GetDomainFromBranch(m_branch);
  1309. }
  1310. else
  1311. {
  1312. savedomain = GetDomainFromBranch(g_branchname);
  1313. if (g_branchname == "")
  1314. savedomain = g_brancharray.ElementAt(g_brancharray.GetSize() - 1).ElementAt(2);
  1315. }
  1316. // ZipTypeDlg dlg;
  1317. // dlg.DoModal ();
  1318. CString m_sel;
  1319. if (m_mode == 1)//拍照
  1320. {
  1321. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
  1322. }
  1323. else if (m_mode == 2)//初修
  1324. {
  1325. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
  1326. }
  1327. else if (m_mode == 3)//精修
  1328. {
  1329. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
  1330. }
  1331. else if (m_mode == 5)//设计
  1332. {
  1333. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
  1334. }
  1335. CStringArray m_uploadtaskarray;
  1336. m_uploadtaskarray.Add(m_id + ";" + m_name);
  1337. m_uploadtaskarray.Add(domain);
  1338. m_uploadtaskarray.Add(savedomain);
  1339. m_uploadtaskarray.Add(m_sel);
  1340. m_uploadtaskarray.Add("");
  1341. m_uploadtaskarray.Add("");
  1342. m_uploadtaskarray.Add("");
  1343. m_uploadtaskarray.Add("");
  1344. m_uploadtaskarray.Add("");
  1345. m_uploadtaskarray.Add("");
  1346. MyLock lock("uploadtaskaccess");
  1347. CFile fp;
  1348. CString pathdir = m_path + "uploadtask";
  1349. {
  1350. int pos = pathdir.Find(m_id);
  1351. pos += m_id.GetLength();
  1352. int pos2 = pathdir.ReverseFind('\\');
  1353. pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
  1354. }
  1355. CString path;
  1356. int taskpos = 1;
  1357. CStringArray m_olduploadtaskarray;
  1358. for (int i = 0; i < 200; i++)
  1359. {
  1360. path.Format("%s%d.dat", pathdir, i + 1);
  1361. if (PathFileExists(path))
  1362. {
  1363. CFile fp;
  1364. if (fp.Open(path, CFile::modeRead))
  1365. {
  1366. DWORD length = fp.GetLength();
  1367. if (!length)continue;
  1368. CStringArray m_array;
  1369. CArchive ar(&fp, CArchive::load);
  1370. m_array.Serialize(ar);
  1371. fp.Close();
  1372. if (domain != m_array.ElementAt(1))continue;
  1373. for (int j = 10; j < m_array.GetSize(); j += 2)
  1374. {
  1375. m_olduploadtaskarray.Add(m_array.ElementAt(j));
  1376. }
  1377. }
  1378. }
  1379. }
  1380. BOOL bexist = 0;
  1381. POSITION pos;
  1382. pos = m_List1.GetFirstSelectedItemPosition();
  1383. if (pos == NULL)
  1384. {
  1385. AfxMessageBox("请选择您要上传的文件!"); return;
  1386. }
  1387. else
  1388. {
  1389. while (pos)
  1390. {
  1391. int iItem = m_List1.GetNextSelectedItem(pos);
  1392. CString title = m_List1.GetItemText(iItem, 0);
  1393. CString file2 = m_path + title + ".jpg";
  1394. if (m_mode == 1)
  1395. { //拍照,加景点
  1396. int pos = file2.Find(m_id);
  1397. pos += m_id.GetLength();
  1398. int pos2 = file2.ReverseFind('\\');
  1399. CString jd;
  1400. if (pos2 > pos)
  1401. {
  1402. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  1403. }
  1404. CString task;
  1405. if (jd != "")
  1406. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  1407. else
  1408. task = file2.Right(file2.GetLength() - pos2 - 1);
  1409. if (::FindArray(&m_olduploadtaskarray, task) == -1)
  1410. {
  1411. m_uploadtaskarray.Add(task);
  1412. m_uploadtaskarray.Add("");
  1413. }
  1414. else
  1415. bexist = 1;
  1416. }
  1417. else
  1418. {
  1419. if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
  1420. {
  1421. m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
  1422. m_uploadtaskarray.Add("");
  1423. }
  1424. else
  1425. bexist = 1;
  1426. }
  1427. }
  1428. }
  1429. if (m_uploadtaskarray.GetSize() > 10)
  1430. {
  1431. CFile fp;
  1432. CString path;
  1433. int taskpos = 1;
  1434. path.Format("%s%d.dat", pathdir, taskpos);
  1435. CString dir = path.Left(path.ReverseFind('\\') + 1);
  1436. pathdir = g_path1 + "\\上传任务\\";
  1437. ::CreateDirectory(pathdir, NULL);
  1438. path.Format("%s%d.dat", pathdir, taskpos);
  1439. while (PathFileExists(path))
  1440. {
  1441. taskpos++;
  1442. path.Format("%s%d.dat", pathdir, taskpos);
  1443. }
  1444. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  1445. CArchive ar(&fp, CArchive::store);
  1446. m_uploadtaskarray.SetAt(4, dir);
  1447. m_uploadtaskarray.Serialize(ar);
  1448. ar.Close();
  1449. fp.Close();
  1450. // SaveTaskPath(path);
  1451. }
  1452. if (bexist)
  1453. AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
  1454. else
  1455. AfxMessageBox("保存上传任务成功!");
  1456. }
  1457. void ShowPic::OnBUTSetDesignNo()
  1458. {
  1459. SetDesignNo dlg;
  1460. dlg.m_id = m_id;
  1461. dlg.DoModal();
  1462. }
  1463. void ShowPic::OnBUTexport() // 只有在设计时,才会有这个导出相片按钮;
  1464. {
  1465. if (IsHasRights2new(12) == 0)return;
  1466. POSITION pos;
  1467. pos = m_List1.GetFirstSelectedItemPosition();
  1468. if (pos == NULL)
  1469. {
  1470. AfxMessageBox("请先选中您要导出的照片!", MB_ICONINFORMATION);
  1471. return;
  1472. }
  1473. CStringArray saExportImage; // 被导出的相片路径数组;
  1474. CString strExportDirectory; // 相片导出的路径;
  1475. GetSavePath(strExportDirectory);
  1476. if (strExportDirectory.IsEmpty())
  1477. {
  1478. return;
  1479. }
  1480. strExportDirectory.TrimRight('\\');
  1481. strExportDirectory += "\\";
  1482. strExportDirectory += m_id;
  1483. strExportDirectory += m_name2;
  1484. strExportDirectory += "设计好的片修";
  1485. strExportDirectory += "\\";
  1486. ::CreateDirectory(strExportDirectory, NULL);
  1487. CStringArray desarray;
  1488. CStringArray dirarray;
  1489. CString str, str2;
  1490. int pos2;
  1491. while (pos)
  1492. {
  1493. int iItem = m_List1.GetNextSelectedItem(pos);
  1494. str = m_List1.GetItemText(iItem, 0);
  1495. str = m_path + str + ".jpg";
  1496. saExportImage.Add(str);
  1497. str2 = strExportDirectory + m_List1.GetItemText(iItem, 0) + ".jpg";
  1498. desarray.Add(str2);
  1499. str2 = "";
  1500. str = m_List1.GetItemText(iItem, 0);
  1501. pos2 = str.Find("\\");
  1502. while (pos2 != -1)
  1503. {
  1504. str2 += str.Left(pos2) + "\\";
  1505. if (::FindArray(&dirarray, str2) == -1)
  1506. {
  1507. dirarray.Add(str2);
  1508. ::CreateDirectory(strExportDirectory + str2, NULL);
  1509. }
  1510. str = str.Right(str.GetLength() - pos2 - 1);
  1511. pos2 = str.Find("\\");
  1512. }
  1513. }
  1514. CStdioFile fp;
  1515. fp.Open(strExportDirectory + "客户要求.txt", CFile::modeCreate | CFile::modeWrite);
  1516. fp.WriteString(remark);
  1517. fp.Close();
  1518. //----------------------------------------------------------------------------------------------
  1519. //----------------------------------------------------------------------------------------------
  1520. // 在设计时,导出查看的设计片;
  1521. //----------------------------------------------------------------------------------------------
  1522. //----------------------------------------------------------------------------------------------
  1523. ImportPhoto dlg;
  1524. dlg.m_mode = 1; // 1.未知;
  1525. dlg.m_pArray = &saExportImage; // 2.作为导出源的设计片的路径集合;
  1526. dlg.m_pDesArray = &desarray; // 3.作为导出目标的设计片的路径集合;
  1527. dlg.m_savepath = strExportDirectory; // 4.保存导出查看的设计片的目录;
  1528. dlg.DoModal();
  1529. AfxMessageBox("导片成功!", MB_ICONINFORMATION);
  1530. // CString str;
  1531. str = " 导出设计片 ";
  1532. str += "客人:";
  1533. str += m_name + m_id;
  1534. WriteLog("导出设计片", str);
  1535. }
  1536. /************************************************************************/
  1537. /*
  1538. 函数:OnButRefreshPhotos
  1539. 描述:刷新相片s和m图
  1540. 参数:
  1541. 返回:
  1542. */
  1543. /************************************************************************/
  1544. void ShowPic::OnButRefreshPhotos()
  1545. {
  1546. TerminateRefreshTh();
  1547. if(m_hRefExitEvent == NULL)
  1548. m_hRefExitEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
  1549. unsigned int dwID = 0;
  1550. m_hThreadRef = (HANDLE)_beginthreadex(NULL, 0, RefreshThFun, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &dwID);
  1551. }
  1552. #if USE_SHARE_FLORD
  1553. /************************************************************************/
  1554. /*
  1555. 函数:GetAllSelectImage
  1556. 描述:获取List控件中选中的全部项;
  1557. 参数:
  1558. OUT: strAry,返回选中项名称;
  1559. 返回:
  1560. 注意:
  1561. 调用约定:
  1562. */
  1563. /************************************************************************/
  1564. void ShowPic::GetAllSelectImage(OUT CStringArray &strAry)
  1565. {
  1566. strAry.RemoveAll();
  1567. POSITION pos = m_List1.GetFirstSelectedItemPosition();
  1568. if( pos == NULL)
  1569. {
  1570. AfxMessageBox("请先选中您要删除的照片!", MB_ICONINFORMATION);
  1571. return;
  1572. }
  1573. if( AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO|MB_ICONSTOP ) != IDYES ) return;
  1574. int nItem = 0;
  1575. CString strImage = _T("");
  1576. while( pos )
  1577. {
  1578. nItem = m_List1.GetNextSelectedItem( pos );
  1579. strAry.Add(m_List1.GetItemText(nItem, 0));
  1580. }
  1581. }
  1582. #endif