ShowPic.cpp 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330
  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);
  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 0
  487. CString str;
  488. str="清除客人";
  489. str+=m_name;
  490. str+=m_id;
  491. if(m_mode==1)
  492. str+="原片";
  493. else if(m_mode==2)
  494. str+="初修片";
  495. else if(m_mode==3)
  496. str+="精修片";
  497. else if(m_mode==5)
  498. str+="设计片";
  499. WriteLog(str);
  500. #else
  501. CString str;
  502. str = "清除";
  503. str += m_name;
  504. str += m_id;
  505. str += "全部";//Jeff.add;
  506. if (m_mode == 1)
  507. str += "原片";
  508. else if (m_mode == 2)
  509. str += "初修片";
  510. else if (m_mode == 3)
  511. str += "精修片";
  512. else if (m_mode == 5)
  513. str += "设计片";
  514. WriteLog(str);
  515. #endif
  516. if (g_branchname != "")
  517. {
  518. str.Format("是否同步删除分店 %s 的照片?", g_branchname);
  519. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  520. CString sql = "deletephotos";
  521. if (m_mode == 1)//拍照
  522. sql += "0";
  523. else if (m_mode == 2)//初修
  524. sql += "1";
  525. else if (m_mode == 3)//精修
  526. sql += "2";
  527. else if (m_mode == 5)//设计
  528. sql += "3";
  529. sql += m_id;
  530. sql += ";";
  531. CString jd;
  532. if (m_mode == 1)
  533. { //拍照,加景点
  534. CString file2 = m_path;
  535. int pos = file2.Find(m_id);
  536. pos += m_id.GetLength();
  537. int pos2 = file2.ReverseFind('\\');
  538. if (pos2 > pos)
  539. {
  540. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  541. }
  542. }
  543. sql += "all";
  544. sql += jd;
  545. g_sendhead.bsql = 1;
  546. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  547. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  548. #if 1//Jeff add;
  549. CString strDelContent;
  550. if (m_mode == 1)
  551. str += "原片";
  552. else if (m_mode == 2)
  553. str += "初修片";
  554. else if (m_mode == 3)
  555. str += "精修片";
  556. else if (m_mode == 5)
  557. str += "设计片";
  558. strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
  559. WriteLog(strDelContent);
  560. #endif
  561. }
  562. else if (m_branch != "")
  563. {
  564. if (GetBranchPhotoPath(m_branch) == "")return;
  565. str.Format("是否同步删除分店 %s 的照片?", m_branch);
  566. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  567. CString sql = "deletephotos";
  568. if (m_mode == 1)//拍照
  569. sql += "0";
  570. else if (m_mode == 2)//初修
  571. sql += "1";
  572. else if (m_mode == 3)//精修
  573. sql += "2";
  574. else if (m_mode == 5)//设计
  575. sql += "3";
  576. sql += m_id;
  577. sql += ";";
  578. CString jd;
  579. if (m_mode == 1)
  580. { //拍照,加景点
  581. CString file2 = m_path;
  582. int pos = file2.Find(m_id);
  583. pos += m_id.GetLength();
  584. int pos2 = file2.ReverseFind('\\');
  585. if (pos2 > pos)
  586. {
  587. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  588. }
  589. }
  590. sql += "all";
  591. sql += jd;
  592. g_sendhead.bsql = 1;
  593. g_branchip = GetIP(m_branch);
  594. g_pMainWnd->OnDisconnect();
  595. g_branchname = m_branch;
  596. g_bBranchModify = 1;
  597. g_pMainWnd->ProcessChatMessageRequest2(sql);
  598. g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
  599. if (g_bSendOK == 0)return;
  600. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  601. #if 1//Jeff add;
  602. CString strDelContent;
  603. if (m_mode == 1)
  604. str += "原片";
  605. else if (m_mode == 2)
  606. str += "初修片";
  607. else if (m_mode == 3)
  608. str += "精修片";
  609. else if (m_mode == 5)
  610. str += "设计片";
  611. strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
  612. WriteLog(strDelContent);
  613. #endif
  614. }
  615. }
  616. void ShowPic::OnBUTdel() // 删除按钮;
  617. {
  618. // TODO: Add your control notification handler code here
  619. POSITION pos;
  620. pos = m_List1.GetFirstSelectedItemPosition();
  621. if (pos == NULL)
  622. {
  623. AfxMessageBox("请先选中您要删除的照片!", MB_ICONINFORMATION);
  624. return;
  625. }
  626. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  627. CStringArray delarray;
  628. //int nDelCount = 0; // Jeff add:被删除的相片数量;// 使用m_nDelCount成员变量;
  629. CString strDelContent; // Jeff add:删除操作的日志内容;
  630. //CStringArray strDelArray; // Jeff add:被删除的相片名称;
  631. while (pos)
  632. {
  633. int iItem = m_List1.GetNextSelectedItem(pos);
  634. CString title = m_List1.GetItemText(iItem, 0);
  635. #if 0// Jeff.
  636. ::DeleteFile(m_path+title+".jpg");
  637. ::DeleteFile(m_path+title+".NEF");
  638. ::DeleteFile(m_path+title+".CR2");
  639. ::DeleteFile(m_path+title+".raw");
  640. #else
  641. // log的内容字段长度有限,写不下这么多文字;
  642. // 被删除的文件名不记录,只记录删除的张数;
  643. /* if(::DeleteFile(m_path+title+".jpg"))
  644. strDelArray.Add(title+".jpb");
  645. if(::DeleteFile(m_path+title+".NEF"))
  646. strDelArray.Add(title+".NEF");
  647. if(::DeleteFile(m_path+title+".CR2"))
  648. strDelArray.Add(title+".CR2");
  649. if(::DeleteFile(m_path+title+".raw"))
  650. strDelArray.Add(title+".raw");*/
  651. ::DeleteFile(m_path + title + ".jpg");
  652. ::DeleteFile(m_path + title + ".NEF");
  653. ::DeleteFile(m_path + title + ".CR2");
  654. ::DeleteFile(m_path + title + ".raw");
  655. m_nDelCount++;
  656. #endif
  657. int pos = title.ReverseFind('\\');
  658. if (pos != -1)
  659. {
  660. ::DeleteFile(m_path + title.Left(pos + 1) + "s" + title.Right(title.GetLength() - pos - 1) + ".jpg");
  661. ::DeleteFile(m_path + title.Left(pos + 1) + "m" + title.Right(title.GetLength() - pos - 1) + ".jpg");
  662. }
  663. else
  664. {
  665. ::DeleteFile(m_path + "s" + title + ".jpg");
  666. ::DeleteFile(m_path + "m" + title + ".jpg");
  667. }
  668. if (m_mode == 1 && g_branchname != "")
  669. { //拍照,加景点
  670. CString file2 = m_path + title;
  671. int pos = file2.Find(m_id);
  672. pos += m_id.GetLength();
  673. int pos2 = file2.ReverseFind('\\');
  674. CString jd;
  675. if (pos2 > pos)
  676. {
  677. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  678. }
  679. CString task;
  680. if (jd != "")
  681. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  682. else
  683. task = file2.Right(file2.GetLength() - pos2 - 1);
  684. delarray.Add(task);
  685. }
  686. else
  687. {
  688. delarray.Add(title);
  689. }
  690. }
  691. LoadPhotos();
  692. #if 0//Jeff.
  693. CString str;
  694. str="删除客人";
  695. str+=m_name;
  696. str+=m_id;
  697. if(m_mode==1)
  698. str+="原片";
  699. else if(m_mode==2)
  700. str+="初修片";
  701. else if(m_mode==3)
  702. str+="精修片";
  703. else if(m_mode==5)
  704. str+="设计片";
  705. WriteLog(str);
  706. #else
  707. CString str;
  708. if (m_mode == 1)
  709. str += "原片";
  710. else if (m_mode == 2)
  711. str += "初修片";
  712. else if (m_mode == 3)
  713. str += "精修片";
  714. else if (m_mode == 5)
  715. str += "设计片";
  716. strDelContent.Format("删除%s, 订单号%s的%s:共删除%d张", m_name, m_id, str, m_nDelCount);
  717. WriteLog(strDelContent);
  718. strDelContent = str;
  719. #endif
  720. if (delarray.GetSize() && g_branchname != "")
  721. {
  722. str.Format("是否同步删除分店 %s 的照片?", g_branchname);
  723. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  724. CString sql = "deletephotos";
  725. if (m_mode == 1)//拍照
  726. sql += "0";
  727. else if (m_mode == 2)//初修
  728. sql += "1";
  729. else if (m_mode == 3)//精修
  730. sql += "2";
  731. else if (m_mode == 5)//设计
  732. sql += "3";
  733. sql += m_id;
  734. sql += ";";
  735. for (int i = 0; i < delarray.GetSize(); i++)
  736. {
  737. sql += delarray.ElementAt(i);
  738. sql += ",";
  739. }
  740. g_sendhead.bsql = 1;
  741. g_pMainWnd->ProcessChatMessageRequest2(sql); 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. else if (delarray.GetSize() && m_branch != "")
  757. {
  758. if (GetBranchPhotoPath(m_branch) == "")return;
  759. str.Format("是否同步删除分店 %s 的照片?", m_branch);
  760. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  761. CString sql = "deletephotos";
  762. if (m_mode == 1)//拍照
  763. sql += "0";
  764. else if (m_mode == 2)//初修
  765. sql += "1";
  766. else if (m_mode == 3)//精修
  767. sql += "2";
  768. else if (m_mode == 5)//设计
  769. sql += "3";
  770. sql += m_id;
  771. sql += ";";
  772. for (int i = 0; i < delarray.GetSize(); i++)
  773. {
  774. sql += delarray.ElementAt(i);
  775. sql += ",";
  776. }
  777. g_sendhead.bsql = 1;
  778. g_branchip = GetIP(m_branch);
  779. g_pMainWnd->OnDisconnect();
  780. g_branchname = m_branch;
  781. g_bBranchModify = 1;
  782. g_pMainWnd->ProcessChatMessageRequest2(sql);
  783. g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
  784. if (g_bSendOK == 0)return;
  785. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  786. #if 1//Jeff add;
  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. extern void SaveTaskPath(CString path);
  801. void ShowPic::OnBUTupload() //上传照片;
  802. {
  803. if (1)//g_branchname=="")
  804. {
  805. OnBUTupload2();
  806. return;
  807. }
  808. // ZipTypeDlg dlg;
  809. // dlg.DoModal ();
  810. CString m_sel;
  811. if (m_mode == 1)//拍照
  812. {
  813. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
  814. }
  815. else if (m_mode == 2)//初修
  816. {
  817. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
  818. }
  819. else if (m_mode == 3)//精修
  820. {
  821. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
  822. }
  823. else if (m_mode == 5)//设计
  824. {
  825. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
  826. }
  827. CStringArray m_uploadtaskarray;
  828. m_uploadtaskarray.Add(m_id + ";" + m_name);
  829. m_uploadtaskarray.Add("");
  830. m_uploadtaskarray.Add("");
  831. m_uploadtaskarray.Add(m_sel);
  832. m_uploadtaskarray.Add("");
  833. m_uploadtaskarray.Add("");
  834. m_uploadtaskarray.Add("");
  835. m_uploadtaskarray.Add("");
  836. m_uploadtaskarray.Add("");
  837. m_uploadtaskarray.Add("");
  838. MyLock lock("uploadtaskaccess");
  839. CFile fp;
  840. CString pathdir = m_path + "uploadtask";
  841. {
  842. int pos = pathdir.Find(m_id);
  843. pos += m_id.GetLength();
  844. int pos2 = pathdir.ReverseFind('\\');
  845. pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
  846. }
  847. CString path;
  848. int taskpos = 1;
  849. CStringArray m_olduploadtaskarray;
  850. for (int i = 0; i < 200; i++)
  851. {
  852. path.Format("%s%d.dat", pathdir, i + 1);
  853. if (PathFileExists(path))
  854. {
  855. CFile fp;
  856. if (fp.Open(path, CFile::modeRead))
  857. {
  858. DWORD length = fp.GetLength();
  859. if (!length)continue;
  860. CStringArray m_array;
  861. CArchive ar(&fp, CArchive::load);
  862. m_array.Serialize(ar);
  863. fp.Close();
  864. for (int j = 10; j < m_array.GetSize(); j += 2)
  865. {
  866. m_olduploadtaskarray.Add(m_array.ElementAt(j));
  867. }
  868. }
  869. }
  870. }
  871. BOOL bexist = 0;
  872. POSITION pos;
  873. pos = m_List1.GetFirstSelectedItemPosition();
  874. if (pos == NULL)
  875. {
  876. AfxMessageBox("请选择您要上传的文件!"); return;
  877. }
  878. else
  879. {
  880. while (pos)
  881. {
  882. int iItem = m_List1.GetNextSelectedItem(pos);
  883. CString title = m_List1.GetItemText(iItem, 0);
  884. CString file2 = m_path + title + ".jpg";
  885. if (m_mode == 1)
  886. { //拍照,加景点
  887. int pos = file2.Find(m_id);
  888. pos += m_id.GetLength();
  889. int pos2 = file2.ReverseFind('\\');
  890. CString jd;
  891. if (pos2 > pos)
  892. {
  893. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  894. }
  895. CString task;
  896. if (jd != "")
  897. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  898. else
  899. task = file2.Right(file2.GetLength() - pos2 - 1);
  900. if (::FindArray(&m_olduploadtaskarray, task) == -1)
  901. {
  902. m_uploadtaskarray.Add(task);
  903. m_uploadtaskarray.Add("");
  904. }
  905. else
  906. bexist = 1;
  907. }
  908. else
  909. {
  910. if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
  911. {
  912. m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
  913. m_uploadtaskarray.Add("");
  914. }
  915. else
  916. bexist = 1;
  917. }
  918. }
  919. }
  920. if (m_uploadtaskarray.GetSize() > 10)
  921. {
  922. CFile fp;
  923. CString path;
  924. int taskpos = 1;
  925. path.Format("%s%d.dat", pathdir, taskpos);
  926. CString dir = path.Left(path.ReverseFind('\\') + 1);
  927. pathdir = g_path1 + "\\上传任务\\";
  928. ::CreateDirectory(pathdir, NULL);
  929. path.Format("%s%d.dat", pathdir, taskpos);
  930. while (PathFileExists(path))
  931. {
  932. taskpos++;
  933. path.Format("%s%d.dat", pathdir, taskpos);
  934. }
  935. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  936. CArchive ar(&fp, CArchive::store);
  937. m_uploadtaskarray.SetAt(4, dir);
  938. m_uploadtaskarray.Serialize(ar);
  939. ar.Close();
  940. fp.Close();
  941. // SaveTaskPath(path);
  942. }
  943. if (bexist)
  944. AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
  945. else
  946. AfxMessageBox("保存上传任务成功!");
  947. }
  948. void ShowPic::OnBUTselall()
  949. {
  950. for (int i = 0; i < m_List1.GetItemCount(); i++)
  951. m_List1.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
  952. }
  953. void ShowPic::OnSelchangeCombo2()
  954. {
  955. int pos = m_combobranch.GetCurSel();
  956. if (pos == -1)return;
  957. CString str;
  958. m_combobranch.GetLBText(pos, str);
  959. if (m_mode == 4)//礼服
  960. {
  961. m_type = str;
  962. LoadPhotos();
  963. return;
  964. }
  965. GetDlgItem(IDC_BUTupload)->SetWindowText("上传至" + str);
  966. GetDlgItem(IDC_BUTupload)->Invalidate();
  967. }
  968. void ShowPic::OnBUTupload2()
  969. {
  970. int combopos = m_combobranch.GetCurSel();
  971. if (combopos == -1)
  972. {
  973. AfxMessageBox("请选择您要上传到的分店!");
  974. return;
  975. }
  976. CString domain = m_iparray.ElementAt(combopos);
  977. CString savedomain;
  978. if (m_branch != "")
  979. {
  980. savedomain = GetDomainFromBranch(m_branch);
  981. }
  982. else
  983. {
  984. savedomain = GetDomainFromBranch(g_branchname);
  985. if (g_branchname == "")
  986. savedomain = g_brancharray.ElementAt(g_brancharray.GetSize() - 1).ElementAt(2);
  987. }
  988. // ZipTypeDlg dlg;
  989. // dlg.DoModal ();
  990. CString m_sel;
  991. if (m_mode == 1)//拍照
  992. {
  993. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
  994. }
  995. else if (m_mode == 2)//初修
  996. {
  997. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
  998. }
  999. else if (m_mode == 3)//精修
  1000. {
  1001. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
  1002. }
  1003. else if (m_mode == 5)//设计
  1004. {
  1005. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
  1006. }
  1007. CStringArray m_uploadtaskarray;
  1008. m_uploadtaskarray.Add(m_id + ";" + m_name);
  1009. m_uploadtaskarray.Add(domain);
  1010. m_uploadtaskarray.Add(savedomain);
  1011. m_uploadtaskarray.Add(m_sel);
  1012. m_uploadtaskarray.Add("");
  1013. m_uploadtaskarray.Add("");
  1014. m_uploadtaskarray.Add("");
  1015. m_uploadtaskarray.Add("");
  1016. m_uploadtaskarray.Add("");
  1017. m_uploadtaskarray.Add("");
  1018. MyLock lock("uploadtaskaccess");
  1019. CFile fp;
  1020. CString pathdir = m_path + "uploadtask";
  1021. {
  1022. int pos = pathdir.Find(m_id);
  1023. pos += m_id.GetLength();
  1024. int pos2 = pathdir.ReverseFind('\\');
  1025. pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
  1026. }
  1027. CString path;
  1028. int taskpos = 1;
  1029. CStringArray m_olduploadtaskarray;
  1030. for (int i = 0; i < 200; i++)
  1031. {
  1032. path.Format("%s%d.dat", pathdir, i + 1);
  1033. if (PathFileExists(path))
  1034. {
  1035. CFile fp;
  1036. if (fp.Open(path, CFile::modeRead))
  1037. {
  1038. DWORD length = fp.GetLength();
  1039. if (!length)continue;
  1040. CStringArray m_array;
  1041. CArchive ar(&fp, CArchive::load);
  1042. m_array.Serialize(ar);
  1043. fp.Close();
  1044. if (domain != m_array.ElementAt(1))continue;
  1045. for (int j = 10; j < m_array.GetSize(); j += 2)
  1046. {
  1047. m_olduploadtaskarray.Add(m_array.ElementAt(j));
  1048. }
  1049. }
  1050. }
  1051. }
  1052. BOOL bexist = 0;
  1053. POSITION pos;
  1054. pos = m_List1.GetFirstSelectedItemPosition();
  1055. if (pos == NULL)
  1056. {
  1057. AfxMessageBox("请选择您要上传的文件!"); return;
  1058. }
  1059. else
  1060. {
  1061. while (pos)
  1062. {
  1063. int iItem = m_List1.GetNextSelectedItem(pos);
  1064. CString title = m_List1.GetItemText(iItem, 0);
  1065. CString file2 = m_path + title + ".jpg";
  1066. if (m_mode == 1)
  1067. { //拍照,加景点
  1068. int pos = file2.Find(m_id);
  1069. pos += m_id.GetLength();
  1070. int pos2 = file2.ReverseFind('\\');
  1071. CString jd;
  1072. if (pos2 > pos)
  1073. {
  1074. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  1075. }
  1076. CString task;
  1077. if (jd != "")
  1078. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  1079. else
  1080. task = file2.Right(file2.GetLength() - pos2 - 1);
  1081. if (::FindArray(&m_olduploadtaskarray, task) == -1)
  1082. {
  1083. m_uploadtaskarray.Add(task);
  1084. m_uploadtaskarray.Add("");
  1085. }
  1086. else
  1087. bexist = 1;
  1088. }
  1089. else
  1090. {
  1091. if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
  1092. {
  1093. m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
  1094. m_uploadtaskarray.Add("");
  1095. }
  1096. else
  1097. bexist = 1;
  1098. }
  1099. }
  1100. }
  1101. if (m_uploadtaskarray.GetSize() > 10)
  1102. {
  1103. CFile fp;
  1104. CString path;
  1105. int taskpos = 1;
  1106. path.Format("%s%d.dat", pathdir, taskpos);
  1107. CString dir = path.Left(path.ReverseFind('\\') + 1);
  1108. pathdir = g_path1 + "\\上传任务\\";
  1109. ::CreateDirectory(pathdir, NULL);
  1110. path.Format("%s%d.dat", pathdir, taskpos);
  1111. while (PathFileExists(path))
  1112. {
  1113. taskpos++;
  1114. path.Format("%s%d.dat", pathdir, taskpos);
  1115. }
  1116. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  1117. CArchive ar(&fp, CArchive::store);
  1118. m_uploadtaskarray.SetAt(4, dir);
  1119. m_uploadtaskarray.Serialize(ar);
  1120. ar.Close();
  1121. fp.Close();
  1122. // SaveTaskPath(path);
  1123. }
  1124. if (bexist)
  1125. AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
  1126. else
  1127. AfxMessageBox("保存上传任务成功!");
  1128. }
  1129. void ShowPic::OnBUTSetDesignNo()
  1130. {
  1131. SetDesignNo dlg;
  1132. dlg.m_id = m_id;
  1133. dlg.DoModal();
  1134. }
  1135. void ShowPic::OnBUTexport() // 只有在设计时,才会有这个导出相片按钮;
  1136. {
  1137. if (IsHasRights2new(12) == 0)return;
  1138. POSITION pos;
  1139. pos = m_List1.GetFirstSelectedItemPosition();
  1140. if (pos == NULL)
  1141. {
  1142. AfxMessageBox("请先选中您要导出的照片!", MB_ICONINFORMATION);
  1143. return;
  1144. }
  1145. CStringArray saExportImage; // 被导出的相片路径数组;
  1146. CString strExportDirectory; // 相片导出的路径;
  1147. GetSavePath(strExportDirectory);
  1148. if (strExportDirectory.IsEmpty())
  1149. {
  1150. return;
  1151. }
  1152. strExportDirectory.TrimRight('\\');
  1153. strExportDirectory += "\\";
  1154. strExportDirectory += m_id;
  1155. strExportDirectory += m_name2;
  1156. strExportDirectory += "设计好的片修";
  1157. strExportDirectory += "\\";
  1158. ::CreateDirectory(strExportDirectory, NULL);
  1159. CStringArray desarray;
  1160. CStringArray dirarray;
  1161. CString str, str2;
  1162. int pos2;
  1163. while (pos)
  1164. {
  1165. int iItem = m_List1.GetNextSelectedItem(pos);
  1166. str = m_List1.GetItemText(iItem, 0);
  1167. str = m_path + str + ".jpg";
  1168. saExportImage.Add(str);
  1169. str2 = strExportDirectory + m_List1.GetItemText(iItem, 0) + ".jpg";
  1170. desarray.Add(str2);
  1171. str2 = "";
  1172. str = m_List1.GetItemText(iItem, 0);
  1173. pos2 = str.Find("\\");
  1174. while (pos2 != -1)
  1175. {
  1176. str2 += str.Left(pos2) + "\\";
  1177. if (::FindArray(&dirarray, str2) == -1)
  1178. {
  1179. dirarray.Add(str2);
  1180. ::CreateDirectory(strExportDirectory + str2, NULL);
  1181. }
  1182. str = str.Right(str.GetLength() - pos2 - 1);
  1183. pos2 = str.Find("\\");
  1184. }
  1185. }
  1186. CStdioFile fp;
  1187. fp.Open(strExportDirectory + "客户要求.txt", CFile::modeCreate | CFile::modeWrite);
  1188. fp.WriteString(remark);
  1189. fp.Close();
  1190. //----------------------------------------------------------------------------------------------
  1191. //----------------------------------------------------------------------------------------------
  1192. // 在设计时,导出查看的设计片;
  1193. //----------------------------------------------------------------------------------------------
  1194. //----------------------------------------------------------------------------------------------
  1195. ImportPhoto dlg;
  1196. dlg.m_mode = 1; // 1.未知;
  1197. dlg.m_pArray = &saExportImage; // 2.作为导出源的设计片的路径集合;
  1198. dlg.m_pDesArray = &desarray; // 3.作为导出目标的设计片的路径集合;
  1199. dlg.m_savepath = strExportDirectory; // 4.保存导出查看的设计片的目录;
  1200. dlg.DoModal();
  1201. AfxMessageBox("导片成功!", MB_ICONINFORMATION);
  1202. // CString str;
  1203. str = " 导出设计片 ";
  1204. str += "客人:";
  1205. str += m_name + m_id;
  1206. WriteLog(str);
  1207. }