ShowPic.cpp 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286
  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. #define THUMBNAIL_WIDTH 100
  13. #define THUMBNAIL_HEIGHT 90
  14. /////////////////////////////////////////////////////////////////////////////
  15. // ShowPic dialog IDC_BU IDC_COMBO2
  16. ShowPic::ShowPic(CWnd* pParent /*=NULL*/)
  17. : CDialog(ShowPic::IDD, pParent)
  18. {
  19. //{{AFX_DATA_INIT(ShowPic)
  20. m_branchname = _T("");
  21. //}}AFX_DATA_INIT
  22. m_bTerminate = false;
  23. m_bRunning = false;
  24. m_hThread = NULL;
  25. m_mode = 0;
  26. m_bdelall = 0;
  27. m_nDelCount = 0;
  28. }
  29. void ShowPic::DoDataExchange(CDataExchange* pDX)
  30. {
  31. CDialog::DoDataExchange(pDX);
  32. //{{AFX_DATA_MAP(ShowPic)
  33. DDX_Control(pDX, IDC_COMBO2, m_combobranch);
  34. DDX_Control(pDX, IDC_LIST1, m_List1);
  35. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  36. DDX_CBString(pDX, IDC_COMBO2, m_branchname);
  37. //}}AFX_DATA_MAP
  38. }
  39. BEGIN_MESSAGE_MAP(ShowPic, CDialog)
  40. //{{AFX_MSG_MAP(ShowPic)
  41. ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
  42. ON_WM_DESTROY()
  43. ON_BN_CLICKED(IDC_BUTdelall, OnBUTdelall)
  44. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  45. ON_BN_CLICKED(IDC_BUTupload, OnBUTupload)
  46. ON_BN_CLICKED(IDC_BUTselall, OnBUTselall)
  47. ON_CBN_SELCHANGE(IDC_COMBO2, OnSelchangeCombo2)
  48. ON_BN_CLICKED(IDC_BUTSetDesignNo, OnBUTSetDesignNo)
  49. ON_BN_CLICKED(IDC_BUTexport, OnBUTexport)
  50. //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52. /////////////////////////////////////////////////////////////////////////////
  53. // ShowPic message handlers
  54. BOOL ShowPic::OnInitDialog()
  55. {
  56. CDialog::OnInitDialog();
  57. CRect rc2;
  58. GetWindowRect(rc2);
  59. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  60. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  61. GetDlgItem(IDOK)->GetWindowRect(rc2);
  62. ScreenToClient(rc2);
  63. int hei = rc2.Height();
  64. GetClientRect(rc2);
  65. rc2.top = hei + 10;
  66. m_List1.MoveWindow(rc2);
  67. int right = rc2.right;
  68. GetDlgItem(IDOK)->GetWindowRect(rc2);
  69. ScreenToClient(rc2);
  70. int dtx = right - rc2.right - 5;
  71. rc2.top = 5;
  72. rc2.bottom = rc2.top + hei;
  73. rc2.left += dtx;
  74. rc2.right += dtx;
  75. GetDlgItem(IDOK)->MoveWindow(rc2);
  76. GetDlgItem(IDC_BUTdel)->GetWindowRect(rc2);
  77. ScreenToClient(rc2);
  78. rc2.top = 5;
  79. rc2.bottom = rc2.top + hei;
  80. rc2.left += dtx;
  81. rc2.right += dtx;
  82. GetDlgItem(IDC_BUTdel)->MoveWindow(rc2);
  83. GetDlgItem(IDC_BUTdelall)->GetWindowRect(rc2);
  84. ScreenToClient(rc2);
  85. rc2.top = 5;
  86. rc2.bottom = rc2.top + hei;
  87. rc2.left += dtx;
  88. rc2.right += dtx;
  89. GetDlgItem(IDC_BUTdelall)->MoveWindow(rc2);
  90. GetDlgItem(IDC_BUTSetDesignNo)->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_BUTSetDesignNo)->MoveWindow(rc2);
  97. GetDlgItem(IDC_BUTexport)->GetWindowRect(rc2);
  98. ScreenToClient(rc2);
  99. rc2.top = 5;
  100. rc2.bottom = rc2.top + hei;
  101. rc2.left += dtx;
  102. rc2.right += dtx;
  103. GetDlgItem(IDC_BUTexport)->MoveWindow(rc2);
  104. //////////////////////////////////////////////////////////
  105. GetDlgItem(IDC_BUTupload)->GetWindowRect(rc2);
  106. ScreenToClient(rc2);
  107. rc2.top = 5;
  108. rc2.bottom = rc2.top + hei;
  109. GetDlgItem(IDC_BUTupload)->MoveWindow(rc2);
  110. GetDlgItem(IDC_BUTselall)->GetWindowRect(rc2);
  111. ScreenToClient(rc2);
  112. rc2.top = 5;
  113. rc2.bottom = rc2.top + hei;
  114. GetDlgItem(IDC_BUTselall)->MoveWindow(rc2);
  115. GetDlgItem(IDC_COMBO2)->GetWindowRect(rc2);
  116. ScreenToClient(rc2);
  117. rc2.top = 5;
  118. rc2.bottom = rc2.top + hei + 300;
  119. GetDlgItem(IDC_COMBO2)->MoveWindow(rc2);
  120. m_combobranch.ShowWindow(0);
  121. if (g_branchname == "")
  122. {
  123. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  124. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  125. }
  126. // else
  127. // GetDlgItem(IDC_BUTupload)->SetWindowText("上传至"+g_branchname);
  128. #ifdef ENTERPRISE_VERSION
  129. if (1)//g_branchname=="")
  130. {
  131. m_combobranch.ShowWindow(1);
  132. for (int i = 0; i < g_brancharray.GetSize() - 1; i++)
  133. {
  134. if (m_iparray.GetSize())
  135. {
  136. if (g_brancharray.ElementAt(i).ElementAt(2) == m_iparray.ElementAt(m_iparray.GetSize() - 1))continue;
  137. }
  138. m_combobranch.AddString(g_brancharray.ElementAt(i).ElementAt(0));
  139. m_iparray.Add(g_brancharray.ElementAt(i).ElementAt(2));
  140. }
  141. GetDlgItem(IDC_BUTupload)->ShowWindow(1);
  142. GetDlgItem(IDC_BUTselall)->ShowWindow(1);
  143. }
  144. #endif
  145. if (m_mode == 1 && IsHasRights2new(4) == 0)//拍照
  146. {
  147. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  148. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  149. }
  150. if (m_mode == 2 && IsHasRights2new(5) == 0)
  151. {
  152. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  153. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  154. }
  155. if (m_mode == 3 && IsHasRights2new(6) == 0)
  156. {
  157. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  158. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  159. }
  160. if (m_mode == 5 && IsHasRights2new(7) == 0)
  161. {
  162. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  163. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  164. }
  165. if (m_mode == 4)//礼服
  166. {
  167. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  168. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  169. }
  170. if (m_mode == 1)//拍照
  171. {
  172. GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(34));
  173. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(34));
  174. }
  175. else if (m_mode == 2)//初修
  176. {
  177. GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(35));
  178. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(35));
  179. }
  180. else if (m_mode == 3)//精修
  181. {
  182. GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(36));
  183. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(36));
  184. }
  185. else if (m_mode == 5)//设计
  186. {
  187. GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(37));
  188. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(37));
  189. GetDlgItem(IDC_BUTSetDesignNo)->EnableWindow(IsHasRights2new(7));
  190. GetDlgItem(IDC_BUTSetDesignNo)->ShowWindow(SW_SHOW);
  191. GetDlgItem(IDC_BUTexport)->EnableWindow(IsHasRights2new(12));
  192. GetDlgItem(IDC_BUTexport)->ShowWindow(SW_SHOW);
  193. }
  194. else if (m_mode == 4)//礼服
  195. {
  196. SetWindowText("礼服查看");
  197. GetDlgItem(IDC_BUTdelall)->EnableWindow(0);
  198. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(43));
  199. m_combobranch.ShowWindow(1);
  200. g_sendhead.bsql = 0;
  201. g_sendhead.code[0] = 72;
  202. g_sendhead.tabcount = 1;
  203. g_pMainWnd->ProcessChatMessageRequest2(0);
  204. if (g_bSendOK == 0)
  205. {
  206. CDialog::OnCancel();
  207. return 0;
  208. }
  209. DataToArray(&m_List1array);
  210. CStringArray typearray;
  211. for (int i = 0; i < m_List1array.GetSize(); i++)
  212. {
  213. if (-1 == ::FindArray(&typearray, m_List1array.ElementAt(i).ElementAt(0)))
  214. typearray.Add(m_List1array.ElementAt(i).ElementAt(0));
  215. }
  216. m_combobranch.AddString("全部");
  217. for (i = 0; i < typearray.GetSize(); i++)
  218. {
  219. m_combobranch.AddString(typearray.ElementAt(i));
  220. }
  221. m_combobranch.SetCurSel(0);
  222. }
  223. m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  224. m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
  225. LoadPhotos();
  226. return TRUE; // return TRUE unless you set the focus to a control
  227. // EXCEPTION: OCX Property Pages should return FALSE
  228. }
  229. unsigned __stdcall LoadThumbNail(LPVOID lpParam)
  230. {
  231. try
  232. {
  233. ShowPic *pDlg = (ShowPic*)lpParam;
  234. CListCtrl *ListCtrl = &pDlg->m_List1;
  235. CImageList* pImgList = &pDlg->m_ImageListThumb;
  236. // reset our image list
  237. for (int i = 0; i < pImgList->GetImageCount(); i++)
  238. pImgList->Remove(i);
  239. // remove all items from list view
  240. ListCtrl->DeleteAllItems();
  241. pImgList->SetImageCount(pDlg->m_vFileName.size());
  242. TCHAR path[MAX_PATH];
  243. vector<CString>::iterator iter;
  244. // Set redraw to FALSE to avoid flickering during adding new items
  245. ListCtrl->SetRedraw(FALSE);
  246. int nIndex = 0;
  247. CString str, spath;
  248. for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
  249. {
  250. str = *iter;
  251. spath.Empty();
  252. if (str.Left(str.ReverseFind('\\') + 1) != pDlg->m_path)
  253. {
  254. spath = str.Left(str.ReverseFind('\\') + 1);
  255. spath = spath.Right(spath.GetLength() - pDlg->m_path.GetLength());
  256. }
  257. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  258. str = spath + str.Left(str.GetLength() - 4);
  259. ListCtrl->InsertItem(nIndex, str, nIndex);
  260. }
  261. ListCtrl->SetRedraw(TRUE);
  262. ListCtrl->Invalidate();
  263. const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;
  264. int XDest, YDest, nDestWidth, nDestHeight;
  265. nIndex = 0;
  266. SolidBrush whitebrush(Color(255, 255, 255, 255));
  267. for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
  268. {
  269. // Load Image File
  270. Image *image = NULL;
  271. Bitmap *pBmp = NULL;
  272. str = *iter;
  273. spath = str.Left(str.ReverseFind('\\') + 1);
  274. spath += "s";
  275. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  276. if (PathFileExists(spath))
  277. ::LoadImageFromBuf(&image, spath);
  278. else
  279. {
  280. str.MakeLower();
  281. if (str.Right(3) != "jpg")continue;
  282. ::LoadImageFromBuf(&image, str);
  283. }
  284. if (image == NULL)continue;
  285. int orientation = GetOrientation(image);
  286. if (orientation == 8)
  287. image->RotateFlip(Rotate270FlipNone);
  288. else if (orientation == 6)
  289. image->RotateFlip(Rotate90FlipNone);
  290. if (image->GetWidth() == 0)
  291. continue;
  292. // Calculate Rect to fit to canvas
  293. const float fImgRatio = (float)image->GetHeight() / image->GetWidth();
  294. if (fImgRatio > fRatio)
  295. {
  296. nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
  297. XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
  298. YDest = 0;
  299. nDestHeight = THUMBNAIL_HEIGHT;
  300. }
  301. else
  302. {
  303. XDest = 0;
  304. nDestWidth = THUMBNAIL_WIDTH;
  305. nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
  306. YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
  307. }
  308. pBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
  309. Graphics graph2(pBmp);
  310. graph2.Clear(Color(255, 192, 192, 192));
  311. graph2.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH - 2, THUMBNAIL_HEIGHT - 2);
  312. Graphics graph(pBmp);
  313. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  314. // Draw Image
  315. graph.DrawImage(image, desRect, 0, 0, image->GetWidth(), image->GetHeight(), UnitPixel);
  316. delete image;
  317. // Attach to Bitmap and Replace image in CImageList
  318. CBitmap bitmap;
  319. HBITMAP hbmp;
  320. pBmp->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
  321. bitmap.Attach(hbmp);
  322. pImgList->Replace(nIndex, &bitmap, NULL);
  323. delete pBmp;
  324. // Redraw only a current item for removing flickering and fast speed.
  325. ListCtrl->RedrawItems(nIndex, nIndex);
  326. // Release used DC and Object
  327. }
  328. ListCtrl->Invalidate();
  329. pDlg->m_bRunning = false;
  330. pDlg->m_bTerminate = false;
  331. _endthreadex(0);
  332. return 0;
  333. }
  334. catch (...)
  335. {
  336. }
  337. }
  338. void ShowPic::LoadThumbImages()
  339. {
  340. TerminateThread();
  341. m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
  342. m_bRunning = true;
  343. }
  344. BOOL ShowPic::TerminateThread()
  345. {
  346. if (!m_bRunning)
  347. return TRUE;
  348. m_bTerminate = true;
  349. for (;;)
  350. {
  351. if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
  352. break;
  353. MSG msg;
  354. while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  355. {
  356. if (!AfxGetApp()->PumpMessage())
  357. break;
  358. }
  359. }
  360. ::CloseHandle(m_hThread);
  361. return TRUE;
  362. }
  363. void ShowPic::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
  364. {
  365. // TODO: Add your control notification handler code here
  366. POSITION pos;
  367. pos = m_List1.GetFirstSelectedItemPosition();
  368. if (pos == NULL)
  369. {
  370. return;
  371. }
  372. int iItem = m_List1.GetNextSelectedItem(pos);
  373. ShowPic22 dlg;
  374. dlg.m_pos = iItem;
  375. dlg.m_pPathArray = &m_patharray1;
  376. dlg.DoModal();
  377. *pResult = 0;
  378. }
  379. void ShowPic::OnDestroy()
  380. {
  381. TerminateThread();
  382. CDialog::OnDestroy();
  383. // TODO: Add your message handler code here
  384. }
  385. void ShowPic::LoadPhotos()
  386. {
  387. m_patharray1.RemoveAll();
  388. m_path.MakeLower();
  389. CStringArray dirarray;
  390. CString str;
  391. if (m_mode == 4)//礼服
  392. {
  393. CString savepath = g_path5 + "\\";
  394. for (int i = 0; i < m_List1array.GetSize(); i++)
  395. {
  396. if (m_type != "" && m_type != "全部" && m_type != m_List1array.ElementAt(i).ElementAt(0))
  397. continue;
  398. // str=savepath+"s"+m_List1array.ElementAt (i).ElementAt (1)+".jpg";
  399. str = savepath + m_List1array.ElementAt(i).ElementAt(1) + ".jpg";
  400. if (::PathFileExists(str))
  401. m_patharray1.Add(str);
  402. }
  403. }
  404. else
  405. {
  406. if (1)
  407. {
  408. using namespace helper_coffs;
  409. ffsco o;
  410. o.dirs(1);
  411. o.find(LPCSTR(m_path), LPCSTR("*.*"));
  412. ffsco::typeT coo;
  413. ffsco::typeT::iterator it;
  414. // 1.获得所有子文件夹;
  415. coo = o.co_dir();
  416. for (it = coo.begin();coo.end() != it;it++)
  417. {
  418. str = (*it).c_str();
  419. if (FindArray(&dirarray, str) == -1)
  420. {
  421. dirarray.Add(str);
  422. }
  423. }
  424. }
  425. if (1)
  426. {
  427. CString filename;
  428. for (int i = 0; i < dirarray.GetSize(); i++)
  429. {
  430. using namespace helper_coffs;
  431. ffsco o;
  432. o.dirs(0);
  433. if (m_mode == 1)//拍照
  434. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.*"));
  435. else
  436. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  437. ffsco::typeT coo;
  438. ffsco::typeT::iterator it;
  439. // 2.获得所有子文件夹下的文件;
  440. coo = o.co_file();
  441. for (it = coo.begin();coo.end() != it;it++)
  442. {
  443. str = (*it).c_str();
  444. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  445. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  446. str.MakeLower();
  447. if (m_mode == 1)//拍照
  448. {
  449. filename = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  450. if (filename.Find(".") != -1)
  451. filename = filename.Left(filename.Find("."));
  452. if (!myisdigit(filename))continue;
  453. }
  454. m_patharray1.Add(str);
  455. }
  456. }
  457. }
  458. }
  459. if (m_bRunning)return;
  460. CStringArray *pArray = &m_patharray1;
  461. m_vFileName.clear();
  462. for (int i = 0; i < pArray->GetSize(); i++)
  463. {
  464. CString filePath = pArray->ElementAt(i);
  465. filePath.MakeLower();
  466. m_vFileName.push_back(filePath);
  467. }
  468. LoadThumbImages();
  469. }
  470. void ShowPic::OnBUTdelall() // 全部删除按钮;
  471. {
  472. // TODO: Add your control notification handler code here
  473. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  474. CString path = m_path;
  475. path.TrimRight('\\');
  476. DeleteDirectory(path); // 递归删除全部查看的jpg:
  477. LoadPhotos();
  478. if (m_mode == 1)
  479. {
  480. CString sql;
  481. sql = "update dindan set [curno]='1' where [id]='" + m_id + "'";
  482. g_sendhead.bsql = 1;
  483. g_pMainWnd->ProcessChatMessageRequest2(sql);
  484. m_bdelall = 1;
  485. }
  486. #if 1
  487. CString str;
  488. str = "清除";
  489. str += m_name;
  490. str += m_id;
  491. str += "全部";//Jeff.add;
  492. if (m_mode == 1)
  493. str += "原片";
  494. else if (m_mode == 2)
  495. str += "初修片";
  496. else if (m_mode == 3)
  497. str += "精修片";
  498. else if (m_mode == 5)
  499. str += "设计片";
  500. WriteLog(str);
  501. #endif
  502. if (g_branchname != "")
  503. {
  504. str.Format("是否同步删除分店 %s 的照片?", g_branchname);
  505. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  506. CString sql = "deletephotos";
  507. if (m_mode == 1)//拍照
  508. sql += "0";
  509. else if (m_mode == 2)//初修
  510. sql += "1";
  511. else if (m_mode == 3)//精修
  512. sql += "2";
  513. else if (m_mode == 5)//设计
  514. sql += "3";
  515. sql += m_id;
  516. sql += ";";
  517. CString jd;
  518. if (m_mode == 1)
  519. { //拍照,加景点
  520. CString file2 = m_path;
  521. int pos = file2.Find(m_id);
  522. pos += m_id.GetLength();
  523. int pos2 = file2.ReverseFind('\\');
  524. if (pos2 > pos)
  525. {
  526. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  527. }
  528. }
  529. sql += "all";
  530. sql += jd;
  531. g_sendhead.bsql = 1;
  532. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  533. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  534. #if 1//Jeff add;
  535. CString strDelContent;
  536. if (m_mode == 1)
  537. str += "原片";
  538. else if (m_mode == 2)
  539. str += "初修片";
  540. else if (m_mode == 3)
  541. str += "精修片";
  542. else if (m_mode == 5)
  543. str += "设计片";
  544. strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
  545. WriteLog(strDelContent);
  546. #endif
  547. }
  548. else if (m_branch != "")
  549. {
  550. if (GetBranchPhotoPath(m_branch) == "")return;
  551. str.Format("是否同步删除分店 %s 的照片?", m_branch);
  552. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  553. CString sql = "deletephotos";
  554. if (m_mode == 1)//拍照
  555. sql += "0";
  556. else if (m_mode == 2)//初修
  557. sql += "1";
  558. else if (m_mode == 3)//精修
  559. sql += "2";
  560. else if (m_mode == 5)//设计
  561. sql += "3";
  562. sql += m_id;
  563. sql += ";";
  564. CString jd;
  565. if (m_mode == 1)
  566. { //拍照,加景点
  567. CString file2 = m_path;
  568. int pos = file2.Find(m_id);
  569. pos += m_id.GetLength();
  570. int pos2 = file2.ReverseFind('\\');
  571. if (pos2 > pos)
  572. {
  573. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  574. }
  575. }
  576. sql += "all";
  577. sql += jd;
  578. g_sendhead.bsql = 1;
  579. g_branchip = GetIP(m_branch);
  580. g_pMainWnd->OnDisconnect();
  581. g_branchname = m_branch;
  582. g_bBranchModify = 1;
  583. g_pMainWnd->ProcessChatMessageRequest2(sql);
  584. g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
  585. if (g_bSendOK == 0)return;
  586. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  587. #if 1//Jeff add;
  588. CString strDelContent;
  589. if (m_mode == 1)
  590. str += "原片";
  591. else if (m_mode == 2)
  592. str += "初修片";
  593. else if (m_mode == 3)
  594. str += "精修片";
  595. else if (m_mode == 5)
  596. str += "设计片";
  597. strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
  598. WriteLog(strDelContent);
  599. #endif
  600. }
  601. }
  602. void ShowPic::OnBUTdel() // 删除按钮;
  603. {
  604. // TODO: Add your control notification handler code here
  605. POSITION pos;
  606. pos = m_List1.GetFirstSelectedItemPosition();
  607. if (pos == NULL)
  608. {
  609. AfxMessageBox("请先选中您要删除的照片!", MB_ICONINFORMATION);
  610. return;
  611. }
  612. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  613. CStringArray delarray;
  614. //int nDelCount = 0; // Jeff add:被删除的相片数量;// 使用m_nDelCount成员变量;
  615. CString strDelContent; // Jeff add:删除操作的日志内容;
  616. //CStringArray strDelArray; // Jeff add:被删除的相片名称;
  617. while (pos)
  618. {
  619. int iItem = m_List1.GetNextSelectedItem(pos);
  620. CString title = m_List1.GetItemText(iItem, 0);
  621. // log的内容字段长度有限,写不下这么多文字;
  622. // 被删除的文件名不记录,只记录删除的张数;
  623. ::DeleteFile(m_path + title + ".jpg"); // 删除jpg;
  624. ::DeleteFile(m_path + title + ".NEF"); // 删除NEF;
  625. ::DeleteFile(m_path + title + ".CR2"); // 删除CR2;
  626. ::DeleteFile(m_path + title + ".raw"); // 删除raw;
  627. m_nDelCount++;
  628. int pos = title.ReverseFind('\\');
  629. if (pos != -1)
  630. {
  631. ::DeleteFile(m_path + title.Left(pos + 1) + "s" + title.Right(title.GetLength() - pos - 1) + ".jpg"); // 删除s小图;
  632. ::DeleteFile(m_path + title.Left(pos + 1) + "m" + title.Right(title.GetLength() - pos - 1) + ".jpg"); // 删除m小图;
  633. }
  634. else
  635. {
  636. ::DeleteFile(m_path + "s" + title + ".jpg"); // 删除s小图
  637. ::DeleteFile(m_path + "m" + title + ".jpg"); // 删除m小图;
  638. }
  639. if (m_mode == 1 && g_branchname != "")
  640. { //拍照,加景点
  641. CString file2 = m_path + title;
  642. int pos = file2.Find(m_id);
  643. pos += m_id.GetLength();
  644. int pos2 = file2.ReverseFind('\\');
  645. CString jd;
  646. if (pos2 > pos)
  647. {
  648. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  649. }
  650. CString task;
  651. if (jd != "")
  652. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  653. else
  654. task = file2.Right(file2.GetLength() - pos2 - 1);
  655. delarray.Add(task);
  656. }
  657. else
  658. {
  659. delarray.Add(title);
  660. }
  661. }
  662. LoadPhotos();
  663. #if 1
  664. CString str;
  665. if (m_mode == 1)
  666. str += "原片";
  667. else if (m_mode == 2)
  668. str += "初修片";
  669. else if (m_mode == 3)
  670. str += "精修片";
  671. else if (m_mode == 5)
  672. str += "设计片";
  673. strDelContent.Format("删除%s, 订单号%s的%s:共删除%d张", m_name, m_id, str, m_nDelCount);
  674. WriteLog(strDelContent);
  675. strDelContent = str;
  676. #endif
  677. if (delarray.GetSize() && g_branchname != "")
  678. {
  679. str.Format("是否同步删除分店 %s 的照片?", g_branchname);
  680. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  681. CString sql = "deletephotos";
  682. if (m_mode == 1)//拍照
  683. sql += "0";
  684. else if (m_mode == 2)//初修
  685. sql += "1";
  686. else if (m_mode == 3)//精修
  687. sql += "2";
  688. else if (m_mode == 5)//设计
  689. sql += "3";
  690. sql += m_id;
  691. sql += ";";
  692. for (int i = 0; i < delarray.GetSize(); i++)
  693. {
  694. sql += delarray.ElementAt(i);
  695. sql += ",";
  696. }
  697. g_sendhead.bsql = 1;
  698. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  699. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  700. #if 1//Jeff add;
  701. if (m_mode == 1)
  702. str += "原片";
  703. else if (m_mode == 2)
  704. str += "初修片";
  705. else if (m_mode == 3)
  706. str += "精修片";
  707. else if (m_mode == 5)
  708. str += "设计片";
  709. strDelContent.Format("客人%s,订单号%s的分店%s的%s被同步删除", m_name, m_id, g_branchname, str);
  710. WriteLog(strDelContent);
  711. #endif
  712. }
  713. else if (delarray.GetSize() && m_branch != "")
  714. {
  715. if (GetBranchPhotoPath(m_branch) == "")return;
  716. str.Format("是否同步删除分店 %s 的照片?", m_branch);
  717. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  718. CString sql = "deletephotos";
  719. if (m_mode == 1)//拍照
  720. sql += "0";
  721. else if (m_mode == 2)//初修
  722. sql += "1";
  723. else if (m_mode == 3)//精修
  724. sql += "2";
  725. else if (m_mode == 5)//设计
  726. sql += "3";
  727. sql += m_id;
  728. sql += ";";
  729. for (int i = 0; i < delarray.GetSize(); i++)
  730. {
  731. sql += delarray.ElementAt(i);
  732. sql += ",";
  733. }
  734. g_sendhead.bsql = 1;
  735. g_branchip = GetIP(m_branch);
  736. g_pMainWnd->OnDisconnect();
  737. g_branchname = m_branch;
  738. g_bBranchModify = 1;
  739. g_pMainWnd->ProcessChatMessageRequest2(sql);
  740. g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
  741. if (g_bSendOK == 0)return;
  742. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  743. #if 1//Jeff add;
  744. if (m_mode == 1)
  745. str += "原片";
  746. else if (m_mode == 2)
  747. str += "初修片";
  748. else if (m_mode == 3)
  749. str += "精修片";
  750. else if (m_mode == 5)
  751. str += "设计片";
  752. strDelContent.Format("客人%s,订单号%s的分店%s的%s被同步删除", m_name, m_id, g_branchname, str);
  753. WriteLog(strDelContent);
  754. #endif
  755. }
  756. }
  757. extern void SaveTaskPath(CString path);
  758. void ShowPic::OnBUTupload() //上传照片;
  759. {
  760. if (1)//g_branchname=="")
  761. {
  762. OnBUTupload2();
  763. return;
  764. }
  765. // ZipTypeDlg dlg;
  766. // dlg.DoModal ();
  767. CString m_sel;
  768. if (m_mode == 1)//拍照
  769. {
  770. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
  771. }
  772. else if (m_mode == 2)//初修
  773. {
  774. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
  775. }
  776. else if (m_mode == 3)//精修
  777. {
  778. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
  779. }
  780. else if (m_mode == 5)//设计
  781. {
  782. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
  783. }
  784. CStringArray m_uploadtaskarray;
  785. m_uploadtaskarray.Add(m_id + ";" + m_name);
  786. m_uploadtaskarray.Add("");
  787. m_uploadtaskarray.Add("");
  788. m_uploadtaskarray.Add(m_sel);
  789. m_uploadtaskarray.Add("");
  790. m_uploadtaskarray.Add("");
  791. m_uploadtaskarray.Add("");
  792. m_uploadtaskarray.Add("");
  793. m_uploadtaskarray.Add("");
  794. m_uploadtaskarray.Add("");
  795. MyLock lock("uploadtaskaccess");
  796. CFile fp;
  797. CString pathdir = m_path + "uploadtask";
  798. {
  799. int pos = pathdir.Find(m_id);
  800. pos += m_id.GetLength();
  801. int pos2 = pathdir.ReverseFind('\\');
  802. pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
  803. }
  804. CString path;
  805. int taskpos = 1;
  806. CStringArray m_olduploadtaskarray;
  807. for (int i = 0; i < 200; i++)
  808. {
  809. path.Format("%s%d.dat", pathdir, i + 1);
  810. if (PathFileExists(path))
  811. {
  812. CFile fp;
  813. if (fp.Open(path, CFile::modeRead))
  814. {
  815. DWORD length = fp.GetLength();
  816. if (!length)continue;
  817. CStringArray m_array;
  818. CArchive ar(&fp, CArchive::load);
  819. m_array.Serialize(ar);
  820. fp.Close();
  821. for (int j = 10; j < m_array.GetSize(); j += 2)
  822. {
  823. m_olduploadtaskarray.Add(m_array.ElementAt(j));
  824. }
  825. }
  826. }
  827. }
  828. BOOL bexist = 0;
  829. POSITION pos;
  830. pos = m_List1.GetFirstSelectedItemPosition();
  831. if (pos == NULL)
  832. {
  833. AfxMessageBox("请选择您要上传的文件!"); return;
  834. }
  835. else
  836. {
  837. while (pos)
  838. {
  839. int iItem = m_List1.GetNextSelectedItem(pos);
  840. CString title = m_List1.GetItemText(iItem, 0);
  841. CString file2 = m_path + title + ".jpg";
  842. if (m_mode == 1)
  843. { //拍照,加景点
  844. int pos = file2.Find(m_id);
  845. pos += m_id.GetLength();
  846. int pos2 = file2.ReverseFind('\\');
  847. CString jd;
  848. if (pos2 > pos)
  849. {
  850. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  851. }
  852. CString task;
  853. if (jd != "")
  854. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  855. else
  856. task = file2.Right(file2.GetLength() - pos2 - 1);
  857. if (::FindArray(&m_olduploadtaskarray, task) == -1)
  858. {
  859. m_uploadtaskarray.Add(task);
  860. m_uploadtaskarray.Add("");
  861. }
  862. else
  863. bexist = 1;
  864. }
  865. else
  866. {
  867. if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
  868. {
  869. m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
  870. m_uploadtaskarray.Add("");
  871. }
  872. else
  873. bexist = 1;
  874. }
  875. }
  876. }
  877. if (m_uploadtaskarray.GetSize() > 10)
  878. {
  879. CFile fp;
  880. CString path;
  881. int taskpos = 1;
  882. path.Format("%s%d.dat", pathdir, taskpos);
  883. CString dir = path.Left(path.ReverseFind('\\') + 1);
  884. pathdir = g_path1 + "\\上传任务\\";
  885. ::CreateDirectory(pathdir, NULL);
  886. path.Format("%s%d.dat", pathdir, taskpos);
  887. while (PathFileExists(path))
  888. {
  889. taskpos++;
  890. path.Format("%s%d.dat", pathdir, taskpos);
  891. }
  892. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  893. CArchive ar(&fp, CArchive::store);
  894. m_uploadtaskarray.SetAt(4, dir);
  895. m_uploadtaskarray.Serialize(ar);
  896. ar.Close();
  897. fp.Close();
  898. // SaveTaskPath(path);
  899. }
  900. if (bexist)
  901. AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
  902. else
  903. AfxMessageBox("保存上传任务成功!");
  904. }
  905. void ShowPic::OnBUTselall()
  906. {
  907. for (int i = 0; i < m_List1.GetItemCount(); i++)
  908. m_List1.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
  909. }
  910. void ShowPic::OnSelchangeCombo2()
  911. {
  912. int pos = m_combobranch.GetCurSel();
  913. if (pos == -1)return;
  914. CString str;
  915. m_combobranch.GetLBText(pos, str);
  916. if (m_mode == 4)//礼服
  917. {
  918. m_type = str;
  919. LoadPhotos();
  920. return;
  921. }
  922. GetDlgItem(IDC_BUTupload)->SetWindowText("上传至" + str);
  923. GetDlgItem(IDC_BUTupload)->Invalidate();
  924. }
  925. void ShowPic::OnBUTupload2()
  926. {
  927. int combopos = m_combobranch.GetCurSel();
  928. if (combopos == -1)
  929. {
  930. AfxMessageBox("请选择您要上传到的分店!");
  931. return;
  932. }
  933. CString domain = m_iparray.ElementAt(combopos);
  934. CString savedomain;
  935. if (m_branch != "")
  936. {
  937. savedomain = GetDomainFromBranch(m_branch);
  938. }
  939. else
  940. {
  941. savedomain = GetDomainFromBranch(g_branchname);
  942. if (g_branchname == "")
  943. savedomain = g_brancharray.ElementAt(g_brancharray.GetSize() - 1).ElementAt(2);
  944. }
  945. // ZipTypeDlg dlg;
  946. // dlg.DoModal ();
  947. CString m_sel;
  948. if (m_mode == 1)//拍照
  949. {
  950. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
  951. }
  952. else if (m_mode == 2)//初修
  953. {
  954. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
  955. }
  956. else if (m_mode == 3)//精修
  957. {
  958. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
  959. }
  960. else if (m_mode == 5)//设计
  961. {
  962. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
  963. }
  964. CStringArray m_uploadtaskarray;
  965. m_uploadtaskarray.Add(m_id + ";" + m_name);
  966. m_uploadtaskarray.Add(domain);
  967. m_uploadtaskarray.Add(savedomain);
  968. m_uploadtaskarray.Add(m_sel);
  969. m_uploadtaskarray.Add("");
  970. m_uploadtaskarray.Add("");
  971. m_uploadtaskarray.Add("");
  972. m_uploadtaskarray.Add("");
  973. m_uploadtaskarray.Add("");
  974. m_uploadtaskarray.Add("");
  975. MyLock lock("uploadtaskaccess");
  976. CFile fp;
  977. CString pathdir = m_path + "uploadtask";
  978. {
  979. int pos = pathdir.Find(m_id);
  980. pos += m_id.GetLength();
  981. int pos2 = pathdir.ReverseFind('\\');
  982. pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
  983. }
  984. CString path;
  985. int taskpos = 1;
  986. CStringArray m_olduploadtaskarray;
  987. for (int i = 0; i < 200; i++)
  988. {
  989. path.Format("%s%d.dat", pathdir, i + 1);
  990. if (PathFileExists(path))
  991. {
  992. CFile fp;
  993. if (fp.Open(path, CFile::modeRead))
  994. {
  995. DWORD length = fp.GetLength();
  996. if (!length)continue;
  997. CStringArray m_array;
  998. CArchive ar(&fp, CArchive::load);
  999. m_array.Serialize(ar);
  1000. fp.Close();
  1001. if (domain != m_array.ElementAt(1))continue;
  1002. for (int j = 10; j < m_array.GetSize(); j += 2)
  1003. {
  1004. m_olduploadtaskarray.Add(m_array.ElementAt(j));
  1005. }
  1006. }
  1007. }
  1008. }
  1009. BOOL bexist = 0;
  1010. POSITION pos;
  1011. pos = m_List1.GetFirstSelectedItemPosition();
  1012. if (pos == NULL)
  1013. {
  1014. AfxMessageBox("请选择您要上传的文件!"); return;
  1015. }
  1016. else
  1017. {
  1018. while (pos)
  1019. {
  1020. int iItem = m_List1.GetNextSelectedItem(pos);
  1021. CString title = m_List1.GetItemText(iItem, 0);
  1022. CString file2 = m_path + title + ".jpg";
  1023. if (m_mode == 1)
  1024. { //拍照,加景点
  1025. int pos = file2.Find(m_id);
  1026. pos += m_id.GetLength();
  1027. int pos2 = file2.ReverseFind('\\');
  1028. CString jd;
  1029. if (pos2 > pos)
  1030. {
  1031. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  1032. }
  1033. CString task;
  1034. if (jd != "")
  1035. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  1036. else
  1037. task = file2.Right(file2.GetLength() - pos2 - 1);
  1038. if (::FindArray(&m_olduploadtaskarray, task) == -1)
  1039. {
  1040. m_uploadtaskarray.Add(task);
  1041. m_uploadtaskarray.Add("");
  1042. }
  1043. else
  1044. bexist = 1;
  1045. }
  1046. else
  1047. {
  1048. if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
  1049. {
  1050. m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
  1051. m_uploadtaskarray.Add("");
  1052. }
  1053. else
  1054. bexist = 1;
  1055. }
  1056. }
  1057. }
  1058. if (m_uploadtaskarray.GetSize() > 10)
  1059. {
  1060. CFile fp;
  1061. CString path;
  1062. int taskpos = 1;
  1063. path.Format("%s%d.dat", pathdir, taskpos);
  1064. CString dir = path.Left(path.ReverseFind('\\') + 1);
  1065. pathdir = g_path1 + "\\上传任务\\";
  1066. ::CreateDirectory(pathdir, NULL);
  1067. path.Format("%s%d.dat", pathdir, taskpos);
  1068. while (PathFileExists(path))
  1069. {
  1070. taskpos++;
  1071. path.Format("%s%d.dat", pathdir, taskpos);
  1072. }
  1073. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  1074. CArchive ar(&fp, CArchive::store);
  1075. m_uploadtaskarray.SetAt(4, dir);
  1076. m_uploadtaskarray.Serialize(ar);
  1077. ar.Close();
  1078. fp.Close();
  1079. // SaveTaskPath(path);
  1080. }
  1081. if (bexist)
  1082. AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
  1083. else
  1084. AfxMessageBox("保存上传任务成功!");
  1085. }
  1086. void ShowPic::OnBUTSetDesignNo()
  1087. {
  1088. SetDesignNo dlg;
  1089. dlg.m_id = m_id;
  1090. dlg.DoModal();
  1091. }
  1092. void ShowPic::OnBUTexport() // 只有在设计时,才会有这个导出相片按钮;
  1093. {
  1094. if (IsHasRights2new(12) == 0)return;
  1095. POSITION pos;
  1096. pos = m_List1.GetFirstSelectedItemPosition();
  1097. if (pos == NULL)
  1098. {
  1099. AfxMessageBox("请先选中您要导出的照片!", MB_ICONINFORMATION);
  1100. return;
  1101. }
  1102. CStringArray saExportImage; // 被导出的相片路径数组;
  1103. CString strExportDirectory; // 相片导出的路径;
  1104. GetSavePath(strExportDirectory);
  1105. if (strExportDirectory.IsEmpty())
  1106. {
  1107. return;
  1108. }
  1109. strExportDirectory.TrimRight('\\');
  1110. strExportDirectory += "\\";
  1111. strExportDirectory += m_id;
  1112. strExportDirectory += m_name2;
  1113. strExportDirectory += "设计好的片修";
  1114. strExportDirectory += "\\";
  1115. ::CreateDirectory(strExportDirectory, NULL);
  1116. CStringArray desarray;
  1117. CStringArray dirarray;
  1118. CString str, str2;
  1119. int pos2;
  1120. while (pos)
  1121. {
  1122. int iItem = m_List1.GetNextSelectedItem(pos);
  1123. str = m_List1.GetItemText(iItem, 0);
  1124. str = m_path + str + ".jpg";
  1125. saExportImage.Add(str);
  1126. str2 = strExportDirectory + m_List1.GetItemText(iItem, 0) + ".jpg";
  1127. desarray.Add(str2);
  1128. str2 = "";
  1129. str = m_List1.GetItemText(iItem, 0);
  1130. pos2 = str.Find("\\");
  1131. while (pos2 != -1)
  1132. {
  1133. str2 += str.Left(pos2) + "\\";
  1134. if (::FindArray(&dirarray, str2) == -1)
  1135. {
  1136. dirarray.Add(str2);
  1137. ::CreateDirectory(strExportDirectory + str2, NULL);
  1138. }
  1139. str = str.Right(str.GetLength() - pos2 - 1);
  1140. pos2 = str.Find("\\");
  1141. }
  1142. }
  1143. CStdioFile fp;
  1144. fp.Open(strExportDirectory + "客户要求.txt", CFile::modeCreate | CFile::modeWrite);
  1145. fp.WriteString(remark);
  1146. fp.Close();
  1147. //----------------------------------------------------------------------------------------------
  1148. //----------------------------------------------------------------------------------------------
  1149. // 在设计时,导出查看的设计片;
  1150. //----------------------------------------------------------------------------------------------
  1151. //----------------------------------------------------------------------------------------------
  1152. ImportPhoto dlg;
  1153. dlg.m_mode = 1; // 1.未知;
  1154. dlg.m_pArray = &saExportImage; // 2.作为导出源的设计片的路径集合;
  1155. dlg.m_pDesArray = &desarray; // 3.作为导出目标的设计片的路径集合;
  1156. dlg.m_savepath = strExportDirectory; // 4.保存导出查看的设计片的目录;
  1157. dlg.DoModal();
  1158. AfxMessageBox("导片成功!", MB_ICONINFORMATION);
  1159. // CString str;
  1160. str = " 导出设计片 ";
  1161. str += "客人:";
  1162. str += m_name + m_id;
  1163. WriteLog(str);
  1164. }