ChoosePhotoBase.cpp 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502
  1. #include "StdAfx.h"
  2. #include "ChoosePhotoBase.h"
  3. #include "YLGL.h"
  4. #include "./helper/ffsco.h"
  5. using namespace helper_coffs;
  6. unsigned __stdcall LoadThumbNail3(LPVOID lpParam);
  7. ChoosePhotoBase::ChoosePhotoBase()
  8. {
  9. m_SelectCategory = INDX_ALL;
  10. m_bSaveFail = 0;
  11. m_liapath = _T("");
  12. m_path = _T(""); // 选片或看设计的片种目录;
  13. m_strOrderNumber = _T("");
  14. m_status8 = _T("");
  15. m_name = _T("");
  16. m_seltxname = _T("");
  17. taoxiname = _T("");
  18. m_taoxijiage = _T("");
  19. m_waiter1 = _T("");
  20. m_waiter2 = _T("");
  21. m_clothescount = _T("");
  22. ren = _T("");
  23. m_time5old = _T("");
  24. m_time6old = _T("");
  25. m_checkstatus = _T(""); // 未看 或者 OK;
  26. m_size = _T("");
  27. m_oldmoney3 = _T("");
  28. m_name1 = _T("");
  29. m_name2 = _T("");
  30. m_phone1 = _T("");
  31. m_phone2 = _T("");
  32. m_time4 = _T("");
  33. m_waiter3 = _T(""); // 选片人员(g_user.name当前登陆系统人员)
  34. m_takezs = _T("");
  35. m_taoxizs = _T("");
  36. m_choosezs = _T("");
  37. m_money3 = _T("");
  38. m_urgent = _T("");
  39. m_bz3 = _T("");
  40. m_bz4 = _T("");
  41. m_bz2 = _T("");
  42. m_time5 = _T("");
  43. m_time6 = _T("");
  44. m_bSave = 0;
  45. m_bModify = 0;
  46. m_showpichwd = NULL;
  47. m_pHideImg = NULL; //相片icon
  48. m_pBk = NULL;
  49. m_Runingmode = 0; // 作用:选片模式==0、看设计模式==1, 默认为0;
  50. m_bRunning = false; // 线程运行标志
  51. m_bTerminate = false; // 线程终止的标志
  52. m_dwThreadID = 0; // Thread ID
  53. m_hThread = NULL;
  54. m_hEvent = NULL; // Thread and Event handle
  55. m_bSort = 0;
  56. m_bCanSave = 1;
  57. m_ticks = 0;
  58. m_timer = 0;
  59. m_nChoosePhotoType = 0;
  60. m_sChooseFilter = _T("");
  61. m_bGrowthTX = 0;
  62. m_bHide = FALSE; //是否显示小图
  63. m_bFromLocal = 0; //是否通过本地获取相图路径
  64. }
  65. ChoosePhotoBase::ChoosePhotoBase(DWORD id, CWnd *pParent) : CDialog(id, pParent)
  66. {
  67. m_SelectCategory = INDX_ALL;
  68. m_bSaveFail = 0;
  69. m_liapath = _T("");
  70. m_path = _T(""); // 选片或看设计的片种目录;
  71. m_strOrderNumber = _T("");
  72. m_status8 = _T("");
  73. m_name = _T("");
  74. m_seltxname = _T("");
  75. taoxiname = _T("");
  76. m_taoxijiage = _T("");
  77. m_waiter1 = _T("");
  78. m_waiter2 = _T("");
  79. m_clothescount = _T("");
  80. ren = _T("");
  81. m_time5old = _T("");
  82. m_time6old = _T("");
  83. m_checkstatus = _T(""); // 未看 或者 OK;
  84. m_size = _T("");
  85. m_oldmoney3 = _T("");
  86. m_name1 = _T("");
  87. m_name2 = _T("");
  88. m_phone1 = _T("");
  89. m_phone2 = _T("");
  90. m_time4 = _T("");
  91. m_waiter3 = _T(""); // 选片人员(g_user.name当前登陆系统人员)
  92. m_takezs = _T("");
  93. m_taoxizs = _T("");
  94. m_choosezs = _T("");
  95. m_money3 = _T("");
  96. m_urgent = _T("");
  97. m_bz3 = _T("");
  98. m_bz4 = _T("");
  99. m_bz2 = _T("");
  100. m_time5 = _T("");
  101. m_time6 = _T("");
  102. m_bSave = 0;
  103. m_bModify = 0;
  104. m_showpichwd = NULL;
  105. m_pHideImg = NULL; //相片icon
  106. m_pBk = NULL;
  107. m_bRunning = false; // 线程运行标志
  108. m_bTerminate = false; // 线程终止的标志
  109. m_dwThreadID = 0; // Thread ID
  110. m_hThread = NULL;
  111. m_hEvent = NULL; // Thread and Event handle
  112. m_Runingmode = 0; // 作用:选片模式==0、看设计模式==1, 默认为0;
  113. m_bSort = 0;
  114. m_bCanSave = 1;
  115. m_ticks = 0;
  116. m_timer = 0;
  117. m_nChoosePhotoType = 0;
  118. m_sChooseFilter = _T("");
  119. m_bGrowthTX = 0;
  120. m_bHide = TRUE; //是否显示小图
  121. m_bFromLocal = 0; //是否通过本地获取相图路径
  122. }
  123. ChoosePhotoBase::~ChoosePhotoBase()
  124. {
  125. }
  126. BOOL ChoosePhotoBase::OnInitDialog()
  127. {
  128. CDialog::OnInitDialog();
  129. return TRUE;
  130. }
  131. CStringArray* ChoosePhotoBase::GetCurArray(const int nIndx, SFolderInfo* m_pForder)
  132. {
  133. return NULL;
  134. }
  135. BOOL ChoosePhotoBase::OnDel()
  136. {
  137. return TRUE;
  138. }
  139. //点击右键事件
  140. void ChoosePhotoBase::OnRclickList1()
  141. {
  142. }
  143. CString ChoosePhotoBase::GetZSInfo(int iItem){return _T("");}
  144. BOOL ChoosePhotoBase::ReLoad(){return TRUE;}
  145. BOOL ChoosePhotoBase::GetData(){return TRUE;}
  146. void ChoosePhotoBase::UpdateChooseZS(){}
  147. void ChoosePhotoBase::LoadPhotos(){}
  148. //通过文件夹获取所有文件
  149. void ChoosePhotoBase::GetAllFileFromFolder(const int nType, CString& strFileNames){}
  150. /************************************************************************/
  151. /*
  152. 函数: ReLoadImageFromRes
  153. 描述: 重新从资源里加载图片
  154. 参数:
  155. Image** pImageOut, 图片资源指针
  156. const CString& strFile, 图片路径
  157. BOOL& bNulling
  158. 返回: 1成功,0失败
  159. */
  160. /************************************************************************/
  161. int ChoosePhotoBase::ReLoadImageFromRes(Image** pImageOut, const CString& strFile, BOOL& bNulling)
  162. {
  163. CString str = strFile;
  164. CString spath = str.Left(str.ReverseFind('\\') + 1);
  165. spath += "s";
  166. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  167. if (PathFileExists(spath))
  168. ::LoadImageFromBuf(pImageOut, spath);
  169. else if (PathFileExists(str))
  170. ::LoadImageFromBuf(pImageOut, str);
  171. else
  172. bNulling = TRUE;
  173. if ((*pImageOut) == NULL || (*pImageOut)->GetWidth() == 0)
  174. return 0;
  175. int orientation = GetOrientation((*pImageOut));
  176. if (orientation == 8)
  177. (*pImageOut)->RotateFlip(Rotate270FlipNone); //旋转、翻转或者同时旋转和翻转
  178. else if (orientation == 6)
  179. (*pImageOut)->RotateFlip(Rotate90FlipNone);
  180. return 1;
  181. }
  182. /************************************************************************/
  183. /*
  184. 函数: GetDelPhotos
  185. 描述: 获取删除的所有相片名
  186. 参数:
  187. OUT CString& strDelPhotos 返回相片名集合
  188. 返回:
  189. */
  190. /************************************************************************/
  191. void ChoosePhotoBase::GetDelPhotos(OUT CString& strDelPhotos)
  192. {
  193. for (int i = 0; i < m_DelPhotoPath.GetSize(); i++)
  194. {
  195. if (strDelPhotos.GetLength() > 4096)
  196. break;
  197. CString no = m_DelPhotoPath.ElementAt(i); //在选片时被删除的相片名的全路径集合;
  198. no = no.Right(no.GetLength() - no.ReverseFind('\\') - 1);
  199. no = no.Left(no.Find('.'));
  200. strDelPhotos += no;
  201. #ifdef USE_SEP_VEB
  202. strDelPhotos += SEPS_VEB;
  203. #else
  204. strDelPhotos += SEPS_SCN;
  205. #endif //#ifdef USE_SEP_VEB
  206. }
  207. // strDelPhotos:解析为只有相片名,以分号为分隔符的字符串;
  208. if (!strDelPhotos.IsEmpty())
  209. {
  210. #ifdef USE_SEP_VEB
  211. strDelPhotos.TrimLeft(SEPS_VEB);
  212. #else
  213. strDelPhotos.TrimLeft(SEPS_SCN);
  214. #endif //#ifdef USE_SEP_VEB
  215. }
  216. }
  217. void ChoosePhotoBase::GetNoSelPhoto(){}
  218. //获取所有文件夹名
  219. void ChoosePhotoBase::GetAllFolderNames(CString& strNames){}
  220. void ChoosePhotoBase::SetLiaPath(CString path)
  221. {
  222. m_liapath = path;
  223. }
  224. void ChoosePhotoBase::DrawInterface(){}
  225. /************************************************************************/
  226. /*
  227. 函数: ZoomImage
  228. 描述: 缩放图片大小
  229. 参数:
  230. 返回:
  231. */
  232. /************************************************************************/
  233. void ChoosePhotoBase::ZoomImage(Image* pImage, Rect& desRt)
  234. {
  235. int XDest(0), YDest(0), nDestWidth(0), nDestHeight(0);
  236. const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;
  237. const float fImgRatio = (float)pImage->GetHeight() / pImage->GetWidth();
  238. if (fImgRatio > fRatio)
  239. {
  240. nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
  241. XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
  242. YDest = 0;
  243. nDestHeight = THUMBNAIL_HEIGHT;
  244. }
  245. else
  246. {
  247. XDest = 0;
  248. nDestWidth = THUMBNAIL_WIDTH;
  249. nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
  250. YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
  251. }
  252. desRt.X = XDest;
  253. desRt.Y = YDest;
  254. desRt.Width = nDestWidth;
  255. desRt.Height = nDestHeight;
  256. }
  257. CString ChoosePhotoBase::GetModifyTime2(CString path)
  258. {
  259. HANDLE hFile;
  260. WIN32_FIND_DATA wfd;
  261. SYSTEMTIME systime;
  262. FILETIME localtime;
  263. CString stime; //输出时间
  264. memset(&wfd, 0, sizeof(wfd));
  265. if ((hFile = FindFirstFile(path, &wfd)) == INVALID_HANDLE_VALUE)
  266. return _T("");
  267. //ok,转换时间
  268. FileTimeToLocalFileTime(&wfd.ftLastWriteTime, &localtime);
  269. FileTimeToSystemTime(&localtime, &systime);
  270. stime.Format("%4d%02d%02d", systime.wYear, systime.wMonth, systime.wDay);
  271. return stime;
  272. }
  273. /************************************************************************/
  274. /*
  275. 函数: GetPathFromNo2
  276. 描述: 通过No2获取路径
  277. 参数:
  278. CString dir, 目标目录
  279. CString no, 图片名
  280. CStringArray *pArray 目标路径集合
  281. 返回: 返回获取的路径
  282. */
  283. /************************************************************************/
  284. CString ChoosePhotoBase::GetPathFromNo2(CString dir, CString no, CStringArray *pArray)
  285. {
  286. CString path = _T("");
  287. if ( no.Find(_T("\\")) != -1 )
  288. {
  289. dir+=no;
  290. for (int i = 0; i < pArray->GetSize(); i++)
  291. {
  292. path = pArray->ElementAt(i);
  293. if (path.ReverseFind(_T('.')) != -1)
  294. path = path.Left(path.ReverseFind(_T('.')));
  295. if ( dir.CompareNoCase(path) == 0 )
  296. return pArray->ElementAt(i);
  297. }
  298. }
  299. else
  300. {
  301. for (int i = 0; i < pArray->GetSize(); i++)
  302. {
  303. path = pArray->ElementAt(i);
  304. path = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
  305. if (path.Find(_T('.')) != -1)
  306. path = path.Left(path.Find(_T('.')));
  307. if ( no.CompareNoCase(path) == 0 )
  308. return pArray->ElementAt(i);
  309. }
  310. }
  311. return _T("");
  312. }
  313. /************************************************************************/
  314. /*
  315. 函数:GetZS
  316. 描述:返回dindansp表中no或no2字段中关于选中相片名的相片数量;
  317. 参数:
  318. str:dindansp表no或no2字段值,使用逗号分隔开所有相片名;
  319. 返回:
  320. 返回no或no2字段中,所包含的相片名数量;
  321. */
  322. /************************************************************************/
  323. int ChoosePhotoBase::GetZS(CString str)
  324. {
  325. #ifdef USE_SEP_VEB
  326. str.TrimLeft(SEPS_VEB);
  327. str.TrimRight(SEPS_VEB);
  328. if (str.IsEmpty())
  329. return 0;
  330. int pos = str.Find(SEPS_VEB);
  331. int count = 1;
  332. while (pos != -1)
  333. {
  334. str.Delete(pos);
  335. pos = str.Find(SEPS_VEB);
  336. count++;
  337. }
  338. #else
  339. str.TrimLeft(SEPS_CMA);
  340. str.TrimRight(SEPS_CMA);
  341. if (str.IsEmpty())
  342. return 0;
  343. int pos = str.Find(SEPC_CMA);
  344. int count = 1;
  345. while (pos != -1)
  346. {
  347. str.Delete(pos);
  348. pos = str.Find(SEPC_CMA);
  349. count++;
  350. }
  351. #endif //#ifdef USE_SEP_VEB
  352. return count;
  353. }
  354. /************************************************************************/
  355. /*
  356. 函数:GetSelCountFromName
  357. 描述:返回相片数量;
  358. 参数:
  359. IN CString name,
  360. OUT CString &scount
  361. 返回:
  362. */
  363. /************************************************************************/
  364. void ChoosePhotoBase::GetSelCountFromName(CString name, CString &scount)
  365. {
  366. #ifdef USE_SEP_VEB
  367. name.TrimLeft(SEPS_VEB);
  368. name.TrimRight(SEPS_VEB);
  369. #else
  370. name.TrimLeft(SEPS_CMA);
  371. name.TrimRight(SEPS_CMA);
  372. #endif //#ifdef USE_SEP_VEB
  373. if (name.GetLength() == 0)
  374. {
  375. scount = "0";
  376. return;
  377. }
  378. int ncount = 0;
  379. #ifdef USE_SEP_VEB
  380. int npos = name.Find(SEPS_VEB);
  381. #else
  382. int npos = name.Find(SEPS_CMA);
  383. #endif //#ifdef USE_SEP_VEB
  384. while (npos != -1)
  385. {
  386. ncount++;
  387. name = name.Right(name.GetLength() - npos - 1);
  388. #ifdef USE_SEP_VEB
  389. npos = name.Find(SEPS_VEB);
  390. #else
  391. npos = name.Find(SEPS_CMA);
  392. #endif //#ifdef USE_SEP_VEB
  393. }
  394. ncount++;
  395. scount.Format("%d", ncount);
  396. }
  397. /************************************************************************/
  398. /*
  399. 函数: GetPathFromNo
  400. 描述: 通过图片名获取路径
  401. 参数:
  402. CString dir, 目标目录
  403. CString no, 图片名
  404. CStringArray *pArray 目标路径集合
  405. 返回: 返回获取的路径
  406. */
  407. /************************************************************************/
  408. CString ChoosePhotoBase::GetPathFromNo(CString dir, CString no, CStringArray *pArray)
  409. {
  410. CStringArray dirarray;
  411. CString sRet = _T("");
  412. CString temp = _T("");
  413. dir.TrimRight('\\');
  414. dir += _T("\\");
  415. if (pArray->GetSize() == 0)
  416. {
  417. ffsco o;
  418. o.dirs(1);
  419. o.find(LPCSTR(dir), LPCSTR("*.*"));
  420. ffsco::typeT coo;
  421. ffsco::typeT::iterator it;
  422. coo = o.co_dir();
  423. for (it = coo.begin(); coo.end() != it; it++)
  424. {
  425. temp = (*it).c_str();
  426. if (::FindArray(&dirarray, temp) == -1 && temp != dir)
  427. dirarray.Add(temp);
  428. }
  429. }
  430. else
  431. dirarray.Copy(*pArray);
  432. for (int i = 0; i < dirarray.GetSize(); i++)
  433. {
  434. temp = dirarray.ElementAt(i);
  435. sRet.Format(_T("%s%s.jpg"), temp, no);
  436. if (::PathFileExists(sRet))
  437. return sRet;
  438. }
  439. return dir + no + _T(".jpg");
  440. }
  441. void ChoosePhotoBase::SortArray2(CArray<int, int>&datearray)
  442. {
  443. int strtemp;
  444. int last = datearray.GetSize() - 1;
  445. bool sorted = true;
  446. do {
  447. sorted = true;
  448. for (int i = 0; i < last; i++)
  449. {
  450. if (datearray[i] < datearray[i + 1])
  451. {
  452. strtemp = datearray[i];
  453. datearray[i] = datearray[i + 1];
  454. datearray[i + 1] = strtemp;
  455. sorted = false;
  456. }
  457. }
  458. last--;
  459. } while (!sorted);
  460. }
  461. /*--------------------------------------------------
  462. // 函数: DelPhotoFromName
  463. // 描述: 通过名字删除
  464. // 参数:
  465. CStringArray& arr, 文件列表
  466. const CString& strName 文件名
  467. // 返回: 成功1,失败0;
  468. //--------------------------------------------------*/
  469. int ChoosePhotoBase::DelPhotoFromName(CStringArray& arr, const CString& strName)
  470. {
  471. if(strName == _T("") || arr.GetSize() == 0)
  472. return 0;
  473. CString strName2 = _T("");
  474. for (int i = 0; i < arr.GetSize(); i++)
  475. {
  476. strName2 = arr.ElementAt(i);
  477. strName2 = strName2.Right(strName2.GetLength() - strName2.ReverseFind('\\') - 1);
  478. strName2 = strName2.Left(strName2.Find('.'));
  479. if (strName == strName2)
  480. {
  481. arr.RemoveAt(i);
  482. return 1;
  483. }
  484. }
  485. return 0;
  486. }
  487. /************************************************************************/
  488. /*
  489. 函数: GetAllPhotoPath
  490. 描述: 获取全部相片路径
  491. 参数:
  492. CSting &strDirPath 目录路径
  493. 返回:
  494. */
  495. /************************************************************************/
  496. void ChoosePhotoBase::GetAllPhotoPath(CString& strDirPath, CStringArray& arr)
  497. {
  498. // 查找m_path下所有文件o.find(...);
  499. CString filename = _T("");
  500. CString path(_T("")), path2(_T(""));
  501. ffsco o;
  502. o.dirs(1);
  503. o.find(LPCSTR(strDirPath), LPCSTR("*.*"));
  504. ffsco::typeT coo;
  505. ffsco::typeT::iterator it;
  506. coo = o.co_file();
  507. for (it = coo.begin(); coo.end() != it; it++) // 遍历文件夹;
  508. {
  509. path = (*it).c_str();
  510. if (path.GetAt(path.ReverseFind('\\') + 1) != 's' && path.GetAt(path.ReverseFind('\\') + 1) != 'm')
  511. {
  512. path.MakeLower();
  513. filename = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
  514. if (filename.Find(_T(".")) != -1)
  515. filename = filename.Left(filename.Find(_T(".")));
  516. if (!myisdigit(filename))continue;
  517. if (m_nChoosePhotoType == 1) // m_AllPhotoPath只添加修片文件夹;
  518. {
  519. #if JEFF_TEST_ON
  520. if(PathFileExists(path))
  521. arr.Add(path);
  522. #endif //#if JEFF_TEST_ON
  523. }
  524. else if (m_nChoosePhotoType == 0 || m_nChoosePhotoType == 2)//else // m_nChoosePhotoType=0,2
  525. {
  526. path2 = path;
  527. if (m_nChoosePhotoType == 0) // 原片+修片;
  528. {
  529. path2.Replace(_T("客户原片"), _T("修好的片"));
  530. //printf("Jeff:原片+修片 path2=%s\n\n",path2); // Jeff Printf;
  531. }
  532. if (m_bGrowthTX == 0)
  533. {
  534. int pos = path2.Find(m_strOrderNumber);
  535. pos += m_strOrderNumber.GetLength();
  536. int pos2 = path2.ReverseFind('\\');
  537. path2 = path2.Left(pos) + path2.Right(path2.GetLength() - pos2);
  538. }
  539. if (m_nChoosePhotoType == 0 && PathFileExists(path2)) // 原片+修片;
  540. {
  541. arr.Add(path2);
  542. }
  543. else // 不仅原片
  544. {
  545. path2.Replace(_T(".raw"), _T(".jpg"));
  546. if (PathFileExists(path2))
  547. {
  548. arr.Add(path2);
  549. continue;
  550. }
  551. path2.Replace(_T(".nef"), _T(".jpg"));
  552. if (PathFileExists(path2))
  553. {
  554. arr.Add(path2);
  555. continue;
  556. }
  557. path2.Replace(_T(".cr2"), _T(".jpg"));
  558. if (PathFileExists(path2))
  559. {
  560. arr.Add(path2);
  561. continue;
  562. }
  563. else
  564. {
  565. if (path.Right(3) != _T("jpg"))
  566. continue;
  567. #if JEFF_TEST_ON
  568. if (PathFileExists(path))
  569. arr.Add(path);
  570. #else
  571. arr.Add(path);
  572. #endif //#if JEFF_TEST_ON
  573. }
  574. }
  575. }
  576. }
  577. }
  578. }
  579. /************************************************************************/
  580. /* 函数:GetTXName[4/17/2016 IT];
  581. /* 描述:若是儿童成长套系,获取成长套系内容;
  582. /* 参数:;
  583. /* [IN] pStrOrder:订单号;
  584. /* [IN] nModle:选片或选设计, nModel == 0 表示选片, nMode == 1 表示选设计;
  585. /* [OUT] bGrowthTx:若查询是儿童成长套系,返回TRUE;
  586. /* [OUT] strTxName:若查询是儿童成长套系,返回要选片的成长套系名;
  587. /* 返回:void;
  588. /* 注意:;
  589. /* 示例:;
  590. /*
  591. /* 修改:;
  592. /* 日期:;
  593. /* 内容:;
  594. /************************************************************************/
  595. void ChoosePhotoBase::GetTXName(IN const CString* pStrOrder, IN const int nModle, OUT BOOL& bGrowthTx, OUT CString& strTxName)
  596. {
  597. if(pStrOrder == NULL || (*pStrOrder) == _T(""))
  598. return;
  599. IsGrowthTx growthtxdlg;
  600. growthtxdlg.m_mode = nModle;
  601. growthtxdlg.m_strOrderNumber = (*pStrOrder);
  602. growthtxdlg.DoModal();
  603. bGrowthTx = growthtxdlg.m_bGrowthTx;
  604. strTxName = growthtxdlg.m_seltxname;
  605. }
  606. /************************************************************************/
  607. /*
  608. 函数: GetPhotos
  609. 描述: 得看设计
  610. 参数:
  611. 返回:
  612. */
  613. /************************************************************************/
  614. void ChoosePhotoBase::GetPhotos()
  615. {
  616. int i = 0;
  617. int j = 0;
  618. m_AllPhotoPath.RemoveAll();
  619. m_path.MakeLower();
  620. CStringArray dirarray;
  621. CString str;
  622. if (1)
  623. {
  624. ffsco o;
  625. o.dirs(1);
  626. o.find(LPCSTR(m_path), LPCSTR(_T("*.*")));
  627. ffsco::typeT coo;
  628. ffsco::typeT::iterator it;
  629. coo = o.co_dir();
  630. for (it = coo.begin(); coo.end() != it; it++)
  631. {
  632. str = (*it).c_str();
  633. str.TrimRight(_T("\\"));
  634. CString dirname = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  635. if (dirname.Find("DelgaBook") != -1)
  636. {
  637. if (FindArray(&m_AllPhotoPath, str) == -1)
  638. m_AllPhotoPath.Add(str);
  639. }
  640. if (FindArray(&dirarray, str) == -1)
  641. dirarray.Add(str);
  642. }
  643. }
  644. if (1)
  645. {
  646. for ( i = 0; i < dirarray.GetSize(); i++)
  647. {
  648. ffsco o;
  649. o.dirs(0);
  650. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  651. ffsco::typeT coo;
  652. ffsco::typeT::iterator it;
  653. coo = o.co_file();
  654. for (it = coo.begin(); coo.end() != it; it++)
  655. {
  656. str = (*it).c_str();
  657. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  658. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  659. str.MakeLower();
  660. m_AllPhotoPath.Add(str);
  661. }
  662. }
  663. }
  664. CStringArray *pArray[1] = { &m_AllPhotoPath };
  665. for ( i = 0; i < 1; i++)
  666. {
  667. m_combo1.ResetContent();
  668. CString Temp;
  669. for ( j = 0; j < pArray[i]->GetSize(); j++)
  670. m_combo1.AddString(pArray[i]->ElementAt(j));
  671. for (j = 0; j < pArray[i]->GetSize(); j++)
  672. {
  673. m_combo1.GetLBText(j, Temp);
  674. pArray[i]->SetAt(j, Temp);
  675. }
  676. }
  677. }
  678. /************************************************************************/
  679. /*
  680. 函数:[3/4/2016 CheckOK];
  681. 描述:判断字符串是否是数字组成;
  682. 参数:
  683. name 要判断的字符串;
  684. 返回:如果是数字组成返回1,否则返回0;
  685. */
  686. /************************************************************************/
  687. BOOL ChoosePhotoBase::CheckOK(CString name)
  688. {
  689. if (name.GetLength() > 4)return 0;
  690. for (int i = 0; i < name.GetLength(); i++)
  691. {
  692. if (name.GetAt(i) < '0' || name.GetAt(i) > '9')return 0;
  693. }
  694. return 1;
  695. }
  696. /************************************************************************/
  697. /*
  698. 函数: GetSelName
  699. 描述: 获取文件名
  700. 参数:
  701. CString name 相片名
  702. 返回:
  703. 注意:
  704. */
  705. /************************************************************************/
  706. CString ChoosePhotoBase::GetSelName(CString name)
  707. {
  708. CString ret;
  709. int i = 0;
  710. #ifdef USE_SEP_VEB
  711. name = SEPS_VEB + name + SEPS_VEB;
  712. #else
  713. name = SEPS_CMA + name + SEPS_CMA;
  714. #endif //#ifdef USE_SEP_VEB
  715. for ( i = 0; i < m_List2.GetItemCount(); i++)
  716. {
  717. if (m_noarray.ElementAt(i).Find(name) != -1)
  718. {// 获取数量;
  719. ret += m_List2.GetItemText(i, 2);
  720. ret += _T("\r\n");
  721. }
  722. }
  723. for (i = 0; i < m_List3.GetItemCount(); i++)
  724. {
  725. if (m_no2array.ElementAt(i).Find(name) != -1)
  726. {// 获取商品名称;
  727. ret += m_List3.GetItemText(i, 2);
  728. ret += _T("\r\n");
  729. }
  730. }
  731. if (!ret.IsEmpty())
  732. {
  733. ret = _T("\r\n") + ret;
  734. ret.TrimRight("\r\n");
  735. }
  736. return ret;
  737. }
  738. /************************************************************************/
  739. /*
  740. 函数: ClearResData
  741. 描述: 清除资源的路径
  742. 参数:
  743. 返回:
  744. */
  745. /************************************************************************/
  746. void ChoosePhotoBase::ClearResData()
  747. {
  748. vector<SResData*>::iterator it = m_vResData.begin();
  749. for(;it != m_vResData.end();)
  750. {
  751. SResData* p = (*it);
  752. if(p != NULL)
  753. delete p;
  754. ++it;
  755. }
  756. m_vResData.clear();
  757. }
  758. /************************************************************************/
  759. /*
  760. 函数: RecordDeletedPhotos
  761. 描述: 记录已删除的相片
  762. 参数:
  763. CString* pStrDel, 要删除的相片
  764. CStringArray& arr 要删除的相片保存到array
  765. 返回:
  766. 注意:
  767. */
  768. /************************************************************************/
  769. void ChoosePhotoBase::RecordDeletedPhotos(CString* pStrDel, CStringArray& arr)
  770. {
  771. if(pStrDel == NULL || (*pStrDel) == _T(""))
  772. return;
  773. //添加删除相片;
  774. #ifdef USE_SEP_VEB
  775. m_delphotos.TrimLeft(SEPC_VEB);
  776. m_delphotos.TrimRight(SEPC_VEB);
  777. m_delphotos = SEPC_VEB + m_delphotos;
  778. m_delphotos += SEPC_VEB;
  779. #else
  780. m_delphotos.TrimLeft(SEPC_SCN);
  781. m_delphotos.TrimRight(SEPC_SCN);
  782. m_delphotos = SEPC_SCN + m_delphotos;
  783. m_delphotos += SEPC_SCN;
  784. #endif //#ifdef USE_SEP_VEB
  785. for (int i = m_AllPhotoPath.GetSize() - 1; i >= 0; i--)
  786. {
  787. CString no;
  788. no = m_AllPhotoPath.ElementAt(i);
  789. no = no.Right(no.GetLength() - no.ReverseFind('\\') - 1);
  790. no = no.Left(no.Find('.'));
  791. #ifdef USE_SEP_VEB
  792. no = SEPC_VEB + no;
  793. no += SEPC_VEB;
  794. #else
  795. no = SEPC_SCN + no;
  796. no += SEPC_SCN;
  797. #endif //#ifdef USE_SEP_VEB
  798. if (m_delphotos.Find(no) != -1)
  799. {
  800. no = m_AllPhotoPath.ElementAt(i);
  801. m_AllPhotoPath.RemoveAt(i);
  802. #if JEFF_TEST_ON
  803. if(PathFileExists(no))
  804. arr.Add(no);
  805. #else
  806. arr.Add(no);
  807. #endif //JEFF_TEST_ON
  808. }
  809. }
  810. }
  811. /************************************************************************/
  812. /*
  813. 函数: AddPhotoFromDir
  814. 描述: 添加选中相片
  815. 参数:
  816. CStringArray* pSelArr 选中相片集合
  817. const CString& strDir, 目标目录
  818. CString& str 文件名: ",004,"
  819. const int nPos 字符','在文件名的位置
  820. 返回: 1成功, 0失败
  821. */
  822. /*************************************************************************/
  823. int ChoosePhotoBase::AddPhotoFromDir(CStringArray* pSelArr, const CString& strDir, CString& str)
  824. {
  825. if(pSelArr == NULL || strDir.IsEmpty() || str == _T(""))
  826. return 0;
  827. CString path(_T(""));
  828. #ifdef USE_SEP_VEB
  829. int pos = str.Find(SEPS_VEB);
  830. #else
  831. int pos = str.Find(SEPS_CMA);
  832. #endif //#ifdef USE_SEP_VEB
  833. while (pos != -1)
  834. {
  835. path = strDir + str.Left(pos) + _T(".jpg");
  836. if (FindArray(pSelArr, path) == -1)
  837. {
  838. #if JEFF_TEST_ON
  839. if (PathFileExists(path))
  840. pSelArr->Add(path);
  841. #else
  842. pSelArr->Add(path);
  843. #endif //#if JEFF_TEST_ON
  844. }
  845. str = str.Right(str.GetLength() - pos - 1);
  846. #ifdef USE_SEP_VEB
  847. pos = str.Find(SEPS_VEB);
  848. #else
  849. pos = str.Find(SEPC_CMA);
  850. #endif //#ifdef USE_SEP_VEB
  851. }
  852. path = strDir + str + _T(".jpg");
  853. if (FindArray(pSelArr, path) == -1)
  854. {
  855. #if JEFF_TEST_ON
  856. if (PathFileExists(path))
  857. pSelArr->Add(path);
  858. #else
  859. pSelArr->Add(path);//MessageBox(path);
  860. #endif //#if JEFF_TEST_ON
  861. }
  862. return 1;
  863. }
  864. void ChoosePhotoBase::CalChooseZS(CStringArray* pSelArr, CStringArray* pAllArr)
  865. {
  866. if(pSelArr == NULL || pAllArr == NULL)
  867. return;
  868. int i = 0;
  869. CString str = _T("");
  870. pSelArr->RemoveAll();
  871. for ( i = 0; i < m_noarray.GetSize(); i++)
  872. {
  873. str = m_noarray.ElementAt(i);
  874. GetPathAddToSel(pSelArr, str, pAllArr);
  875. }
  876. for (i = 0; i < m_no2array.GetSize(); i++)
  877. {
  878. str = m_no2array.ElementAt(i);
  879. GetPathAddToSel(pSelArr, str, pAllArr);
  880. }
  881. }
  882. //--------------------------------------------------
  883. // remark by Jeff 2014.12.15
  884. // 函数:CheckName
  885. // 描述:类似CheckOK,判断字符串是否是数字组成(除去"$" "."两符号以及后缀名);
  886. // 参数:name 要判断的字符串;
  887. // 返回:如果是数字组成返回1,否则返回0;
  888. //--------------------------------------------------
  889. BOOL ChoosePhotoBase::CheckName(CString name)
  890. {//$001.002.003
  891. int pos = name.Find("$");
  892. if (pos != 0)return 0;
  893. name.Delete(0, 1);
  894. pos = name.Find(".");
  895. while (pos != -1)
  896. {
  897. if (CheckOK(name.Left(pos)) == 0)return 0;
  898. name = name.Right(name.GetLength() - pos - 1);
  899. pos = name.Find(".");
  900. }
  901. return CheckOK(name);
  902. }
  903. /************************************************************************/
  904. /* 函数:GetPathAddToSel[4/17/2016 IT];
  905. /* 描述:获取路径添加到选中相片;
  906. /* 参数:;
  907. /* [IN] pSelArr:dindapsp.no或dindansp.no2的相片路径结果集;
  908. /* [IN] strName:dindansp表中每个商品记录中的no字段对应的相片串;
  909. /* [IN] pAllArr:strName的相片路径来源;
  910. /* 返回:1成功,0失败;
  911. /* 注意:;
  912. /* 示例:;
  913. /*
  914. /* 修改:;
  915. /* 日期:;
  916. /* 内容:;
  917. /************************************************************************/
  918. int ChoosePhotoBase::GetPathAddToSel(CStringArray* pSelArr, const CString& strName, CStringArray* pAllArr)
  919. {
  920. if(pSelArr == NULL || strName == _T("") || pAllArr == NULL)
  921. return 0;
  922. CString str = strName;
  923. if (m_bFromLocal)
  924. {
  925. // 本地(缓存)加载选片
  926. #ifdef USE_SEP_VEB
  927. str.TrimLeft(SEPS_VEB);
  928. str.TrimRight(SEPS_VEB);
  929. #else
  930. str.TrimLeft(SEPS_CMA);
  931. str.TrimRight(SEPS_CMA);
  932. #endif //#ifdef USE_SEP_VEB
  933. if (str.IsEmpty())
  934. return 0;
  935. CString path(_T("")), path2(_T(""));
  936. #ifdef _UNICODE
  937. WCHAR spath[MAX_PATH] = {0};
  938. #else
  939. char spath[MAX_PATH] = {0};
  940. #endif //#ifdef _UNICODE
  941. ::GetSystemDirectory(spath, MAX_PATH);
  942. CString sysdir = spath;
  943. sysdir += _T("\\lyfz");
  944. sysdir += _T("\\");
  945. sysdir += m_strOrderNumber;
  946. sysdir += _T("\\");
  947. AddPhotoFromDir(pSelArr, sysdir, str);
  948. }
  949. else
  950. {
  951. #ifdef USE_SEP_VEB
  952. str.TrimLeft(SEPS_VEB);
  953. str.TrimRight(SEPS_VEB);
  954. #else
  955. str.TrimLeft(SEPS_CMA);
  956. str.TrimRight(SEPS_CMA);
  957. #endif //#ifdef USE_SEP_VEB
  958. if (str.IsEmpty())
  959. return 0;
  960. #ifdef USE_SEP_VEB
  961. int pos = str.Find(SEPS_VEB);
  962. #else
  963. int pos = str.Find(SEPS_CMA);
  964. #endif //#ifdef USE_SEP_VEB
  965. CString path(_T("")), path2(_T(""));
  966. while (pos != -1)
  967. {
  968. path = GetPathFromNo2(m_path, str.Left(pos), pAllArr);
  969. path2 = path;
  970. if (path != _T("") && FindArray(pSelArr, path) == -1)
  971. {
  972. if (PathFileExists(path))
  973. pSelArr->Add(path);
  974. }
  975. str = str.Right(str.GetLength() - pos - 1);
  976. #ifdef USE_SEP_VEB
  977. pos = str.Find(SEPS_VEB);
  978. #else
  979. pos = str.Find(SEPS_CMA);
  980. #endif //#ifdef USE_SEP_VEB
  981. }
  982. path = GetPathFromNo2(m_path, str, pAllArr);//+".jpg";
  983. path2 = path;
  984. if(path == _T(""))
  985. return 0;
  986. if (FindArray(pSelArr, path) == -1)
  987. {
  988. if (PathFileExists(path))
  989. pSelArr->Add(path);
  990. }
  991. }
  992. return 1;
  993. }
  994. /************************************************************************/
  995. /*
  996. 函数: LoadThumbImages
  997. 描述: 创建线程加载函数LoadThumbNail3
  998. 参数:
  999. 返回:
  1000. 注意:
  1001. */
  1002. /************************************************************************/
  1003. void ChoosePhotoBase::LoadThumbImages()
  1004. {
  1005. TerminateThread();
  1006. m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail3, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
  1007. m_bRunning = true;
  1008. }
  1009. BOOL ChoosePhotoBase::TerminateThread()
  1010. {
  1011. if (!m_bRunning)
  1012. return TRUE;
  1013. m_bTerminate = true;
  1014. for (;;)
  1015. {
  1016. if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
  1017. break;
  1018. MSG msg;
  1019. while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  1020. {
  1021. if (!AfxGetApp()->PumpMessage())
  1022. break;
  1023. }
  1024. }
  1025. ::CloseHandle(m_hThread);
  1026. m_hThread = NULL;
  1027. return TRUE;
  1028. }
  1029. //extern void LoadImageFromFile(Image **img, CString path);
  1030. unsigned __stdcall LoadThumbNail3(LPVOID lpParam)
  1031. {
  1032. ChoosePhotoBase* pDlg = (ChoosePhotoBase*)lpParam;
  1033. pDlg->DrawImageWork();
  1034. return 0;
  1035. }
  1036. void ChoosePhotoBase::Save(IN LPCTSTR lpPath, IN LPCTSTR lpFileName)
  1037. {
  1038. int i = 0;
  1039. int j = 0;
  1040. CString sql;
  1041. CArray<CStringArray, CStringArray>sparray;
  1042. sparray.SetSize(m_List2.GetItemCount() + m_no2array.GetSize());
  1043. for ( i = 0; i < m_List2.GetItemCount(); i++)
  1044. {
  1045. sparray.ElementAt(i).Add(m_strOrderNumber);
  1046. sparray.ElementAt(i).Add(m_List2.GetItemText(i, 0));
  1047. sparray.ElementAt(i).Add(m_List2.GetItemText(i, 1));
  1048. sparray.ElementAt(i).Add(m_List2.GetItemText(i, 2));
  1049. sparray.ElementAt(i).Add(m_List2.GetItemText(i, 3));
  1050. sparray.ElementAt(i).Add(m_List2.GetItemText(i, 4));
  1051. }
  1052. for ( j = 0; j < m_no2array.GetSize(); j++)
  1053. {
  1054. sparray.ElementAt(i).Add(m_strOrderNumber);
  1055. sparray.ElementAt(i).Add(m_List3.GetItemText(j, 0));
  1056. sparray.ElementAt(i).Add(m_List3.GetItemText(j, 1));
  1057. sparray.ElementAt(i).Add(m_List3.GetItemText(j, 2));
  1058. sparray.ElementAt(i).Add(m_List3.GetItemText(j, 3));
  1059. sparray.ElementAt(i).Add(m_List3.GetItemText(j, 4));
  1060. sparray.ElementAt(i).Add(m_List3.GetItemText(j, 5));
  1061. #ifdef LKAY_VERSION
  1062. sparray.ElementAt (i).Add ( m_List3.GetItemText (j, 6) );
  1063. sparray.ElementAt (i).Add ( m_List3.GetItemText (j, 7) );
  1064. #endif //#ifdef LKAY_VERSION
  1065. sparray.ElementAt(i).Add("4");
  1066. i++;
  1067. }
  1068. if (sparray.GetSize() == 0)
  1069. {
  1070. sparray.SetSize(1);
  1071. sparray.ElementAt(0).Add(m_strOrderNumber);
  1072. }
  1073. CMemFile memfile;
  1074. CArchive ar(&memfile, CArchive::store);
  1075. for (int ii = 0; ii < sparray.GetSize(); ii++)
  1076. {
  1077. sparray.ElementAt(ii).Serialize(ar);
  1078. }
  1079. ar.Close();
  1080. int length = memfile.GetLength();
  1081. BYTE *pData = memfile.Detach();
  1082. int size = sparray.GetSize();
  1083. BYTE *pData2 = new BYTE[length + sizeof(int)];
  1084. memcpy(pData2, pData, length);
  1085. memcpy(pData2 + length, &size, sizeof(int));
  1086. delete[]pData;
  1087. length += sizeof(int);
  1088. CString savepath = _T("");
  1089. //savepath.Format("%s\\%s.dat", g_mainpath, lpFileName/*m_strOrderNumber*/);选片
  1090. //savepath.Format("%s\\%s-2.dat", g_mainpath, lpFileName/*m_strOrderNumber*/);选版
  1091. savepath.Format("%s\\%s.dat", lpPath, lpFileName);
  1092. if (1)
  1093. {
  1094. CFile fp;
  1095. fp.Open(savepath, CFile::modeCreate | CFile::modeWrite);
  1096. fp.Write(pData2, length);
  1097. fp.Close();
  1098. }
  1099. delete[]pData2;
  1100. }
  1101. /************************************************************************/
  1102. /*
  1103. 函数: IsFileExist
  1104. 描述: 文件是否存在
  1105. 参数:
  1106. 返回:
  1107. */
  1108. /************************************************************************/
  1109. BOOL ChoosePhotoBase::IsFileExistInDir(CString* pPath)
  1110. {
  1111. BOOL bExist = FALSE;
  1112. if(pPath == NULL || (*pPath) == _T(""))
  1113. return bExist;
  1114. ffsco o;
  1115. o.dirs(0);
  1116. o.find(pPath->GetBuffer(pPath->GetLength()), LPCSTR("*.jpg"));
  1117. int nsize = o.co_file().size();
  1118. if (nsize > 0)
  1119. bExist = TRUE;
  1120. return bExist;
  1121. }
  1122. /************************************************************************/
  1123. /* 函数:IsSelPhoto[4/18/2016 IT];
  1124. /* 描述:是否选取相片;
  1125. /* 参数:;
  1126. /* [IN] strPhotoName:如:"|004|";
  1127. /* [OUT] :;
  1128. /* [IN/OUT] :;
  1129. /* 返回:void;
  1130. /* 注意:;
  1131. /* 示例:;
  1132. /*
  1133. /* 修改:;
  1134. /* 日期:;
  1135. /* 内容:;
  1136. /************************************************************************/
  1137. BOOL ChoosePhotoBase::IsSelPhoto(CString strPhotoName)
  1138. {
  1139. int nPos = 0;
  1140. int i = 0;
  1141. for (i = 0; i < m_no2array.GetSize(); i++)
  1142. {
  1143. // m_no2array.ElementAt(i) 前后都有 SEPS_VEB;
  1144. if ( m_no2array.ElementAt(i).Find(strPhotoName) != -1 )
  1145. {
  1146. return TRUE;
  1147. }
  1148. }
  1149. for (i = 0; i < m_noarray.GetSize(); i++)
  1150. {
  1151. // m_noarray.ElementAt(i) 前后都有 SEPS_VEB;
  1152. if ( m_noarray.ElementAt(i).Find(strPhotoName) != -1 )
  1153. {
  1154. return TRUE;
  1155. }
  1156. }
  1157. return FALSE;
  1158. }
  1159. /************************************************************************/
  1160. /*
  1161. 函数: IsPhoto2Exist
  1162. 描述:
  1163. 参数:
  1164. 返回: 0,>1
  1165. */
  1166. /************************************************************************/
  1167. BOOL ChoosePhotoBase::IsPhoto2Exist()
  1168. {
  1169. CString path2;
  1170. CString path = _T("");
  1171. path = g_path2 + _T("\\");
  1172. path += m_strOrderNumber;
  1173. path += _T("\\");
  1174. CStringArray StrSubFoloderArray;
  1175. ffsco o;
  1176. o.dirs(1); // Jeff.1:查找子目录;
  1177. o.find(LPCSTR(path), LPCSTR("*.*")); // 可能存在m和s开头的缩略图,需要过滤掉;
  1178. if (o.count() == 0)
  1179. return 0;
  1180. // 获取子目录数;
  1181. ffsco::typeT coo;
  1182. ffsco::typeT::iterator it;
  1183. coo = o.co_dir();
  1184. for (it = coo.begin(); it != coo.end(); it++)
  1185. {
  1186. if (::FindArray(&StrSubFoloderArray, (*it).c_str()) == -1)
  1187. StrSubFoloderArray.Add((*it).c_str());
  1188. }
  1189. // 获取子目录下的文件数;
  1190. CStringArray StrPhotoArray;
  1191. for (int n = 0; n < StrSubFoloderArray.GetSize(); n++)
  1192. {
  1193. ffsco op;
  1194. op.dirs(0);
  1195. // printf("path=%s\n", StrSubFoloderArray.ElementAt(n));
  1196. op.find(LPCSTR(StrSubFoloderArray.ElementAt(n)), LPCSTR("*.*"));
  1197. ffsco::typeT coo;
  1198. ffsco::typeT::iterator itp;
  1199. coo = op.co_file();
  1200. for (itp = coo.begin(); itp != coo.end(); itp++)
  1201. {
  1202. StrPhotoArray.Add((*itp).c_str());
  1203. }
  1204. }
  1205. CString strTempFile;
  1206. int nIndex = 0;
  1207. int nSizeOfFile = 0; // 记录相片文件数;
  1208. int nCount = StrPhotoArray.GetSize();
  1209. for (int i = 0; i < nCount; i++)
  1210. {
  1211. strTempFile = StrPhotoArray.ElementAt(i);
  1212. nIndex = strTempFile.ReverseFind('\\');
  1213. strTempFile = strTempFile.Right(strTempFile.GetLength() - nIndex - 1);
  1214. // printf("file=%s\n", strTempFile);
  1215. if (strTempFile.Left(1) == _T("m") || strTempFile.Left(1) == _T("s"))
  1216. {
  1217. continue;
  1218. }
  1219. strTempFile = strTempFile.Right(4);
  1220. strTempFile.MakeLower();
  1221. if (strTempFile == _T(".jpg"))
  1222. {
  1223. nSizeOfFile++;
  1224. }
  1225. else if (strTempFile == _T(".raw"))
  1226. {
  1227. nSizeOfFile++;
  1228. }
  1229. else if (strTempFile == _T(".cr2"))
  1230. {
  1231. nSizeOfFile++;
  1232. }
  1233. else if (strTempFile == _T(".nef"))
  1234. {
  1235. nSizeOfFile++;
  1236. }
  1237. }
  1238. return nSizeOfFile;
  1239. }
  1240. void ChoosePhotoBase::OnPaint2(CWnd *pWnd)
  1241. {
  1242. try
  1243. {
  1244. CPaintDC dc(pWnd); // device context for painting
  1245. // TODO: Add your message handler code here
  1246. CRect rc;
  1247. GetClientRect(rc);
  1248. if (m_pBk == NULL)
  1249. {
  1250. return;
  1251. }
  1252. int width = m_pBk->GetWidth();
  1253. int height = m_pBk->GetHeight();
  1254. Graphics graph(dc.GetSafeHdc());
  1255. Rect destinationRect(0, 0, rc.Width(), rc.Height());
  1256. graph.SetSmoothingMode(SmoothingModeHighQuality);
  1257. graph.DrawImage(m_pBk, destinationRect, 0, 0, width, height, UnitPixel);
  1258. }
  1259. catch (...)
  1260. {
  1261. }
  1262. }
  1263. /************************************************************************/
  1264. /*
  1265. 函数: IsThereACacheImg
  1266. 描述: 检查本机上是否有缓存的相片
  1267. 参数:
  1268. 返回:
  1269. */
  1270. /************************************************************************/
  1271. BOOL ChoosePhotoBase::IsThereACacheImg()
  1272. {
  1273. CString str = _T("");
  1274. char path[MAX_PATH] = {0};
  1275. ::GetSystemDirectory(path, MAX_PATH);
  1276. CString sysdir = path;
  1277. sysdir += _T("\\lyfz");
  1278. ::CreateDirectory(sysdir, NULL);
  1279. sysdir += _T("\\");
  1280. sysdir += m_strOrderNumber;
  1281. ffsco o;
  1282. o.dirs(1);
  1283. o.find(LPCSTR(sysdir), LPCSTR(_T("*.jpg")));
  1284. ffsco::typeT coo;
  1285. ffsco::typeT::iterator it;
  1286. coo = o.co_file();
  1287. if (coo.size())
  1288. {
  1289. if (AfxMessageBox("提醒, 此客人有本机缓存片,是否使用缓存片?", MB_YESNO | MB_ICONINFORMATION) == IDYES)
  1290. {
  1291. for (it = coo.begin(); coo.end() != it; it++)
  1292. {
  1293. str = (*it).c_str();
  1294. if (str.GetAt(str.ReverseFind('\\') + 1) != 's' && str.GetAt(str.ReverseFind('\\') + 1) != 'm')
  1295. m_AllPhotoPath.Add(str);
  1296. }
  1297. return 1;
  1298. }
  1299. }
  1300. return 0;
  1301. }
  1302. /************************************************************************/
  1303. /*
  1304. 函数: GetNoSelPhotoCount
  1305. 描述: 获取未选相片数量
  1306. 参数:
  1307. CStringArray* pAllPhotoPath,
  1308. CStringArray* pSelPhotoPath
  1309. 返回:
  1310. 注意: 返回数量
  1311. */
  1312. /************************************************************************/
  1313. int ChoosePhotoBase::GetNoSelPhotoCount(CStringArray* pAllPhotoPath, CStringArray* pSelPhotoPath)
  1314. {
  1315. if(pAllPhotoPath == NULL || pSelPhotoPath == NULL)
  1316. return 0;
  1317. int nRet = 0;
  1318. CString str1, str2;
  1319. for (int i = 0; i < pAllPhotoPath->GetSize(); i++)
  1320. {
  1321. BOOL bFind = 0;
  1322. for (int j = 0; j < pSelPhotoPath->GetSize(); j++)
  1323. {
  1324. str1 = pAllPhotoPath->ElementAt(i);
  1325. str2 = pSelPhotoPath->ElementAt(j);
  1326. if (str1.CollateNoCase(str2) == 0)
  1327. {
  1328. bFind = 1;
  1329. break;
  1330. }
  1331. }
  1332. if (bFind == 0)
  1333. nRet++;
  1334. }
  1335. return nRet;
  1336. }
  1337. /************************************************************************/
  1338. /*
  1339. 函数: IsFolderExist
  1340. 描述: 判断共享目录是否存在
  1341. 参数:
  1342. const CString& strDomain 域名
  1343. std::vector<CString*>& vPath 共享目录集
  1344. 返回: TRUE成功,FALSE失败
  1345. */
  1346. /************************************************************************/
  1347. BOOL ChoosePhotoBase::IsShareFolderExist(CString& strSharePath)
  1348. {
  1349. if(strSharePath == _T(""))
  1350. return FALSE;
  1351. char szPath[MAX_PATH] = { 0 };
  1352. #if defined(VC80) || defined(VC70) || defined(VC60)
  1353. strcpy(szPath, strSharePath.GetBuffer(strSharePath.GetLength()));
  1354. #else
  1355. _tcscpy_s(szPath, MAX_PATH, strSharePath.GetString());
  1356. #endif
  1357. if(IsExistFolder(szPath) == -1)
  1358. return FALSE;
  1359. return TRUE;
  1360. }