ShowPic.cpp 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335
  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. int i = 0;
  209. DataToArray(&m_List1array);
  210. CStringArray typearray;
  211. for ( 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. return 0;
  338. }
  339. void ShowPic::LoadThumbImages()
  340. {
  341. TerminateThread();
  342. m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
  343. m_bRunning = true;
  344. }
  345. BOOL ShowPic::TerminateThread()
  346. {
  347. if (!m_bRunning)
  348. return TRUE;
  349. m_bTerminate = true;
  350. for (;;)
  351. {
  352. if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
  353. break;
  354. MSG msg;
  355. while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  356. {
  357. if (!AfxGetApp()->PumpMessage())
  358. break;
  359. }
  360. }
  361. ::CloseHandle(m_hThread);
  362. return TRUE;
  363. }
  364. void ShowPic::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
  365. {
  366. // TODO: Add your control notification handler code here
  367. POSITION pos;
  368. pos = m_List1.GetFirstSelectedItemPosition();
  369. if (pos == NULL)
  370. {
  371. return;
  372. }
  373. int iItem = m_List1.GetNextSelectedItem(pos);
  374. ShowPic22 dlg;
  375. dlg.m_pos = iItem;
  376. dlg.m_pPathArray = &m_patharray1;
  377. dlg.DoModal();
  378. *pResult = 0;
  379. }
  380. void ShowPic::OnDestroy()
  381. {
  382. TerminateThread();
  383. CDialog::OnDestroy();
  384. // TODO: Add your message handler code here
  385. }
  386. void ShowPic::LoadPhotos()
  387. {
  388. m_patharray1.RemoveAll();
  389. m_path.MakeLower();
  390. CStringArray dirarray;
  391. CString str;
  392. if (m_mode == 4)//礼服
  393. {
  394. CString savepath = g_path5 + "\\";
  395. for (int i = 0; i < m_List1array.GetSize(); i++)
  396. {
  397. if (m_type != "" && m_type != "全部" && m_type != m_List1array.ElementAt(i).ElementAt(0))
  398. continue;
  399. // str=savepath+"s"+m_List1array.ElementAt (i).ElementAt (1)+".jpg";
  400. str = savepath + m_List1array.ElementAt(i).ElementAt(1) + ".jpg";
  401. if (::PathFileExists(str))
  402. m_patharray1.Add(str);
  403. }
  404. }
  405. else
  406. {
  407. if (1)
  408. {
  409. using namespace helper_coffs;
  410. ffsco o;
  411. o.dirs(1);
  412. o.find(LPCSTR(m_path), LPCSTR("*.*"));
  413. ffsco::typeT coo;
  414. ffsco::typeT::iterator it;
  415. // 1.获得所有子文件夹;
  416. coo = o.co_dir();
  417. for (it = coo.begin();coo.end() != it;it++)
  418. {
  419. str = (*it).c_str();
  420. if (FindArray(&dirarray, str) == -1)
  421. {
  422. dirarray.Add(str);
  423. }
  424. }
  425. }
  426. if (1)
  427. {
  428. CString filename;
  429. for (int i = 0; i < dirarray.GetSize(); i++)
  430. {
  431. using namespace helper_coffs;
  432. ffsco o;
  433. o.dirs(0);
  434. if (m_mode == 1)//拍照
  435. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.*"));
  436. else
  437. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  438. ffsco::typeT coo;
  439. ffsco::typeT::iterator it;
  440. // 2.获得所有子文件夹下的文件;
  441. coo = o.co_file();
  442. for (it = coo.begin();coo.end() != it;it++)
  443. {
  444. str = (*it).c_str();
  445. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  446. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  447. str.MakeLower();
  448. if (m_mode == 1)//拍照
  449. {
  450. filename = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  451. if (filename.Find(".") != -1)
  452. filename = filename.Left(filename.Find("."));
  453. if (!myisdigit(filename))continue;
  454. }
  455. m_patharray1.Add(str);
  456. }
  457. }
  458. }
  459. }
  460. if (m_bRunning)return;
  461. CStringArray *pArray = &m_patharray1;
  462. m_vFileName.clear();
  463. for (int i = 0; i < pArray->GetSize(); i++)
  464. {
  465. CString filePath = pArray->ElementAt(i);
  466. filePath.MakeLower();
  467. m_vFileName.push_back(filePath);
  468. }
  469. LoadThumbImages();
  470. }
  471. void ShowPic::OnBUTdelall() // 全部删除按钮;
  472. {
  473. // TODO: Add your control notification handler code here
  474. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  475. CString path = m_path;
  476. path.TrimRight('\\');
  477. DeleteDirectory(path);
  478. LoadPhotos();
  479. if (m_mode == 1)
  480. {
  481. CString sql;
  482. sql = "update dindan set [curno]='1' where [id]='" + m_id + "'";
  483. g_sendhead.bsql = 1;
  484. g_pMainWnd->ProcessChatMessageRequest2(sql);
  485. m_bdelall = 1;
  486. }
  487. #if 0
  488. CString str;
  489. str="清除客人";
  490. str+=m_name;
  491. str+=m_id;
  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. #else
  502. CString str;
  503. str = "清除";
  504. str += m_name;
  505. str += m_id;
  506. str += "全部";//Jeff.add;
  507. if (m_mode == 1)
  508. str += "原片";
  509. else if (m_mode == 2)
  510. str += "初修片";
  511. else if (m_mode == 3)
  512. str += "精修片";
  513. else if (m_mode == 5)
  514. str += "设计片";
  515. WriteLog(_T("普通日志"), _T("清除相片"), g_user.name, str);
  516. #endif
  517. if (g_branchname != "")
  518. {
  519. str.Format("是否同步删除分店 %s 的照片?", g_branchname);
  520. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  521. CString sql = "deletephotos";
  522. if (m_mode == 1)//拍照
  523. sql += "0";
  524. else if (m_mode == 2)//初修
  525. sql += "1";
  526. else if (m_mode == 3)//精修
  527. sql += "2";
  528. else if (m_mode == 5)//设计
  529. sql += "3";
  530. sql += m_id;
  531. sql += ";";
  532. CString jd;
  533. if (m_mode == 1)
  534. { //拍照,加景点
  535. CString file2 = m_path;
  536. int pos = file2.Find(m_id);
  537. pos += m_id.GetLength();
  538. int pos2 = file2.ReverseFind('\\');
  539. if (pos2 > pos)
  540. {
  541. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  542. }
  543. }
  544. sql += "all";
  545. sql += jd;
  546. g_sendhead.bsql = 1;
  547. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  548. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  549. #if 1//Jeff add;
  550. CString strDelContent;
  551. if (m_mode == 1)
  552. str += "原片";
  553. else if (m_mode == 2)
  554. str += "初修片";
  555. else if (m_mode == 3)
  556. str += "精修片";
  557. else if (m_mode == 5)
  558. str += "设计片";
  559. strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
  560. WriteLog(_T("普通日志"), _T("远程删片"), g_user.name, str);
  561. #endif
  562. }
  563. else if (m_branch != "")
  564. {
  565. if (GetBranchPhotoPath(m_branch) == "")return;
  566. str.Format("是否同步删除分店 %s 的照片?", m_branch);
  567. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  568. CString sql = "deletephotos";
  569. if (m_mode == 1)//拍照
  570. sql += "0";
  571. else if (m_mode == 2)//初修
  572. sql += "1";
  573. else if (m_mode == 3)//精修
  574. sql += "2";
  575. else if (m_mode == 5)//设计
  576. sql += "3";
  577. sql += m_id;
  578. sql += ";";
  579. CString jd;
  580. if (m_mode == 1)
  581. { //拍照,加景点
  582. CString file2 = m_path;
  583. int pos = file2.Find(m_id);
  584. pos += m_id.GetLength();
  585. int pos2 = file2.ReverseFind('\\');
  586. if (pos2 > pos)
  587. {
  588. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  589. }
  590. }
  591. sql += "all";
  592. sql += jd;
  593. g_sendhead.bsql = 1;
  594. g_branchip = GetIP(m_branch);
  595. g_pMainWnd->OnDisconnect();
  596. g_branchname = m_branch;
  597. g_bBranchModify = 1;
  598. g_pMainWnd->ProcessChatMessageRequest2(sql);
  599. g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
  600. if (g_bSendOK == 0)return;
  601. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  602. #if 1//Jeff add;
  603. CString strDelContent;
  604. if (m_mode == 1)
  605. str += "原片";
  606. else if (m_mode == 2)
  607. str += "初修片";
  608. else if (m_mode == 3)
  609. str += "精修片";
  610. else if (m_mode == 5)
  611. str += "设计片";
  612. strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
  613. WriteLog(_T("普通日志"), _T("远程删片"), g_user.name, str);
  614. #endif
  615. }
  616. }
  617. void ShowPic::OnBUTdel() // 删除按钮;
  618. {
  619. // TODO: Add your control notification handler code here
  620. POSITION pos;
  621. pos = m_List1.GetFirstSelectedItemPosition();
  622. if (pos == NULL)
  623. {
  624. AfxMessageBox("请先选中您要删除的照片!", MB_ICONINFORMATION);
  625. return;
  626. }
  627. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  628. CStringArray delarray;
  629. int nDelCount = 0; // Jeff add:被删除的相片数量;
  630. CString strDelContent; // Jeff add:删除操作的日志内容;
  631. //CStringArray strDelArray; // Jeff add:被删除的相片名称;
  632. while (pos)
  633. {
  634. int iItem = m_List1.GetNextSelectedItem(pos);
  635. CString title = m_List1.GetItemText(iItem, 0);
  636. #if 0// Jeff.
  637. ::DeleteFile(m_path+title+".jpg");
  638. ::DeleteFile(m_path+title+".NEF");
  639. ::DeleteFile(m_path+title+".CR2");
  640. ::DeleteFile(m_path+title+".raw");
  641. #else
  642. // log的内容字段长度有限,写不下这么多文字;
  643. // 被删除的文件名不记录,只记录删除的张数;
  644. /* if(::DeleteFile(m_path+title+".jpg"))
  645. strDelArray.Add(title+".jpb");
  646. if(::DeleteFile(m_path+title+".NEF"))
  647. strDelArray.Add(title+".NEF");
  648. if(::DeleteFile(m_path+title+".CR2"))
  649. strDelArray.Add(title+".CR2");
  650. if(::DeleteFile(m_path+title+".raw"))
  651. strDelArray.Add(title+".raw");*/
  652. ::DeleteFile(m_path + title + ".jpg");
  653. ::DeleteFile(m_path + title + ".NEF");
  654. ::DeleteFile(m_path + title + ".CR2");
  655. ::DeleteFile(m_path + title + ".raw");
  656. nDelCount++;
  657. #endif
  658. int pos = title.ReverseFind('\\');
  659. if (pos != -1)
  660. {
  661. ::DeleteFile(m_path + title.Left(pos + 1) + "s" + title.Right(title.GetLength() - pos - 1) + ".jpg");
  662. ::DeleteFile(m_path + title.Left(pos + 1) + "m" + title.Right(title.GetLength() - pos - 1) + ".jpg");
  663. }
  664. else
  665. {
  666. ::DeleteFile(m_path + "s" + title + ".jpg");
  667. ::DeleteFile(m_path + "m" + title + ".jpg");
  668. }
  669. if (m_mode == 1 && g_branchname != "")
  670. { //拍照,加景点
  671. CString file2 = m_path + title;
  672. int pos = file2.Find(m_id);
  673. pos += m_id.GetLength();
  674. int pos2 = file2.ReverseFind('\\');
  675. CString jd;
  676. if (pos2 > pos)
  677. {
  678. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  679. }
  680. CString task;
  681. if (jd != "")
  682. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  683. else
  684. task = file2.Right(file2.GetLength() - pos2 - 1);
  685. delarray.Add(task);
  686. }
  687. else
  688. {
  689. delarray.Add(title);
  690. }
  691. }
  692. LoadPhotos();
  693. #if 0//Jeff.
  694. CString str;
  695. str="删除客人";
  696. str+=m_name;
  697. str+=m_id;
  698. if(m_mode==1)
  699. str+="原片";
  700. else if(m_mode==2)
  701. str+="初修片";
  702. else if(m_mode==3)
  703. str+="精修片";
  704. else if(m_mode==5)
  705. str+="设计片";
  706. WriteLog(str);
  707. #else
  708. CString str;
  709. if (m_mode == 1)
  710. str += "原片";
  711. else if (m_mode == 2)
  712. str += "初修片";
  713. else if (m_mode == 3)
  714. str += "精修片";
  715. else if (m_mode == 5)
  716. str += "设计片";
  717. strDelContent.Format("删除%s, 订单号%s的%s:共删除%d张", m_name, m_id, str, nDelCount);
  718. WriteLog(_T("普通日志"), _T("删除相片"), g_user.name, str);
  719. strDelContent = str;
  720. #endif
  721. if (delarray.GetSize() && g_branchname != "")
  722. {
  723. str.Format("是否同步删除分店 %s 的照片?", g_branchname);
  724. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  725. CString sql = "deletephotos";
  726. if (m_mode == 1)//拍照
  727. sql += "0";
  728. else if (m_mode == 2)//初修
  729. sql += "1";
  730. else if (m_mode == 3)//精修
  731. sql += "2";
  732. else if (m_mode == 5)//设计
  733. sql += "3";
  734. sql += m_id;
  735. sql += ";";
  736. for (int i = 0; i < delarray.GetSize(); i++)
  737. {
  738. sql += delarray.ElementAt(i);
  739. sql += ",";
  740. }
  741. g_sendhead.bsql = 1;
  742. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  743. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  744. #if 1//Jeff add;
  745. if (m_mode == 1)
  746. str += "原片";
  747. else if (m_mode == 2)
  748. str += "初修片";
  749. else if (m_mode == 3)
  750. str += "精修片";
  751. else if (m_mode == 5)
  752. str += "设计片";
  753. strDelContent.Format("客人%s,订单号%s的分店%s的%s被同步删除", m_name, m_id, g_branchname, str);
  754. WriteLog(_T("普通日志"), _T("删除相片"), g_user.name, str);
  755. #endif
  756. }
  757. else if (delarray.GetSize() && m_branch != "")
  758. {
  759. if (GetBranchPhotoPath(m_branch) == "")return;
  760. str.Format("是否同步删除分店 %s 的照片?", m_branch);
  761. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  762. CString sql = "deletephotos";
  763. if (m_mode == 1)//拍照
  764. sql += "0";
  765. else if (m_mode == 2)//初修
  766. sql += "1";
  767. else if (m_mode == 3)//精修
  768. sql += "2";
  769. else if (m_mode == 5)//设计
  770. sql += "3";
  771. sql += m_id;
  772. sql += ";";
  773. for (int i = 0; i < delarray.GetSize(); i++)
  774. {
  775. sql += delarray.ElementAt(i);
  776. sql += ",";
  777. }
  778. g_sendhead.bsql = 1;
  779. g_branchip = GetIP(m_branch);
  780. g_pMainWnd->OnDisconnect();
  781. g_branchname = m_branch;
  782. g_bBranchModify = 1;
  783. g_pMainWnd->ProcessChatMessageRequest2(sql);
  784. g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
  785. if (g_bSendOK == 0)return;
  786. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  787. #if 1//Jeff add;
  788. if (m_mode == 1)
  789. str += "原片";
  790. else if (m_mode == 2)
  791. str += "初修片";
  792. else if (m_mode == 3)
  793. str += "精修片";
  794. else if (m_mode == 5)
  795. str += "设计片";
  796. strDelContent.Format("客人%s,订单号%s的分店%s的%s被同步删除", m_name, m_id, g_branchname, str);
  797. WriteLog(_T("普通日志"), _T("远程删片"), g_user.name, str);
  798. #endif
  799. }
  800. }
  801. extern void SaveTaskPath(CString path);
  802. void ShowPic::OnBUTupload() //上传照片;
  803. {
  804. if (1)//g_branchname=="")
  805. {
  806. OnBUTupload2();
  807. return;
  808. }
  809. // ZipTypeDlg dlg;
  810. // dlg.DoModal ();
  811. CString m_sel;
  812. if (m_mode == 1)//拍照
  813. {
  814. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
  815. }
  816. else if (m_mode == 2)//初修
  817. {
  818. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
  819. }
  820. else if (m_mode == 3)//精修
  821. {
  822. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
  823. }
  824. else if (m_mode == 5)//设计
  825. {
  826. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
  827. }
  828. CStringArray m_uploadtaskarray;
  829. m_uploadtaskarray.Add(m_id + ";" + m_name);
  830. m_uploadtaskarray.Add("");
  831. m_uploadtaskarray.Add("");
  832. m_uploadtaskarray.Add(m_sel);
  833. m_uploadtaskarray.Add("");
  834. m_uploadtaskarray.Add("");
  835. m_uploadtaskarray.Add("");
  836. m_uploadtaskarray.Add("");
  837. m_uploadtaskarray.Add("");
  838. m_uploadtaskarray.Add("");
  839. MyLock lock("uploadtaskaccess");
  840. CFile fp;
  841. CString pathdir = m_path + "uploadtask";
  842. {
  843. int pos = pathdir.Find(m_id);
  844. pos += m_id.GetLength();
  845. int pos2 = pathdir.ReverseFind('\\');
  846. pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
  847. }
  848. CString path;
  849. int taskpos = 1;
  850. CStringArray m_olduploadtaskarray;
  851. for (int i = 0; i < 200; i++)
  852. {
  853. path.Format("%s%d.dat", pathdir, i + 1);
  854. if (PathFileExists(path))
  855. {
  856. CFile fp;
  857. if (fp.Open(path, CFile::modeRead))
  858. {
  859. DWORD length = fp.GetLength();
  860. if (!length)continue;
  861. CStringArray m_array;
  862. CArchive ar(&fp, CArchive::load);
  863. m_array.Serialize(ar);
  864. fp.Close();
  865. for (int j = 10; j < m_array.GetSize(); j += 2)
  866. {
  867. m_olduploadtaskarray.Add(m_array.ElementAt(j));
  868. }
  869. }
  870. }
  871. }
  872. BOOL bexist = 0;
  873. POSITION pos;
  874. pos = m_List1.GetFirstSelectedItemPosition();
  875. if (pos == NULL)
  876. {
  877. AfxMessageBox("请选择您要上传的文件!"); return;
  878. }
  879. else
  880. {
  881. while (pos)
  882. {
  883. int iItem = m_List1.GetNextSelectedItem(pos);
  884. CString title = m_List1.GetItemText(iItem, 0);
  885. CString file2 = m_path + title + ".jpg";
  886. if (m_mode == 1)
  887. { //拍照,加景点
  888. int pos = file2.Find(m_id);
  889. pos += m_id.GetLength();
  890. int pos2 = file2.ReverseFind('\\');
  891. CString jd;
  892. if (pos2 > pos)
  893. {
  894. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  895. }
  896. CString task;
  897. if (jd != "")
  898. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  899. else
  900. task = file2.Right(file2.GetLength() - pos2 - 1);
  901. if (::FindArray(&m_olduploadtaskarray, task) == -1)
  902. {
  903. m_uploadtaskarray.Add(task);
  904. m_uploadtaskarray.Add("");
  905. }
  906. else
  907. bexist = 1;
  908. }
  909. else
  910. {
  911. if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
  912. {
  913. m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
  914. m_uploadtaskarray.Add("");
  915. }
  916. else
  917. bexist = 1;
  918. }
  919. }
  920. }
  921. if (m_uploadtaskarray.GetSize() > 10)
  922. {
  923. CFile fp;
  924. CString path;
  925. int taskpos = 1;
  926. path.Format("%s%d.dat", pathdir, taskpos);
  927. CString dir = path.Left(path.ReverseFind('\\') + 1);
  928. pathdir = g_path1 + "\\上传任务\\";
  929. ::CreateDirectory(pathdir, NULL);
  930. path.Format("%s%d.dat", pathdir, taskpos);
  931. while (PathFileExists(path))
  932. {
  933. taskpos++;
  934. path.Format("%s%d.dat", pathdir, taskpos);
  935. }
  936. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  937. CArchive ar(&fp, CArchive::store);
  938. m_uploadtaskarray.SetAt(4, dir);
  939. m_uploadtaskarray.Serialize(ar);
  940. ar.Close();
  941. fp.Close();
  942. // SaveTaskPath(path);
  943. }
  944. if (bexist)
  945. AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
  946. else
  947. AfxMessageBox("保存上传任务成功!");
  948. }
  949. void ShowPic::OnBUTselall()
  950. {
  951. for (int i = 0; i < m_List1.GetItemCount(); i++)
  952. m_List1.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
  953. }
  954. void ShowPic::OnSelchangeCombo2()
  955. {
  956. int pos = m_combobranch.GetCurSel();
  957. if (pos == -1)return;
  958. CString str;
  959. m_combobranch.GetLBText(pos, str);
  960. if (m_mode == 4)//礼服
  961. {
  962. m_type = str;
  963. LoadPhotos();
  964. return;
  965. }
  966. GetDlgItem(IDC_BUTupload)->SetWindowText("上传至" + str);
  967. GetDlgItem(IDC_BUTupload)->Invalidate();
  968. }
  969. void ShowPic::OnBUTupload2()
  970. {
  971. int combopos = m_combobranch.GetCurSel();
  972. if (combopos == -1)
  973. {
  974. AfxMessageBox("请选择您要上传到的分店!");
  975. return;
  976. }
  977. CString domain = m_iparray.ElementAt(combopos);
  978. CString savedomain;
  979. if (m_branch != "")
  980. {
  981. savedomain = GetDomainFromBranch(m_branch);
  982. }
  983. else
  984. {
  985. savedomain = GetDomainFromBranch(g_branchname);
  986. if (g_branchname == "")
  987. savedomain = g_brancharray.ElementAt(g_brancharray.GetSize() - 1).ElementAt(2);
  988. }
  989. // ZipTypeDlg dlg;
  990. // dlg.DoModal ();
  991. CString m_sel;
  992. if (m_mode == 1)//拍照
  993. {
  994. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
  995. }
  996. else if (m_mode == 2)//初修
  997. {
  998. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
  999. }
  1000. else if (m_mode == 3)//精修
  1001. {
  1002. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
  1003. }
  1004. else if (m_mode == 5)//设计
  1005. {
  1006. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
  1007. }
  1008. CStringArray m_uploadtaskarray;
  1009. m_uploadtaskarray.Add(m_id + ";" + m_name);
  1010. m_uploadtaskarray.Add(domain);
  1011. m_uploadtaskarray.Add(savedomain);
  1012. m_uploadtaskarray.Add(m_sel);
  1013. m_uploadtaskarray.Add("");
  1014. m_uploadtaskarray.Add("");
  1015. m_uploadtaskarray.Add("");
  1016. m_uploadtaskarray.Add("");
  1017. m_uploadtaskarray.Add("");
  1018. m_uploadtaskarray.Add("");
  1019. MyLock lock("uploadtaskaccess");
  1020. CFile fp;
  1021. CString pathdir = m_path + "uploadtask";
  1022. {
  1023. int pos = pathdir.Find(m_id);
  1024. pos += m_id.GetLength();
  1025. int pos2 = pathdir.ReverseFind('\\');
  1026. pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
  1027. }
  1028. CString path;
  1029. int taskpos = 1;
  1030. CStringArray m_olduploadtaskarray;
  1031. for (int i = 0; i < 200; i++)
  1032. {
  1033. path.Format("%s%d.dat", pathdir, i + 1);
  1034. if (PathFileExists(path))
  1035. {
  1036. CFile fp;
  1037. if (fp.Open(path, CFile::modeRead))
  1038. {
  1039. DWORD length = fp.GetLength();
  1040. if (!length)continue;
  1041. CStringArray m_array;
  1042. CArchive ar(&fp, CArchive::load);
  1043. m_array.Serialize(ar);
  1044. fp.Close();
  1045. if (domain != m_array.ElementAt(1))continue;
  1046. for (int j = 10; j < m_array.GetSize(); j += 2)
  1047. {
  1048. m_olduploadtaskarray.Add(m_array.ElementAt(j));
  1049. }
  1050. }
  1051. }
  1052. }
  1053. BOOL bexist = 0;
  1054. POSITION pos;
  1055. pos = m_List1.GetFirstSelectedItemPosition();
  1056. if (pos == NULL)
  1057. {
  1058. AfxMessageBox("请选择您要上传的文件!"); return;
  1059. }
  1060. else
  1061. {
  1062. while (pos)
  1063. {
  1064. int iItem = m_List1.GetNextSelectedItem(pos);
  1065. CString title = m_List1.GetItemText(iItem, 0);
  1066. CString file2 = m_path + title + ".jpg";
  1067. if (m_mode == 1)
  1068. { //拍照,加景点
  1069. int pos = file2.Find(m_id);
  1070. pos += m_id.GetLength();
  1071. int pos2 = file2.ReverseFind('\\');
  1072. CString jd;
  1073. if (pos2 > pos)
  1074. {
  1075. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  1076. }
  1077. CString task;
  1078. if (jd != "")
  1079. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  1080. else
  1081. task = file2.Right(file2.GetLength() - pos2 - 1);
  1082. if (::FindArray(&m_olduploadtaskarray, task) == -1)
  1083. {
  1084. m_uploadtaskarray.Add(task);
  1085. m_uploadtaskarray.Add("");
  1086. }
  1087. else
  1088. bexist = 1;
  1089. }
  1090. else
  1091. {
  1092. if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
  1093. {
  1094. m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
  1095. m_uploadtaskarray.Add("");
  1096. }
  1097. else
  1098. bexist = 1;
  1099. }
  1100. }
  1101. }
  1102. if (m_uploadtaskarray.GetSize() > 10)
  1103. {
  1104. CFile fp;
  1105. CString path;
  1106. int taskpos = 1;
  1107. path.Format("%s%d.dat", pathdir, taskpos);
  1108. CString dir = path.Left(path.ReverseFind('\\') + 1);
  1109. pathdir = g_path1 + "\\上传任务\\";
  1110. ::CreateDirectory(pathdir, NULL);
  1111. path.Format("%s%d.dat", pathdir, taskpos);
  1112. while (PathFileExists(path))
  1113. {
  1114. taskpos++;
  1115. path.Format("%s%d.dat", pathdir, taskpos);
  1116. }
  1117. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  1118. CArchive ar(&fp, CArchive::store);
  1119. m_uploadtaskarray.SetAt(4, dir);
  1120. m_uploadtaskarray.Serialize(ar);
  1121. ar.Close();
  1122. fp.Close();
  1123. // SaveTaskPath(path);
  1124. }
  1125. if (bexist)
  1126. AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
  1127. else
  1128. AfxMessageBox("保存上传任务成功!");
  1129. }
  1130. void ShowPic::OnBUTSetDesignNo()
  1131. {
  1132. SetDesignNo dlg;
  1133. dlg.m_id = m_id;
  1134. dlg.DoModal();
  1135. }
  1136. void ShowPic::OnBUTexport() // 只有在设计时,才会有这个导出相片按钮;
  1137. {
  1138. if (IsHasRights2new(12) == 0)return;
  1139. POSITION pos;
  1140. pos = m_List1.GetFirstSelectedItemPosition();
  1141. if (pos == NULL)
  1142. {
  1143. AfxMessageBox("请先选中您要导出的照片!", MB_ICONINFORMATION);
  1144. return;
  1145. }
  1146. CStringArray saExportImage; // 被导出的相片路径数组;
  1147. CString strExportDirectory; // 相片导出的路径;
  1148. GetSavePath(strExportDirectory);
  1149. if (strExportDirectory.IsEmpty())
  1150. {
  1151. return;
  1152. }
  1153. strExportDirectory.TrimRight('\\');
  1154. strExportDirectory += "\\";
  1155. strExportDirectory += m_id;
  1156. strExportDirectory += m_name2;
  1157. strExportDirectory += "设计好的片修";
  1158. strExportDirectory += "\\";
  1159. ::CreateDirectory(strExportDirectory, NULL);
  1160. CStringArray desarray;
  1161. CStringArray dirarray;
  1162. CString str, str2;
  1163. int pos2;
  1164. while (pos)
  1165. {
  1166. int iItem = m_List1.GetNextSelectedItem(pos);
  1167. str = m_List1.GetItemText(iItem, 0);
  1168. str = m_path + str + ".jpg";
  1169. saExportImage.Add(str);
  1170. str2 = strExportDirectory + m_List1.GetItemText(iItem, 0) + ".jpg";
  1171. desarray.Add(str2);
  1172. str2 = "";
  1173. str = m_List1.GetItemText(iItem, 0);
  1174. pos2 = str.Find("\\");
  1175. while (pos2 != -1)
  1176. {
  1177. str2 += str.Left(pos2) + "\\";
  1178. if (::FindArray(&dirarray, str2) == -1)
  1179. {
  1180. dirarray.Add(str2);
  1181. ::CreateDirectory(strExportDirectory + str2, NULL);
  1182. }
  1183. str = str.Right(str.GetLength() - pos2 - 1);
  1184. pos2 = str.Find("\\");
  1185. }
  1186. }
  1187. CStdioFile fp;
  1188. fp.Open(strExportDirectory + "客户要求.txt", CFile::modeCreate | CFile::modeWrite);
  1189. fp.WriteString(remark);
  1190. fp.Close();
  1191. //----------------------------------------------------------------------------------------------
  1192. //----------------------------------------------------------------------------------------------
  1193. // 在设计时,导出查看的设计片;
  1194. //----------------------------------------------------------------------------------------------
  1195. //----------------------------------------------------------------------------------------------
  1196. ImportPhoto dlg;
  1197. dlg.m_mode = 1; // 1.未知;
  1198. dlg.m_pArray = &saExportImage; // 2.作为导出源的设计片的路径集合;
  1199. dlg.m_pDesArray = &desarray; // 3.作为导出目标的设计片的路径集合;
  1200. dlg.m_savepath = strExportDirectory; // 4.保存导出查看的设计片的目录;
  1201. dlg.DoModal();
  1202. AfxMessageBox("导片成功!", MB_ICONINFORMATION);
  1203. // CString str;
  1204. str = " 导出设计片 ";
  1205. str += "客人:";
  1206. str += m_name + m_id;
  1207. WriteLog(_T("普通日志"), _T("导出设计片"), g_user.name, str);
  1208. }