12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115 |
- #include "stdafx.h"
- #include "ylgl.h"
- #include "ImportPhoto.h"
- #include "MyLock.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- ImportPhoto::ImportPhoto(CWnd* pParent ): CDialog(ImportPhoto::IDD, pParent)
- {
- m_mode = 0;
- m_pArray2 = NULL;
- m_pDesArray = NULL;
- m_exitcode = 0;
- m_bOverWrite = 1;
- m_bBeautifySkinFrom = 0;
- m_bOrigin = 0;
- m_bSaveUploadTask = 0;
- m_bCopyToLocal = 0;
- m_nOutputSize = 0;
- m_bOfmat = 0;
- m_nphototype = -1;
- m_bAddname = 0;
- beginno = -1;
- m_bautono = 1;
- }
- void ImportPhoto::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_PROGRESS1, m_progress);
- }
- BEGIN_MESSAGE_MAP(ImportPhoto, CDialog)
- ON_WM_CLOSE()
- END_MESSAGE_MAP()
- void ImportPhoto::OnOK()
- {
-
- }
- void ImportPhoto::OnCancel()
- {
-
- }
- int ImportPhoto::GetFileNo(CString strOrderFolder)
- {
- if (m_bautono == 0)
- {
- int a = beginno;
- beginno++;
- return a;
- }
- CString path;
- CString path2;
- CString path3;
- CString path4;
- int begin = 1;
- CString temp;
- CStringArray array;
-
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(strOrderFolder), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- temp = (*it).c_str();
- if (::FindArray(&array, temp) == -1)
- array.Add(temp);
- }
-
- BOOL bFind = 1;
- while (bFind)
- {
- bFind = 0;
- for (int i = 0; i < array.GetSize(); i++)
- {
- strOrderFolder = array.ElementAt(i);
- path.Format("%s%03d.jpg", strOrderFolder, begin);
- path2.Format("%s%03d.raw", strOrderFolder, begin);
- path3.Format("%s%03d.cr2", strOrderFolder, begin);
- path4.Format("%s%03d.NEF", strOrderFolder, begin);
-
- while (PathFileExists(path) || PathFileExists(path2) || PathFileExists(path3) || PathFileExists(path4))
- {
- begin++;
- path.Format("%s%03d.jpg", strOrderFolder, begin);
- path2.Format("%s%03d.raw", strOrderFolder, begin);
- path3.Format("%s%03d.cr2", strOrderFolder, begin);
- path4.Format("%s%03d.NEF", strOrderFolder, begin);
- bFind = 1;
- }
- }
- }
-
- beginno = begin + 1;
- return begin;
- }
- void FilterFileName(CString &str)
- {
-
-
- str.Replace("/", "");
- str.Replace("\\", "");
- str.Replace(":", "");
- str.Replace("*", "");
- str.Replace("?", "");
- str.Replace("\"", "");
- str.Replace("<", "");
- str.Replace(">", "");
- str.Replace("|", "");
-
- }
- UINT ImportPhotoThread(LPVOID lpParameter)
- {
- ImportPhoto *pThis = (ImportPhoto*)lpParameter;
- pThis->m_progress.SetRange(0, pThis->m_pArray->GetSize());
-
- CString filename, filename2;
- CString temp;
- int pos;
- BOOL bNeedGet;
- CString temp2;
- int fileno;
-
- if (pThis->m_pArray2)
- {
- if (pThis->m_bAddname)
- {
- for (int i = 0; i < pThis->m_pArray->GetSize(); i++)
- {
- filename = pThis->m_pArray->ElementAt(i);
- temp = filename.Right(filename.GetLength() - filename.ReverseFind('\\') - 1);
- pos = temp.Find(".");
- temp = temp.Left(pos);
- temp += "(" + pThis->m_name + ",";
- temp2 = pThis->m_pArray2->ElementAt(i) + ").jpg";
- FilterFileName(temp2);
-
- ::CopyFile(filename, pThis->m_savepath + temp + temp2, pThis->m_bOverWrite == 0);
- pThis->m_progress.SetPos(i + 1);
- }
- }
- else
- {
- for (int i = 0; i < pThis->m_pArray->GetSize(); i++)
- {
- filename = pThis->m_pArray->ElementAt(i);
- if(filename == _T(""))
- continue;
- filename2 = pThis->m_pArray2->ElementAt(i);
- pos = filename2.Find(";");
- while (pos != -1)
- {
- temp = filename2.Left(pos);
- FilterFileName(temp);
- filename2 = filename2.Right(filename2.GetLength() - pos - 1);
- pos = filename2.Find(";");
-
- ::CreateDirectory(pThis->m_savepath + temp, NULL);
- pThis->MyCopyFile(filename, pThis->m_savepath + temp + filename.Right(filename.GetLength() - filename.ReverseFind('\\')), pThis->m_bOverWrite == 0);
- temp2 = filename.Right(filename.GetLength() - filename.ReverseFind('\\') - 1);
- int pos2 = temp2.Find(".");
- if (pos2 != -1)
- {
- temp2 = temp2.Left(pos2);
- CString filename2;
- }
- }
- temp = filename2;
- FilterFileName(temp);
- ::CreateDirectory(pThis->m_savepath + temp, NULL);
- pThis->MyCopyFile(filename, pThis->m_savepath + temp + filename.Right(filename.GetLength() - filename.ReverseFind('\\')), pThis->m_bOverWrite == 0);
- temp2 = filename.Right(filename.GetLength() - filename.ReverseFind('\\') - 1);
- pos = temp2.Find(".");
- if (pos != -1)
- {
- temp2 = temp2.Left(pos);
- }
- pThis->m_progress.SetPos(i + 1);
- }
- }
- }
- else if (pThis->m_pDesArray)
- {
- for (int i = 0; i < pThis->m_pArray->GetSize(); i++)
- {
- filename = pThis->m_pArray->ElementAt(i);
- if (pThis->m_mode == 2)
- {
- temp = filename.Right(filename.GetLength() - filename.ReverseFind('\\') - 1);
- pos = temp.Find(".");
- bNeedGet = 1;
- if (bNeedGet)
- filename2.Format("%s%03d.jpg", pThis->m_savepath, pThis->GetFileNo(pThis->m_calnopath));
- else
- filename2.Format("%s%s.jpg", pThis->m_savepath, temp);
- pThis->MyCopyFile(filename, filename2, pThis->m_bOverWrite == 0);
- }
- else
- pThis->MyCopyFile(filename, pThis->m_pDesArray->ElementAt(i), pThis->m_bOverWrite == 0);
- #if 1
- pThis->m_AryOfImagePath.Add(pThis->m_pDesArray->ElementAt(i));
- #endif
- pThis->m_progress.SetPos(i + 1);
- }
- }
-
-
-
-
-
-
-
- else
- {
- for (int i = 0; i < pThis->m_pArray->GetSize(); i++)
- {
-
- filename = pThis->m_pArray->ElementAt(i);
-
-
-
- if (pThis->m_mode == 2)
- {
-
- CString ext = filename.Right(filename.GetLength() - filename.ReverseFind('.') - 1);
- if (0)
- {
- temp = filename.Right(filename.GetLength() - filename.ReverseFind('\\') - 1);
- filename2.Format("%s%s", pThis->m_savepath, temp);
- }
- else
- {
-
-
-
- fileno = pThis->GetFileNo(pThis->m_calnopath);
-
- filename2.Format("%s%03d.%s", pThis->m_savepath, fileno, ext);
- }
-
- pThis->MyCopyFile(filename, filename2, pThis->m_bOverWrite == 0);
- #if 1
- pThis->m_AryOfImagePath.Add(filename2);
- #endif
- }
- else
- {
- if (pThis->m_bBeautifySkinFrom)
- {
- temp = pThis->m_savepath + filename.Right(filename.GetLength() - filename.ReverseFind('\\') - 1);
- pos = temp.ReverseFind('.');
- if (pos == -1)continue;
- temp = temp.Left(pos);
- pos = 0;
- filename2.Format("%s.jpg", temp);
- pos = 2;
- while (::PathFileExists(filename2))
- {
- filename2.Format("%s-%d.jpg", temp, pos);
- pos++;
- }
- pThis->MyCopyFile(filename, filename2, pThis->m_bOverWrite == 0);
- }
- else
- {
- if (pThis->m_bOrigin)
- {
- temp = filename.Right(filename.GetLength() - filename.ReverseFind('\\') - 1);
- pos = temp.Find(".");
- if (pos == -1)continue;
- temp = temp.Left(pos);
- pThis->MyCopyFile(filename, pThis->m_savepath + filename.Right(filename.GetLength() - filename.ReverseFind('\\') - 1), pThis->m_bOverWrite == 0);
- }
- else
- {
- filename2 = pThis->m_savepath+filename.Right (filename.GetLength ()-filename.ReverseFind ('\\')-1);
- pThis->MyCopyFile (filename, filename2, pThis->m_bOverWrite==0);
- #if 1
- pThis->m_AryOfImagePath.Add(filename2);
- #endif
- }
- }
- }
- pThis->m_progress.SetPos(i + 1);
- }
- }
- pThis->PostMessage(WM_CLOSE, 0, 0);
- return 1;
- }
- BOOL ImportPhoto::OnInitDialog()
- {
- CDialog::OnInitDialog();
- #if JEFF_TEST_OFF
-
- if ( IsDirectoryLegitimate(m_name) == FALSE)
- {
- AfxMessageBox("目标路径包含创建目录时的非法目录字符'/ \\ : * ? \" < > |',请修改后重新操作!");
- return FALSE;
- }
- #endif
- if (m_bCopyToLocal)
- SetDlgItemText(IDC_STATIC1, "客照缓存中, 请稍候...");
- else if (m_mode == 1)
- SetDlgItemText(IDC_STATIC1, "正在导出客照, 请稍候...");
- #if JEFF_TEST_OFF
- HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, ImprotOrExportImageThread, (LPVOID)this, 0, NULL);
- CloseHandle(hThread);
- #endif
- if (beginno != -1 && beginno != 0)
- {
- m_bautono = 0;
- }
- AfxBeginThread((AFX_THREADPROC)ImportPhotoThread, (LPVOID)this);
- return TRUE;
- }
- void SaveTaskPath(CString pathname)
- {
- return;
- CString path = g_path1 + "\\taskpath.dat";
- CStringArray array;
- CFile fp;
- if (::PathFileExists(path))
- {
- try
- {
- int trycount = 5;
- while (1)
- {
- if (fp.Open(path, CFile::modeRead | CFile::shareExclusive))break;
- fp.Close();
- trycount--;
- if (trycount == 0)break;
- ::Sleep(1000);
- }
- if (trycount == 0)
- {
- if (::PathFileExists(path))return;
- }
- CArchive ar(&fp, CArchive::load);
- array.Serialize(ar);
- fp.Close();
- }
- catch (...)
- {
- fp.Close();
-
- }
- }
- array.Add(pathname);
- try
- {
- int trycount = 5;
- while (1)
- {
- if (fp.Open(path, CFile::modeCreate | CFile::modeWrite | CFile::shareExclusive))break;
- fp.Close();
- trycount--;
- if (trycount == 0)break;
- ::Sleep(1000);
- }
- if (trycount == 0)
- {
-
- return;
- }
- CArchive ar(&fp, CArchive::store);
- array.Serialize(ar);
- ar.Close();
- fp.Close();
- }
- catch (...)
- {
-
- fp.Close();
- }
- }
- void ImportPhoto::OnClose()
- {
- #if USE_SHARE_FLORD
-
-
- CString strSQLInsert;
- if ( m_nphototype != -1)
- {
- int nIndex = 0;
- CString AryOfName;
- int nSize = m_AryOfImagePath.GetSize();
- for (int i = 0; i < nSize; i++)
- {
- CString strPath = m_AryOfImagePath.ElementAt(i);
-
- if (!PathFileExists(strPath)) continue;
-
- nIndex = strPath.ReverseFind(_T('\\'));
- if (nIndex != -1)
- {
-
- strPath = strPath.Mid(nIndex + 1);
- nIndex = strPath.ReverseFind(_T('.'));
- if (nIndex != -1)
- {
- strPath = strPath.Left(nIndex);
- AryOfName += strPath;
- AryOfName += _T("|");
- }
- }
- }
-
-
- strSQLInsert.Format(INSERT_INCREMENT, 0, g_domain, CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"), m_id, m_nphototype + 1, AryOfName, g_user.account, g_user.name);
-
-
-
- if ( g_bAllBranch )
- {
-
- BOOL bCurBranchModify = g_bBranchModify;
- g_bBranchModify = FALSE;
-
- g_pMainWnd->OnDisconnect();
-
- g_branchname = m_branch;
- g_branchip = GetIP(m_branch);
-
-
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strSQLInsert);
- if ( !g_bSendOK )
- {
-
- printf("Jeff:A#多店汇总时连接本店服务器失败\n");
-
- }
- g_bBranchModify = bCurBranchModify;
- g_branchname = g_branchip = _T("");
- }
- else if ( g_branchname != _T("") && g_branchip != _T("") )
- {
-
- CString strBranch = g_branchname;
- CString strBranchIP = g_branchip;
- g_branchname = g_branchip = _T("");
- g_bBranchModify = FALSE;
-
- g_pMainWnd->OnDisconnect();
-
-
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strSQLInsert);
- if (!g_bSendOK)
- {
-
- printf("Jeff:B#连接分店时导入相片失败\n");
- WriteTextLog(_T("连接分店时,写增量时连接服务器失败"));
- }
-
- g_pMainWnd->OnDisconnect();
- g_bBranchModify = TRUE;
- g_branchname = strBranch;
- g_branchip = strBranchIP;
- }
- else
- {
-
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strSQLInsert);
- if (!g_bSendOK)
- {
-
- printf("Jeff:C#连接本店时导入相片失败\n");
- WriteTextLog(_T("本店连接时,写增量时连接服务器失败"));
- }
- }
- }
- #endif
-
- if (m_nphototype < 0 || m_nphototype>3)
- {
- CDialog::OnOK();
- return;
- }
-
- if (m_uploadtaskarray.GetSize() <= 10)
- {
- CDialog::OnOK();
- return;
- }
- #ifdef ENTERPRISE_VERSION
-
- if (m_bSaveUploadTask)
- {
-
-
- CString m_rule = g_cominfoarraylocal.ElementAt(0).ElementAt(116);
- CString m_header, m_left, m_right, m_currule;
- CStringArray rulearray;
- if (m_nphototype == 0)
- {
- m_header = "type0@:";
- }
- else if (m_nphototype == 1)
- {
- m_header = "type1@:";
- }
- else if (m_nphototype == 2)
- {
- m_header = "type2@:";
- }
- else if (m_nphototype == 3)
- {
- m_header = "type3@:";
- }
- int pos = m_rule.Find(m_header);
- if (pos != -1)
- {
- m_left = m_rule.Left(pos);
- m_rule = m_rule.Right(m_rule.GetLength() - pos);
- m_rule.Delete(0, m_header.GetLength());
- pos = m_rule.Find("@:");
- if (pos != -1)
- {
- m_right = m_rule.Right(m_rule.GetLength() - pos + 5);
- m_rule = m_rule.Left(pos - 5);
- }
-
-
- m_currule = m_rule;
- m_rule.Empty();
- m_currule.TrimLeft("%$");
- m_currule.TrimRight("%$");
-
- if (m_currule.Find("%$") != -1)
- {
- pos = m_currule.Find("%$");
- while (pos != -1)
- {
- if (m_currule.Left(pos) != "")rulearray.Add(m_currule.Left(pos));
- m_currule = m_currule.Right(m_currule.GetLength() - pos - 2);
- pos = m_currule.Find("%$");
- }
- }
- if (m_currule != "")rulearray.Add(m_currule);
- }
- for (int i = 0; i < rulearray.GetSize(); i++)
- {
- m_currule = rulearray.ElementAt(i);
- pos = m_currule.Find("->");
- if (pos == -1)continue;
- m_left = m_currule.Left(pos);
- m_right = m_currule.Right(m_currule.GetLength() - pos - 2);
- CString curdomain, curdomain2;
-
- if (m_branch != "")
- {
- curdomain = GetDomainFromBranch(m_branch);
- curdomain2 = GetDomainFromBranch(g_brancharray.ElementAt(g_brancharray.GetSize() - 1).ElementAt(0));
- }
- else if (g_branchname != "")
- {
- curdomain = GetDomainFromBranch(g_branchname);
- curdomain2 = GetDomainFromBranch(g_brancharray.ElementAt(g_brancharray.GetSize() - 1).ElementAt(0));
- }
- else
- {
- curdomain = GetDomainFromBranch(g_brancharray.ElementAt(g_brancharray.GetSize() - 1).ElementAt(0));
- curdomain2 = curdomain;
- }
-
- CString domainleft = GetDomainFromBranch(m_left);
- if (curdomain != domainleft)
- {
- continue;
- }
-
- CString domainright = GetDomainFromBranch(m_right);
- if (domainleft.Find(".ly.com") == -1 || domainright.Find(".ly.com") == -1)
- {
- continue;
- }
- if (curdomain2 == domainright)
- {
- continue;
- }
- MyLock lock("uploadtaskaccess");
-
- m_uploadtaskarray.SetAt(1, domainright);
- m_uploadtaskarray.SetAt(2, domainleft);
- m_uploadtaskarray.SetAt(3, m_sel);
- CFile fp;
- CString pathdir = m_savepath + "uploadtask";
-
- if (m_id != "")
- {
- 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;
- 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);
- printf("Jeff:path: %s\n", path);
- }
- 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 USE_SHARE_FLORD
-
-
-
-
-
-
-
- if ( g_bAllBranch && m_branch != "" )
- {
-
- g_pMainWnd->OnDisconnect();
-
- g_branchname = m_right;
- g_branchip = GetIP(m_right);
- g_bBranchModify = TRUE;
-
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strSQLInsert);
- if ( !g_bSendOK )
- {
-
-
- }
-
- g_pMainWnd->OnDisconnect();
-
- g_bBranchModify = FALSE;
- g_branchip = "";
- g_branchname = "";
- }
- else if ( g_branchname != "" )
- {
- if ( !g_branchname.CompareNoCase(m_right) && !g_branchip.CompareNoCase(GetIP(m_right)) )
- {
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strSQLInsert);
- }
- else
- {
- CString strCurBranch = g_branchname;
- CString strCurBranchIP = g_branchip;
- BOOL bCurBranchModify = g_bBranchModify;
-
- g_pMainWnd->OnDisconnect();
-
- g_branchname = m_right;
- g_branchip = GetIP(m_right);
- g_bBranchModify = TRUE;
-
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strSQLInsert);
- if ( !g_bSendOK )
- {
-
-
- }
-
- g_pMainWnd->OnDisconnect();
-
- g_bBranchModify = bCurBranchModify;
- g_branchip = strCurBranchIP;
- g_branchname = strCurBranch;
- }
- }
- else
- {
-
- g_pMainWnd->OnDisconnect();
-
- g_branchname = m_right;
- g_branchip = GetIP(m_right);
- g_bBranchModify = TRUE;
-
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strSQLInsert);
- if ( !g_bSendOK )
- {
-
-
- }
-
- g_pMainWnd->OnDisconnect();
-
- g_bBranchModify = FALSE;
- g_branchip = "";
- g_branchname = "";
- }
- #endif
- }
- }
- #endif
-
-
- CDialog::OnOK();
- }
- extern void SaveImageToFile(Image *img, CString path);
- void ImportPhoto::MyCopyFile(CString file1, CString file2, BOOL bOverWrite)
- {
- if (::PathFileExists(file1) == 0)
- {
- return;
- }
- if (m_bOfmat)
- {
- CString file1bak = file1;
- CString file2bak = file2;
- file1bak = file1bak.Left(file1bak.GetLength() - 3);
- file2bak = file2bak.Left(file2bak.GetLength() - 3);
- file1bak += "jpg";
- file2bak += "jpg";
- CString src = file1bak;
- CString des = file2bak;
- src.Replace(".jpg", ".raw");
- des.Replace(".jpg", ".raw");
- ::CopyFile(src, des, bOverWrite);
- src = file1bak;
- des = file2bak;
- src.Replace(".jpg", ".nef");
- des.Replace(".jpg", ".nef");
- ::CopyFile(src, des, bOverWrite);
- src = file1bak;
- des = file2bak;
- src.Replace(".jpg", ".cr2");
- des.Replace(".jpg", ".cr2");
- ::CopyFile(src, des, bOverWrite);
- }
- if (m_nphototype == 0 || m_nphototype == 1 || m_nphototype == 2 || m_nphototype == 3)
- {
- CString str = file2;
- CString spath = str.Left(str.ReverseFind('\\') + 1);
- CString mpath = spath;
- spath += "s";
- spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- mpath += "m";
- mpath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- ::DeleteFile(spath);
- ::DeleteFile(mpath);
- }
- if (m_nOutputSize)
- {
- file1.MakeLower();
- if (file1.Right(3) == "jpg")
- {
- Image *img = NULL;
- ::LoadImageFromBuf(&img, file1);
- if (img == NULL)
- {
- if (::CopyFile(file1, file2, bOverWrite) == 0)
- {
- CString str;
- str = file1;
- int pos = str.ReverseFind('\\');
- if (pos != -1)
- str = str.Right(str.GetLength() - pos - 1);
- AfxMessageBox("拷贝失败" + str + "请重新导入此文件!");
- }
- }
- else if (img->GetWidth() == 0)
- {
- if (::CopyFile(file1, file2, bOverWrite) == 0)
- {
- CString str;
- str = file1;
- int pos = str.ReverseFind('\\');
- if (pos != -1)
- str = str.Right(str.GetLength() - pos - 1);
- AfxMessageBox("拷贝失败" + str + "请重新导入此文件!!");
- }
- }
- else
- {
- int newsize = m_nOutputSize;
- if (img->GetWidth() > newsize || img->GetHeight() > newsize)
- {
- CRect rc(0, 0, newsize, newsize);
- RectFitDes(img->GetWidth(), img->GetHeight(), rc);
- Image *simg = img->GetThumbnailImage(rc.Width(), rc.Height(), NULL, NULL);
- Graphics graphic(simg);
- graphic.DrawImage(img, 0, 0, simg->GetWidth(), simg->GetHeight());
- delete img;
- ::SaveImageToFile(simg, file2);
- delete simg;
- }
- else
- {
- if (::CopyFile(file1, file2, bOverWrite) == 0)
- {
- CString str;
- str = file1;
- int pos = str.ReverseFind('\\');
- if (pos != -1)
- str = str.Right(str.GetLength() - pos - 1);
- AfxMessageBox("拷贝失败" + str + "请重新导入此文件!!!");
- }
- }
- }
- }
- else
- {
- if (::CopyFile(file1, file2, bOverWrite) == 0)
- {
- CString str;
- str = file1;
- int pos = str.ReverseFind('\\');
- if (pos != -1)
- str = str.Right(str.GetLength() - pos - 1);
- AfxMessageBox("拷贝失败" + str + "请重新导入此文件!!!!");
- }
- }
- }
- else
- {
- if (::CopyFile(file1, file2, bOverWrite) == 0)
- {
- CString str;
- str = file1;
- int pos = str.ReverseFind('\\');
- if (pos != -1)
- str = str.Right(str.GetLength() - pos - 1);
- AfxMessageBox("拷贝失败" + str + "请重新导入此文件!!!!!");
- }
-
- if (m_bCopyToLocal)
- {
- CString path = file2;
- CString spath = path.Left(path.ReverseFind('\\') + 1);
- spath += "s";
-
- spath += path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
-
- {
- Image *pImg = NULL;
- ::LoadImageFromBuf(&pImg, path);
- if (pImg == NULL)return;
- if (pImg->GetWidth() == 0)return;
- CRect rc(0, 0, 100, 90);
- RectFitDes(pImg->GetWidth(), pImg->GetHeight(), rc);
- Image *simg = pImg->GetThumbnailImage(rc.Width(), rc.Height(), NULL, NULL);
- if (simg == NULL)return;
- Graphics graphic(simg);
- graphic.Clear(Color(255, 255, 255, 255));
- graphic.DrawImage(pImg, 0, 0, simg->GetWidth(), simg->GetHeight());
-
- UINT totalBufferSize;
- UINT numProperties;
- pImg->GetPropertySize(&totalBufferSize, &numProperties);
-
- PropertyItem* pAllItems = (PropertyItem*)malloc(totalBufferSize);
-
- pImg->GetAllPropertyItems(totalBufferSize, numProperties, pAllItems);
-
- for (UINT j = 0; j < numProperties; ++j)
- {
- if (PropertyTagOrientation == pAllItems[j].id)
- {
- short* ptrLong = (short*)(pAllItems[j].value);
- int ret = (int)*ptrLong;
-
-
-
- if (ret == 8)
- {
- simg->RotateFlip(Rotate270FlipNone);
- }
- else if (ret == 6)
- {
- simg->RotateFlip(Rotate90FlipNone);
- }
- break;
- }
- }
- free(pAllItems);
-
- ::SaveImageToFile(simg, spath);
- delete simg;
- delete pImg;
- }
- }
- }
- file2.MakeLower();
- if (m_mode != 1 && file2.Right(3) == "jpg")
- {
- CString path = file2.Left(file2.ReverseFind('\\'));
- path.TrimRight("\\"); path += "\\";
- path += "modifytime";
- CStdioFile fp;
- if (::PathFileExists(path))
- {
- fp.Open(path, CFile::modeWrite);
- fp.WriteString(g_date);
- fp.Close();
- }
- else
- {
- fp.Open(path, CFile::modeCreate | CFile::modeWrite);
- fp.WriteString(g_date);
- fp.Close();
- }
- }
- #ifdef ENTERPRISE_VERSION
- if (m_bSaveUploadTask)
- {
- if (m_id != "")
- {
- if (file2.Right(3) == "jpg")
- {
- 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);
- m_uploadtaskarray.Add(task);
- m_uploadtaskarray.Add("");
- }
- }
- else
- {
- if (file2.Right(3) == "jpg")
- {
- m_uploadtaskarray.Add(file2.Right(file2.GetLength() - m_savepath.GetLength()));
- m_uploadtaskarray.Add("");
- }
- }
- }
- #endif
- }
- unsigned int WINAPI ImportPhoto::ImprotOrExportImageThread(LPVOID lp)
- {
- ImportPhoto *pThis = (ImportPhoto*)lp;
- if ( pThis->m_bImportImage )
- {
-
- switch ( pThis->m_ImportOfImageType )
- {
- case ImageType_Original:
- break;
- case ImageType_Early:
- break;
- case ImageType_Further:
- break;
- case ImageType_Design:
- break;
- default:
- break;
- }
-
- if ( pThis->m_pArray->GetSize() > 0 && lyfzCreateDirectory(pThis->m_savepath))
- lyfzImportImage(pThis->m_savepath, *(pThis->m_pArray));
- }
- else
- {
-
- switch (pThis->m_ExportOfImageType)
- {
- case ImageType_Original:
- break;
- case ImageType_Early:
- break;
- case ImageType_Further:
- break;
- case ImageType_Design:
- default:
- break;
- }
- }
- return 0;
- }
|