ShowPic.cpp 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047
  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. #include "DlgImgThumbnail.h"
  14. #define THUMBNAIL_WIDTH 100
  15. #define THUMBNAIL_HEIGHT 90
  16. ThreadSection ShowPic::m_ThreadSection;
  17. unsigned __stdcall RefreshWork(LPVOID lpParam);
  18. /////////////////////////////////////////////////////////////////////////////
  19. // ShowPic dialog IDC_BU IDC_COMBO2
  20. ShowPic::ShowPic(CWnd* pParent /*=NULL*/): CDialog(ShowPic::IDD, pParent)
  21. {
  22. m_branchname = _T("");
  23. m_bRunning = false;
  24. m_bExit = FALSE;
  25. m_hThread = NULL;
  26. m_mode = 0;
  27. m_bdelall = 0;
  28. m_nDelCount = 0;
  29. m_hRefExitEvent = NULL;
  30. m_hThreadRef = NULL;
  31. m_bOriginalImg = FALSE;
  32. m_pUnKnown = NULL;
  33. //m_hEvent = NULL;
  34. }
  35. void ShowPic::DoDataExchange(CDataExchange* pDX)
  36. {
  37. CDialog::DoDataExchange(pDX);
  38. //{{AFX_DATA_MAP(ShowPic)
  39. DDX_Control(pDX, IDC_COMBO2, m_combobranch);
  40. DDX_Control(pDX, IDC_LIST1, m_List1);
  41. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  42. DDX_CBString(pDX, IDC_COMBO2, m_branchname);
  43. //}}AFX_DATA_MAP
  44. }
  45. BEGIN_MESSAGE_MAP(ShowPic, CDialog)
  46. //{{AFX_MSG_MAP(ShowPic)
  47. ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
  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 )
  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 )
  511. {
  512. pImgList->Replace(i, &bitmap, NULL);
  513. pListCtrl->RedrawItems(i, i);
  514. }
  515. }
  516. }
  517. }
  518. }
  519. DWORD ShowPic::LoadThumbNail(LPVOID lpParam)
  520. {
  521. try
  522. {
  523. ShowPic *pDlg = (ShowPic*)lpParam;
  524. CListCtrl *ListCtrl = &pDlg->m_List1;
  525. CImageList* pImgList = &pDlg->m_ImageListThumb;
  526. for (int i = 0; !pDlg->m_bExit && i < pImgList->GetImageCount(); i++)
  527. pImgList->Remove(i);
  528. ListCtrl->DeleteAllItems();
  529. pImgList->SetImageCount(pDlg->m_vFileName.GetSize());
  530. if ( pDlg->m_bExit )
  531. {
  532. pDlg->m_bRunning = false;
  533. pDlg->m_bExit = false;
  534. return 0;
  535. }
  536. ListCtrl->Invalidate();
  537. AddListItemName(pDlg, ListCtrl, pDlg->m_vFileName);
  538. DrawListItemImg(pDlg, ListCtrl, pImgList, pDlg->m_vFileName);
  539. if (!pDlg->m_bExit)
  540. ListCtrl->Invalidate();
  541. pDlg->m_bRunning = false;
  542. pDlg->m_bExit = false;
  543. return 0;
  544. }
  545. catch (...)
  546. {
  547. }
  548. return 0;
  549. }
  550. /************************************************************************/
  551. /*
  552. 函数:TerminateRefreshTh
  553. 描述:结束刷新图片线程
  554. 参数:
  555. 返回:
  556. */
  557. /************************************************************************/
  558. BOOL ShowPic::TerminateRefreshTh()
  559. {
  560. //设为有信号
  561. if(m_hRefExitEvent)
  562. SetEvent(m_hRefExitEvent);
  563. //等待线程结束
  564. if(m_hThreadRef)
  565. WaitForSingleObject(m_hThreadRef, INFINITE);
  566. if(m_hRefExitEvent)
  567. {
  568. ::CloseHandle(m_hRefExitEvent);
  569. m_hRefExitEvent = NULL;
  570. }
  571. if(m_hThreadRef)
  572. {
  573. ::CloseHandle(m_hThreadRef);
  574. m_hThreadRef = NULL;
  575. }
  576. return TRUE;
  577. }
  578. /************************************************************************/
  579. /*
  580. 函数:RefreshThFun
  581. 描述:刷新
  582. 参数:
  583. 返回:
  584. */
  585. /************************************************************************/
  586. void ShowPic::RefreshWork()
  587. {
  588. BOOL bFinish = TRUE;
  589. for(int i=0; i<m_vFileName.GetSize(); i++)
  590. {
  591. // 等待退出信号;
  592. if(m_hRefExitEvent && WaitForSingleObject(m_hRefExitEvent, 0) == WAIT_OBJECT_0)
  593. {
  594. bFinish = FALSE;
  595. break;
  596. }
  597. CString str = m_vFileName.ElementAt(i);
  598. CString spath = str.Left(str.ReverseFind('\\') + 1);
  599. spath += "s";
  600. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  601. if(!::PathFileExists(spath))
  602. ImgThumbnail(m_vFileName.ElementAt(i), SET_PIX(100, 76), spath, 100);
  603. spath = str.Left(str.ReverseFind('\\') + 1);
  604. spath += "m";
  605. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  606. if(!::PathFileExists(spath))
  607. ImgThumbnail(m_vFileName.ElementAt(i), SET_PIX(2000, 1500), spath, 100);
  608. }
  609. if(bFinish)
  610. {
  611. MessageBox(_T("刷新完成"));
  612. LoadThumbImages();
  613. }
  614. }
  615. /************************************************************************/
  616. /*
  617. 函数:RefreshThFun
  618. 描述:线程函数
  619. 参数:
  620. 返回:
  621. */
  622. /************************************************************************/
  623. unsigned __stdcall RefreshThFun(LPVOID lpParam)
  624. {
  625. ShowPic* p = (ShowPic*)lpParam;
  626. try
  627. {
  628. p->RefreshWork();
  629. return 0;
  630. }
  631. catch (CException* e)
  632. {
  633. return 0;
  634. }
  635. }
  636. void ShowPic::LoadThumbImages()
  637. {
  638. ExitLoadThread();
  639. m_hThread = CreateThread(NULL, 0, LoadThumbNail, this, 0, NULL);
  640. if( m_hThread )
  641. {
  642. m_bRunning = true;
  643. }
  644. }
  645. BOOL ShowPic::ExitLoadThread()
  646. {
  647. if ( m_bRunning ) m_bExit = true;
  648. if ( m_hThread )
  649. {
  650. while( WaitForSingleObject(m_hThread,0) == WAIT_OBJECT_0 )
  651. {
  652. Sleep(100); // 由于该线程内容调用到各种主线程的窗口事件,所以不能死等,必须Sleep以保持主窗口线程鲜活;
  653. break;
  654. }
  655. CloseHandle(m_hThread);
  656. m_hThread = NULL;
  657. }
  658. return TRUE;
  659. }
  660. void ShowPic::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
  661. {
  662. if ( m_bOriginalImg )
  663. {
  664. MessageBox(_T("不支持查看原始格式相片!"), _T("温馨提示!"), MB_OK|MB_ICONHAND);
  665. return;
  666. }
  667. POSITION pos;
  668. pos = m_List1.GetFirstSelectedItemPosition();
  669. if (pos == NULL)
  670. {
  671. return;
  672. }
  673. int iItem = m_List1.GetNextSelectedItem(pos);
  674. ShowPic22 dlg;
  675. dlg.m_nCurImgPos = iItem;
  676. dlg.m_pAryImgPath = &m_patharray1;
  677. dlg.DoModal();
  678. *pResult = 0;
  679. }
  680. BOOL ShowPic::DestroyWindow()
  681. {
  682. // TODO: 在此添加专用代码和/或调用基类
  683. m_bExit = true;
  684. #ifdef _DEBUG
  685. TRACE("退出窗口DestroyWindow\n");
  686. #endif
  687. AutoThreadSection aSection(&m_ThreadSection);
  688. ExitLoadThread();
  689. TerminateRefreshTh();
  690. return CDialog::DestroyWindow();
  691. }
  692. void ShowPic::LoadPhotos() // 从订单目录中加载相片;
  693. {
  694. #ifdef USE_KERNEL_DLL
  695. if ( m_mode == 4 )
  696. {// 礼服;
  697. CString str = _T("");
  698. CString savepath = g_path5 + _T("\\");
  699. int i = 0;
  700. for ( i = 0; i < m_List1array.GetSize(); i++)
  701. {
  702. if (m_type != _T("") && m_type != _T("全部") && m_type != m_List1array.ElementAt(i).ElementAt(0))
  703. continue;
  704. OutputDebugString(m_List1array.ElementAt(i).ElementAt(1) + _T("\n"));
  705. CString str = savepath + m_List1array.ElementAt(i).ElementAt(1) + _T(".jpg");
  706. if ( PathFileExists(str) )
  707. m_patharray1.Add(str);
  708. }
  709. if (m_bRunning)return;
  710. CStringArray *pArray = &m_patharray1;
  711. m_vFileName.RemoveAll();
  712. for ( i = 0; i < pArray->GetSize(); i++)
  713. {
  714. CString filePath = pArray->ElementAt(i);
  715. filePath.MakeLower();
  716. m_vFileName.Add(filePath);
  717. }
  718. LoadThumbImages();
  719. return;
  720. }
  721. // 非礼服,原片、初修片、精修片、设计片;
  722. INT nImgType = m_mode;
  723. if ( m_mode == 5)
  724. nImgType--;
  725. CStringArray AryLoadExtImgpath;
  726. CStringArray AryWithExtImgpath;
  727. CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname);
  728. if ( GetOrderImgpathEx(nImgType, strBranchId, m_id, TRUE, _T("*.jpg|*.jpeg"), _T("*.cr2|*.raw|*.nef|*.ra2"), AryLoadExtImgpath, AryWithExtImgpath, m_aryOfShareDirectory))
  729. {
  730. INT i = 0;
  731. CString str;
  732. m_patharray1.RemoveAll();
  733. CString strfilename;
  734. INT nSize = AryLoadExtImgpath.GetSize();
  735. if ( nSize == 0 && AryWithExtImgpath.GetSize() )
  736. { // 没有jpg可显示的相片,但有原始格式的相片;
  737. m_bOriginalImg = TRUE;
  738. nSize = AryWithExtImgpath.GetSize();
  739. for (i = 0; i < nSize; i++ )
  740. {
  741. str = AryWithExtImgpath.ElementAt(i);
  742. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  743. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  744. str.MakeLower();
  745. if (!g_bOriginal && m_mode == 1) // 拍照;
  746. {
  747. strfilename = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  748. if (strfilename.ReverseFind(_T('.')) != -1)
  749. strfilename = strfilename.Left(strfilename.ReverseFind(_T('.')));
  750. // 若只是用于系统数字编号的,可以使用Isdigit来判断相片编号是否为数字编号;
  751. if ( !myisdigit(strfilename) )
  752. continue;
  753. }
  754. m_patharray1.Add(str);
  755. }
  756. }
  757. else
  758. {
  759. m_bOriginalImg = FALSE;
  760. for (i = 0; i < nSize; i++ )
  761. {
  762. str = AryLoadExtImgpath.ElementAt(i);
  763. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  764. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  765. str.MakeLower();
  766. if (!g_bOriginal && m_mode == 1) // 拍照;
  767. {
  768. strfilename = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  769. if (strfilename.ReverseFind(_T('.')) != -1)
  770. strfilename = strfilename.Left(strfilename.ReverseFind(_T('.')));
  771. // 若只是用于系统数字编号的,可以使用Isdigit来判断相片编号是否为数字编号;
  772. if ( !myisdigit(strfilename) )
  773. continue;
  774. }
  775. m_patharray1.Add(str);
  776. }
  777. }
  778. if (m_bRunning)return;
  779. CStringArray *pArray = &m_patharray1;
  780. m_vFileName.RemoveAll();
  781. for ( i = 0; i < pArray->GetSize(); i++)
  782. {
  783. CString filePath = pArray->ElementAt(i);
  784. filePath.MakeLower();
  785. m_vFileName.Add(filePath);
  786. }
  787. LoadThumbImages();
  788. }
  789. else
  790. {
  791. // 如果没有找到目录,则清空所有list项目;
  792. for (int i = 0; i < m_ImageListThumb.GetImageCount(); i++)
  793. m_ImageListThumb.Remove(i);
  794. m_List1.DeleteAllItems();
  795. }
  796. if ( m_mode == 1)
  797. {
  798. CString strText ;
  799. strText.Format(_T("客户照片查看,当前张数:%ld"), m_vFileName.GetSize());
  800. SetWindowText(strText);
  801. }
  802. #else
  803. m_patharray1.RemoveAll();
  804. m_path.MakeLower();
  805. CStringArray dirarray;
  806. CString str;
  807. if (m_mode == 4)//礼服
  808. {
  809. CString savepath = g_path5 + "\\";
  810. for (int i = 0; i < m_List1array.GetSize(); i++)
  811. {
  812. if (m_type != "" && m_type != "全部" && m_type != m_List1array.ElementAt(i).ElementAt(0))
  813. continue;
  814. // str=savepath+"s"+m_List1array.ElementAt (i).ElementAt (1)+".jpg";
  815. str = savepath + m_List1array.ElementAt(i).ElementAt(1) + ".jpg";
  816. if (::PathFileExists(str))
  817. m_patharray1.Add(str);
  818. }
  819. }
  820. else
  821. {
  822. #if USE_SHARE_FLORD // 多级共享目录查看相片;
  823. int nPhotoType = m_mode;
  824. if ( m_mode == 5)
  825. nPhotoType--;
  826. // 根据域名,相片类型,订单号查找相片;
  827. //LoadPhotos(nPhotoType, m_id, m_branch);
  828. m_aryOfShareDirectory.RemoveAll();
  829. CNetShareInfo::GetInstance()->LoadOrderImages(nPhotoType, m_id, m_branch, m_patharray1, &m_aryOfShareDirectory);
  830. #else
  831. if (1)
  832. {
  833. using namespace helper_coffs;
  834. ffsco o;
  835. o.dirs(1);
  836. o.find(LPCSTR(m_path), LPCSTR("*.*"));
  837. ffsco::typeT coo;
  838. ffsco::typeT::iterator it;
  839. // 1.获得所有子文件夹;
  840. coo = o.co_dir();
  841. for (it = coo.begin();coo.end() != it;it++)
  842. {
  843. str = (*it).c_str();
  844. if (FindArray(&dirarray, str) == -1)
  845. {
  846. dirarray.Add(str);
  847. }
  848. }
  849. }
  850. if (1)
  851. {
  852. CString filename;
  853. for (int i = 0; i < dirarray.GetSize(); i++)
  854. {
  855. using namespace helper_coffs;
  856. ffsco o;
  857. o.dirs(0);
  858. if (m_mode == 1)//拍照
  859. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.*"));
  860. else
  861. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  862. ffsco::typeT coo;
  863. ffsco::typeT::iterator it;
  864. // 2.获得所有子文件夹下的文件;
  865. coo = o.co_file();
  866. for (it = coo.begin();coo.end() != it;it++)
  867. {
  868. str = (*it).c_str();
  869. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  870. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  871. str.MakeLower();
  872. if (m_mode == 1)//拍照
  873. {
  874. filename = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  875. if (filename.Find(".") != -1)
  876. filename = filename.Left(filename.Find("."));
  877. if (!myisdigit(filename))continue;
  878. }
  879. m_patharray1.Add(str);
  880. }
  881. }
  882. }
  883. #endif
  884. }
  885. if (m_bRunning)return;
  886. CStringArray *pArray = &m_patharray1;
  887. m_vFileName.clear();
  888. for (int i = 0; i < pArray->GetSize(); i++)
  889. {
  890. CString filePath = pArray->ElementAt(i);
  891. filePath.MakeLower();
  892. m_vFileName.push_back(filePath);
  893. }
  894. LoadThumbImages();
  895. #endif
  896. }
  897. void ShowPic::OnBUTdelall() // 全部删除按钮;
  898. {
  899. // TODO: Add your control notification handler code here
  900. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  901. // 删除多级共享目录下的全部订单相片;
  902. int nSize = m_aryOfShareDirectory.GetSize();
  903. for ( int i = 0; i < nSize; i++)
  904. {
  905. DeleteDirectory(m_aryOfShareDirectory.ElementAt(i));
  906. }
  907. LoadPhotos();
  908. if (m_mode == 1)
  909. {
  910. CString sql;
  911. sql = "update dindan set [curno]='1' where [id]='" + m_id + "'";
  912. g_sendhead.bsql = 1;
  913. g_pMainWnd->ProcessChatMessageRequest2(sql);
  914. m_bdelall = 1;
  915. }
  916. #if 1
  917. CString str;
  918. str = "清除";
  919. str += m_name;
  920. str += m_id;
  921. str += "全部";//Jeff.add;
  922. if (m_mode == 1)
  923. str += "原片";
  924. else if (m_mode == 2)
  925. str += "初修片";
  926. else if (m_mode == 3)
  927. str += "精修片";
  928. else if (m_mode == 5)
  929. str += "设计片";
  930. WriteLog("清除订单相片", str);
  931. #endif
  932. if (g_branchname != "")
  933. {
  934. str.Format("是否同步删除分店 %s 的照片?", g_branchname);
  935. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  936. CString sql = "deletephotos";
  937. if (m_mode == 1)//拍照
  938. sql += "0";
  939. else if (m_mode == 2)//初修
  940. sql += "1";
  941. else if (m_mode == 3)//精修
  942. sql += "2";
  943. else if (m_mode == 5)//设计
  944. sql += "3";
  945. sql += m_id;
  946. sql += ";";
  947. CString jd;
  948. if (m_mode == 1)
  949. { //拍照,加景点
  950. CString file2 = m_path;
  951. int pos = file2.Find(m_id);
  952. pos += m_id.GetLength();
  953. int pos2 = file2.ReverseFind('\\');
  954. if (pos2 > pos)
  955. {
  956. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  957. }
  958. }
  959. sql += "all";
  960. sql += jd;
  961. g_sendhead.bsql = 1;
  962. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  963. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  964. #if 1//Jeff add;
  965. CString strDelContent;
  966. if (m_mode == 1)
  967. str += "原片";
  968. else if (m_mode == 2)
  969. str += "初修片";
  970. else if (m_mode == 3)
  971. str += "精修片";
  972. else if (m_mode == 5)
  973. str += "设计片";
  974. strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
  975. WriteLog("删除分店照片", strDelContent);
  976. #endif
  977. }
  978. else if (m_branch != "")
  979. {
  980. if (GetBranchPhotoPath(m_branch) == "")return;
  981. str.Format("是否同步删除分店 %s 的照片?", m_branch);
  982. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  983. CString sql = "deletephotos";
  984. if (m_mode == 1)//拍照
  985. sql += "0";
  986. else if (m_mode == 2)//初修
  987. sql += "1";
  988. else if (m_mode == 3)//精修
  989. sql += "2";
  990. else if (m_mode == 5)//设计
  991. sql += "3";
  992. sql += m_id;
  993. sql += ";";
  994. CString jd;
  995. if (m_mode == 1)
  996. { //拍照,加景点
  997. CString file2 = m_path;
  998. int pos = file2.Find(m_id);
  999. pos += m_id.GetLength();
  1000. int pos2 = file2.ReverseFind('\\');
  1001. if (pos2 > pos)
  1002. {
  1003. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  1004. }
  1005. }
  1006. sql += "all";
  1007. sql += jd;
  1008. g_sendhead.bsql = 1;
  1009. g_branchip = GetIP(m_branch);
  1010. g_pMainWnd->OnDisconnect();
  1011. g_branchname = m_branch;
  1012. g_bBranchModify = 1;
  1013. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1014. g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
  1015. if (g_bSendOK == 0)return;
  1016. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  1017. #if 1//Jeff add;
  1018. CString strDelContent;
  1019. if (m_mode == 1)
  1020. str += "原片";
  1021. else if (m_mode == 2)
  1022. str += "初修片";
  1023. else if (m_mode == 3)
  1024. str += "精修片";
  1025. else if (m_mode == 5)
  1026. str += "设计片";
  1027. strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
  1028. WriteLog("删除分店照片", strDelContent);
  1029. #endif
  1030. }
  1031. }
  1032. void ShowPic::OnBUTdel() // 删除按钮;
  1033. {
  1034. #if USE_SHARE_FLORD
  1035. // 获取list列表中选中的相片集合;
  1036. CStringArray delarray;
  1037. GetAllSelectImage(delarray);
  1038. int nPhotoType = m_mode;
  1039. if ( m_mode == 5)
  1040. {
  1041. nPhotoType--;
  1042. }
  1043. CString strDomain;
  1044. CStringArray strAryOfDeleted;
  1045. if ( !m_branch.IsEmpty() )
  1046. {
  1047. strDomain = GetDomainFromBranch(m_branch);
  1048. }
  1049. else
  1050. {
  1051. strDomain = g_branchname;
  1052. }
  1053. int i = 0;
  1054. for(i = 0; i<delarray.GetSize(); i++)
  1055. {
  1056. for ( int nIndex = 0; nIndex < m_vFileName.GetSize(); nIndex++)
  1057. {
  1058. CString str = m_vFileName.ElementAt(nIndex);
  1059. if(str != _T(""))
  1060. {
  1061. CString strdel = delarray.ElementAt(i);
  1062. // 如果是精修片目录里,会有多个子文件夹,而且每个子文件夹都可能会有相同名称的相片;
  1063. if ( strdel.Find(_T("\\")) != -1)
  1064. {// 子文件夹;
  1065. if ( str.Find(strdel) != -1 )
  1066. {
  1067. strAryOfDeleted.Add(m_vFileName.ElementAt(nIndex));
  1068. }
  1069. }
  1070. else
  1071. {// 根目录,从订单号截断;
  1072. if ( str.Find(m_id) != -1 )
  1073. {
  1074. str = str.Mid(str.Find(m_id) + m_id.GetLength() + 1);
  1075. if ( str.Find(_T("\\")) == -1 )
  1076. {// 排除掉子目录;
  1077. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  1078. str = str.Left(str.Find(_T(".")));
  1079. if(str.CompareNoCase(strdel) == 0)
  1080. strAryOfDeleted.Add(m_vFileName.ElementAt(nIndex));
  1081. }
  1082. }
  1083. }
  1084. }
  1085. }
  1086. }
  1087. int nDelCount = strAryOfDeleted.GetSize();
  1088. //////////////////////////////////////////////////////////////////////////
  1089. // 删除已找到的相片文件;
  1090. CString strTemp;
  1091. for ( int n = 0; n < nDelCount; n++)
  1092. {
  1093. // 删除原相片;
  1094. strTemp = strAryOfDeleted.ElementAt(n);
  1095. DeleteFile(strTemp);
  1096. strTemp.MakeLower();
  1097. strTemp.Replace(_T(".jpg"),_T(".nef"));
  1098. DeleteFile(strTemp);
  1099. strTemp.Replace(_T(".nef"),_T(".cr2"));
  1100. DeleteFile(strTemp);
  1101. strTemp.Replace(_T(".cr2"),_T(".raw"));
  1102. DeleteFile(strTemp);
  1103. strTemp.Replace(_T(".raw"),_T(".jpg"));
  1104. // 再删除s+m缩略图;
  1105. CString strAblum;
  1106. CString strLeft, strRight;
  1107. int nIndex = strTemp.ReverseFind('\\');
  1108. strLeft = strTemp.Left( nIndex + 1 );
  1109. strRight = strTemp.Mid( nIndex + 1);
  1110. strAblum.Format("%ss%s",strLeft,strRight);
  1111. DeleteFile(strAblum);
  1112. strAblum.Format("%sm%s",strLeft,strRight);
  1113. DeleteFile(strAblum);
  1114. // 若是原片,则要删除原片目录下的上传任务;
  1115. if ( m_mode == 1 && !g_branchname.IsEmpty() )
  1116. {
  1117. // 暂时空处理,此处逻辑未明确;
  1118. }
  1119. }
  1120. // 重新加载相片;
  1121. LoadPhotos();
  1122. // 写删除日志;
  1123. switch( m_mode )
  1124. {
  1125. case 1:
  1126. strTemp.Format("删除<%s>订单<%s>的原片%d张",m_name,m_id,nDelCount);
  1127. break;
  1128. case 2:
  1129. strTemp.Format("删除<%s>订单<%s>的初修片%d张",m_name,m_id,nDelCount);
  1130. break;
  1131. case 3:
  1132. strTemp.Format("删除<%s>订单<%s>的精修片%d张",m_name,m_id,nDelCount);
  1133. break;
  1134. case 5:
  1135. strTemp.Format("删除<%s>订单<%s>的设计片%d张",m_name,m_id,nDelCount);
  1136. break;
  1137. default:
  1138. break;
  1139. }
  1140. WriteLog("删除订单相片", strTemp);
  1141. // 当连接分店时,除了删除本店的相片外,还要删除外网分店的相片;
  1142. if ( !g_branchname.IsEmpty() && strAryOfDeleted.GetSize() )
  1143. {
  1144. strTemp.Format("是否同步删除分店 %s 的照片?", g_branchname);
  1145. if( AfxMessageBox(strTemp, MB_YESNO|MB_ICONSTOP) != IDYES )
  1146. return;
  1147. strTemp = "deletephotos";
  1148. if( m_mode == 1 )
  1149. strTemp += "0";
  1150. else if( m_mode == 2 )
  1151. strTemp += "1";
  1152. else if( m_mode == 3 )
  1153. strTemp += "2";
  1154. else if( m_mode == 5 )
  1155. strTemp += "3";
  1156. strTemp += m_id;
  1157. strTemp += ":";
  1158. for(int i = 0; i < delarray.GetSize(); i++)
  1159. {
  1160. strTemp += delarray.ElementAt(i);
  1161. strTemp += ",";
  1162. }
  1163. g_sendhead.bsql = 1;
  1164. g_pMainWnd->ProcessChatMessageRequest2(strTemp);
  1165. if( g_bSendOK == 0 )
  1166. return;
  1167. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  1168. // 日志记录;
  1169. if(m_mode==1)
  1170. strTemp.Format("<%s>订单<%s>分店<%s>的原片被同步删除",m_name, m_id, g_branchname);
  1171. else if(m_mode==2)
  1172. strTemp.Format("<%s>订单<%s>分店<%s>的初修片被同步删除",m_name, m_id, g_branchname);
  1173. else if(m_mode==3)
  1174. strTemp.Format("<%s>订单<%s>分店<%s>的精修片被同步删除",m_name, m_id, g_branchname);
  1175. else if(m_mode==5)
  1176. strTemp.Format("<%s>订单<%s>分店<%s>的设计片被同步删除",m_name, m_id, g_branchname);
  1177. WriteLog("分店相片同步删除", strTemp);
  1178. }
  1179. // 当多店汇总时,通过分店名得到分店域名,再删除分店的相片;
  1180. if ( !m_branch.IsEmpty() && strAryOfDeleted.GetSize() )
  1181. {
  1182. if ( strDomain.IsEmpty() )
  1183. return;
  1184. strTemp.Format( "是否同步删除分店 %s 的照片?", m_branch );
  1185. if( AfxMessageBox(strTemp, MB_YESNO|MB_ICONSTOP) != IDYES )
  1186. return;
  1187. strTemp = "deletephotos";
  1188. if( m_mode == 1 )
  1189. strTemp += "0";
  1190. else if( m_mode == 2 )
  1191. strTemp += "1";
  1192. else if( m_mode == 3 )
  1193. strTemp += "2";
  1194. else if( m_mode == 5 )
  1195. strTemp += "3";
  1196. strTemp += m_id;
  1197. strTemp += ":";
  1198. for(int i = 0; i < delarray.GetSize(); i++)
  1199. {
  1200. strTemp += delarray.ElementAt(i);
  1201. strTemp += ",";
  1202. }
  1203. g_sendhead.bsql = 1;
  1204. g_pMainWnd->ProcessChatMessageRequest2(strTemp);
  1205. if( g_bSendOK == 0 )
  1206. return;
  1207. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  1208. // 日志记录;
  1209. if(m_mode==1)
  1210. strTemp.Format("<%s>订单<%s>分店<%s>的原片被同步删除",m_name, m_id, g_branchname);
  1211. else if(m_mode==2)
  1212. strTemp.Format("<%s>订单<%s>分店<%s>的初修片被同步删除",m_name, m_id, g_branchname);
  1213. else if(m_mode==3)
  1214. strTemp.Format("<%s>订单<%s>分店<%s>的精修片被同步删除",m_name, m_id, g_branchname);
  1215. else if(m_mode==5)
  1216. strTemp.Format("<%s>订单<%s>分店<%s>的设计片被同步删除",m_name, m_id, g_branchname);
  1217. WriteLog("分店相片同步删除", strTemp);
  1218. }
  1219. // 直接返回,不执行旧过程;
  1220. return ;
  1221. #else
  1222. // TODO: Add your control notification handler code here
  1223. POSITION pos;
  1224. pos = m_List1.GetFirstSelectedItemPosition();
  1225. if (pos == NULL)
  1226. {
  1227. AfxMessageBox("请先选中您要删除的照片!", MB_ICONINFORMATION);
  1228. return;
  1229. }
  1230. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  1231. CStringArray delarray;
  1232. //int nDelCount = 0; // Jeff add:被删除的相片数量;// 使用m_nDelCount成员变量;
  1233. CString strDelContent; // Jeff add:删除操作的日志内容;
  1234. //CStringArray strDelArray; // Jeff add:被删除的相片名称;
  1235. while (pos)
  1236. {
  1237. int iItem = m_List1.GetNextSelectedItem(pos);
  1238. CString title = m_List1.GetItemText(iItem, 0);
  1239. // log的内容字段长度有限,写不下这么多文字;
  1240. // 被删除的文件名不记录,只记录删除的张数;
  1241. ::DeleteFile(m_path + title + ".jpg"); // 删除jpg;
  1242. ::DeleteFile(m_path + title + ".NEF"); // 删除NEF;
  1243. ::DeleteFile(m_path + title + ".CR2"); // 删除CR2;
  1244. ::DeleteFile(m_path + title + ".raw"); // 删除raw;
  1245. m_nDelCount++;
  1246. int pos = title.ReverseFind('\\');
  1247. if (pos != -1)
  1248. {
  1249. ::DeleteFile(m_path + title.Left(pos + 1) + "s" + title.Right(title.GetLength() - pos - 1) + ".jpg"); // 删除s小图;
  1250. ::DeleteFile(m_path + title.Left(pos + 1) + "m" + title.Right(title.GetLength() - pos - 1) + ".jpg"); // 删除m小图;
  1251. }
  1252. else
  1253. {
  1254. ::DeleteFile(m_path + "s" + title + ".jpg"); // 删除s小图
  1255. ::DeleteFile(m_path + "m" + title + ".jpg"); // 删除m小图;
  1256. }
  1257. if (m_mode == 1 && g_branchname != "")
  1258. { //拍照,加景点
  1259. CString file2 = m_path + title;
  1260. int pos = file2.Find(m_id);
  1261. pos += m_id.GetLength();
  1262. int pos2 = file2.ReverseFind('\\');
  1263. CString jd;
  1264. if (pos2 > pos)
  1265. {
  1266. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  1267. }
  1268. CString task;
  1269. if (jd != "")
  1270. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  1271. else
  1272. task = file2.Right(file2.GetLength() - pos2 - 1);
  1273. delarray.Add(task);
  1274. }
  1275. else
  1276. {
  1277. delarray.Add(title);
  1278. }
  1279. }
  1280. LoadPhotos();
  1281. #if 1
  1282. CString str;
  1283. if (m_mode == 1)
  1284. str += "原片";
  1285. else if (m_mode == 2)
  1286. str += "初修片";
  1287. else if (m_mode == 3)
  1288. str += "精修片";
  1289. else if (m_mode == 5)
  1290. str += "设计片";
  1291. strDelContent.Format("删除%s, 订单号%s的%s:共删除%d张", m_name, m_id, str, m_nDelCount);
  1292. WriteLog("删除相片", strDelContent);
  1293. strDelContent = str;
  1294. #endif
  1295. if (delarray.GetSize() && g_branchname != "")
  1296. {
  1297. str.Format("是否同步删除分店 %s 的照片?", g_branchname);
  1298. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  1299. CString sql = "deletephotos";
  1300. if (m_mode == 1)//拍照
  1301. sql += "0";
  1302. else if (m_mode == 2)//初修
  1303. sql += "1";
  1304. else if (m_mode == 3)//精修
  1305. sql += "2";
  1306. else if (m_mode == 5)//设计
  1307. sql += "3";
  1308. sql += m_id;
  1309. sql += ";";
  1310. for (int i = 0; i < delarray.GetSize(); i++)
  1311. {
  1312. sql += delarray.ElementAt(i);
  1313. sql += ",";
  1314. }
  1315. g_sendhead.bsql = 1;
  1316. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  1317. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  1318. #if 1//Jeff add;
  1319. if (m_mode == 1)
  1320. str += "原片";
  1321. else if (m_mode == 2)
  1322. str += "初修片";
  1323. else if (m_mode == 3)
  1324. str += "精修片";
  1325. else if (m_mode == 5)
  1326. str += "设计片";
  1327. strDelContent.Format("客人%s,订单号%s的分店%s的%s被同步删除", m_name, m_id, g_branchname, str);
  1328. WriteLog("分店相片同步删除", strDelContent);
  1329. #endif
  1330. }
  1331. else if (delarray.GetSize() && m_branch != "")
  1332. {
  1333. if (GetBranchPhotoPath(m_branch) == "")return;
  1334. str.Format("是否同步删除分店 %s 的照片?", m_branch);
  1335. if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
  1336. CString sql = "deletephotos";
  1337. if (m_mode == 1)//拍照
  1338. sql += "0";
  1339. else if (m_mode == 2)//初修
  1340. sql += "1";
  1341. else if (m_mode == 3)//精修
  1342. sql += "2";
  1343. else if (m_mode == 5)//设计
  1344. sql += "3";
  1345. sql += m_id;
  1346. sql += ";";
  1347. for (int i = 0; i < delarray.GetSize(); i++)
  1348. {
  1349. sql += delarray.ElementAt(i);
  1350. sql += ",";
  1351. }
  1352. g_sendhead.bsql = 1;
  1353. g_branchip = GetIP(m_branch);
  1354. g_pMainWnd->OnDisconnect();
  1355. g_branchname = m_branch;
  1356. g_bBranchModify = 1;
  1357. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1358. g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
  1359. if (g_bSendOK == 0)return;
  1360. AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
  1361. #if 1//Jeff add;
  1362. if (m_mode == 1)
  1363. str += "原片";
  1364. else if (m_mode == 2)
  1365. str += "初修片";
  1366. else if (m_mode == 3)
  1367. str += "精修片";
  1368. else if (m_mode == 5)
  1369. str += "设计片";
  1370. strDelContent.Format("客人%s,订单号%s的分店%s的%s被同步删除", m_name, m_id, g_branchname, str);
  1371. WriteLog("分店相片同步删除", strDelContent);
  1372. #endif
  1373. }
  1374. #endif
  1375. }
  1376. extern void SaveTaskPath(CString path);
  1377. void ShowPic::OnBUTupload() //上传照片;
  1378. {
  1379. if (1)//g_branchname=="")
  1380. {
  1381. OnBUTupload2();
  1382. return;
  1383. }
  1384. // ZipTypeDlg dlg;
  1385. // dlg.DoModal ();
  1386. CString m_sel;
  1387. if (m_mode == 1)//拍照
  1388. {
  1389. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
  1390. }
  1391. else if (m_mode == 2)//初修
  1392. {
  1393. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
  1394. }
  1395. else if (m_mode == 3)//精修
  1396. {
  1397. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
  1398. }
  1399. else if (m_mode == 5)//设计
  1400. {
  1401. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
  1402. }
  1403. CStringArray m_uploadtaskarray;
  1404. m_uploadtaskarray.Add(m_id + ";" + m_name);
  1405. m_uploadtaskarray.Add("");
  1406. m_uploadtaskarray.Add("");
  1407. m_uploadtaskarray.Add(m_sel);
  1408. m_uploadtaskarray.Add("");
  1409. m_uploadtaskarray.Add("");
  1410. m_uploadtaskarray.Add("");
  1411. m_uploadtaskarray.Add("");
  1412. m_uploadtaskarray.Add("");
  1413. m_uploadtaskarray.Add("");
  1414. MyLock lock("uploadtaskaccess");
  1415. CFile fp;
  1416. CString pathdir = m_path + "uploadtask";
  1417. {
  1418. int pos = pathdir.Find(m_id);
  1419. pos += m_id.GetLength();
  1420. int pos2 = pathdir.ReverseFind('\\');
  1421. pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
  1422. }
  1423. CString path;
  1424. int taskpos = 1;
  1425. CStringArray m_olduploadtaskarray;
  1426. for (int i = 0; i < 200; i++)
  1427. {
  1428. path.Format("%s%d.dat", pathdir, i + 1);
  1429. if (PathFileExists(path))
  1430. {
  1431. CFile fp;
  1432. if (fp.Open(path, CFile::modeRead))
  1433. {
  1434. DWORD length = fp.GetLength();
  1435. if (!length)continue;
  1436. CStringArray m_array;
  1437. CArchive ar(&fp, CArchive::load);
  1438. m_array.Serialize(ar);
  1439. fp.Close();
  1440. for (int j = 10; j < m_array.GetSize(); j += 2)
  1441. {
  1442. m_olduploadtaskarray.Add(m_array.ElementAt(j));
  1443. }
  1444. }
  1445. }
  1446. }
  1447. BOOL bexist = 0;
  1448. POSITION pos;
  1449. pos = m_List1.GetFirstSelectedItemPosition();
  1450. if (pos == NULL)
  1451. {
  1452. AfxMessageBox("请选择您要上传的文件!"); return;
  1453. }
  1454. else
  1455. {
  1456. while (pos)
  1457. {
  1458. int iItem = m_List1.GetNextSelectedItem(pos);
  1459. CString title = m_List1.GetItemText(iItem, 0);
  1460. CString file2 = m_path + title + ".jpg";
  1461. if (m_mode == 1)
  1462. { //拍照,加景点
  1463. int pos = file2.Find(m_id);
  1464. pos += m_id.GetLength();
  1465. int pos2 = file2.ReverseFind('\\');
  1466. CString jd;
  1467. if (pos2 > pos)
  1468. {
  1469. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  1470. }
  1471. CString task;
  1472. if (jd != "")
  1473. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  1474. else
  1475. task = file2.Right(file2.GetLength() - pos2 - 1);
  1476. if (::FindArray(&m_olduploadtaskarray, task) == -1)
  1477. {
  1478. m_uploadtaskarray.Add(task);
  1479. m_uploadtaskarray.Add("");
  1480. }
  1481. else
  1482. bexist = 1;
  1483. }
  1484. else
  1485. {
  1486. if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
  1487. {
  1488. m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
  1489. m_uploadtaskarray.Add("");
  1490. }
  1491. else
  1492. bexist = 1;
  1493. }
  1494. }
  1495. }
  1496. if (m_uploadtaskarray.GetSize() > 10)
  1497. {
  1498. CFile fp;
  1499. CString path;
  1500. int taskpos = 1;
  1501. path.Format("%s%d.dat", pathdir, taskpos);
  1502. CString dir = path.Left(path.ReverseFind('\\') + 1);
  1503. pathdir = g_path1 + "\\上传任务\\";
  1504. ::CreateDirectory(pathdir, NULL);
  1505. path.Format("%s%d.dat", pathdir, taskpos);
  1506. while (PathFileExists(path))
  1507. {
  1508. taskpos++;
  1509. path.Format("%s%d.dat", pathdir, taskpos);
  1510. }
  1511. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  1512. CArchive ar(&fp, CArchive::store);
  1513. m_uploadtaskarray.SetAt(4, dir);
  1514. m_uploadtaskarray.Serialize(ar);
  1515. ar.Close();
  1516. fp.Close();
  1517. }
  1518. if (bexist)
  1519. AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
  1520. else
  1521. AfxMessageBox("保存上传任务成功!");
  1522. }
  1523. void ShowPic::OnBUTselall()
  1524. {
  1525. for (int i = 0; i < m_List1.GetItemCount(); i++)
  1526. m_List1.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
  1527. }
  1528. void ShowPic::OnSelchangeCombo2()
  1529. {
  1530. int pos = m_combobranch.GetCurSel();
  1531. if (pos == -1)return;
  1532. CString str;
  1533. m_combobranch.GetLBText(pos, str);
  1534. m_patharray1.RemoveAll();
  1535. m_vFileName.RemoveAll();
  1536. if (m_mode == 4)//礼服
  1537. {
  1538. m_type = str;
  1539. LoadPhotos();
  1540. return;
  1541. }
  1542. GetDlgItem(IDC_BUTupload)->SetWindowText("上传至" + str);
  1543. GetDlgItem(IDC_BUTupload)->Invalidate();
  1544. }
  1545. void ShowPic::OnBUTupload2()
  1546. {
  1547. int combopos = m_combobranch.GetCurSel();
  1548. if (combopos == -1)
  1549. {
  1550. AfxMessageBox("请选择您要上传到的分店!");
  1551. return;
  1552. }
  1553. CString domain = m_iparray.ElementAt(combopos);
  1554. CString savedomain;
  1555. if (m_branch != "")
  1556. {
  1557. savedomain = GetDomainFromBranch(m_branch);
  1558. }
  1559. else
  1560. {
  1561. savedomain = GetDomainFromBranch(g_branchname);
  1562. if (g_branchname == "")
  1563. savedomain = g_brancharray.ElementAt(g_brancharray.GetSize() - 1).ElementAt(2);
  1564. }
  1565. // ZipTypeDlg dlg;
  1566. // dlg.DoModal ();
  1567. CString m_sel;
  1568. if (m_mode == 1)//拍照
  1569. {
  1570. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
  1571. }
  1572. else if (m_mode == 2)//初修
  1573. {
  1574. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
  1575. }
  1576. else if (m_mode == 3)//精修
  1577. {
  1578. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
  1579. }
  1580. else if (m_mode == 5)//设计
  1581. {
  1582. m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
  1583. }
  1584. CStringArray m_uploadtaskarray;
  1585. m_uploadtaskarray.Add(m_id + ";" + m_name);
  1586. m_uploadtaskarray.Add(domain);
  1587. m_uploadtaskarray.Add(savedomain);
  1588. m_uploadtaskarray.Add(m_sel);
  1589. m_uploadtaskarray.Add("");
  1590. m_uploadtaskarray.Add("");
  1591. m_uploadtaskarray.Add("");
  1592. m_uploadtaskarray.Add("");
  1593. m_uploadtaskarray.Add("");
  1594. m_uploadtaskarray.Add("");
  1595. MyLock lock("uploadtaskaccess");
  1596. CFile fp;
  1597. CString pathdir = m_path + "uploadtask";
  1598. {
  1599. int pos = pathdir.Find(m_id);
  1600. pos += m_id.GetLength();
  1601. int pos2 = pathdir.ReverseFind('\\');
  1602. pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
  1603. }
  1604. CString path;
  1605. int taskpos = 1;
  1606. CStringArray m_olduploadtaskarray;
  1607. for (int i = 0; i < 200; i++)
  1608. {
  1609. path.Format("%s%d.dat", pathdir, i + 1);
  1610. if (PathFileExists(path))
  1611. {
  1612. CFile fp;
  1613. if (fp.Open(path, CFile::modeRead))
  1614. {
  1615. DWORD length = fp.GetLength();
  1616. if (!length)continue;
  1617. CStringArray m_array;
  1618. CArchive ar(&fp, CArchive::load);
  1619. m_array.Serialize(ar);
  1620. fp.Close();
  1621. if (domain != m_array.ElementAt(1))continue;
  1622. for (int j = 10; j < m_array.GetSize(); j += 2)
  1623. {
  1624. m_olduploadtaskarray.Add(m_array.ElementAt(j));
  1625. }
  1626. }
  1627. }
  1628. }
  1629. BOOL bexist = 0;
  1630. POSITION pos;
  1631. pos = m_List1.GetFirstSelectedItemPosition();
  1632. if (pos == NULL)
  1633. {
  1634. AfxMessageBox("请选择您要上传的文件!"); return;
  1635. }
  1636. else
  1637. {
  1638. while (pos)
  1639. {
  1640. int iItem = m_List1.GetNextSelectedItem(pos);
  1641. CString title = m_List1.GetItemText(iItem, 0);
  1642. CString file2 = m_path + title + ".jpg";
  1643. if (m_mode == 1)
  1644. { //拍照,加景点
  1645. int pos = file2.Find(m_id);
  1646. pos += m_id.GetLength();
  1647. int pos2 = file2.ReverseFind('\\');
  1648. CString jd;
  1649. if (pos2 > pos)
  1650. {
  1651. jd = file2.Mid(pos + 1, pos2 - pos - 1);
  1652. }
  1653. CString task;
  1654. if (jd != "")
  1655. task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
  1656. else
  1657. task = file2.Right(file2.GetLength() - pos2 - 1);
  1658. if (::FindArray(&m_olduploadtaskarray, task) == -1)
  1659. {
  1660. m_uploadtaskarray.Add(task);
  1661. m_uploadtaskarray.Add("");
  1662. }
  1663. else
  1664. bexist = 1;
  1665. }
  1666. else
  1667. {
  1668. if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
  1669. {
  1670. m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
  1671. m_uploadtaskarray.Add("");
  1672. }
  1673. else
  1674. bexist = 1;
  1675. }
  1676. }
  1677. }
  1678. if (m_uploadtaskarray.GetSize() > 10)
  1679. {
  1680. CFile fp;
  1681. CString path;
  1682. int taskpos = 1;
  1683. path.Format("%s%d.dat", pathdir, taskpos);
  1684. CString dir = path.Left(path.ReverseFind('\\') + 1);
  1685. pathdir = g_path1 + "\\上传任务\\";
  1686. ::CreateDirectory(pathdir, NULL);
  1687. path.Format("%s%d.dat", pathdir, taskpos);
  1688. while (PathFileExists(path))
  1689. {
  1690. taskpos++;
  1691. path.Format("%s%d.dat", pathdir, taskpos);
  1692. }
  1693. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  1694. CArchive ar(&fp, CArchive::store);
  1695. m_uploadtaskarray.SetAt(4, dir);
  1696. m_uploadtaskarray.Serialize(ar);
  1697. ar.Close();
  1698. fp.Close();
  1699. // SaveTaskPath(path);
  1700. }
  1701. if (bexist)
  1702. AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
  1703. else
  1704. AfxMessageBox("保存上传任务成功!");
  1705. }
  1706. void ShowPic::OnBUTSetDesignNo()
  1707. {
  1708. SetDesignNo dlg;
  1709. dlg.m_id = m_id;
  1710. dlg.DoModal();
  1711. }
  1712. void ShowPic::OnBUTexport() // 只有在设计时,才会有这个导出相片按钮;
  1713. {
  1714. if (IsHasRights2new(12) == 0)return;
  1715. POSITION pos;
  1716. pos = m_List1.GetFirstSelectedItemPosition();
  1717. if (pos == NULL)
  1718. {
  1719. AfxMessageBox("请先选中您要导出的照片!", MB_ICONINFORMATION);
  1720. return;
  1721. }
  1722. CStringArray saExportImage; // 被导出的相片路径数组;
  1723. CString strExportDirectory; // 相片导出的路径;
  1724. GetSavePath(strExportDirectory);
  1725. if (strExportDirectory.IsEmpty())
  1726. {
  1727. return;
  1728. }
  1729. strExportDirectory.TrimRight('\\');
  1730. strExportDirectory += "\\";
  1731. strExportDirectory += m_id;
  1732. strExportDirectory += m_name2;
  1733. strExportDirectory += "设计好的片修";
  1734. strExportDirectory += "\\";
  1735. ::CreateDirectory(strExportDirectory, NULL);
  1736. CStringArray desarray;
  1737. CStringArray dirarray;
  1738. CString str, str2;
  1739. int pos2;
  1740. while (pos)
  1741. {
  1742. int iItem = m_List1.GetNextSelectedItem(pos);
  1743. str = m_List1.GetItemText(iItem, 0);
  1744. str = m_path + str + ".jpg";
  1745. saExportImage.Add(str);
  1746. str2 = strExportDirectory + m_List1.GetItemText(iItem, 0) + ".jpg";
  1747. desarray.Add(str2);
  1748. str2 = "";
  1749. str = m_List1.GetItemText(iItem, 0);
  1750. pos2 = str.Find("\\");
  1751. while (pos2 != -1)
  1752. {
  1753. str2 += str.Left(pos2) + "\\";
  1754. if (::FindArray(&dirarray, str2) == -1)
  1755. {
  1756. dirarray.Add(str2);
  1757. ::CreateDirectory(strExportDirectory + str2, NULL);
  1758. }
  1759. str = str.Right(str.GetLength() - pos2 - 1);
  1760. pos2 = str.Find("\\");
  1761. }
  1762. }
  1763. CStdioFile fp;
  1764. fp.Open(strExportDirectory + "客户要求.txt", CFile::modeCreate | CFile::modeWrite);
  1765. fp.WriteString(remark);
  1766. fp.Close();
  1767. //----------------------------------------------------------------------------------------------
  1768. //----------------------------------------------------------------------------------------------
  1769. // 在设计时,导出查看的设计片;
  1770. //----------------------------------------------------------------------------------------------
  1771. //----------------------------------------------------------------------------------------------
  1772. ImportPhoto dlg;
  1773. dlg.m_mode = 1; // 1.未知;
  1774. dlg.m_pArray = &saExportImage; // 2.作为导出源的设计片的路径集合;
  1775. dlg.m_pDesArray = &desarray; // 3.作为导出目标的设计片的路径集合;
  1776. dlg.m_savepath = strExportDirectory; // 4.保存导出查看的设计片的目录;
  1777. dlg.DoModal();
  1778. AfxMessageBox("导片成功!", MB_ICONINFORMATION);
  1779. // CString str;
  1780. str = " 导出设计片 ";
  1781. str += "客人:";
  1782. str += m_name + m_id;
  1783. WriteLog("导出设计片", str);
  1784. }
  1785. /************************************************************************/
  1786. /*
  1787. 函数:OnButRefreshPhotos
  1788. 描述:刷新相片s和m图
  1789. 参数:
  1790. 返回:
  1791. */
  1792. /************************************************************************/
  1793. void ShowPic::OnButRefreshPhotos()
  1794. {
  1795. #if 0
  1796. TerminateRefreshTh();
  1797. if(m_hRefExitEvent == NULL)
  1798. m_hRefExitEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
  1799. unsigned int dwID = 0;
  1800. m_hThreadRef = (HANDLE)_beginthreadex(NULL, 0, RefreshThFun, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &dwID);
  1801. #else
  1802. CDlgImgThumbnail dlg;
  1803. dlg.m_AryImages.Copy(m_vFileName);
  1804. dlg.DoModal();
  1805. if ( dlg.m_bFinshThumbnail )
  1806. {
  1807. AfxMessageBox(_T("生成小图完成!"));
  1808. }
  1809. LoadThumbImages();
  1810. #endif
  1811. }
  1812. #if USE_SHARE_FLORD
  1813. /************************************************************************/
  1814. /*
  1815. 函数:GetAllSelectImage
  1816. 描述:获取List控件中选中的全部项;
  1817. 参数:
  1818. OUT: strAry,返回选中项名称;
  1819. 返回:
  1820. 注意:
  1821. 调用约定:
  1822. */
  1823. /************************************************************************/
  1824. void ShowPic::GetAllSelectImage(OUT CStringArray &strAry)
  1825. {
  1826. strAry.RemoveAll();
  1827. POSITION pos = m_List1.GetFirstSelectedItemPosition();
  1828. if( pos == NULL)
  1829. {
  1830. AfxMessageBox("请先选中您要删除的照片!", MB_ICONINFORMATION);
  1831. return;
  1832. }
  1833. if( AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO|MB_ICONSTOP ) != IDYES ) return;
  1834. int nItem = 0;
  1835. CString strImage = _T("");
  1836. while( pos )
  1837. {
  1838. nItem = m_List1.GetNextSelectedItem( pos );
  1839. strAry.Add(m_List1.GetItemText(nItem, 0));
  1840. }
  1841. }
  1842. #endif