ChoosePhotoBase.cpp 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485
  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. for (int i = 0; i < pArray->GetSize(); i++)
  288. {
  289. path = pArray->ElementAt(i);
  290. path = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
  291. if (path.Find(_T(".")) != -1)
  292. path = path.Left(path.Find(_T(".")));
  293. if ( no.CompareNoCase(path) == 0 )
  294. return pArray->ElementAt(i);
  295. }
  296. return _T("");
  297. }
  298. /************************************************************************/
  299. /*
  300. 函数:GetZS
  301. 描述:返回dindansp表中no或no2字段中关于选中相片名的相片数量;
  302. 参数:
  303. str:dindansp表no或no2字段值,使用逗号分隔开所有相片名;
  304. 返回:
  305. 返回no或no2字段中,所包含的相片名数量;
  306. */
  307. /************************************************************************/
  308. int ChoosePhotoBase::GetZS(CString str)
  309. {
  310. #ifdef USE_SEP_VEB
  311. str.TrimLeft(SEPS_VEB);
  312. str.TrimRight(SEPS_VEB);
  313. if (str.IsEmpty())
  314. return 0;
  315. int pos = str.Find(SEPS_VEB);
  316. int count = 1;
  317. while (pos != -1)
  318. {
  319. str.Delete(pos);
  320. pos = str.Find(SEPS_VEB);
  321. count++;
  322. }
  323. #else
  324. str.TrimLeft(SEPS_CMA);
  325. str.TrimRight(SEPS_CMA);
  326. if (str.IsEmpty())
  327. return 0;
  328. int pos = str.Find(SEPC_CMA);
  329. int count = 1;
  330. while (pos != -1)
  331. {
  332. str.Delete(pos);
  333. pos = str.Find(SEPC_CMA);
  334. count++;
  335. }
  336. #endif //#ifdef USE_SEP_VEB
  337. return count;
  338. }
  339. /************************************************************************/
  340. /*
  341. 函数:GetSelCountFromName
  342. 描述:返回相片数量;
  343. 参数:
  344. IN CString name,
  345. OUT CString &scount
  346. 返回:
  347. */
  348. /************************************************************************/
  349. void ChoosePhotoBase::GetSelCountFromName(CString name, CString &scount)
  350. {
  351. #ifdef USE_SEP_VEB
  352. name.TrimLeft(SEPS_VEB);
  353. name.TrimRight(SEPS_VEB);
  354. #else
  355. name.TrimLeft(SEPS_CMA);
  356. name.TrimRight(SEPS_CMA);
  357. #endif //#ifdef USE_SEP_VEB
  358. if (name.GetLength() == 0)
  359. {
  360. scount = "0";
  361. return;
  362. }
  363. int ncount = 0;
  364. #ifdef USE_SEP_VEB
  365. int npos = name.Find(SEPS_VEB);
  366. #else
  367. int npos = name.Find(SEPS_CMA);
  368. #endif //#ifdef USE_SEP_VEB
  369. while (npos != -1)
  370. {
  371. ncount++;
  372. name = name.Right(name.GetLength() - npos - 1);
  373. #ifdef USE_SEP_VEB
  374. npos = name.Find(SEPS_VEB);
  375. #else
  376. npos = name.Find(SEPS_CMA);
  377. #endif //#ifdef USE_SEP_VEB
  378. }
  379. ncount++;
  380. scount.Format("%d", ncount);
  381. }
  382. /************************************************************************/
  383. /*
  384. 函数: GetPathFromNo
  385. 描述: 通过图片名获取路径
  386. 参数:
  387. CString dir, 目标目录
  388. CString no, 图片名
  389. CStringArray *pArray 目标路径集合
  390. 返回: 返回获取的路径
  391. */
  392. /************************************************************************/
  393. CString ChoosePhotoBase::GetPathFromNo(CString dir, CString no, CStringArray *pArray)
  394. {
  395. CStringArray dirarray;
  396. CString sRet = _T("");
  397. CString temp = _T("");
  398. dir.TrimRight('\\');
  399. dir += _T("\\");
  400. if (pArray->GetSize() == 0)
  401. {
  402. ffsco o;
  403. o.dirs(1);
  404. o.find(LPCSTR(dir), LPCSTR("*.*"));
  405. ffsco::typeT coo;
  406. ffsco::typeT::iterator it;
  407. coo = o.co_dir();
  408. for (it = coo.begin(); coo.end() != it; it++)
  409. {
  410. temp = (*it).c_str();
  411. if (::FindArray(&dirarray, temp) == -1 && temp != dir)
  412. dirarray.Add(temp);
  413. }
  414. }
  415. else
  416. dirarray.Copy(*pArray);
  417. for (int i = 0; i < dirarray.GetSize(); i++)
  418. {
  419. temp = dirarray.ElementAt(i);
  420. sRet.Format(_T("%s%s.jpg"), temp, no);
  421. if (::PathFileExists(sRet))
  422. return sRet;
  423. }
  424. return dir + no + _T(".jpg");
  425. }
  426. void ChoosePhotoBase::SortArray2(CArray<int, int>&datearray)
  427. {
  428. int strtemp;
  429. int last = datearray.GetSize() - 1;
  430. bool sorted = true;
  431. do {
  432. sorted = true;
  433. for (int i = 0; i < last; i++)
  434. {
  435. if (datearray[i] < datearray[i + 1])
  436. {
  437. strtemp = datearray[i];
  438. datearray[i] = datearray[i + 1];
  439. datearray[i + 1] = strtemp;
  440. sorted = false;
  441. }
  442. }
  443. last--;
  444. } while (!sorted);
  445. }
  446. /*--------------------------------------------------
  447. // 函数: DelPhotoFromName
  448. // 描述: 通过名字删除
  449. // 参数:
  450. CStringArray& arr, 文件列表
  451. const CString& strName 文件名
  452. // 返回: 成功1,失败0;
  453. //--------------------------------------------------*/
  454. int ChoosePhotoBase::DelPhotoFromName(CStringArray& arr, const CString& strName)
  455. {
  456. if(strName == _T("") || arr.GetSize() == 0)
  457. return 0;
  458. CString strName2 = _T("");
  459. for (int i = 0; i < arr.GetSize(); i++)
  460. {
  461. strName2 = arr.ElementAt(i);
  462. strName2 = strName2.Right(strName2.GetLength() - strName2.ReverseFind('\\') - 1);
  463. strName2 = strName2.Left(strName2.Find('.'));
  464. if (strName == strName2)
  465. {
  466. arr.RemoveAt(i);
  467. return 1;
  468. }
  469. }
  470. return 0;
  471. }
  472. /************************************************************************/
  473. /*
  474. 函数: GetAllPhotoPath
  475. 描述: 获取全部相片路径
  476. 参数:
  477. CSting &strDirPath 目录路径
  478. 返回:
  479. */
  480. /************************************************************************/
  481. void ChoosePhotoBase::GetAllPhotoPath(CString& strDirPath, CStringArray& arr)
  482. {
  483. // 查找m_path下所有文件o.find(...);
  484. CString filename = _T("");
  485. CString path(_T("")), path2(_T(""));
  486. ffsco o;
  487. o.dirs(1);
  488. o.find(LPCSTR(strDirPath), LPCSTR("*.*"));
  489. ffsco::typeT coo;
  490. ffsco::typeT::iterator it;
  491. coo = o.co_file();
  492. for (it = coo.begin(); coo.end() != it; it++) // 遍历文件夹;
  493. {
  494. path = (*it).c_str();
  495. if (path.GetAt(path.ReverseFind('\\') + 1) != 's' && path.GetAt(path.ReverseFind('\\') + 1) != 'm')
  496. {
  497. path.MakeLower();
  498. filename = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
  499. if (filename.Find(_T(".")) != -1)
  500. filename = filename.Left(filename.Find(_T(".")));
  501. if (!myisdigit(filename))continue;
  502. if (m_nChoosePhotoType == 1) // m_AllPhotoPath只添加修片文件夹;
  503. {
  504. #if JEFF_TEST_ON
  505. if(PathFileExists(path))
  506. arr.Add(path);
  507. #endif //#if JEFF_TEST_ON
  508. }
  509. else if (m_nChoosePhotoType == 0 || m_nChoosePhotoType == 2)//else // m_nChoosePhotoType=0,2
  510. {
  511. path2 = path;
  512. if (m_nChoosePhotoType == 0) // 原片+修片;
  513. {
  514. path2.Replace(_T("客户原片"), _T("修好的片"));
  515. //printf("Jeff:原片+修片 path2=%s\n\n",path2); // Jeff Printf;
  516. }
  517. if (m_bGrowthTX == 0)
  518. {
  519. int pos = path2.Find(m_strOrderNumber);
  520. pos += m_strOrderNumber.GetLength();
  521. int pos2 = path2.ReverseFind('\\');
  522. path2 = path2.Left(pos) + path2.Right(path2.GetLength() - pos2);
  523. }
  524. if (m_nChoosePhotoType == 0 && PathFileExists(path2)) // 原片+修片;
  525. {
  526. arr.Add(path2);
  527. }
  528. else // 不仅原片
  529. {
  530. path2.Replace(_T(".raw"), _T(".jpg"));
  531. if (PathFileExists(path2))
  532. {
  533. arr.Add(path2);
  534. continue;
  535. }
  536. path2.Replace(_T(".nef"), _T(".jpg"));
  537. if (PathFileExists(path2))
  538. {
  539. arr.Add(path2);
  540. continue;
  541. }
  542. path2.Replace(_T(".cr2"), _T(".jpg"));
  543. if (PathFileExists(path2))
  544. {
  545. arr.Add(path2);
  546. continue;
  547. }
  548. else
  549. {
  550. if (path.Right(3) != _T("jpg"))
  551. continue;
  552. #if JEFF_TEST_ON
  553. if (PathFileExists(path))
  554. arr.Add(path);
  555. #else
  556. arr.Add(path);
  557. #endif //#if JEFF_TEST_ON
  558. }
  559. }
  560. }
  561. }
  562. }
  563. }
  564. /************************************************************************/
  565. /* 函数:GetTXName[4/17/2016 IT];
  566. /* 描述:若是儿童成长套系,获取成长套系内容;
  567. /* 参数:;
  568. /* [IN] pStrOrder:订单号;
  569. /* [IN] nModle:选片或选设计, nModel == 0 表示选片, nMode == 1 表示选设计;
  570. /* [OUT] bGrowthTx:若查询是儿童成长套系,返回TRUE;
  571. /* [OUT] strTxName:若查询是儿童成长套系,返回要选片的成长套系名;
  572. /* 返回:void;
  573. /* 注意:;
  574. /* 示例:;
  575. /*
  576. /* 修改:;
  577. /* 日期:;
  578. /* 内容:;
  579. /************************************************************************/
  580. void ChoosePhotoBase::GetTXName(IN const CString* pStrOrder, IN const int nModle, OUT BOOL& bGrowthTx, OUT CString& strTxName)
  581. {
  582. if(pStrOrder == NULL || (*pStrOrder) == _T(""))
  583. return;
  584. IsGrowthTx growthtxdlg;
  585. growthtxdlg.m_mode = nModle;
  586. growthtxdlg.m_strOrderNumber = (*pStrOrder);
  587. growthtxdlg.DoModal();
  588. bGrowthTx = growthtxdlg.m_bGrowthTx;
  589. strTxName = growthtxdlg.m_seltxname;
  590. }
  591. /************************************************************************/
  592. /*
  593. 函数: GetPhotos
  594. 描述: 得看设计
  595. 参数:
  596. 返回:
  597. */
  598. /************************************************************************/
  599. void ChoosePhotoBase::GetPhotos()
  600. {
  601. int i = 0;
  602. int j = 0;
  603. m_AllPhotoPath.RemoveAll();
  604. m_path.MakeLower();
  605. CStringArray dirarray;
  606. CString str;
  607. if (1)
  608. {
  609. ffsco o;
  610. o.dirs(1);
  611. o.find(LPCSTR(m_path), LPCSTR(_T("*.*")));
  612. ffsco::typeT coo;
  613. ffsco::typeT::iterator it;
  614. coo = o.co_dir();
  615. for (it = coo.begin(); coo.end() != it; it++)
  616. {
  617. str = (*it).c_str();
  618. str.TrimRight(_T("\\"));
  619. CString dirname = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  620. if (dirname.Find("DelgaBook") != -1)
  621. {
  622. if (FindArray(&m_AllPhotoPath, str) == -1)
  623. m_AllPhotoPath.Add(str);
  624. }
  625. if (FindArray(&dirarray, str) == -1)
  626. dirarray.Add(str);
  627. }
  628. }
  629. if (1)
  630. {
  631. for ( i = 0; i < dirarray.GetSize(); i++)
  632. {
  633. ffsco o;
  634. o.dirs(0);
  635. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  636. ffsco::typeT coo;
  637. ffsco::typeT::iterator it;
  638. coo = o.co_file();
  639. for (it = coo.begin(); coo.end() != it; it++)
  640. {
  641. str = (*it).c_str();
  642. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  643. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  644. str.MakeLower();
  645. m_AllPhotoPath.Add(str);
  646. }
  647. }
  648. }
  649. CStringArray *pArray[1] = { &m_AllPhotoPath };
  650. for ( i = 0; i < 1; i++)
  651. {
  652. m_combo1.ResetContent();
  653. CString Temp;
  654. for ( j = 0; j < pArray[i]->GetSize(); j++)
  655. m_combo1.AddString(pArray[i]->ElementAt(j));
  656. for (j = 0; j < pArray[i]->GetSize(); j++)
  657. {
  658. m_combo1.GetLBText(j, Temp);
  659. pArray[i]->SetAt(j, Temp);
  660. }
  661. }
  662. }
  663. /************************************************************************/
  664. /*
  665. 函数:[3/4/2016 CheckOK];
  666. 描述:判断字符串是否是数字组成;
  667. 参数:
  668. name 要判断的字符串;
  669. 返回:如果是数字组成返回1,否则返回0;
  670. */
  671. /************************************************************************/
  672. BOOL ChoosePhotoBase::CheckOK(CString name)
  673. {
  674. if (name.GetLength() > 4)return 0;
  675. for (int i = 0; i < name.GetLength(); i++)
  676. {
  677. if (name.GetAt(i) < '0' || name.GetAt(i) > '9')return 0;
  678. }
  679. return 1;
  680. }
  681. /************************************************************************/
  682. /*
  683. 函数: GetSelName
  684. 描述: 获取文件名
  685. 参数:
  686. CString name 相片名
  687. 返回:
  688. 注意:
  689. */
  690. /************************************************************************/
  691. CString ChoosePhotoBase::GetSelName(CString name)
  692. {
  693. CString ret;
  694. int i = 0;
  695. #ifdef USE_SEP_VEB
  696. name = SEPS_VEB + name + SEPS_VEB;
  697. #else
  698. name = SEPS_CMA + name + SEPS_CMA;
  699. #endif //#ifdef USE_SEP_VEB
  700. for ( i = 0; i < m_List2.GetItemCount(); i++)
  701. {
  702. if (m_noarray.ElementAt(i).Find(name) != -1)
  703. {// 获取数量;
  704. ret += m_List2.GetItemText(i, 2);
  705. ret += _T("\r\n");
  706. }
  707. }
  708. for (i = 0; i < m_List3.GetItemCount(); i++)
  709. {
  710. if (m_no2array.ElementAt(i).Find(name) != -1)
  711. {// 获取商品名称;
  712. ret += m_List3.GetItemText(i, 2);
  713. ret += _T("\r\n");
  714. }
  715. }
  716. if (!ret.IsEmpty())
  717. {
  718. ret = _T("\r\n") + ret;
  719. ret.TrimRight("\r\n");
  720. }
  721. return ret;
  722. }
  723. /************************************************************************/
  724. /*
  725. 函数: ClearResData
  726. 描述: 清除资源的路径
  727. 参数:
  728. 返回:
  729. */
  730. /************************************************************************/
  731. void ChoosePhotoBase::ClearResData()
  732. {
  733. vector<SResData*>::iterator it = m_vResData.begin();
  734. for(;it != m_vResData.end();)
  735. {
  736. SResData* p = (*it);
  737. if(p != NULL)
  738. delete p;
  739. ++it;
  740. }
  741. m_vResData.clear();
  742. }
  743. /************************************************************************/
  744. /*
  745. 函数: RecordDeletedPhotos
  746. 描述: 记录已删除的相片
  747. 参数:
  748. CString* pStrDel, 要删除的相片
  749. CStringArray& arr 要删除的相片保存到array
  750. 返回:
  751. 注意:
  752. */
  753. /************************************************************************/
  754. void ChoosePhotoBase::RecordDeletedPhotos(CString* pStrDel, CStringArray& arr)
  755. {
  756. if(pStrDel == NULL || (*pStrDel) == _T(""))
  757. return;
  758. //添加删除相片;
  759. #ifdef USE_SEP_VEB
  760. m_delphotos.TrimLeft(SEPC_VEB);
  761. m_delphotos.TrimRight(SEPC_VEB);
  762. m_delphotos = SEPC_VEB + m_delphotos;
  763. m_delphotos += SEPC_VEB;
  764. #else
  765. m_delphotos.TrimLeft(SEPC_SCN);
  766. m_delphotos.TrimRight(SEPC_SCN);
  767. m_delphotos = SEPC_SCN + m_delphotos;
  768. m_delphotos += SEPC_SCN;
  769. #endif //#ifdef USE_SEP_VEB
  770. for (int i = m_AllPhotoPath.GetSize() - 1; i >= 0; i--)
  771. {
  772. CString no;
  773. no = m_AllPhotoPath.ElementAt(i);
  774. no = no.Right(no.GetLength() - no.ReverseFind('\\') - 1);
  775. no = no.Left(no.Find('.'));
  776. #ifdef USE_SEP_VEB
  777. no = SEPC_VEB + no;
  778. no += SEPC_VEB;
  779. #else
  780. no = SEPC_SCN + no;
  781. no += SEPC_SCN;
  782. #endif //#ifdef USE_SEP_VEB
  783. if (m_delphotos.Find(no) != -1)
  784. {
  785. no = m_AllPhotoPath.ElementAt(i);
  786. m_AllPhotoPath.RemoveAt(i);
  787. #if JEFF_TEST_ON
  788. if(PathFileExists(no))
  789. arr.Add(no);
  790. #else
  791. arr.Add(no);
  792. #endif //JEFF_TEST_ON
  793. }
  794. }
  795. }
  796. /************************************************************************/
  797. /*
  798. 函数: AddPhotoFromDir
  799. 描述: 添加选中相片
  800. 参数:
  801. CStringArray* pSelArr 选中相片集合
  802. const CString& strDir, 目标目录
  803. CString& str 文件名: ",004,"
  804. const int nPos 字符','在文件名的位置
  805. 返回: 1成功, 0失败
  806. */
  807. /*************************************************************************/
  808. int ChoosePhotoBase::AddPhotoFromDir(CStringArray* pSelArr, const CString& strDir, CString& str)
  809. {
  810. if(pSelArr == NULL || strDir.IsEmpty() || str == _T(""))
  811. return 0;
  812. CString path(_T(""));
  813. #ifdef USE_SEP_VEB
  814. int pos = str.Find(SEPS_VEB);
  815. #else
  816. int pos = str.Find(SEPS_CMA);
  817. #endif //#ifdef USE_SEP_VEB
  818. while (pos != -1)
  819. {
  820. path = strDir + str.Left(pos) + _T(".jpg");
  821. if (FindArray(pSelArr, path) == -1)
  822. {
  823. #if JEFF_TEST_ON
  824. if (PathFileExists(path))
  825. pSelArr->Add(path);
  826. #else
  827. pSelArr->Add(path);
  828. #endif //#if JEFF_TEST_ON
  829. }
  830. str = str.Right(str.GetLength() - pos - 1);
  831. #ifdef USE_SEP_VEB
  832. pos = str.Find(SEPS_VEB);
  833. #else
  834. pos = str.Find(SEPC_CMA);
  835. #endif //#ifdef USE_SEP_VEB
  836. }
  837. path = strDir + str + _T(".jpg");
  838. if (FindArray(pSelArr, path) == -1)
  839. {
  840. #if JEFF_TEST_ON
  841. if (PathFileExists(path))
  842. pSelArr->Add(path);
  843. #else
  844. pSelArr->Add(path);//MessageBox(path);
  845. #endif //#if JEFF_TEST_ON
  846. }
  847. return 1;
  848. }
  849. void ChoosePhotoBase::CalChooseZS(CStringArray* pSelArr, CStringArray* pAllArr)
  850. {
  851. if(pSelArr == NULL || pAllArr == NULL)
  852. return;
  853. int i = 0;
  854. CString str = _T("");
  855. pSelArr->RemoveAll();
  856. for ( i = 0; i < m_noarray.GetSize(); i++)
  857. {
  858. str = m_noarray.ElementAt(i);
  859. GetPathAddToSel(pSelArr, str, pAllArr);
  860. }
  861. for (i = 0; i < m_no2array.GetSize(); i++)
  862. {
  863. str = m_no2array.ElementAt(i);
  864. GetPathAddToSel(pSelArr, str, pAllArr);
  865. }
  866. }
  867. //--------------------------------------------------
  868. // remark by Jeff 2014.12.15
  869. // 函数:CheckName
  870. // 描述:类似CheckOK,判断字符串是否是数字组成(除去"$" "."两符号以及后缀名);
  871. // 参数:name 要判断的字符串;
  872. // 返回:如果是数字组成返回1,否则返回0;
  873. //--------------------------------------------------
  874. BOOL ChoosePhotoBase::CheckName(CString name)
  875. {//$001.002.003
  876. int pos = name.Find("$");
  877. if (pos != 0)return 0;
  878. name.Delete(0, 1);
  879. pos = name.Find(".");
  880. while (pos != -1)
  881. {
  882. if (CheckOK(name.Left(pos)) == 0)return 0;
  883. name = name.Right(name.GetLength() - pos - 1);
  884. pos = name.Find(".");
  885. }
  886. return CheckOK(name);
  887. }
  888. /************************************************************************/
  889. /* 函数:GetPathAddToSel[4/17/2016 IT];
  890. /* 描述:获取路径添加到选中相片;
  891. /* 参数:;
  892. /* [IN] pSelArr:dindapsp.no或dindansp.no2的相片路径结果集;
  893. /* [IN] strName:dindansp表中每个商品记录中的no字段对应的相片串;
  894. /* [IN] pAllArr:strName的相片路径来源;
  895. /* 返回:1成功,0失败;
  896. /* 注意:;
  897. /* 示例:;
  898. /*
  899. /* 修改:;
  900. /* 日期:;
  901. /* 内容:;
  902. /************************************************************************/
  903. int ChoosePhotoBase::GetPathAddToSel(CStringArray* pSelArr, const CString& strName, CStringArray* pAllArr)
  904. {
  905. if(pSelArr == NULL || strName == _T("") || pAllArr == NULL)
  906. return 0;
  907. CString str = strName;
  908. if (m_bFromLocal)
  909. {
  910. // 本地(缓存)加载选片
  911. #ifdef USE_SEP_VEB
  912. str.TrimLeft(SEPS_VEB);
  913. str.TrimRight(SEPS_VEB);
  914. #else
  915. str.TrimLeft(SEPS_CMA);
  916. str.TrimRight(SEPS_CMA);
  917. #endif //#ifdef USE_SEP_VEB
  918. if (str.IsEmpty())
  919. return 0;
  920. CString path(_T("")), path2(_T(""));
  921. #ifdef _UNICODE
  922. WCHAR spath[MAX_PATH] = {0};
  923. #else
  924. char spath[MAX_PATH] = {0};
  925. #endif //#ifdef _UNICODE
  926. ::GetSystemDirectory(spath, MAX_PATH);
  927. CString sysdir = spath;
  928. sysdir += _T("\\lyfz");
  929. sysdir += _T("\\");
  930. sysdir += m_strOrderNumber;
  931. sysdir += _T("\\");
  932. AddPhotoFromDir(pSelArr, sysdir, str);
  933. }
  934. else
  935. {
  936. #ifdef USE_SEP_VEB
  937. str.TrimLeft(SEPS_VEB);
  938. str.TrimRight(SEPS_VEB);
  939. #else
  940. str.TrimLeft(SEPS_CMA);
  941. str.TrimRight(SEPS_CMA);
  942. #endif //#ifdef USE_SEP_VEB
  943. if (str.IsEmpty())
  944. return 0;
  945. #ifdef USE_SEP_VEB
  946. int pos = str.Find(SEPS_VEB);
  947. #else
  948. int pos = str.Find(SEPS_CMA);
  949. #endif //#ifdef USE_SEP_VEB
  950. CString path(_T("")), path2(_T(""));
  951. while (pos != -1)
  952. {
  953. path = GetPathFromNo2(m_path, str.Left(pos), pAllArr);
  954. path2 = path;
  955. if (path != _T("") && FindArray(pSelArr, path) == -1)
  956. {
  957. if (PathFileExists(path))
  958. pSelArr->Add(path);
  959. }
  960. str = str.Right(str.GetLength() - pos - 1);
  961. #ifdef USE_SEP_VEB
  962. pos = str.Find(SEPS_VEB);
  963. #else
  964. pos = str.Find(SEPS_CMA);
  965. #endif //#ifdef USE_SEP_VEB
  966. }
  967. path = GetPathFromNo2(m_path, str, pAllArr);//+".jpg";
  968. path2 = path;
  969. if(path == _T(""))
  970. return 0;
  971. if (FindArray(pSelArr, path) == -1)
  972. {
  973. if (PathFileExists(path))
  974. pSelArr->Add(path);
  975. }
  976. }
  977. return 1;
  978. }
  979. /************************************************************************/
  980. /*
  981. 函数: LoadThumbImages
  982. 描述: 创建线程加载函数LoadThumbNail3
  983. 参数:
  984. 返回:
  985. 注意:
  986. */
  987. /************************************************************************/
  988. void ChoosePhotoBase::LoadThumbImages()
  989. {
  990. TerminateThread();
  991. m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail3, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
  992. m_bRunning = true;
  993. }
  994. BOOL ChoosePhotoBase::TerminateThread()
  995. {
  996. if (!m_bRunning)
  997. return TRUE;
  998. m_bTerminate = true;
  999. for (;;)
  1000. {
  1001. if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
  1002. break;
  1003. MSG msg;
  1004. while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  1005. {
  1006. if (!AfxGetApp()->PumpMessage())
  1007. break;
  1008. }
  1009. }
  1010. ::CloseHandle(m_hThread);
  1011. m_hThread = NULL;
  1012. return TRUE;
  1013. }
  1014. //extern void LoadImageFromFile(Image **img, CString path);
  1015. unsigned __stdcall LoadThumbNail3(LPVOID lpParam)
  1016. {
  1017. ChoosePhotoBase* pDlg = (ChoosePhotoBase*)lpParam;
  1018. pDlg->DrawImageWork();
  1019. return 0;
  1020. }
  1021. void ChoosePhotoBase::Save(IN LPCTSTR lpPath, IN LPCTSTR lpFileName)
  1022. {
  1023. int i = 0;
  1024. int j = 0;
  1025. CString sql;
  1026. CArray<CStringArray, CStringArray>sparray;
  1027. sparray.SetSize(m_List2.GetItemCount() + m_no2array.GetSize());
  1028. for ( i = 0; i < m_List2.GetItemCount(); i++)
  1029. {
  1030. sparray.ElementAt(i).Add(m_strOrderNumber);
  1031. sparray.ElementAt(i).Add(m_List2.GetItemText(i, 0));
  1032. sparray.ElementAt(i).Add(m_List2.GetItemText(i, 1));
  1033. sparray.ElementAt(i).Add(m_List2.GetItemText(i, 2));
  1034. sparray.ElementAt(i).Add(m_List2.GetItemText(i, 3));
  1035. sparray.ElementAt(i).Add(m_List2.GetItemText(i, 4));
  1036. }
  1037. for ( j = 0; j < m_no2array.GetSize(); j++)
  1038. {
  1039. sparray.ElementAt(i).Add(m_strOrderNumber);
  1040. sparray.ElementAt(i).Add(m_List3.GetItemText(j, 0));
  1041. sparray.ElementAt(i).Add(m_List3.GetItemText(j, 1));
  1042. sparray.ElementAt(i).Add(m_List3.GetItemText(j, 2));
  1043. sparray.ElementAt(i).Add(m_List3.GetItemText(j, 3));
  1044. sparray.ElementAt(i).Add(m_List3.GetItemText(j, 4));
  1045. sparray.ElementAt(i).Add(m_List3.GetItemText(j, 5));
  1046. #ifdef LKAY_VERSION
  1047. sparray.ElementAt (i).Add ( m_List3.GetItemText (j, 6) );
  1048. sparray.ElementAt (i).Add ( m_List3.GetItemText (j, 7) );
  1049. #endif //#ifdef LKAY_VERSION
  1050. sparray.ElementAt(i).Add("4");
  1051. i++;
  1052. }
  1053. if (sparray.GetSize() == 0)
  1054. {
  1055. sparray.SetSize(1);
  1056. sparray.ElementAt(0).Add(m_strOrderNumber);
  1057. }
  1058. CMemFile memfile;
  1059. CArchive ar(&memfile, CArchive::store);
  1060. for (int ii = 0; ii < sparray.GetSize(); ii++)
  1061. {
  1062. sparray.ElementAt(ii).Serialize(ar);
  1063. }
  1064. ar.Close();
  1065. int length = memfile.GetLength();
  1066. BYTE *pData = memfile.Detach();
  1067. int size = sparray.GetSize();
  1068. BYTE *pData2 = new BYTE[length + sizeof(int)];
  1069. memcpy(pData2, pData, length);
  1070. memcpy(pData2 + length, &size, sizeof(int));
  1071. delete[]pData;
  1072. length += sizeof(int);
  1073. CString savepath = _T("");
  1074. //savepath.Format("%s\\%s.dat", g_mainpath, lpFileName/*m_strOrderNumber*/);选片
  1075. //savepath.Format("%s\\%s-2.dat", g_mainpath, lpFileName/*m_strOrderNumber*/);选版
  1076. savepath.Format("%s\\%s.dat", lpPath, lpFileName);
  1077. if (1)
  1078. {
  1079. CFile fp;
  1080. fp.Open(savepath, CFile::modeCreate | CFile::modeWrite);
  1081. fp.Write(pData2, length);
  1082. fp.Close();
  1083. }
  1084. delete[]pData2;
  1085. }
  1086. /************************************************************************/
  1087. /*
  1088. 函数: IsFileExist
  1089. 描述: 文件是否存在
  1090. 参数:
  1091. 返回:
  1092. */
  1093. /************************************************************************/
  1094. BOOL ChoosePhotoBase::IsFileExistInDir(CString* pPath)
  1095. {
  1096. BOOL bExist = FALSE;
  1097. if(pPath == NULL || (*pPath) == _T(""))
  1098. return bExist;
  1099. ffsco o;
  1100. o.dirs(0);
  1101. o.find(pPath->GetBuffer(pPath->GetLength()), LPCSTR("*.jpg"));
  1102. int nsize = o.co_file().size();
  1103. if (nsize > 0)
  1104. bExist = TRUE;
  1105. return bExist;
  1106. }
  1107. /************************************************************************/
  1108. /* 函数:IsSelPhoto[4/18/2016 IT];
  1109. /* 描述:是否选取相片;
  1110. /* 参数:;
  1111. /* [IN] strPhotoName:如:"|004|";
  1112. /* [OUT] :;
  1113. /* [IN/OUT] :;
  1114. /* 返回:void;
  1115. /* 注意:;
  1116. /* 示例:;
  1117. /*
  1118. /* 修改:;
  1119. /* 日期:;
  1120. /* 内容:;
  1121. /************************************************************************/
  1122. BOOL ChoosePhotoBase::IsSelPhoto(CString strPhotoName)
  1123. {
  1124. int nPos = 0;
  1125. int i = 0;
  1126. for (i = 0; i < m_no2array.GetSize(); i++)
  1127. {
  1128. // m_no2array.ElementAt(i) 前后都有 SEPS_VEB;
  1129. if ( m_no2array.ElementAt(i).Find(strPhotoName) != -1 )
  1130. {
  1131. return TRUE;
  1132. }
  1133. }
  1134. for (i = 0; i < m_noarray.GetSize(); i++)
  1135. {
  1136. // m_noarray.ElementAt(i) 前后都有 SEPS_VEB;
  1137. if ( m_noarray.ElementAt(i).Find(strPhotoName) != -1 )
  1138. {
  1139. return TRUE;
  1140. }
  1141. }
  1142. return FALSE;
  1143. }
  1144. /************************************************************************/
  1145. /*
  1146. 函数: IsPhoto2Exist
  1147. 描述:
  1148. 参数:
  1149. 返回: 0,>1
  1150. */
  1151. /************************************************************************/
  1152. BOOL ChoosePhotoBase::IsPhoto2Exist()
  1153. {
  1154. CString path2;
  1155. CString path = _T("");
  1156. path = g_path2 + _T("\\");
  1157. path += m_strOrderNumber;
  1158. path += _T("\\");
  1159. CStringArray StrSubFoloderArray;
  1160. ffsco o;
  1161. o.dirs(1); // Jeff.1:查找子目录;
  1162. o.find(LPCSTR(path), LPCSTR("*.*")); // 可能存在m和s开头的缩略图,需要过滤掉;
  1163. if (o.count() == 0)
  1164. return 0;
  1165. // 获取子目录数;
  1166. ffsco::typeT coo;
  1167. ffsco::typeT::iterator it;
  1168. coo = o.co_dir();
  1169. for (it = coo.begin(); it != coo.end(); it++)
  1170. {
  1171. if (::FindArray(&StrSubFoloderArray, (*it).c_str()) == -1)
  1172. StrSubFoloderArray.Add((*it).c_str());
  1173. }
  1174. // 获取子目录下的文件数;
  1175. CStringArray StrPhotoArray;
  1176. for (int n = 0; n < StrSubFoloderArray.GetSize(); n++)
  1177. {
  1178. ffsco op;
  1179. op.dirs(0);
  1180. // printf("path=%s\n", StrSubFoloderArray.ElementAt(n));
  1181. op.find(LPCSTR(StrSubFoloderArray.ElementAt(n)), LPCSTR("*.*"));
  1182. ffsco::typeT coo;
  1183. ffsco::typeT::iterator itp;
  1184. coo = op.co_file();
  1185. for (itp = coo.begin(); itp != coo.end(); itp++)
  1186. {
  1187. StrPhotoArray.Add((*itp).c_str());
  1188. }
  1189. }
  1190. CString strTempFile;
  1191. int nIndex = 0;
  1192. int nSizeOfFile = 0; // 记录相片文件数;
  1193. int nCount = StrPhotoArray.GetSize();
  1194. for (int i = 0; i < nCount; i++)
  1195. {
  1196. strTempFile = StrPhotoArray.ElementAt(i);
  1197. nIndex = strTempFile.ReverseFind('\\');
  1198. strTempFile = strTempFile.Right(strTempFile.GetLength() - nIndex - 1);
  1199. // printf("file=%s\n", strTempFile);
  1200. if (strTempFile.Left(1) == _T("m") || strTempFile.Left(1) == _T("s"))
  1201. {
  1202. continue;
  1203. }
  1204. strTempFile = strTempFile.Right(4);
  1205. strTempFile.MakeLower();
  1206. if (strTempFile == _T(".jpg"))
  1207. {
  1208. nSizeOfFile++;
  1209. }
  1210. else if (strTempFile == _T(".raw"))
  1211. {
  1212. nSizeOfFile++;
  1213. }
  1214. else if (strTempFile == _T(".cr2"))
  1215. {
  1216. nSizeOfFile++;
  1217. }
  1218. else if (strTempFile == _T(".nef"))
  1219. {
  1220. nSizeOfFile++;
  1221. }
  1222. }
  1223. return nSizeOfFile;
  1224. }
  1225. void ChoosePhotoBase::OnPaint2(CWnd *pWnd)
  1226. {
  1227. try
  1228. {
  1229. CPaintDC dc(pWnd); // device context for painting
  1230. // TODO: Add your message handler code here
  1231. CRect rc;
  1232. GetClientRect(rc);
  1233. if (m_pBk == NULL)
  1234. {
  1235. return;
  1236. }
  1237. int width = m_pBk->GetWidth();
  1238. int height = m_pBk->GetHeight();
  1239. Graphics graph(dc.GetSafeHdc());
  1240. Rect destinationRect(0, 0, rc.Width(), rc.Height());
  1241. graph.SetSmoothingMode(SmoothingModeHighQuality);
  1242. graph.DrawImage(m_pBk, destinationRect, 0, 0, width, height, UnitPixel);
  1243. }
  1244. catch (...)
  1245. {
  1246. }
  1247. }
  1248. /************************************************************************/
  1249. /*
  1250. 函数: IsThereACacheImg
  1251. 描述: 检查本机上是否有缓存的相片
  1252. 参数:
  1253. 返回:
  1254. */
  1255. /************************************************************************/
  1256. BOOL ChoosePhotoBase::IsThereACacheImg()
  1257. {
  1258. CString str = _T("");
  1259. char path[MAX_PATH] = {0};
  1260. ::GetSystemDirectory(path, MAX_PATH);
  1261. CString sysdir = path;
  1262. sysdir += _T("\\lyfz");
  1263. ::CreateDirectory(sysdir, NULL);
  1264. sysdir += _T("\\");
  1265. sysdir += m_strOrderNumber;
  1266. ffsco o;
  1267. o.dirs(1);
  1268. o.find(LPCSTR(sysdir), LPCSTR(_T("*.jpg")));
  1269. ffsco::typeT coo;
  1270. ffsco::typeT::iterator it;
  1271. coo = o.co_file();
  1272. if (coo.size())
  1273. {
  1274. if (AfxMessageBox("提醒, 此客人有本机缓存片,是否使用缓存片?", MB_YESNO | MB_ICONINFORMATION) == IDYES)
  1275. {
  1276. for (it = coo.begin(); coo.end() != it; it++)
  1277. {
  1278. str = (*it).c_str();
  1279. if (str.GetAt(str.ReverseFind('\\') + 1) != 's' && str.GetAt(str.ReverseFind('\\') + 1) != 'm')
  1280. m_AllPhotoPath.Add(str);
  1281. }
  1282. return 1;
  1283. }
  1284. }
  1285. return 0;
  1286. }
  1287. /************************************************************************/
  1288. /*
  1289. 函数: GetNoSelPhotoCount
  1290. 描述: 获取未选相片数量
  1291. 参数:
  1292. CStringArray* pAllPhotoPath,
  1293. CStringArray* pSelPhotoPath
  1294. 返回:
  1295. 注意: 返回数量
  1296. */
  1297. /************************************************************************/
  1298. int ChoosePhotoBase::GetNoSelPhotoCount(CStringArray* pAllPhotoPath, CStringArray* pSelPhotoPath)
  1299. {
  1300. if(pAllPhotoPath == NULL || pSelPhotoPath == NULL)
  1301. return 0;
  1302. int nRet = 0;
  1303. CString str1, str2;
  1304. for (int i = 0; i < pAllPhotoPath->GetSize(); i++)
  1305. {
  1306. BOOL bFind = 0;
  1307. for (int j = 0; j < pSelPhotoPath->GetSize(); j++)
  1308. {
  1309. str1 = pAllPhotoPath->ElementAt(i);
  1310. str2 = pSelPhotoPath->ElementAt(j);
  1311. if (str1.CollateNoCase(str2) == 0)
  1312. {
  1313. bFind = 1;
  1314. break;
  1315. }
  1316. }
  1317. if (bFind == 0)
  1318. nRet++;
  1319. }
  1320. return nRet;
  1321. }
  1322. /************************************************************************/
  1323. /*
  1324. 函数: IsFolderExist
  1325. 描述: 判断共享目录是否存在
  1326. 参数:
  1327. const CString& strDomain 域名
  1328. std::vector<CString*>& vPath 共享目录集
  1329. 返回: TRUE成功,FALSE失败
  1330. */
  1331. /************************************************************************/
  1332. BOOL ChoosePhotoBase::IsShareFolderExist(CString& strSharePath)
  1333. {
  1334. if(strSharePath == _T(""))
  1335. return FALSE;
  1336. char szPath[MAX_PATH] = { 0 };
  1337. #ifdef VC60
  1338. strcpy(szPath, strSharePath.GetBuffer(strSharePath.GetLength()));
  1339. #else
  1340. _tcscpy_s(szPath, MAX_PATH, strSharePath.GetString());
  1341. #endif
  1342. if(IsExistFolder(szPath) == -1)
  1343. return FALSE;
  1344. return TRUE;
  1345. }