ShowPic.cpp 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071
  1. // ShowPic.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "ShowPic.h"
  6. #include "ShowPic22.h"
  7. #include "ImportPhoto.h"
  8. #include "JPEG.h"
  9. #include "MyLock.h"
  10. #include "ZipTypeDlg.h"
  11. #include "SetDesignNo.h"
  12. #include "NetShareInfo.h"
  13. #define THUMBNAIL_WIDTH 100
  14. #define THUMBNAIL_HEIGHT 90
  15. ThreadSection ShowPic::m_ThreadSection;
  16. unsigned __stdcall RefreshWork(LPVOID lpParam);
  17. /////////////////////////////////////////////////////////////////////////////
  18. // ShowPic dialog IDC_BU IDC_COMBO2
  19. ShowPic::ShowPic(CWnd* pParent /*=NULL*/): CDialog(ShowPic::IDD, pParent)
  20. {
  21. m_branchname = _T("");
  22. m_bRunning = false;
  23. m_bExit = FALSE;
  24. m_hThread = NULL;
  25. m_mode = 0;
  26. m_bdelall = 0;
  27. m_nDelCount = 0;
  28. m_hRefExitEvent = NULL;
  29. m_hThreadRef = NULL;
  30. m_bOriginalImg = FALSE;
  31. m_pUnKnown = NULL;
  32. //m_hEvent = NULL;
  33. }
  34. void ShowPic::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CDialog::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(ShowPic)
  38. DDX_Control(pDX, IDC_COMBO2, m_combobranch);
  39. DDX_Control(pDX, IDC_LIST1, m_List1);
  40. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  41. DDX_CBString(pDX, IDC_COMBO2, m_branchname);
  42. //}}AFX_DATA_MAP
  43. }
  44. BEGIN_MESSAGE_MAP(ShowPic, CDialog)
  45. //{{AFX_MSG_MAP(ShowPic)
  46. ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
  47. //ON_WM_DESTROY()
  48. ON_BN_CLICKED(IDC_BUTdelall, OnBUTdelall)
  49. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  50. ON_BN_CLICKED(IDC_BUTupload, OnBUTupload)
  51. ON_BN_CLICKED(IDC_BUTselall, OnBUTselall)
  52. ON_CBN_SELCHANGE(IDC_COMBO2, OnSelchangeCombo2)
  53. ON_BN_CLICKED(IDC_BUTSetDesignNo, OnBUTSetDesignNo)
  54. ON_BN_CLICKED(IDC_BUTexport, OnBUTexport)
  55. ON_BN_CLICKED(IDC_BUT_RefreshPhotos, OnButRefreshPhotos)
  56. //}}AFX_MSG_MAP
  57. END_MESSAGE_MAP()
  58. /////////////////////////////////////////////////////////////////////////////
  59. // ShowPic message handlers
  60. BOOL ShowPic::OnInitDialog()
  61. {
  62. CDialog::OnInitDialog();
  63. m_id.MakeLower();
  64. // 1.移动到合适的位置;
  65. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  66. // 2.获取窗口新的区域坐标值;
  67. CRect rcWnd;
  68. GetClientRect(rcWnd);
  69. // 3.自动处理控件大小与位置,共有9个控件;
  70. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  71. // 4.获取OK(关闭)按钮大小,并计算出放置控件的区域;
  72. CRect rcCtrl;
  73. GetDlgItem(IDOK)->GetWindowRect(rcCtrl);
  74. ScreenToClient(rcCtrl);
  75. // 5.计算出所有控件的显示区域;
  76. CRect rcAllCtrl;
  77. rcAllCtrl.top = rcCtrl.top;
  78. rcAllCtrl.bottom = rcCtrl.bottom;
  79. rcAllCtrl.left = rcWnd.left + 5;
  80. rcAllCtrl.right = rcWnd.right - 5;
  81. CRect *prcCtrl = SubgroubRectangle(rcAllCtrl, 5, 9);
  82. int hei = rcCtrl.Height();
  83. rcCtrl = rcWnd;
  84. rcCtrl.top = hei + 10;
  85. m_List1.MoveWindow(rcCtrl);
  86. int right = rcCtrl.right;
  87. // 关闭;
  88. GetDlgItem(IDOK)->GetWindowRect(rcCtrl);
  89. ScreenToClient(rcCtrl);
  90. int dtx = right - rcCtrl.right - 5;
  91. rcCtrl.top = 5;
  92. rcCtrl.bottom = rcCtrl.top + hei;
  93. rcCtrl.left += dtx;
  94. rcCtrl.right += dtx;
  95. GetDlgItem(IDOK)->MoveWindow(rcCtrl);
  96. //删除;
  97. GetDlgItem(IDC_BUTdel)->GetWindowRect(rcCtrl);
  98. ScreenToClient(rcCtrl);
  99. rcCtrl.top = 5;
  100. rcCtrl.bottom = rcCtrl.top + hei;
  101. rcCtrl.left += dtx;
  102. rcCtrl.right += dtx;
  103. GetDlgItem(IDC_BUTdel)->MoveWindow(rcCtrl);
  104. //全部删除;
  105. GetDlgItem(IDC_BUTdelall)->GetWindowRect(rcCtrl);
  106. ScreenToClient(rcCtrl);
  107. rcCtrl.top = 5;
  108. rcCtrl.bottom = rcCtrl.top + hei;
  109. rcCtrl.left += dtx;
  110. rcCtrl.right += dtx;
  111. GetDlgItem(IDC_BUTdelall)->MoveWindow(rcCtrl);
  112. CRect tmpRt(rcCtrl);
  113. GetDlgItem(IDC_BUTSetDesignNo)->GetWindowRect(rcCtrl);
  114. ScreenToClient(rcCtrl);
  115. rcCtrl.top = 5;
  116. rcCtrl.bottom = rcCtrl.top + hei;
  117. rcCtrl.left += dtx;
  118. rcCtrl.right += dtx;
  119. GetDlgItem(IDC_BUTSetDesignNo)->MoveWindow(rcCtrl);
  120. GetDlgItem(IDC_BUTexport)->GetWindowRect(rcCtrl);
  121. ScreenToClient(rcCtrl);
  122. rcCtrl.top = 5;
  123. rcCtrl.bottom = rcCtrl.top + hei;
  124. rcCtrl.left += dtx;
  125. rcCtrl.right += dtx;
  126. GetDlgItem(IDC_BUTexport)->MoveWindow(rcCtrl);
  127. //刷新按钮;
  128. CRect refeshRt(0, 0, 0, 0);
  129. GetDlgItem(IDC_BUT_RefreshPhotos)->GetWindowRect(refeshRt);
  130. //设计;
  131. if(m_mode == 5)
  132. tmpRt = rcCtrl;
  133. int nWide = refeshRt.right - refeshRt.left;
  134. tmpRt.left = tmpRt.left - nWide - 5;
  135. tmpRt.right = tmpRt.left + nWide;
  136. GetDlgItem(IDC_BUT_RefreshPhotos)->MoveWindow(tmpRt);
  137. //////////////////////////////////////////////////////////
  138. GetDlgItem(IDC_BUTupload)->GetWindowRect(rcCtrl);
  139. ScreenToClient(rcCtrl);
  140. rcCtrl.top = 5;
  141. rcCtrl.bottom = rcCtrl.top + hei;
  142. GetDlgItem(IDC_BUTupload)->MoveWindow(rcCtrl);
  143. GetDlgItem(IDC_BUTselall)->GetWindowRect(rcCtrl);
  144. ScreenToClient(rcCtrl);
  145. rcCtrl.top = 5;
  146. rcCtrl.bottom = rcCtrl.top + hei;
  147. GetDlgItem(IDC_BUTselall)->MoveWindow(rcCtrl);
  148. GetDlgItem(IDC_COMBO2)->GetWindowRect(rcCtrl);
  149. ScreenToClient(rcCtrl);
  150. rcCtrl.top = 5;
  151. rcCtrl.bottom = rcCtrl.top + hei + 300;
  152. GetDlgItem(IDC_COMBO2)->MoveWindow(rcCtrl);
  153. m_combobranch.ShowWindow(0);
  154. if (g_branchname == "")
  155. {
  156. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  157. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  158. }
  159. // else
  160. // GetDlgItem(IDC_BUTupload)->SetWindowText("上传至"+g_branchname);
  161. int i = 0;
  162. #ifdef ENTERPRISE_VERSION
  163. if (1)//g_branchname=="")
  164. {
  165. m_combobranch.ShowWindow(1);
  166. for ( i = 0; i < g_brancharray.GetSize() - 1; i++)
  167. {
  168. if (m_iparray.GetSize())
  169. {
  170. if (g_brancharray.ElementAt(i).ElementAt(2) == m_iparray.ElementAt(m_iparray.GetSize() - 1))continue;
  171. }
  172. m_combobranch.AddString(g_brancharray.ElementAt(i).ElementAt(0));
  173. m_iparray.Add(g_brancharray.ElementAt(i).ElementAt(2));
  174. }
  175. GetDlgItem(IDC_BUTupload)->ShowWindow(1);
  176. GetDlgItem(IDC_BUTselall)->ShowWindow(1);
  177. }
  178. #endif
  179. if (m_mode == 1 && IsHasRights2new(4) == 0)//拍照
  180. {
  181. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  182. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  183. }
  184. if (m_mode == 2 && IsHasRights2new(5) == 0)
  185. {
  186. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  187. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  188. }
  189. if (m_mode == 3 && IsHasRights2new(6) == 0)
  190. {
  191. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  192. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  193. }
  194. if (m_mode == 5 && IsHasRights2new(7) == 0)
  195. {
  196. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  197. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  198. }
  199. if (m_mode == 4)//礼服
  200. {
  201. GetDlgItem(IDC_BUTupload)->ShowWindow(0);
  202. GetDlgItem(IDC_BUTselall)->ShowWindow(0);
  203. }
  204. if (m_mode == 1)//拍照
  205. {
  206. GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(34));
  207. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(34));
  208. }
  209. else if (m_mode == 2)//初修
  210. {
  211. GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(35));
  212. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(35));
  213. }
  214. else if (m_mode == 3)//精修
  215. {
  216. GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(36));
  217. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(36));
  218. }
  219. else if (m_mode == 5)//设计
  220. {
  221. GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(37));
  222. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(37));
  223. GetDlgItem(IDC_BUTSetDesignNo)->EnableWindow(IsHasRights2new(7));
  224. GetDlgItem(IDC_BUTSetDesignNo)->ShowWindow(SW_SHOW);
  225. GetDlgItem(IDC_BUTexport)->EnableWindow(IsHasRights2new(12));
  226. GetDlgItem(IDC_BUTexport)->ShowWindow(SW_SHOW);
  227. }
  228. else if (m_mode == 4)//礼服
  229. {
  230. SetWindowText("礼服查看");
  231. GetDlgItem(IDC_BUTdelall)->EnableWindow(0);
  232. GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(43));
  233. m_combobranch.ShowWindow(1);
  234. g_sendhead.bsql = 0;
  235. g_sendhead.code[0] = 72;
  236. g_sendhead.tabcount = 1;
  237. g_pMainWnd->ProcessChatMessageRequest2(0);
  238. if (g_bSendOK == 0)
  239. {
  240. CDialog::OnCancel();
  241. return 0;
  242. }
  243. DataToArray(&m_List1array);
  244. CStringArray typearray;
  245. for ( i = 0; i < m_List1array.GetSize(); i++)
  246. {
  247. if (-1 == FindArray(&typearray, m_List1array.ElementAt(i).ElementAt(0)))
  248. typearray.Add(m_List1array.ElementAt(i).ElementAt(0));
  249. }
  250. m_combobranch.AddString("全部");
  251. for (i = 0; i < typearray.GetSize(); i++)
  252. {
  253. m_combobranch.AddString(typearray.ElementAt(i));
  254. }
  255. m_combobranch.SetCurSel(0);
  256. }
  257. //加载相片和文件夹icon;
  258. LoadImageFromRes(&m_pUnKnown, MAKEINTRESOURCE(PNG_UNKNOWN), _T("PNG"));
  259. if( m_pUnKnown == NULL )
  260. {
  261. MessageBox(_T("加载图标失败"));
  262. return FALSE;
  263. }
  264. m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  265. m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
  266. LoadPhotos();
  267. return TRUE; // return TRUE unless you set the focus to a control
  268. // EXCEPTION: OCX Property Pages should return FALSE
  269. }
  270. /************************************************************************/
  271. /* 函数:[6/1/2016 IT];
  272. /* 描述:;
  273. /* 参数:;
  274. /* [IN] :;
  275. /* [OUT] :;
  276. /* [IN/OUT] :;
  277. /* 返回:void;
  278. /* 注意:;
  279. /* 示例:;
  280. /*
  281. /* 修改:;
  282. /* 日期:;
  283. /* 内容:;
  284. /************************************************************************/
  285. CRect* ShowPic::SubgroubRectangle(IN CRect rc, IN const INT& nDivWidth, IN const INT &nDivisions)
  286. {
  287. if ( rc.IsRectEmpty() )
  288. return NULL;
  289. CRect *pRect = new CRect[nDivisions];
  290. INT nRealWidth = rc.Width() - nDivWidth*(nDivisions-1);
  291. INT nSumWidth = 0;
  292. for ( int i = 0; i < nDivisions; i++ )
  293. {
  294. pRect[i].top = rc.top;
  295. pRect[i].bottom = rc.bottom;
  296. pRect[i].left = nSumWidth;
  297. pRect[i].right = pRect[i].left + nRealWidth;
  298. nSumWidth += nRealWidth + nDivWidth;
  299. }
  300. return pRect;
  301. }
  302. /************************************************************************/
  303. /* 函数:AddListItemName[6/1/2016 IT];
  304. /* 描述:添加项名称到ListCtrl列表中;
  305. /* 参数:;
  306. /* [IN] pThis:;
  307. /* [IN] pListCtrl:;
  308. /* [IN] AryItemName:;
  309. /* 返回:void;
  310. /* 注意:;
  311. /* 示例:;
  312. /*
  313. /* 修改:;
  314. /* 日期:;
  315. /* 内容:;
  316. /************************************************************************/
  317. BOOL ShowPic::AddListItemName(IN ShowPic* pThis, IN CListCtrl* pListCtrl, IN IN CStringArray& AryItemName)
  318. {
  319. if ( pListCtrl == NULL || AryItemName.GetSize() == 0 )
  320. return FALSE;
  321. // 1.清除pListCtrl项;
  322. pListCtrl->DeleteAllItems();
  323. pListCtrl->Invalidate();
  324. // 2.逐个名字项添加;
  325. INT nPos = -1;
  326. // 插入名字时,不进行重绘,减少消耗;
  327. pListCtrl->SetRedraw(FALSE);
  328. for ( int i = 0; !pThis->m_bExit && i < AryItemName.GetSize(); i++ )
  329. {
  330. CString strImg = AryItemName.ElementAt(i);
  331. // 查找订单号;
  332. nPos = strImg.Find(pThis->m_id);
  333. if ( nPos != -1 )
  334. {
  335. // 留下订单号后面的内容(景点名);
  336. strImg = strImg.Mid(nPos + pThis->m_id.GetLength() + 1);
  337. nPos = strImg.ReverseFind(_T('.'));
  338. if ( nPos != -1 )
  339. strImg = strImg.Left(nPos);
  340. if ( !pThis->m_bOriginalImg )
  341. pListCtrl->InsertItem(i, strImg, i);
  342. else
  343. pListCtrl->InsertItem(i, strImg, 0);
  344. }
  345. }
  346. // 添加完成后,重绘列表;
  347. pListCtrl->SetRedraw(TRUE);
  348. return TRUE;
  349. }
  350. /************************************************************************/
  351. /* 函数:[6/1/2016 IT];
  352. /* 描述:;
  353. /* 参数:;
  354. /* [IN] :;
  355. /* [OUT] :;
  356. /* [IN/OUT] :;
  357. /* 返回:void;
  358. /* 注意:;
  359. /* 示例:;
  360. /*
  361. /* 修改:;
  362. /* 日期:;
  363. /* 内容:;
  364. /************************************************************************/
  365. void ShowPic::ZoomImage(Image* pImage, Rect& desRt)
  366. {
  367. int XDest(0), YDest(0), nDestWidth(0), nDestHeight(0);
  368. const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;
  369. const float fImgRatio = (float)pImage->GetHeight() / pImage->GetWidth();
  370. if (fImgRatio > fRatio)
  371. {
  372. nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
  373. XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
  374. YDest = 0;
  375. nDestHeight = THUMBNAIL_HEIGHT;
  376. }
  377. else
  378. {
  379. XDest = 0;
  380. nDestWidth = THUMBNAIL_WIDTH;
  381. nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
  382. YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
  383. }
  384. desRt.X = XDest;
  385. desRt.Y = YDest;
  386. desRt.Width = nDestWidth;
  387. desRt.Height = nDestHeight;
  388. }
  389. /************************************************************************/
  390. /* 函数:DrawListItemImg[6/1/2016 IT];
  391. /* 描述:;
  392. /* 参数:;
  393. /* [IN] :;
  394. /* [OUT] :;
  395. /* [IN/OUT] :;
  396. /* 返回:void;
  397. /* 注意:如果没有生成小图,加载大图时,会造成函数用时超长,从而导致线程结束不及时,List也可能被释放;
  398. /* 示例:;
  399. /*
  400. /* 修改:;
  401. /* 日期:;
  402. /* 内容:;
  403. /************************************************************************/
  404. void ShowPic::DrawListItemImg(IN ShowPic* pThis, IN CListCtrl* pListCtrl, IN CImageList* pImgList, IN CStringArray& AryItemName)
  405. {
  406. if ( pListCtrl == NULL || pImgList == NULL || AryItemName.GetSize() == 0)
  407. return;
  408. Bitmap *pBitmap = NULL;
  409. // 1.是否是原始格式的相片;
  410. if ( pThis->m_bOriginalImg )
  411. {
  412. // 创建bitmap使用白颜色填充区域;
  413. SolidBrush whitebrush(Color(255, 255, 255, 255));
  414. pBitmap = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
  415. Graphics graph(pBitmap);
  416. graph.Clear(Color(255, 192, 192, 192));
  417. graph.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH -2 , THUMBNAIL_HEIGHT -2);
  418. graph.Save();
  419. // 缩放图片以符合画布大小;
  420. if ( pThis->m_pUnKnown == NULL )
  421. LoadImageFromRes(&pThis->m_pUnKnown, MAKEINTRESOURCE(PNG_UNKNOWN), _T("PNG"));
  422. Rect desrc(0,0,0,0);
  423. ZoomImage(pThis->m_pUnKnown, desrc);
  424. // 绘制图标res\unknown.png;
  425. Graphics graph2(pBitmap);
  426. graph2.DrawImage(pThis->m_pUnKnown, desrc, 0, 0, pThis->m_pUnKnown->GetWidth(), pThis->m_pUnKnown->GetHeight(), UnitPixel);
  427. // 将图片替换bitmap添加到图标列表;
  428. CBitmap bitmap;
  429. HBITMAP hbmp;
  430. pBitmap->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
  431. bitmap.Attach(hbmp);
  432. for ( int i = 0; !pThis->m_bExit && i < AryItemName.GetSize(); i++ )
  433. {
  434. AutoThreadSection aSection(&m_ThreadSection);
  435. if (!pThis->m_bExit /*&& ::IsWindow(pListCtrl->m_hWnd)*/)
  436. {
  437. pImgList->Replace(i, &bitmap, NULL);
  438. pListCtrl->RedrawItems(i, i);
  439. }
  440. }
  441. if ( pBitmap )
  442. delete pBitmap;
  443. pBitmap = NULL;
  444. }
  445. else
  446. {
  447. INT nPos = -1;
  448. Image* pImage = NULL;
  449. for ( int i = 0; !pThis->m_bExit && i < AryItemName.GetSize(); i++ )
  450. {
  451. pImage = NULL;
  452. pBitmap = NULL;
  453. CString strImg = AryItemName.ElementAt(i);
  454. nPos = strImg.ReverseFind(_T('\\'));
  455. if ( nPos != -1 )
  456. {
  457. CString strSmallImg = strImg.Left( nPos + 1);
  458. strSmallImg += _T("s");
  459. strSmallImg += strImg.Mid(nPos+1);
  460. // 小图存在时;
  461. if ( PathFileExists(strSmallImg) )
  462. {
  463. LoadImageFromBuf(&pImage, strSmallImg);
  464. }
  465. else
  466. {// 无小图,加载大图;
  467. strImg.MakeLower();
  468. if (strImg.Right(3) != _T("jpg") && strImg.Right(4) != _T("jpeg"))
  469. continue;
  470. LoadImageFromBuf(&pImage, strImg);
  471. }
  472. if ( pImage == NULL )
  473. continue;
  474. // 旋转侧拍的相片;
  475. int nOrientation = GetOrientation(pImage);
  476. if (nOrientation == 8)
  477. pImage->RotateFlip(Rotate270FlipNone);
  478. else if (nOrientation == 6)
  479. pImage->RotateFlip(Rotate90FlipNone);
  480. if (pImage->GetWidth() == 0)
  481. {
  482. delete pImage;
  483. continue;
  484. }
  485. // 创建bitmap使用白颜色填充区域;
  486. SolidBrush whitebrush(Color(255, 255, 255, 255));
  487. pBitmap = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
  488. Graphics graph(pBitmap);
  489. graph.Clear(Color(255, 192, 192, 192));
  490. graph.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH -2 , THUMBNAIL_HEIGHT -2);
  491. graph.Save();
  492. // 缩放图片以符合画布大小;
  493. Rect desrc(0,0,0,0);
  494. ZoomImage(pImage, desrc);
  495. // 绘制图标;
  496. Graphics graph2(pBitmap);
  497. graph2.DrawImage(pImage, desrc, 0, 0, pImage->GetWidth(), pImage->GetHeight(), UnitPixel);
  498. if ( pImage )
  499. delete pImage;
  500. pImage = NULL;
  501. // 将图片替换bitmap添加到图标列表;
  502. CBitmap bitmap;
  503. HBITMAP hbmp;
  504. pBitmap->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
  505. bitmap.Attach(hbmp);
  506. if ( pBitmap )
  507. delete pBitmap;
  508. pBitmap = NULL;
  509. AutoThreadSection aSection(&m_ThreadSection);
  510. if (!pThis->m_bExit /*&& ::IsWindow(pListCtrl->m_hWnd)*/)
  511. {
  512. pImgList->Replace(i, &bitmap, NULL);
  513. pListCtrl->RedrawItems(i, i);
  514. }
  515. }
  516. }
  517. }
  518. #ifdef _DEBUG
  519. TRACE("退出DrawListItemImg\n");
  520. #endif
  521. }
  522. DWORD ShowPic::LoadThumbNail(LPVOID lpParam)
  523. {
  524. try
  525. {
  526. ShowPic *pDlg = (ShowPic*)lpParam;
  527. CListCtrl *ListCtrl = &pDlg->m_List1;
  528. CImageList* pImgList = &pDlg->m_ImageListThumb;
  529. for (int i = 0; !pDlg->m_bExit && i < pImgList->GetImageCount(); i++)
  530. pImgList->Remove(i);
  531. ListCtrl->DeleteAllItems();
  532. pImgList->SetImageCount(pDlg->m_vFileName.GetSize());
  533. if ( pDlg->m_bExit )
  534. {
  535. pDlg->m_bRunning = false;
  536. pDlg->m_bExit = false;
  537. return 0;
  538. }
  539. ListCtrl->Invalidate();
  540. AddListItemName(pDlg, ListCtrl, pDlg->m_vFileName);
  541. DrawListItemImg(pDlg, ListCtrl, pImgList, pDlg->m_vFileName);
  542. if (!pDlg->m_bExit)
  543. ListCtrl->Invalidate();
  544. pDlg->m_bRunning = false;
  545. pDlg->m_bExit = false;
  546. return 0;
  547. }
  548. catch (...)
  549. {
  550. }
  551. return 0;
  552. }
  553. /************************************************************************/
  554. /*
  555. 函数:TerminateRefreshTh
  556. 描述:结束刷新图片线程
  557. 参数:
  558. 返回:
  559. */
  560. /************************************************************************/
  561. BOOL ShowPic::TerminateRefreshTh()
  562. {
  563. //设为有信号
  564. if(m_hRefExitEvent)
  565. SetEvent(m_hRefExitEvent);
  566. //等待线程结束
  567. if(m_hThreadRef)
  568. WaitForSingleObject(m_hThreadRef, INFINITE);
  569. if(m_hRefExitEvent)
  570. {
  571. ::CloseHandle(m_hRefExitEvent);
  572. m_hRefExitEvent = NULL;
  573. }
  574. if(m_hThreadRef)
  575. {
  576. ::CloseHandle(m_hThreadRef);
  577. m_hThreadRef = NULL;
  578. }
  579. return TRUE;
  580. }
  581. /************************************************************************/
  582. /*
  583. 函数:RefreshThFun
  584. 描述:刷新
  585. 参数:
  586. 返回:
  587. */
  588. /************************************************************************/
  589. void ShowPic::RefreshWork()
  590. {
  591. BOOL bFinish = TRUE;
  592. for(int i=0; i<m_patharray1.GetSize(); i++)
  593. {
  594. // 等待退出信号;
  595. if(m_hRefExitEvent && WaitForSingleObject(m_hRefExitEvent, 0) == WAIT_OBJECT_0)
  596. {
  597. bFinish = FALSE;
  598. break;
  599. }
  600. CString str = m_patharray1.ElementAt(i);
  601. CString spath = str.Left(str.ReverseFind('\\') + 1);
  602. spath += "s";
  603. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  604. if(!::PathFileExists(spath))
  605. ImgThumbnail(m_patharray1.ElementAt(i), SET_PIX(100, 76), spath, 100);
  606. spath = str.Left(str.ReverseFind('\\') + 1);
  607. spath += "m";
  608. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  609. if(!::PathFileExists(spath))
  610. ImgThumbnail(m_patharray1.ElementAt(i), SET_PIX(2000, 1500), spath, 100);
  611. }
  612. if(bFinish)
  613. {
  614. MessageBox(_T("刷新完成"));
  615. LoadThumbImages();
  616. }
  617. }
  618. /************************************************************************/
  619. /*
  620. 函数:RefreshThFun
  621. 描述:线程函数
  622. 参数:
  623. 返回:
  624. */
  625. /************************************************************************/
  626. unsigned __stdcall RefreshThFun(LPVOID lpParam)
  627. {
  628. ShowPic* p = (ShowPic*)lpParam;
  629. try
  630. {
  631. p->RefreshWork();
  632. return 0;
  633. }
  634. catch (CException* e)
  635. {
  636. return 0;
  637. }
  638. }
  639. void ShowPic::LoadThumbImages()
  640. {
  641. ExitLoadThread();
  642. m_hThread = CreateThread(NULL, 0, LoadThumbNail, this, 0, NULL);
  643. if( m_hThread )
  644. {
  645. m_bRunning = true;
  646. }
  647. }
  648. BOOL ShowPic::ExitLoadThread()
  649. {
  650. if ( m_bRunning ) m_bExit = true;
  651. if ( m_hThread )
  652. {
  653. while( WaitForSingleObject(m_hThread,0) == WAIT_OBJECT_0 )
  654. //while(GetExitCodeThread(m_hThread, 0))
  655. {
  656. Sleep(100); // 由于该线程内容调用到各种主线程的窗口事件,所以不能死等,必须Sleep以保持主窗口线程鲜活;
  657. break;
  658. #ifdef _DEBUG
  659. TRACE("线程已完成\n");
  660. #endif
  661. }
  662. CloseHandle(m_hThread);
  663. m_hThread = NULL;
  664. }
  665. #ifdef _DEBUG
  666. TRACE("\n退出显示线程\n");
  667. #endif
  668. return TRUE;
  669. }
  670. void ShowPic::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
  671. {
  672. if ( m_bOriginalImg )
  673. {
  674. MessageBox(_T("不支持查看原始格式相片!"), _T("温馨提示!"), MB_OK|MB_ICONHAND);
  675. return;
  676. }
  677. POSITION pos;
  678. pos = m_List1.GetFirstSelectedItemPosition();
  679. if (pos == NULL)
  680. {
  681. return;
  682. }
  683. int iItem = m_List1.GetNextSelectedItem(pos);
  684. ShowPic22 dlg;
  685. dlg.m_nCurImgPos = iItem;
  686. dlg.m_pAryImgPath = &m_patharray1;
  687. dlg.DoModal();
  688. *pResult = 0;
  689. }
  690. /*
  691. 事件执行顺序:WM_CLOSE ->WM_SYSCOMMAND ->WM_COMMAND(IDCANCEL)->WS_DESTROY->WM_NCDESTROY
  692. 所以,不在能DESTROY里退出,因为List已经被释放了;
  693. void ShowPic::OnDestroy()
  694. {
  695. m_bExit = true;
  696. #ifdef _DEBUG
  697. TRACE("退出窗口\n");
  698. #endif
  699. ExitLoadThread();
  700. TerminateRefreshTh();
  701. CDialog::OnDestroy();
  702. }
  703. */
  704. void ShowPic::LoadPhotos() // 从订单目录中加载相片;
  705. {
  706. #ifdef USE_KERNEL_DLL
  707. if ( m_mode == 4 )
  708. {// 礼服;
  709. CString str = _T("");
  710. CString savepath = g_path5 + _T("\\");
  711. int i = 0;
  712. for ( i = 0; i < m_List1array.GetSize(); i++)
  713. {
  714. if (m_type != _T("") && m_type != _T("全部") && m_type != m_List1array.ElementAt(i).ElementAt(0))
  715. continue;
  716. OutputDebugString(m_List1array.ElementAt(i).ElementAt(1) + _T("\n"));
  717. CString str = savepath + m_List1array.ElementAt(i).ElementAt(1) + _T(".jpg");
  718. if ( PathFileExists(str) )
  719. m_patharray1.Add(str);
  720. }
  721. if (m_bRunning)return;
  722. CStringArray *pArray = &m_patharray1;
  723. m_vFileName.RemoveAll();
  724. for ( i = 0; i < pArray->GetSize(); i++)
  725. {
  726. CString filePath = pArray->ElementAt(i);
  727. filePath.MakeLower();
  728. m_vFileName.Add(filePath);
  729. }
  730. LoadThumbImages();
  731. return;
  732. }
  733. // 非礼服,原片、初修片、精修片、设计片;
  734. INT nImgType = m_mode;
  735. if ( m_mode == 5)
  736. nImgType--;
  737. CStringArray AryLoadExtImgpath;
  738. CStringArray AryWithExtImgpath;
  739. CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname);
  740. if ( GetOrderImgpathEx(nImgType, strBranchId, m_id, TRUE, _T("*.jpg|*.jpeg"), _T("*.cr2|*.raw|*.nef|*.ra2"), AryLoadExtImgpath, AryWithExtImgpath, m_aryOfShareDirectory))
  741. {
  742. INT i = 0;
  743. CString str;
  744. m_patharray1.RemoveAll();
  745. CString strfilename;
  746. INT nSize = AryLoadExtImgpath.GetSize();
  747. if ( nSize == 0 && AryWithExtImgpath.GetSize() )
  748. { // 没有jpg可显示的相片,但有原始格式的相片;
  749. m_bOriginalImg = TRUE;
  750. nSize = AryWithExtImgpath.GetSize();
  751. for (i = 0; i < nSize; i++ )
  752. {
  753. str = AryWithExtImgpath.ElementAt(i);
  754. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  755. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  756. str.MakeLower();
  757. if (!g_bOriginal && m_mode == 1) // 拍照;
  758. {
  759. strfilename = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  760. if (strfilename.ReverseFind(_T('.')) != -1)
  761. strfilename = strfilename.Left(strfilename.ReverseFind(_T('.')));
  762. // 若只是用于系统数字编号的,可以使用Isdigit来判断相片编号是否为数字编号;
  763. if ( !myisdigit(strfilename) )
  764. continue;
  765. }
  766. m_patharray1.Add(str);
  767. }
  768. }
  769. else
  770. {
  771. m_bOriginalImg = FALSE;
  772. for (i = 0; i < nSize; i++ )
  773. {
  774. str = AryLoadExtImgpath.ElementAt(i);
  775. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  776. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  777. str.MakeLower();
  778. if (!g_bOriginal && m_mode == 1) // 拍照;
  779. {
  780. strfilename = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  781. if (strfilename.ReverseFind(_T('.')) != -1)
  782. strfilename = strfilename.Left(strfilename.ReverseFind(_T('.')));
  783. // 若只是用于系统数字编号的,可以使用Isdigit来判断相片编号是否为数字编号;
  784. if ( !myisdigit(strfilename) )
  785. continue;
  786. }
  787. m_patharray1.Add(str);
  788. }
  789. }
  790. if (m_bRunning)return;
  791. CStringArray *pArray = &m_patharray1;
  792. m_vFileName.RemoveAll();
  793. for ( i = 0; i < pArray->GetSize(); i++)
  794. {
  795. CString filePath = pArray->ElementAt(i);
  796. filePath.MakeLower();
  797. m_vFileName.Add(filePath);
  798. }
  799. LoadThumbImages();
  800. }
  801. else
  802. {
  803. // 如果没有找到目录,则清空所有list项目;
  804. for (int i = 0; i < m_ImageListThumb.GetImageCount(); i++)
  805. m_ImageListThumb.Remove(i);
  806. m_List1.DeleteAllItems();
  807. }
  808. if ( m_mode == 1)
  809. {
  810. CString strText ;
  811. strText.Format(_T("客户照片查看,当前张数:%ld"), m_vFileName.GetSize());
  812. SetWindowText(strText);
  813. }
  814. #else
  815. m_patharray1.RemoveAll();
  816. m_path.MakeLower();
  817. CStringArray dirarray;
  818. CString str;
  819. if (m_mode == 4)//礼服
  820. {
  821. CString savepath = g_path5 + "\\";
  822. for (int i = 0; i < m_List1array.GetSize(); i++)
  823. {
  824. if (m_type != "" && m_type != "全部" && m_type != m_List1array.ElementAt(i).ElementAt(0))
  825. continue;
  826. // str=savepath+"s"+m_List1array.ElementAt (i).ElementAt (1)+".jpg";
  827. str = savepath + m_List1array.ElementAt(i).ElementAt(1) + ".jpg";
  828. if (::PathFileExists(str))
  829. m_patharray1.Add(str);
  830. }
  831. }
  832. else
  833. {
  834. #if USE_SHARE_FLORD // 多级共享目录查看相片;
  835. int nPhotoType = m_mode;
  836. if ( m_mode == 5)
  837. nPhotoType--;
  838. // 根据域名,相片类型,订单号查找相片;
  839. //LoadPhotos(nPhotoType, m_id, m_branch);
  840. m_aryOfShareDirectory.RemoveAll();
  841. CNetShareInfo::GetInstance()->LoadOrderImages(nPhotoType, m_id, m_branch, m_patharray1, &m_aryOfShareDirectory);
  842. #else
  843. if (1)
  844. {
  845. using namespace helper_coffs;
  846. ffsco o;
  847. o.dirs(1);
  848. o.find(LPCSTR(m_path), LPCSTR("*.*"));
  849. ffsco::typeT coo;
  850. ffsco::typeT::iterator it;
  851. // 1.获得所有子文件夹;
  852. coo = o.co_dir();
  853. for (it = coo.begin();coo.end() != it;it++)
  854. {
  855. str = (*it).c_str();
  856. if (FindArray(&dirarray, str) == -1)
  857. {
  858. dirarray.Add(str);
  859. }
  860. }
  861. }
  862. if (1)
  863. {
  864. CString filename;
  865. for (int i = 0; i < dirarray.GetSize(); i++)
  866. {
  867. using namespace helper_coffs;
  868. ffsco o;
  869. o.dirs(0);
  870. if (m_mode == 1)//拍照
  871. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.*"));
  872. else
  873. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  874. ffsco::typeT coo;
  875. ffsco::typeT::iterator it;
  876. // 2.获得所有子文件夹下的文件;
  877. coo = o.co_file();
  878. for (it = coo.begin();coo.end() != it;it++)
  879. {
  880. str = (*it).c_str();
  881. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  882. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  883. str.MakeLower();
  884. if (m_mode == 1)//拍照
  885. {
  886. filename = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  887. if (filename.Find(".") != -1)
  888. filename = filename.Left(filename.Find("."));
  889. if (!myisdigit(filename))continue;
  890. }
  891. m_patharray1.Add(str);
  892. }
  893. }
  894. }
  895. #endif
  896. }
  897. if (m_bRunning)return;
  898. CStringArray *pArray = &m_patharray1;
  899. m_vFileName.clear();
  900. for (int i = 0; i < pArray->GetSize(); i++)
  901. {
  902. CString filePath = pArray->ElementAt(i);
  903. filePath.MakeLower();
  904. m_vFileName.push_back(filePath);
  905. }
  906. LoadThumbImages();
  907. #endif
  908. }
  909. void ShowPic::OnBUTdelall() // 全部删除按钮;
  910. {
  911. // TODO: Add your control notification handler code here
  912. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  913. #if USE_SHARE_FLORD // 2015.04.13
  914. // 删除多级共享目录下的全部订单相片;
  915. int nSize = m_aryOfShareDirectory.GetSize();
  916. for ( int i = 0; i < nSize; i++)
  917. {
  918. DeleteDirectory(m_aryOfShareDirectory.ElementAt(i));
  919. }
  920. LoadPhotos();
  921. #else
  922. CString path = m_path;
  923. path.TrimRight('\\');
  924. DeleteDirectory(path); // 递归删除全部查看的jpg:
  925. LoadPhotos();
  926. #endif
  927. if (m_mode == 1)
  928. {
  929. CString sql;
  930. sql = "update dindan set [curno]='1' where [id]='" + m_id + "'";
  931. g_sendhead.bsql = 1;
  932. g_pMainWnd->ProcessChatMessageRequest2(sql);
  933. m_bdelall = 1;
  934. }
  935. #if 1
  936. CString str;
  937. str = "清除";
  938. str += m_name;
  939. str += m_id;
  940. str += "全部";//Jeff.add;
  941. if (m_mode == 1)
  942. str += "原片";
  943. else if (m_mode == 2)
  944. str += "初修片";
  945. else if (m_mode == 3)
  946. str += "精修片";
  947. else if (m_mode == 5)
  948. str += "设计片";
  949. WriteLog("清除订单相片", str);
  950. #endif
  951. if (g_branchname != "")
  952. {
  953. str.Format("是否同步删除分店 %s 的照片?", g_branchname);
  954. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  955. CString sql = "deletephotos";
  956. if (m_mode == 1)//拍照
  957. sql += "0";
  958. else if (m_mode == 2)//初修
  959. sql += "1";
  960. else if (m_mode == 3)//精修
  961. sql += "2";
  962. else if (m_mode == 5)//设计
  963. sql += "3";
  964. sql += m_id;
  965. sql += ";";
  966. CString jd;
  967. if (m_mode == 1)
  968. { //拍照,加景点
  969. CString file2 = m_path;
  970. int pos = file2.Find(m_id);
  971. pos += m_id.GetLength();
  972. int pos2 = file2.ReverseFind('\\');
  973. if (pos2 > pos)
  974. {
  975. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  976. }
  977. }
  978. sql += "all";
  979. sql += jd;
  980. g_sendhead.bsql = 1;
  981. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  982. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  983. #if 1//Jeff add;
  984. CString strDelContent;
  985. if (m_mode == 1)
  986. str += "原片";
  987. else if (m_mode == 2)
  988. str += "初修片";
  989. else if (m_mode == 3)
  990. str += "精修片";
  991. else if (m_mode == 5)
  992. str += "设计片";
  993. strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
  994. WriteLog("删除分店照片", strDelContent);
  995. #endif
  996. }
  997. else if (m_branch != "")
  998. {
  999. if (GetBranchPhotoPath(m_branch) == "")return;
  1000. str.Format("是否同步删除分店 %s 的照片?", m_branch);
  1001. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  1002. CString sql = "deletephotos";
  1003. if (m_mode == 1)//拍照
  1004. sql += "0";
  1005. else if (m_mode == 2)//初修
  1006. sql += "1";
  1007. else if (m_mode == 3)//精修
  1008. sql += "2";
  1009. else if (m_mode == 5)//设计
  1010. sql += "3";
  1011. sql += m_id;
  1012. sql += ";";
  1013. CString jd;
  1014. if (m_mode == 1)
  1015. { //拍照,加景点
  1016. CString file2 = m_path;
  1017. int pos = file2.Find(m_id);
  1018. pos += m_id.GetLength();
  1019. int pos2 = file2.ReverseFind('\\');
  1020. if (pos2 > pos)
  1021. {
  1022. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  1023. }
  1024. }
  1025. sql += "all";
  1026. sql += jd;
  1027. g_sendhead.bsql = 1;
  1028. g_branchip = GetIP(m_branch);
  1029. g_pMainWnd->OnDisconnect();
  1030. g_branchname = m_branch;
  1031. g_bBranchModify = 1;
  1032. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1033. g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
  1034. if (g_bSendOK == 0)return;
  1035. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  1036. #if 1//Jeff add;
  1037. CString strDelContent;
  1038. if (m_mode == 1)
  1039. str += "原片";
  1040. else if (m_mode == 2)
  1041. str += "初修片";
  1042. else if (m_mode == 3)
  1043. str += "精修片";
  1044. else if (m_mode == 5)
  1045. str += "设计片";
  1046. strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
  1047. WriteLog("删除分店照片", strDelContent);
  1048. #endif
  1049. }
  1050. }
  1051. void ShowPic::OnBUTdel() // 删除按钮;
  1052. {
  1053. #if USE_SHARE_FLORD
  1054. // 获取list列表中选中的相片集合;
  1055. CStringArray delarray;
  1056. GetAllSelectImage(delarray);
  1057. int nPhotoType = m_mode;
  1058. if ( m_mode == 5)
  1059. {
  1060. nPhotoType--;
  1061. }
  1062. CString strDomain;
  1063. CStringArray strAryOfDeleted;
  1064. if ( !m_branch.IsEmpty() )
  1065. {
  1066. strDomain = GetDomainFromBranch(m_branch);
  1067. }
  1068. else
  1069. {
  1070. strDomain = g_branchname;
  1071. }
  1072. int i = 0;
  1073. for(i = 0; i<delarray.GetSize(); i++)
  1074. {
  1075. for ( int nIndex = 0; nIndex < m_vFileName.GetSize(); nIndex++)
  1076. {
  1077. CString str = m_vFileName.ElementAt(nIndex);
  1078. if(str != _T(""))
  1079. {
  1080. CString strdel = delarray.ElementAt(i);
  1081. // 如果是精修片目录里,会有多个子文件夹,而且每个子文件夹都可能会有相同名称的相片;
  1082. if ( strdel.Find(_T("\\")) != -1)
  1083. {// 子文件夹;
  1084. if ( str.Find(strdel) != -1 )
  1085. {
  1086. strAryOfDeleted.Add(m_vFileName.ElementAt(nIndex));
  1087. }
  1088. }
  1089. else
  1090. {// 根目录,从订单号截断;
  1091. if ( str.Find(m_id) != -1 )
  1092. {
  1093. str = str.Mid(str.Find(m_id) + m_id.GetLength() + 1);
  1094. if ( str.Find(_T("\\")) == -1 )
  1095. {// 排除掉子目录;
  1096. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  1097. str = str.Left(str.Find(_T(".")));
  1098. if(str.CompareNoCase(strdel) == 0)
  1099. strAryOfDeleted.Add(m_vFileName.ElementAt(nIndex));
  1100. }
  1101. }
  1102. }
  1103. }
  1104. }
  1105. }
  1106. int nDelCount = strAryOfDeleted.GetSize();
  1107. //////////////////////////////////////////////////////////////////////////
  1108. // 删除已找到的相片文件;
  1109. CString strTemp;
  1110. for ( int n = 0; n < nDelCount; n++)
  1111. {
  1112. // 删除原相片;
  1113. strTemp = strAryOfDeleted.ElementAt(n);
  1114. DeleteFile(strTemp);
  1115. strTemp.MakeLower();
  1116. strTemp.Replace(_T(".jpg"),_T(".nef"));
  1117. DeleteFile(strTemp);
  1118. strTemp.Replace(_T(".nef"),_T(".cr2"));
  1119. DeleteFile(strTemp);
  1120. strTemp.Replace(_T(".cr2"),_T(".raw"));
  1121. DeleteFile(strTemp);
  1122. strTemp.Replace(_T(".raw"),_T(".jpg"));
  1123. // 再删除s+m缩略图;
  1124. CString strAblum;
  1125. CString strLeft, strRight;
  1126. int nIndex = strTemp.ReverseFind('\\');
  1127. strLeft = strTemp.Left( nIndex + 1 );
  1128. strRight = strTemp.Mid( nIndex + 1);
  1129. strAblum.Format("%ss%s",strLeft,strRight);
  1130. DeleteFile(strAblum);
  1131. strAblum.Format("%sm%s",strLeft,strRight);
  1132. DeleteFile(strAblum);
  1133. // 若是原片,则要删除原片目录下的上传任务;
  1134. if ( m_mode == 1 && !g_branchname.IsEmpty() )
  1135. {
  1136. // 暂时空处理,此处逻辑未明确;
  1137. }
  1138. }
  1139. // 重新加载相片;
  1140. LoadPhotos();
  1141. // 写删除日志;
  1142. switch( m_mode )
  1143. {
  1144. case 1:
  1145. strTemp.Format("删除<%s>订单<%s>的原片%d张",m_name,m_id,nDelCount);
  1146. break;
  1147. case 2:
  1148. strTemp.Format("删除<%s>订单<%s>的初修片%d张",m_name,m_id,nDelCount);
  1149. break;
  1150. case 3:
  1151. strTemp.Format("删除<%s>订单<%s>的精修片%d张",m_name,m_id,nDelCount);
  1152. break;
  1153. case 5:
  1154. strTemp.Format("删除<%s>订单<%s>的设计片%d张",m_name,m_id,nDelCount);
  1155. break;
  1156. default:
  1157. break;
  1158. }
  1159. WriteLog("删除订单相片", strTemp);
  1160. // 当连接分店时,除了删除本店的相片外,还要删除外网分店的相片;
  1161. if ( !g_branchname.IsEmpty() && strAryOfDeleted.GetSize() )
  1162. {
  1163. strTemp.Format("是否同步删除分店 %s 的照片?", g_branchname);
  1164. if( AfxMessageBox(strTemp, MB_YESNO|MB_ICONSTOP) != IDYES )
  1165. return;
  1166. strTemp = "deletephotos";
  1167. if( m_mode == 1 )
  1168. strTemp += "0";
  1169. else if( m_mode == 2 )
  1170. strTemp += "1";
  1171. else if( m_mode == 3 )
  1172. strTemp += "2";
  1173. else if( m_mode == 5 )
  1174. strTemp += "3";
  1175. strTemp += m_id;
  1176. strTemp += ":";
  1177. for(int i = 0; i < delarray.GetSize(); i++)
  1178. {
  1179. strTemp += delarray.ElementAt(i);
  1180. strTemp += ",";
  1181. }
  1182. g_sendhead.bsql = 1;
  1183. g_pMainWnd->ProcessChatMessageRequest2(strTemp);
  1184. if( g_bSendOK == 0 )
  1185. return;
  1186. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  1187. // 日志记录;
  1188. if(m_mode==1)
  1189. strTemp.Format("<%s>订单<%s>分店<%s>的原片被同步删除",m_name, m_id, g_branchname);
  1190. else if(m_mode==2)
  1191. strTemp.Format("<%s>订单<%s>分店<%s>的初修片被同步删除",m_name, m_id, g_branchname);
  1192. else if(m_mode==3)
  1193. strTemp.Format("<%s>订单<%s>分店<%s>的精修片被同步删除",m_name, m_id, g_branchname);
  1194. else if(m_mode==5)
  1195. strTemp.Format("<%s>订单<%s>分店<%s>的设计片被同步删除",m_name, m_id, g_branchname);
  1196. WriteLog("分店相片同步删除", strTemp);
  1197. }
  1198. // 当多店汇总时,通过分店名得到分店域名,再删除分店的相片;
  1199. if ( !m_branch.IsEmpty() && strAryOfDeleted.GetSize() )
  1200. {
  1201. if ( strDomain.IsEmpty() )
  1202. return;
  1203. strTemp.Format( "是否同步删除分店 %s 的照片?", m_branch );
  1204. if( AfxMessageBox(strTemp, MB_YESNO|MB_ICONSTOP) != IDYES )
  1205. return;
  1206. strTemp = "deletephotos";
  1207. if( m_mode == 1 )
  1208. strTemp += "0";
  1209. else if( m_mode == 2 )
  1210. strTemp += "1";
  1211. else if( m_mode == 3 )
  1212. strTemp += "2";
  1213. else if( m_mode == 5 )
  1214. strTemp += "3";
  1215. strTemp += m_id;
  1216. strTemp += ":";
  1217. for(int i = 0; i < delarray.GetSize(); i++)
  1218. {
  1219. strTemp += delarray.ElementAt(i);
  1220. strTemp += ",";
  1221. }
  1222. g_sendhead.bsql = 1;
  1223. g_pMainWnd->ProcessChatMessageRequest2(strTemp);
  1224. if( g_bSendOK == 0 )
  1225. return;
  1226. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  1227. // 日志记录;
  1228. if(m_mode==1)
  1229. strTemp.Format("<%s>订单<%s>分店<%s>的原片被同步删除",m_name, m_id, g_branchname);
  1230. else if(m_mode==2)
  1231. strTemp.Format("<%s>订单<%s>分店<%s>的初修片被同步删除",m_name, m_id, g_branchname);
  1232. else if(m_mode==3)
  1233. strTemp.Format("<%s>订单<%s>分店<%s>的精修片被同步删除",m_name, m_id, g_branchname);
  1234. else if(m_mode==5)
  1235. strTemp.Format("<%s>订单<%s>分店<%s>的设计片被同步删除",m_name, m_id, g_branchname);
  1236. WriteLog("分店相片同步删除", strTemp);
  1237. }
  1238. // 直接返回,不执行旧过程;
  1239. return ;
  1240. #else
  1241. // TODO: Add your control notification handler code here
  1242. POSITION pos;
  1243. pos = m_List1.GetFirstSelectedItemPosition();
  1244. if (pos == NULL)
  1245. {
  1246. AfxMessageBox("请先选中您要删除的照片!", MB_ICONINFORMATION);
  1247. return;
  1248. }
  1249. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  1250. CStringArray delarray;
  1251. //int nDelCount = 0; // Jeff add:被删除的相片数量;// 使用m_nDelCount成员变量;
  1252. CString strDelContent; // Jeff add:删除操作的日志内容;
  1253. //CStringArray strDelArray; // Jeff add:被删除的相片名称;
  1254. while (pos)
  1255. {
  1256. int iItem = m_List1.GetNextSelectedItem(pos);
  1257. CString title = m_List1.GetItemText(iItem, 0);
  1258. // log的内容字段长度有限,写不下这么多文字;
  1259. // 被删除的文件名不记录,只记录删除的张数;
  1260. ::DeleteFile(m_path + title + ".jpg"); // 删除jpg;
  1261. ::DeleteFile(m_path + title + ".NEF"); // 删除NEF;
  1262. ::DeleteFile(m_path + title + ".CR2"); // 删除CR2;
  1263. ::DeleteFile(m_path + title + ".raw"); // 删除raw;
  1264. m_nDelCount++;
  1265. int pos = title.ReverseFind('\\');
  1266. if (pos != -1)
  1267. {
  1268. ::DeleteFile(m_path + title.Left(pos + 1) + "s" + title.Right(title.GetLength() - pos - 1) + ".jpg"); // 删除s小图;
  1269. ::DeleteFile(m_path + title.Left(pos + 1) + "m" + title.Right(title.GetLength() - pos - 1) + ".jpg"); // 删除m小图;
  1270. }
  1271. else
  1272. {
  1273. ::DeleteFile(m_path + "s" + title + ".jpg"); // 删除s小图
  1274. ::DeleteFile(m_path + "m" + title + ".jpg"); // 删除m小图;
  1275. }
  1276. if (m_mode == 1 && g_branchname != "")
  1277. { //拍照,加景点
  1278. CString file2 = m_path + title;
  1279. int pos = file2.Find(m_id);
  1280. pos += m_id.GetLength();
  1281. int pos2 = file2.ReverseFind('\\');
  1282. CString jd;
  1283. if (pos2 > pos)
  1284. {
  1285. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  1286. }
  1287. CString task;
  1288. if (jd != "")
  1289. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  1290. else
  1291. task = file2.Right(file2.GetLength() - pos2 - 1);
  1292. delarray.Add(task);
  1293. }
  1294. else
  1295. {
  1296. delarray.Add(title);
  1297. }
  1298. }
  1299. LoadPhotos();
  1300. #if 1
  1301. CString str;
  1302. if (m_mode == 1)
  1303. str += "原片";
  1304. else if (m_mode == 2)
  1305. str += "初修片";
  1306. else if (m_mode == 3)
  1307. str += "精修片";
  1308. else if (m_mode == 5)
  1309. str += "设计片";
  1310. strDelContent.Format("删除%s, 订单号%s的%s:共删除%d张", m_name, m_id, str, m_nDelCount);
  1311. WriteLog("删除相片", strDelContent);
  1312. strDelContent = str;
  1313. #endif
  1314. if (delarray.GetSize() && g_branchname != "")
  1315. {
  1316. str.Format("是否同步删除分店 %s 的照片?", g_branchname);
  1317. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  1318. CString sql = "deletephotos";
  1319. if (m_mode == 1)//拍照
  1320. sql += "0";
  1321. else if (m_mode == 2)//初修
  1322. sql += "1";
  1323. else if (m_mode == 3)//精修
  1324. sql += "2";
  1325. else if (m_mode == 5)//设计
  1326. sql += "3";
  1327. sql += m_id;
  1328. sql += ";";
  1329. for (int i = 0; i < delarray.GetSize(); i++)
  1330. {
  1331. sql += delarray.ElementAt(i);
  1332. sql += ",";
  1333. }
  1334. g_sendhead.bsql = 1;
  1335. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  1336. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  1337. #if 1//Jeff add;
  1338. if (m_mode == 1)
  1339. str += "原片";
  1340. else if (m_mode == 2)
  1341. str += "初修片";
  1342. else if (m_mode == 3)
  1343. str += "精修片";
  1344. else if (m_mode == 5)
  1345. str += "设计片";
  1346. strDelContent.Format("客人%s,订单号%s的分店%s的%s被同步删除", m_name, m_id, g_branchname, str);
  1347. WriteLog("分店相片同步删除", strDelContent);
  1348. #endif
  1349. }
  1350. else if (delarray.GetSize() && m_branch != "")
  1351. {
  1352. if (GetBranchPhotoPath(m_branch) == "")return;
  1353. str.Format("是否同步删除分店 %s 的照片?", m_branch);
  1354. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  1355. CString sql = "deletephotos";
  1356. if (m_mode == 1)//拍照
  1357. sql += "0";
  1358. else if (m_mode == 2)//初修
  1359. sql += "1";
  1360. else if (m_mode == 3)//精修
  1361. sql += "2";
  1362. else if (m_mode == 5)//设计
  1363. sql += "3";
  1364. sql += m_id;
  1365. sql += ";";
  1366. for (int i = 0; i < delarray.GetSize(); i++)
  1367. {
  1368. sql += delarray.ElementAt(i);
  1369. sql += ",";
  1370. }
  1371. g_sendhead.bsql = 1;
  1372. g_branchip = GetIP(m_branch);
  1373. g_pMainWnd->OnDisconnect();
  1374. g_branchname = m_branch;
  1375. g_bBranchModify = 1;
  1376. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1377. g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
  1378. if (g_bSendOK == 0)return;
  1379. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  1380. #if 1//Jeff add;
  1381. if (m_mode == 1)
  1382. str += "原片";
  1383. else if (m_mode == 2)
  1384. str += "初修片";
  1385. else if (m_mode == 3)
  1386. str += "精修片";
  1387. else if (m_mode == 5)
  1388. str += "设计片";
  1389. strDelContent.Format("客人%s,订单号%s的分店%s的%s被同步删除", m_name, m_id, g_branchname, str);
  1390. WriteLog("分店相片同步删除", strDelContent);
  1391. #endif
  1392. }
  1393. #endif
  1394. }
  1395. extern void SaveTaskPath(CString path);
  1396. void ShowPic::OnBUTupload() //上传照片;
  1397. {
  1398. if (1)//g_branchname=="")
  1399. {
  1400. OnBUTupload2();
  1401. return;
  1402. }
  1403. // ZipTypeDlg dlg;
  1404. // dlg.DoModal ();
  1405. CString m_sel;
  1406. if (m_mode == 1)//拍照
  1407. {
  1408. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
  1409. }
  1410. else if (m_mode == 2)//初修
  1411. {
  1412. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
  1413. }
  1414. else if (m_mode == 3)//精修
  1415. {
  1416. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
  1417. }
  1418. else if (m_mode == 5)//设计
  1419. {
  1420. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
  1421. }
  1422. CStringArray m_uploadtaskarray;
  1423. m_uploadtaskarray.Add(m_id + ";" + m_name);
  1424. m_uploadtaskarray.Add("");
  1425. m_uploadtaskarray.Add("");
  1426. m_uploadtaskarray.Add(m_sel);
  1427. m_uploadtaskarray.Add("");
  1428. m_uploadtaskarray.Add("");
  1429. m_uploadtaskarray.Add("");
  1430. m_uploadtaskarray.Add("");
  1431. m_uploadtaskarray.Add("");
  1432. m_uploadtaskarray.Add("");
  1433. MyLock lock("uploadtaskaccess");
  1434. CFile fp;
  1435. CString pathdir = m_path + "uploadtask";
  1436. {
  1437. int pos = pathdir.Find(m_id);
  1438. pos += m_id.GetLength();
  1439. int pos2 = pathdir.ReverseFind('\\');
  1440. pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
  1441. }
  1442. CString path;
  1443. int taskpos = 1;
  1444. CStringArray m_olduploadtaskarray;
  1445. for (int i = 0; i < 200; i++)
  1446. {
  1447. path.Format("%s%d.dat", pathdir, i + 1);
  1448. if (PathFileExists(path))
  1449. {
  1450. CFile fp;
  1451. if (fp.Open(path, CFile::modeRead))
  1452. {
  1453. DWORD length = fp.GetLength();
  1454. if (!length)continue;
  1455. CStringArray m_array;
  1456. CArchive ar(&fp, CArchive::load);
  1457. m_array.Serialize(ar);
  1458. fp.Close();
  1459. for (int j = 10; j < m_array.GetSize(); j += 2)
  1460. {
  1461. m_olduploadtaskarray.Add(m_array.ElementAt(j));
  1462. }
  1463. }
  1464. }
  1465. }
  1466. BOOL bexist = 0;
  1467. POSITION pos;
  1468. pos = m_List1.GetFirstSelectedItemPosition();
  1469. if (pos == NULL)
  1470. {
  1471. AfxMessageBox("请选择您要上传的文件!"); return;
  1472. }
  1473. else
  1474. {
  1475. while (pos)
  1476. {
  1477. int iItem = m_List1.GetNextSelectedItem(pos);
  1478. CString title = m_List1.GetItemText(iItem, 0);
  1479. CString file2 = m_path + title + ".jpg";
  1480. if (m_mode == 1)
  1481. { //拍照,加景点
  1482. int pos = file2.Find(m_id);
  1483. pos += m_id.GetLength();
  1484. int pos2 = file2.ReverseFind('\\');
  1485. CString jd;
  1486. if (pos2 > pos)
  1487. {
  1488. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  1489. }
  1490. CString task;
  1491. if (jd != "")
  1492. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  1493. else
  1494. task = file2.Right(file2.GetLength() - pos2 - 1);
  1495. if (::FindArray(&m_olduploadtaskarray, task) == -1)
  1496. {
  1497. m_uploadtaskarray.Add(task);
  1498. m_uploadtaskarray.Add("");
  1499. }
  1500. else
  1501. bexist = 1;
  1502. }
  1503. else
  1504. {
  1505. if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
  1506. {
  1507. m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
  1508. m_uploadtaskarray.Add("");
  1509. }
  1510. else
  1511. bexist = 1;
  1512. }
  1513. }
  1514. }
  1515. if (m_uploadtaskarray.GetSize() > 10)
  1516. {
  1517. CFile fp;
  1518. CString path;
  1519. int taskpos = 1;
  1520. path.Format("%s%d.dat", pathdir, taskpos);
  1521. CString dir = path.Left(path.ReverseFind('\\') + 1);
  1522. pathdir = g_path1 + "\\上传任务\\";
  1523. ::CreateDirectory(pathdir, NULL);
  1524. path.Format("%s%d.dat", pathdir, taskpos);
  1525. while (PathFileExists(path))
  1526. {
  1527. taskpos++;
  1528. path.Format("%s%d.dat", pathdir, taskpos);
  1529. }
  1530. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  1531. CArchive ar(&fp, CArchive::store);
  1532. m_uploadtaskarray.SetAt(4, dir);
  1533. m_uploadtaskarray.Serialize(ar);
  1534. ar.Close();
  1535. fp.Close();
  1536. }
  1537. if (bexist)
  1538. AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
  1539. else
  1540. AfxMessageBox("保存上传任务成功!");
  1541. }
  1542. void ShowPic::OnBUTselall()
  1543. {
  1544. for (int i = 0; i < m_List1.GetItemCount(); i++)
  1545. m_List1.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
  1546. }
  1547. void ShowPic::OnSelchangeCombo2()
  1548. {
  1549. int pos = m_combobranch.GetCurSel();
  1550. if (pos == -1)return;
  1551. CString str;
  1552. m_combobranch.GetLBText(pos, str);
  1553. m_patharray1.RemoveAll();
  1554. m_vFileName.RemoveAll();
  1555. if (m_mode == 4)//礼服
  1556. {
  1557. m_type = str;
  1558. LoadPhotos();
  1559. return;
  1560. }
  1561. GetDlgItem(IDC_BUTupload)->SetWindowText("上传至" + str);
  1562. GetDlgItem(IDC_BUTupload)->Invalidate();
  1563. }
  1564. void ShowPic::OnBUTupload2()
  1565. {
  1566. int combopos = m_combobranch.GetCurSel();
  1567. if (combopos == -1)
  1568. {
  1569. AfxMessageBox("请选择您要上传到的分店!");
  1570. return;
  1571. }
  1572. CString domain = m_iparray.ElementAt(combopos);
  1573. CString savedomain;
  1574. if (m_branch != "")
  1575. {
  1576. savedomain = GetDomainFromBranch(m_branch);
  1577. }
  1578. else
  1579. {
  1580. savedomain = GetDomainFromBranch(g_branchname);
  1581. if (g_branchname == "")
  1582. savedomain = g_brancharray.ElementAt(g_brancharray.GetSize() - 1).ElementAt(2);
  1583. }
  1584. // ZipTypeDlg dlg;
  1585. // dlg.DoModal ();
  1586. CString m_sel;
  1587. if (m_mode == 1)//拍照
  1588. {
  1589. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
  1590. }
  1591. else if (m_mode == 2)//初修
  1592. {
  1593. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
  1594. }
  1595. else if (m_mode == 3)//精修
  1596. {
  1597. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
  1598. }
  1599. else if (m_mode == 5)//设计
  1600. {
  1601. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
  1602. }
  1603. CStringArray m_uploadtaskarray;
  1604. m_uploadtaskarray.Add(m_id + ";" + m_name);
  1605. m_uploadtaskarray.Add(domain);
  1606. m_uploadtaskarray.Add(savedomain);
  1607. m_uploadtaskarray.Add(m_sel);
  1608. m_uploadtaskarray.Add("");
  1609. m_uploadtaskarray.Add("");
  1610. m_uploadtaskarray.Add("");
  1611. m_uploadtaskarray.Add("");
  1612. m_uploadtaskarray.Add("");
  1613. m_uploadtaskarray.Add("");
  1614. MyLock lock("uploadtaskaccess");
  1615. CFile fp;
  1616. CString pathdir = m_path + "uploadtask";
  1617. {
  1618. int pos = pathdir.Find(m_id);
  1619. pos += m_id.GetLength();
  1620. int pos2 = pathdir.ReverseFind('\\');
  1621. pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
  1622. }
  1623. CString path;
  1624. int taskpos = 1;
  1625. CStringArray m_olduploadtaskarray;
  1626. for (int i = 0; i < 200; i++)
  1627. {
  1628. path.Format("%s%d.dat", pathdir, i + 1);
  1629. if (PathFileExists(path))
  1630. {
  1631. CFile fp;
  1632. if (fp.Open(path, CFile::modeRead))
  1633. {
  1634. DWORD length = fp.GetLength();
  1635. if (!length)continue;
  1636. CStringArray m_array;
  1637. CArchive ar(&fp, CArchive::load);
  1638. m_array.Serialize(ar);
  1639. fp.Close();
  1640. if (domain != m_array.ElementAt(1))continue;
  1641. for (int j = 10; j < m_array.GetSize(); j += 2)
  1642. {
  1643. m_olduploadtaskarray.Add(m_array.ElementAt(j));
  1644. }
  1645. }
  1646. }
  1647. }
  1648. BOOL bexist = 0;
  1649. POSITION pos;
  1650. pos = m_List1.GetFirstSelectedItemPosition();
  1651. if (pos == NULL)
  1652. {
  1653. AfxMessageBox("请选择您要上传的文件!"); return;
  1654. }
  1655. else
  1656. {
  1657. while (pos)
  1658. {
  1659. int iItem = m_List1.GetNextSelectedItem(pos);
  1660. CString title = m_List1.GetItemText(iItem, 0);
  1661. CString file2 = m_path + title + ".jpg";
  1662. if (m_mode == 1)
  1663. { //拍照,加景点
  1664. int pos = file2.Find(m_id);
  1665. pos += m_id.GetLength();
  1666. int pos2 = file2.ReverseFind('\\');
  1667. CString jd;
  1668. if (pos2 > pos)
  1669. {
  1670. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  1671. }
  1672. CString task;
  1673. if (jd != "")
  1674. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  1675. else
  1676. task = file2.Right(file2.GetLength() - pos2 - 1);
  1677. if (::FindArray(&m_olduploadtaskarray, task) == -1)
  1678. {
  1679. m_uploadtaskarray.Add(task);
  1680. m_uploadtaskarray.Add("");
  1681. }
  1682. else
  1683. bexist = 1;
  1684. }
  1685. else
  1686. {
  1687. if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
  1688. {
  1689. m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
  1690. m_uploadtaskarray.Add("");
  1691. }
  1692. else
  1693. bexist = 1;
  1694. }
  1695. }
  1696. }
  1697. if (m_uploadtaskarray.GetSize() > 10)
  1698. {
  1699. CFile fp;
  1700. CString path;
  1701. int taskpos = 1;
  1702. path.Format("%s%d.dat", pathdir, taskpos);
  1703. CString dir = path.Left(path.ReverseFind('\\') + 1);
  1704. pathdir = g_path1 + "\\上传任务\\";
  1705. ::CreateDirectory(pathdir, NULL);
  1706. path.Format("%s%d.dat", pathdir, taskpos);
  1707. while (PathFileExists(path))
  1708. {
  1709. taskpos++;
  1710. path.Format("%s%d.dat", pathdir, taskpos);
  1711. }
  1712. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  1713. CArchive ar(&fp, CArchive::store);
  1714. m_uploadtaskarray.SetAt(4, dir);
  1715. m_uploadtaskarray.Serialize(ar);
  1716. ar.Close();
  1717. fp.Close();
  1718. // SaveTaskPath(path);
  1719. }
  1720. if (bexist)
  1721. AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
  1722. else
  1723. AfxMessageBox("保存上传任务成功!");
  1724. }
  1725. void ShowPic::OnBUTSetDesignNo()
  1726. {
  1727. SetDesignNo dlg;
  1728. dlg.m_id = m_id;
  1729. dlg.DoModal();
  1730. }
  1731. void ShowPic::OnBUTexport() // 只有在设计时,才会有这个导出相片按钮;
  1732. {
  1733. if (IsHasRights2new(12) == 0)return;
  1734. POSITION pos;
  1735. pos = m_List1.GetFirstSelectedItemPosition();
  1736. if (pos == NULL)
  1737. {
  1738. AfxMessageBox("请先选中您要导出的照片!", MB_ICONINFORMATION);
  1739. return;
  1740. }
  1741. CStringArray saExportImage; // 被导出的相片路径数组;
  1742. CString strExportDirectory; // 相片导出的路径;
  1743. GetSavePath(strExportDirectory);
  1744. if (strExportDirectory.IsEmpty())
  1745. {
  1746. return;
  1747. }
  1748. strExportDirectory.TrimRight('\\');
  1749. strExportDirectory += "\\";
  1750. strExportDirectory += m_id;
  1751. strExportDirectory += m_name2;
  1752. strExportDirectory += "设计好的片修";
  1753. strExportDirectory += "\\";
  1754. ::CreateDirectory(strExportDirectory, NULL);
  1755. CStringArray desarray;
  1756. CStringArray dirarray;
  1757. CString str, str2;
  1758. int pos2;
  1759. while (pos)
  1760. {
  1761. int iItem = m_List1.GetNextSelectedItem(pos);
  1762. str = m_List1.GetItemText(iItem, 0);
  1763. str = m_path + str + ".jpg";
  1764. saExportImage.Add(str);
  1765. str2 = strExportDirectory + m_List1.GetItemText(iItem, 0) + ".jpg";
  1766. desarray.Add(str2);
  1767. str2 = "";
  1768. str = m_List1.GetItemText(iItem, 0);
  1769. pos2 = str.Find("\\");
  1770. while (pos2 != -1)
  1771. {
  1772. str2 += str.Left(pos2) + "\\";
  1773. if (::FindArray(&dirarray, str2) == -1)
  1774. {
  1775. dirarray.Add(str2);
  1776. ::CreateDirectory(strExportDirectory + str2, NULL);
  1777. }
  1778. str = str.Right(str.GetLength() - pos2 - 1);
  1779. pos2 = str.Find("\\");
  1780. }
  1781. }
  1782. CStdioFile fp;
  1783. fp.Open(strExportDirectory + "客户要求.txt", CFile::modeCreate | CFile::modeWrite);
  1784. fp.WriteString(remark);
  1785. fp.Close();
  1786. //----------------------------------------------------------------------------------------------
  1787. //----------------------------------------------------------------------------------------------
  1788. // 在设计时,导出查看的设计片;
  1789. //----------------------------------------------------------------------------------------------
  1790. //----------------------------------------------------------------------------------------------
  1791. ImportPhoto dlg;
  1792. dlg.m_mode = 1; // 1.未知;
  1793. dlg.m_pArray = &saExportImage; // 2.作为导出源的设计片的路径集合;
  1794. dlg.m_pDesArray = &desarray; // 3.作为导出目标的设计片的路径集合;
  1795. dlg.m_savepath = strExportDirectory; // 4.保存导出查看的设计片的目录;
  1796. dlg.DoModal();
  1797. AfxMessageBox("导片成功!", MB_ICONINFORMATION);
  1798. // CString str;
  1799. str = " 导出设计片 ";
  1800. str += "客人:";
  1801. str += m_name + m_id;
  1802. WriteLog("导出设计片", str);
  1803. }
  1804. /************************************************************************/
  1805. /*
  1806. 函数:OnButRefreshPhotos
  1807. 描述:刷新相片s和m图
  1808. 参数:
  1809. 返回:
  1810. */
  1811. /************************************************************************/
  1812. void ShowPic::OnButRefreshPhotos()
  1813. {
  1814. TerminateRefreshTh();
  1815. if(m_hRefExitEvent == NULL)
  1816. m_hRefExitEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
  1817. unsigned int dwID = 0;
  1818. m_hThreadRef = (HANDLE)_beginthreadex(NULL, 0, RefreshThFun, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &dwID);
  1819. }
  1820. #if USE_SHARE_FLORD
  1821. /************************************************************************/
  1822. /*
  1823. 函数:GetAllSelectImage
  1824. 描述:获取List控件中选中的全部项;
  1825. 参数:
  1826. OUT: strAry,返回选中项名称;
  1827. 返回:
  1828. 注意:
  1829. 调用约定:
  1830. */
  1831. /************************************************************************/
  1832. void ShowPic::GetAllSelectImage(OUT CStringArray &strAry)
  1833. {
  1834. strAry.RemoveAll();
  1835. POSITION pos = m_List1.GetFirstSelectedItemPosition();
  1836. if( pos == NULL)
  1837. {
  1838. AfxMessageBox("请先选中您要删除的照片!", MB_ICONINFORMATION);
  1839. return;
  1840. }
  1841. if( AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO|MB_ICONSTOP ) != IDYES ) return;
  1842. int nItem = 0;
  1843. CString strImage = _T("");
  1844. while( pos )
  1845. {
  1846. nItem = m_List1.GetNextSelectedItem( pos );
  1847. strAry.Add(m_List1.GetItemText(nItem, 0));
  1848. }
  1849. }
  1850. #endif
  1851. BOOL ShowPic::DestroyWindow()
  1852. {
  1853. // TODO: 在此添加专用代码和/或调用基类
  1854. m_bExit = true;
  1855. #ifdef _DEBUG
  1856. TRACE("退出窗口DestroyWindow\n");
  1857. #endif
  1858. AutoThreadSection aSection(&m_ThreadSection);
  1859. ExitLoadThread();
  1860. TerminateRefreshTh();
  1861. return CDialog::DestroyWindow();
  1862. }