12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763 |
- // ShowPic.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "ShowPic.h"
- #include "ShowPic22.h"
- #include "ImportPhoto.h"
- #include "JPEG.h"
- #include "MyLock.h"
- #include "ZipTypeDlg.h"
- #include "SetDesignNo.h"
- #include "NetShareInfo.h"
- #define THUMBNAIL_WIDTH 100
- #define THUMBNAIL_HEIGHT 90
- unsigned __stdcall RefreshWork(LPVOID lpParam);
- /////////////////////////////////////////////////////////////////////////////
- // ShowPic dialog IDC_BU IDC_COMBO2
- ShowPic::ShowPic(CWnd* pParent /*=NULL*/): CDialog(ShowPic::IDD, pParent)
- {
- m_branchname = _T("");
- m_bRunning = false;
- m_bExit = FALSE;
- m_hThread = NULL;
- m_mode = 0;
- m_bdelall = 0;
- m_nDelCount = 0;
- m_hRefExitEvent = NULL;
- m_hThreadRef = NULL;
- //m_hEvent = NULL;
- }
- void ShowPic::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(ShowPic)
- DDX_Control(pDX, IDC_COMBO2, m_combobranch);
- DDX_Control(pDX, IDC_LIST1, m_List1);
- DDX_Control(pDX, IDC_COMBO1, m_combo1);
- DDX_CBString(pDX, IDC_COMBO2, m_branchname);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(ShowPic, CDialog)
- //{{AFX_MSG_MAP(ShowPic)
- ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
- ON_WM_DESTROY()
- ON_BN_CLICKED(IDC_BUTdelall, OnBUTdelall)
- ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
- ON_BN_CLICKED(IDC_BUTupload, OnBUTupload)
- ON_BN_CLICKED(IDC_BUTselall, OnBUTselall)
- ON_CBN_SELCHANGE(IDC_COMBO2, OnSelchangeCombo2)
- ON_BN_CLICKED(IDC_BUTSetDesignNo, OnBUTSetDesignNo)
- ON_BN_CLICKED(IDC_BUTexport, OnBUTexport)
- ON_BN_CLICKED(IDC_BUT_RefreshPhotos, OnButRefreshPhotos)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // ShowPic message handlers
- BOOL ShowPic::OnInitDialog()
- {
- CDialog::OnInitDialog();
- m_id.MakeLower();
- CRect rc2;
- GetWindowRect(rc2);
- ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
- EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
- GetDlgItem(IDOK)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- int hei = rc2.Height();
- GetClientRect(rc2);
- rc2.top = hei + 10;
- m_List1.MoveWindow(rc2);
- int right = rc2.right;
- //关闭
- GetDlgItem(IDOK)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- int dtx = right - rc2.right - 5;
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- rc2.left += dtx;
- rc2.right += dtx;
- GetDlgItem(IDOK)->MoveWindow(rc2);
- //删除
- GetDlgItem(IDC_BUTdel)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- rc2.left += dtx;
- rc2.right += dtx;
- GetDlgItem(IDC_BUTdel)->MoveWindow(rc2);
- //全部删除
- GetDlgItem(IDC_BUTdelall)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- rc2.left += dtx;
- rc2.right += dtx;
- GetDlgItem(IDC_BUTdelall)->MoveWindow(rc2);
- CRect tmpRt(rc2);
- GetDlgItem(IDC_BUTSetDesignNo)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- rc2.left += dtx;
- rc2.right += dtx;
- GetDlgItem(IDC_BUTSetDesignNo)->MoveWindow(rc2);
- GetDlgItem(IDC_BUTexport)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- rc2.left += dtx;
- rc2.right += dtx;
- GetDlgItem(IDC_BUTexport)->MoveWindow(rc2);
- //刷新按钮
- CRect refeshRt(0, 0, 0, 0);
- GetDlgItem(IDC_BUT_RefreshPhotos)->GetWindowRect(refeshRt);
- //设计
- if(m_mode == 5)
- tmpRt = rc2;
- int nWide = refeshRt.right - refeshRt.left;
- tmpRt.left = tmpRt.left - nWide - 5;
- tmpRt.right = tmpRt.left + nWide;
- GetDlgItem(IDC_BUT_RefreshPhotos)->MoveWindow(tmpRt);
- //////////////////////////////////////////////////////////
- GetDlgItem(IDC_BUTupload)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- GetDlgItem(IDC_BUTupload)->MoveWindow(rc2);
- GetDlgItem(IDC_BUTselall)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- GetDlgItem(IDC_BUTselall)->MoveWindow(rc2);
- GetDlgItem(IDC_COMBO2)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei + 300;
- GetDlgItem(IDC_COMBO2)->MoveWindow(rc2);
- m_combobranch.ShowWindow(0);
- if (g_branchname == "")
- {
- GetDlgItem(IDC_BUTupload)->ShowWindow(0);
- GetDlgItem(IDC_BUTselall)->ShowWindow(0);
- }
- // else
- // GetDlgItem(IDC_BUTupload)->SetWindowText("上传至"+g_branchname);
- int i = 0;
- #ifdef ENTERPRISE_VERSION
- if (1)//g_branchname=="")
- {
- m_combobranch.ShowWindow(1);
- for ( i = 0; i < g_brancharray.GetSize() - 1; i++)
- {
- if (m_iparray.GetSize())
- {
- if (g_brancharray.ElementAt(i).ElementAt(2) == m_iparray.ElementAt(m_iparray.GetSize() - 1))continue;
- }
- m_combobranch.AddString(g_brancharray.ElementAt(i).ElementAt(0));
- m_iparray.Add(g_brancharray.ElementAt(i).ElementAt(2));
- }
- GetDlgItem(IDC_BUTupload)->ShowWindow(1);
- GetDlgItem(IDC_BUTselall)->ShowWindow(1);
- }
- #endif
- if (m_mode == 1 && IsHasRights2new(4) == 0)//拍照
- {
- GetDlgItem(IDC_BUTupload)->ShowWindow(0);
- GetDlgItem(IDC_BUTselall)->ShowWindow(0);
- }
- if (m_mode == 2 && IsHasRights2new(5) == 0)
- {
- GetDlgItem(IDC_BUTupload)->ShowWindow(0);
- GetDlgItem(IDC_BUTselall)->ShowWindow(0);
- }
- if (m_mode == 3 && IsHasRights2new(6) == 0)
- {
- GetDlgItem(IDC_BUTupload)->ShowWindow(0);
- GetDlgItem(IDC_BUTselall)->ShowWindow(0);
- }
- if (m_mode == 5 && IsHasRights2new(7) == 0)
- {
- GetDlgItem(IDC_BUTupload)->ShowWindow(0);
- GetDlgItem(IDC_BUTselall)->ShowWindow(0);
- }
- if (m_mode == 4)//礼服
- {
- GetDlgItem(IDC_BUTupload)->ShowWindow(0);
- GetDlgItem(IDC_BUTselall)->ShowWindow(0);
- }
- if (m_mode == 1)//拍照
- {
- GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(34));
- GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(34));
- }
- else if (m_mode == 2)//初修
- {
- GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(35));
- GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(35));
- }
- else if (m_mode == 3)//精修
- {
- GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(36));
- GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(36));
- }
- else if (m_mode == 5)//设计
- {
- GetDlgItem(IDC_BUTdelall)->EnableWindow(IsHasRights2new(37));
- GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(37));
- GetDlgItem(IDC_BUTSetDesignNo)->EnableWindow(IsHasRights2new(7));
- GetDlgItem(IDC_BUTSetDesignNo)->ShowWindow(SW_SHOW);
- GetDlgItem(IDC_BUTexport)->EnableWindow(IsHasRights2new(12));
- GetDlgItem(IDC_BUTexport)->ShowWindow(SW_SHOW);
- }
- else if (m_mode == 4)//礼服
- {
- SetWindowText("礼服查看");
- GetDlgItem(IDC_BUTdelall)->EnableWindow(0);
- GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(43));
- m_combobranch.ShowWindow(1);
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 72;
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(0);
- if (g_bSendOK == 0)
- {
- CDialog::OnCancel();
- return 0;
- }
- DataToArray(&m_List1array);
- CStringArray typearray;
- for ( i = 0; i < m_List1array.GetSize(); i++)
- {
- if (-1 == ::FindArray(&typearray, m_List1array.ElementAt(i).ElementAt(0)))
- typearray.Add(m_List1array.ElementAt(i).ElementAt(0));
- }
- m_combobranch.AddString("全部");
- for (i = 0; i < typearray.GetSize(); i++)
- {
- m_combobranch.AddString(typearray.ElementAt(i));
- }
- m_combobranch.SetCurSel(0);
- }
- m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
- m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
- LoadPhotos();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- DWORD ShowPic::LoadThumbNail(LPVOID lpParam)
- {
- try
- {
- ShowPic *pDlg = (ShowPic*)lpParam;
- CListCtrl *ListCtrl = &pDlg->m_List1;
- CImageList* pImgList = &pDlg->m_ImageListThumb;
- for (int i = 0; !pDlg->m_bExit && i < pImgList->GetImageCount(); i++)
- pImgList->Remove(i);
- ListCtrl->DeleteAllItems();
- pImgList->SetImageCount(pDlg->m_vFileName.GetSize());
- TCHAR path[MAX_PATH] = {0};
- vector<CString>::iterator iter;
- // Set redraw to FALSE to avoid flickering during adding new items
- ListCtrl->SetRedraw(FALSE);
- int nIndex = 0;
- INT xIndex = 0;
- for (nIndex = 0; !pDlg->m_bExit && nIndex < pDlg->m_vFileName.GetSize(); nIndex++)
- {
- // str和spath放在线程的for循环外面,会内存泄漏,原因未明;
- CString str = pDlg->m_vFileName.ElementAt(nIndex);
- CString spath = _T("");
- #ifdef USE_KERNEL_DLL
- xIndex = str.Find(pDlg->m_id);
- if ( xIndex != -1 )
- {
- str = str.Mid( xIndex + pDlg->m_id.GetLength() + 1);
- xIndex = str.ReverseFind(_T('.'));
- if ( xIndex != -1 )
- str = str.Left(xIndex);
- }
- #else
- int nPos = str.Find(pDlg->m_id);
- if(nPos == -1)
- continue;
- CString strLeft = str.Left(nPos + pDlg->m_id.GetLength() + 1);
- str = str.Right((str.GetLength() - strLeft.GetLength()));
- str = str.Left(str.ReverseFind('.'));
- #endif
- ListCtrl->InsertItem(nIndex, str, nIndex);
- }
- if ( pDlg->m_bExit )
- {
- pDlg->m_bRunning = false;
- pDlg->m_bExit = false;
- return 0;
- }
- ListCtrl->SetRedraw(TRUE);
- ListCtrl->Invalidate();
- const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;
- int XDest, YDest, nDestWidth, nDestHeight;
- nIndex = 0;
- SolidBrush whitebrush(Color(255, 255, 255, 255));
- for (nIndex = 0; !pDlg->m_bExit && nIndex < pDlg->m_vFileName.GetSize(); nIndex++)
- {
- // Load Image File
- Image *image = NULL;
- Bitmap *pBmp = NULL;
- CString str = pDlg->m_vFileName.ElementAt(nIndex);
- CString spath = str.Left(str.ReverseFind('\\') + 1);
- spath += "s";
- spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- if (PathFileExists(spath))
- ::LoadImageFromBuf(&image, spath);
- else
- {
- str.MakeLower();
- if (str.Right(3) != "jpg")continue;
- ::LoadImageFromBuf(&image, str);
- }
- if (image == NULL)continue;
- int orientation = GetOrientation(image);
- if (orientation == 8)
- image->RotateFlip(Rotate270FlipNone);
- else if (orientation == 6)
- image->RotateFlip(Rotate90FlipNone);
- if (image->GetWidth() == 0)
- continue;
- // Calculate Rect to fit to canvas
- const float fImgRatio = (float)image->GetHeight() / image->GetWidth();
- if (fImgRatio > fRatio)
- {
- nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
- XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
- YDest = 0;
- nDestHeight = THUMBNAIL_HEIGHT;
- }
- else
- {
- XDest = 0;
- nDestWidth = THUMBNAIL_WIDTH;
- nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
- YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
- }
- pBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
- Graphics graph2(pBmp);
- graph2.Clear(Color(255, 192, 192, 192));
- graph2.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH - 2, THUMBNAIL_HEIGHT - 2);
- Graphics graph(pBmp);
- Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
- // Draw Image
- graph.DrawImage(image, desRect, 0, 0, image->GetWidth(), image->GetHeight(), UnitPixel);
- delete image;
- // Attach to Bitmap and Replace image in CImageList
- CBitmap bitmap;
- HBITMAP hbmp;
- pBmp->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
- bitmap.Attach(hbmp);
- pImgList->Replace(nIndex, &bitmap, NULL);
- delete pBmp;
- // Redraw only a current item for removing flickering and fast speed.
- ListCtrl->RedrawItems(nIndex, nIndex);
- }
- if (!pDlg->m_bExit)
- ListCtrl->Invalidate();
- pDlg->m_bRunning = false;
- pDlg->m_bExit = false;
- return 0;
- }
- catch (...)
- {
- }
- return 0;
- }
- /************************************************************************/
- /*
- 函数:TerminateRefreshTh
- 描述:结束刷新图片线程
- 参数:
- 返回:
- */
- /************************************************************************/
- BOOL ShowPic::TerminateRefreshTh()
- {
- //设为有信号
- if(m_hRefExitEvent)
- SetEvent(m_hRefExitEvent);
- //等待线程结束
- if(m_hThreadRef)
- WaitForSingleObject(m_hThreadRef, INFINITE);
- if(m_hRefExitEvent)
- {
- ::CloseHandle(m_hRefExitEvent);
- m_hRefExitEvent = NULL;
- }
- if(m_hThreadRef)
- {
- ::CloseHandle(m_hThreadRef);
- m_hThreadRef = NULL;
- }
- return TRUE;
- }
- /************************************************************************/
- /*
- 函数:RefreshThFun
- 描述:刷新
- 参数:
- 返回:
- */
- /************************************************************************/
- void ShowPic::RefreshWork()
- {
- BOOL bFinish = TRUE;
- for(int i=0; i<m_patharray1.GetSize(); i++)
- {
- // 等待退出信号;
- if(m_hRefExitEvent && WaitForSingleObject(m_hRefExitEvent, 0) == WAIT_OBJECT_0)
- {
- bFinish = FALSE;
- break;
- }
- CString str = m_patharray1.ElementAt(i);
- CString spath = str.Left(str.ReverseFind('\\') + 1);
- spath += "s";
- spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- if(!::PathFileExists(spath))
- ImgThumbnail(m_patharray1.ElementAt(i), SET_PIX(100, 76), spath, 100);
- spath = str.Left(str.ReverseFind('\\') + 1);
- spath += "m";
- spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- if(!::PathFileExists(spath))
- ImgThumbnail(m_patharray1.ElementAt(i), SET_PIX(2000, 1500), spath, 100);
- }
- if(bFinish)
- {
- MessageBox(_T("刷新完成"));
- LoadThumbImages();
- }
- }
- /************************************************************************/
- /*
- 函数:RefreshThFun
- 描述:线程函数
- 参数:
- 返回:
- */
- /************************************************************************/
- unsigned __stdcall RefreshThFun(LPVOID lpParam)
- {
- ShowPic* p = (ShowPic*)lpParam;
- try
- {
- p->RefreshWork();
- return 0;
- }
- catch (CException* e)
- {
- return 0;
- }
- }
- void ShowPic::LoadThumbImages()
- {
- ExitLoadThread();
- m_hThread = CreateThread(NULL, 0, LoadThumbNail, this, 0, NULL);
- if( m_hThread )
- {
- m_bRunning = true;
- }
- }
- BOOL ShowPic::ExitLoadThread()
- {
- if ( m_bRunning ) m_bExit = true;
- if ( m_hThread )
- {
- while( WaitForSingleObject(m_hThread,0) == WAIT_OBJECT_0 )
- {
- Sleep(100); // 由于该线程内容调用到各种主线程的窗口事件,所以不能死等,必须Sleep以保持主窗口线程鲜活;
- break;
- }
- CloseHandle(m_hThread);
- m_hThread = NULL;
- }
- return TRUE;
- }
- void ShowPic::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
- {
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- return;
- }
- int iItem = m_List1.GetNextSelectedItem(pos);
- ShowPic22 dlg;
- dlg.m_nCurImgPos = iItem;
- dlg.m_AryOfImgPath = &m_patharray1;
- dlg.DoModal();
- *pResult = 0;
- }
- void ShowPic::OnDestroy()
- {
- m_bExit = true;
- ExitLoadThread();
- TerminateRefreshTh();
- CDialog::OnDestroy();
- }
- void ShowPic::LoadPhotos()
- {
- #ifdef USE_KERNEL_DLL
- if ( m_mode == 4 )
- {// 礼服;
- CString str = _T("");
- CString savepath = g_path5 + _T("\\");
- for (int i = 0; i < m_List1array.GetSize(); i++)
- {
- if (m_type != _T("") && m_type != _T("全部") && m_type != m_List1array.ElementAt(i).ElementAt(0))
- continue;
- CString str = savepath + m_List1array.ElementAt(i).ElementAt(1) + _T(".jpg");
- if ( PathFileExists(str) )
- m_patharray1.Add(str);
- }
- return;
- }
- // 非礼服,原片、初修片、精修片、设计片;
- INT nImgType = m_mode;
- if ( m_mode == 5)
- nImgType--;
- CStringArray AryLoadExtImgpath;
- CStringArray AryWithExtImgpath;
- CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname);
- if ( GetOrderImgpathEx(nImgType, strBranchId, m_id, TRUE, _T("*.jpg|*.jpeg"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, m_aryOfShareDirectory))
- {
- INT i = 0;
- CString str;
- m_patharray1.RemoveAll();
- CString strfilename;
- INT nSize = AryLoadExtImgpath.GetSize();
- for (i = 0; i < nSize; i++ )
- {
- str = AryLoadExtImgpath.ElementAt(i);
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- str.MakeLower();
- if (!g_bOriginal && m_mode == 1) // 拍照;
- {
- strfilename = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- if (strfilename.Find(_T(".")) != -1)
- strfilename = strfilename.Left(strfilename.Find(_T(".")));
- // 若只是用于系统数字编号的,可以使用Isdigit来判断相片编号是否为数字编号;
- if ( !myisdigit(strfilename) )
- continue;
- }
- m_patharray1.Add(str);
- }
- if (m_bRunning)return;
- CStringArray *pArray = &m_patharray1;
- m_vFileName.RemoveAll();
- for ( i = 0; i < pArray->GetSize(); i++)
- {
- CString filePath = pArray->ElementAt(i);
- filePath.MakeLower();
- m_vFileName.Add(filePath);
- }
- LoadThumbImages();
- }
- #else
- m_patharray1.RemoveAll();
- m_path.MakeLower();
- CStringArray dirarray;
- CString str;
- if (m_mode == 4)//礼服
- {
- CString savepath = g_path5 + "\\";
- for (int i = 0; i < m_List1array.GetSize(); i++)
- {
- if (m_type != "" && m_type != "全部" && m_type != m_List1array.ElementAt(i).ElementAt(0))
- continue;
- // str=savepath+"s"+m_List1array.ElementAt (i).ElementAt (1)+".jpg";
- str = savepath + m_List1array.ElementAt(i).ElementAt(1) + ".jpg";
- if (::PathFileExists(str))
- m_patharray1.Add(str);
- }
- }
- else
- {
- #if USE_SHARE_FLORD // 多级共享目录查看相片;
- int nPhotoType = m_mode;
- if ( m_mode == 5)
- nPhotoType--;
- // 根据域名,相片类型,订单号查找相片;
- //LoadPhotos(nPhotoType, m_id, m_branch);
- m_aryOfShareDirectory.RemoveAll();
- CNetShareInfo::GetInstance()->LoadOrderImages(nPhotoType, m_id, m_branch, m_patharray1, &m_aryOfShareDirectory);
- #else
- if (1)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(m_path), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- // 1.获得所有子文件夹;
- coo = o.co_dir();
- for (it = coo.begin();coo.end() != it;it++)
- {
- str = (*it).c_str();
- if (FindArray(&dirarray, str) == -1)
- {
- dirarray.Add(str);
- }
- }
- }
- if (1)
- {
- CString filename;
- for (int i = 0; i < dirarray.GetSize(); i++)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(0);
- if (m_mode == 1)//拍照
- o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.*"));
- else
- o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- // 2.获得所有子文件夹下的文件;
- coo = o.co_file();
- for (it = coo.begin();coo.end() != it;it++)
- {
- str = (*it).c_str();
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- str.MakeLower();
- if (m_mode == 1)//拍照
- {
- filename = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- if (filename.Find(".") != -1)
- filename = filename.Left(filename.Find("."));
- if (!myisdigit(filename))continue;
- }
- m_patharray1.Add(str);
- }
- }
- }
- #endif
- }
- if (m_bRunning)return;
- CStringArray *pArray = &m_patharray1;
- m_vFileName.clear();
- for (int i = 0; i < pArray->GetSize(); i++)
- {
- CString filePath = pArray->ElementAt(i);
- filePath.MakeLower();
- m_vFileName.push_back(filePath);
- }
- LoadThumbImages();
- #endif
- }
- void ShowPic::OnBUTdelall() // 全部删除按钮;
- {
- // TODO: Add your control notification handler code here
- if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
- #if USE_SHARE_FLORD // 2015.04.13
- // 删除多级共享目录下的全部订单相片;
- int nSize = m_aryOfShareDirectory.GetSize();
- for ( int i = 0; i < nSize; i++)
- {
- DeleteDirectory(m_aryOfShareDirectory.ElementAt(i));
- }
- LoadPhotos();
- #else
- CString path = m_path;
- path.TrimRight('\\');
- DeleteDirectory(path); // 递归删除全部查看的jpg:
- LoadPhotos();
- #endif
- if (m_mode == 1)
- {
- CString sql;
- sql = "update dindan set [curno]='1' where [id]='" + m_id + "'";
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- m_bdelall = 1;
- }
- #if 1
- CString str;
- str = "清除";
- str += m_name;
- str += m_id;
- str += "全部";//Jeff.add;
- if (m_mode == 1)
- str += "原片";
- else if (m_mode == 2)
- str += "初修片";
- else if (m_mode == 3)
- str += "精修片";
- else if (m_mode == 5)
- str += "设计片";
- WriteLog("清除订单相片", str);
- #endif
- if (g_branchname != "")
- {
- str.Format("是否同步删除分店 %s 的照片?", g_branchname);
- if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
- CString sql = "deletephotos";
- if (m_mode == 1)//拍照
- sql += "0";
- else if (m_mode == 2)//初修
- sql += "1";
- else if (m_mode == 3)//精修
- sql += "2";
- else if (m_mode == 5)//设计
- sql += "3";
- sql += m_id;
- sql += ";";
- CString jd;
- if (m_mode == 1)
- { //拍照,加景点
- CString file2 = m_path;
- int pos = file2.Find(m_id);
- pos += m_id.GetLength();
- int pos2 = file2.ReverseFind('\\');
- if (pos2 > pos)
- {
- jd = file2.Mid(pos + 1, pos2 - pos - 1);
- }
- }
- sql += "all";
- sql += jd;
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
- AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
- #if 1//Jeff add;
- CString strDelContent;
- if (m_mode == 1)
- str += "原片";
- else if (m_mode == 2)
- str += "初修片";
- else if (m_mode == 3)
- str += "精修片";
- else if (m_mode == 5)
- str += "设计片";
- strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
- WriteLog("删除分店照片", strDelContent);
- #endif
- }
- else if (m_branch != "")
- {
- if (GetBranchPhotoPath(m_branch) == "")return;
- str.Format("是否同步删除分店 %s 的照片?", m_branch);
- if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
- CString sql = "deletephotos";
- if (m_mode == 1)//拍照
- sql += "0";
- else if (m_mode == 2)//初修
- sql += "1";
- else if (m_mode == 3)//精修
- sql += "2";
- else if (m_mode == 5)//设计
- sql += "3";
- sql += m_id;
- sql += ";";
- CString jd;
- if (m_mode == 1)
- { //拍照,加景点
- CString file2 = m_path;
- int pos = file2.Find(m_id);
- pos += m_id.GetLength();
- int pos2 = file2.ReverseFind('\\');
- if (pos2 > pos)
- {
- jd = file2.Mid(pos + 1, pos2 - pos - 1);
- }
- }
- sql += "all";
- sql += jd;
- g_sendhead.bsql = 1;
- g_branchip = GetIP(m_branch);
- g_pMainWnd->OnDisconnect();
- g_branchname = m_branch;
- g_bBranchModify = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
- if (g_bSendOK == 0)return;
- AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
- #if 1//Jeff add;
- CString strDelContent;
- if (m_mode == 1)
- str += "原片";
- else if (m_mode == 2)
- str += "初修片";
- else if (m_mode == 3)
- str += "精修片";
- else if (m_mode == 5)
- str += "设计片";
- strDelContent.Format("客人%s,订单号%s的分店%s的全部%s被同步删除", m_name, m_id, g_branchname, str);
- WriteLog("删除分店照片", strDelContent);
- #endif
- }
- }
- void ShowPic::OnBUTdel() // 删除按钮;
- {
- #if USE_SHARE_FLORD
- // 获取list列表中选中的相片集合;
- CStringArray delarray;
- GetAllSelectImage(delarray);
- int nPhotoType = m_mode;
- if ( m_mode == 5)
- {
- nPhotoType--;
- }
- CString strDomain;
- CStringArray strAryOfDeleted;
- if ( !m_branch.IsEmpty() )
- {
- strDomain = GetDomainFromBranch(m_branch);
- }
- else
- {
- strDomain = g_branchname;
- }
- int i = 0;
- for(i = 0; i<delarray.GetSize(); i++)
- {
- for ( int nIndex = 0; nIndex < m_vFileName.GetSize(); nIndex++)
- {
- CString str = m_vFileName.ElementAt(nIndex);
- if(str != _T(""))
- {
- CString strdel = delarray.ElementAt(i);
- strdel.TrimLeft(_T("\\"));
- strdel.TrimRight(_T("\\"));
- strdel = strdel.Right(strdel.GetLength() - strdel.ReverseFind('\\') - 1);
- str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- str = str.Left(str.Find(_T(".")));
- if(str.CompareNoCase(strdel) == 0)
- strAryOfDeleted.Add(m_vFileName.ElementAt(nIndex));
- }
- }
- }
- int nDelCount = strAryOfDeleted.GetSize();
- //////////////////////////////////////////////////////////////////////////
- // 删除已找到的相片文件;
- CString strTemp;
- for ( int n = 0; n < nDelCount; n++)
- {
- // 删除原相片;
- strTemp = strAryOfDeleted.ElementAt(n);
- DeleteFile(strTemp);
- strTemp.MakeLower();
- strTemp.Replace(_T(".jpg"),_T(".nef"));
- DeleteFile(strTemp);
- strTemp.Replace(_T(".nef"),_T(".cr2"));
- DeleteFile(strTemp);
- strTemp.Replace(_T(".cr2"),_T(".raw"));
- DeleteFile(strTemp);
- strTemp.Replace(_T(".raw"),_T(".jpg"));
- // 再删除s+m缩略图;
- CString strAblum;
- CString strLeft, strRight;
- int nIndex = strTemp.ReverseFind('\\');
- strLeft = strTemp.Left( nIndex + 1 );
- strRight = strTemp.Mid( nIndex + 1);
- strAblum.Format("%ss%s",strLeft,strRight);
- DeleteFile(strAblum);
- strAblum.Format("%sm%s",strLeft,strRight);
- DeleteFile(strAblum);
- // 若是原片,则要删除原片目录下的上传任务;
- if ( m_mode == 1 && !g_branchname.IsEmpty() )
- {
- // 暂时空处理,此处逻辑未明确;
- }
- }
- // 重新加载相片;
- LoadPhotos();
- // 写删除日志;
- switch( m_mode )
- {
- case 1:
- strTemp.Format("删除<%s>订单<%s>的原片%d张",m_name,m_id,nDelCount);
- break;
- case 2:
- strTemp.Format("删除<%s>订单<%s>的初修片%d张",m_name,m_id,nDelCount);
- break;
- case 3:
- strTemp.Format("删除<%s>订单<%s>的精修片%d张",m_name,m_id,nDelCount);
- break;
- case 5:
- strTemp.Format("删除<%s>订单<%s>的设计片%d张",m_name,m_id,nDelCount);
- break;
- default:
- break;
- }
- WriteLog("删除订单相片", strTemp);
- // 当连接分店时,除了删除本店的相片外,还要删除外网分店的相片;
- if ( !g_branchname.IsEmpty() && strAryOfDeleted.GetSize() )
- {
- strTemp.Format("是否同步删除分店 %s 的照片?", g_branchname);
- if( AfxMessageBox(strTemp, MB_YESNO|MB_ICONSTOP) != IDYES )
- return;
- strTemp = "deletephotos";
- if( m_mode == 1 )
- strTemp += "0";
- else if( m_mode == 2 )
- strTemp += "1";
- else if( m_mode == 3 )
- strTemp += "2";
- else if( m_mode == 5 )
- strTemp += "3";
- strTemp += m_id;
- strTemp += ":";
- for(int i = 0; i < delarray.GetSize(); i++)
- {
- strTemp += delarray.ElementAt(i);
- strTemp += ",";
- }
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strTemp);
- if( g_bSendOK == 0 )
- return;
- AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
- // 日志记录;
- if(m_mode==1)
- strTemp.Format("<%s>订单<%s>分店<%s>的原片被同步删除",m_name, m_id, g_branchname);
- else if(m_mode==2)
- strTemp.Format("<%s>订单<%s>分店<%s>的初修片被同步删除",m_name, m_id, g_branchname);
- else if(m_mode==3)
- strTemp.Format("<%s>订单<%s>分店<%s>的精修片被同步删除",m_name, m_id, g_branchname);
- else if(m_mode==5)
- strTemp.Format("<%s>订单<%s>分店<%s>的设计片被同步删除",m_name, m_id, g_branchname);
- WriteLog("分店相片同步删除", strTemp);
- }
- // 当多店汇总时,通过分店名得到分店域名,再删除分店的相片;
- if ( !m_branch.IsEmpty() && strAryOfDeleted.GetSize() )
- {
- if ( strDomain.IsEmpty() )
- return;
- strTemp.Format( "是否同步删除分店 %s 的照片?", m_branch );
- if( AfxMessageBox(strTemp, MB_YESNO|MB_ICONSTOP) != IDYES )
- return;
- strTemp = "deletephotos";
- if( m_mode == 1 )
- strTemp += "0";
- else if( m_mode == 2 )
- strTemp += "1";
- else if( m_mode == 3 )
- strTemp += "2";
- else if( m_mode == 5 )
- strTemp += "3";
- strTemp += m_id;
- strTemp += ":";
- for(int i = 0; i < delarray.GetSize(); i++)
- {
- strTemp += delarray.ElementAt(i);
- strTemp += ",";
- }
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strTemp);
- if( g_bSendOK == 0 )
- return;
- AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
- // 日志记录;
- if(m_mode==1)
- strTemp.Format("<%s>订单<%s>分店<%s>的原片被同步删除",m_name, m_id, g_branchname);
- else if(m_mode==2)
- strTemp.Format("<%s>订单<%s>分店<%s>的初修片被同步删除",m_name, m_id, g_branchname);
- else if(m_mode==3)
- strTemp.Format("<%s>订单<%s>分店<%s>的精修片被同步删除",m_name, m_id, g_branchname);
- else if(m_mode==5)
- strTemp.Format("<%s>订单<%s>分店<%s>的设计片被同步删除",m_name, m_id, g_branchname);
- WriteLog("分店相片同步删除", strTemp);
- }
- // 直接返回,不执行旧过程;
- return ;
- #else
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- AfxMessageBox("请先选中您要删除的照片!", MB_ICONINFORMATION);
- return;
- }
- if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
- CStringArray delarray;
- //int nDelCount = 0; // Jeff add:被删除的相片数量;// 使用m_nDelCount成员变量;
- CString strDelContent; // Jeff add:删除操作的日志内容;
- //CStringArray strDelArray; // Jeff add:被删除的相片名称;
- while (pos)
- {
- int iItem = m_List1.GetNextSelectedItem(pos);
- CString title = m_List1.GetItemText(iItem, 0);
- // log的内容字段长度有限,写不下这么多文字;
- // 被删除的文件名不记录,只记录删除的张数;
- ::DeleteFile(m_path + title + ".jpg"); // 删除jpg;
- ::DeleteFile(m_path + title + ".NEF"); // 删除NEF;
- ::DeleteFile(m_path + title + ".CR2"); // 删除CR2;
- ::DeleteFile(m_path + title + ".raw"); // 删除raw;
- m_nDelCount++;
- int pos = title.ReverseFind('\\');
- if (pos != -1)
- {
- ::DeleteFile(m_path + title.Left(pos + 1) + "s" + title.Right(title.GetLength() - pos - 1) + ".jpg"); // 删除s小图;
- ::DeleteFile(m_path + title.Left(pos + 1) + "m" + title.Right(title.GetLength() - pos - 1) + ".jpg"); // 删除m小图;
- }
- else
- {
- ::DeleteFile(m_path + "s" + title + ".jpg"); // 删除s小图
- ::DeleteFile(m_path + "m" + title + ".jpg"); // 删除m小图;
- }
- if (m_mode == 1 && g_branchname != "")
- { //拍照,加景点
- CString file2 = m_path + title;
- int pos = file2.Find(m_id);
- pos += m_id.GetLength();
- int pos2 = file2.ReverseFind('\\');
- CString jd;
- if (pos2 > pos)
- {
- jd = file2.Mid(pos + 1, pos2 - pos - 1);
- }
- CString task;
- if (jd != "")
- task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
- else
- task = file2.Right(file2.GetLength() - pos2 - 1);
- delarray.Add(task);
- }
- else
- {
- delarray.Add(title);
- }
- }
- LoadPhotos();
- #if 1
- CString str;
- if (m_mode == 1)
- str += "原片";
- else if (m_mode == 2)
- str += "初修片";
- else if (m_mode == 3)
- str += "精修片";
- else if (m_mode == 5)
- str += "设计片";
- strDelContent.Format("删除%s, 订单号%s的%s:共删除%d张", m_name, m_id, str, m_nDelCount);
- WriteLog("删除相片", strDelContent);
- strDelContent = str;
- #endif
- if (delarray.GetSize() && g_branchname != "")
- {
- str.Format("是否同步删除分店 %s 的照片?", g_branchname);
- if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
- CString sql = "deletephotos";
- if (m_mode == 1)//拍照
- sql += "0";
- else if (m_mode == 2)//初修
- sql += "1";
- else if (m_mode == 3)//精修
- sql += "2";
- else if (m_mode == 5)//设计
- sql += "3";
- sql += m_id;
- sql += ";";
- for (int i = 0; i < delarray.GetSize(); i++)
- {
- sql += delarray.ElementAt(i);
- sql += ",";
- }
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
- AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
- #if 1//Jeff add;
- if (m_mode == 1)
- str += "原片";
- else if (m_mode == 2)
- str += "初修片";
- else if (m_mode == 3)
- str += "精修片";
- else if (m_mode == 5)
- str += "设计片";
- strDelContent.Format("客人%s,订单号%s的分店%s的%s被同步删除", m_name, m_id, g_branchname, str);
- WriteLog("分店相片同步删除", strDelContent);
- #endif
- }
- else if (delarray.GetSize() && m_branch != "")
- {
- if (GetBranchPhotoPath(m_branch) == "")return;
- str.Format("是否同步删除分店 %s 的照片?", m_branch);
- if (AfxMessageBox(str, MB_YESNO | MB_ICONSTOP) != IDYES)return;
- CString sql = "deletephotos";
- if (m_mode == 1)//拍照
- sql += "0";
- else if (m_mode == 2)//初修
- sql += "1";
- else if (m_mode == 3)//精修
- sql += "2";
- else if (m_mode == 5)//设计
- sql += "3";
- sql += m_id;
- sql += ";";
- for (int i = 0; i < delarray.GetSize(); i++)
- {
- sql += delarray.ElementAt(i);
- sql += ",";
- }
- g_sendhead.bsql = 1;
- g_branchip = GetIP(m_branch);
- g_pMainWnd->OnDisconnect();
- g_branchname = m_branch;
- g_bBranchModify = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- g_pMainWnd->OnDisconnect(); g_bBranchModify = 0; g_branchip = g_branchname = "";
- if (g_bSendOK == 0)return;
- AfxMessageBox("远程删片成功!", MB_ICONINFORMATION);
- #if 1//Jeff add;
- if (m_mode == 1)
- str += "原片";
- else if (m_mode == 2)
- str += "初修片";
- else if (m_mode == 3)
- str += "精修片";
- else if (m_mode == 5)
- str += "设计片";
- strDelContent.Format("客人%s,订单号%s的分店%s的%s被同步删除", m_name, m_id, g_branchname, str);
- WriteLog("分店相片同步删除", strDelContent);
- #endif
- }
- #endif
- }
- extern void SaveTaskPath(CString path);
- void ShowPic::OnBUTupload() //上传照片;
- {
- if (1)//g_branchname=="")
- {
- OnBUTupload2();
- return;
- }
- // ZipTypeDlg dlg;
- // dlg.DoModal ();
- CString m_sel;
- if (m_mode == 1)//拍照
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
- }
- else if (m_mode == 2)//初修
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
- }
- else if (m_mode == 3)//精修
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
- }
- else if (m_mode == 5)//设计
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
- }
- CStringArray m_uploadtaskarray;
- m_uploadtaskarray.Add(m_id + ";" + m_name);
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add(m_sel);
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- MyLock lock("uploadtaskaccess");
- CFile fp;
- CString pathdir = m_path + "uploadtask";
- {
- int pos = pathdir.Find(m_id);
- pos += m_id.GetLength();
- int pos2 = pathdir.ReverseFind('\\');
- pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
- }
- CString path;
- int taskpos = 1;
- CStringArray m_olduploadtaskarray;
- for (int i = 0; i < 200; i++)
- {
- path.Format("%s%d.dat", pathdir, i + 1);
- if (PathFileExists(path))
- {
- CFile fp;
- if (fp.Open(path, CFile::modeRead))
- {
- DWORD length = fp.GetLength();
- if (!length)continue;
- CStringArray m_array;
- CArchive ar(&fp, CArchive::load);
- m_array.Serialize(ar);
- fp.Close();
- for (int j = 10; j < m_array.GetSize(); j += 2)
- {
- m_olduploadtaskarray.Add(m_array.ElementAt(j));
- }
- }
- }
- }
- BOOL bexist = 0;
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- AfxMessageBox("请选择您要上传的文件!"); return;
- }
- else
- {
- while (pos)
- {
- int iItem = m_List1.GetNextSelectedItem(pos);
- CString title = m_List1.GetItemText(iItem, 0);
- CString file2 = m_path + title + ".jpg";
- if (m_mode == 1)
- { //拍照,加景点
- int pos = file2.Find(m_id);
- pos += m_id.GetLength();
- int pos2 = file2.ReverseFind('\\');
- CString jd;
- if (pos2 > pos)
- {
- jd = file2.Mid(pos + 1, pos2 - pos - 1);
- }
- CString task;
- if (jd != "")
- task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
- else
- task = file2.Right(file2.GetLength() - pos2 - 1);
- if (::FindArray(&m_olduploadtaskarray, task) == -1)
- {
- m_uploadtaskarray.Add(task);
- m_uploadtaskarray.Add("");
- }
- else
- bexist = 1;
- }
- else
- {
- if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
- {
- m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
- m_uploadtaskarray.Add("");
- }
- else
- bexist = 1;
- }
- }
- }
- if (m_uploadtaskarray.GetSize() > 10)
- {
- CFile fp;
- CString path;
- int taskpos = 1;
- path.Format("%s%d.dat", pathdir, taskpos);
- CString dir = path.Left(path.ReverseFind('\\') + 1);
- pathdir = g_path1 + "\\上传任务\\";
- ::CreateDirectory(pathdir, NULL);
- path.Format("%s%d.dat", pathdir, taskpos);
- while (PathFileExists(path))
- {
- taskpos++;
- path.Format("%s%d.dat", pathdir, taskpos);
- }
- fp.Open(path, CFile::modeCreate | CFile::modeWrite);
- CArchive ar(&fp, CArchive::store);
- m_uploadtaskarray.SetAt(4, dir);
- m_uploadtaskarray.Serialize(ar);
- ar.Close();
- fp.Close();
- }
- if (bexist)
- AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
- else
- AfxMessageBox("保存上传任务成功!");
- }
- void ShowPic::OnBUTselall()
- {
- for (int i = 0; i < m_List1.GetItemCount(); i++)
- m_List1.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
- }
- void ShowPic::OnSelchangeCombo2()
- {
- int pos = m_combobranch.GetCurSel();
- if (pos == -1)return;
- CString str;
- m_combobranch.GetLBText(pos, str);
- if (m_mode == 4)//礼服
- {
- m_type = str;
- LoadPhotos();
- return;
- }
- GetDlgItem(IDC_BUTupload)->SetWindowText("上传至" + str);
- GetDlgItem(IDC_BUTupload)->Invalidate();
- }
- void ShowPic::OnBUTupload2()
- {
- int combopos = m_combobranch.GetCurSel();
- if (combopos == -1)
- {
- AfxMessageBox("请选择您要上传到的分店!");
- return;
- }
- CString domain = m_iparray.ElementAt(combopos);
- CString savedomain;
- if (m_branch != "")
- {
- savedomain = GetDomainFromBranch(m_branch);
- }
- else
- {
- savedomain = GetDomainFromBranch(g_branchname);
- if (g_branchname == "")
- savedomain = g_brancharray.ElementAt(g_brancharray.GetSize() - 1).ElementAt(2);
- }
- // ZipTypeDlg dlg;
- // dlg.DoModal ();
- CString m_sel;
- if (m_mode == 1)//拍照
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(78);
- }
- else if (m_mode == 2)//初修
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(79);
- }
- else if (m_mode == 3)//精修
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(80);
- }
- else if (m_mode == 5)//设计
- {
- m_sel = g_cominfoarraylocal.ElementAt(0).ElementAt(81);
- }
- CStringArray m_uploadtaskarray;
- m_uploadtaskarray.Add(m_id + ";" + m_name);
- m_uploadtaskarray.Add(domain);
- m_uploadtaskarray.Add(savedomain);
- m_uploadtaskarray.Add(m_sel);
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- m_uploadtaskarray.Add("");
- MyLock lock("uploadtaskaccess");
- CFile fp;
- CString pathdir = m_path + "uploadtask";
- {
- int pos = pathdir.Find(m_id);
- pos += m_id.GetLength();
- int pos2 = pathdir.ReverseFind('\\');
- pathdir = pathdir.Left(pos) + pathdir.Right(pathdir.GetLength() - pos2);
- }
- CString path;
- int taskpos = 1;
- CStringArray m_olduploadtaskarray;
- for (int i = 0; i < 200; i++)
- {
- path.Format("%s%d.dat", pathdir, i + 1);
- if (PathFileExists(path))
- {
- CFile fp;
- if (fp.Open(path, CFile::modeRead))
- {
- DWORD length = fp.GetLength();
- if (!length)continue;
- CStringArray m_array;
- CArchive ar(&fp, CArchive::load);
- m_array.Serialize(ar);
- fp.Close();
- if (domain != m_array.ElementAt(1))continue;
- for (int j = 10; j < m_array.GetSize(); j += 2)
- {
- m_olduploadtaskarray.Add(m_array.ElementAt(j));
- }
- }
- }
- }
- BOOL bexist = 0;
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- AfxMessageBox("请选择您要上传的文件!"); return;
- }
- else
- {
- while (pos)
- {
- int iItem = m_List1.GetNextSelectedItem(pos);
- CString title = m_List1.GetItemText(iItem, 0);
- CString file2 = m_path + title + ".jpg";
- if (m_mode == 1)
- { //拍照,加景点
- int pos = file2.Find(m_id);
- pos += m_id.GetLength();
- int pos2 = file2.ReverseFind('\\');
- CString jd;
- if (pos2 > pos)
- {
- jd = file2.Mid(pos + 1, pos2 - pos - 1);
- }
- CString task;
- if (jd != "")
- task = jd + "\\" + file2.Right(file2.GetLength() - pos2 - 1);
- else
- task = file2.Right(file2.GetLength() - pos2 - 1);
- if (::FindArray(&m_olduploadtaskarray, task) == -1)
- {
- m_uploadtaskarray.Add(task);
- m_uploadtaskarray.Add("");
- }
- else
- bexist = 1;
- }
- else
- {
- if (::FindArray(&m_olduploadtaskarray, file2.Right(file2.GetLength() - m_path.GetLength())) == -1)
- {
- m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_path.GetLength()));
- m_uploadtaskarray.Add("");
- }
- else
- bexist = 1;
- }
- }
- }
- if (m_uploadtaskarray.GetSize() > 10)
- {
- CFile fp;
- CString path;
- int taskpos = 1;
- path.Format("%s%d.dat", pathdir, taskpos);
- CString dir = path.Left(path.ReverseFind('\\') + 1);
- pathdir = g_path1 + "\\上传任务\\";
- ::CreateDirectory(pathdir, NULL);
- path.Format("%s%d.dat", pathdir, taskpos);
- while (PathFileExists(path))
- {
- taskpos++;
- path.Format("%s%d.dat", pathdir, taskpos);
- }
- fp.Open(path, CFile::modeCreate | CFile::modeWrite);
- CArchive ar(&fp, CArchive::store);
- m_uploadtaskarray.SetAt(4, dir);
- m_uploadtaskarray.Serialize(ar);
- ar.Close();
- fp.Close();
- // SaveTaskPath(path);
- }
- if (bexist)
- AfxMessageBox("已有存在的任务,存在的任务被忽略,保存上传任务成功!");
- else
- AfxMessageBox("保存上传任务成功!");
- }
- void ShowPic::OnBUTSetDesignNo()
- {
- SetDesignNo dlg;
- dlg.m_id = m_id;
- dlg.DoModal();
- }
- void ShowPic::OnBUTexport() // 只有在设计时,才会有这个导出相片按钮;
- {
- if (IsHasRights2new(12) == 0)return;
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- AfxMessageBox("请先选中您要导出的照片!", MB_ICONINFORMATION);
- return;
- }
- CStringArray saExportImage; // 被导出的相片路径数组;
- CString strExportDirectory; // 相片导出的路径;
- GetSavePath(strExportDirectory);
- if (strExportDirectory.IsEmpty())
- {
- return;
- }
- strExportDirectory.TrimRight('\\');
- strExportDirectory += "\\";
- strExportDirectory += m_id;
- strExportDirectory += m_name2;
- strExportDirectory += "设计好的片修";
- strExportDirectory += "\\";
- ::CreateDirectory(strExportDirectory, NULL);
- CStringArray desarray;
- CStringArray dirarray;
- CString str, str2;
- int pos2;
- while (pos)
- {
- int iItem = m_List1.GetNextSelectedItem(pos);
- str = m_List1.GetItemText(iItem, 0);
- str = m_path + str + ".jpg";
- saExportImage.Add(str);
- str2 = strExportDirectory + m_List1.GetItemText(iItem, 0) + ".jpg";
- desarray.Add(str2);
- str2 = "";
- str = m_List1.GetItemText(iItem, 0);
- pos2 = str.Find("\\");
- while (pos2 != -1)
- {
- str2 += str.Left(pos2) + "\\";
- if (::FindArray(&dirarray, str2) == -1)
- {
- dirarray.Add(str2);
- ::CreateDirectory(strExportDirectory + str2, NULL);
- }
- str = str.Right(str.GetLength() - pos2 - 1);
- pos2 = str.Find("\\");
- }
- }
- CStdioFile fp;
- fp.Open(strExportDirectory + "客户要求.txt", CFile::modeCreate | CFile::modeWrite);
- fp.WriteString(remark);
- fp.Close();
- //----------------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------------
- // 在设计时,导出查看的设计片;
- //----------------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------------
- ImportPhoto dlg;
- dlg.m_mode = 1; // 1.未知;
- dlg.m_pArray = &saExportImage; // 2.作为导出源的设计片的路径集合;
- dlg.m_pDesArray = &desarray; // 3.作为导出目标的设计片的路径集合;
- dlg.m_savepath = strExportDirectory; // 4.保存导出查看的设计片的目录;
- dlg.DoModal();
- AfxMessageBox("导片成功!", MB_ICONINFORMATION);
- // CString str;
- str = " 导出设计片 ";
- str += "客人:";
- str += m_name + m_id;
- WriteLog("导出设计片", str);
- }
- /************************************************************************/
- /*
- 函数:OnButRefreshPhotos
- 描述:刷新相片s和m图
- 参数:
- 返回:
- */
- /************************************************************************/
- void ShowPic::OnButRefreshPhotos()
- {
- TerminateRefreshTh();
- if(m_hRefExitEvent == NULL)
- m_hRefExitEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
- unsigned int dwID = 0;
- m_hThreadRef = (HANDLE)_beginthreadex(NULL, 0, RefreshThFun, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &dwID);
- }
- #if USE_SHARE_FLORD
- /************************************************************************/
- /*
- 函数:GetAllSelectImage
- 描述:获取List控件中选中的全部项;
- 参数:
- OUT: strAry,返回选中项名称;
- 返回:
- 注意:
- 调用约定:
- */
- /************************************************************************/
- void ShowPic::GetAllSelectImage(OUT CStringArray &strAry)
- {
- strAry.RemoveAll();
- POSITION pos = m_List1.GetFirstSelectedItemPosition();
- if( pos == NULL)
- {
- AfxMessageBox("请先选中您要删除的照片!", MB_ICONINFORMATION);
- return;
- }
- if( AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO|MB_ICONSTOP ) != IDYES ) return;
- int nItem = 0;
- CString strImage = _T("");
- while( pos )
- {
- nItem = m_List1.GetNextSelectedItem( pos );
- strAry.Add(m_List1.GetItemText(nItem, 0));
- }
- }
- #endif
|