ShowPic.cpp 32 KB

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