123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198 |
- #include "StdAfx.h"
- #include "ImgOfOriginal.h"
- #include "underlyingapi.h"
- #include "global.h"
- #include "filehelp.h"
- using namespace filehelping;
- ULONG_PTR ImgOfOriginal::m_gdiplusToken;
- ImgOfOriginal::ImgOfOriginal(void)
- {
- GdiplusStartupInput gdiplusStartupInput;
- GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
- }
- ImgOfOriginal::~ImgOfOriginal(void)
- {
- Gdiplus::GdiplusShutdown(m_gdiplusToken);
- }
- BOOL ImgOfOriginal::InitializeEnvironment(IN LPCTSTR lpBranchId, IN IMGSHARE_VEC* pvtImgShareInfo)
- {
- if (g_pBranchId && gp_vtImgShareInfo)
- return TRUE;
- g_pBranchId = lpBranchId;
- gp_vtImgShareInfo = pvtImgShareInfo;
- return TRUE;
- }
- #if 0
- /************************************************************************/
- /*
- 函数:AppendLocalSharepath
- 描述:将本机的固定的共享目录添加到指针对象pvtImgShareInfo中;
- 参数:
- IN OUT: pvtImgShareInfo 共享路径容器;
- 返回:
- 注意: 需要获取本机的加密锁存储的域名值;
- */
- /************************************************************************/
- void ImgOfOriginal::AppendLocalSharepath(IN OUT IMGSHARE_VEC *pvtImgShareInfo)
- {
- if (pvtImgShareInfo)
- {
- ImgShareInfo tagImgShare;
- tagImgShare.bEnable = TRUE;
- tagImgShare.byMinCapacity = 5;
- tagImgShare.byMaxCapacity = 35;
- tagImgShare.byImgType = OImgtype;
- tagImgShare.byPriority = 255;
- _stprintf_s(tagImgShare.szBranchId, MAX_PATH, _T("%s"), _T("本机加密狗"));
- _stprintf_s(tagImgShare.szShareDirectory, MAX_PATH, _T("\\\\%s\\%s\\"), _T("主机名"), OImgpath);
- pvtImgShareInfo->push_back(new ImgShareInfo(tagImgShare));
- ImgShareInfo tagImgShare1;
- tagImgShare1.bEnable = TRUE;
- tagImgShare1.byMinCapacity = 5;
- tagImgShare1.byMaxCapacity = 35;
- tagImgShare1.byImgType = EImgtype;
- tagImgShare1.byPriority = 255;
- _stprintf_s(tagImgShare1.szBranchId, MAX_PATH, _T("%s"), _T("本机加密狗"));
- _stprintf_s(tagImgShare1.szShareDirectory, MAX_PATH, _T("\\\\%s\\%s\\"), _T("主机名"), EImgpath);
- pvtImgShareInfo->push_back(new ImgShareInfo(tagImgShare1));
- ImgShareInfo tagImgShare2;
- tagImgShare2.bEnable = TRUE;
- tagImgShare2.byMinCapacity = 5;
- tagImgShare2.byMaxCapacity = 35;
- tagImgShare2.byImgType = FImgtype;
- tagImgShare2.byPriority = 255;
- _stprintf_s(tagImgShare2.szBranchId, MAX_PATH, _T("%s"), _T("本机加密狗"));
- _stprintf_s(tagImgShare2.szShareDirectory, MAX_PATH, _T("\\\\%s\\%s\\"), _T("主机名"), FImgpath);
- pvtImgShareInfo->push_back(new ImgShareInfo(tagImgShare2));
- ImgShareInfo tagImgShare3;
- tagImgShare3.bEnable = TRUE;
- tagImgShare3.byMinCapacity = 5;
- tagImgShare3.byMaxCapacity = 35;
- tagImgShare3.byImgType = DImgtype;
- tagImgShare3.byPriority = 255;
- _stprintf_s(tagImgShare3.szBranchId, MAX_PATH, _T("%s"), _T("本机加密狗"));
- _stprintf_s(tagImgShare3.szShareDirectory, MAX_PATH, _T("\\\\%s\\%s\\"), _T("主机名"), DImgpath);
- pvtImgShareInfo->push_back(new ImgShareInfo(tagImgShare3));
- //////////////////////////////////////////////////////////////////////////
- ImgShareInfo tagImgShare4;
- tagImgShare4.bEnable = TRUE;
- tagImgShare4.byMinCapacity = 5;
- tagImgShare4.byMaxCapacity = 35;
- tagImgShare4.byImgType = OBImgtype;
- tagImgShare4.byPriority = 255;
- _stprintf_s(tagImgShare4.szBranchId, MAX_PATH, _T("%s"), _T("本机加密狗"));
- _stprintf_s(tagImgShare4.szShareDirectory, MAX_PATH, _T("\\\\%s\\%s\\"), _T("主机名"), OBImgpath);
- pvtImgShareInfo->push_back(new ImgShareInfo(tagImgShare4));
- ImgShareInfo tagImgShare5;
- tagImgShare5.bEnable = TRUE;
- tagImgShare5.byMinCapacity = 5;
- tagImgShare5.byMaxCapacity = 35;
- tagImgShare5.byImgType = EBImgtype;
- tagImgShare5.byPriority = 255;
- _stprintf_s(tagImgShare5.szBranchId, MAX_PATH, _T("%s"), _T("本机加密狗"));
- _stprintf_s(tagImgShare5.szShareDirectory, MAX_PATH, _T("\\\\%s\\%s\\"), _T("主机名"), EBImgpath);
- pvtImgShareInfo->push_back(new ImgShareInfo(tagImgShare5));
- ImgShareInfo tagImgShare6;
- tagImgShare6.bEnable = TRUE;
- tagImgShare6.byMinCapacity = 5;
- tagImgShare6.byMaxCapacity = 35;
- tagImgShare6.byImgType = FBImgtype;
- tagImgShare6.byPriority = 255;
- _stprintf_s(tagImgShare6.szBranchId, MAX_PATH, _T("%s"), _T("本机加密狗"));
- _stprintf_s(tagImgShare6.szShareDirectory, MAX_PATH, _T("\\\\%s\\%s\\"), _T("主机名"), FBImgpath);
- pvtImgShareInfo->push_back(new ImgShareInfo(tagImgShare6));
- ImgShareInfo tagImgShare7;
- tagImgShare7.bEnable = TRUE;
- tagImgShare7.byMinCapacity = 5;
- tagImgShare7.byMaxCapacity = 35;
- tagImgShare7.byImgType = DBImgtype;
- tagImgShare7.byPriority = 255;
- _stprintf_s(tagImgShare7.szBranchId, MAX_PATH, _T("%s"), _T("本机加密狗"));
- _stprintf_s(tagImgShare7.szShareDirectory, MAX_PATH, _T("\\\\%s\\%s\\"), _T("主机名"), DBImgpath);
- pvtImgShareInfo->push_back(new ImgShareInfo(tagImgShare7));
- }
- }
- #endif
- CString ImgOfOriginal::GetFileName(IN CONST CString& strfile)
- {
- CString name = _T("");
- int nIndex = strfile.ReverseFind(_T('\\'));
- if (nIndex == -1)
- return _T("");
- name = strfile.Mid(nIndex + 1);
- nIndex = name.ReverseFind(_T('.'));
- if (nIndex == -1)
- return _T("");
- name = name.Mid(0, nIndex);
- return name;
- }
- /************************************************************************/
- /*
- 函数:GetFilteringImg
- 描述:过滤掉扩展名不符合要求的文件名;
- 参数:
- IN: AryImgs 要被过滤的文件名数组;
- IN: lpCopyExt 要保留的文件的扩展名;
- 返回:
- 注意:
- */
- /************************************************************************/
- void ImgOfOriginal::GetFilteringImg(IN CStringArray &AryImgs, IN LPCTSTR lpCopyExt)
- {
- if (AryImgs.GetSize() == 0 || lpCopyExt == NULL) return;
- // 获取复制扩展名;
- int nIndex = 0;
- TString strtmp;
- TString strCopyExt(lpCopyExt);
- if (strCopyExt.find(_T("*.*")) != TString::npos) return;
- strCopyExt.append(_T("|"));
- STR_VEC vtCopyExt;
- // 将所有扩展名解析到数组里;
- do
- {
- nIndex = strCopyExt.find(_T('|'));
- if (nIndex != TString::npos)
- {
- strtmp = strCopyExt.substr(0, nIndex);
- strCopyExt = strCopyExt.substr(nIndex + 1);
- if (strtmp.compare(_T("*.*")))
- vtCopyExt.push_back(strtmp);
- }
- } while (strCopyExt.find(_T('|')) != TString::npos);
- // 过滤非复制扩展名的文件,同时去掉缩略图,保留指定复制扩展名的文件;
- for (int i = AryImgs.GetSize(); i > 0; i--)
- {
- BOOL bExsit = FALSE;
- for (STR_VEC::iterator itExt = vtCopyExt.begin(); itExt != vtCopyExt.end(); itExt++)
- {
- if (AryImgs.ElementAt(i).MakeLower().Find(itExt->c_str()) != -1) {
- bExsit = TRUE;
- break;
- }
- }
- if (!bExsit) {
- AryImgs.RemoveAt(i);
- continue;
- }
- #if 1// 这里应该去除"s"和"m"开头的缩略图;// 但新的做法是在订单里创建缩略图子文件夹;// 总而言之,都要去掉缩略图;
- nIndex = AryImgs.ElementAt(i).ReverseFind(_T('\\'));
- if (nIndex != -1)
- {
- strtmp = AryImgs.ElementAt(i).Mid(nIndex + 1);
- if (strtmp[0] == _T('s') || strtmp[0] == _T('m')) {
- AryImgs.RemoveAt(i);
- continue;
- }
- }
- #endif
- }
- }
- /************************************************************************/
- /*
- 函数:GetFilteringImg
- 描述:过滤掉扩展名不符合要求的文件名;
- 参数:
- IN: AryImgs 要被过滤的文件名数组;
- IN: lpCopyExt 要保留的文件的扩展名;
- 返回:
- 注意:
- */
- /************************************************************************/
- void ImgOfOriginal::GetFilteringImg(IN STR_VEC &vtImgs, IN LPCTSTR lpCopyExt)
- {
- if (vtImgs.size() == 0 || lpCopyExt == NULL) return;
- // 获取复制扩展名;
- int nIndex = 0;
- TString strtmp;
- TString strCopyExt(lpCopyExt);
- if (strCopyExt.find(_T("*.*")) != TString::npos) return;
- strCopyExt.append(_T("|"));
- STR_VEC vtCopyExt;
- // 将所有扩展名解析到数组里;
- do
- {
- nIndex = strCopyExt.find(_T('|'));
- if (nIndex != TString::npos)
- {
- strtmp = strCopyExt.substr(0, nIndex);
- strCopyExt = strCopyExt.substr(nIndex + 1);
- if (strtmp.compare(_T("*.*")))
- vtCopyExt.push_back(strtmp);
- }
- } while (strCopyExt.find(_T('|')) != TString::npos);
- // 过滤非复制扩展名的文件,同时去掉缩略图,保留指定复制扩展名的文件;
- for (STR_VEC::iterator it = vtImgs.begin(); it != vtImgs.end();)
- {
- BOOL bExsit = FALSE;
- for (STR_VEC::iterator itExt = vtCopyExt.begin(); itExt != vtCopyExt.end(); itExt++)
- {
- if (filehelpImpl::match(itExt->c_str(), it->c_str())) {
- bExsit = TRUE;
- break;
- }
- }
- if (!bExsit) {
- it = vtImgs.erase(it);
- continue;
- }
- #if 1// 这里应该去除"s"和"m"开头的缩略图;// 但新的做法是在订单里创建缩略图子文件夹;// 总而言之,都要去掉缩略图;
- nIndex = it->find_last_of(_T('\\'));
- if (nIndex != TString::npos) {
- strtmp = it->substr(nIndex + 1);
- if (strtmp[0] == _T('s') || strtmp[0] == _T('m')) {
- it = vtImgs.erase(it);
- continue;
- }
- }
- #endif
- it++;
- }
- }
- void ImgOfOriginal::SubgroupExt(IN STR_VEC &vtAllImgs, IN LPCTSTR lpSubgroupExt, IN CStringArray &AryImgs)
- {
- if (vtAllImgs.size() == 0 || lpSubgroupExt == NULL) return;
- // 获取复制扩展名;
- int nIndex = 0;
- TString strtmp;
- TString strSubgroupExt(lpSubgroupExt);
- if (strSubgroupExt.find(_T("*.*")) != TString::npos)
- {
- for (STR_VEC::iterator it = vtAllImgs.begin(); it != vtAllImgs.end(); it++)
- AryImgs.Add(CString(it->c_str()));
- return;
- }
- strSubgroupExt.append(_T("|"));
- STR_VEC vtSubgroupExt;
- // 将所有扩展名解析到数组里;
- do
- {
- nIndex = strSubgroupExt.find(_T('|'));
- if (nIndex != TString::npos)
- {
- strtmp = strSubgroupExt.substr(0, nIndex);
- strSubgroupExt = strSubgroupExt.substr(nIndex + 1);
- if (strtmp.compare(_T("*.*")))
- vtSubgroupExt.push_back(strtmp);
- }
- } while (strSubgroupExt.find(_T('|')) != TString::npos);
- // 过滤非复制扩展名的文件,同时去掉缩略图,保留指定复制扩展名的文件;
- for (STR_VEC::iterator it = vtAllImgs.begin(); it != vtAllImgs.end(); it++)
- {
- BOOL bExsit = FALSE;
- for (STR_VEC::iterator itExt = vtSubgroupExt.begin(); itExt != vtSubgroupExt.end(); itExt++)
- {
- if (filehelpImpl::match(itExt->c_str(), it->c_str()))
- {
- #if 1// 这里应该去除"s"和"m"开头的缩略图;// 但新的做法是在订单里创建缩略图子文件夹;// 总而言之,都要去掉缩略图;
- nIndex = it->find_last_of(_T('\\'));
- if (nIndex != TString::npos)
- {
- strtmp = it->substr(nIndex + 1);
- if (strtmp[0] == _T('s') || strtmp[0] == _T('m'))
- {
- continue;
- }
- }
- #endif
- AryImgs.Add(CString(it->c_str()));
- break;
- }
- }
- }
- }
- void ImgOfOriginal::SubgroupExt(IN STR_VEC &vtAllImgs, IN LPCTSTR lpSubgroupExt, IN STR_VEC &vtImgs)
- {
- if (vtAllImgs.size() == 0 || lpSubgroupExt == NULL) return;
- // 获取复制扩展名;
- int nIndex = 0;
- TString strtmp;
- TString strSubgroupExt(lpSubgroupExt);
- if (strSubgroupExt.find(_T("*.*")) != TString::npos)
- {
- for (STR_VEC::iterator it = vtAllImgs.begin(); it != vtAllImgs.end(); it++)
- vtImgs.push_back(*it);
- return;
- }
- strSubgroupExt.append(_T("|"));
- STR_VEC vtSubgroupExt;
- // 将所有扩展名解析到数组里;
- do
- {
- nIndex = strSubgroupExt.find(_T('|'));
- if (nIndex != TString::npos)
- {
- strtmp = strSubgroupExt.substr(0, nIndex);
- strSubgroupExt = strSubgroupExt.substr(nIndex + 1);
- if (strtmp.compare(_T("*.*")))
- vtSubgroupExt.push_back(strtmp);
- }
- } while (strSubgroupExt.find(_T('|')) != TString::npos);
- // 过滤非复制扩展名的文件,同时去掉缩略图,保留指定复制扩展名的文件;
- for (STR_VEC::iterator it = vtAllImgs.begin(); it != vtAllImgs.end(); it++)
- {
- BOOL bExsit = FALSE;
- for (STR_VEC::iterator itExt = vtSubgroupExt.begin(); itExt != vtSubgroupExt.end(); itExt++)
- {
- if (filehelpImpl::match(itExt->c_str(), it->c_str())) {
- #if 1// 这里应该去除"s"和"m"开头的缩略图;// 但新的做法是在订单里创建缩略图子文件夹;// 总而言之,都要去掉缩略图;
- nIndex = it->find_last_of(_T('\\'));
- if (nIndex != TString::npos) {
- strtmp = it->substr(nIndex + 1);
- if (strtmp[0] == _T('s') || strtmp[0] == _T('m')) {
- continue;
- }
- }
- #endif
- vtImgs.push_back(*it);
- break;
- }
- }
- }
- }
- /************************************************************************/
- /*
- 函数:CopyImg2Specifiedpath
- 描述:拷贝相片到指定的目录;
- 参数:
- IN: lpExistpath 相片源目录;
- IN: lpSpecifiedpath 目标路径;
- IN: lpCopyExt 指定要复制的文件的扩展名;
- IN: dwCopyPix 复制时是否要压缩成指定像素;
- IN: bOriginalCopy 复制源相片时,是否原样复制;
- IN: bFailIfExists 目标文件存在是否复制;
- 返回: 返回成功复制的相片张数;
- 注意:
- */
- /************************************************************************/
- INT ImgOfOriginal::CopyImg2Specifiedpath(IN LPCTSTR lpExistpath, IN LPCTSTR lpSpecifiedpath, IN LPCTSTR lpCopyExt, IN CONST DWORD &dwCopyPix, IN BOOL bOriginalCopy, IN BOOL bFailIfExists)
- {
- // 源目录不存在,返回-1;
- if (!PathFileExists(lpExistpath)) return -1;
- // 判断目标目录是否存在,不存在创建;
- if (!PathFileExists(lpSpecifiedpath))
- if (!underlyingapi::CreateDirectoryEx(lpSpecifiedpath))
- return 0;
- // 查找源目录下全部文件;
- STR_VEC vtFiles;
- filehelpImpl lf;
- lf.getfiles_findin_subfolder(lpExistpath, _T("*.*"), &vtFiles);
- // 过滤非复制扩展名的文件,同时去掉缩略图,保留指定复制扩展名的文件;
- // 若是原名导入时,这里不应该过滤任何相片;只有导出时才需要过滤;
- GetFilteringImg(vtFiles, lpCopyExt);
- int nCount = 0;
- int nIndex = 0;
- TString strtmp;
- if (bOriginalCopy && dwCopyPix != INVALID_COPY_PIX) // 是否原样复制 且压缩;
- {
- for (STR_VEC::iterator it = vtFiles.begin(); it != vtFiles.end(); it++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp[_tcslen(lpSpecifiedpath) - 1] != _T('\\'))
- strtmp.append(_T("\\"));
- strtmp.append(it->substr(it->find(lpExistpath) + _tcslen(lpExistpath) + 1));
- if (PathFileExists(strtmp.c_str()) && bFailIfExists)
- continue;
- if (underlyingapi::ImgThumbnail(it->c_str(), dwCopyPix, strtmp.c_str(), 100))
- {
- // 返回压缩失败原因;
- }
- else
- nCount++;
- }
- }
- else if (bOriginalCopy && dwCopyPix == INVALID_COPY_PIX)// 原样复制,不压缩;
- {
- for (STR_VEC::iterator it = vtFiles.begin(); it != vtFiles.end(); it++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp[_tcslen(lpSpecifiedpath) - 1] != _T('\\'))
- strtmp.append(_T("\\"));
- strtmp.append(it->substr(it->find(lpExistpath) + _tcslen(lpExistpath) + 1));
- // 按需要创建 or // 避免多次调用创建文件函数,应该在外面一次性创建完,再执行复制操作;
- again: if (!CopyFile(it->c_str(), strtmp.c_str(), bFailIfExists))
- {
- DWORD dwError = GetLastError();
- if (dwError == ERROR_PATH_NOT_FOUND)
- {
- // 目录不存在,创建;
- underlyingapi::CreateDirectoryEx(strtmp.substr(0, strtmp.find_last_of(_T('\\'))).c_str());
- goto again;
- }
- }
- else
- nCount++;
- }
- }
- else if (!bOriginalCopy && dwCopyPix != INVALID_COPY_PIX) // 压缩,不原样复制,所有源相片放在目标根目录;
- {
- for (STR_VEC::iterator it = vtFiles.begin(); it != vtFiles.end(); it++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp[_tcslen(lpSpecifiedpath) - 1] != _T('\\'))
- strtmp.append(_T("\\"));
- nIndex = it->find_last_of(_T('\\'));
- if (nIndex != TString::npos)
- {
- strtmp.append(it->substr(nIndex + 1));
- if (PathFileExists(strtmp.c_str()) && bFailIfExists)
- continue;
- if (!underlyingapi::ImgThumbnail(it->c_str(), dwCopyPix, strtmp.c_str(), 100))
- {
- // 返回压缩失败原因;
- OutputDebugString(_T("压缩文件失败!\n"));
- }
- else
- nCount++;
- }
- }
- }
- else // 不压缩,不原样;
- {
- for (STR_VEC::iterator it = vtFiles.begin(); it != vtFiles.end(); it++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp[_tcslen(lpSpecifiedpath) - 1] != _T('\\'))
- strtmp.append(_T("\\"));
- nIndex = it->find_last_of(_T('\\'));
- if (nIndex != TString::npos)
- {
- strtmp.append(it->substr(nIndex + 1));
- // 按需要创建 or // 避免多次调用创建文件函数,应该在外面一次性创建完,再执行复制操作;
- again1: if (!CopyFile(it->c_str(), strtmp.c_str(), bFailIfExists))
- {
- DWORD dwError = GetLastError();
- if (dwError == ERROR_PATH_NOT_FOUND)
- {
- // 目录不存在,创建;
- underlyingapi::CreateDirectoryEx(strtmp.substr(0, strtmp.find_last_of(_T('\\'))).c_str());
- goto again1;
- }
- }
- else
- nCount++;
- }
- }
- }
- return nCount;
- }
- /************************************************************************/
- /*
- 函数:CopyImg2Specifiedpath
- 描述:拷贝相片到指定的目录;
- 参数:
- IN: AryOfSelectedImg 源相片数组;
- IN: lpSpecifiedpath 目标路径;
- IN: lpWithExt 指定要复制的其他同名文件的扩展名;
- IN: dwCopyPix 复制时是否要压缩成指定像素;
- IN: bCopyBySubpath 复制时是否创建子目录;
- IN: lpSeparator 复制时如何创建子目录,通过该分隔串截取源相片路径剩余路径创建子目录;
- IN: bFailIfExists 目标文件存在是否复制;
- 返回: 返回成功复制的相片张数;
- 注意:
- */
- /************************************************************************/
- INT ImgOfOriginal::CopyImg2Specifiedpath(IN CStringArray& AryOfSelectedImg, IN LPCTSTR lpSpecifiedpath, IN LPCTSTR lpWithExt, IN CONST DWORD &dwCopyPix, IN BOOL bCopyBySubpath, IN LPCTSTR lpSeparator, IN BOOL bFailIfExists)
- {
- // 空数组则返回;
- if (AryOfSelectedImg.GetSize() == 0) return 0;
- // 判断目标目录是否存在,不存在创建;
- if (!PathFileExists(lpSpecifiedpath))
- if (!underlyingapi::CreateDirectoryEx(lpSpecifiedpath))
- return 0;
- int nCount = 0;
- int nIndex = 0;
- STR_VEC vtWithExt;
- // 解析复制子带扩展名;
- if (lpWithExt)
- {
- // 获取复制扩展名;
- TString str;
- TString strWithExt = underlyingapi::lowercase(lpWithExt);
- if (strWithExt.find(_T("*.*")) == TString::npos)
- {
- strWithExt.append(_T("|"));
- do
- {// 将所有扩展名解析到数组里;
- nIndex = strWithExt.find(_T('|'));
- if (nIndex != TString::npos)
- {
- str = strWithExt.substr(0, nIndex);
- strWithExt = strWithExt.substr(nIndex + 1);
- vtWithExt.push_back(str.substr(1));
- }
- } while (strWithExt.find(_T('|')) != TString::npos);
- }
- }
- CString strtmp;
- int nSize = AryOfSelectedImg.GetSize();
- if (!bCopyBySubpath && dwCopyPix == INVALID_COPY_PIX) // 不创建子目录,且不压缩, 直接放在目标目录下;
- {
- for (int i = 0; i < nSize; i++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp.GetAt(strtmp.GetLength() - 1) != _T('\\'))
- strtmp += _T("\\");
- nIndex = AryOfSelectedImg.ElementAt(i).ReverseFind(_T('\\'));
- if (nIndex != -1)
- {
- strtmp += AryOfSelectedImg.ElementAt(i).Mid(nIndex + 1);
- again: if (!CopyFile(AryOfSelectedImg.ElementAt(i), strtmp, bFailIfExists))
- {
- // 返回复制错误信息;
- DWORD dwError = GetLastError();
- if (dwError == ERROR_PATH_NOT_FOUND)
- {
- // 目录不存在,创建;
- underlyingapi::CreateDirectoryEx(strtmp.Left(strtmp.ReverseFind(_T('\\'))));
- goto again;
- }
- }
- else
- nCount++;
- // 复制其他扩展名的相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- CString strWithExt = AryOfSelectedImg.ElementAt(i);
- strWithExt.MakeLower();
- if (strWithExt.Find(itExt->c_str()) != -1) // 不复制本扩展名;
- continue;
- nIndex = AryOfSelectedImg.ElementAt(i).ReverseFind(_T('.'));
- if (nIndex != -1)
- {
- strWithExt.Replace(strWithExt.Mid(nIndex), itExt->c_str());
- strtmp.Replace(strtmp.Mid(strtmp.ReverseFind(_T('.'))), itExt->c_str());
- if (!CopyFile(strWithExt, strtmp, bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- }
- else if (!bCopyBySubpath && dwCopyPix != INVALID_COPY_PIX) // 不创建子目录, 压缩;
- {
- for (int i = 0; i < nSize; i++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp.GetAt(strtmp.GetLength() - 1) != _T('\\'))
- strtmp += _T("\\");
- nIndex = AryOfSelectedImg.ElementAt(i).ReverseFind(_T('\\'));
- if (nIndex != -1)
- {
- strtmp += AryOfSelectedImg.ElementAt(i).Mid(nIndex + 1);
- if (PathFileExists(strtmp) && bFailIfExists)
- {//目标相片存在,且覆盖存在相片选项真;
- continue;
- }
- else
- {
- if (!underlyingapi::ImgThumbnail(AryOfSelectedImg.ElementAt(i), dwCopyPix, strtmp, 100))
- {
- // 返回压缩失败原因;
- }
- else
- nCount++;
- }
- // 复制其他扩展名的相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- CString strWithExt = AryOfSelectedImg.ElementAt(i);
- strWithExt.MakeLower();
- if (strWithExt.Find(itExt->c_str()) != -1) // 不复制本扩展名;
- continue;
- nIndex = AryOfSelectedImg.ElementAt(i).ReverseFind(_T('.'));
- if (nIndex != -1)
- {
- strWithExt.Replace(strWithExt.Mid(nIndex), itExt->c_str());
- strtmp.Replace(strtmp.Mid(strtmp.ReverseFind(_T('.'))), itExt->c_str());
- if (!CopyFile(strWithExt, strtmp, bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- }
- else if (bCopyBySubpath && dwCopyPix == INVALID_COPY_PIX) // 创建子目录,不压缩;
- {
- if (lpSeparator == NULL)
- {
- // 分隔符为空,返回错误信息;
- return FALSE;
- }
- CString strRight;
- int nSeparatorlen = _tcslen(lpSeparator);
- for (int i = 0; i < nSize; i++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp.GetAt(strtmp.GetLength() - 1) != _T('\\'))
- strtmp += _T("\\");
- nIndex = AryOfSelectedImg.ElementAt(i).Find(lpSeparator);
- if (nIndex != -1)
- {
- strRight = AryOfSelectedImg.ElementAt(i).Mid(nIndex + nSeparatorlen);
- nIndex = strRight.Find(_T("\\"));
- if (nIndex != -1)
- {
- strRight = strRight.Mid(nIndex + 1);
- strtmp += strRight;
- again1: if (!CopyFile(AryOfSelectedImg.ElementAt(i), strtmp, bFailIfExists))
- {
- // 返回复制错误信息;
- DWORD dwError = GetLastError();
- if (dwError == ERROR_PATH_NOT_FOUND)
- {
- // 目录不存在,创建;
- underlyingapi::CreateDirectoryEx(strtmp.Left(strtmp.ReverseFind(_T('\\'))));
- goto again1;
- }
- }
- else
- nCount++;
- // 复制其他扩展名的相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- CString strWithExt = AryOfSelectedImg.ElementAt(i);
- strWithExt.MakeLower();
- if (strWithExt.Find(itExt->c_str()) != -1) // 不复制本扩展名;
- continue;
- nIndex = AryOfSelectedImg.ElementAt(i).ReverseFind(_T('.'));
- if (nIndex != -1)
- {
- strWithExt.Replace(strWithExt.Mid(nIndex), itExt->c_str());
- strtmp.Replace(strtmp.Mid(strtmp.ReverseFind(_T('.'))), itExt->c_str());
- if (!CopyFile(strWithExt, strtmp, bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- }
- }
- else if (bCopyBySubpath && dwCopyPix != INVALID_COPY_PIX) // 创建子目录,压缩;
- {
- if (lpSeparator == NULL)
- {
- // 同时返回错误信息;
- return FALSE;
- }
- CString strRight;
- int nSeparatorlen = _tcslen(lpSeparator);
- for (int i = 0; i < nSize; i++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp.GetAt(strtmp.GetLength() - 1) != _T('\\'))
- strtmp += _T("\\");
- nIndex = AryOfSelectedImg.ElementAt(i).Find(lpSeparator);
- if (nIndex != -1)
- {
- strRight = AryOfSelectedImg.ElementAt(i).Mid(nIndex + nSeparatorlen);
- nIndex = strRight.Find(_T("\\"));
- if (nIndex != -1)
- {
- strRight = strRight.Mid(nIndex + 1);
- strtmp += strRight;
- if (PathFileExists(strtmp) && bFailIfExists)
- {//目标相片存在,且覆盖存在相片选项真;
- continue;
- }
- else
- {
- if (!underlyingapi::ImgThumbnail(AryOfSelectedImg.ElementAt(i), dwCopyPix, strtmp, 100))
- {
- // 返回压缩失败原因;
- }
- else
- nCount++;
- }
- // 复制其他扩展名的相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- CString strWithExt = AryOfSelectedImg.ElementAt(i);
- strWithExt.MakeLower();
- if (strWithExt.Find(itExt->c_str()) != -1) // 不复制本扩展名;
- continue;
- nIndex = AryOfSelectedImg.ElementAt(i).ReverseFind(_T('.'));
- if (nIndex != -1)
- {
- strWithExt.Replace(strWithExt.Mid(nIndex), itExt->c_str());
- strtmp.Replace(strtmp.Mid(strtmp.ReverseFind(_T('.'))), itExt->c_str());
- if (!CopyFile(strWithExt, strtmp, bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- }
- }
- return nCount;
- }
- /************************************************************************/
- /*
- 函数:CopyImg2Specifiedpath
- 描述:拷贝相片到指定的目录;
- 参数:
- IN: AryOfSelectedImg 源相片数组;
- IN: lpSpecifiedpath 目标路径;
- IN: lpWithExt 指定要复制的其他同名文件的扩展名;
- IN: dwCopyPix 复制时是否要压缩成指定像素;
- IN: bCopyBySubpath 复制时是否创建子目录;
- IN: lpSeparator 复制时如何创建子目录,通过该分隔串截取源相片路径剩余路径创建子目录;
- IN: bFailIfExists 目标文件存在是否复制;
- 返回: 返回成功复制的相片张数;
- 注意:
- */
- /************************************************************************/
- INT ImgOfOriginal::CopyImg2Specifiedpath(IN STR_VEC& AryOfSelectedImg, IN LPCTSTR lpSpecifiedpath, IN LPCTSTR lpWithExt, IN CONST DWORD &dwCopyPix, IN BOOL bCopyBySubpath, IN LPCTSTR lpSeparator, IN BOOL bFailIfExists)
- {
- // 空数组则返回;
- if (AryOfSelectedImg.size() == 0) return 0;
- // 判断目标目录是否存在,不存在创建;
- if (!PathFileExists(lpSpecifiedpath))
- if (!underlyingapi::CreateDirectoryEx(lpSpecifiedpath))
- return 0;
- int nCount = 0;
- int nIndex = 0;
- STR_VEC vtWithExt;
- // 解析复制子带扩展名;
- if (lpWithExt)
- {
- // 获取复制扩展名;
- TString str;
- TString strWithExt = underlyingapi::lowercase(lpWithExt);
- if (strWithExt.find(_T("*.*")) == TString::npos)
- {
- strWithExt.append(_T("|"));
- do
- {// 将所有扩展名解析到数组里;
- nIndex = strWithExt.find(_T('|'));
- if (nIndex != TString::npos)
- {
- str = strWithExt.substr(0, nIndex);
- strWithExt = strWithExt.substr(nIndex + 1);
- vtWithExt.push_back(str.substr(1));
- }
- } while (strWithExt.find(_T('|')) != TString::npos);
- }
- }
- TString strtmp;
- if (!bCopyBySubpath && dwCopyPix == INVALID_COPY_PIX) // 不创建子目录,且不压缩, 直接放在目标目录下;
- {
- for (STR_VEC::iterator it = AryOfSelectedImg.begin(); it != AryOfSelectedImg.end(); it++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp[_tcslen(strtmp.c_str()) - 1] != _T('\\'))
- strtmp.append(_T("\\"));
- nIndex = it->find_last_of(_T('\\'));
- if (nIndex != TString::npos)
- {
- strtmp += it->substr(nIndex + 1);
- again: if (!CopyFile(it->c_str(), strtmp.c_str(), bFailIfExists))
- {
- // 返回复制错误信息;
- DWORD dwError = GetLastError();
- if (dwError == ERROR_PATH_NOT_FOUND)
- {
- // 目录不存在,创建;
- underlyingapi::CreateDirectoryEx(strtmp.substr(0, strtmp.find_last_of(_T('\\'))).c_str());
- goto again;
- }
- }
- else
- nCount++;
- // 复制其他扩展名的相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- TString strWithExt = underlyingapi::lowercase(it->c_str());
- if (strWithExt.find(itExt->c_str()) != TString::npos) // 不复制本扩展名;
- continue;
- nIndex = it->find_last_of(_T('.'));
- if (nIndex != TString::npos)
- {
- //strWithExt.replace(nIndex,itExt->size(),itExt->c_str());
- //strtmp.replace(strtmp.find_last_of(_T('.')), itExt->size(), itExt->c_str());
- strWithExt.replace(nIndex, it->length() - nIndex, itExt->c_str());
- strtmp.replace(strtmp.find_last_of(_T('.')), strtmp.length() - strtmp.find_last_of(_T('.')), itExt->c_str());
- if (!CopyFile(strWithExt.c_str(), strtmp.c_str(), bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- }
- else if (!bCopyBySubpath && dwCopyPix != INVALID_COPY_PIX) // 不创建子目录, 压缩;
- {
- for (STR_VEC::iterator it = AryOfSelectedImg.begin(); it != AryOfSelectedImg.end(); it++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp[_tcslen(strtmp.c_str()) - 1] != _T('\\'))
- strtmp.append(_T("\\"));
- nIndex = it->find_last_of(_T('\\'));
- if (nIndex != TString::npos)
- {
- strtmp += it->substr(nIndex + 1);
- if (PathFileExists(strtmp.c_str()) && bFailIfExists)
- {//目标相片存在,且覆盖存在相片选项真;
- continue;
- }
- else
- {
- if (!underlyingapi::ImgThumbnail(it->c_str(), dwCopyPix, strtmp, 100))
- {
- // 返回压缩失败原因;
- }
- else
- nCount++;
- }
- // 复制其他扩展名的相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- TString strWithExt = underlyingapi::lowercase(it->c_str());
- if (strWithExt.find(itExt->c_str()) != TString::npos) // 不复制本扩展名;
- continue;
- nIndex = it->find_last_of(_T('.'));
- if (nIndex != TString::npos)
- {
- //strWithExt.replace(nIndex,itExt->size(),itExt->c_str());
- //strtmp.replace(strtmp.find_last_of(_T('.')), itExt->size(), itExt->c_str());
- strWithExt.replace(nIndex, it->length() - nIndex, itExt->c_str());
- strtmp.replace(strtmp.find_last_of(_T('.')), strtmp.length() - strtmp.find_last_of(_T('.')), itExt->c_str());
- if (!CopyFile(strWithExt.c_str(), strtmp.c_str(), bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- }
- else if (bCopyBySubpath && dwCopyPix == INVALID_COPY_PIX) // 创建子目录,不压缩;
- {
- if (lpSeparator == NULL)
- {
- // 分隔符为空,返回错误信息;
- return FALSE;
- }
- TString strRight;
- int nSeparatorlen = _tcslen(lpSeparator);
- for (STR_VEC::iterator it = AryOfSelectedImg.begin(); it != AryOfSelectedImg.end(); it++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp[_tcslen(strtmp.c_str()) - 1] != _T('\\'))
- strtmp.append(_T("\\"));
- nIndex = it->find(lpSeparator);
- if (nIndex != TString::npos)
- {
- strRight = it->substr(nIndex + nSeparatorlen);
- nIndex = strRight.find(_T("\\"));
- if (nIndex != TString::npos)
- {
- strRight = strRight.substr(nIndex + 1);
- strtmp += strRight;
- again1: if (!CopyFile(it->c_str(), strtmp.c_str(), bFailIfExists))
- {
- // 返回复制错误信息;
- DWORD dwError = GetLastError();
- if (dwError == ERROR_PATH_NOT_FOUND)
- {
- // 目录不存在,创建;
- underlyingapi::CreateDirectoryEx(strtmp.substr(0, strtmp.find_last_of(_T('\\'))).c_str());
- goto again1;
- }
- }
- else
- nCount++;
- // 复制其他扩展名的相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- TString strWithExt = underlyingapi::lowercase(it->c_str());
- if (strWithExt.find(itExt->c_str()) != TString::npos) // 不复制本扩展名;
- continue;
- nIndex = it->find_last_of(_T('.'));
- if (nIndex != TString::npos)
- {
- //strWithExt.replace(nIndex,itExt->size(),itExt->c_str());
- //strtmp.replace(strtmp.find_last_of(_T('.')), itExt->size(), itExt->c_str());
- strWithExt.replace(nIndex, it->length() - nIndex, itExt->c_str());
- strtmp.replace(strtmp.find_last_of(_T('.')), strtmp.length() - strtmp.find_last_of(_T('.')), itExt->c_str());
- if (!CopyFile(strWithExt.c_str(), strtmp.c_str(), bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- else
- {
- // 没有该分隔符;
- OutputDebugString(_T("没有该分隔符\n"));
- }
- }
- }
- else if (bCopyBySubpath && dwCopyPix != INVALID_COPY_PIX) // 创建子目录,压缩;
- {
- if (lpSeparator == NULL)
- {
- // 同时返回错误信息;
- return FALSE;
- }
- TString strRight;
- int nSeparatorlen = _tcslen(lpSeparator);
- for (STR_VEC::iterator it = AryOfSelectedImg.begin(); it != AryOfSelectedImg.end(); it++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp[_tcslen(strtmp.c_str()) - 1] != _T('\\'))
- strtmp.append(_T("\\"));
- nIndex = it->find(lpSeparator);
- if (nIndex != TString::npos)
- {
- strRight = it->substr(nIndex + nSeparatorlen);
- nIndex = strRight.find(_T("\\"));
- if (nIndex != TString::npos)
- {
- strRight = strRight.substr(nIndex + 1);
- strtmp += strRight;
- if (PathFileExists(strtmp.c_str()) && bFailIfExists)
- {//目标相片存在,且覆盖存在相片选项真;
- continue;
- }
- else
- {
- if (!underlyingapi::ImgThumbnail(it->c_str(), dwCopyPix, strtmp, 100))
- {
- // 返回压缩失败原因;
- }
- else
- nCount++;
- }
- // 复制其他扩展名的相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- TString strWithExt = underlyingapi::lowercase(it->c_str());
- if (strWithExt.find(itExt->c_str()) != TString::npos) // 不复制本扩展名;
- continue;
- nIndex = it->find_last_of(_T('.'));
- if (nIndex != -1)
- {
- //strWithExt.replace(nIndex,itExt->size(),itExt->c_str());
- //strtmp.replace(strtmp.find_last_of(_T('.')), itExt->size(), itExt->c_str());
- strWithExt.replace(nIndex, it->length() - nIndex, itExt->c_str());
- strtmp.replace(strtmp.find_last_of(_T('.')), strtmp.length() - strtmp.find_last_of(_T('.')), itExt->c_str());
- if (!CopyFile(strWithExt.c_str(), strtmp.c_str(), bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- }
- }
- return nCount;
- }
- /************************************************************************/
- /*
- 函数:CopyImg2Specifiedpath
- 描述:拷贝相片到指定的目录;
- 参数:
- IN: AryOfExistImages 源相片数组;
- IN: AryOfNewImages 目录相片数组;
- IN: dwCopyPix 复制时是否要压缩成指定像素;
- IN: lpWithExt 指定要复制的其他同名文件的扩展名;
- IN: bFailIfExists 目标文件存在是否复制;
- 返回: 返回成功复制的相片张数;
- 注意:
- */
- /************************************************************************/
- INT ImgOfOriginal::CopyImg2Specifiedpath(IN CStringArray& AryOfExistImages, IN CStringArray& AryOfNewImages, IN CONST DWORD &dwCopyPix, IN LPCTSTR lpWithExt, IN BOOL bFailIfExists)
- {
- if (AryOfExistImages.GetSize() == 0 || AryOfNewImages.GetSize() == 0) return 0;
- int nCount = 0;
- int nIndex = 0;
- STR_VEC vtWithExt;
- // 解析复制子带扩展名;
- if (lpWithExt)
- {
- // 获取复制扩展名;
- TString str;
- TString strWithExt = underlyingapi::lowercase(lpWithExt);
- if (strWithExt.find(_T("*.*")) == TString::npos)
- {
- strWithExt.append(_T("|"));
- do
- {// 将所有扩展名解析到数组里;
- nIndex = strWithExt.find(_T('|'));
- if (nIndex != TString::npos)
- {
- str = strWithExt.substr(0, nIndex);
- strWithExt = strWithExt.substr(nIndex + 1);
- vtWithExt.push_back(str.substr(1));
- }
- } while (strWithExt.find(_T('|')) != TString::npos);
- }
- }
- CString strExist, strNew;
- // 值最小的为准;
- int nSize = (AryOfNewImages.GetSize() > AryOfExistImages.GetSize()) ? AryOfExistImages.GetSize() : AryOfNewImages.GetSize();
- if (dwCopyPix == INVALID_COPY_PIX)
- {
- for (int i = 0; i < nSize; i++)
- {
- strNew = AryOfNewImages.ElementAt(i);
- strExist = AryOfExistImages.ElementAt(i);
- again: if (!CopyFile(strExist, strNew, bFailIfExists))
- {
- // 返回复制错误信息;
- DWORD dwError = GetLastError();
- if (dwError == ERROR_PATH_NOT_FOUND)
- {
- // 目录不存在,创建;
- underlyingapi::CreateDirectoryEx(strNew.Left(strNew.ReverseFind(_T('\\'))));
- goto again;
- }
- }
- else
- nCount++;
- strNew.MakeLower();
- // 复制子带扩展名相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- if (strNew.Find(itExt->c_str()) != -1) // 不复制本扩展名;
- continue;
- nIndex = strExist.ReverseFind(_T('.'));
- if (nIndex != -1)
- {
- strExist.Replace(strExist.Mid(nIndex), itExt->c_str());
- strNew.Replace(strNew.Mid(strNew.ReverseFind(_T('.'))), itExt->c_str());
- if (!CopyFile(strExist, strNew, bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- else
- {
- for (int i = 0; i < nSize; i++)
- {
- strNew = AryOfNewImages.ElementAt(i);
- strExist = AryOfExistImages.ElementAt(i);
- if (PathFileExists(AryOfNewImages.ElementAt(i)) && bFailIfExists)
- continue;
- if (!underlyingapi::ImgThumbnail(strExist, dwCopyPix, strNew, 100))
- {
- // 返回复制错误信息;
- }
- else
- nCount++;
- strNew.MakeLower();
- // 复制子带扩展名相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- if (strNew.Find(itExt->c_str()) != -1) // 不复制本扩展名;
- continue;
- nIndex = strExist.ReverseFind(_T('.'));
- if (nIndex != -1)
- {
- strExist.Replace(strExist.Mid(nIndex), itExt->c_str());
- strNew.Replace(strNew.Mid(strNew.ReverseFind(_T('.'))), itExt->c_str());
- if (!CopyFile(strExist, strNew, bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- return nCount;
- }
- /************************************************************************/
- /*
- 函数:CopyImg2Specifiedpath
- 描述:拷贝相片到指定的目录;
- 参数:
- IN: AryOfExistImages 源相片数组;
- IN: AryOfNewImages 目录相片数组;
- IN: dwCopyPix 复制时是否要压缩成指定像素;
- IN: lpWithExt 指定要复制的其他同名文件的扩展名;
- IN: bFailIfExists 目标文件存在是否复制;
- 返回: 返回成功复制的相片张数;
- 注意:
- */
- /************************************************************************/
- INT ImgOfOriginal::CopyImg2Specifiedpath(IN STR_VEC& AryOfExistImages, IN STR_VEC& AryOfNewImages, IN CONST DWORD &dwCopyPix, IN LPCTSTR lpWithExt, IN BOOL bFailIfExists)
- {
- if (AryOfExistImages.size() == 0 || AryOfNewImages.size() == 0) return 0;
- int nCount = 0;
- int nIndex = 0;
- STR_VEC vtWithExt;
- // 解析复制子带扩展名;
- if (lpWithExt)
- {
- // 获取复制扩展名;
- TString str;
- TString strWithExt = underlyingapi::lowercase(lpWithExt);
- if (strWithExt.find(_T("*.*")) == TString::npos)
- {
- strWithExt.append(_T("|"));
- do
- {// 将所有扩展名解析到数组里;
- nIndex = strWithExt.find(_T('|'));
- if (nIndex != TString::npos)
- {
- str = strWithExt.substr(0, nIndex);
- strWithExt = strWithExt.substr(nIndex + 1);
- vtWithExt.push_back(str.substr(1));
- }
- } while (strWithExt.find(_T('|')) != TString::npos);
- }
- }
- TString strExist, strNew;
- // 值最小的为准;
- int nSize = (AryOfNewImages.size() > AryOfExistImages.size()) ? AryOfExistImages.size() : AryOfNewImages.size();
- if (dwCopyPix == INVALID_COPY_PIX)
- {
- for (STR_VEC::iterator itExist = AryOfExistImages.begin(), itNew = AryOfNewImages.begin();
- itExist != AryOfExistImages.end() && itNew != AryOfNewImages.end(); itExist++, itNew++)
- {
- strExist = underlyingapi::lowercase(itExist->c_str());
- again: if (!CopyFile(itExist->c_str(), itNew->c_str(), bFailIfExists))
- {
- // 返回复制错误信息;
- DWORD dwError = GetLastError();
- if (dwError == ERROR_PATH_NOT_FOUND)
- {
- // 目录不存在,创建;
- underlyingapi::CreateDirectoryEx(itNew->substr(0, itNew->find_last_of(_T('\\'))).c_str());
- goto again;
- }
- }
- else
- nCount++;
- // 复制子带扩展名相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- if (strExist.find(itExt->c_str()) != TString::npos) // 不复制本扩展名;
- continue;
- nIndex = itExist->find_last_of(_T('.'));
- if (nIndex != -1)
- {
- //strExist.replace(nIndex,itExt->size(),itExt->c_str());
- //strNew.replace(strNew.find_last_of(_T('.')), itExt->size(), itExt->c_str());
- strExist.replace(nIndex, itExist->length() - nIndex, itExt->c_str());
- strNew.replace(strNew.find_last_of(_T('.')), strNew.length() - strNew.find_last_of(_T('.')), itExt->c_str());
- if (!CopyFile(strExist.c_str(), strNew.c_str(), bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- else
- {
- for (STR_VEC::iterator itExist = AryOfExistImages.begin(), itNew = AryOfNewImages.begin();
- itExist != AryOfExistImages.end() && itNew != AryOfNewImages.end(); itExist++, itNew++)
- {
- strExist = underlyingapi::lowercase(itExist->c_str());
- if (PathFileExists(strNew.c_str()) && bFailIfExists)
- continue;
- if (!underlyingapi::ImgThumbnail(strExist, dwCopyPix, strNew, 100))
- {
- // 返回复制错误信息;
- }
- else
- nCount++;
- // 复制子带扩展名相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- if (strExist.find(itExt->c_str()) != TString::npos) // 不复制本扩展名;
- continue;
- nIndex = itExist->find_last_of(_T('.'));
- if (nIndex != -1)
- {
- //strExist.replace(nIndex,itExt->size(),itExt->c_str());
- //strNew.replace(strNew.find_last_of(_T('.')), itExt->size(), itExt->c_str());
- strExist.replace(nIndex, itExist->length() - nIndex, itExt->c_str());
- strNew.replace(strNew.find_last_of(_T('.')), strNew.length() - strNew.find_last_of(_T('.')), itExt->c_str());
- if (!CopyFile(strExist.c_str(), strNew.c_str(), bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- return nCount;
- }
- /************************************************************************/
- /*
- 函数:CopyImg2Specifiedpath_ex
- 描述:拷贝相片到指定的目录;
- 参数:
- IN: lpExistpath 相片源目录;
- IN: lpSpecifiedpath 目标路径;
- IN: lpCopyExt 指定要复制的文件的扩展名;
- IN: lpWithExt 指定要复制的其他同名文件的扩展名;
- IN: dwCopyPix 复制时是否要压缩成指定像素;
- IN: bOriginalCopy 复制源相片时,是否原样复制;
- IN: bFailIfExists 目标文件存在是否复制;
- 返回: 返回成功复制的相片张数;
- 注意:
- */
- /************************************************************************/
- INT ImgOfOriginal::CopyImg2Specifiedpath_ex(IN LPCTSTR lpExistpath, IN LPCTSTR lpSpecifiedpath, IN LPCTSTR lpCopyExt, IN LPCTSTR lpWithExt, IN CONST DWORD &dwCopyPix, IN BOOL bOriginalCopy, IN BOOL bFailIfExists)
- {
- // 源目录不存在,返回-1;
- if (!PathFileExists(lpExistpath)) return -1;
- // 判断目标目录是否存在,不存在创建;
- if (!PathFileExists(lpSpecifiedpath))
- if (!underlyingapi::CreateDirectoryEx(lpSpecifiedpath))
- return 0;
- // 查找源目录下全部文件;
- STR_VEC vtFiles;
- filehelpImpl lf;
- lf.getfiles_findin_subfolder(lpExistpath, _T("*.*"), &vtFiles);
- // 过滤非复制扩展名的文件,同时去掉缩略图,保留指定复制扩展名的文件;
- GetFilteringImg(vtFiles, lpCopyExt);
- int nCount = 0;
- int nIndex = 0;
- STR_VEC vtWithExt;
- // 解析复制子带扩展名;
- if (lpWithExt)
- {
- // 获取复制扩展名;
- TString str;
- TString strWithExt = underlyingapi::lowercase(lpWithExt);
- if (strWithExt.find(_T("*.*")) == TString::npos)
- {
- strWithExt.append(_T("|"));
- do
- {// 将所有扩展名解析到数组里;
- nIndex = strWithExt.find(_T('|'));
- if (nIndex != TString::npos)
- {
- str = strWithExt.substr(0, nIndex);
- strWithExt = strWithExt.substr(nIndex + 1);
- vtWithExt.push_back(str.substr(1));
- }
- } while (strWithExt.find(_T('|')) != TString::npos);
- }
- }
- TString strtmp;
- if (bOriginalCopy && dwCopyPix != INVALID_COPY_PIX) // 是否原样复制 且压缩;
- {
- for (STR_VEC::iterator it = vtFiles.begin(); it != vtFiles.end(); it++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp[_tcslen(lpSpecifiedpath) - 1] != _T('\\'))
- strtmp.append(_T("\\"));
- strtmp.append(it->substr(it->find(lpExistpath) + _tcslen(lpExistpath) + 1));
- if (PathFileExists(strtmp.c_str()) && bFailIfExists)
- continue;
- if (underlyingapi::ImgThumbnail(it->c_str(), dwCopyPix, strtmp.c_str(), 100))
- {
- // 返回压缩失败原因;
- }
- else
- nCount++;
- // 复制其他扩展名的相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- TString strWithExt = underlyingapi::lowercase(it->c_str());
- if (strWithExt.find(itExt->c_str()) != TString::npos) // 不复制本扩展名;
- continue;
- nIndex = it->find_last_of(_T('.'));
- if (nIndex != TString::npos)
- {
- //strWithExt.replace(nIndex,itExt->size(),itExt->c_str());
- //strtmp.replace(strtmp.find_last_of(_T('.')), itExt->size(), itExt->c_str());
- strWithExt.replace(nIndex, it->length() - nIndex, itExt->c_str());
- strtmp.replace(strtmp.find_last_of(_T('.')), strtmp.length() - strtmp.find_last_of(_T('.')), itExt->c_str());
- if (!CopyFile(strWithExt.c_str(), strtmp.c_str(), bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- else if (bOriginalCopy && dwCopyPix == INVALID_COPY_PIX)// 原样复制,不压缩;
- {
- for (STR_VEC::iterator it = vtFiles.begin(); it != vtFiles.end(); it++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp[_tcslen(lpSpecifiedpath) - 1] != _T('\\'))
- strtmp.append(_T("\\"));
- strtmp.append(it->substr(it->find(lpExistpath) + _tcslen(lpExistpath) + 1));
- // 按需要创建 or // 避免多次调用创建文件函数,应该在外面一次性创建完,再执行复制操作;
- again: if (!CopyFile(it->c_str(), strtmp.c_str(), bFailIfExists))
- {
- DWORD dwError = GetLastError();
- if (dwError == ERROR_PATH_NOT_FOUND)
- {
- // 目录不存在,创建;
- underlyingapi::CreateDirectoryEx(strtmp.substr(0, strtmp.find_last_of(_T('\\'))).c_str());
- goto again;
- }
- }
- else
- nCount++;
- // 复制其他扩展名的相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- TString strWithExt = underlyingapi::lowercase(it->c_str());
- if (strWithExt.find(itExt->c_str()) != TString::npos) // 不复制本扩展名;
- continue;
- nIndex = it->find_last_of(_T('.'));
- if (nIndex != TString::npos)
- {
- //strWithExt.replace(nIndex,itExt->size(),itExt->c_str());
- //strtmp.replace(strtmp.find_last_of(_T('.')), itExt->size(), itExt->c_str());
- strWithExt.replace(nIndex, it->length() - nIndex, itExt->c_str());
- strtmp.replace(strtmp.find_last_of(_T('.')), strtmp.length() - strtmp.find_last_of(_T('.')), itExt->c_str());
- if (!CopyFile(strWithExt.c_str(), strtmp.c_str(), bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- else if (!bOriginalCopy && dwCopyPix != INVALID_COPY_PIX) // 压缩,不原样复制,所有源相片放在目标根目录;
- {
- for (STR_VEC::iterator it = vtFiles.begin(); it != vtFiles.end(); it++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp[_tcslen(lpSpecifiedpath) - 1] != _T('\\'))
- strtmp.append(_T("\\"));
- nIndex = it->find_last_of(_T('\\'));
- if (nIndex != TString::npos)
- {
- strtmp.append(it->substr(nIndex + 1));
- if (PathFileExists(strtmp.c_str()) && bFailIfExists)
- continue;
- if (!underlyingapi::ImgThumbnail(it->c_str(), dwCopyPix, strtmp.c_str(), 100))
- {
- // 返回压缩失败原因;
- }
- else
- nCount++;
- // 复制其他扩展名的相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- TString strWithExt = underlyingapi::lowercase(it->c_str());
- if (strWithExt.find(itExt->c_str()) != TString::npos) // 不复制本扩展名;
- continue;
- nIndex = it->find_last_of(_T('.'));
- if (nIndex != TString::npos)
- {
- //strWithExt.replace(nIndex,itExt->size(),itExt->c_str());
- //strtmp.replace(strtmp.find_last_of(_T('.')), itExt->size(), itExt->c_str());
- strWithExt.replace(nIndex, it->length() - nIndex, itExt->c_str());
- strtmp.replace(strtmp.find_last_of(_T('.')), strtmp.length() - strtmp.find_last_of(_T('.')), itExt->c_str());
- if (!CopyFile(strWithExt.c_str(), strtmp.c_str(), bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- }
- else // 不压缩,不原样;
- {
- for (STR_VEC::iterator it = vtFiles.begin(); it != vtFiles.end(); it++)
- {
- strtmp = lpSpecifiedpath;
- if (strtmp[_tcslen(lpSpecifiedpath) - 1] != _T('\\'))
- strtmp.append(_T("\\"));
- nIndex = it->find_last_of(_T('\\'));
- if (nIndex != TString::npos)
- {
- strtmp.append(it->substr(nIndex + 1));
- // 按需要创建 or // 避免多次调用创建文件函数,应该在外面一次性创建完,再执行复制操作;
- again1: if (!CopyFile(it->c_str(), strtmp.c_str(), bFailIfExists))
- {
- DWORD dwError = GetLastError();
- if (dwError == ERROR_PATH_NOT_FOUND)
- {
- // 目录不存在,创建;
- underlyingapi::CreateDirectoryEx(strtmp.substr(0, strtmp.find_last_of(_T('\\'))).c_str());
- goto again1;
- }
- }
- else
- nCount++;
- // 复制其他扩展名的相片;
- for (STR_VEC::iterator itExt = vtWithExt.begin(); itExt != vtWithExt.end(); itExt++)
- {
- TString strWithExt = underlyingapi::lowercase(it->c_str());
- if (strWithExt.find(itExt->c_str()) != TString::npos) // 不复制本扩展名;
- continue;
- nIndex = it->find_last_of(_T('.'));
- if (nIndex != TString::npos)
- {
- //strWithExt.replace(nIndex,itExt->size(),itExt->c_str());
- //strtmp.replace(strtmp.find_last_of(_T('.')), itExt->size(), itExt->c_str());
- strWithExt.replace(nIndex, it->length() - nIndex, itExt->c_str());
- strtmp.replace(strtmp.find_last_of(_T('.')), strtmp.length() - strtmp.find_last_of(_T('.')), itExt->c_str());
- if (!CopyFile(strWithExt.c_str(), strtmp.c_str(), bFailIfExists))
- {
- // 返回复制错误信息;
- }
- }
- }
- }
- }
- }
- return nCount;
- }
- #if 0
- BOOL ImgOfOriginal::GetLocalSharedirectory(IN CONST INT &nImgType, OUT LPTSTR lpResultSharedirectory, IN CONST INT &nBufSize)
- {
- // 获取本地计算机名;
- DWORD dwBufLen = MAX_COMPUTERNAME_LENGTH + 1;
- TCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1] = { 0 };
- if (!GetComputerName(szComputerName, &dwBufLen))
- {
- DWORD dwError = GetLastError();
- // 返回错误代码;
- return FALSE;
- }
- switch (nImgType)
- {
- case OImgtype:
- _stprintf_s(lpResultSharedirectory, nBufSize, _T("\\\\%s\\%s\\"), szComputerName, OImgpath);
- break;
- case EImgtype:
- _stprintf_s(lpResultSharedirectory, nBufSize, _T("\\\\%s\\%s\\"), szComputerName, EImgpath);
- break;
- case FImgtype:
- _stprintf_s(lpResultSharedirectory, nBufSize, _T("\\\\%s\\%s\\"), szComputerName, FImgpath);
- break;
- case DImgtype:
- _stprintf_s(lpResultSharedirectory, nBufSize, _T("\\\\%s\\%s\\"), szComputerName, DImgpath);
- break;
- // 以下为备份共享目录;
- case OBImgtype:
- _stprintf_s(lpResultSharedirectory, nBufSize, _T("\\\\%s\\%s"), szComputerName, OBImgpath);
- break;
- case EBImgtype:
- _stprintf_s(lpResultSharedirectory, nBufSize, _T("\\\\%s\\%s"), szComputerName, EBImgpath);
- break;
- case FBImgtype:
- _stprintf_s(lpResultSharedirectory, nBufSize, _T("\\\\%s\\%s"), szComputerName, FBImgpath);
- break;
- case DBImgtype:
- _stprintf_s(lpResultSharedirectory, nBufSize, _T("\\\\%s\\%s"), szComputerName, DBImgpath);
- break;
- default:
- break;
- }
- return TRUE;
- }
- #endif
- BOOL ImgOfOriginal::GetLocalEnableShareDirectory(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, OUT LPTSTR lpEnableShareDirectory, IN CONST INT &nBufSize)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- double dTotalNum = 0.0;
- double dFreeNum = 0.0;
- BOOL bGetEnable = FALSE;
- BYTE byCurPriority = 0;
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- if (pImgsi->byImgType == nImgType && _tcscmp(pImgsi->szBranchId, lpBranchId) == 0)
- {
- if ( bGetEnable )
- {
- if ( byCurPriority > pImgsi->byPriority )
- continue;
- }
- #if 0 // 以下代码有错,不需要判断是否本店;
- if (_tcscmp(lpBranchId, g_pBranchId) == 0) // 本机域名;
- _stprintf_s(lpEnableShareDirectory, nBufSize, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- else // 分店存储的规则是在本店共享目录下创建域名文件夹;
- _stprintf_s(lpEnableShareDirectory, nBufSize, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum);
- #else
- // 若分店相片也单独一个目录存储,不需要判断是否为本店;
- _stprintf_s(lpEnableShareDirectory, nBufSize, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- #endif
- if (!underlyingapi::GetDiskSpaceInfo(pImgsi->szShareDirectory, dTotalNum, dFreeNum))
- {//获取硬盘容量失败,可能路径无效或硬盘损坏;
- continue;
- }
- // 如果目录存在,且安全容量值满足要求,直接返回;
- if (PathFileExists(lpEnableShareDirectory))
- {
- if (dFreeNum > pImgsi->byMinCapacity)
- {
- bGetEnable = TRUE;
- break;
- }
- }
- // 剩余容量大于更盘容量;
- if (dFreeNum > pImgsi->byMaxCapacity)
- {
- // 直至最大优先级被找到;
- if (byCurPriority < pImgsi->byPriority)
- {
- byCurPriority = pImgsi->byPriority;
- bGetEnable = TRUE;
- }
- }
- }
- }
- return bGetEnable;
- }
- BOOL ImgOfOriginal::GetEnableShareDirectory(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, OUT LPTSTR lpEnableShareDirectory, IN CONST INT &nBufSize)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- double dTotalNum = 0.0;
- double dFreeNum = 0.0;
- BOOL bGetEnable = FALSE;
- BYTE byCurPriority = 0;
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- if (pImgsi->byImgType == nImgType && _tcscmp(pImgsi->szBranchId, lpBranchId) == 0)
- {
- if ( bGetEnable )
- {
- if ( byCurPriority > pImgsi->byPriority )
- continue;
- }
- #if 0 // 以下代码有错,不需要判断是否本店;
- if (_tcscmp(lpBranchId, g_pBranchId) == 0) // 本机域名;
- _stprintf_s(lpEnableShareDirectory, nBufSize, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- else // 分店存储的规则是在本店共享目录下创建域名文件夹;
- _stprintf_s(lpEnableShareDirectory, nBufSize, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum);
- #else
- // 若分店相片也单独一个目录存储,不需要判断是否为本店;
- _stprintf_s(lpEnableShareDirectory, nBufSize, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- #endif
- if (!underlyingapi::GetDiskSpaceInfo(pImgsi->szShareDirectory, dTotalNum, dFreeNum))
- {//获取硬盘容量失败,可能路径无效或硬盘损坏;
- continue;
- }
- // 如果目录存在,且安全容量值满足要求,直接返回;
- if (PathFileExists(lpEnableShareDirectory))
- {
- if (dFreeNum > pImgsi->byMinCapacity)
- {
- bGetEnable = TRUE;
- break;
- }
- }
- // 剩余容量大于更盘容量;
- if (dFreeNum > pImgsi->byMaxCapacity)
- {
- // 直至最大优先级被找到;
- if (byCurPriority < pImgsi->byPriority)
- {
- byCurPriority = pImgsi->byPriority;
- bGetEnable = TRUE;
- }
- }
- }
- }
- return bGetEnable;
- }
- //////////////////////////////////////////////////////////////////////////
- BOOL ImgOfOriginal::LoadSpecifiedpathImages(IN LPCTSTR lpSepcifiedpath, IN LPCTSTR lpLoadExt, OUT CStringArray &AryOfSpecifiedpathImages)
- {
- if (!lpSepcifiedpath || !PathFileExists(lpSepcifiedpath))
- return FALSE;
- if (!filehelpImpl::iscorrectext(lpLoadExt)) return FALSE;
- // 查找源目录下全部文件;
- STR_VEC vtFiles;
- filehelpImpl lf;
- lf.getfiles_findin_subfolder(lpSepcifiedpath, _T("*.*"), &vtFiles);
- // 过滤不符合扩展名的图像,注意该函数的使用方向;
- GetFilteringImg(vtFiles, lpLoadExt);
- for (STR_VEC::iterator it = vtFiles.begin(); it != vtFiles.end(); it++)
- {
- AryOfSpecifiedpathImages.Add(it->c_str());
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSpecifiedpathImages(IN LPCTSTR lpSepcifiedpath, IN LPCTSTR lpLoadExt, OUT STR_VEC &AryOfSpecifiedpathImages)
- {
- if (!lpSepcifiedpath || !PathFileExists(lpSepcifiedpath))
- return FALSE;
- // 查找源目录下全部文件;
- filehelpImpl lf;
- lf.getfiles_findin_subfolder(lpSepcifiedpath, _T("*.*"), &AryOfSpecifiedpathImages);
- // 过滤不符合扩展名的图像,注意该函数的使用方向;
- GetFilteringImg(AryOfSpecifiedpathImages, lpLoadExt);
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSelectedIamgesFromSpecifiedpath(IN LPCTSTR lpSepcifiedpath, IN LPCTSTR lpLoadExt, IN CStringArray &AryOfSelectedIamges, OUT CStringArray &AryOfNoExistIamges, OUT CStringArray &AryOfSelectedImagepaths)
- {
- // 判断目录有效性;
- if (!lpSepcifiedpath || !underlyingapi::IsValidpath(lpSepcifiedpath) || !PathFileExists(lpSepcifiedpath)) return FALSE;
- // 查找源目录下全部文件;
- STR_VEC vtFiles;
- filehelpImpl lf;
- lf.getfiles_findin_subfolder(lpSepcifiedpath, _T("*.*"), &vtFiles);
- // 过滤不符合扩展名的图像,注意该函数的使用方向;
- GetFilteringImg(vtFiles, lpLoadExt);
- // 再度过滤未存在的相片;
- TCHAR path_buffer[_MAX_PATH] = { 0 };
- TCHAR szDrive[_MAX_DRIVE] = { 0 };
- TCHAR szDir[_MAX_DIR] = { 0 };
- TCHAR szFname[_MAX_FNAME] = { 0 };
- TCHAR szExt[_MAX_EXT] = { 0 };
- CString strImgpath;
- for (STR_VEC::iterator it = vtFiles.begin(); it != vtFiles.end(); it++)
- {
- _tsplitpath_s(it->c_str(), szDrive, szDir, szFname, szExt);
- for (int i = 0; i < AryOfSelectedIamges.GetSize(); i++)
- {
- if (AryOfSelectedIamges.ElementAt(i).CompareNoCase(szFname) == 0)
- {
- strImgpath = it->c_str();
- AryOfSelectedImagepaths.Add(strImgpath);
- //AryOfSelectedIamges.RemoveAt(i);// 会删除不同扩展名的文件,如 (扩展名:*.jpg|*.jpeg) 001.jpg 和 001.jpeg 有一个会没有记录到;
- break;
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSelectedIamgesFromSpecifiedpath(IN LPCTSTR lpSepcifiedpath, IN LPCTSTR lpLoadExt, IN STR_VEC &AryOfSelectedIamges, OUT STR_VEC &AryOfNoExistIamges, OUT STR_VEC &AryOfSelectedImagepaths)
- {
- // 判断目录有效性;
- if (!lpSepcifiedpath || !underlyingapi::IsValidpath(lpSepcifiedpath) || !PathFileExists(lpSepcifiedpath)) return FALSE;
- // 查找源目录下全部文件;
- STR_VEC vtFiles;
- filehelpImpl lf;
- lf.getfiles_findin_subfolder(lpSepcifiedpath, _T("*.*"), &vtFiles);
- // 过滤不符合扩展名的图像,注意该函数的使用方向;
- GetFilteringImg(vtFiles, lpLoadExt);
- // 再度过滤未存在的相片;
- TCHAR path_buffer[_MAX_PATH] = { 0 };
- TCHAR szDrive[_MAX_DRIVE] = { 0 };
- TCHAR szDir[_MAX_DIR] = { 0 };
- TCHAR szFname[_MAX_FNAME] = { 0 };
- TCHAR szExt[_MAX_EXT] = { 0 };
- for (STR_VEC::iterator it = vtFiles.begin(); it != vtFiles.end(); it++)
- {
- _tsplitpath_s(it->c_str(), szDrive, szDir, szFname, szExt);
- for (STR_VEC::iterator itImg = AryOfSelectedIamges.begin(); itImg != AryOfSelectedIamges.end(); itImg++)
- {
- TString strImgpath = szFname;
- filehelpImpl::uppercase(strImgpath);
- filehelpImpl::uppercase(*itImg);
- if (itImg->compare(strImgpath) == 0)
- {
- strImgpath = it->c_str();
- AryOfSelectedImagepaths.push_back(strImgpath);
- //AryOfSelectedIamges.erase(itImg); // 会删除不同扩展名的文件,如 (扩展名:*.jpg|*.jpeg) 001.jpg 和 001.jpeg 有一个会没有记录到;
- break;
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSelectedIamges(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN LPCTSTR lpLoadExt, IN CStringArray &AryOfSelectedIamges, OUT CStringArray &AryOfNoExistIamges, OUT CStringArray &AryOfSelectedImagepaths)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- int nSize = 0;
- CString strImage = _T("");
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- TCHAR szShareDirectory[MAX_PATH] = { 0 };
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum);
- }
- if (PathFileExists(szOrderpath))
- {
- LoadSelectedIamgesFromSpecifiedpath(szOrderpath, lpLoadExt, AryOfSelectedIamges, AryOfNoExistIamges, AryOfSelectedImagepaths);
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSelectedIamges(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN LPCTSTR lpLoadExt, IN STR_VEC &AryOfSelectedIamges, OUT STR_VEC &AryOfNoExistIamges, OUT STR_VEC &AryOfSelectedImagepaths)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- int nSize = 0;
- CString strImage = _T("");
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum);
- }
- if (PathFileExists(szOrderpath))
- {
- LoadSelectedIamgesFromSpecifiedpath(szOrderpath, lpLoadExt, AryOfSelectedIamges, AryOfNoExistIamges, AryOfSelectedImagepaths);
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSelectedIamges2(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN LPCTSTR lpLoadExt, IN CStringArray &AryOfSelectedIamges, OUT CStringArray &AryOfNoExistIamges, OUT CStringArray &AryOfSelectedImagepaths)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- int nSize = 0;
- CString strImage = _T("");
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- TCHAR szShareDirectory[MAX_PATH] = { 0 };
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum);
- }
- if (PathFileExists(szOrderpath))
- {
- for (int i = 0; i < AryOfSelectedIamges.GetSize(); i++)
- {
- strImage.Format(_T("%s\\%s.jpg"), szOrderpath, AryOfSelectedIamges.ElementAt(i));
- if (PathFileExists(strImage))
- {
- AryOfSelectedImagepaths.Add(strImage);
- }
- }
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSelectedIamges2(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN LPCTSTR lpLoadExt, IN STR_VEC &AryOfSelectedIamges, OUT STR_VEC &AryOfNoExistIamges, OUT STR_VEC &AryOfSelectedImagepaths)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- int nSize = 0;
- TString strImage;
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum);
- }
- if (PathFileExists(szOrderpath))
- {
- for (STR_VEC::iterator itImg = AryOfSelectedIamges.begin(); itImg != AryOfSelectedIamges.end(); itImg++)
- {
- strImage = szOrderpath;
- strImage.append(_T("\\"));
- strImage.append(itImg->c_str());
- strImage.append(_T(".jpg"));
- if (PathFileExists(strImage.c_str()))
- {
- AryOfSelectedImagepaths.push_back(strImage);
- }
- }
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSelectedIamgesInOrder(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN LPCTSTR lpLoadExt, IN CStringArray &AryOfSelectedIamges, OUT CStringArray &AryOfNoExistIamges, OUT CStringArray &AryOfSelectedImagepaths)
- {
- CStringArray tmpselectedImg;
- CStringArray tmpselectedImgpaths;
- if (!LoadSelectedIamges(nImgType, lpBranchId, lpOrderNum, lpLoadExt, tmpselectedImg, AryOfNoExistIamges, tmpselectedImgpaths)) return FALSE;
- tmpselectedImg.Copy(AryOfSelectedIamges);
- tmpselectedImgpaths.Copy(AryOfSelectedImagepaths);
- CString strImage = _T("");
- // 再按顺序加入AryOfSelectedImagePaths;
- for (int i = 0; i < AryOfSelectedIamges.GetSize(); i++)
- {
- // 如果某张相片没有找到对应的文件,赋空;
- BOOL bGetImage = FALSE;
- for (int n = 0; n < tmpselectedImgpaths.GetSize(); n++)
- {
- strImage = tmpselectedImgpaths.ElementAt(n).Mid(tmpselectedImgpaths.ElementAt(n).ReverseFind('\\') + 1);
- strImage = strImage.Left(strImage.Find('.'));
- if (AryOfSelectedIamges.ElementAt(i).CompareNoCase(strImage) == 0)
- {
- bGetImage = TRUE;
- AryOfSelectedImagepaths.Add(tmpselectedImgpaths.ElementAt(n));
- break;
- }
- }
- if (!bGetImage)
- {
- AryOfSelectedImagepaths.Add(_T(""));
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSelectedIamgesInOrder(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN LPCTSTR lpLoadExt, IN STR_VEC &AryOfSelectedIamges, OUT STR_VEC &AryOfNoExistIamges, OUT STR_VEC &AryOfSelectedImagepaths)
- {
- STR_VEC tmpselectedImg;
- STR_VEC tmpselectedImgpaths;
- if (!LoadSelectedIamges(nImgType, lpBranchId, lpOrderNum, lpLoadExt, tmpselectedImg, AryOfNoExistIamges, tmpselectedImgpaths)) return FALSE;
- for (STR_VEC::iterator it = AryOfSelectedIamges.begin(); it != AryOfSelectedIamges.end(); it++)
- {
- tmpselectedImg.push_back(it->c_str());
- }
- for (STR_VEC::iterator it = AryOfSelectedImagepaths.begin(); it != AryOfSelectedImagepaths.end(); it++)
- {
- tmpselectedImgpaths.push_back(it->c_str());
- }
- int nIndex = 0;
- TString strImage = _T("");
- // 再按顺序加入AryOfSelectedImagePaths;
- for (STR_VEC::iterator itName = AryOfSelectedIamges.begin(); itName != AryOfSelectedIamges.end(); itName++)
- {
- // 如果某张相片没有找到对应的文件,赋空;
- BOOL bGetImage = FALSE;
- for (STR_VEC::iterator itpath = tmpselectedImgpaths.begin(); itpath != tmpselectedImgpaths.end(); itpath++)
- {
- if ((nIndex = itpath->find_last_of(_T('\\'))) != TString::npos)
- {
- strImage = itpath->substr(nIndex + 1);
- if ((nIndex = strImage.find_last_of(_T('.'))) != TString::npos)
- {
- strImage = strImage.substr(nIndex);
- filehelpImpl::uppercase(strImage);
- filehelpImpl::uppercase(*itName);
- if (itName->compare(strImage) == 0)
- {
- bGetImage = TRUE;
- AryOfSelectedImagepaths.push_back(itpath->c_str());
- break;
- }
- }
- }
- }
- if (!bGetImage)
- {
- AryOfSelectedImagepaths.push_back(_T(""));
- }
- }
- // 重新排序;
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSceneryImages(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN LPCTSTR lpScenery, IN LPCTSTR lpLoadExt, OUT CStringArray& AryOfSceneryImagepaths, OUT CStringArray* pAryOfSceneryDirectory /* = NULL */)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- int nSize = 0;
- CString strImage = _T("");
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- TCHAR szScenery[MAX_PATH] = { 0 };
- if (lpScenery == NULL || (_tcscmp(lpScenery, _T("")) == 0 || _tcscmp(lpScenery, _T("全部")) == 0))
- _stprintf_s(szScenery, _T("%s"), _T(""));
- else
- _stprintf_s(szScenery, _T("%s"), lpScenery);
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpOrderNum, szScenery);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum, szScenery);
- }
- if (PathFileExists(szOrderpath))
- {
- if (pAryOfSceneryDirectory)
- pAryOfSceneryDirectory->Add(szOrderpath);
- LoadSpecifiedpathImages(szOrderpath, lpLoadExt, AryOfSceneryImagepaths);
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSceneryImages(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN LPCTSTR lpScenery, IN LPCTSTR lpLoadExt, OUT STR_VEC& AryOfSceneryImagepaths, OUT STR_VEC* pAryOfSceneryDirectory /* = NULL */)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- int nSize = 0;
- CString strImage = _T("");
- TCHAR szScenery[MAX_PATH] = { 0 };
- if (lpScenery == NULL || (_tcscmp(lpScenery, _T("")) == 0 || _tcscmp(lpScenery, _T("全部")) == 0))
- _stprintf_s(szScenery, _T("%s"), _T(""));
- else
- _stprintf_s(szScenery, _T("%s"), lpScenery);
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpOrderNum, szScenery);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum, szScenery);
- }
- if (PathFileExists(szOrderpath))
- {
- if (pAryOfSceneryDirectory)
- pAryOfSceneryDirectory->push_back(szOrderpath);
- LoadSpecifiedpathImages(szOrderpath, lpLoadExt, AryOfSceneryImagepaths);
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadOrderImages(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN LPCTSTR lpLoadExt, OUT CStringArray& AryOfOrderImagePaths, OUT CStringArray* pAryOfOrderDirectory /* = NULL */)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- int nSize = 0;
- CString strImage = _T("");
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum);
- }
- if (PathFileExists(szOrderpath))
- {
- if (pAryOfOrderDirectory)
- pAryOfOrderDirectory->Add(szOrderpath);
- LoadSpecifiedpathImages(szOrderpath, lpLoadExt, AryOfOrderImagePaths);
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadOrderImages(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN LPCTSTR lpLoadExt, OUT STR_VEC& AryOfOrderImagePaths, OUT STR_VEC* pAryOfOrderDirectory /* = NULL */)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- int nSize = 0;
- CString strImage = _T("");
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum);
- }
- if (PathFileExists(szOrderpath))
- {
- if (pAryOfOrderDirectory)
- pAryOfOrderDirectory->push_back(szOrderpath);
- LoadSpecifiedpathImages(szOrderpath, lpLoadExt, AryOfOrderImagePaths);
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::GetOrderAllShareDirectory(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, OUT CStringArray& AryOfOrderAllShareDirectory)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum);
- }
- if (PathFileExists(szOrderpath))
- {
- AryOfOrderAllShareDirectory.Add(szOrderpath);
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::GetOrderAllShareDirectory(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, OUT STR_VEC& AryOfOrderAllShareDirectory)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum);
- }
- if (PathFileExists(szOrderpath))
- {
- AryOfOrderAllShareDirectory.push_back(szOrderpath);
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::GetSceneryAllShareDirectory(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN LPCTSTR lpScenery, OUT CStringArray &AryOfSceneryAllShareDirectory)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- TCHAR szScenery[MAX_PATH] = { 0 };
- if (lpScenery == NULL || (_tcscmp(lpScenery, _T("")) == 0 || _tcscmp(lpScenery, _T("全部")) == 0))
- _stprintf_s(szScenery, _T("%s"), _T(""));
- else
- _stprintf_s(szScenery, _T("%s"), lpScenery);
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpOrderNum, szScenery);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum, szScenery);
- }
- if (PathFileExists(szOrderpath))
- {
- AryOfSceneryAllShareDirectory.Add(szOrderpath);
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::GetSceneryAllShareDirectory(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN LPCTSTR lpScenery, OUT STR_VEC &AryOfSceneryAllShareDirectory)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- TCHAR szScenery[MAX_PATH] = { 0 };
- if (lpScenery == NULL || (_tcscmp(lpScenery, _T("")) == 0 || _tcscmp(lpScenery, _T("全部")) == 0))
- _stprintf_s(szScenery, _T("%s"), _T(""));
- else
- _stprintf_s(szScenery, _T("%s"), lpScenery);
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpOrderNum, szScenery);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum, szScenery);
- }
- if (PathFileExists(szOrderpath))
- {
- AryOfSceneryAllShareDirectory.push_back(szOrderpath);
- }
- }
- }
- return TRUE;
- }
- //////////////////////////////////////////////////////////////////////////
- BOOL ImgOfOriginal::LoadSpecifiedpathImagesEx(IN LPCTSTR lpSepcifiedpath, IN BOOL bLoadInSubfolder, IN LPCTSTR lpLoadExt, OUT CStringArray &AryOfLoadImgs, IN LPCTSTR lpWithExt, OUT CStringArray &AryOfWithImgs)
- {
- // 指定目录是否存在;
- if (!PathFileExists(lpSepcifiedpath)) return FALSE;
- // 扩展名是否有效;
- if (!filehelpImpl::iscorrectext(lpLoadExt)) return FALSE;
- #if 0
- // 合并扩展名;
- TString findext = lpLoadExt;
- if (findext[findext.length() - 1] != _T('|'))
- {
- findext.append(_T("|"));
- }
- findext.append(lpWithExt);
- // 扩展名是否有效;
- if (!filehelpImpl::iscorrectext(lpWithExt)) return FALSE;
- #else
- TString findext;
- if (!underlyingapi::extmerge(lpLoadExt, lpWithExt,findext))
- return FALSE;
- #endif
- STR_VEC vtFiles;
- filehelpImpl lf;
- if (bLoadInSubfolder)
- {
- lf.getfiles_findin_subfolder(lpSepcifiedpath, findext.c_str(), &vtFiles);
- }
- else
- {
- lf.getfiles_findout_subfolder(lpSepcifiedpath, findext.c_str(), &vtFiles);
- }
- // 分组扩展名;
- SubgroupExt(vtFiles, lpLoadExt, AryOfLoadImgs);
- SubgroupExt(vtFiles, lpWithExt, AryOfWithImgs);
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSpecifiedpathImagesEx(IN LPCTSTR lpSepcifiedpath, IN BOOL bLoadInSubfolder, IN LPCTSTR lpLoadExt, OUT STR_VEC &AryOfLoadImgs, IN LPCTSTR lpWithExt, OUT STR_VEC &AryOfWithImgs)
- {
- // 指定目录是否存在;
- if (!PathFileExists(lpSepcifiedpath)) return FALSE;
- // 扩展名是否有效;
- if (!filehelpImpl::iscorrectext(lpLoadExt)) return FALSE;
- #if 0
- // 合并扩展名;
- TString findext = lpLoadExt;
- if (findext[findext.length() - 1] != _T('|'))
- {
- findext.append(_T("|"));
- }
- findext.append(lpWithExt);
- // 扩展名是否有效;
- if (!filehelpImpl::iscorrectext(lpWithExt)) return FALSE;
- #else
- TString findext;
- if (!underlyingapi::extmerge(lpLoadExt, lpWithExt, findext))
- return FALSE;
- #endif
- STR_VEC vtFiles;
- filehelpImpl lf;
- if (bLoadInSubfolder)
- {
- lf.getfiles_findin_subfolder(lpSepcifiedpath, findext.c_str(), &vtFiles);
- }
- else
- {
- lf.getfiles_findout_subfolder(lpSepcifiedpath, findext.c_str(), &vtFiles);
- }
- // 分组扩展名;
- SubgroupExt(vtFiles, lpLoadExt, AryOfLoadImgs);
- SubgroupExt(vtFiles, lpWithExt, AryOfWithImgs);
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSelectedIamgesFromSpecifiedpathEx(IN LPCTSTR lpSepcifiedpath, IN BOOL bLoadInSubfolder, IN CStringArray &AryOfSelectedIamges, OUT CStringArray &AryOfNoExistIamges, IN LPCTSTR lpLoadExt, OUT CStringArray &AryOfLoadImagepaths, IN LPCTSTR lpWithExt, OUT CStringArray &AryOfWithImagepaths)
- {
- // 指定目录是否存在;
- if (!PathFileExists(lpSepcifiedpath)) return FALSE;
- // 扩展名是否有效;
- if (!filehelpImpl::iscorrectext(lpLoadExt)) return FALSE;
- #if 0
- // 合并扩展名;
- TString findext = lpLoadExt;
- if (findext[findext.length() - 1] != _T('|'))
- {
- findext.append(_T("|"));
- }
- findext.append(lpWithExt);
- // 扩展名是否有效;
- if (!filehelpImpl::iscorrectext(lpWithExt)) return FALSE;
- #else
- TString findext;
- if (!underlyingapi::extmerge(lpLoadExt, lpWithExt, findext))
- return FALSE;
- #endif
- STR_VEC vtFiles;
- filehelpImpl lf;
- if (bLoadInSubfolder)
- {
- lf.getfiles_findin_subfolder(lpSepcifiedpath, findext.c_str(), &vtFiles);
- }
- else
- {
- lf.getfiles_findout_subfolder(lpSepcifiedpath, findext.c_str(), &vtFiles);
- }
- #if 0
- // 分组扩展名;
- CStringArray AryLoad;
- CStringArray AryWith;
- SubgroupExt(vtFiles, lpLoadExt, AryLoad);
- SubgroupExt(vtFiles, lpWithExt, AryWith);
- // 过滤不存在的文件名;
- BOOL bExist;
- CString strname;
- int nSize = AryOfSelectedIamges.GetSize();
- for (int i = 0; i < nSize; i++)
- {
- bExist = FALSE;
- for (int n = 0; n < AryLoad.GetSize(); n++)
- {
- strname = GetFileName(AryLoad.ElementAt(n));
- if (strname.CompareNoCase(AryOfSelectedIamges.ElementAt(i)) == 0)
- {
- bExist = TRUE;
- AryOfLoadImagepaths.Add(AryLoad.ElementAt(n));
- //break; //不能break,否则其他扩展名会加载不了;
- }
- }
- for (int j = 0; j < AryWith.GetSize(); j++)
- {
- strname = GetFileName(AryWith.ElementAt(j));
- if (strname.CompareNoCase(AryOfSelectedIamges.ElementAt(i)) == 0)
- {
- AryOfWithImagepaths.Add(AryWith.ElementAt(j));
- //break; 同理;
- }
- }
- if (!bExist)
- {
- AryOfNoExistIamges.Add(AryOfSelectedIamges.ElementAt(i));
- }
- }
- #else // 以下做法,无法获取不存在文件的相片名; 但是使用另一变量来保存存在的相片名,再与原相片名相减;
- SubgroupExt(vtFiles, lpLoadExt, AryOfLoadImagepaths);
- SubgroupExt(vtFiles, lpWithExt, AryOfWithImagepaths);
- // 过滤不存在的文件名;
- BOOL bExist;
- CString strname;
- int nSize = AryOfSelectedIamges.GetSize();
- CStringArray AryExistImg; // 存在文件的相片名;
- for (int i = AryOfLoadImagepaths.GetSize() - 1; i > 0; i--)
- {
- bExist = FALSE;
- strname = GetFileName(AryOfLoadImagepaths.ElementAt(i));
- for (int n = 0; n < nSize; n++)
- {
- if (strname.CompareNoCase(AryOfSelectedIamges.ElementAt(n)) == 0)
- {
- bExist = TRUE;
- if (!underlyingapi::IsStringExistNoCase(strname, AryExistImg))
- AryExistImg.Add(strname);
- // 不能break;因为如果加载多个扩展名的话,会加载后面的失败;
- }
- }
- if (!bExist)
- {
- AryOfLoadImagepaths.RemoveAt(i);
- }
- }
- for (int i = AryOfWithImagepaths.GetSize() - 1; i > 0; i--)
- {
- bExist = FALSE;
- strname = GetFileName(AryOfWithImagepaths.ElementAt(i));
- for (int n = 0; n < nSize; n++)
- {
- if (strname.CompareNoCase(AryOfSelectedIamges.ElementAt(n)) == 0)
- {
- bExist = TRUE;
- }
- }
- if (!bExist)
- {
- AryOfWithImagepaths.RemoveAt(i);
- }
- }
- // 减去存在的相片名;
- #if 0
- for (int i = AryOfSelectedIamges.GetSize() - 1; i > 0; i--)
- {
- for (int n = AryExistImg.GetSize() - 1; n > 0; n-- )
- {
- if (AryExistImg.ElementAt(n).CompareNoCase(AryOfSelectedIamges.ElementAt(i)) == 0)
- {
- AryOfSelectedIamges.RemoveAt(i);
- break;
- }
- }
- }
- #else
- for (int i = AryOfSelectedIamges.GetSize() - 1; i > 0; i--)
- {
- bExist = FALSE;
- for (int n = AryExistImg.GetSize() - 1; n > 0; n-- )
- {
- if (AryExistImg.ElementAt(n).CompareNoCase(AryOfSelectedIamges.ElementAt(i)) == 0)
- {
- bExist = TRUE;
- break;
- }
- }
- if ( !bExist )
- {
- AryOfNoExistIamges.Add(AryOfSelectedIamges.ElementAt(i));
- }
- }
- #endif
- #endif
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSelectedIamgesFromSpecifiedpathEx(IN LPCTSTR lpSepcifiedpath, IN BOOL bLoadInSubfolder, IN STR_VEC &AryOfSelectedIamges, OUT STR_VEC &AryOfNoExistIamges, IN LPCTSTR lpLoadExt, OUT STR_VEC &AryOfLoadImagepaths, IN LPCTSTR lpWithExt, OUT STR_VEC &AryOfWithImagepaths)
- {
- // 指定目录是否存在;
- if (!PathFileExists(lpSepcifiedpath)) return FALSE;
- // 扩展名是否有效;
- if (!filehelpImpl::iscorrectext(lpLoadExt)) return FALSE;
- #if 0
- // 合并扩展名;
- TString findext = lpLoadExt;
- if (findext[findext.length() - 1] != _T('|'))
- {
- findext.append(_T("|"));
- }
- findext.append(lpWithExt);
- // 扩展名是否有效;
- if (!filehelpImpl::iscorrectext(lpWithExt)) return FALSE;
- #else
- TString findext;
- if (!underlyingapi::extmerge(lpLoadExt, lpWithExt, findext))
- return FALSE;
- #endif
- STR_VEC vtFiles;
- filehelpImpl lf;
- if (bLoadInSubfolder)
- {
- lf.getfiles_findin_subfolder(lpSepcifiedpath, findext.c_str(), &vtFiles);
- }
- else
- {
- lf.getfiles_findout_subfolder(lpSepcifiedpath, findext.c_str(), &vtFiles);
- }
- // 分组扩展名;
- SubgroupExt(vtFiles, lpLoadExt, AryOfLoadImagepaths);
- SubgroupExt(vtFiles, lpWithExt, AryOfWithImagepaths);
- TString name;
- TString name1;
- BOOL bExist = FALSE;
- STR_VEC vtExistImg;
- // 过滤无用文件名;
- for (STR_VEC::iterator it = AryOfLoadImagepaths.begin(); it != AryOfLoadImagepaths.end(); )
- {
- bExist = FALSE;
- name = filehelpImpl::getfilename(*it);
- filehelpImpl::uppercase(name);
- for (STR_VEC::iterator itn = AryOfSelectedIamges.begin(); itn != AryOfSelectedIamges.end(); itn++)
- {
- filehelpImpl::uppercase(*itn);
- if ( name.compare(*itn) == 0 )
- {
- bExist = TRUE;
- it++;
- vtExistImg.push_back(name);
- break;
- }
- }
- if ( !bExist )
- {
- it = AryOfLoadImagepaths.erase(it);
- }
- }
- // 过滤无用文件名;
- for (STR_VEC::iterator it = AryOfWithImagepaths.begin(); it != AryOfWithImagepaths.end(); )
- {
- bExist = FALSE;
- name = filehelpImpl::getfilename(*it);
- filehelpImpl::uppercase(name);
- for (STR_VEC::iterator itn = AryOfSelectedIamges.begin(); itn != AryOfSelectedIamges.end(); itn++)
- {
- filehelpImpl::uppercase(*itn);
- if ( name.compare(*itn) == 0 )
- {
- bExist = TRUE;
- it++;
- vtExistImg.push_back(name);
- break;
- }
- }
- if ( !bExist )
- {
- it = AryOfWithImagepaths.erase(it);
- }
- }
- // 减去存在的相片名;
- for ( STR_VEC::iterator it = AryOfSelectedIamges.begin(); it != AryOfSelectedIamges.end(); )
- {
- bExist = FALSE;
- for ( STR_VEC::iterator ite = vtExistImg.begin(); ite != vtExistImg.end(); ite++ )
- {
- if ( ite->compare(*it) == 0 )
- {
- bExist = TRUE;
- break;
- }
- }
- if ( !bExist )
- {
- AryOfNoExistIamges.push_back(*it);
- }
- it++;
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSelectedIamgesEx(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN BOOL bLoadInSubfolder, IN CStringArray &AryOfSelectedIamges, OUT CStringArray &AryOfNoExistIamges, IN LPCTSTR lpLoadExt, OUT CStringArray &AryOfLoadImagepaths, IN LPCTSTR lpWithExt, OUT CStringArray &AryOfWithImagepaths)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- int nSize = 0;
- CString strImage = _T("");
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- TCHAR szShareDirectory[MAX_PATH] = { 0 };
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum);
- }
- if (PathFileExists(szOrderpath))
- {
- LoadSelectedIamgesFromSpecifiedpathEx(szOrderpath, bLoadInSubfolder, AryOfSelectedIamges, AryOfNoExistIamges, lpLoadExt, AryOfLoadImagepaths, lpWithExt, AryOfWithImagepaths);
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSelectedIamgesEx(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN BOOL bLoadInSubfolder, IN STR_VEC &AryOfSelectedIamges, OUT STR_VEC &AryOfNoExistIamges, IN LPCTSTR lpLoadExt, OUT STR_VEC &AryOfLoadImagepaths, IN LPCTSTR lpWithExt, OUT STR_VEC &AryOfWithImagepaths)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- int nSize = 0;
- CString strImage = _T("");
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum);
- }
- if (PathFileExists(szOrderpath))
- {
- LoadSelectedIamgesFromSpecifiedpathEx(szOrderpath, bLoadInSubfolder, AryOfSelectedIamges, AryOfNoExistIamges, lpLoadExt, AryOfLoadImagepaths, lpWithExt, AryOfWithImagepaths);
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSelectedIamgesInOrderEx(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN BOOL bLoadInSubfolder, IN CStringArray &AryOfSelectedIamges, OUT CStringArray &AryOfNoExistIamges, IN LPCTSTR lpLoadExt, OUT CStringArray &AryOfLoadImagepaths, IN LPCTSTR lpWithExt, OUT CStringArray &AryOfWithImagepaths)
- {
- CStringArray tmpLoadImgpaths;
- CStringArray tmpWithImgpaths;
- if ( !LoadSelectedIamgesEx(nImgType, lpBranchId, lpOrderNum, bLoadInSubfolder, AryOfSelectedIamges, AryOfNoExistIamges, lpLoadExt, tmpLoadImgpaths, lpWithExt, tmpWithImgpaths))
- return FALSE;
- CString strImage = _T("");
- // 再按顺序加入AryOfSelectedImagePaths;
- for (int i = 0; i < AryOfSelectedIamges.GetSize(); i++)
- {
- // 如果某张相片没有找到对应的文件,赋空;
- BOOL bGetImage = FALSE;
- for (int n = 0; n < tmpLoadImgpaths.GetSize(); n++)
- {
- strImage = tmpLoadImgpaths.ElementAt(n).Mid(tmpLoadImgpaths.ElementAt(n).ReverseFind('\\') + 1);
- strImage = strImage.Left(strImage.Find('.'));
- if (AryOfSelectedIamges.ElementAt(i).CompareNoCase(strImage) == 0)
- {
- bGetImage = TRUE;
- AryOfLoadImagepaths.Add(tmpLoadImgpaths.ElementAt(n));
- break;
- }
- }
- if (!bGetImage)
- {
- AryOfLoadImagepaths.Add(_T(""));
- }
- }
- for (int i = 0; i < AryOfSelectedIamges.GetSize(); i++)
- {
- // 如果某张相片没有找到对应的文件,赋空;
- BOOL bGetImage = FALSE;
- for (int n = 0; n < tmpWithImgpaths.GetSize(); n++)
- {
- strImage = tmpWithImgpaths.ElementAt(n).Mid(tmpWithImgpaths.ElementAt(n).ReverseFind('\\') + 1);
- strImage = strImage.Left(strImage.Find('.'));
- if (AryOfWithImagepaths.ElementAt(i).CompareNoCase(strImage) == 0)
- {
- bGetImage = TRUE;
- AryOfWithImagepaths.Add(tmpWithImgpaths.ElementAt(n));
- break;
- }
- }
- if (!bGetImage)
- {
- AryOfWithImagepaths.Add(_T(""));
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSelectedIamgesInOrderEx(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN BOOL bLoadInSubfolder, IN STR_VEC &AryOfSelectedIamges, OUT STR_VEC &AryOfNoExistIamges, IN LPCTSTR lpLoadExt, OUT STR_VEC &AryOfLoadImagepaths, IN LPCTSTR lpWithExt, OUT STR_VEC &AryOfWithImagepaths)
- {
- STR_VEC tmpLoadImg;
- STR_VEC tmpWithImg;
- if (!LoadSelectedIamgesEx(nImgType, lpBranchId, lpOrderNum, bLoadInSubfolder, AryOfSelectedIamges, AryOfNoExistIamges, lpLoadExt, tmpLoadImg, lpWithExt, tmpWithImg))
- return FALSE;
- int nIndex = 0;
- TString strImage = _T("");
- // 再按顺序加入AryOfSelectedImagePaths;
- for (STR_VEC::iterator itName = AryOfSelectedIamges.begin(); itName != AryOfSelectedIamges.end(); itName++)
- {
- // 如果某张相片没有找到对应的文件,赋空;
- BOOL bGetImage = FALSE;
- for (STR_VEC::iterator itpath = tmpLoadImg.begin(); itpath != tmpLoadImg.end(); itpath++)
- {
- if ((nIndex = itpath->find_last_of(_T('\\'))) != TString::npos)
- {
- strImage = itpath->substr(nIndex + 1);
- if ((nIndex = strImage.find_last_of(_T('.'))) != TString::npos)
- {
- strImage = strImage.substr(nIndex);
- filehelpImpl::uppercase(strImage);
- filehelpImpl::uppercase(*itName);
- if (itName->compare(strImage) == 0)
- {
- bGetImage = TRUE;
- AryOfLoadImagepaths.push_back(itpath->c_str());
- break;
- }
- }
- }
- }
- if (!bGetImage)
- {
- AryOfLoadImagepaths.push_back(_T(""));
- }
- }
- for (STR_VEC::iterator itName = AryOfSelectedIamges.begin(); itName != AryOfSelectedIamges.end(); itName++)
- {
- // 如果某张相片没有找到对应的文件,赋空;
- BOOL bGetImage = FALSE;
- for (STR_VEC::iterator itpath = tmpLoadImg.begin(); itpath != tmpLoadImg.end(); itpath++)
- {
- if ((nIndex = itpath->find_last_of(_T('\\'))) != TString::npos)
- {
- strImage = itpath->substr(nIndex + 1);
- if ((nIndex = strImage.find_last_of(_T('.'))) != TString::npos)
- {
- strImage = strImage.substr(nIndex);
- filehelpImpl::uppercase(strImage);
- filehelpImpl::uppercase(*itName);
- if (itName->compare(strImage) == 0)
- {
- bGetImage = TRUE;
- AryOfWithImagepaths.push_back(itpath->c_str());
- break;
- }
- }
- }
- }
- if (!bGetImage)
- {
- AryOfWithImagepaths.push_back(_T(""));
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSceneryImagesEx(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN LPCTSTR lpScenery, IN LPCTSTR lpLoadExt, OUT CStringArray& AryOfLoadImagepaths, IN LPCTSTR lpWithExt, IN CStringArray& AryOfWithImagepaths, OUT CStringArray* pAryOfSceneryDirectory /* = NULL */)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- int nSize = 0;
- CString strImage = _T("");
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- TCHAR szScenery[MAX_PATH] = { 0 };
- if (lpScenery == NULL || (_tcscmp(lpScenery, _T("")) == 0 || _tcscmp(lpScenery, _T("全部")) == 0))
- _stprintf_s(szScenery, _T("%s"), _T(""));
- else
- _stprintf_s(szScenery, _T("%s"), lpScenery);
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpOrderNum, szScenery);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum, szScenery);
- }
- if (PathFileExists(szOrderpath))
- {
- if (pAryOfSceneryDirectory)
- pAryOfSceneryDirectory->Add(szOrderpath);
- //LoadSpecifiedpathImages(szOrderpath, lpLoadExt, AryOfSceneryImagepaths);
- LoadSpecifiedpathImagesEx(szOrderpath, FALSE, lpLoadExt, AryOfLoadImagepaths, lpWithExt, AryOfWithImagepaths);
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadSceneryImagesEx(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN LPCTSTR lpScenery, IN LPCTSTR lpLoadExt, OUT STR_VEC& AryOfLoadImagepaths, IN LPCTSTR lpWithExt, IN STR_VEC& AryOfWithImagepaths, OUT STR_VEC* pAryOfSceneryDirectory /* = NULL */)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- int nSize = 0;
- CString strImage = _T("");
- TCHAR szScenery[MAX_PATH] = { 0 };
- if (lpScenery == NULL || (_tcscmp(lpScenery, _T("")) == 0 || _tcscmp(lpScenery, _T("全部")) == 0))
- _stprintf_s(szScenery, _T("%s"), _T(""));
- else
- _stprintf_s(szScenery, _T("%s"), lpScenery);
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpOrderNum, szScenery);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum, szScenery);
- }
- if (PathFileExists(szOrderpath))
- {
- if (pAryOfSceneryDirectory)
- pAryOfSceneryDirectory->push_back(szOrderpath);
- //LoadSpecifiedpathImages(szOrderpath, lpLoadExt, AryOfSceneryImagepaths);
- LoadSpecifiedpathImagesEx(szOrderpath, FALSE, lpLoadExt, AryOfLoadImagepaths, lpWithExt, AryOfWithImagepaths);
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadOrderImagesEx(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN BOOL bLoadInSubfolder, IN LPCTSTR lpLoadExt, OUT CStringArray& AryOfOrderImagePaths, IN LPCTSTR lpWithExt, IN CStringArray& AryOfWithImagepaths, OUT CStringArray* pAryOfOrderDirectory /* = NULL */)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- int nSize = 0;
- CString strImage = _T("");
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum);
- }
- if (PathFileExists(szOrderpath))
- {
- if (pAryOfOrderDirectory)
- pAryOfOrderDirectory->Add(szOrderpath);
- //LoadSpecifiedpathImages(szOrderpath, lpLoadExt, AryOfOrderImagePaths);
- LoadSpecifiedpathImagesEx(szOrderpath, FALSE, lpLoadExt, AryOfOrderImagePaths, lpWithExt, AryOfWithImagepaths);
- }
- }
- }
- return TRUE;
- }
- BOOL ImgOfOriginal::LoadOrderImagesEx(IN CONST INT &nImgType, IN LPCTSTR lpBranchId, IN LPCTSTR lpOrderNum, IN BOOL bLoadInSubfolder, IN LPCTSTR lpLoadExt, OUT STR_VEC& AryOfOrderImagePaths, IN LPCTSTR lpWithExt, IN STR_VEC& AryOfWithImagepaths, OUT STR_VEC* pAryOfOrderDirectory /* = NULL */)
- {
- // 判断域名有效性;
- if (lpBranchId == NULL || _tcscmp(lpBranchId, _T("")) == 0) return FALSE; // 传入的域名空;
- if (_tcsstr(lpBranchId, _T(".ly.com")) == NULL) return FALSE; // 域名有错;
- if (gp_vtImgShareInfo || gp_vtImgShareInfo->size() == 0) return FALSE; // 共享路径无;
- if (g_pBranchId == NULL) return FALSE; // 本机域名出错;
- int nSize = 0;
- CString strImage = _T("");
- for (IMGSHARE_VEC::iterator it = gp_vtImgShareInfo->begin(); it != gp_vtImgShareInfo->end(); it++)
- {
- ImgShareInfo *pImgsi = *it;
- TCHAR szOrderpath[MAX_PATH] = { 0 };
- if (nImgType == pImgsi->byImgType && _tcscmp(lpBranchId, pImgsi->szBranchId) == 0)
- {
- if (_tcscmp(lpBranchId, g_pBranchId) == 0)
- {//本机域名;
- _stprintf_s(szOrderpath, _T("%s\\%s"), pImgsi->szShareDirectory, lpOrderNum);
- }
- else
- {
- _stprintf_s(szOrderpath, _T("%s\\%s\\%s"), pImgsi->szShareDirectory, lpBranchId, lpOrderNum);
- }
- if (PathFileExists(szOrderpath))
- {
- if (pAryOfOrderDirectory)
- pAryOfOrderDirectory->push_back(szOrderpath);
- //LoadSpecifiedpathImages(szOrderpath, lpLoadExt, AryOfOrderImagePaths);
- LoadSpecifiedpathImagesEx(szOrderpath, FALSE, lpLoadExt, AryOfOrderImagePaths, lpWithExt, AryOfWithImagepaths);
- }
- }
- }
- return TRUE;
- }
|