DBServerDlg.cpp 218 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937
  1. /****************************************************************/
  2. /* */
  3. /* ApplicationDlg.cpp */
  4. /* */
  5. /* Implementation of the CDBServerDlg class. */
  6. /* This class is a part of the Date Server. */
  7. /* */
  8. /* Programmed by LYFZ van der Meer */
  9. /* Copyright LYFZ Software Solutions 2002 */
  10. /* http://www.LYFZvandermeer.nl */
  11. /* */
  12. /* Last updated: 10 july 2002 */
  13. /* */
  14. /****************************************************************/
  15. //在ApplicationDlg.cpp文件中实现主窗口界面的设计。及其主窗口相应控件的功能和参数的映射。 D4F876E2-w78F-22D5-q98A-Y0B0D07B847C
  16. #include "stdafx.h"
  17. #include "DBServer.h"
  18. #include "theDBServer.h"
  19. #include "DBServerDlg.h"
  20. #include "UserAccountsDlg.h"
  21. #include "WizardPages.h"
  22. #include "AboutDlg.h"
  23. #include <afxpriv.h>
  24. #include <process.h>
  25. //#include "Shlwapi.h"
  26. #include "ClientCenter.h"
  27. #include "MyLock.h"
  28. #include "mysqldata.h"
  29. #include "./helper/ffsco.h"
  30. //#include <tlhelp32.h>
  31. #include "ShowPic3.h"
  32. #include "DogTimeOutDlg.h"
  33. #include "InputAuthDlg.h"
  34. #include "ConnectThread.h"
  35. #pragma comment(lib, "NETAPI32.LIB ")
  36. #include "SelYear.h"
  37. /*********ErrorExit(...)函数头文件************/
  38. //#include <strsafe.h>
  39. /***********************************/
  40. #ifdef _DEBUG
  41. #define new DEBUG_NEW
  42. #undef THIS_FILE
  43. static char THIS_FILE[] = __FILE__;
  44. #endif
  45. #define LIMITCOUNT 1 //历史数据每次转10个 autorun
  46. extern BOOL g_bSteal;
  47. extern BOOL g_bConvertHisAll;
  48. extern CDBServer theApp;
  49. extern CtheDBServer theServer;
  50. #define WM_ICON_NOTIFY WM_USER+12
  51. CDBServerDlg *g_pMainWnd = NULL;
  52. //#define IPC_CUSTOM_MSG2 _T("{D4F876E2-w78F-22D5-q98A-Y0B0D07B847C}")
  53. #define IPC_CUSTOM_MSG2 _T("{E4F876E2-Q78F-22D5-C98A-Y0B0D07B847C}")
  54. UINT g_wmClose = RegisterWindowMessage(IPC_CUSTOM_MSG2);
  55. //extern BOOL EncryptFile2(BYTE *buffer, DWORD leng, PCHAR szPassword);
  56. //extern CStringArray g_conniparray;
  57. CArray<CDatabase*, CDatabase*>g_pHistoryDBarray[200];
  58. CDatabase *g_pDB[200];
  59. CConnectThread *g_pThreadPt[200];
  60. int g_nDBCount = 0;
  61. /////////////////////////////////////////////////////////////////////////////
  62. // CDBServerDlg dialog
  63. #pragma comment(lib, "Shlwapi.lib")
  64. extern DWORD g_nSendCode;
  65. extern BOOL g_bReturned;
  66. DWORD GetLastDirTime(CString dir)
  67. {
  68. try
  69. {
  70. CString path = dir;
  71. path.TrimRight("\\");
  72. path += "\\";
  73. path += "modifytime";
  74. CStdioFile fp;
  75. if (::PathFileExists(path))
  76. {
  77. fp.Open(path, CFile::modeRead);
  78. fp.ReadString(path);
  79. fp.Close();
  80. path.TrimLeft(); path.TrimRight();
  81. path.Replace("-", "");
  82. return atoi(path);
  83. }
  84. else
  85. {
  86. using namespace helper_coffs;
  87. ffsco o;
  88. o.dirs(1);
  89. o.find(LPCSTR(dir), LPCSTR("*.jpg"));
  90. ffsco::typeT coo;
  91. ffsco::typeT::iterator it;
  92. coo = o.co_file();
  93. CString path;
  94. DWORD maxdate = 0;
  95. for (it = coo.begin(); coo.end() != it; it++)
  96. {
  97. if (g_pMainWnd->m_bTerminate2)return 99999999; // Jeff.奇葩的返回值!
  98. path = (*it).c_str();
  99. maxdate = max(maxdate, atol(GetModifyTime2(path)));
  100. }
  101. return maxdate;
  102. }
  103. }
  104. catch (...)
  105. {
  106. WriteTextLog("出错");
  107. }
  108. }
  109. static UINT auIDStatusBar[] =
  110. {
  111. ID_SEPARATOR,
  112. ID_INDICATOR_DATA_RECEIVED,
  113. ID_INDICATOR_DATA_SEND,
  114. ID_INDICATOR_ONLINELED,
  115. ID_INDICATOR_OFFLINELED
  116. };
  117. /********************************************************************/
  118. /* */
  119. /* Function name : CDBServerDlg::CDBServerDlg */
  120. /* Description : Constructor */
  121. /* */
  122. /********************************************************************/
  123. CDBServerDlg::CDBServerDlg(CWnd* pParent /*=NULL*/)
  124. : CDialog(CDBServerDlg::IDD, pParent)
  125. {
  126. //{{AFX_DATA_INIT(CDBServerDlg)
  127. //}}AFX_DATA_INIT
  128. m_hIcon = AfxGetApp()->LoadIcon(IDI_DBServer);
  129. m_bTerminate = false;
  130. m_bRunning = false;
  131. m_hThread = NULL;
  132. m_bTerminate2 = false;
  133. m_bRunning2 = false;
  134. m_hThread2 = NULL;
  135. hInst = NULL;
  136. CString version = _T("Version 1.0");
  137. g_bAutoRun = AfxGetApp()->GetProfileInt(version, "brun", 0);
  138. for (int i = 0; i < 200; i++)
  139. {
  140. g_pDB[i] = NULL;
  141. g_pThreadPt[i] = NULL;
  142. }
  143. }
  144. /********************************************************************/
  145. /* */
  146. /* Function name : CDBServerDlg::~CDBServerDlg */
  147. /* Description : Destructor */
  148. /* */
  149. /********************************************************************/
  150. CDBServerDlg::~CDBServerDlg()
  151. {
  152. for (int i = 0; i < 200; i++)
  153. {
  154. CDatabase *db = g_pDB[i];
  155. if (db)
  156. {
  157. db->Close();
  158. delete db;
  159. }
  160. for (int j = 0; j < g_pHistoryDBarray[i].GetSize(); j++)
  161. {
  162. CDatabase *db = g_pHistoryDBarray[i].ElementAt(j);
  163. if (db)
  164. {
  165. db->Close();
  166. delete db;
  167. }
  168. }
  169. g_pHistoryDBarray[i].RemoveAll();
  170. }
  171. }
  172. /********************************************************************/
  173. /* */
  174. /* Function name : CDBServerDlg::DoDataExchange */
  175. /* Description : Called by the framework to exchange and validate */
  176. /* dialog data. */
  177. /* */
  178. /********************************************************************/
  179. void CDBServerDlg::DoDataExchange(CDataExchange* pDX)
  180. {
  181. CDialog::DoDataExchange(pDX);
  182. //{{AFX_DATA_MAP(CDBServerDlg)
  183. DDX_Control(pDX, IDC_INFOBAR, m_InfobarCtrl);
  184. DDX_Control(pDX, IDC_OUTLOOKBAR, m_OutlookBar);
  185. //}}AFX_DATA_MAP
  186. }
  187. BEGIN_MESSAGE_MAP(CDBServerDlg, CDialog)
  188. //{{AFX_MSG_MAP(CDBServerDlg)
  189. ON_WM_DESTROY()
  190. ON_COMMAND(ID_SERVER_START, OnServerStart)
  191. ON_UPDATE_COMMAND_UI(ID_SERVER_START, OnUpdateServerStart)
  192. ON_COMMAND(ID_SERVER_STOP, OnServerStop)
  193. ON_UPDATE_COMMAND_UI(ID_SERVER_STOP, OnUpdateServerStop)
  194. ON_COMMAND(ID_SERVER_EXIT, OnServerExit)
  195. ON_NOTIFY(NM_CLICK, IDC_OUTLOOKBAR, OnClickOutlookBar)
  196. ON_NOTIFY(LVN_KEYDOWN, IDC_OUTLOOKBAR, OnKeydownOutlookBar)
  197. ON_COMMAND(ID_USER_ACCOUNTS, OnUserAccounts)
  198. ON_WM_CLOSE()
  199. ON_COMMAND(IDC_VIEW_TRACE, OnViewTrace)
  200. ON_COMMAND(IDC_VIEW_ONLINE_USERS, OnViewOnlineUsers)
  201. ON_COMMAND(IDC_VIEW_CONFIGURATION, OnViewConfiguration)
  202. ON_UPDATE_COMMAND_UI(IDC_VIEW_TRACE, OnUpdateViewTrace)
  203. ON_UPDATE_COMMAND_UI(IDC_VIEW_ONLINE_USERS, OnUpdateViewOnlineUsers)
  204. ON_UPDATE_COMMAND_UI(IDC_VIEW_CONFIGURATION, OnUpdateViewConfiguration)
  205. ON_COMMAND(IDC_VIEW_STATISTICS, OnViewStatistics)
  206. ON_UPDATE_COMMAND_UI(IDC_VIEW_STATISTICS, OnUpdateViewStatistics)
  207. ON_COMMAND(IDC_VIEW_SECURITY, OnViewSecurity)
  208. ON_UPDATE_COMMAND_UI(IDC_VIEW_SECURITY, OnUpdateViewSecurity)
  209. ON_COMMAND(ID_ACCOUNT_WIZARD, OnAccountWizard)
  210. ON_WM_TIMER()
  211. ON_COMMAND(IDM_OPEN, OnOpen)
  212. ON_COMMAND(IDM_EXIT, OnExit)
  213. ON_COMMAND(IDM_AUTORUN, OnAutorun)
  214. //}}AFX_MSG_MAP
  215. ON_MESSAGE(WM_ICON_NOTIFY, OnTrayNotification)
  216. ON_REGISTERED_MESSAGE(g_wmClose, OnAbortClose)
  217. END_MESSAGE_MAP()
  218. LRESULT CDBServerDlg::OnAbortClose(WPARAM wParam, LPARAM lParam)
  219. {
  220. if (wParam == 2)
  221. {
  222. WriteTextLog("连接失败,服务将重启");
  223. OnExit2();
  224. }
  225. else if (wParam == 3)//更新分店
  226. {
  227. LoadBranchInfo();
  228. }
  229. return 1;
  230. }
  231. BOOL CDBServerDlg::OnInitDialog()
  232. {
  233. g_pMainWnd = this;
  234. CDialog::OnInitDialog();
  235. char server[50];
  236. DWORD leng = 50;
  237. ::GetComputerName(server, &leng);
  238. g_localip = server;
  239. MyGetIPByName(g_localip);
  240. // setup listview ctrl, so that it looks like the outbar control
  241. SetupOutlookBar();
  242. // Add statusbar to the dialog
  243. CreateStatusbar();
  244. CRect rect;
  245. GetDlgItem(IDC_STATIC1)->GetWindowRect(rect);
  246. ScreenToClient(rect);
  247. rect.right += 4;
  248. GetDlgItem(IDC_STATIC1)->MoveWindow(rect);
  249. // create property pages
  250. m_TracePage.Create(IDD_PROPPAGE_TRACE, this);
  251. m_OnlineUsersPage.Create(IDD_PROPPAGE_ONLINE, this);
  252. m_ConfigurationPage.Create(IDD_PROPPAGE_CONFIGURATION, this);
  253. m_StatisticsPage.Create(IDD_PROPPAGE_STATISTICS, this);
  254. m_SecurityPage.Create(IDD_PROPPAGE_SECURITY, this);
  255. // activate main page
  256. ActivatePage(0);
  257. // Set the icon for this dialog.
  258. SetIcon(m_hIcon, TRUE); // Set big icon
  259. SetIcon(m_hIcon, FALSE); // Set small icon
  260. g_curdb = &g_db;
  261. OnButton1(); // Jeff 初始化服务端,内含定时器1;
  262. GetFileDate(); // Jeff获取文件信息;
  263. //LoadDB();
  264. LoadHistoryDB();//Jeff加载历史数据库;
  265. int aaaa = 30;
  266. while (aaaa--)
  267. AddOneConn();//添加数据库连接;
  268. SetTimer(2, 10, NULL);
  269. CheckBakState();// 检查相片备份情况
  270. hInst = LoadLibrary("SENSAPI.DLL"); //加载动态库 ;
  271. if (hInst)
  272. {
  273. typedef BOOL(WINAPI *MYFUNC)(LPDWORD);
  274. MYFUNC IsNetworkConnect = NULL;
  275. //取得IsNetworkAlive函数指针
  276. IsNetworkConnect = (MYFUNC)GetProcAddress(hInst, "IsNetworkAlive");
  277. if (IsNetworkConnect)
  278. {
  279. DWORD dwActiveWan = 1;
  280. if (IsNetworkConnect(&dwActiveWan))
  281. m_bNetWorkOK = 1;
  282. else
  283. m_bNetWorkOK = 0;
  284. SetTimer(5, 10000, NULL);
  285. }
  286. else
  287. m_bNetWorkOK = 0;
  288. }
  289. else
  290. m_bNetWorkOK = 0;
  291. return TRUE;
  292. }
  293. /********************************************************************/
  294. /* */
  295. /* Function name : OnDestroy */
  296. /* Description : Handle WM_DESTROY message */
  297. /* */
  298. /********************************************************************/
  299. void CDBServerDlg::OnDestroy()
  300. {
  301. OnServerStop();
  302. KillTimer(1);
  303. KillTimer(2);
  304. KillTimer(3);
  305. KillTimer(4);
  306. KillTimer(5);
  307. KillTimer(6);
  308. KillTimer(7);
  309. KillTimer(8);
  310. CDialog::OnDestroy();
  311. }
  312. /********************************************************************/
  313. /* */
  314. /* Function name : OnServerStart */
  315. /* Description : Start Date Server -> start listening on port 21 */
  316. /* */
  317. /********************************************************************/
  318. //启动数据服务器,使其在21号端口侦听
  319. void CDBServerDlg::OnServerStart()
  320. {
  321. ServerStart();
  322. }
  323. BOOL CDBServerDlg::ServerStart()
  324. {
  325. if (theServer.Start())
  326. {
  327. m_wndStatusBar.SetPaneText(0, "数据服务已启动", TRUE);
  328. SetOnlineLed(TRUE);
  329. SetOfflineLed(FALSE);
  330. WriteTextLog("启动成功");
  331. return 1;
  332. }
  333. else
  334. {
  335. WriteTextLog("启动失败");
  336. CDialog::OnCancel();
  337. return 0;
  338. }
  339. }
  340. /********************************************************************/
  341. /* */
  342. /* Function name : OnUpdateServerStart */
  343. /* Description : Update 'Start' status */
  344. /* */
  345. /********************************************************************/
  346. void CDBServerDlg::OnUpdateServerStart(CCmdUI* pCmdUI)
  347. {
  348. pCmdUI->Enable(!theServer.IsActive());
  349. }
  350. /********************************************************************/
  351. /* */
  352. /* Function name : OnServerStop */
  353. /* Description : Stop Date Server */
  354. /* */
  355. /********************************************************************/
  356. //停止服务器
  357. void CDBServerDlg::OnServerStop()
  358. {
  359. theServer.Stop();
  360. m_wndStatusBar.SetPaneText(0, "数据服务已停止", TRUE);
  361. SetOnlineLed(FALSE);
  362. SetOfflineLed(TRUE);
  363. }
  364. /********************************************************************/
  365. /* */
  366. /* Function name : OnUpdateServerStop */
  367. /* Description : Update 'Stop' status */
  368. /* */
  369. /********************************************************************/
  370. void CDBServerDlg::OnUpdateServerStop(CCmdUI* pCmdUI)
  371. {
  372. pCmdUI->Enable(theServer.IsActive());
  373. }
  374. /********************************************************************/
  375. /* */
  376. /* Function name : OnServerExit */
  377. /* Description : Let's get out of here... */
  378. /* */
  379. /********************************************************************/
  380. void CDBServerDlg::OnServerExit()
  381. {
  382. OnCancel();
  383. }
  384. /********************************************************************/
  385. /* */
  386. /* Function name : CDBServerDlg::SetupOutlookBar */
  387. /* Description : Initialize listview, change color/iconspacing to */
  388. /* make it look a little bit like the outlook bar. */
  389. /* */
  390. /********************************************************************/
  391. void CDBServerDlg::SetupOutlookBar()
  392. {
  393. // create Imagelist
  394. m_ImageList.Create(32, 32, ILC_COLOR16 | ILC_MASK, 1, 4);
  395. HICON hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_LOG));
  396. m_ImageList.Add(hIcon);
  397. hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ONLINE_USERS));
  398. m_ImageList.Add(hIcon);
  399. hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_CONFIGURATION));
  400. m_ImageList.Add(hIcon);
  401. hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_SECURITY));
  402. m_ImageList.Add(hIcon);
  403. hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_STATISTICS));
  404. m_ImageList.Add(hIcon);
  405. m_OutlookBar.SetImageList(&m_ImageList, LVSIL_NORMAL);
  406. CRect rc;
  407. m_OutlookBar.GetClientRect(rc);
  408. // set new icon spacing
  409. m_OutlookBar.SetIconSpacing(rc.Width(), 64);
  410. // change colors
  411. m_OutlookBar.SetTextColor(RGB(255, 255, 255));
  412. m_OutlookBar.SetTextBkColor(RGB(128, 128, 128));
  413. m_OutlookBar.SetBkColor(RGB(128, 128, 128));
  414. // insert items
  415. m_OutlookBar.InsertColumn(0, "OutlookBar");
  416. m_OutlookBar.InsertItem(0, "服务器日志", 0);
  417. m_OutlookBar.InsertItem(1, "在线用户", 1);
  418. m_OutlookBar.InsertItem(2, "关于", 2);
  419. m_OutlookBar.InsertItem(3, "功能区", 3);
  420. /* m_OutlookBar.InsertItem(4, "Security", 4);*/
  421. // m_OutlookBar.SetExtendedStyle(LVS_EX_TRACKSELECT);
  422. }
  423. /********************************************************************/
  424. /* */
  425. /* Function name : CDBServerDlg::MoveChilds */
  426. /* Description : Move child windows into place holder area. */
  427. /* */
  428. /********************************************************************/
  429. void CDBServerDlg::MoveChilds()
  430. {
  431. // position property pages
  432. CRect rcDlgs;
  433. // get dialog area rect
  434. GetDlgItem(IDC_DIALOG_AREA)->GetWindowRect(rcDlgs);
  435. ScreenToClient(rcDlgs);
  436. m_ConfigurationPage.MoveWindow(rcDlgs);
  437. m_TracePage.MoveWindow(rcDlgs);
  438. m_OnlineUsersPage.MoveWindow(rcDlgs);
  439. m_StatisticsPage.MoveWindow(rcDlgs);
  440. m_SecurityPage.MoveWindow(rcDlgs);
  441. }
  442. /********************************************************************/
  443. /* */
  444. /* Function name : CDBServerDlg::ActivatePage */
  445. /* Description : Called when an icon on the outlookbar is pressed.*/
  446. /* */
  447. /********************************************************************/
  448. void CDBServerDlg::ActivatePage(int nIndex)
  449. {
  450. switch (nIndex)
  451. {
  452. case 0:
  453. m_OnlineUsersPage.ShowWindow(SW_HIDE);
  454. m_ConfigurationPage.ShowWindow(SW_HIDE);
  455. m_StatisticsPage.ShowWindow(SW_HIDE);
  456. m_SecurityPage.ShowWindow(SW_HIDE);
  457. m_TracePage.ShowWindow(SW_SHOW);
  458. m_InfobarCtrl.SetText("服务器日志");
  459. break;
  460. case 1:
  461. m_TracePage.ShowWindow(SW_HIDE);
  462. m_ConfigurationPage.ShowWindow(SW_HIDE);
  463. m_StatisticsPage.ShowWindow(SW_HIDE);
  464. m_SecurityPage.ShowWindow(SW_HIDE);
  465. m_OnlineUsersPage.RefreshData();
  466. m_OnlineUsersPage.ShowWindow(SW_SHOW);
  467. m_InfobarCtrl.SetText("在线用户");
  468. break;
  469. case 2:
  470. m_OnlineUsersPage.ShowWindow(SW_HIDE);
  471. m_TracePage.ShowWindow(SW_HIDE);
  472. m_StatisticsPage.ShowWindow(SW_HIDE);
  473. m_SecurityPage.ShowWindow(SW_HIDE);
  474. m_ConfigurationPage.ShowWindow(SW_SHOW);
  475. m_InfobarCtrl.SetText("关于");
  476. break;
  477. case 4:
  478. m_OnlineUsersPage.ShowWindow(SW_HIDE);
  479. m_TracePage.ShowWindow(SW_HIDE);
  480. m_ConfigurationPage.ShowWindow(SW_HIDE);
  481. m_SecurityPage.ShowWindow(SW_HIDE);
  482. m_StatisticsPage.ShowWindow(SW_SHOW);
  483. m_InfobarCtrl.SetText("Statistics");
  484. break;
  485. case 3:
  486. m_OnlineUsersPage.ShowWindow(SW_HIDE);
  487. m_TracePage.ShowWindow(SW_HIDE);
  488. m_ConfigurationPage.ShowWindow(SW_HIDE);
  489. m_SecurityPage.ShowWindow(SW_SHOW);
  490. m_StatisticsPage.ShowWindow(SW_HIDE);
  491. m_InfobarCtrl.SetText("功能区");
  492. break;
  493. default:
  494. break;
  495. }
  496. MoveChilds();
  497. }
  498. /********************************************************************/
  499. /* */
  500. /* Function name : CDBServerDlg::OnClickOutlookBar */
  501. /* Description : User clicked on our listview -> activate page. */
  502. /* */
  503. /********************************************************************/
  504. void CDBServerDlg::OnClickOutlookBar(NMHDR* pNMHDR, LRESULT* pResult)
  505. {
  506. // get index of selected item
  507. int nIndex = m_OutlookBar.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
  508. if (nIndex == -1)
  509. return;
  510. ActivatePage(nIndex);
  511. *pResult = 0;
  512. }
  513. /********************************************************************/
  514. /* */
  515. /* Function name : CDBServerDlg::OnKeydownOutlookBar */
  516. /* Description : User pressed a key -> activate page. */
  517. /* */
  518. /********************************************************************/
  519. void CDBServerDlg::OnKeydownOutlookBar(NMHDR* pNMHDR, LRESULT* pResult)
  520. {
  521. LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR;
  522. // get index of selected item
  523. int nIndex = m_OutlookBar.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
  524. if (nIndex == -1)
  525. return;
  526. if (pLVKeyDow->wVKey == VK_DOWN)
  527. {
  528. if (m_OutlookBar.GetItemCount() - 1 > nIndex)
  529. {
  530. ActivatePage(nIndex + 1);
  531. }
  532. }
  533. else
  534. if (pLVKeyDow->wVKey == VK_UP)
  535. {
  536. if (nIndex > 0)
  537. {
  538. ActivatePage(nIndex - 1);
  539. }
  540. }
  541. else
  542. if (pLVKeyDow->wVKey == VK_NEXT)
  543. {
  544. ActivatePage(m_OutlookBar.GetItemCount() - 1);
  545. }
  546. else
  547. if (pLVKeyDow->wVKey == VK_PRIOR)
  548. {
  549. ActivatePage(0);
  550. }
  551. *pResult = 0;
  552. }
  553. /********************************************************************/
  554. /* */
  555. /* Function name : CreateStatusbar */
  556. /* Description : This function creates a statusbar on a dialogbox.*/
  557. /* */
  558. /********************************************************************/
  559. BOOL CDBServerDlg::CreateStatusbar()
  560. {
  561. // Create the Toolbar and attach the resource
  562. if (!m_wndToolBar.Create(this) || !m_wndToolBar.LoadToolBar(IDR_TOOLBAR1))
  563. {
  564. TRACE0("Failed to Create Dialog Toolbar\n");
  565. return FALSE;
  566. }
  567. m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);
  568. // Make it flat.
  569. m_wndToolBar.ModifyStyle(0, m_wndToolBar.GetStyle() | TBSTYLE_FLAT);
  570. // Create status bar at the bottom of the dialog window
  571. if (m_wndStatusBar.Create(this))
  572. {
  573. m_wndStatusBar.SetIndicators(auIDStatusBar, sizeof(auIDStatusBar) / sizeof(UINT));
  574. m_wndStatusBar.SetPaneText(0, "Date Server is offline", TRUE);
  575. // Make a sunken or recessed border around the first pane
  576. m_wndStatusBar.SetPaneInfo(0, m_wndStatusBar.GetItemID(0), SBPS_STRETCH, NULL);
  577. SetOnlineLed(FALSE);
  578. SetOfflineLed(FALSE);
  579. m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_ONLINELED), ID_INDICATOR_ONLINELED, SBPS_NOBORDERS, 14);
  580. // m_wndStatusBar.GetStatusBarCtrl().SetTipText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_ONLINELED), "This status light is green when the server is online");
  581. m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_OFFLINELED), ID_INDICATOR_OFFLINELED, SBPS_NOBORDERS, 14);
  582. // m_wndStatusBar.GetStatusBarCtrl().SetTipText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_OFFLINELED), "This status light is green when the server is online");
  583. }
  584. // We need to resize the dialog to make room for control bars.
  585. // First, figure out how big the control bars are.
  586. CRect rcClientStart;
  587. CRect rcClientNow;
  588. GetClientRect(rcClientStart);
  589. RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0, reposQuery, rcClientNow);
  590. // Now move all the controls so they are in the same relative
  591. // position within the remaining client area as they would be
  592. // with no control bars.
  593. CPoint ptOffset(rcClientNow.left - rcClientStart.left, rcClientNow.top - rcClientStart.top);
  594. CRect rcChild;
  595. CWnd* pwndChild = GetWindow(GW_CHILD);
  596. while (pwndChild)
  597. {
  598. pwndChild->GetWindowRect(rcChild);
  599. ScreenToClient(rcChild);
  600. rcChild.OffsetRect(ptOffset);
  601. pwndChild->MoveWindow(rcChild, FALSE);
  602. pwndChild = pwndChild->GetNextWindow();
  603. }
  604. // Adjust the dialog window dimensions
  605. CRect rcWindow;
  606. GetWindowRect(rcWindow);
  607. rcWindow.right += rcClientStart.Width() - rcClientNow.Width();
  608. rcWindow.bottom += rcClientStart.Height() - rcClientNow.Height();
  609. MoveWindow(rcWindow, FALSE);
  610. // And position the control bars
  611. RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
  612. return TRUE;
  613. }
  614. /********************************************************************/
  615. /* */
  616. /* Function name : OnUserAccounts */
  617. /* Description : Show user accounts. */
  618. /* */
  619. /********************************************************************/
  620. void CDBServerDlg::OnUserAccounts()
  621. {
  622. CUserAccountsDlg dlg;
  623. theServer.m_UserManager.GetUserList(dlg.m_UserArray);
  624. if (dlg.DoModal() == IDOK)
  625. {
  626. theServer.m_UserManager.UpdateUserList(dlg.m_UserArray);
  627. }
  628. }
  629. /********************************************************************/
  630. /* */
  631. /* Function name : OnFTPUserConnected */
  632. /* Description : A user has connected to our server. */
  633. /* */
  634. /********************************************************************/
  635. void CDBServerDlg::OnFTPUserConnected(DWORD nThreadID, LPCTSTR lpszUser, LPCSTR lpszAddress)
  636. {
  637. m_OnlineUsersPage.AddUser(nThreadID, lpszUser, lpszAddress);
  638. }
  639. /********************************************************************/
  640. /* */
  641. /* Function name : OnFTPUserDisconnected */
  642. /* Description : A user has disconnected from our server. */
  643. /* */
  644. /********************************************************************/
  645. void CDBServerDlg::OnFTPUserDisconnected(DWORD nThreadID, LPCTSTR lpszUser)
  646. {
  647. m_OnlineUsersPage.RemoveUser(nThreadID);
  648. }
  649. /********************************************************************/
  650. /* */
  651. /* Function name : OnFTPStatusChange */
  652. /* Description : FTP Status changed. */
  653. /* */
  654. /********************************************************************/
  655. void CDBServerDlg::OnFTPStatusChange(int nType, LPCTSTR lpszText)
  656. {
  657. m_TracePage.AddTraceLine(nType, lpszText);
  658. switch (nType)
  659. {
  660. case 3:
  661. theApp.m_LogFile << error_lvl << date << time << lpszText << endl;
  662. break;
  663. default:
  664. theApp.m_LogFile << trace_lvl << date << time << lpszText << endl;
  665. break;
  666. }
  667. }
  668. /********************************************************************/
  669. /* */
  670. /* Function name : OnFTPReceivedBytesChange */
  671. /* Description : Number of received bytes has changed. */
  672. /* */
  673. /********************************************************************/
  674. void CDBServerDlg::OnFTPReceivedBytesChange(int nBytes)
  675. {
  676. m_StatisticsPage.SetValue(6, FormatSize(nBytes, 0));
  677. CString strStatus;
  678. strStatus.Format("%s received", FormatSize(nBytes, 0));
  679. m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_DATA_RECEIVED), strStatus, TRUE);
  680. CClientDC dc(this);
  681. CSize size = dc.GetTextExtent(strStatus);
  682. m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_DATA_RECEIVED), ID_INDICATOR_DATA_RECEIVED, SBPS_NORMAL, size.cx);
  683. }
  684. /********************************************************************/
  685. /* */
  686. /* Function name : OnFTPSentBytesChange */
  687. /* Description : Number of sent bytes has changed. */
  688. /* */
  689. /********************************************************************/
  690. void CDBServerDlg::OnFTPSentBytesChange(int nBytes)
  691. {
  692. m_StatisticsPage.SetValue(7, FormatSize(nBytes, 0));
  693. CString strStatus;
  694. strStatus.Format("%s sent", FormatSize(nBytes, 0));
  695. m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_DATA_SEND), strStatus, TRUE);
  696. CClientDC dc(this);
  697. CSize size = dc.GetTextExtent(strStatus);
  698. m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_DATA_SEND), ID_INDICATOR_DATA_SEND, SBPS_NORMAL, size.cx);
  699. }
  700. /********************************************************************/
  701. /* */
  702. /* Function name : OnViewTrace */
  703. /* Description : Handle menu selection. */
  704. /* */
  705. /********************************************************************/
  706. void CDBServerDlg::OnViewTrace()
  707. {
  708. ActivatePage(0);
  709. }
  710. /********************************************************************/
  711. /* */
  712. /* Function name : OnViewOnlineUsers */
  713. /* Description : Handle menu selection. */
  714. /* */
  715. /********************************************************************/
  716. void CDBServerDlg::OnViewOnlineUsers()
  717. {
  718. ActivatePage(1);
  719. }
  720. /********************************************************************/
  721. /* */
  722. /* Function name : OnViewConfiguration */
  723. /* Description : Handle menu selection. */
  724. /* */
  725. /********************************************************************/
  726. void CDBServerDlg::OnViewConfiguration()
  727. {
  728. ActivatePage(2);
  729. }
  730. /********************************************************************/
  731. /* */
  732. /* Function name : OnViewStatistics */
  733. /* Description : Handle menu selection. */
  734. /* */
  735. /********************************************************************/
  736. void CDBServerDlg::OnViewStatistics()
  737. {
  738. ActivatePage(3);
  739. }
  740. /********************************************************************/
  741. /* */
  742. /* Function name : OnViewSecurity */
  743. /* Description : Handle menu selection. */
  744. /* */
  745. /********************************************************************/
  746. void CDBServerDlg::OnViewSecurity()
  747. {
  748. ActivatePage(4);
  749. }
  750. /********************************************************************/
  751. /* */
  752. /* Function name : OnUpdateViewTrace */
  753. /* Description : Update menu state of Trace item. */
  754. /* */
  755. /********************************************************************/
  756. void CDBServerDlg::OnUpdateViewTrace(CCmdUI* pCmdUI)
  757. {
  758. pCmdUI->SetRadio(m_TracePage.IsWindowVisible());
  759. }
  760. /********************************************************************/
  761. /* */
  762. /* Function name : OnUpdateViewOnlineUsers */
  763. /* Description : Update menu state of Online Users item. */
  764. /* */
  765. /********************************************************************/
  766. void CDBServerDlg::OnUpdateViewOnlineUsers(CCmdUI* pCmdUI)
  767. {
  768. pCmdUI->SetRadio(m_OnlineUsersPage.IsWindowVisible());
  769. }
  770. /********************************************************************/
  771. /* */
  772. /* Function name : OnUpdateViewConfiguration */
  773. /* Description : Update menu state of Configuration item. */
  774. /* */
  775. /********************************************************************/
  776. void CDBServerDlg::OnUpdateViewConfiguration(CCmdUI* pCmdUI)
  777. {
  778. pCmdUI->SetRadio(m_ConfigurationPage.IsWindowVisible());
  779. }
  780. /********************************************************************/
  781. /* */
  782. /* Function name : OnUpdateViewStatistics */
  783. /* Description : Update menu state of Statistics item. */
  784. /* */
  785. /********************************************************************/
  786. void CDBServerDlg::OnUpdateViewStatistics(CCmdUI* pCmdUI)
  787. {
  788. pCmdUI->SetRadio(m_StatisticsPage.IsWindowVisible());
  789. }
  790. /********************************************************************/
  791. /* */
  792. /* Function name : OnUpdateViewSecurity */
  793. /* Description : Update menu state of Security item. */
  794. /* */
  795. /********************************************************************/
  796. void CDBServerDlg::OnUpdateViewSecurity(CCmdUI* pCmdUI)
  797. {
  798. pCmdUI->SetRadio(m_SecurityPage.IsWindowVisible());
  799. }
  800. /********************************************************************/
  801. /* */
  802. /* Function name : SetOnlineLed */
  803. /* Description : Turn online LED on/off. */
  804. /* */
  805. /********************************************************************/
  806. void CDBServerDlg::SetOnlineLed(BOOL bOnline)
  807. {
  808. HICON hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(),
  809. bOnline ? MAKEINTRESOURCE(IDI_LED_GREEN) : MAKEINTRESOURCE(IDI_LED_OFF),
  810. IMAGE_ICON, 16, 16, LR_SHARED);
  811. m_wndStatusBar.GetStatusBarCtrl().SetIcon(m_wndStatusBar.CommandToIndex(ID_INDICATOR_ONLINELED), hIcon);
  812. m_wndStatusBar.GetStatusBarCtrl().Invalidate();
  813. m_wndStatusBar.GetStatusBarCtrl().UpdateWindow();
  814. DestroyIcon(hIcon);
  815. }
  816. /********************************************************************/
  817. /* */
  818. /* Function name : SetOfflineLed */
  819. /* Description : Turn offline LED on/off. */
  820. /* */
  821. /********************************************************************/
  822. void CDBServerDlg::SetOfflineLed(BOOL bOffline)
  823. {
  824. HICON hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(),
  825. bOffline ? MAKEINTRESOURCE(IDI_LED_RED) : MAKEINTRESOURCE(IDI_LED_OFF),
  826. IMAGE_ICON, 16, 16, LR_SHARED);
  827. m_wndStatusBar.GetStatusBarCtrl().SetIcon(m_wndStatusBar.CommandToIndex(ID_INDICATOR_OFFLINELED), hIcon);
  828. m_wndStatusBar.GetStatusBarCtrl().Invalidate();
  829. m_wndStatusBar.GetStatusBarCtrl().UpdateWindow();
  830. DestroyIcon(hIcon);
  831. }
  832. void CDBServerDlg::OnFTPStatisticChange(int nType, int nValue)
  833. {
  834. m_StatisticsPage.SetValue(nType, nValue);
  835. }
  836. /********************************************************************/
  837. /* */
  838. /* Function name : FormatSize */
  839. /* Description : Format size, the way explorer diplays it */
  840. /* */
  841. /********************************************************************/
  842. char* CDBServerDlg::FormatSize(DWORD dwSizeLow, DWORD dwSizeHigh)
  843. {
  844. static char szBuff[100];
  845. unsigned __int64 nFileSize = ((unsigned __int64)(((DWORD)(dwSizeLow)) |
  846. ((unsigned __int64)((DWORD)(dwSizeHigh))) << 32));
  847. unsigned __int64 kb = 0;
  848. if (nFileSize > 1024)
  849. {
  850. kb = nFileSize / 1024;
  851. if (nFileSize % 1024)
  852. kb++;
  853. }
  854. // make it a string
  855. _ui64tot(kb, szBuff, 10);
  856. // add thousand seperators
  857. int nLength = lstrlen(szBuff);
  858. if (nLength > 3)
  859. {
  860. LPCTSTR ptr = szBuff;
  861. ptr += (nLength - 1);
  862. char szTemp[100];
  863. LPTSTR ptrTemp = szTemp;
  864. for (int i = 0; i < nLength; i++)
  865. {
  866. if (i && ((i % 3) == 0))
  867. {
  868. if (*ptrTemp != ',')
  869. {
  870. *ptrTemp = ',';
  871. ptrTemp = _tcsinc(ptrTemp);
  872. }
  873. }
  874. *ptrTemp = *ptr;
  875. ptrTemp = _tcsinc(ptrTemp);
  876. ptr = _tcsdec(szBuff, ptr);
  877. }
  878. // terminate string
  879. *ptrTemp = '\0';
  880. // reverse string
  881. _tcsrev(szTemp);
  882. lstrcpy(szBuff, szTemp);
  883. }
  884. // add 'KB' to it
  885. lstrcat(szBuff, " KB");
  886. return szBuff;
  887. }
  888. /********************************************************************/
  889. /* */
  890. /* Function name : OnAccountWizard */
  891. /* Description : Launch New Account Wizard */
  892. /* */
  893. /********************************************************************/
  894. void CDBServerDlg::OnAccountWizard()
  895. {
  896. CBitmap bmpHeader, bmpWatermark;
  897. VERIFY(bmpHeader.LoadBitmap(IDB_BANNER));
  898. VERIFY(bmpWatermark.LoadBitmap(IDB_WATERMARK));
  899. // show windows 2000-like wizard
  900. CWizardSheet wizSheet("New Account Wizard", this, 0, bmpWatermark, NULL, bmpHeader);
  901. wizSheet.m_psh.hInstance = ::GetModuleHandle(NULL);
  902. if (wizSheet.DoModal() == ID_WIZFINISH)
  903. {
  904. CArray<CUser, CUser&> m_UserArray;
  905. theServer.m_UserManager.GetUserList(m_UserArray);
  906. int nIndex = -1;
  907. for (int i = 0; i < m_UserArray.GetSize(); i++)
  908. {
  909. // if it already exists -> update it
  910. if (m_UserArray[i].m_strName.CompareNoCase(wizSheet.m_Page1.m_strAccountName) == 0)
  911. {
  912. nIndex = i;
  913. break;
  914. }
  915. }
  916. // add new account ?
  917. if (nIndex == -1)
  918. {
  919. CUser user;
  920. nIndex = m_UserArray.Add(user);
  921. }
  922. m_UserArray[nIndex].m_bAccountDisabled = FALSE;
  923. m_UserArray[nIndex].m_strName = wizSheet.m_Page1.m_strAccountName;
  924. m_UserArray[nIndex].m_strPassword = wizSheet.m_Page2.m_strPassword;
  925. // add home directory
  926. CDirectory directory;
  927. directory.m_strDir = wizSheet.m_Page3.m_strHomeDirectory;
  928. directory.m_strAlias = "";
  929. directory.m_bIsHomeDir = TRUE;
  930. directory.m_bAllowCreateDirectory = wizSheet.m_Page4.m_bAllowCreateDirectory;
  931. directory.m_bAllowDelete = wizSheet.m_Page4.m_bAllowDelete;
  932. directory.m_bAllowDownload = wizSheet.m_Page4.m_bAllowDownload;
  933. directory.m_bAllowRename = wizSheet.m_Page4.m_bAllowRename;
  934. directory.m_bAllowUpload = wizSheet.m_Page4.m_bAllowUpload;
  935. directory.m_strAlias = "";
  936. m_UserArray[nIndex].m_DirectoryArray.Add(directory);
  937. // update
  938. theServer.m_UserManager.UpdateUserList(m_UserArray);
  939. }
  940. }
  941. void CDBServerDlg::OnCancel()
  942. {
  943. }
  944. void CDBServerDlg::OnOK()
  945. {
  946. }
  947. void CDBServerDlg::OnButton1()
  948. {
  949. // TODO: Add your control notification handler code here
  950. try
  951. {
  952. theServer.Initialize(this);
  953. if (ServerStart() == 0)
  954. return;
  955. if (g_pSkinData == NULL)
  956. InitLia();
  957. /////////////////////
  958. CString logdays;
  959. MyLock lock("dbaccessxiao");
  960. CRecordset myset(&g_db);
  961. CString sql = "select logdays from version";
  962. myset.Open(CRecordset::forwardOnly, sql);
  963. myset.GetFieldValue("logdays", logdays);
  964. myset.Close();
  965. int days = 180;
  966. if (logdays == "1个月")
  967. days = 31;
  968. else if (logdays == "2个月")
  969. days = 61;
  970. else if (logdays == "3个月")
  971. days = 92;
  972. else
  973. days = 183;
  974. CTime tm = CTime::GetCurrentTime();
  975. CTimeSpan dt(days, 0, 0, 0);
  976. tm -= dt;
  977. CString date = tm.Format("%Y-%m-%d");
  978. ///////////////////
  979. tm = CTime::GetCurrentTime();
  980. CTimeSpan dt2(183, 0, 0, 0);
  981. tm -= dt2;
  982. date = tm.Format("%Y%m%d%H%M%S");
  983. sql = "delete from sendreg where [status]='OK' and [timestamp]<'" + date + "'";
  984. g_db.ExecuteSQL(sql);
  985. //////////////////////////////////
  986. sql = "select version from version";
  987. myset.Open(CRecordset::forwardOnly, sql);
  988. myset.GetFieldValue("version", sql);
  989. myset.Close();
  990. m_ConfigurationPage.m_versionno = "00" + sql;
  991. m_ConfigurationPage.UpdateData(0);
  992. /////////////////////
  993. }
  994. catch (...)
  995. {
  996. WriteTextLog("出错1");
  997. }
  998. }
  999. void CDBServerDlg::OnClose()
  1000. {
  1001. m_TrayIcon.Create(this, WM_ICON_NOTIFY, "影楼管理系统服务器", m_hIcon, IDR_MENUtray); //构造
  1002. ShowWindow(SW_HIDE); //隐藏窗口
  1003. }
  1004. LRESULT CDBServerDlg::OnTrayNotification(WPARAM wParam, LPARAM lParam)
  1005. {
  1006. return m_TrayIcon.OnTrayNotification(wParam, lParam);
  1007. }
  1008. void CDBServerDlg::OnOpen()
  1009. {
  1010. ShowWindow(SW_SHOW);
  1011. }
  1012. void CDBServerDlg::OnExit2()
  1013. {
  1014. try
  1015. {
  1016. TerminateThread();
  1017. TerminateThread2();
  1018. m_TrayIcon.RemoveIcon();
  1019. if (g_pSkinData)delete[]g_pSkinData; g_pSkinData = NULL;
  1020. g_db.Close();
  1021. for (int i = 0; i < g_dbHistoryArray.GetSize(); i++)
  1022. {
  1023. g_dbHistoryArray.ElementAt(i)->Close();
  1024. delete g_dbHistoryArray.ElementAt(i);
  1025. }
  1026. ReleaseBranchDB();
  1027. }
  1028. catch (...)
  1029. {
  1030. WriteTextLog("出错在函数OnExit2中");
  1031. }
  1032. CDialog::OnCancel();
  1033. }
  1034. void CDBServerDlg::OnExit()
  1035. {
  1036. try
  1037. {
  1038. TerminateThread();
  1039. TerminateThread2();
  1040. DWORD id = FindAppProcessID("AutoRun.exe");
  1041. if (id != -1)
  1042. {
  1043. HANDLE ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
  1044. if (ProcessHandle)TerminateProcess(ProcessHandle, 0);
  1045. }
  1046. m_TrayIcon.RemoveIcon();
  1047. if (g_pSkinData)delete[]g_pSkinData; g_pSkinData = NULL;
  1048. g_db.Close();
  1049. for (int i = 0; i < g_dbHistoryArray.GetSize(); i++)
  1050. {
  1051. g_dbHistoryArray.ElementAt(i)->Close();
  1052. delete g_dbHistoryArray.ElementAt(i);
  1053. }
  1054. ReleaseBranchDB();
  1055. }
  1056. catch (...)
  1057. {
  1058. WriteTextLog("出错在函数OnExit中");
  1059. }
  1060. CDialog::OnCancel();
  1061. }
  1062. void CDBServerDlg::OnTimer(UINT nIDEvent) //定时器;
  1063. {
  1064. try
  1065. {
  1066. if (nIDEvent == 1)
  1067. {
  1068. KillTimer(nIDEvent);
  1069. LoadThumbImages();
  1070. }
  1071. else if (nIDEvent == 2)
  1072. {
  1073. KillTimer(nIDEvent);
  1074. OnClose();// 托盘显示;
  1075. try
  1076. {
  1077. CheckHistoryData(); // Jeff:back history db data;
  1078. LoadBranchInfo2();
  1079. }
  1080. catch (...)
  1081. {
  1082. }
  1083. SetTimer(1, 2 * 60 * 1000, NULL);
  1084. SetTimer(4, 1000 * 60 * 2, NULL);
  1085. SetTimer(7, 1000 * 60 * 60 * 1, NULL);
  1086. SetTimer(8, 3000, NULL);
  1087. SetTimer(9, 10000, NULL);
  1088. }
  1089. else if (nIDEvent == 3)
  1090. {
  1091. g_pMainWnd->KillTimer(3);
  1092. DWORD id = FindAppProcessID("MsgServer.exe");
  1093. if (id != -1)
  1094. {
  1095. HANDLE ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
  1096. if (ProcessHandle)
  1097. TerminateProcess(ProcessHandle, 0);
  1098. }
  1099. CString autorunpath = g_mainpath + "\\MsgServer.exe";
  1100. ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
  1101. }
  1102. else if (nIDEvent == 4) //Jeff.这里也有自动启动MsgServer.exe服务处理,而且是2分钟/次的频率;
  1103. {
  1104. UpdateDate();
  1105. CheckMemberMsg();
  1106. BakPhoto();
  1107. }
  1108. else if (nIDEvent == 5)
  1109. {
  1110. typedef BOOL(WINAPI *MYFUNC)(LPDWORD);
  1111. MYFUNC IsNetworkConnect = NULL;
  1112. //取得IsNetworkAlive函数指针
  1113. IsNetworkConnect = (MYFUNC)GetProcAddress(hInst, "IsNetworkAlive");
  1114. if (IsNetworkConnect)
  1115. {
  1116. DWORD dwActiveWan = 1;
  1117. BOOL state;
  1118. if (IsNetworkConnect(&dwActiveWan))
  1119. state = 1;
  1120. else
  1121. state = 0;
  1122. if (m_bNetWorkOK != state)
  1123. {
  1124. KillTimer(nIDEvent);
  1125. WriteTextLog("网络断开");
  1126. OnExit2();
  1127. }
  1128. }
  1129. }
  1130. else if (nIDEvent == 6)
  1131. {
  1132. KillTimer(nIDEvent);
  1133. ShutDown();
  1134. }
  1135. else if (nIDEvent == 7)
  1136. {
  1137. CheckBakState();
  1138. GenUPhoneData();
  1139. }
  1140. else if (nIDEvent == 8)
  1141. {
  1142. CheckConnCount();
  1143. }
  1144. #if 0 // Jeff.开启定时关机功能
  1145. else if ( nIDEvent == 11)
  1146. {
  1147. g_curdb=&g_db;
  1148. CString m_bak6;
  1149. CString strShutDownTime;
  1150. CRecordset myset(g_curdb);
  1151. CString sql="select * from [version]";
  1152. myset.Open(CRecordset::forwardOnly, sql);
  1153. myset.GetFiledVale("ShutDownTime",strShutDownTime);
  1154. myset.Close();
  1155. CTime tShutDownTime(
  1156. CTime::GetCurrentTime().GetYear(),
  1157. CTime::GetCurrentTime().GetMonth(),
  1158. CTime::GetCurrentTime().GetDay(),
  1159. atoi(strShutDownTime.Left(2)),
  1160. atoi(strShutDownTime.Right(2)),
  1161. 0);
  1162. if (CTime::GetCurrentTime() >= tShutDownTime)
  1163. {
  1164. MyExitWindows();
  1165. }
  1166. }
  1167. #endif
  1168. }
  1169. catch (...)
  1170. {
  1171. WriteTextLog("出错在函数Timer中");
  1172. }
  1173. }
  1174. void LoadImageFromBuf(Image **img, BYTE *pData, DWORD leng)//g_bakserver1
  1175. {
  1176. try
  1177. {
  1178. if (pData == NULL)return;
  1179. if (*img)delete *img;
  1180. *img = NULL;
  1181. // Allocate global memory on which to create stream
  1182. HGLOBAL m_hMem = GlobalAlloc(GMEM_MOVEABLE, leng);
  1183. if (m_hMem == NULL)return;
  1184. BYTE* pmem = (BYTE*)GlobalLock(m_hMem);
  1185. memcpy(pmem, pData, leng);
  1186. IStream* pstm;
  1187. CreateStreamOnHGlobal(m_hMem, TRUE, &pstm);
  1188. // load from stream
  1189. *img = Gdiplus::Image::FromStream(pstm);
  1190. // free/release stuff
  1191. GlobalUnlock(m_hMem);
  1192. pstm->Release();
  1193. }
  1194. catch (...)
  1195. {
  1196. }
  1197. }
  1198. void LoadImageFromBuf(Image **img, CString path)
  1199. {
  1200. try
  1201. {
  1202. CFile fp;
  1203. if (fp.Open(path, CFile::modeRead))
  1204. {
  1205. DWORD leng = fp.GetLength();
  1206. BYTE *pData = new BYTE[leng];
  1207. fp.Read(pData, leng);
  1208. fp.Close();
  1209. LoadImageFromBuf(img, pData, leng);
  1210. delete[]pData;
  1211. }
  1212. }
  1213. catch (...)
  1214. {
  1215. }
  1216. }
  1217. void LoadImageFromRes(Image **img, LPCTSTR lpszResourceName, LPCTSTR ResourceType)
  1218. {
  1219. try
  1220. {
  1221. HGLOBAL hGlobal = NULL;
  1222. HRSRC hSource = NULL;
  1223. LPVOID lpVoid = NULL;
  1224. int nSize = 0;
  1225. BOOL bResult = FALSE;
  1226. hSource = FindResource(NULL, lpszResourceName, ResourceType);
  1227. if (hSource == NULL)return;
  1228. hGlobal = LoadResource(NULL, hSource);
  1229. if (hGlobal == NULL)return;
  1230. lpVoid = LockResource(hGlobal);
  1231. if (lpVoid == NULL)return;
  1232. nSize = (UINT)SizeofResource(NULL, hSource);
  1233. LoadImageFromBuf(img, (BYTE*)hGlobal, nSize);
  1234. UnlockResource(hGlobal); // 16Bit Windows Needs This
  1235. FreeResource(hGlobal); // 16Bit Windows Needs This (32Bit - Automatic Release)
  1236. }
  1237. catch (...)
  1238. {
  1239. }
  1240. }
  1241. // ---------------------------------------------------------------------------------------------------------------------------------------------------------------
  1242. // TimeAt: 2014-09-15 AM;
  1243. // Remark: Jeff;
  1244. // 函数:GenSPhoto
  1245. // 描述:对指定文件夹内的相片生成S或M缩略图;
  1246. // 参数:
  1247. // dir: 需要生成缩略图的文件目录;
  1248. // bMPhoto: 是否生成M缩略图;
  1249. // 其它:
  1250. // 在生成缩略图前,记录jpg文件总数nOldCount,每生成一个缩略图nOldCount++;
  1251. // 最后全部图生成完毕,获取新的jpg文件总数nNewCount,if(nOldCount == nNewCount)则表示所有相片已生成缩略图完毕,生成ok文件表示成功生成缩略图;
  1252. //
  1253. // 函数调用全局参数:
  1254. // g_bSteal:意义未明!
  1255. //
  1256. // 注意:该函数非线程安全!
  1257. // 非线程安全:
  1258. // 获取文件总数nOldCount结束后,若有新文件在本函数以外其他函数或进程、线程被添加,则生成缩略图完成后再次获取文件总数nNewCount就不会与nOldCount++后的结果相等;
  1259. // 而实际上本次缩略图已生成完毕。
  1260. // ---------------------------------------------------------------------------------------------------------------------------------------------------------------
  1261. void GenSPhoto(CString dir, BOOL bMPhoto) // 参数:bMPhoto:是否生成M缩略图;
  1262. {
  1263. // 如果是公告附件目录退出;
  1264. if (dir.Find("公告附件") != -1)return;
  1265. // 如果不是客户原片或修好的片目录,设置bMPhoto参数为0,不生成M缩略图;
  1266. if (dir.Find("客户原片(管理软件)$") != -1 || dir.Find("修好的片(管理软件)$") != -1)
  1267. {
  1268. }
  1269. else
  1270. bMPhoto = 0;
  1271. // 对指定文件目录dir进行指定后缀jpg文件遍历;
  1272. using namespace helper_coffs;
  1273. ffsco o;
  1274. o.dirs(1);
  1275. o.find(LPCSTR(dir), LPCSTR("*.jpg"));
  1276. ffsco::typeT coo;
  1277. ffsco::typeT::iterator it;
  1278. coo = o.co_file();
  1279. int oldsize = coo.size();
  1280. CString path, temp, spath, mpath;
  1281. for (it = coo.begin(); coo.end() != it; it++)
  1282. {
  1283. try
  1284. {
  1285. if (g_pMainWnd->m_bTerminate)return;
  1286. // 遍历到的jpg文件如果是缩略图则不处理,继续遍历;
  1287. path = (*it).c_str();
  1288. spath = path.Left(path.ReverseFind('\\') + 1);
  1289. mpath = spath;
  1290. spath += "s";
  1291. mpath += "m";
  1292. temp = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
  1293. if (temp.GetAt(0) == 's')continue;
  1294. if (temp.GetAt(0) == 'm')continue;
  1295. spath += path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
  1296. mpath += path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
  1297. if (g_bSteal)
  1298. {
  1299. Image *pImg = NULL;
  1300. ::LoadImageFromBuf(&pImg, path);
  1301. if (pImg == NULL)continue;
  1302. if (pImg->GetWidth() == 0)continue; // Jeff.continue前未释放pImg;
  1303. delete pImg;
  1304. EncryptFile3(path);
  1305. if (path.Find("客户原片") != -1)
  1306. {
  1307. int pos = path.Find("管理软件)$");
  1308. if (pos != -1)
  1309. {
  1310. path = g_bakserver1 + path.Right(path.GetLength() - pos - 10);
  1311. EncryptFile3(path);
  1312. }
  1313. }
  1314. else if (path.Find("修好的片") != -1)
  1315. {
  1316. int pos = path.Find("管理软件)$");
  1317. if (pos != -1)
  1318. {
  1319. path = g_bakserver2 + path.Right(path.GetLength() - pos - 10);
  1320. EncryptFile3(path);
  1321. }
  1322. }
  1323. else if (path.Find("精修好的片") != -1)
  1324. {
  1325. int pos = path.Find("管理软件)$");
  1326. if (pos != -1)
  1327. {
  1328. path = g_bakserver3 + path.Right(path.GetLength() - pos - 10);
  1329. EncryptFile3(path);
  1330. }
  1331. }
  1332. else if (path.Find("设计好的片") != -1)
  1333. {
  1334. int pos = path.Find("管理软件)$");
  1335. if (pos != -1)
  1336. {
  1337. path = g_bakserver4 + path.Right(path.GetLength() - pos - 10);
  1338. EncryptFile3(path);
  1339. }
  1340. }
  1341. oldsize++;
  1342. }
  1343. else if (!CheckFileExist(spath))
  1344. {
  1345. Image *pImg = NULL;
  1346. ::LoadImageFromBuf(&pImg, path);
  1347. if (pImg == NULL)continue;
  1348. if (pImg->GetWidth() == 0)continue; // Jeff.返回前未释放pImg;
  1349. CRect rc(0, 0, 100, 90);
  1350. RectFitDes(pImg->GetWidth(), pImg->GetHeight(), rc);
  1351. Image *simg = pImg->GetThumbnailImage(rc.Width(), rc.Height(), NULL, NULL);
  1352. if (simg == NULL)continue;// Jeff.返回前未释放pImg;
  1353. Image *simg2 = NULL;
  1354. if (bMPhoto)
  1355. {
  1356. CRect rc2(0, 0, 2000, 2000);
  1357. RectFitDes(pImg->GetWidth(), pImg->GetHeight(), rc2);
  1358. simg2 = pImg->GetThumbnailImage(rc2.Width(), rc2.Height(), NULL, NULL);
  1359. if (simg2 == NULL)continue;// Jeff.返回前未释放pImg;
  1360. }
  1361. Graphics graphic(simg);//防止GetThumbnailImage影响质量
  1362. graphic.Clear(Color(255, 255, 255, 255));
  1363. graphic.DrawImage(pImg, 0, 0, simg->GetWidth(), simg->GetHeight());
  1364. if (bMPhoto)
  1365. {
  1366. Graphics graphic2(simg2);//防止GetThumbnailImage影响质量
  1367. graphic2.Clear(Color(255, 255, 255, 255));
  1368. graphic2.DrawImage(pImg, 0, 0, simg2->GetWidth(), simg2->GetHeight());
  1369. }
  1370. ///////////////////////////////
  1371. UINT totalBufferSize;
  1372. UINT numProperties;
  1373. pImg->GetPropertySize(&totalBufferSize, &numProperties);
  1374. // Allocate the buffer that will receive the property items.
  1375. PropertyItem* pAllItems = (PropertyItem*)malloc(totalBufferSize);
  1376. // Fill the buffer.
  1377. pImg->GetAllPropertyItems(totalBufferSize, numProperties, pAllItems);
  1378. // Print the id data member of each property item.
  1379. for (UINT j = 0; j < numProperties; ++j)
  1380. {
  1381. if (PropertyTagOrientation == pAllItems[j].id)
  1382. {
  1383. short* ptrLong = (short*)(pAllItems[j].value);
  1384. int ret = (int)*ptrLong;
  1385. // CString str;
  1386. // str.Format ("%d", ret);
  1387. // AfxMessageBox(str);
  1388. if (ret == 8)
  1389. {
  1390. if (simg2)simg2->RotateFlip(Rotate270FlipNone);
  1391. simg->RotateFlip(Rotate270FlipNone);
  1392. }
  1393. else if (ret == 6)
  1394. {
  1395. if (simg2)simg2->RotateFlip(Rotate90FlipNone);
  1396. simg->RotateFlip(Rotate90FlipNone);
  1397. }
  1398. break;
  1399. }
  1400. }
  1401. free(pAllItems);
  1402. ///////////////////////////////
  1403. ::SaveImageToFile(simg, spath); oldsize++;
  1404. delete simg;
  1405. delete pImg;
  1406. if (bMPhoto)
  1407. {
  1408. ::SaveImageToFile2(simg2, mpath, 100); oldsize++;
  1409. delete simg2;
  1410. }
  1411. }
  1412. }
  1413. catch (...)
  1414. {
  1415. WriteTextLog("出错在函数GenSPhoto中");
  1416. }
  1417. }
  1418. try
  1419. {
  1420. ffsco o;
  1421. o.dirs(1);
  1422. o.find(LPCSTR(dir), LPCSTR("*.jpg"));
  1423. ffsco::typeT coo;
  1424. ffsco::typeT::iterator it;
  1425. coo = o.co_file();
  1426. int newsize = coo.size();
  1427. if (oldsize == newsize)
  1428. {
  1429. path = dir + "\\ok";
  1430. CFile fp;
  1431. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  1432. fp.Close();
  1433. }
  1434. }
  1435. catch (...)
  1436. {
  1437. WriteTextLog("出错在函数GenSPhoto2中");
  1438. }
  1439. }
  1440. //--------------------------------------------------------------------------------
  1441. // Remark by Jeff 2014.10.22
  1442. // 函数:
  1443. // 描述:
  1444. // dir:客户原片、修好的片、精修片、设计片目录的订单文件夹路径;
  1445. // desdir:dir对就的备份目录;
  1446. // 参数:
  1447. // 返回:
  1448. //
  1449. // 调用关系:
  1450. // 1.
  1451. // 2.
  1452. // 3.
  1453. //--------------------------------------------------------------------------------
  1454. BOOL BakAllPhoto(CString dir, CString desdir, CString g_path1, CString g_path2, CString g_path3, CString g_path4)
  1455. {
  1456. try
  1457. {
  1458. CString childdir;
  1459. CString srcdir = dir;
  1460. srcdir.MakeLower();
  1461. if (srcdir.Find(g_path1) != -1)
  1462. childdir = srcdir.Right(srcdir.GetLength() - g_path1.GetLength());
  1463. else if (srcdir.Find(g_path2) != -1)
  1464. childdir = srcdir.Right(srcdir.GetLength() - g_path2.GetLength());
  1465. else if (srcdir.Find(g_path3) != -1)
  1466. childdir = srcdir.Right(srcdir.GetLength() - g_path3.GetLength());
  1467. else if (srcdir.Find(g_path4) != -1)
  1468. childdir = srcdir.Right(srcdir.GetLength() - g_path4.GetLength());
  1469. else
  1470. {
  1471. WriteTextLog("备份出错-目录未找到!");
  1472. return 0;
  1473. }
  1474. /* srcdir.TrimLeft ("\\");
  1475. srcdir.Delete (srcdir.Find ('\\'));
  1476. if(srcdir.Find ('\\')==-1)
  1477. childdir="";
  1478. else
  1479. childdir=srcdir.Right (srcdir.GetLength ()-srcdir.Find ('\\'));*/
  1480. childdir.TrimLeft("\\");
  1481. childdir.TrimRight("\\");
  1482. while (childdir.Find('\\') != -1)
  1483. {
  1484. desdir += "\\";
  1485. desdir += childdir.Left(childdir.Find('\\'));
  1486. //if(CheckFolderFileExist (desdir)==0)
  1487. {
  1488. // if(!
  1489. CreateDirectory(desdir, NULL);//)return;
  1490. }
  1491. childdir = childdir.Right(childdir.GetLength() - childdir.Find('\\') - 1);
  1492. }
  1493. desdir += "\\";
  1494. desdir += childdir;
  1495. //if(CheckFolderFileExist (desdir)==0)
  1496. {
  1497. // if(!
  1498. CreateDirectory(desdir, NULL);//)return;
  1499. }
  1500. desdir += "\\";
  1501. // Jeff.进行相片复制操作;
  1502. using namespace helper_coffs;
  1503. ffsco o;
  1504. o.dirs(0);
  1505. o.find(LPCSTR(dir), LPCSTR("*.*"));
  1506. ffsco::typeT coo;
  1507. ffsco::typeT::iterator it;
  1508. coo = o.co_file();
  1509. CString path, temp, despath;
  1510. for (it = coo.begin(); coo.end() != it; it++)
  1511. {
  1512. try
  1513. {
  1514. if (g_pMainWnd->m_bTerminate2)return 0;
  1515. path = (*it).c_str();
  1516. temp = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
  1517. if (temp.GetAt(0) == 's')continue;
  1518. despath = desdir + path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
  1519. if (CheckFileExist(despath))
  1520. {
  1521. /* HANDLE hFile=CreateFile(path,GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
  1522. HANDLE hFile2=CreateFile(despath,GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
  1523. FILETIME ftWrite,ftWrite2;
  1524. if(GetFileTime(hFile, NULL, NULL, &ftWrite)==0)
  1525. {
  1526. CloseHandle(hFile);
  1527. CloseHandle(hFile2);
  1528. return;
  1529. }
  1530. if(GetFileTime(hFile2, NULL, NULL, &ftWrite2)==0)
  1531. {
  1532. CloseHandle(hFile);
  1533. CloseHandle(hFile2);
  1534. return;
  1535. }
  1536. CloseHandle(hFile);
  1537. CloseHandle(hFile2);
  1538. if(ftWrite.dwHighDateTime!=ftWrite2.dwHighDateTime || ftWrite.dwLowDateTime!=ftWrite2.dwLowDateTime)
  1539. {*/
  1540. if (::CopyFile(path, despath, 0))
  1541. g_bakphoto = "照片备份成功";
  1542. // }
  1543. }
  1544. else
  1545. {
  1546. if (::CopyFile(path, despath, 0))
  1547. g_bakphoto = "照片备份成功";
  1548. }
  1549. }
  1550. catch (...)
  1551. {
  1552. }
  1553. }
  1554. }
  1555. catch (...)
  1556. {
  1557. WriteTextLog("出错在函数BakAllPhoto中");
  1558. return 0;
  1559. }
  1560. return 1;
  1561. }
  1562. //--------------------------------------------------------------------------------
  1563. // Remark by Jeff 2014.10.22
  1564. // 函数:
  1565. // 描述:
  1566. // 参数:
  1567. // 返回:
  1568. //
  1569. // 调用关系:
  1570. // 1.
  1571. // 2.
  1572. // 3.
  1573. //--------------------------------------------------------------------------------
  1574. unsigned __stdcall LoadThumbNail(LPVOID lpParam)
  1575. {
  1576. BOOL bMphoto = 0;
  1577. if (g_bSteal == 0)
  1578. {
  1579. CRecordset myset(&g_db);
  1580. CString sql = "select * from version";
  1581. myset.Open(CRecordset::forwardOnly, sql);
  1582. myset.GetFieldValue("setcheck15", sql);
  1583. myset.Close();
  1584. bMphoto = atoi(sql);
  1585. }
  1586. CDBServerDlg *pDlg = (CDBServerDlg*)lpParam;
  1587. try
  1588. {
  1589. CString g_path1;
  1590. CString g_path2;
  1591. CString g_path3;
  1592. CString g_path4;
  1593. char server[50];
  1594. DWORD leng = 50;
  1595. ::GetComputerName(server, &leng);
  1596. g_path1 = g_path2 = g_path3 = g_path4 = server;
  1597. if (g_path2.IsEmpty())return 0;
  1598. g_path1 = "\\\\" + g_path1 + "\\客户原片(管理软件)$";
  1599. g_path2 = "\\\\" + g_path2 + "\\修好的片(管理软件)$";
  1600. g_path3 = "\\\\" + g_path3 + "\\设计好的片(管理软件)$";
  1601. g_path4 = "\\\\" + g_path4 + "\\精修好的片(管理软件)$";
  1602. GetPathFromNetShareName("客户原片(管理软件)$", g_path1);
  1603. GetPathFromNetShareName("修好的片(管理软件)$", g_path2);
  1604. GetPathFromNetShareName("设计好的片(管理软件)$", g_path3);
  1605. GetPathFromNetShareName("精修好的片(管理软件)$", g_path4);
  1606. CStringArray dirarray;
  1607. CString path, path2;
  1608. using namespace helper_coffs;
  1609. CString patharray[4] = { g_path1, g_path2, g_path3, g_path4 };
  1610. // Remark:Jeff.
  1611. // 遍历原片、修好片、设计片、精修片目录,查看是否有ok或ok.dat文件存在;
  1612. // 说明:ok文件在客户端再次导入相片时会被删除;
  1613. // 只有服务端生成小图后,ok才被重新生成;
  1614. int i = 0;
  1615. for ( i = 0; i < 4; i++)
  1616. {
  1617. if (pDlg->m_bTerminate)
  1618. {
  1619. break;
  1620. }
  1621. ffsco o;
  1622. o.dirs(1);
  1623. o.find(LPCSTR(patharray[i]), LPCSTR("*.*"));
  1624. ffsco::typeT coo;
  1625. ffsco::typeT::iterator it;
  1626. coo = o.co_dir();
  1627. it = coo.begin();
  1628. it++;
  1629. for (; coo.end() != it; it++)
  1630. {
  1631. if (pDlg->m_bTerminate)
  1632. {
  1633. break;
  1634. }
  1635. path = (*it).c_str();
  1636. path.TrimRight("\\");
  1637. path2 = path;
  1638. path2 += "\\ok2.dat";
  1639. path += "\\ok";
  1640. if (CheckFileExist(path2) && path2.Find(".ly.com") == -1)
  1641. {
  1642. ::DeleteFile(path); // 删除ok文件;
  1643. ::DeleteFile(path2); // 删除ok.dat文件;
  1644. }
  1645. // g_bCheckAll g_bSteal的意义???
  1646. if (g_bCheckAll || g_bSteal)
  1647. {
  1648. if (FindArray(&dirarray, (*it).c_str()) == -1)
  1649. dirarray.Add((*it).c_str());
  1650. }
  1651. else if (CheckFileExist(path) == 0)
  1652. {
  1653. if (FindArray(&dirarray, (*it).c_str()) == -1)
  1654. dirarray.Add((*it).c_str());
  1655. }
  1656. }
  1657. }
  1658. for (i = 0; i < dirarray.GetSize(); i++)
  1659. {
  1660. if (pDlg->m_bTerminate)
  1661. {
  1662. break;
  1663. }
  1664. GenSPhoto(dirarray.ElementAt(i), bMphoto);
  1665. }
  1666. }
  1667. catch (...)
  1668. {
  1669. WriteTextLog("出错在函数GenThumb中");
  1670. }
  1671. pDlg->m_bRunning = false;
  1672. pDlg->m_bTerminate = false;
  1673. pDlg->SetTimer(1, 60 * 1000, NULL);
  1674. _endthreadex(0);
  1675. return 0;
  1676. }
  1677. //--------------------------------------------------------------------------------
  1678. // Remark by Jeff 2014.10.22
  1679. // 函数:LoadThumbNail2
  1680. // 描述:线程函数,备份相片.
  1681. // 参数:
  1682. // 返回:
  1683. //
  1684. // 调用关系:
  1685. // 1.
  1686. // 2.
  1687. // 3.
  1688. //--------------------------------------------------------------------------------
  1689. unsigned __stdcall LoadThumbNail2(LPVOID lpParam)//备份
  1690. {
  1691. CDBServerDlg *pDlg = (CDBServerDlg*)lpParam;
  1692. int step = 1;
  1693. BOOL bError = 0;
  1694. try
  1695. {
  1696. g_tisks = ::GetTickCount();
  1697. WriteTextLog("开始备份照片");
  1698. CDatabase *g_curdb = &g_db;
  1699. // CRstPath rsSt;
  1700. CString g_path1;
  1701. CString g_path2;
  1702. CString g_path3;
  1703. CString g_path4;
  1704. g_path1 = g_path2 = g_path3 = g_path4 = g_localname;
  1705. CString localname = g_localname;
  1706. g_path1 = "\\\\" + g_path1 + "\\客户原片(管理软件)$";
  1707. g_path2 = "\\\\" + g_path2 + "\\修好的片(管理软件)$";
  1708. g_path3 = "\\\\" + g_path3 + "\\设计好的片(管理软件)$";
  1709. g_path4 = "\\\\" + g_path4 + "\\精修好的片(管理软件)$";
  1710. GetPathFromNetShareName("客户原片(管理软件)$", g_path1);
  1711. GetPathFromNetShareName("修好的片(管理软件)$", g_path2);
  1712. GetPathFromNetShareName("设计好的片(管理软件)$", g_path3);
  1713. GetPathFromNetShareName("精修好的片(管理软件)$", g_path4);
  1714. step = 2;
  1715. g_path1.MakeLower();
  1716. g_path2.MakeLower();
  1717. g_path3.MakeLower();
  1718. g_path4.MakeLower();
  1719. CString m_bak1, m_bak2, m_bak3, m_bak4; // 是否备份(指定的备份目录是否需要备份);
  1720. CString m_bak11, m_bak22, m_bak33, m_bak44; // 是否备份(集团版的分店备份目录是否需要备份??);
  1721. CString m_bakserver1, m_bakserver2, m_bakserver3, m_bakserver4; // 相片备份目录 ;
  1722. {
  1723. MyLock lock("dbaccessxiao");
  1724. CRstversion rsSt;
  1725. rsSt.m_pDatabase = g_curdb;
  1726. rsSt.Open();
  1727. if (!rsSt.IsEOF())
  1728. {
  1729. m_bak1 = rsSt.m_bak1;
  1730. m_bak2 = rsSt.m_bak2;
  1731. m_bak3 = rsSt.m_bak3;
  1732. m_bak4 = rsSt.m_bak4;
  1733. m_bakserver1 = rsSt.m_bakserver1;
  1734. m_bakserver2 = rsSt.m_bakserver2;
  1735. m_bakserver3 = rsSt.m_bakserver3;
  1736. m_bakserver4 = rsSt.m_bakserver4;
  1737. m_bak11 = rsSt.bak11;
  1738. m_bak22 = rsSt.bak22;
  1739. m_bak33 = rsSt.bak33;
  1740. m_bak44 = rsSt.bak44;
  1741. }
  1742. rsSt.Close();
  1743. step = 3;
  1744. }
  1745. #ifdef CHILD_VERSION
  1746. if (m_bakserver1.Find(":") == -1 && m_bakserver1 != "")
  1747. m_bakserver1 = "\\\\" + m_bakserver1 + "\\客户原片备份(儿童管理软件)$";
  1748. if (1)//(localname.CompareNoCase (m_bakserver1)==0 || CompareIP(localname, m_bakserver1)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\客户原片备份(儿童管理软件)$"))
  1749. GetPathFromNetShareName("客户原片备份(儿童管理软件)$", m_bakserver1);
  1750. if (m_bakserver2.Find(":") == -1 && m_bakserver2 != "")
  1751. m_bakserver2 = "\\\\" + m_bakserver2 + "\\修好的片备份(儿童管理软件)$";
  1752. if (1)//((localname.CompareNoCase (m_bakserver2)==0 || CompareIP(localname, m_bakserver2)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\修好的片备份(儿童管理软件)$"))
  1753. GetPathFromNetShareName("修好的片备份(儿童管理软件)$", m_bakserver2);
  1754. if (m_bakserver3.Find(":") == -1 && m_bakserver3 != "")
  1755. m_bakserver3 = "\\\\" + m_bakserver3 + "\\精修好的片备份(儿童管理软件)$";
  1756. if (1)//((localname.CompareNoCase (m_bakserver3)==0 || CompareIP(localname, m_bakserver3)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\精修好的片备份(儿童管理软件)$"))
  1757. GetPathFromNetShareName("精修好的片备份(儿童管理软件)$", m_bakserver3);
  1758. if (m_bakserver4.Find(":") == -1 && m_bakserver4 != "")
  1759. m_bakserver4 = "\\\\" + m_bakserver4 + "\\设计好的片备份(儿童管理软件)$";
  1760. if (1)//((localname.CompareNoCase (m_bakserver4)==0 || CompareIP(localname, m_bakserver4)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\设计好的片备份(儿童管理软件)$"))
  1761. GetPathFromNetShareName("设计好的片备份(儿童管理软件)$", m_bakserver4);
  1762. #else
  1763. if (m_bakserver1.Find(":") == -1 && m_bakserver1 != "")
  1764. m_bakserver1 = "\\\\" + m_bakserver1 + "\\客户原片备份(管理软件)$";
  1765. if (1)//((localname.CompareNoCase (m_bakserver1)==0 || CompareIP(localname, m_bakserver1)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\客户原片备份(管理软件)$"))
  1766. GetPathFromNetShareName("客户原片备份(管理软件)$", m_bakserver1);
  1767. if (m_bakserver2.Find(":") == -1 && m_bakserver2 != "")
  1768. m_bakserver2 = "\\\\" + m_bakserver2 + "\\修好的片备份(管理软件)$";
  1769. if (1)//((localname.CompareNoCase (m_bakserver2)==0 || CompareIP(localname, m_bakserver2)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\修好的片备份(管理软件)$"))
  1770. GetPathFromNetShareName("修好的片备份(管理软件)$", m_bakserver2);
  1771. if (m_bakserver3.Find(":") == -1 && m_bakserver3 != "")
  1772. m_bakserver3 = "\\\\" + m_bakserver3 + "\\精修好的片备份(管理软件)$";
  1773. if (1)//((localname.CompareNoCase (m_bakserver3)==0 || CompareIP(localname, m_bakserver3)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\精修好的片备份(管理软件)$"))
  1774. GetPathFromNetShareName("精修好的片备份(管理软件)$", m_bakserver3);
  1775. if (m_bakserver4.Find(":") == -1 && m_bakserver4 != "")
  1776. m_bakserver4 = "\\\\" + m_bakserver4 + "\\设计好的片备份(管理软件)$";
  1777. if (1)//((localname.CompareNoCase (m_bakserver4)==0 || CompareIP(localname, m_bakserver4)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\设计好的片备份(管理软件)$"))
  1778. GetPathFromNetShareName("设计好的片备份(管理软件)$", m_bakserver4);
  1779. #endif
  1780. WriteTextLog(m_bakserver1); WriteTextLog(m_bakserver2); WriteTextLog(m_bakserver3); WriteTextLog(m_bakserver4);
  1781. step = 4;
  1782. CStringArray dirarray;
  1783. CString str, path;
  1784. using namespace helper_coffs;
  1785. BOOL bcheck1 = atoi(m_bak1);
  1786. BOOL bcheck2 = atoi(m_bak2);
  1787. BOOL bcheck3 = atoi(m_bak3);
  1788. BOOL bcheck4 = atoi(m_bak4);
  1789. BOOL bcheck11 = atoi(m_bak11);
  1790. BOOL bcheck22 = atoi(m_bak22);
  1791. BOOL bcheck33 = atoi(m_bak33);
  1792. BOOL bcheck44 = atoi(m_bak44);
  1793. // 下列4变量应该使用结构体保存;
  1794. CString patharray[4] = { g_path1, g_path2, g_path4, g_path3 };
  1795. BOOL bcheck[4] = { bcheck1, bcheck2, bcheck3, bcheck4 };
  1796. // 集团版;
  1797. BOOL bcheckbranch[4] = { bcheck11, bcheck22, bcheck33, bcheck44 };
  1798. CString patharray2[4] = { m_bakserver1, m_bakserver2, m_bakserver3, m_bakserver4 };
  1799. CArray<int, int>posarray;
  1800. int i = 0;
  1801. for ( i = 0; i < 4; i++)
  1802. {
  1803. if (pDlg->m_bTerminate2)
  1804. {
  1805. break;
  1806. }
  1807. // if(!CheckFolderFileExist (patharray[i]))continue;
  1808. // if(!CheckFolderFileExist (patharray2[i]))continue;
  1809. if (bcheck[i] == 0)continue; // Jeff,跳过没有设置备份要求的相片;
  1810. if (patharray2[i] == "")continue; // Jeff.跳过没有备份目录的备份;
  1811. if (!::CheckFolderFileExist(patharray2[i]))continue; // Jeff.跳过备份目录不对的备份;
  1812. if (!::CheckFolderFileExist(patharray[i]))continue; // Jeff.跳过源目录不对的备份;
  1813. // 获取订单文件夹路径全名;
  1814. ffsco o;
  1815. o.dirs(1);
  1816. o.find(LPCSTR(patharray[i]), LPCSTR("*.*"));
  1817. ffsco::typeT coo;
  1818. ffsco::typeT::iterator it;
  1819. coo = o.co_dir();
  1820. it = coo.begin();
  1821. it++;
  1822. for (; coo.end() != it; it++)
  1823. {
  1824. if (pDlg->m_bTerminate2)
  1825. {
  1826. break;
  1827. }
  1828. str = (*it).c_str();
  1829. if (str.Find(".ly.com") != -1 && bcheckbranch[i] == 0)continue;
  1830. if (FindArray(&dirarray, str) == -1)
  1831. {
  1832. dirarray.Add(str);
  1833. posarray.Add(i);
  1834. }
  1835. }
  1836. }
  1837. step = 5;
  1838. // Jeff.对每个订单文件夹进行相片复制操作;
  1839. bError = 0;
  1840. for (i = 0; i<dirarray.GetSize(); i++)
  1841. {
  1842. if (pDlg->m_bTerminate2)break;
  1843. CTime tm = CTime::GetCurrentTime();
  1844. tm -= CTimeSpan(10, 0, 0, 0);
  1845. CString date = tm.Format("%Y%m%d");
  1846. DWORD dirdate = GetLastDirTime(dirarray.ElementAt(i));
  1847. if (pDlg->m_bTerminate2)break;
  1848. CString ss;
  1849. if (dirdate>atol(date))
  1850. {
  1851. // ss.Format ("%d>%d", dirdate, atol(date));
  1852. // WriteTextLog(ss);
  1853. // WriteTextLog(dirarray.ElementAt (i));
  1854. step = 6;
  1855. if (0 == BakAllPhoto(dirarray.ElementAt(i), patharray2[posarray.ElementAt(i)], g_path1, g_path2, g_path3, g_path4))
  1856. bError = 1;
  1857. CString path = dirarray.ElementAt(i);
  1858. path.TrimRight("\\"); path += "\\";
  1859. path += "modifytime";
  1860. CStdioFile fp;
  1861. if (!::PathFileExists(path))
  1862. {
  1863. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  1864. fp.WriteString(CTime::GetCurrentTime().Format("%Y-%m-%d"));
  1865. fp.Close();
  1866. }
  1867. }
  1868. else
  1869. {
  1870. step = 7;
  1871. CString path = dirarray.ElementAt(i);
  1872. path.TrimRight("\\"); path += "\\";
  1873. path += "modifytime";
  1874. CStdioFile fp;
  1875. if (!::PathFileExists(path))
  1876. {
  1877. step = 8;
  1878. // CString ss;
  1879. // ss.Format ("出错在函数备份照片中-step:%d,文件:%s", step, path);
  1880. // WriteTextLog(ss);
  1881. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  1882. fp.WriteString(CTime::GetCurrentTime().Format("%Y-%m-%d"));
  1883. fp.Close();
  1884. }
  1885. }
  1886. }
  1887. if (bError)
  1888. g_bakphoto = "照片备份失败";
  1889. else
  1890. g_bakphoto = "照片备份成功";
  1891. step = 9;
  1892. }
  1893. catch (CException *e)
  1894. {
  1895. TCHAR szError[1024] = { 0 };
  1896. e->GetErrorMessage(szError, 1024);
  1897. WriteTextLog(CString(szError));
  1898. e->Delete();
  1899. if (step != 8)
  1900. {
  1901. CString ss;
  1902. ss.Format("出错在函数备份照片中-step:%d", step);
  1903. WriteTextLog(ss);
  1904. g_bakphoto = "照片备份出错";
  1905. }
  1906. else
  1907. {
  1908. if (bError)
  1909. g_bakphoto = "照片备份失败";
  1910. else
  1911. g_bakphoto = "照片备份成功";
  1912. }
  1913. }
  1914. pDlg->SetTimer(6, 3000, NULL);
  1915. pDlg->m_bRunning2 = false;
  1916. pDlg->m_bTerminate2 = false;
  1917. _endthreadex(0);
  1918. return 0;
  1919. }
  1920. void CDBServerDlg::LoadThumbImages()
  1921. {
  1922. if (m_bRunning)return;
  1923. TerminateThread();
  1924. m_bRunning = true;
  1925. m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
  1926. }
  1927. //--------------------------------------------------------------
  1928. // Remark by Jeff 2014.10.22
  1929. // 函数:LoadThumbImages2
  1930. // 描述:
  1931. // 参数:
  1932. // 返回:
  1933. //
  1934. // 调用关系:
  1935. // 1.LoadThumbImages2() 只由 BakPhoto() 调用;
  1936. // 2.BakPhoto()由CDBServerDlg::SetTimer(4) 调用,调用频率2分钟,周期数直到程序结束。
  1937. // 3.CDBServerDlg::SetTimer(4) 由 CDBServerDlg::SetTimer(2) 调用,调用频率10毫秒,只有一个周期。
  1938. // 4.CDBServerDlg::SetTimer(2) 由 CDBServerDlg::OnInitDialog() 调用.
  1939. //--------------------------------------------------------------
  1940. void CDBServerDlg::LoadThumbImages2()
  1941. {
  1942. if (m_bRunning2)return;
  1943. TerminateThread2();
  1944. m_bRunning2 = true;
  1945. m_hThread2 = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail2, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID2);
  1946. }
  1947. BOOL CDBServerDlg::TerminateThread()
  1948. {
  1949. try
  1950. {
  1951. if (!m_bRunning)
  1952. return TRUE;
  1953. m_bTerminate = true;
  1954. for (;;)
  1955. {
  1956. if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
  1957. break;
  1958. MSG msg;
  1959. while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  1960. {
  1961. if (!AfxGetApp()->PumpMessage())
  1962. break;
  1963. }
  1964. }
  1965. ::CloseHandle(m_hThread);
  1966. m_bRunning = false;
  1967. return TRUE;
  1968. }
  1969. catch (...)
  1970. {
  1971. WriteTextLog("出错在函数TerminateThread中");
  1972. }
  1973. }
  1974. BOOL CDBServerDlg::TerminateThread2()
  1975. {
  1976. try
  1977. {
  1978. if (!m_bRunning2)
  1979. return TRUE;
  1980. m_bTerminate2 = true;
  1981. for (;;)
  1982. {
  1983. if (::WaitForSingleObject(m_hThread2, 0) == WAIT_OBJECT_0)
  1984. break;
  1985. MSG msg;
  1986. while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  1987. {
  1988. if (!AfxGetApp()->PumpMessage())
  1989. break;
  1990. }
  1991. }
  1992. ::CloseHandle(m_hThread2);
  1993. m_bRunning2 = false;
  1994. return TRUE;
  1995. }
  1996. catch (...)
  1997. {
  1998. WriteTextLog("出错在函数TerminateThread2中");
  1999. }
  2000. }
  2001. void CDBServerDlg::InitLia()
  2002. {
  2003. if (g_pSkinData)
  2004. delete[]g_pSkinData;
  2005. g_pSkinData = NULL;
  2006. HGLOBAL hGlobal = NULL;
  2007. HRSRC hSource = NULL;
  2008. LPVOID lpBuffer = NULL;
  2009. BOOL bResult = FALSE;
  2010. // 1.定位我们的自定义资源,这里因为我们是从本模块定位资源,所以将句柄简单地置为NULL即可
  2011. hSource = FindResource(NULL, MAKEINTRESOURCE(LIA004), _T("SOFTKEY"));
  2012. if (hSource == NULL)
  2013. {
  2014. WriteTextLog(_T("定位资源失败"));
  2015. return;
  2016. }
  2017. // 2.获取资源的大小;
  2018. g_SkinLeng = (UINT)SizeofResource(NULL, hSource);
  2019. // 3.加载资源;
  2020. hGlobal = LoadResource(NULL, hSource);
  2021. if (hGlobal == NULL)
  2022. {
  2023. WriteTextLog(_T("加载资源失败"));
  2024. return;
  2025. }
  2026. // 4.锁定资源,获取buffer;
  2027. lpBuffer = LockResource(hGlobal);
  2028. if (lpBuffer == NULL)
  2029. {
  2030. WriteTextLog(_T("锁定资源失败"));
  2031. return;
  2032. }
  2033. g_pSkinData = new BYTE[g_SkinLeng];
  2034. memcpy(g_pSkinData, lpBuffer, g_SkinLeng);
  2035. UnlockResource(hGlobal);
  2036. FreeResource(hGlobal);
  2037. }
  2038. BOOL CheckExistDinDan(CString id)
  2039. {
  2040. CRecordset myset(&g_db);
  2041. CString sql = "select count(*) as cot from dindan where id='" + id + "'";
  2042. myset.Open(CRecordset::forwardOnly, sql);
  2043. myset.GetFieldValue("cot", sql);
  2044. myset.Close();
  2045. return atol(sql);
  2046. }
  2047. //CString g_nCurConvertDBName="db"; // Jeff.deal
  2048. CString g_nCurConvertDBName(g_szDBName);
  2049. /************************************************************************/
  2050. /* [函数]:CheckHistoryData
  2051. /* [描述]:将被检测的数据库已完成的订单数据转到历史数据库中,并删除被检测的数据库已完成的订单;
  2052. /* [参数]:
  2053. /* pSrcdb: 源数据库,用于被转历史的数据库;
  2054. /* nSrcYear: 源数据库的年份;
  2055. /* bMode2: 转储模式:0=年度完成的订单; 1=年度所有订单,包含未完成订单;
  2056. /* [返回]:void
  2057. /*
  2058. /************************************************************************/
  2059. void CDBServerDlg::CheckHistoryData(CDatabase *pSrcdb /* = NULL */, int nSrcYear /* = 0 */, BOOL bMode2 /* = 0*/)//历史备份;
  2060. {
  2061. #if JEFF_TEST_ON
  2062. // 取消转将当前数据库完成订单的记录转到年份数据库中,此步直接返回;
  2063. return;
  2064. #endif
  2065. try
  2066. {
  2067. //g_nCurConvertDBName="db";
  2068. g_nCurConvertDBName = g_szDBName;
  2069. if (pSrcdb != NULL)
  2070. {
  2071. g_bConvertHisAll = 1;
  2072. g_nCurConvertDBName.Format("%d", nSrcYear);
  2073. if (bMode2)
  2074. {
  2075. // MessageBox(g_nCurConvertDBName);
  2076. }
  2077. }
  2078. if (g_bConvertHisAll)
  2079. {
  2080. DWORD id = FindAppProcessID("AutoRun.exe");
  2081. if (id != -1)
  2082. {
  2083. HANDLE ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
  2084. if (ProcessHandle)
  2085. TerminateProcess(ProcessHandle, 0);
  2086. }
  2087. ShowWindow(SW_HIDE);
  2088. WriteTextLog("全部转历史开始");
  2089. }
  2090. CString sql;
  2091. g_curdb = &g_db;
  2092. if (pSrcdb != NULL)
  2093. g_curdb = pSrcdb;
  2094. // 1.获取去年年份值 lastyear
  2095. CTime tm = CTime::GetCurrentTime();
  2096. int lastyear = tm.GetYear() - 1;
  2097. CString strdate, strdate2;
  2098. strdate.Format("%04d-%02d-%02d", lastyear, 1, 1);
  2099. strdate2.Format("%04d-%02d-%02d", lastyear, 12, 31);
  2100. CString filter = "time1>='" + strdate + "' and time1<='" + strdate2 + "' and status3='OK'";
  2101. DWORD ii = 0;
  2102. CArray<CStringArray, CStringArray> strOrderNumberArray; //用于记录订单单号;
  2103. // 2.获取得订单号,并存储在CArray<CStringArray,CStringArray>
  2104. if (bMode2)// 存储即将转为历史数据库的所有年度订单的数据库记录(包含未完成);
  2105. {
  2106. CString filter = "time1>='" + strdate + "' and time1<='" + strdate2 + "'";
  2107. // AfxMessageBox(filter);
  2108. CRecordset myset(g_curdb);
  2109. CString sql = "select count(*) as cot from dindan"; // 订单单数;
  2110. if (!filter.IsEmpty())
  2111. sql += " where " + filter;
  2112. myset.Open(CRecordset::forwardOnly, sql);
  2113. myset.GetFieldValue("cot", sql);
  2114. myset.Close();
  2115. // AfxMessageBox(sql);
  2116. int count = atol(sql);
  2117. strOrderNumberArray.SetSize(count, 1);
  2118. CRstDindanForm rsSt;
  2119. rsSt.m_pDatabase = g_curdb;
  2120. if (!filter.IsEmpty())
  2121. rsSt.m_strFilter = filter;
  2122. rsSt.Open();
  2123. ii = 0;
  2124. while (!rsSt.IsEOF())
  2125. {
  2126. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2127. //if(CheckExistDinDan(rsSt.id)==0)
  2128. {
  2129. strOrderNumberArray.ElementAt(ii).Add(rsSt.id);
  2130. ii++;
  2131. }
  2132. rsSt.MoveNext();
  2133. if (strOrderNumberArray.GetSize() <= ii)
  2134. break;
  2135. }
  2136. rsSt.Close();
  2137. strOrderNumberArray.SetSize(ii, 1);
  2138. }
  2139. else// 存储即将转为历史数据库的已完成订单的年度数据库记录;
  2140. {
  2141. // 有多少订单完成的;
  2142. CRecordset myset(g_curdb);
  2143. CString sql = "select count(*) as cot from dindan";
  2144. if (!filter.IsEmpty())
  2145. sql += " where " + filter;
  2146. myset.Open(CRecordset::forwardOnly, sql);
  2147. myset.GetFieldValue("cot", sql);
  2148. myset.Close();
  2149. int count = atol(sql);
  2150. strOrderNumberArray.SetSize(count, 1);
  2151. CRstDindanForm rsSt;
  2152. rsSt.m_pDatabase = g_curdb;
  2153. if (!filter.IsEmpty())
  2154. rsSt.m_strFilter = filter;
  2155. rsSt.Open();
  2156. ii = 0;
  2157. while (!rsSt.IsEOF())
  2158. {
  2159. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2160. strOrderNumberArray.ElementAt(ii).Add(rsSt.id);
  2161. ii++;
  2162. rsSt.MoveNext();
  2163. if (strOrderNumberArray.GetSize() <= ii)
  2164. break;
  2165. }
  2166. rsSt.Close();
  2167. strOrderNumberArray.SetSize(ii, 1);
  2168. }
  2169. // 3.获取该年份名称的数据库;
  2170. CDatabase *pLastYeardb = GetDB(lastyear);
  2171. if (pLastYeardb == NULL)
  2172. {
  2173. CheckYear(lastyear);
  2174. return;
  2175. }
  2176. CDatabase *pdb2Transfer = g_curdb; // pdb2Transfer需要转为成历史数据库的数据库;
  2177. pLastYeardb = GetDB(lastyear); // pLastYeardb往年历史数据库;
  2178. if (pLastYeardb == NULL)
  2179. {
  2180. // Jeff数据库中,没有历史数据库存在,退出历史转换任务;
  2181. return;
  2182. }
  2183. // 4.根据订单号,遍历数据;
  2184. int i = 0;
  2185. for ( i = 0; i < strOrderNumberArray.GetSize(); i++)
  2186. {
  2187. // if("20121013-005"!=g_List1array.ElementAt (i).ElementAt (0))continue;
  2188. // TransDinDan返回:1表示正常, 100及以上表示源数据库里记录 > 目标数据库记录;
  2189. // TransDinDan将源数据库中的订单数据insert into 到目标数据库中;
  2190. int ret = TransDinDan(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear);
  2191. if (ret == 1)
  2192. {
  2193. // ret == 1表示源数据库将订单数据插入到目标数据库成功,则删除源数据库中的订单数据;
  2194. sql = "delete from dindan where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
  2195. MyExecuteSQL(g_curdb, sql);
  2196. sql = "delete from dindansp where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
  2197. MyExecuteSQL(g_curdb, sql);
  2198. sql = "delete from photoprint where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
  2199. MyExecuteSQL(g_curdb, sql);
  2200. sql = "delete from dindanbukuan where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
  2201. MyExecuteSQL(g_curdb, sql);
  2202. sql = "delete from dindanbukuan2 where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
  2203. MyExecuteSQL(g_curdb, sql);
  2204. sql = "delete from client where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
  2205. MyExecuteSQL(g_curdb, sql);
  2206. sql = "delete from burncdreg where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
  2207. MyExecuteSQL(g_curdb, sql);
  2208. sql = "delete from digitalwork where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
  2209. MyExecuteSQL(g_curdb, sql);
  2210. sql = "delete from mywork where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
  2211. MyExecuteSQL(g_curdb, sql);
  2212. sql = "delete from dindanjd where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
  2213. MyExecuteSQL(g_curdb, sql);
  2214. sql = "delete from dindansp2 where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
  2215. MyExecuteSQL(g_curdb, sql);
  2216. sql = "delete from dindansp3 where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
  2217. MyExecuteSQL(g_curdb, sql);
  2218. }
  2219. else
  2220. {
  2221. // ret=105,已经转过,但是2014被删除过,然后再次转时发现2014里没有记录;待定;
  2222. sql.Format("ret:%d", ret);
  2223. WriteTextLog("转历史失败" + strOrderNumberArray.ElementAt(i).ElementAt(0) + sql);
  2224. }
  2225. #ifdef LIMITCOUNT
  2226. if (g_bConvertHisAll == 0)
  2227. {
  2228. if (i > 100)break;
  2229. }
  2230. #endif
  2231. }
  2232. ////////////////////////////支出
  2233. //WriteTextLog("支出");
  2234. strdate.Format("%04d-%02d-%02d", lastyear, 1, 1);
  2235. strdate2.Format("%04d-%02d-%02d", lastyear, 12, 31);
  2236. filter = "dat>='" + strdate + "' and dat<='" + strdate2 + "'";
  2237. {
  2238. strOrderNumberArray.RemoveAll();
  2239. CRecordset myset(g_curdb);
  2240. CString sql = "select count(*) as cot from gudingfeiyong";
  2241. if (!filter.IsEmpty())
  2242. sql += " where " + filter;
  2243. myset.Open(CRecordset::forwardOnly, sql);
  2244. myset.GetFieldValue("cot", sql);
  2245. myset.Close();
  2246. int count = atol(sql);
  2247. strOrderNumberArray.SetSize(count, 1);
  2248. CRstPayOutInput rsSt;
  2249. rsSt.m_pDatabase = g_curdb;
  2250. if (!filter.IsEmpty())
  2251. rsSt.m_strFilter = filter;
  2252. rsSt.Open();
  2253. ii = 0;
  2254. while (!rsSt.IsEOF())
  2255. {
  2256. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2257. strOrderNumberArray.ElementAt(ii).Add(rsSt.id);
  2258. ii++;
  2259. rsSt.MoveNext(); if (strOrderNumberArray.GetSize() <= ii)break;
  2260. }
  2261. rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
  2262. }
  2263. for (i = 0; i < strOrderNumberArray.GetSize(); i++)
  2264. {
  2265. if (TransPayOut(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
  2266. {
  2267. {
  2268. sql.Format("delete from gudingfeiyong where id=%d", atol(strOrderNumberArray.ElementAt(i).ElementAt(0)));
  2269. MyExecuteSQL(g_curdb, sql);
  2270. }
  2271. }
  2272. #ifdef LIMITCOUNT
  2273. if (g_bConvertHisAll == 0)
  2274. {
  2275. if (i > 100)break;
  2276. }
  2277. #endif
  2278. }
  2279. ////////////////////////////其它收入
  2280. strdate.Format("%04d-%02d-%02d", lastyear, 1, 1);
  2281. strdate2.Format("%04d-%02d-%02d", lastyear, 12, 31);
  2282. filter = "dat>='" + strdate + "' and dat<='" + strdate2 + "'";
  2283. {
  2284. strOrderNumberArray.RemoveAll();
  2285. CRecordset myset(g_curdb);
  2286. CString sql = "select count(*) as cot from singleincome";
  2287. if (!filter.IsEmpty())
  2288. sql += " where " + filter;
  2289. myset.Open(CRecordset::forwardOnly, sql);
  2290. myset.GetFieldValue("cot", sql);
  2291. myset.Close();
  2292. int count = atol(sql);
  2293. strOrderNumberArray.SetSize(count, 1);
  2294. CRstIncomeInput rsSt;
  2295. rsSt.m_pDatabase = g_curdb;
  2296. if (!filter.IsEmpty())
  2297. rsSt.m_strFilter = filter;
  2298. rsSt.Open();
  2299. ii = 0;
  2300. while (!rsSt.IsEOF())
  2301. {
  2302. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2303. if (atoi(rsSt.balance) == 0)
  2304. strOrderNumberArray.ElementAt(ii).Add(rsSt.id);
  2305. else
  2306. {
  2307. rsSt.MoveNext(); continue;
  2308. }
  2309. ii++;
  2310. rsSt.MoveNext();
  2311. if (strOrderNumberArray.GetSize() <= ii)break;
  2312. }
  2313. rsSt.Close();
  2314. strOrderNumberArray.SetSize(ii, 1);
  2315. }
  2316. for (i = 0; i < strOrderNumberArray.GetSize(); i++)
  2317. {
  2318. if (TransIncome(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
  2319. {
  2320. {
  2321. sql.Format("delete from singleincome where id=%d", atol(strOrderNumberArray.ElementAt(i).ElementAt(0)));
  2322. MyExecuteSQL(g_curdb, sql);
  2323. sql.Format("delete from singleincomemoney where [id]='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
  2324. MyExecuteSQL(g_curdb, sql);
  2325. }
  2326. }
  2327. #ifdef LIMITCOUNT
  2328. if (g_bConvertHisAll == 0)
  2329. {
  2330. if (i > 100)break;
  2331. }
  2332. #endif
  2333. }
  2334. ////////////////////////////其它二销收款
  2335. filter = "id not in(select id from singleincome)";
  2336. {
  2337. strOrderNumberArray.RemoveAll();
  2338. CRecordset myset(g_curdb);
  2339. CString sql = "select count(*) as cot from singleincomemoney";
  2340. if (!filter.IsEmpty())
  2341. sql += " where " + filter;
  2342. myset.Open(CRecordset::forwardOnly, sql);
  2343. myset.GetFieldValue("cot", sql);
  2344. myset.Close();
  2345. int count = atol(sql);
  2346. strOrderNumberArray.SetSize(count, 1);
  2347. CRstsingleincomemoney rsSt;
  2348. rsSt.m_pDatabase = g_curdb;
  2349. if (!filter.IsEmpty())
  2350. rsSt.m_strFilter = filter;
  2351. rsSt.Open();
  2352. ii = 0;
  2353. while (!rsSt.IsEOF())
  2354. {
  2355. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2356. strOrderNumberArray.ElementAt(ii).Add(rsSt.id);
  2357. ii++;
  2358. rsSt.MoveNext();
  2359. if (strOrderNumberArray.GetSize() <= ii)
  2360. break;
  2361. }
  2362. rsSt.Close();
  2363. strOrderNumberArray.SetSize(ii, 1);
  2364. }
  2365. ////////////////////////////其它二销收款
  2366. for (i = 0; i < strOrderNumberArray.GetSize(); i++)
  2367. {
  2368. if (TransIncomeMoney(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
  2369. {
  2370. {
  2371. sql.Format("delete from singleincomemoney where [id]='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
  2372. MyExecuteSQL(g_curdb, sql);
  2373. }
  2374. }
  2375. #ifdef LIMITCOUNT
  2376. if (i > 100)break;
  2377. #endif
  2378. }
  2379. ///1/////////////////////////client2phonerecord 2010-08-09 16:22:16
  2380. strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
  2381. strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
  2382. filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
  2383. {
  2384. strOrderNumberArray.RemoveAll();
  2385. CRecordset myset(g_curdb);
  2386. CString sql = "select count(*) as cot from client2phonerecord"; if (!filter.IsEmpty())sql += " where " + filter;
  2387. myset.Open(CRecordset::forwardOnly, sql);
  2388. myset.GetFieldValue("cot", sql);
  2389. myset.Close();
  2390. int count = atol(sql);
  2391. strOrderNumberArray.SetSize(count, 1);
  2392. CRstclient2phonerecord rsSt;
  2393. rsSt.m_pDatabase = g_curdb;
  2394. if (!filter.IsEmpty())
  2395. rsSt.m_strFilter = filter;
  2396. rsSt.Open();
  2397. ii = 0;
  2398. while (!rsSt.IsEOF())
  2399. {
  2400. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2401. strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
  2402. ii++;
  2403. rsSt.MoveNext();
  2404. if (strOrderNumberArray.GetSize() <= ii)
  2405. break;
  2406. }
  2407. rsSt.Close();
  2408. strOrderNumberArray.SetSize(ii, 1);
  2409. }
  2410. for (i = 0; i < strOrderNumberArray.GetSize(); i++)
  2411. {
  2412. if (Transclient2phonerecord(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
  2413. {
  2414. {
  2415. sql.Format("delete from client2phonerecord where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
  2416. MyExecuteSQL(g_curdb, sql);
  2417. }
  2418. }
  2419. #ifdef LIMITCOUNT
  2420. if (g_bConvertHisAll == 0)
  2421. {
  2422. if (i > 100)break;
  2423. }
  2424. #endif
  2425. }
  2426. ///////////////////////////
  2427. ////////////////////////////client2phonerecordout 2010-08-09 16:22:16
  2428. strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
  2429. strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
  2430. filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
  2431. {
  2432. strOrderNumberArray.RemoveAll();
  2433. CRecordset myset(g_curdb);
  2434. CString sql = "select count(*) as cot from client2phonerecordout";
  2435. if (!filter.IsEmpty())
  2436. sql += " where " + filter;
  2437. myset.Open(CRecordset::forwardOnly, sql);
  2438. myset.GetFieldValue("cot", sql);
  2439. myset.Close();
  2440. int count = atol(sql);
  2441. strOrderNumberArray.SetSize(count, 1);
  2442. CRstclient2phonerecordout rsSt;
  2443. rsSt.m_pDatabase = g_curdb;
  2444. if (!filter.IsEmpty())
  2445. rsSt.m_strFilter = filter;
  2446. rsSt.Open();
  2447. ii = 0;
  2448. while (!rsSt.IsEOF())
  2449. {
  2450. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2451. strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
  2452. ii++;
  2453. rsSt.MoveNext(); if (strOrderNumberArray.GetSize() <= ii)break;
  2454. }
  2455. rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
  2456. }
  2457. for (i = 0; i < strOrderNumberArray.GetSize(); i++)
  2458. {
  2459. if (Transclient2phonerecordout(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
  2460. {
  2461. {
  2462. sql.Format("delete from client2phonerecordout where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
  2463. MyExecuteSQL(g_curdb, sql);
  2464. }
  2465. }
  2466. #ifdef LIMITCOUNT
  2467. if (g_bConvertHisAll == 0)
  2468. {
  2469. if (i > 100)break;
  2470. }
  2471. #endif
  2472. }
  2473. ///1/////////////////////////client3phonerecord 2010-08-09 16:22:16
  2474. strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
  2475. strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
  2476. filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
  2477. {
  2478. strOrderNumberArray.RemoveAll();
  2479. CRecordset myset(g_curdb);
  2480. CString sql = "select count(*) as cot from client3phonerecord";
  2481. if (!filter.IsEmpty())
  2482. sql += " where " + filter;
  2483. myset.Open(CRecordset::forwardOnly, sql);
  2484. myset.GetFieldValue("cot", sql);
  2485. myset.Close();
  2486. int count = atol(sql);
  2487. strOrderNumberArray.SetSize(count, 1);
  2488. CRstclient3phonerecord rsSt;
  2489. rsSt.m_pDatabase = g_curdb;
  2490. if (!filter.IsEmpty())
  2491. rsSt.m_strFilter = filter;
  2492. rsSt.Open();
  2493. ii = 0;
  2494. while (!rsSt.IsEOF())
  2495. {
  2496. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2497. strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
  2498. ii++;
  2499. rsSt.MoveNext();
  2500. if (strOrderNumberArray.GetSize() <= ii)
  2501. break;
  2502. }
  2503. rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
  2504. }
  2505. for (i = 0; i < strOrderNumberArray.GetSize(); i++)
  2506. {
  2507. if (Transclient3phonerecord(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
  2508. {
  2509. {
  2510. sql.Format("delete from client3phonerecord where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
  2511. MyExecuteSQL(g_curdb, sql);
  2512. }
  2513. }
  2514. #ifdef LIMITCOUNT
  2515. if (g_bConvertHisAll == 0)
  2516. {
  2517. if (i > 100)break;
  2518. }
  2519. #endif
  2520. }
  2521. ///////////////////////////
  2522. ////////////////////////////client3phonerecordout 2010-08-09 16:22:16
  2523. strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
  2524. strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
  2525. filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
  2526. {
  2527. strOrderNumberArray.RemoveAll();
  2528. CRecordset myset(g_curdb);
  2529. CString sql = "select count(*) as cot from client3phonerecordout";
  2530. if (!filter.IsEmpty())
  2531. sql += " where " + filter;
  2532. myset.Open(CRecordset::forwardOnly, sql);
  2533. myset.GetFieldValue("cot", sql);
  2534. myset.Close();
  2535. int count = atol(sql);
  2536. strOrderNumberArray.SetSize(count, 1);
  2537. CRstclient3phonerecordout rsSt;
  2538. rsSt.m_pDatabase = g_curdb;
  2539. if (!filter.IsEmpty())
  2540. rsSt.m_strFilter = filter;
  2541. rsSt.Open();
  2542. ii = 0;
  2543. while (!rsSt.IsEOF())
  2544. {
  2545. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2546. strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
  2547. ii++;
  2548. rsSt.MoveNext(); if (strOrderNumberArray.GetSize() <= ii)break;
  2549. }
  2550. rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
  2551. }
  2552. for (i = 0; i < strOrderNumberArray.GetSize(); i++)
  2553. {
  2554. if (Transclient3phonerecordout(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
  2555. {
  2556. {
  2557. sql.Format("delete from client3phonerecordout where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
  2558. MyExecuteSQL(g_curdb, sql);
  2559. }
  2560. }
  2561. #ifdef LIMITCOUNT
  2562. if (g_bConvertHisAll == 0)
  2563. {
  2564. if (i > 100)break;
  2565. }
  2566. #endif
  2567. }
  2568. ///////////////////////////
  2569. ////////////////////////////employeephonerecord 2010-08-09 16:22:16
  2570. strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
  2571. strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
  2572. filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
  2573. {
  2574. strOrderNumberArray.RemoveAll();
  2575. CRecordset myset(g_curdb);
  2576. CString sql = "select count(*) as cot from employeephonerecord";
  2577. if (!filter.IsEmpty())
  2578. sql += " where " + filter;
  2579. myset.Open(CRecordset::forwardOnly, sql);
  2580. myset.GetFieldValue("cot", sql);
  2581. myset.Close();
  2582. int count = atol(sql);
  2583. strOrderNumberArray.SetSize(count, 1);
  2584. CRstemployeephonerecord rsSt;
  2585. rsSt.m_pDatabase = g_curdb;
  2586. if (!filter.IsEmpty())
  2587. rsSt.m_strFilter = filter;
  2588. rsSt.Open();
  2589. ii = 0;
  2590. while (!rsSt.IsEOF())
  2591. {
  2592. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2593. strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
  2594. ii++;
  2595. rsSt.MoveNext();
  2596. if (strOrderNumberArray.GetSize() <= ii)
  2597. break;
  2598. }
  2599. rsSt.Close();
  2600. strOrderNumberArray.SetSize(ii, 1);
  2601. }
  2602. for (i = 0; i < strOrderNumberArray.GetSize(); i++)
  2603. {
  2604. if (Transemployeephonerecord(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
  2605. {
  2606. {
  2607. sql.Format("delete from employeephonerecord where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
  2608. MyExecuteSQL(g_curdb, sql);
  2609. }
  2610. }
  2611. #ifdef LIMITCOUNT
  2612. if (g_bConvertHisAll == 0)
  2613. {
  2614. if (i > 100)break;
  2615. }
  2616. #endif
  2617. }
  2618. ///////////////////////////
  2619. ////////////////////////////employeephonerecordout 2010-08-09 16:22:16
  2620. strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
  2621. strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
  2622. filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
  2623. {
  2624. strOrderNumberArray.RemoveAll();
  2625. CRecordset myset(g_curdb);
  2626. CString sql = "select count(*) as cot from employeephonerecordout";
  2627. if (!filter.IsEmpty())
  2628. sql += " where " + filter;
  2629. myset.Open(CRecordset::forwardOnly, sql);
  2630. myset.GetFieldValue("cot", sql);
  2631. myset.Close();
  2632. int count = atol(sql);
  2633. strOrderNumberArray.SetSize(count, 1);
  2634. CRstemployeephonerecordout rsSt;
  2635. rsSt.m_pDatabase = g_curdb;
  2636. if (!filter.IsEmpty())
  2637. rsSt.m_strFilter = filter;
  2638. rsSt.Open();
  2639. ii = 0;
  2640. while (!rsSt.IsEOF())
  2641. {
  2642. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2643. strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
  2644. ii++;
  2645. rsSt.MoveNext();
  2646. if (strOrderNumberArray.GetSize() <= ii)
  2647. break;
  2648. }
  2649. rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
  2650. }
  2651. for (i = 0; i < strOrderNumberArray.GetSize(); i++)
  2652. {
  2653. if (Transemployeephonerecordout(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
  2654. {
  2655. {
  2656. sql.Format("delete from employeephonerecordout where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
  2657. MyExecuteSQL(g_curdb, sql);
  2658. }
  2659. }
  2660. #ifdef LIMITCOUNT
  2661. if (g_bConvertHisAll == 0)
  2662. {
  2663. if (i > 100)break;
  2664. }
  2665. #endif
  2666. }
  2667. ///////////////////////////
  2668. ////////////////////////////phonerecord 2010-08-09 16:22:16
  2669. strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
  2670. strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
  2671. filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
  2672. {
  2673. strOrderNumberArray.RemoveAll();
  2674. CRecordset myset(g_curdb);
  2675. CString sql = "select count(*) as cot from phonerecord";
  2676. if (!filter.IsEmpty())
  2677. sql += " where " + filter;
  2678. myset.Open(CRecordset::forwardOnly, sql);
  2679. myset.GetFieldValue("cot", sql);
  2680. myset.Close();
  2681. int count = atol(sql);
  2682. strOrderNumberArray.SetSize(count, 1);
  2683. CRstphonerecord rsSt; rsSt.m_pDatabase = g_curdb;
  2684. if (!filter.IsEmpty())
  2685. rsSt.m_strFilter = filter;
  2686. rsSt.Open();
  2687. ii = 0;
  2688. while (!rsSt.IsEOF())
  2689. {
  2690. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2691. strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
  2692. ii++;
  2693. rsSt.MoveNext();
  2694. if (strOrderNumberArray.GetSize() <= ii)
  2695. break;
  2696. }
  2697. rsSt.Close();
  2698. strOrderNumberArray.SetSize(ii, 1);
  2699. }
  2700. for (i = 0; i < strOrderNumberArray.GetSize(); i++)
  2701. {
  2702. if (Transphonerecord(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
  2703. {
  2704. {
  2705. sql.Format("delete from phonerecord where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
  2706. MyExecuteSQL(g_curdb, sql);
  2707. }
  2708. }
  2709. #ifdef LIMITCOUNT
  2710. if (g_bConvertHisAll == 0)
  2711. {
  2712. if (i > 100)break;
  2713. }
  2714. #endif
  2715. }
  2716. ///////////////////////////
  2717. ////////////////////////////phonerecordout 2010-08-09 16:22:16
  2718. strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
  2719. strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
  2720. filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
  2721. {
  2722. strOrderNumberArray.RemoveAll();
  2723. CRecordset myset(g_curdb);
  2724. CString sql = "select count(*) as cot from phonerecordout";
  2725. if (!filter.IsEmpty())
  2726. sql += " where " + filter;
  2727. myset.Open(CRecordset::forwardOnly, sql);
  2728. myset.GetFieldValue("cot", sql);
  2729. myset.Close();
  2730. int count = atol(sql);
  2731. strOrderNumberArray.SetSize(count, 1);
  2732. CRstphonerecordout rsSt;
  2733. rsSt.m_pDatabase = g_curdb;
  2734. if (!filter.IsEmpty())
  2735. rsSt.m_strFilter = filter;
  2736. rsSt.Open();
  2737. ii = 0;
  2738. while (!rsSt.IsEOF())
  2739. {
  2740. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2741. strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
  2742. ii++;
  2743. rsSt.MoveNext(); if (strOrderNumberArray.GetSize() <= ii)break;
  2744. }
  2745. rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
  2746. }
  2747. for (i = 0; i < strOrderNumberArray.GetSize(); i++)
  2748. {
  2749. if (Transphonerecordout(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
  2750. {
  2751. {
  2752. sql.Format("delete from phonerecordout where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
  2753. MyExecuteSQL(g_curdb, sql);
  2754. }
  2755. }
  2756. #ifdef LIMITCOUNT
  2757. if (g_bConvertHisAll == 0)
  2758. {
  2759. if (i > 100)break;
  2760. }
  2761. #endif
  2762. }
  2763. ///////////////////////////
  2764. ////////////////////////////unknownphonerecord 2010-08-09 16:22:16
  2765. strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
  2766. strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
  2767. filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
  2768. {
  2769. strOrderNumberArray.RemoveAll();
  2770. CRecordset myset(g_curdb);
  2771. CString sql = "select count(*) as cot from unknownphonerecord";
  2772. if (!filter.IsEmpty())
  2773. sql += " where " + filter;
  2774. myset.Open(CRecordset::forwardOnly, sql);
  2775. myset.GetFieldValue("cot", sql);
  2776. myset.Close();
  2777. int count = atol(sql);
  2778. strOrderNumberArray.SetSize(count, 1);
  2779. CRstunknownphonerecord rsSt;
  2780. rsSt.m_pDatabase = g_curdb;
  2781. if (!filter.IsEmpty())
  2782. rsSt.m_strFilter = filter;
  2783. rsSt.Open();
  2784. ii = 0;
  2785. while (!rsSt.IsEOF())
  2786. {
  2787. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2788. strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
  2789. ii++;
  2790. rsSt.MoveNext(); if (strOrderNumberArray.GetSize() <= ii)break;
  2791. }
  2792. rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
  2793. }
  2794. for (i = 0; i < strOrderNumberArray.GetSize(); i++)
  2795. {
  2796. if (Transunknownphonerecord(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
  2797. {
  2798. {
  2799. sql.Format("delete from unknownphonerecord where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
  2800. MyExecuteSQL(g_curdb, sql);
  2801. }
  2802. }
  2803. #ifdef LIMITCOUNT
  2804. if (g_bConvertHisAll == 0)
  2805. {
  2806. if (i > 100)break;
  2807. }
  2808. #endif
  2809. }
  2810. ///////////////////////////
  2811. ////////////////////////////unknownphonerecordout 2010-08-09 16:22:16
  2812. strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
  2813. strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
  2814. filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
  2815. {
  2816. strOrderNumberArray.RemoveAll();
  2817. CRecordset myset(g_curdb);
  2818. CString sql = "select count(*) as cot from unknownphonerecordout";
  2819. if (!filter.IsEmpty())
  2820. sql += " where " + filter;
  2821. myset.Open(CRecordset::forwardOnly, sql);
  2822. myset.GetFieldValue("cot", sql);
  2823. myset.Close();
  2824. int count = atol(sql);
  2825. strOrderNumberArray.SetSize(count, 1);
  2826. CRstunknownphonerecordout rsSt;
  2827. rsSt.m_pDatabase = g_curdb;
  2828. if (!filter.IsEmpty())
  2829. rsSt.m_strFilter = filter;
  2830. rsSt.Open();
  2831. ii = 0;
  2832. while (!rsSt.IsEOF())
  2833. {
  2834. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2835. strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
  2836. ii++;
  2837. rsSt.MoveNext();
  2838. if (strOrderNumberArray.GetSize() <= ii)
  2839. break;
  2840. }
  2841. rsSt.Close();
  2842. strOrderNumberArray.SetSize(ii, 1);
  2843. }
  2844. for (i = 0; i < strOrderNumberArray.GetSize(); i++)
  2845. {
  2846. if (Transunknownphonerecordout(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
  2847. {
  2848. {
  2849. sql.Format("delete from unknownphonerecordout where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
  2850. MyExecuteSQL(g_curdb, sql);
  2851. }
  2852. }
  2853. #ifdef LIMITCOUNT
  2854. if (g_bConvertHisAll == 0)
  2855. {
  2856. if (i > 100)break;
  2857. }
  2858. #endif
  2859. }
  2860. ///////////////////////////
  2861. ////////////////////////////misscallrecord 2010-08-09 16:22:16
  2862. strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
  2863. strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
  2864. filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
  2865. {
  2866. strOrderNumberArray.RemoveAll();
  2867. CRecordset myset(g_curdb);
  2868. CString sql = "select count(*) as cot from misscallrecord";
  2869. if (!filter.IsEmpty())
  2870. sql += " where " + filter;
  2871. myset.Open(CRecordset::forwardOnly, sql);
  2872. myset.GetFieldValue("cot", sql);
  2873. myset.Close();
  2874. int count = atol(sql);
  2875. strOrderNumberArray.SetSize(count, 1);
  2876. CRstmisscallrecord rsSt;
  2877. rsSt.m_pDatabase = g_curdb;
  2878. if (!filter.IsEmpty())
  2879. rsSt.m_strFilter = filter;
  2880. rsSt.Open();
  2881. ii = 0;
  2882. while (!rsSt.IsEOF())
  2883. {
  2884. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2885. strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
  2886. ii++;
  2887. rsSt.MoveNext();
  2888. if (strOrderNumberArray.GetSize() <= ii)
  2889. break;
  2890. }
  2891. rsSt.Close();
  2892. strOrderNumberArray.SetSize(ii, 1);
  2893. }
  2894. for (i = 0; i < strOrderNumberArray.GetSize(); i++)
  2895. {
  2896. if (Transmisscallrecord(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
  2897. {
  2898. {
  2899. sql.Format("delete from misscallrecord where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
  2900. MyExecuteSQL(g_curdb, sql);
  2901. }
  2902. }
  2903. #ifdef LIMITCOUNT
  2904. if (g_bConvertHisAll == 0)
  2905. {
  2906. if (i > 100)break;
  2907. }
  2908. #endif
  2909. }
  2910. ///////////////////////////
  2911. ////////////////////////////sendreg
  2912. strdate.Format("%04d%02d%02d000000", lastyear, 1, 1);
  2913. strdate2.Format("%04d%02d%02d999999", lastyear, 12, 31);
  2914. filter = "timestamp>='" + strdate + "' and timestamp<='" + strdate2 + "' and issended='OK'";
  2915. {
  2916. strOrderNumberArray.RemoveAll();
  2917. CRecordset myset(g_curdb);
  2918. CString sql = "select count(*) as cot from sendreg";
  2919. if (!filter.IsEmpty())
  2920. sql += " where " + filter;
  2921. myset.Open(CRecordset::forwardOnly, sql);
  2922. myset.GetFieldValue("cot", sql);
  2923. myset.Close();
  2924. int count = atol(sql);
  2925. strOrderNumberArray.SetSize(count, 1);
  2926. RstSendReg rsSt;
  2927. rsSt.m_pDatabase = g_curdb;
  2928. if (!filter.IsEmpty())
  2929. rsSt.m_strFilter = filter;
  2930. rsSt.Open();
  2931. ii = 0;
  2932. while (!rsSt.IsEOF())
  2933. {
  2934. strOrderNumberArray.ElementAt(ii).RemoveAll();
  2935. strOrderNumberArray.ElementAt(ii).Add(rsSt.m_timestamp);
  2936. ii++;
  2937. rsSt.MoveNext(); if (strOrderNumberArray.GetSize() <= ii)break;
  2938. }
  2939. rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
  2940. }
  2941. for (i = 0; i < strOrderNumberArray.GetSize(); i++)
  2942. {
  2943. if (TransSendReg(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
  2944. {
  2945. {
  2946. sql.Format("delete from sendreg where [timestamp]='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
  2947. MyExecuteSQL(g_curdb, sql);
  2948. }
  2949. }
  2950. #ifdef LIMITCOUNT
  2951. if (g_bConvertHisAll == 0)
  2952. {
  2953. if (i > 100)break;
  2954. }
  2955. #endif
  2956. }
  2957. ///////////////////////////
  2958. }
  2959. catch (...)
  2960. {
  2961. WriteTextLog("出错在函数TransHisData中");
  2962. }
  2963. if (g_bConvertHisAll)WriteTextLog("转换完成!");
  2964. g_bConvertHisAll = 0;
  2965. /////////////////////////生成来电精灵数据
  2966. //return;
  2967. /* g_sendhead.code[0]=80;
  2968. g_sendhead.code[1]=90;
  2969. g_sendhead.code[2]=11;
  2970. g_sendhead.code[3]=138;
  2971. g_sendhead.code[4]=24;
  2972. g_sendhead.code[0]=181;
  2973. g_sendhead.code[0]=65;
  2974. g_sendhead.code[0]=56;*/
  2975. MyLock lock("processChatMessageRequestxiao");
  2976. CArray<int, int>codearray;
  2977. codearray.Add(80);
  2978. codearray.Add(90);
  2979. codearray.Add(11);
  2980. codearray.Add(138);
  2981. codearray.Add(24);
  2982. codearray.Add(181);
  2983. codearray.Add(65);
  2984. codearray.Add(56);
  2985. codearray.Add(179);
  2986. codearray.Add(53);
  2987. CFile fp;
  2988. CString savepath, g_path1;
  2989. char server[50];
  2990. DWORD leng = 50;
  2991. ::GetComputerName(server, &leng);
  2992. g_path1 = server;
  2993. g_path1 = "\\\\" + g_path1 + "\\电话录音(管理软件)$";
  2994. GetPathFromNetShareName("电话录音(管理软件)$", g_path1);
  2995. if (g_path1.IsEmpty())return;
  2996. try
  2997. {
  2998. CArray<CDatabase*, CDatabase*>dbarraytemp;
  2999. dbarraytemp.Copy(g_dbHistoryArray);
  3000. dbarraytemp.InsertAt(0, &g_db);
  3001. for (int aa = 0; aa < dbarraytemp.GetSize(); aa++)
  3002. {
  3003. g_curdb = dbarraytemp.ElementAt(aa);
  3004. savepath.Format("%s\\uphonedata%d.dat", g_path1, aa);
  3005. ::DeleteFile(savepath); // 删除uphonedata.dat文件;
  3006. if (fp.Open(savepath, CFile::modeCreate | CFile::modeWrite) == 0)
  3007. {
  3008. WriteTextLog("更新来电精灵数据出错");
  3009. return;
  3010. }
  3011. CConnectSocket consock;
  3012. consock.m_pConndb = g_curdb;
  3013. for (int i = 0; i < codearray.GetSize(); i++)
  3014. {
  3015. BYTE code = codearray.ElementAt(i);
  3016. DWORD length, arraysize;
  3017. BYTE *pReturn = NULL;
  3018. consock.GetDataFromCode(code, &pReturn, length, arraysize, "");
  3019. fp.Write(&code, sizeof(BYTE));
  3020. fp.Write(&length, sizeof(DWORD));
  3021. fp.Write(&arraysize, sizeof(DWORD));
  3022. fp.Write(pReturn, length);
  3023. }
  3024. fp.Close();
  3025. }
  3026. g_curdb = &g_db;
  3027. }
  3028. catch (CException *e)
  3029. {
  3030. TCHAR szError[1024] = { 0 };
  3031. e->GetErrorMessage(szError, 1024);
  3032. WriteTextLog(CString(szError));
  3033. WriteTextLog("获取来电精灵数据出错");
  3034. e->Delete();
  3035. }
  3036. WriteTextLog("转历史数据完成");
  3037. }
  3038. //------------------------------------------------------------------------------------
  3039. // Jeff remark
  3040. // 函数:CheckYear
  3041. // 描述:
  3042. // 1.检查指定年份的历史数据库mdf文件是否存在,存在则直接附加
  3043. // 2.不存在,则使用null.mdf文件拷贝创建历史年份数据库mdf并附加;
  3044. // 参数:
  3045. // year:被检查年份值;
  3046. // 返回:void
  3047. //------------------------------------------------------------------------------------
  3048. #if JEFF_TEST_ON
  3049. void CDBServerDlg::CheckYear(int year)
  3050. {
  3051. try
  3052. {
  3053. #ifdef SQLSERVER_VERSION
  3054. CString sql;
  3055. // 1.判断年份数据库是否存在;
  3056. CString strPathOfYearmdf;
  3057. CString strPathOfYearldf;
  3058. strPathOfYearmdf.Format("%s\\数据\\%d.mdf", g_mainpath, year);
  3059. strPathOfYearldf.Format("%s\\数据\\%d_log.ldf", g_mainpath, year);
  3060. CString strPathOfnulldbmdf = g_mainpath + "\\数据\\dbnull.mdf";
  3061. CString strPathOfnulldbldf = g_mainpath + "\\数据\\dbnull_log.ldf";
  3062. if (PathFileExists(strPathOfYearmdf) == TRUE)
  3063. {
  3064. if (PathFileExists(strPathOfYearldf) == TRUE)
  3065. {
  3066. sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", year, strPathOfYearmdf, strPathOfYearldf);
  3067. }
  3068. else
  3069. {
  3070. // 此时要删除dbnull_log.ldf文件;
  3071. // 因为如果2015没有对应的ldf文件,在逻辑名仍为dbnull没有改为2015时,他会使用dbnull_log.ldf做为2015数据库的日志文件;
  3072. // 这样造成其他数据库在使用dbnull时会产生错误;
  3073. DeleteFile(strPathOfnulldbldf);
  3074. sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
  3075. }
  3076. g_db.SetQueryTimeout(600);
  3077. try
  3078. {
  3079. g_db.ExecuteSQL(sql);
  3080. }
  3081. catch (CDBException * e)
  3082. {
  3083. WriteTextLog(e->m_strError);
  3084. WriteTextLog("历史数据库初始化失败!");
  3085. e->Delete();
  3086. return;
  3087. }
  3088. }
  3089. else
  3090. {
  3091. // 判断dbnull.mdf文件是否存在;
  3092. if (PathFileExists(strPathOfnulldbmdf) == FALSE)
  3093. {
  3094. WriteTextLog("空数据库丢失!");
  3095. return;
  3096. }
  3097. // 判断拷贝mdf文件是否失败;
  3098. if (FALSE == CopyFile(strPathOfnulldbmdf, strPathOfYearmdf, 1))
  3099. {
  3100. DWORD dwError = ::GetLastError();
  3101. CString strDescription;
  3102. strDescription.Format("dbnull.mdf拷贝为%d.mdf失败", year);
  3103. ErrorExit(strDescription, dwError);
  3104. return;
  3105. }
  3106. else
  3107. {
  3108. DeleteFile(strPathOfYearldf); // 删除%d_log.LDF文件;
  3109. if (PathFileExists(strPathOfnulldbldf) == TRUE)
  3110. {
  3111. if (FALSE == CopyFile(strPathOfnulldbldf, strPathOfYearldf, 1))
  3112. {
  3113. DWORD dwError = ::GetLastError();
  3114. CString strDescription;
  3115. strDescription.Format("null.mdf拷贝为%d.mdf", year);
  3116. ErrorExit(strDescription, dwError);
  3117. // 此时要删除dbnull_log.ldf文件;
  3118. // 因为如果2015没有对应的ldf文件,在逻辑名仍为dbnull没有改为2015时,他会使用dbnull_log.ldf做为2015数据库的日志文件;
  3119. // 这样造成其他数据库在使用dbnull时会产生错误;
  3120. DeleteFile(strPathOfnulldbldf);
  3121. sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
  3122. }
  3123. else
  3124. {
  3125. sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", year, strPathOfYearmdf, strPathOfYearldf);
  3126. }
  3127. }
  3128. else
  3129. {
  3130. // 此时要删除dbnull_log.ldf文件;
  3131. // 因为如果2015没有对应的ldf文件,在逻辑名仍为dbnull没有改为2015时,他会使用dbnull_log.ldf做为2015数据库的日志文件;
  3132. // 这样造成其他数据库在使用dbnull时会产生错误;
  3133. DeleteFile(strPathOfnulldbldf);
  3134. sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
  3135. }
  3136. g_db.SetQueryTimeout(600);
  3137. try
  3138. {
  3139. g_db.ExecuteSQL(sql);
  3140. }
  3141. catch (CDBException * e)
  3142. {
  3143. WriteTextLog(e->m_strError);
  3144. WriteTextLog("历史数据库初始化失败!");
  3145. e->Delete();
  3146. return;
  3147. }
  3148. }
  3149. }
  3150. // 附加成功后,修改逻辑名称;
  3151. sql.Format("alter database [%d] modify file(name='dbnull',newname='%d')", year, year);
  3152. try
  3153. {
  3154. g_db.ExecuteSQL(sql);
  3155. }
  3156. catch (CDBException * e)
  3157. {
  3158. WriteTextLog(e->m_strError);
  3159. WriteTextLog("修改历史数据库主文件逻辑名失败,请手动修改!");
  3160. e->Delete();
  3161. }
  3162. sql.Format("alter database [%d] modify file(name='dbnull_log',newname='%d_log')", year, year);
  3163. try
  3164. {
  3165. g_db.ExecuteSQL(sql);
  3166. }
  3167. catch (CDBException * e)
  3168. {
  3169. WriteTextLog(e->m_strError);
  3170. WriteTextLog("修改历史数据库日志文件逻辑名失败,请手动修改!");
  3171. e->Delete();
  3172. }
  3173. OnExit2();
  3174. #else
  3175. CString path,sql;
  3176. path.Format ("%s\\数据\\%d.mdb", g_mainpath, year);
  3177. if(::PathFileExists (path)==0)
  3178. {
  3179. CString nulldb=g_mainpath+"\\数据\\dbnull.mdb";
  3180. ::CopyFile (nulldb, path, 1);
  3181. CDatabase *db=new CDatabase;
  3182. CString strCon;
  3183. strCon.Format("DRIVER=Microsoft Access Driver (*.mdb);DSN='';DBQ=%s;PWD=lijialyfz",path);
  3184. if(db->OpenEx(strCon,CDatabase::noOdbcDialog))
  3185. {
  3186. g_nYearArray.Add (year);
  3187. g_dbHistoryArray.Add (db);
  3188. sql.Format ("insert into historydb([year])values('%d')", year);
  3189. MyExecuteSQL(&g_db, sql);
  3190. }
  3191. else
  3192. delete db;
  3193. }
  3194. #endif
  3195. }
  3196. catch (...)
  3197. {
  3198. WriteTextLog("出错在函数CheckYear中");
  3199. }
  3200. }
  3201. #else
  3202. void CDBServerDlg::CheckYear(int year)
  3203. {
  3204. try
  3205. {
  3206. #ifdef SQLSERVER_VERSION
  3207. CString strPathOfYearmdf;
  3208. CString strPathOfYearldf;
  3209. CString sql;
  3210. strPathOfYearmdf.Format("%s\\数据\\%d.mdf", g_mainpath, year);
  3211. strPathOfYearldf.Format("%s\\数据\\%d_log.LDF", g_mainpath, year);
  3212. ::DeleteFile(strPathOfYearldf); // 删除%d_log.LDF文件;
  3213. {
  3214. CString strPathOfnulldbmdf = g_mainpath + "\\数据\\dbnull.mdf";
  3215. CString strPathOfnulldbldf = g_mainpath + "\\数据\\dbnull_log.LDF";
  3216. ::DeleteFile(strPathOfnulldbldf); // 删除%d_log.LDF文件;
  3217. // 1.判断null.mdf文件是否存在;
  3218. if (::PathFileExists(strPathOfnulldbmdf) == 0)
  3219. {
  3220. WriteTextLog("空数据库丢失!");
  3221. return;
  3222. }
  3223. // 2.若年份mdf文件不存在,用null.mdf复制一份年份mdf数据库文件;
  3224. BOOL bCopyed = 0;
  3225. if (::PathFileExists(strPathOfYearmdf) == 0)
  3226. {
  3227. #if 0
  3228. ::CopyFile(nulldb, path, 1);
  3229. bCopyed=1;
  3230. #else // Jeff add:判断拷贝文件失败的原因;
  3231. if (!::CopyFile(strPathOfnulldbmdf, strPathOfYearmdf, 1))
  3232. {
  3233. DWORD dwError = ::GetLastError();
  3234. CString strDescription;
  3235. strDescription.Format("null.mdf拷贝为%d.mdf", year);
  3236. ErrorExit(strDescription, dwError);
  3237. // return;//直接返回;
  3238. }
  3239. else
  3240. {
  3241. bCopyed = 1;
  3242. }
  3243. #endif
  3244. }
  3245. if (::PathFileExists(strPathOfYearmdf) == 0)
  3246. {
  3247. WriteTextLog("拷贝数据库文件失败!");
  3248. return;
  3249. }
  3250. BOOL bLog = 0;
  3251. if (::PathFileExists(strPathOfnulldbldf))
  3252. {
  3253. bLog = 1;
  3254. }
  3255. // .将年份数据库mdf附加到数据库里;
  3256. CString sql;
  3257. if (bCopyed)
  3258. {
  3259. if (bLog)
  3260. sql.Format("exec sp_attach_db '%s',@filename1='%s',@filename2='%s'", "dbnull", strPathOfYearmdf, strPathOfYearldf);
  3261. else
  3262. sql.Format("exec sp_attach_db '%s',@filename1='%s'", "dbnull", strPathOfYearmdf);
  3263. g_db.SetQueryTimeout(600);
  3264. try
  3265. {
  3266. g_db.ExecuteSQL(sql);
  3267. }
  3268. catch (CDBException * e)
  3269. {
  3270. WriteTextLog(e->m_strError);
  3271. WriteTextLog("历史数据库初始化失败!");
  3272. e->Delete();
  3273. }
  3274. sql.Format("exec sp_renamedb '%s','%d'", "dbnull", year); g_db.ExecuteSQL(sql);
  3275. }
  3276. else // 没有执行CopyFile,年份mdf原本就存在;
  3277. {
  3278. if (bLog)
  3279. sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", year, strPathOfYearmdf, strPathOfYearldf);
  3280. else
  3281. sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
  3282. g_db.SetQueryTimeout(600);
  3283. try
  3284. {
  3285. g_db.ExecuteSQL(sql);
  3286. }
  3287. catch (CDBException * e)
  3288. {
  3289. WriteTextLog(e->m_strError);
  3290. WriteTextLog("历史数据库初始化失败!");
  3291. e->Delete();
  3292. }
  3293. }
  3294. OnExit2();
  3295. /* g_db.SetQueryTimeout(100);
  3296. CDatabase *db=new CDatabase;
  3297. try
  3298. {
  3299. CString strCon;
  3300. strCon.Format(_T("driver={SQL Server};Server=%s;DATABASE=%d;%s"), g_sservrename,year,g_sdbpsw);
  3301. db->OpenEx(strCon,CDatabase::noOdbcDialog);
  3302. g_nYearArray.Add (year);
  3303. dbarray.Add (db);
  3304. sql.Format ("insert into [historydb]([year])values('%d')", year);
  3305. MyExecuteSQL(&g_db, sql);
  3306. }
  3307. catch(CDBException * e)
  3308. {
  3309. delete db;
  3310. WriteTextLog(e->m_strError);
  3311. WriteTextLog("历史数据库打开失败!");
  3312. }*/
  3313. }
  3314. #else
  3315. CString path,sql;
  3316. path.Format ("%s\\数据\\%d.mdb", g_mainpath, year);
  3317. if(::PathFileExists (path)==0)
  3318. {
  3319. CString nulldb=g_mainpath+"\\数据\\dbnull.mdb";
  3320. ::CopyFile (nulldb, path, 1);
  3321. CDatabase *db=new CDatabase;
  3322. CString strCon;
  3323. strCon.Format("DRIVER=Microsoft Access Driver (*.mdb);DSN='';DBQ=%s;PWD=lijialyfz",path);
  3324. if(db->OpenEx(strCon,CDatabase::noOdbcDialog))
  3325. {
  3326. g_nYearArray.Add (year);
  3327. g_dbHistoryArray.Add (db);
  3328. sql.Format ("insert into historydb([year])values('%d')", year);
  3329. MyExecuteSQL(&g_db, sql);
  3330. }
  3331. else
  3332. delete db;
  3333. }
  3334. #endif
  3335. }
  3336. catch (...)
  3337. {
  3338. WriteTextLog("出错在函数CheckYear中");
  3339. }
  3340. }
  3341. #endif
  3342. CDatabase* CDBServerDlg::GetDB(int year)
  3343. {
  3344. try
  3345. {
  3346. for (int i = 0; i < g_nYearArray.GetSize(); i++)
  3347. {
  3348. if (g_nYearArray.ElementAt(i) == year)
  3349. {
  3350. return g_dbHistoryArray.ElementAt(i);
  3351. }
  3352. }
  3353. return NULL;
  3354. }
  3355. catch (...)
  3356. {
  3357. WriteTextLog("出错在函数GetDB中");
  3358. }
  3359. }
  3360. /************************************************************************/
  3361. /* mark by Jeff;
  3362. /* 函数:CheckDinDanExist
  3363. /* 描述:
  3364. /* 参数:
  3365. /* pBeConverted_db:(源)
  3366. /* pToConverted_db:(目标)
  3367. /* strOderNumber:
  3368. /* pRetArray:
  3369. /*
  3370. /* 返回:1表示正常,100及以上表示源数据库里记录 > 目标数据库记录;
  3371. /*
  3372. /************************************************************************/
  3373. BOOL CDBServerDlg::CheckDinDanExist(CDatabase *pBeConverted_db, CDatabase *pToConverted_db, CString strOderNumber, CStringArray *pRetArray)
  3374. {
  3375. try
  3376. {
  3377. pRetArray->RemoveAll();
  3378. int count1 = 0;
  3379. int count2 = 0;
  3380. CString sql;
  3381. {
  3382. CRecordset myset(pBeConverted_db);
  3383. sql = "select count(*) as cot from dindan where id='" + strOderNumber + "'";
  3384. myset.Open(CRecordset::forwardOnly, sql);
  3385. myset.GetFieldValue("cot", sql);
  3386. myset.Close();
  3387. count1 = atoi(sql);
  3388. }
  3389. {
  3390. CRecordset myset(pToConverted_db);
  3391. sql = "select count(*) as cot from dindan where id='" + strOderNumber + "'";
  3392. myset.Open(CRecordset::forwardOnly, sql);
  3393. myset.GetFieldValue("cot", sql);
  3394. myset.Close();
  3395. count2 = atoi(sql);
  3396. }
  3397. if (count1 > count2)//100
  3398. pRetArray->Add("0");
  3399. else
  3400. pRetArray->Add("1");
  3401. {
  3402. CRecordset myset(pBeConverted_db);
  3403. sql = "select count(*) as cot from dindansp where id='" + strOderNumber + "'";
  3404. myset.Open(CRecordset::forwardOnly, sql);
  3405. myset.GetFieldValue("cot", sql);
  3406. myset.Close();
  3407. count1 = atoi(sql);
  3408. }
  3409. {
  3410. CRecordset myset(pToConverted_db);
  3411. sql = "select count(*) as cot from dindansp where id='" + strOderNumber + "'";
  3412. myset.Open(CRecordset::forwardOnly, sql);
  3413. myset.GetFieldValue("cot", sql);
  3414. myset.Close();
  3415. count2 = atoi(sql);
  3416. }
  3417. if (count1 > count2)//101
  3418. pRetArray->Add("0");
  3419. else
  3420. pRetArray->Add("1");
  3421. {
  3422. CRecordset myset(pBeConverted_db);
  3423. sql = "select count(*) as cot from dindanbukuan where id='" + strOderNumber + "'";
  3424. myset.Open(CRecordset::forwardOnly, sql);
  3425. myset.GetFieldValue("cot", sql);
  3426. myset.Close();
  3427. count1 = atoi(sql);
  3428. }
  3429. {
  3430. CRecordset myset(pToConverted_db);
  3431. sql = "select count(*) as cot from dindanbukuan where id='" + strOderNumber + "'";
  3432. myset.Open(CRecordset::forwardOnly, sql);
  3433. myset.GetFieldValue("cot", sql);
  3434. myset.Close();
  3435. count2 = atoi(sql);
  3436. }
  3437. if (count1 > count2)//102
  3438. pRetArray->Add("0");
  3439. else
  3440. pRetArray->Add("1");
  3441. {
  3442. CRecordset myset(pBeConverted_db);
  3443. sql = "select count(*) as cot from dindanbukuan2 where id='" + strOderNumber + "'";
  3444. myset.Open(CRecordset::forwardOnly, sql);
  3445. myset.GetFieldValue("cot", sql);
  3446. myset.Close();
  3447. count1 = atoi(sql);
  3448. }
  3449. {
  3450. CRecordset myset(pToConverted_db);
  3451. sql = "select count(*) as cot from dindanbukuan2 where id='" + strOderNumber + "'";
  3452. myset.Open(CRecordset::forwardOnly, sql);
  3453. myset.GetFieldValue("cot", sql);
  3454. myset.Close();
  3455. count2 = atoi(sql);
  3456. }
  3457. if (count1 > count2)//103
  3458. pRetArray->Add("0");
  3459. else
  3460. pRetArray->Add("1");
  3461. {
  3462. CRecordset myset(pBeConverted_db);
  3463. sql = "select count(*) as cot from photoprint where id='" + strOderNumber + "'";
  3464. myset.Open(CRecordset::forwardOnly, sql);
  3465. myset.GetFieldValue("cot", sql);
  3466. myset.Close();
  3467. count1 = atoi(sql);
  3468. }
  3469. {
  3470. CRecordset myset(pToConverted_db);
  3471. sql = "select count(*) as cot from photoprint where id='" + strOderNumber + "'";
  3472. myset.Open(CRecordset::forwardOnly, sql);
  3473. myset.GetFieldValue("cot", sql);
  3474. myset.Close();
  3475. count2 = atoi(sql);
  3476. }
  3477. if (count1 > count2)//104
  3478. pRetArray->Add("0");
  3479. else
  3480. pRetArray->Add("1");
  3481. {
  3482. CRecordset myset(pBeConverted_db);
  3483. sql = "select count(*) as cot from client where id='" + strOderNumber + "'";
  3484. myset.Open(CRecordset::forwardOnly, sql);
  3485. myset.GetFieldValue("cot", sql);
  3486. myset.Close();
  3487. count1 = atoi(sql);
  3488. }
  3489. {
  3490. CRecordset myset(pToConverted_db);
  3491. sql = "select count(*) as cot from client where id='" + strOderNumber + "'";
  3492. myset.Open(CRecordset::forwardOnly, sql);
  3493. myset.GetFieldValue("cot", sql);
  3494. myset.Close();
  3495. count2 = atoi(sql);
  3496. }
  3497. if (count1 > count2)//105
  3498. pRetArray->Add("0");
  3499. else
  3500. pRetArray->Add("1");
  3501. {
  3502. CRecordset myset(pBeConverted_db);
  3503. sql = "select count(*) as cot from burncdreg where id='" + strOderNumber + "'";
  3504. myset.Open(CRecordset::forwardOnly, sql);
  3505. myset.GetFieldValue("cot", sql);
  3506. myset.Close();
  3507. count1 = atoi(sql);
  3508. }
  3509. {
  3510. CRecordset myset(pToConverted_db);
  3511. sql = "select count(*) as cot from burncdreg where id='" + strOderNumber + "'";
  3512. myset.Open(CRecordset::forwardOnly, sql);
  3513. myset.GetFieldValue("cot", sql);
  3514. myset.Close();
  3515. count2 = atoi(sql);
  3516. }
  3517. if (count1 > count2)//7
  3518. pRetArray->Add("0");
  3519. else
  3520. pRetArray->Add("1");
  3521. {
  3522. CRecordset myset(pBeConverted_db);
  3523. sql = "select count(*) as cot from digitalwork where id='" + strOderNumber + "'";
  3524. myset.Open(CRecordset::forwardOnly, sql);
  3525. myset.GetFieldValue("cot", sql);
  3526. myset.Close();
  3527. count1 = atoi(sql);
  3528. }
  3529. {
  3530. CRecordset myset(pToConverted_db);
  3531. sql = "select count(*) as cot from digitalwork where id='" + strOderNumber + "'";
  3532. myset.Open(CRecordset::forwardOnly, sql);
  3533. myset.GetFieldValue("cot", sql);
  3534. myset.Close();
  3535. count2 = atoi(sql);
  3536. }
  3537. if (count1 > count2)//8
  3538. pRetArray->Add("0");
  3539. else
  3540. pRetArray->Add("1");
  3541. {
  3542. CRecordset myset(pBeConverted_db);
  3543. sql = "select count(*) as cot from mywork where id='" + strOderNumber + "'";
  3544. myset.Open(CRecordset::forwardOnly, sql);
  3545. myset.GetFieldValue("cot", sql);
  3546. myset.Close();
  3547. count1 = atoi(sql);
  3548. }
  3549. {
  3550. CRecordset myset(pToConverted_db);
  3551. sql = "select count(*) as cot from mywork where id='" + strOderNumber + "'";
  3552. myset.Open(CRecordset::forwardOnly, sql);
  3553. myset.GetFieldValue("cot", sql);
  3554. myset.Close();
  3555. count2 = atoi(sql);
  3556. }
  3557. if (count1 > count2)//9
  3558. pRetArray->Add("0");
  3559. else
  3560. pRetArray->Add("1");
  3561. {
  3562. CRecordset myset(pBeConverted_db);
  3563. sql = "select count(*) as cot from dindanjd where id='" + strOderNumber + "'";
  3564. myset.Open(CRecordset::forwardOnly, sql);
  3565. myset.GetFieldValue("cot", sql);
  3566. myset.Close();
  3567. count1 = atoi(sql);
  3568. }
  3569. {
  3570. CRecordset myset(pToConverted_db);
  3571. sql = "select count(*) as cot from dindanjd where id='" + strOderNumber + "'";
  3572. myset.Open(CRecordset::forwardOnly, sql);
  3573. myset.GetFieldValue("cot", sql);
  3574. myset.Close();
  3575. count2 = atoi(sql);
  3576. }
  3577. if (count1 > count2)//10
  3578. pRetArray->Add("0");
  3579. else
  3580. pRetArray->Add("1");
  3581. {
  3582. CRecordset myset(pBeConverted_db);
  3583. sql = "select count(*) as cot from dindansp2 where id='" + strOderNumber + "'";
  3584. myset.Open(CRecordset::forwardOnly, sql);
  3585. myset.GetFieldValue("cot", sql);
  3586. myset.Close();
  3587. count1 = atoi(sql);
  3588. }
  3589. {
  3590. CRecordset myset(pToConverted_db);
  3591. sql = "select count(*) as cot from dindansp2 where id='" + strOderNumber + "'";
  3592. myset.Open(CRecordset::forwardOnly, sql);
  3593. myset.GetFieldValue("cot", sql);
  3594. myset.Close();
  3595. count2 = atoi(sql);
  3596. }
  3597. if (count1 > count2)
  3598. pRetArray->Add("0");
  3599. else
  3600. pRetArray->Add("1");
  3601. {
  3602. CRecordset myset(pBeConverted_db);
  3603. sql = "select count(*) as cot from dindansp3 where id='" + strOderNumber + "'";
  3604. myset.Open(CRecordset::forwardOnly, sql);
  3605. myset.GetFieldValue("cot", sql);
  3606. myset.Close();
  3607. count1 = atoi(sql);
  3608. }
  3609. {
  3610. CRecordset myset(pToConverted_db);
  3611. sql = "select count(*) as cot from dindansp3 where id='" + strOderNumber + "'";
  3612. myset.Open(CRecordset::forwardOnly, sql);
  3613. myset.GetFieldValue("cot", sql);
  3614. myset.Close();
  3615. count2 = atoi(sql);
  3616. }
  3617. if (count1 > count2)
  3618. pRetArray->Add("0");
  3619. else
  3620. pRetArray->Add("1");
  3621. for (int i = 0; i < pRetArray->GetSize(); i++)
  3622. {
  3623. if (pRetArray->ElementAt(i) == "0")return 100 + i;
  3624. }
  3625. return 1;
  3626. }
  3627. catch (CDBException * e)
  3628. {
  3629. WriteTextLog(e->m_strError);
  3630. WriteTextLog("出错在函数check1中");
  3631. e->Delete();
  3632. }
  3633. return 100;
  3634. }
  3635. BOOL CDBServerDlg::CheckPayOutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  3636. {
  3637. try
  3638. {
  3639. int count1 = 0;
  3640. int count2 = 0;
  3641. CString sql;
  3642. {
  3643. CRecordset myset(pdb1);
  3644. sql.Format("select count(*) as cot from gudingfeiyong where [id]=%d", atol(id));
  3645. myset.Open(CRecordset::forwardOnly, sql);
  3646. myset.GetFieldValue("cot", sql);
  3647. myset.Close();
  3648. count1 = atoi(sql);
  3649. }
  3650. {
  3651. CRecordset myset(pdb2);
  3652. sql = "select count(*) as cot from gudingfeiyong where [id]='" + id + "'";
  3653. myset.Open(CRecordset::forwardOnly, sql);
  3654. myset.GetFieldValue("cot", sql);
  3655. myset.Close();
  3656. count2 = atoi(sql);
  3657. }
  3658. if (count1 > count2)return 0;
  3659. return 1;
  3660. }
  3661. catch (...)
  3662. {
  3663. WriteTextLog("出错在函数check2中");
  3664. }
  3665. return 0;
  3666. }
  3667. BOOL CDBServerDlg::CheckIncomeExist(CDatabase *pdb1, CDatabase *pdb2, CString id, CStringArray *pretarray)
  3668. {
  3669. try
  3670. {
  3671. pretarray->RemoveAll();
  3672. int count1 = 0;
  3673. int count2 = 0;
  3674. CString sql;
  3675. {
  3676. CRecordset myset(pdb1);
  3677. sql.Format("select count(*) as cot from singleincome where [id]=%d", atol(id));
  3678. myset.Open(CRecordset::forwardOnly, sql);
  3679. myset.GetFieldValue("cot", sql);
  3680. myset.Close();
  3681. count1 = atoi(sql);
  3682. }
  3683. {
  3684. CRecordset myset(pdb2);
  3685. sql = "select count(*) as cot from singleincome where [id]='" + id + "'";
  3686. myset.Open(CRecordset::forwardOnly, sql);
  3687. myset.GetFieldValue("cot", sql);
  3688. myset.Close();
  3689. count2 = atoi(sql);
  3690. }
  3691. if (count1 > count2)
  3692. pretarray->Add("0");
  3693. else
  3694. pretarray->Add("1");
  3695. {
  3696. CRecordset myset(pdb1);
  3697. sql.Format("select count(*) as cot from singleincomemoney where [id]='%s'", id);
  3698. myset.Open(CRecordset::forwardOnly, sql);
  3699. myset.GetFieldValue("cot", sql);
  3700. myset.Close();
  3701. count1 = atoi(sql);
  3702. }
  3703. {
  3704. CRecordset myset(pdb2);
  3705. sql.Format("select count(*) as cot from singleincomemoney where [id]='%s'", id);
  3706. myset.Open(CRecordset::forwardOnly, sql);
  3707. myset.GetFieldValue("cot", sql);
  3708. myset.Close();
  3709. count2 = atoi(sql);
  3710. }
  3711. if (count1 > count2)
  3712. pretarray->Add("0");
  3713. else
  3714. pretarray->Add("1");
  3715. for (int i = 0; i < pretarray->GetSize(); i++)
  3716. {
  3717. if (pretarray->ElementAt(i) == "0")return 0;
  3718. }
  3719. return 1;
  3720. }
  3721. catch (...)
  3722. {
  3723. WriteTextLog("出错在函数check3中");
  3724. }
  3725. return 0;
  3726. }
  3727. BOOL CDBServerDlg::CheckIncomeMoneyExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  3728. {
  3729. try
  3730. {
  3731. int count1 = 0;
  3732. int count2 = 0;
  3733. CString sql;
  3734. {
  3735. CRecordset myset(pdb1);
  3736. sql.Format("select count(*) as cot from singleincomemoney where [id]='%s'", id);
  3737. myset.Open(CRecordset::forwardOnly, sql);
  3738. myset.GetFieldValue("cot", sql);
  3739. myset.Close();
  3740. count1 = atoi(sql);
  3741. }
  3742. {
  3743. CRecordset myset(pdb2);
  3744. sql.Format("select count(*) as cot from singleincomemoney where [id]='%s'", id);
  3745. myset.Open(CRecordset::forwardOnly, sql);
  3746. myset.GetFieldValue("cot", sql);
  3747. myset.Close();
  3748. count2 = atoi(sql);
  3749. }
  3750. if (count1 > count2)return 0;
  3751. return 1;
  3752. }
  3753. catch (...)
  3754. {
  3755. WriteTextLog("出错在函数check3中");
  3756. }
  3757. return 0;
  3758. }
  3759. /************************************************************************/
  3760. /* mark by Jeff
  3761. /* 函数:TransDinDan
  3762. /* 描述:
  3763. /* 参数:
  3764. /* pBeConverted_db:被转换的数据库(源);
  3765. /* pToConverted_db:要转到的数据库(目标);
  3766. /* strOrderNumber: 订单号;
  3767. /* nYear: 要转换的年份;
  3768. /*
  3769. /* 返回:
  3770. /************************************************************************/
  3771. int CDBServerDlg::TransDinDan(CDatabase *pBeConverted_db, CDatabase *pToConverted_db, CString strOrderNumber, int nYear)
  3772. {
  3773. int step = 0;
  3774. CStringArray retarray;
  3775. try
  3776. {
  3777. CString sql, str;
  3778. // CheckDinDanExist返回:1表示正常, 100及以上表示源数据库里记录 > 目标数据库记录;
  3779. if (CheckDinDanExist(pBeConverted_db, pToConverted_db, strOrderNumber, &retarray) == 1)
  3780. return 1;
  3781. step = 1;
  3782. CString temp;
  3783. CODBCFieldInfo fieldinfo;
  3784. int ret = 1;
  3785. // 以下全是insert into 到目录数据库中;
  3786. CRecordset myset(pBeConverted_db);
  3787. try
  3788. {
  3789. if (retarray.ElementAt(0) == "0")
  3790. {
  3791. sql.Format("insert into [%d].[dbo].[dindan] select * from [%s].[dbo].[dindan] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  3792. MyExecuteSQL(pBeConverted_db, sql);
  3793. }
  3794. }
  3795. catch (CDBException * e)
  3796. {
  3797. WriteTextLog("step2" + e->m_strError);
  3798. e->Delete();
  3799. ret = 2;
  3800. }
  3801. step = 2;
  3802. try
  3803. {
  3804. if (retarray.ElementAt(1) == "0")
  3805. {
  3806. sql.Format("insert into [%d].[dbo].[dindansp] select * from [%s].[dbo].[dindansp] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  3807. MyExecuteSQL(pBeConverted_db, sql);
  3808. }
  3809. }
  3810. catch (CDBException * e)
  3811. {
  3812. WriteTextLog("step3" + e->m_strError);
  3813. e->Delete();
  3814. ret = 3;
  3815. }
  3816. step = 3;
  3817. try
  3818. {
  3819. if (retarray.ElementAt(2) == "0")
  3820. {
  3821. sql.Format("insert into [%d].[dbo].[dindanbukuan] ([autoid],[id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck]) select [autoid],[id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck] from [%s].[dbo].[dindanbukuan] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  3822. MyExecuteSQL(pBeConverted_db, sql);
  3823. }
  3824. }
  3825. catch (CDBException * e)
  3826. {
  3827. WriteTextLog("step4" + e->m_strError);
  3828. e->Delete();
  3829. ret = 4;
  3830. }
  3831. step = 4;
  3832. try
  3833. {
  3834. if (retarray.ElementAt(3) == "0")
  3835. {
  3836. sql.Format("insert into [%d].[dbo].[dindanbukuan2] ([autoid],[id],[money],[ren],[date],[bz],[kind],[ren2]) select [autoid],[id],[money],[ren],[date],[bz],[kind],[ren2] from [%s].[dbo].[dindanbukuan2] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  3837. MyExecuteSQL(pBeConverted_db, sql);
  3838. }
  3839. }
  3840. catch (CDBException * e)
  3841. {
  3842. WriteTextLog("step5" + e->m_strError);
  3843. e->Delete();
  3844. ret = 5;
  3845. }
  3846. step = 5;
  3847. try
  3848. {
  3849. if (retarray.ElementAt(4) == "0")
  3850. {
  3851. sql.Format("insert into [%d].[dbo].[photoprint] select * from [%s].[dbo].[photoprint] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  3852. MyExecuteSQL(pBeConverted_db, sql);
  3853. }
  3854. }
  3855. catch (CDBException * e)
  3856. {
  3857. WriteTextLog("step6" + e->m_strError);
  3858. e->Delete();
  3859. ret = 6;
  3860. }
  3861. step = 6;
  3862. try
  3863. {
  3864. if (retarray.ElementAt(5) == "0")
  3865. {
  3866. sql.Format("insert into [%d].[dbo].[client] select * from [%s].[dbo].[client] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  3867. MyExecuteSQL(pBeConverted_db, sql);
  3868. }
  3869. }
  3870. catch (CDBException * e)
  3871. {
  3872. WriteTextLog("step7" + e->m_strError);
  3873. e->Delete();
  3874. ret = 7;
  3875. }
  3876. step = 7;
  3877. try
  3878. {
  3879. if (retarray.ElementAt(6) == "0")
  3880. {
  3881. sql.Format("insert into [%d].[dbo].[burncdreg] select * from [%s].[dbo].[burncdreg] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  3882. MyExecuteSQL(pBeConverted_db, sql);
  3883. }
  3884. }
  3885. catch (CDBException * e)
  3886. {
  3887. WriteTextLog("step8" + e->m_strError);
  3888. e->Delete();
  3889. ret = 8;
  3890. }
  3891. step = 8;
  3892. try
  3893. {
  3894. if (retarray.ElementAt(7) == "0")
  3895. {
  3896. sql.Format("insert into [%d].[dbo].[digitalwork] select * from [%s].[dbo].[digitalwork] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  3897. MyExecuteSQL(pBeConverted_db, sql);
  3898. }
  3899. }
  3900. catch (CDBException * e)
  3901. {
  3902. WriteTextLog("step9" + e->m_strError);
  3903. e->Delete();
  3904. ret = 9;
  3905. }
  3906. step = 9;
  3907. try
  3908. {
  3909. if (retarray.ElementAt(8) == "0")
  3910. {
  3911. sql.Format("insert into [%d].[dbo].[mywork] select * from [%s].[dbo].[mywork] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  3912. MyExecuteSQL(pBeConverted_db, sql);
  3913. }
  3914. }
  3915. catch (CDBException * e)
  3916. {
  3917. WriteTextLog("step10" + e->m_strError);
  3918. e->Delete();
  3919. ret = 10;
  3920. }
  3921. step = 10;
  3922. try
  3923. {
  3924. if (retarray.ElementAt(9) == "0")
  3925. {
  3926. sql.Format("insert into [%d].[dbo].[dindanjd] select * from [%s].[dbo].[dindanjd] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  3927. MyExecuteSQL(pBeConverted_db, sql);
  3928. }
  3929. }
  3930. catch (CDBException * e)
  3931. {
  3932. WriteTextLog("step11" + e->m_strError);
  3933. e->Delete();
  3934. ret = 11;
  3935. }
  3936. step = 11;
  3937. try
  3938. {
  3939. if (retarray.ElementAt(10) == "0")
  3940. {
  3941. sql.Format("insert into [%d].[dbo].[dindansp2] select * from [%s].[dbo].[dindansp2] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  3942. MyExecuteSQL(pBeConverted_db, sql);
  3943. }
  3944. }
  3945. catch (CDBException * e)
  3946. {
  3947. WriteTextLog("step12" + e->m_strError);
  3948. e->Delete();
  3949. ret = 12;
  3950. }
  3951. step = 12;
  3952. try
  3953. {
  3954. if (retarray.ElementAt(11) == "0")
  3955. {
  3956. sql.Format("insert into [%d].[dbo].[dindansp3] select * from [%s].[dbo].[dindansp3] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  3957. MyExecuteSQL(pBeConverted_db, sql);
  3958. }
  3959. }
  3960. catch (CDBException * e)
  3961. {
  3962. WriteTextLog("step13" + e->m_strError);
  3963. e->Delete();
  3964. ret = 13;
  3965. }
  3966. if (ret != 1)return 200 + ret;
  3967. // 插入到目标数据库后再到目标数据库里查询是否存在;
  3968. return CheckDinDanExist(pBeConverted_db, pToConverted_db, strOrderNumber, &retarray);
  3969. }
  3970. catch (...)
  3971. {
  3972. CString str;
  3973. str.Format("%d size:%d", step, retarray.GetSize());
  3974. WriteTextLog("出错在函数trans1中-" + str);
  3975. }
  3976. return 0;
  3977. }
  3978. BOOL CDBServerDlg::TransPayOut(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3979. {
  3980. try
  3981. {
  3982. CString sql;
  3983. if (CheckPayOutExist(pdb1, pdb2, id))return 1;
  3984. CString temp;
  3985. CODBCFieldInfo fieldinfo;
  3986. BOOL ret = 1;
  3987. CRecordset myset(pdb1);
  3988. try
  3989. {
  3990. sql.Format("insert into [%d].[dbo].[gudingfeiyong] select * from [%s].[dbo].[gudingfeiyong] where id=%d", year, g_nCurConvertDBName, atol(id));
  3991. MyExecuteSQL(pdb1, sql);
  3992. }
  3993. catch (CDBException * e)
  3994. {
  3995. WriteTextLog(e->m_strError);
  3996. e->Delete();
  3997. ret = 0;
  3998. }
  3999. if (ret == 0)return 0;
  4000. return CheckPayOutExist(pdb1, pdb2, id);
  4001. }
  4002. catch (...)
  4003. {
  4004. WriteTextLog("出错在函数trans2中");
  4005. }
  4006. return 0;
  4007. }
  4008. //singleincome
  4009. BOOL CDBServerDlg::TransIncome(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  4010. {
  4011. try
  4012. {
  4013. CString sql;
  4014. CStringArray retarray;
  4015. if (CheckIncomeExist(pdb1, pdb2, id, &retarray))return 1;
  4016. CString temp;
  4017. CODBCFieldInfo fieldinfo;
  4018. BOOL ret = 1;
  4019. CRecordset myset(pdb1);
  4020. try
  4021. {
  4022. if (retarray.ElementAt(0) == "0")
  4023. {
  4024. sql.Format("insert into [%d].[dbo].[singleincome] select * from [%s].[dbo].[singleincome] where id=%d", year, g_nCurConvertDBName, atol(id));
  4025. MyExecuteSQL(pdb1, sql);
  4026. }
  4027. }
  4028. catch (...)
  4029. {
  4030. ret = 0;
  4031. }
  4032. try
  4033. {
  4034. if (retarray.ElementAt(1) == "0")
  4035. {
  4036. sql.Format("insert into [%d].[dbo].[singleincomemoney] select * from [%s].[dbo].[singleincomemoney] where id='%s'", year, g_nCurConvertDBName, id);
  4037. MyExecuteSQL(pdb1, sql);
  4038. }
  4039. }
  4040. catch (CDBException * e)
  4041. {
  4042. WriteTextLog(e->m_strError);
  4043. e->Delete();
  4044. ret = 0;
  4045. }
  4046. if (ret == 0)return 0;
  4047. return CheckIncomeExist(pdb1, pdb2, id, &retarray);
  4048. }
  4049. catch (...)
  4050. {
  4051. WriteTextLog("出错在函数trans3中");
  4052. }
  4053. return 0;
  4054. }
  4055. BOOL CDBServerDlg::TransIncomeMoney(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  4056. {
  4057. try
  4058. {
  4059. CString sql;
  4060. if (CheckIncomeMoneyExist(pdb1, pdb2, id))return 1;
  4061. CString temp;
  4062. CODBCFieldInfo fieldinfo;
  4063. BOOL ret = 1;
  4064. CRecordset myset(pdb1);
  4065. try
  4066. {
  4067. sql.Format("insert into [%d].[dbo].[singleincomemoney] select * from [%s].[dbo].[singleincomemoney] where id='%s'", year, g_nCurConvertDBName, id);
  4068. MyExecuteSQL(pdb1, sql);
  4069. }
  4070. catch (CDBException * e)
  4071. {
  4072. WriteTextLog(e->m_strError);
  4073. e->Delete();
  4074. ret = 0;
  4075. }
  4076. if (ret == 0)return 0;
  4077. return CheckIncomeMoneyExist(pdb1, pdb2, id);
  4078. }
  4079. catch (...)
  4080. {
  4081. WriteTextLog("出错在函数trans3中");
  4082. }
  4083. return 0;
  4084. }
  4085. BOOL CDBServerDlg::Checkclient2phonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  4086. {
  4087. try
  4088. {
  4089. int count1 = 0;
  4090. int count2 = 0;
  4091. CString sql;
  4092. {
  4093. CRecordset myset(pdb1);
  4094. sql = "select count(*) as cot from client2phonerecord where [datetime]='" + id + "'";
  4095. myset.Open(CRecordset::forwardOnly, sql);
  4096. myset.GetFieldValue("cot", sql);
  4097. myset.Close();
  4098. count1 = atoi(sql);
  4099. }
  4100. {
  4101. CRecordset myset(pdb2);
  4102. sql = "select count(*) as cot from client2phonerecord where [datetime]='" + id + "'";
  4103. myset.Open(CRecordset::forwardOnly, sql);
  4104. myset.GetFieldValue("cot", sql);
  4105. myset.Close();
  4106. count2 = atoi(sql);
  4107. }
  4108. if (count1 > count2)return 0;
  4109. return 1;
  4110. }
  4111. catch (...)
  4112. {
  4113. WriteTextLog("出错在函数check3中");
  4114. }
  4115. return 0;
  4116. }
  4117. BOOL CDBServerDlg::Transclient2phonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  4118. {
  4119. try
  4120. {
  4121. CString sql;
  4122. if (Checkclient2phonerecordExist(pdb1, pdb2, id))return 1;
  4123. CString temp;
  4124. CODBCFieldInfo fieldinfo;
  4125. BOOL ret = 1;
  4126. CRecordset myset(pdb1);
  4127. try
  4128. {
  4129. sql.Format("insert into [%d].[dbo].[client2phonerecord] select * from [%s].[dbo].[client2phonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  4130. MyExecuteSQL(pdb1, sql);
  4131. }
  4132. catch (...)
  4133. {
  4134. ret = 0;
  4135. }
  4136. if (ret == 0)return 0;
  4137. return Checkclient2phonerecordExist(pdb1, pdb2, id);
  4138. }
  4139. catch (...)
  4140. {
  4141. WriteTextLog("出错在函数trans3中");
  4142. }
  4143. return 0;
  4144. }
  4145. BOOL CDBServerDlg::Checkclient3phonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  4146. {
  4147. try
  4148. {
  4149. int count1 = 0;
  4150. int count2 = 0;
  4151. CString sql;
  4152. {
  4153. CRecordset myset(pdb1);
  4154. sql = "select count(*) as cot from client3phonerecord where [datetime]='" + id + "'";
  4155. myset.Open(CRecordset::forwardOnly, sql);
  4156. myset.GetFieldValue("cot", sql);
  4157. myset.Close();
  4158. count1 = atoi(sql);
  4159. }
  4160. {
  4161. CRecordset myset(pdb2);
  4162. sql = "select count(*) as cot from client3phonerecord where [datetime]='" + id + "'";
  4163. myset.Open(CRecordset::forwardOnly, sql);
  4164. myset.GetFieldValue("cot", sql);
  4165. myset.Close();
  4166. count2 = atoi(sql);
  4167. }
  4168. if (count1 > count2)return 0;
  4169. return 1;
  4170. }
  4171. catch (...)
  4172. {
  4173. WriteTextLog("出错在函数check3中");
  4174. }
  4175. return 0;
  4176. }
  4177. BOOL CDBServerDlg::Transclient3phonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  4178. {
  4179. try
  4180. {
  4181. CString sql;
  4182. if (Checkclient3phonerecordExist(pdb1, pdb2, id))return 1;
  4183. CString temp;
  4184. CODBCFieldInfo fieldinfo;
  4185. BOOL ret = 1;
  4186. CRecordset myset(pdb1);
  4187. try
  4188. {
  4189. sql.Format("insert into [%d].[dbo].[client3phonerecord] select * from [%s].[dbo].[client3phonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  4190. MyExecuteSQL(pdb1, sql);
  4191. }
  4192. catch (...)
  4193. {
  4194. ret = 0;
  4195. }
  4196. if (ret == 0)return 0;
  4197. return Checkclient3phonerecordExist(pdb1, pdb2, id);
  4198. }
  4199. catch (...)
  4200. {
  4201. WriteTextLog("出错在函数trans3中");
  4202. }
  4203. return 0;
  4204. }
  4205. BOOL CDBServerDlg::Checkclient2phonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  4206. {
  4207. try
  4208. {
  4209. int count1 = 0;
  4210. int count2 = 0;
  4211. CString sql;
  4212. {
  4213. CRecordset myset(pdb1);
  4214. sql = "select count(*) as cot from client2phonerecordout where [datetime]='" + id + "'";
  4215. myset.Open(CRecordset::forwardOnly, sql);
  4216. myset.GetFieldValue("cot", sql);
  4217. myset.Close();
  4218. count1 = atoi(sql);
  4219. }
  4220. {
  4221. CRecordset myset(pdb2);
  4222. sql = "select count(*) as cot from client2phonerecordout where [datetime]='" + id + "'";
  4223. myset.Open(CRecordset::forwardOnly, sql);
  4224. myset.GetFieldValue("cot", sql);
  4225. myset.Close();
  4226. count2 = atoi(sql);
  4227. }
  4228. if (count1 > count2)return 0;
  4229. return 1;
  4230. }
  4231. catch (...)
  4232. {
  4233. WriteTextLog("出错在函数check3中");
  4234. }
  4235. return 0;
  4236. }
  4237. BOOL CDBServerDlg::Transclient2phonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  4238. {
  4239. try
  4240. {
  4241. CString sql;
  4242. if (Checkclient2phonerecordoutExist(pdb1, pdb2, id))return 1;
  4243. CString temp;
  4244. CODBCFieldInfo fieldinfo;
  4245. BOOL ret = 1;
  4246. CRecordset myset(pdb1);
  4247. try
  4248. {
  4249. sql.Format("insert into [%d].[dbo].[client2phonerecordout] select * from [%s].[dbo].[client2phonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  4250. MyExecuteSQL(pdb1, sql);
  4251. }
  4252. catch (...)
  4253. {
  4254. ret = 0;
  4255. }
  4256. if (ret == 0)return 0;
  4257. return Checkclient2phonerecordoutExist(pdb1, pdb2, id);
  4258. }
  4259. catch (...)
  4260. {
  4261. WriteTextLog("出错在函数trans3中");
  4262. }
  4263. return 0;
  4264. }
  4265. BOOL CDBServerDlg::Checkclient3phonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  4266. {
  4267. try
  4268. {
  4269. int count1 = 0;
  4270. int count2 = 0;
  4271. CString sql;
  4272. {
  4273. CRecordset myset(pdb1);
  4274. sql = "select count(*) as cot from client3phonerecordout where [datetime]='" + id + "'";
  4275. myset.Open(CRecordset::forwardOnly, sql);
  4276. myset.GetFieldValue("cot", sql);
  4277. myset.Close();
  4278. count1 = atoi(sql);
  4279. }
  4280. {
  4281. CRecordset myset(pdb2);
  4282. sql = "select count(*) as cot from client3phonerecordout where [datetime]='" + id + "'";
  4283. myset.Open(CRecordset::forwardOnly, sql);
  4284. myset.GetFieldValue("cot", sql);
  4285. myset.Close();
  4286. count2 = atoi(sql);
  4287. }
  4288. if (count1 > count2)return 0;
  4289. return 1;
  4290. }
  4291. catch (...)
  4292. {
  4293. WriteTextLog("出错在函数check3中");
  4294. }
  4295. return 0;
  4296. }
  4297. BOOL CDBServerDlg::Transclient3phonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  4298. {
  4299. try
  4300. {
  4301. CString sql;
  4302. if (Checkclient3phonerecordoutExist(pdb1, pdb2, id))return 1;
  4303. CString temp;
  4304. CODBCFieldInfo fieldinfo;
  4305. BOOL ret = 1;
  4306. CRecordset myset(pdb1);
  4307. try
  4308. {
  4309. sql.Format("insert into [%d].[dbo].[client3phonerecordout] select * from [%s].[dbo].[client3phonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  4310. MyExecuteSQL(pdb1, sql);
  4311. }
  4312. catch (...)
  4313. {
  4314. ret = 0;
  4315. }
  4316. if (ret == 0)return 0;
  4317. return Checkclient3phonerecordoutExist(pdb1, pdb2, id);
  4318. }
  4319. catch (...)
  4320. {
  4321. WriteTextLog("出错在函数trans3中");
  4322. }
  4323. return 0;
  4324. }
  4325. BOOL CDBServerDlg::CheckemployeephonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  4326. {
  4327. try
  4328. {
  4329. int count1 = 0;
  4330. int count2 = 0;
  4331. CString sql;
  4332. {
  4333. CRecordset myset(pdb1);
  4334. sql = "select count(*) as cot from employeephonerecord where [datetime]='" + id + "'";
  4335. myset.Open(CRecordset::forwardOnly, sql);
  4336. myset.GetFieldValue("cot", sql);
  4337. myset.Close();
  4338. count1 = atoi(sql);
  4339. }
  4340. {
  4341. CRecordset myset(pdb2);
  4342. sql = "select count(*) as cot from employeephonerecord where [datetime]='" + id + "'";
  4343. myset.Open(CRecordset::forwardOnly, sql);
  4344. myset.GetFieldValue("cot", sql);
  4345. myset.Close();
  4346. count2 = atoi(sql);
  4347. }
  4348. if (count1 > count2)return 0;
  4349. return 1;
  4350. }
  4351. catch (...)
  4352. {
  4353. WriteTextLog("出错在函数check3中");
  4354. }
  4355. return 0;
  4356. }
  4357. BOOL CDBServerDlg::Transemployeephonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  4358. {
  4359. try
  4360. {
  4361. CString sql;
  4362. if (CheckemployeephonerecordExist(pdb1, pdb2, id))return 1;
  4363. CString temp;
  4364. CODBCFieldInfo fieldinfo;
  4365. BOOL ret = 1;
  4366. CRecordset myset(pdb1);
  4367. try
  4368. {
  4369. sql.Format("insert into [%d].[dbo].[employeephonerecord] select * from [%s].[dbo].[employeephonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  4370. MyExecuteSQL(pdb1, sql);
  4371. }
  4372. catch (...)
  4373. {
  4374. ret = 0;
  4375. }
  4376. if (ret == 0)return 0;
  4377. return CheckemployeephonerecordExist(pdb1, pdb2, id);
  4378. }
  4379. catch (...)
  4380. {
  4381. WriteTextLog("出错在函数trans3中");
  4382. }
  4383. return 0;
  4384. }
  4385. BOOL CDBServerDlg::CheckemployeephonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  4386. {
  4387. try
  4388. {
  4389. int count1 = 0;
  4390. int count2 = 0;
  4391. CString sql;
  4392. {
  4393. CRecordset myset(pdb1);
  4394. sql = "select count(*) as cot from employeephonerecordout where [datetime]='" + id + "'";
  4395. myset.Open(CRecordset::forwardOnly, sql);
  4396. myset.GetFieldValue("cot", sql);
  4397. myset.Close();
  4398. count1 = atoi(sql);
  4399. }
  4400. {
  4401. CRecordset myset(pdb2);
  4402. sql = "select count(*) as cot from employeephonerecordout where [datetime]='" + id + "'";
  4403. myset.Open(CRecordset::forwardOnly, sql);
  4404. myset.GetFieldValue("cot", sql);
  4405. myset.Close();
  4406. count2 = atoi(sql);
  4407. }
  4408. if (count1 > count2)return 0;
  4409. return 1;
  4410. }
  4411. catch (...)
  4412. {
  4413. WriteTextLog("出错在函数check3中");
  4414. }
  4415. return 0;
  4416. }
  4417. BOOL CDBServerDlg::Transemployeephonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  4418. {
  4419. try
  4420. {
  4421. CString sql;
  4422. if (CheckemployeephonerecordoutExist(pdb1, pdb2, id))return 1;
  4423. CString temp;
  4424. CODBCFieldInfo fieldinfo;
  4425. BOOL ret = 1;
  4426. CRecordset myset(pdb1);
  4427. try
  4428. {
  4429. sql.Format("insert into [%d].[dbo].[employeephonerecordout] select * from [%s].[dbo].[employeephonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  4430. MyExecuteSQL(pdb1, sql);
  4431. }
  4432. catch (...)
  4433. {
  4434. ret = 0;
  4435. }
  4436. if (ret == 0)return 0;
  4437. return CheckemployeephonerecordoutExist(pdb1, pdb2, id);
  4438. }
  4439. catch (...)
  4440. {
  4441. WriteTextLog("出错在函数trans3中");
  4442. }
  4443. return 0;
  4444. }
  4445. BOOL CDBServerDlg::CheckphonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  4446. {
  4447. try
  4448. {
  4449. int count1 = 0;
  4450. int count2 = 0;
  4451. CString sql;
  4452. {
  4453. CRecordset myset(pdb1);
  4454. sql = "select count(*) as cot from phonerecord where [datetime]='" + id + "'";
  4455. myset.Open(CRecordset::forwardOnly, sql);
  4456. myset.GetFieldValue("cot", sql);
  4457. myset.Close();
  4458. count1 = atoi(sql);
  4459. }
  4460. {
  4461. CRecordset myset(pdb2);
  4462. sql = "select count(*) as cot from phonerecord where [datetime]='" + id + "'";
  4463. myset.Open(CRecordset::forwardOnly, sql);
  4464. myset.GetFieldValue("cot", sql);
  4465. myset.Close();
  4466. count2 = atoi(sql);
  4467. }
  4468. if (count1 > count2)return 0;
  4469. return 1;
  4470. }
  4471. catch (...)
  4472. {
  4473. WriteTextLog("出错在函数check3中");
  4474. }
  4475. return 0;
  4476. }
  4477. BOOL CDBServerDlg::Transphonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  4478. {
  4479. try
  4480. {
  4481. CString sql;
  4482. if (CheckphonerecordExist(pdb1, pdb2, id))return 1;
  4483. CString temp;
  4484. CODBCFieldInfo fieldinfo;
  4485. BOOL ret = 1;
  4486. CRecordset myset(pdb1);
  4487. try
  4488. {
  4489. sql.Format("insert into [%d].[dbo].[phonerecord] select * from [%s].[dbo].[phonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  4490. MyExecuteSQL(pdb1, sql);
  4491. }
  4492. catch (...)
  4493. {
  4494. ret = 0;
  4495. }
  4496. if (ret == 0)return 0;
  4497. return CheckphonerecordExist(pdb1, pdb2, id);
  4498. }
  4499. catch (...)
  4500. {
  4501. WriteTextLog("出错在函数trans3中");
  4502. }
  4503. return 0;
  4504. }
  4505. BOOL CDBServerDlg::CheckphonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  4506. {
  4507. try
  4508. {
  4509. int count1 = 0;
  4510. int count2 = 0;
  4511. CString sql;
  4512. {
  4513. CRecordset myset(pdb1);
  4514. sql = "select count(*) as cot from phonerecordout where [datetime]='" + id + "'";
  4515. myset.Open(CRecordset::forwardOnly, sql);
  4516. myset.GetFieldValue("cot", sql);
  4517. myset.Close();
  4518. count1 = atoi(sql);
  4519. }
  4520. {
  4521. CRecordset myset(pdb2);
  4522. sql = "select count(*) as cot from phonerecordout where [datetime]='" + id + "'";
  4523. myset.Open(CRecordset::forwardOnly, sql);
  4524. myset.GetFieldValue("cot", sql);
  4525. myset.Close();
  4526. count2 = atoi(sql);
  4527. }
  4528. if (count1 > count2)return 0;
  4529. return 1;
  4530. }
  4531. catch (...)
  4532. {
  4533. WriteTextLog("出错在函数check3中");
  4534. }
  4535. return 0;
  4536. }
  4537. BOOL CDBServerDlg::Transphonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  4538. {
  4539. try
  4540. {
  4541. CString sql;
  4542. if (CheckphonerecordoutExist(pdb1, pdb2, id))return 1;
  4543. CString temp;
  4544. CODBCFieldInfo fieldinfo;
  4545. BOOL ret = 1;
  4546. CRecordset myset(pdb1);
  4547. try
  4548. {
  4549. sql.Format("insert into [%d].[dbo].[phonerecordout] select * from [%s].[dbo].[phonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  4550. MyExecuteSQL(pdb1, sql);
  4551. }
  4552. catch (...)
  4553. {
  4554. ret = 0;
  4555. }
  4556. if (ret == 0)return 0;
  4557. return CheckphonerecordoutExist(pdb1, pdb2, id);
  4558. }
  4559. catch (...)
  4560. {
  4561. WriteTextLog("出错在函数trans3中");
  4562. }
  4563. return 0;
  4564. }
  4565. BOOL CDBServerDlg::CheckunknownphonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  4566. {
  4567. try
  4568. {
  4569. int count1 = 0;
  4570. int count2 = 0;
  4571. CString sql;
  4572. {
  4573. CRecordset myset(pdb1);
  4574. sql = "select count(*) as cot from unknownphonerecord where [datetime]='" + id + "'";
  4575. myset.Open(CRecordset::forwardOnly, sql);
  4576. myset.GetFieldValue("cot", sql);
  4577. myset.Close();
  4578. count1 = atoi(sql);
  4579. }
  4580. {
  4581. CRecordset myset(pdb2);
  4582. sql = "select count(*) as cot from unknownphonerecord where [datetime]='" + id + "'";
  4583. myset.Open(CRecordset::forwardOnly, sql);
  4584. myset.GetFieldValue("cot", sql);
  4585. myset.Close();
  4586. count2 = atoi(sql);
  4587. }
  4588. if (count1 > count2)return 0;
  4589. return 1;
  4590. }
  4591. catch (...)
  4592. {
  4593. WriteTextLog("出错在函数check3中");
  4594. }
  4595. return 0;
  4596. }
  4597. BOOL CDBServerDlg::Transunknownphonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  4598. {
  4599. try
  4600. {
  4601. CString sql;
  4602. if (CheckunknownphonerecordExist(pdb1, pdb2, id))return 1;
  4603. CString temp;
  4604. CODBCFieldInfo fieldinfo;
  4605. BOOL ret = 1;
  4606. CRecordset myset(pdb1);
  4607. try
  4608. {
  4609. sql.Format("insert into [%d].[dbo].[unknownphonerecord] select * from [%s].[dbo].[unknownphonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  4610. MyExecuteSQL(pdb1, sql);
  4611. }
  4612. catch (...)
  4613. {
  4614. ret = 0;
  4615. }
  4616. if (ret == 0)return 0;
  4617. return CheckunknownphonerecordExist(pdb1, pdb2, id);
  4618. }
  4619. catch (...)
  4620. {
  4621. WriteTextLog("出错在函数trans3中");
  4622. }
  4623. return 0;
  4624. }
  4625. BOOL CDBServerDlg::CheckunknownphonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  4626. {
  4627. try
  4628. {
  4629. int count1 = 0;
  4630. int count2 = 0;
  4631. CString sql;
  4632. {
  4633. CRecordset myset(pdb1);
  4634. sql = "select count(*) as cot from unknownphonerecordout where [datetime]='" + id + "'";
  4635. myset.Open(CRecordset::forwardOnly, sql);
  4636. myset.GetFieldValue("cot", sql);
  4637. myset.Close();
  4638. count1 = atoi(sql);
  4639. }
  4640. {
  4641. CRecordset myset(pdb2);
  4642. sql = "select count(*) as cot from unknownphonerecordout where [datetime]='" + id + "'";
  4643. myset.Open(CRecordset::forwardOnly, sql);
  4644. myset.GetFieldValue("cot", sql);
  4645. myset.Close();
  4646. count2 = atoi(sql);
  4647. }
  4648. if (count1 > count2)return 0;
  4649. return 1;
  4650. }
  4651. catch (...)
  4652. {
  4653. WriteTextLog("出错在函数check3中");
  4654. }
  4655. return 0;
  4656. }
  4657. BOOL CDBServerDlg::Transunknownphonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  4658. {
  4659. try
  4660. {
  4661. CString sql;
  4662. if (CheckunknownphonerecordoutExist(pdb1, pdb2, id))return 1;
  4663. CString temp;
  4664. CODBCFieldInfo fieldinfo;
  4665. BOOL ret = 1;
  4666. CRecordset myset(pdb1);
  4667. try
  4668. {
  4669. sql.Format("insert into [%d].[dbo].[unknownphonerecordout] select * from [%s].[dbo].[unknownphonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  4670. MyExecuteSQL(pdb1, sql);
  4671. }
  4672. catch (...)
  4673. {
  4674. ret = 0;
  4675. }
  4676. if (ret == 0)return 0;
  4677. return CheckunknownphonerecordoutExist(pdb1, pdb2, id);
  4678. }
  4679. catch (...)
  4680. {
  4681. WriteTextLog("出错在函数trans3中");
  4682. }
  4683. return 0;
  4684. }
  4685. BOOL CDBServerDlg::CheckmisscallrecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  4686. {
  4687. try
  4688. {
  4689. int count1 = 0;
  4690. int count2 = 0;
  4691. CString sql;
  4692. {
  4693. CRecordset myset(pdb1);
  4694. sql = "select count(*) as cot from misscallrecord where [datetime]='" + id + "'";
  4695. myset.Open(CRecordset::forwardOnly, sql);
  4696. myset.GetFieldValue("cot", sql);
  4697. myset.Close();
  4698. count1 = atoi(sql);
  4699. }
  4700. {
  4701. CRecordset myset(pdb2);
  4702. sql = "select count(*) as cot from misscallrecord where [datetime]='" + id + "'";
  4703. myset.Open(CRecordset::forwardOnly, sql);
  4704. myset.GetFieldValue("cot", sql);
  4705. myset.Close();
  4706. count2 = atoi(sql);
  4707. }
  4708. if (count1 > count2)return 0;
  4709. return 1;
  4710. }
  4711. catch (...)
  4712. {
  4713. WriteTextLog("出错在函数check3中");
  4714. }
  4715. return 0;
  4716. }
  4717. BOOL CDBServerDlg::Transmisscallrecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  4718. {
  4719. try
  4720. {
  4721. CString sql;
  4722. if (CheckmisscallrecordExist(pdb1, pdb2, id))return 1;
  4723. CString temp;
  4724. CODBCFieldInfo fieldinfo;
  4725. BOOL ret = 1;
  4726. CRecordset myset(pdb1);
  4727. try
  4728. {
  4729. sql.Format("insert into [%d].[dbo].[misscallrecord] select * from [%s].[dbo].[misscallrecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  4730. MyExecuteSQL(pdb1, sql);
  4731. }
  4732. catch (...)
  4733. {
  4734. ret = 0;
  4735. }
  4736. if (ret == 0)return 0;
  4737. return CheckmisscallrecordExist(pdb1, pdb2, id);
  4738. }
  4739. catch (...)
  4740. {
  4741. WriteTextLog("出错在函数trans3中");
  4742. }
  4743. return 0;
  4744. }
  4745. BOOL CDBServerDlg::CheckSendReg(CDatabase *pdb1, CDatabase *pdb2, CString id)
  4746. {
  4747. try
  4748. {
  4749. int count1 = 0;
  4750. int count2 = 0;
  4751. CString sql;
  4752. {
  4753. CRecordset myset(pdb1);
  4754. sql.Format("select count(*) as cot from sendreg where [timestamp]='%s'", id);
  4755. myset.Open(CRecordset::forwardOnly, sql);
  4756. myset.GetFieldValue("cot", sql);
  4757. myset.Close();
  4758. count1 = atoi(sql);
  4759. }
  4760. {
  4761. CRecordset myset(pdb2);
  4762. sql.Format("select count(*) as cot from sendreg where [timestamp]='%s'", id);
  4763. myset.Open(CRecordset::forwardOnly, sql);
  4764. myset.GetFieldValue("cot", sql);
  4765. myset.Close();
  4766. count2 = atoi(sql);
  4767. }
  4768. if (count1 > count2)return 0;
  4769. return 1;
  4770. }
  4771. catch (...)
  4772. {
  4773. WriteTextLog("出错在函数check3中");
  4774. }
  4775. return 0;
  4776. }
  4777. BOOL CDBServerDlg::TransSendReg(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  4778. {
  4779. try
  4780. {
  4781. CString sql;
  4782. if (CheckSendReg(pdb1, pdb2, id))return 1;
  4783. CString temp;
  4784. CODBCFieldInfo fieldinfo;
  4785. BOOL ret = 1;
  4786. CRecordset myset(pdb1);
  4787. try
  4788. {
  4789. sql.Format("insert into [%d].[dbo].[sendreg] select * from [%s].[dbo].[sendreg] where [timestamp]='%s'", year, g_nCurConvertDBName, id);
  4790. MyExecuteSQL(pdb1, sql);
  4791. }
  4792. catch (...)
  4793. {
  4794. ret = 0;
  4795. }
  4796. if (ret == 0)return 0;
  4797. return CheckSendReg(pdb1, pdb2, id);
  4798. }
  4799. catch (...)
  4800. {
  4801. WriteTextLog("出错在函数trans3中");
  4802. }
  4803. return 0;
  4804. }
  4805. void CDBServerDlg::MyExecuteSQL(CDatabase* pdb, CString sql)
  4806. {
  4807. try
  4808. {
  4809. MyLock lock("dbaccessxiao");
  4810. pdb->ExecuteSQL(sql);
  4811. }
  4812. catch (...)
  4813. {
  4814. // WriteTextLog("出错在函数executesql中");
  4815. }
  4816. }
  4817. void CDBServerDlg::UpdateDate()
  4818. {
  4819. try
  4820. {
  4821. /* CString tm,sql;
  4822. tm=CTime::GetCurrentTime ().Format ("%Y-%m-%d");
  4823. sql.Format ("update version set curdate='%s'",tm);
  4824. MyExecuteSQL(&g_db, sql);
  4825. */
  4826. /* CTime tm2=CTime::GetCurrentTime ();
  4827. CTimeSpan dt2(365, 0, 0, 0);
  4828. tm2-=dt2;
  4829. tm=tm2.Format ("%Y%m%d%H%M%S");
  4830. sql.Format ("delete from sendreg where timestamp<'%s'",tm);
  4831. MyExecuteSQL(&g_db, sql);*/
  4832. HWND hwnd = ::FindWindow(NULL, "AutoRun.exe - 应用程序错误");
  4833. if (hwnd)
  4834. {
  4835. HWND child = ::FindWindowEx(hwnd, 0, NULL, "确定");
  4836. CWnd *pWnd = CWnd::FromHandle(child);
  4837. ::PostMessage(hwnd, WM_COMMAND, pWnd->GetDlgCtrlID(), (LPARAM)child);
  4838. }
  4839. CString autorunpath = g_mainpath + "\\AutoRun.exe";
  4840. if (0 == g_bConvertHisAll)
  4841. ShellExecute(NULL, _T("open"), g_mainpath + "\\AutoRun.exe", NULL, NULL, SW_HIDE);
  4842. autorunpath = g_mainpath + "\\MsgServer.exe";
  4843. ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
  4844. #ifdef ENTERPRISE_VERSION
  4845. autorunpath = g_mainpath + "\\DataSyncReceive.exe";
  4846. ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
  4847. autorunpath = g_mainpath + "\\DataSyncSend.exe";
  4848. ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
  4849. autorunpath = g_mainpath + "\\CPhotoFTPReceive.exe";
  4850. ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
  4851. autorunpath = g_mainpath + "\\CPhotoFTPSend.exe";
  4852. ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
  4853. #endif
  4854. }
  4855. catch (...)
  4856. {
  4857. WriteTextLog("出错在函数UpdateDate中");
  4858. }
  4859. }
  4860. BOOL CheckDateOK(CString str)
  4861. {
  4862. try
  4863. {
  4864. CString tip;
  4865. int i;
  4866. CString demo = CTime::GetCurrentTime().Format("%Y-%m-%d");
  4867. if (str.GetLength() != demo.GetLength())
  4868. goto ll;
  4869. //2009-01-01
  4870. if (str.GetAt(4) != '-')
  4871. goto ll;
  4872. if (str.GetAt(7) != '-')
  4873. goto ll;
  4874. for (i = 0; i < str.GetLength(); i++)
  4875. {
  4876. if (i == 4 || i == 7)continue;
  4877. if (str.GetAt(i) < '0' || str.GetAt(i) > '9')
  4878. goto ll;
  4879. }
  4880. return 1;
  4881. ll:
  4882. return 0;
  4883. }
  4884. catch (...)
  4885. {
  4886. WriteTextLog("出错");
  4887. }
  4888. }
  4889. //--------------------------------------------------------------------------
  4890. // Remark by Jeff:2014.10.22
  4891. // 函数:AutoDelPhoto
  4892. // 描述:自动删除取件后的订单相片,包括客户原片、初修片、精修片、设计片。(不含备份相片)
  4893. // 参数:#
  4894. // 返回:#
  4895. //
  4896. // 调用关系:
  4897. // 1.AutoDelPhoto()由 BakPhoto()调用。
  4898. // 2.BakPhoto()由CDBServerDlg::SetTimer(4) 调用,调用频率2分钟,周期数直到程序结束。
  4899. // 3.CDBServerDlg::SetTimer(4) 由 CDBServerDlg::SetTimer(2) 调用,调用频率10毫秒,只有一个周期。
  4900. // 4.CDBServerDlg::SetTimer(2) 由 CDBServerDlg::OnInitDialog() 调用.
  4901. //
  4902. //--------------------------------------------------------------------------
  4903. void CDBServerDlg::AutoDelPhoto() // Jeff自动删除取件后的订单相片;
  4904. {
  4905. try
  4906. {
  4907. #ifdef ENTERPRISE_VERSION
  4908. GenYLGL();
  4909. #endif
  4910. g_curdb = &g_db;
  4911. CString m_check1; // 自动删除客人原片;
  4912. CString m_check2; // 自动删除客人初修片;
  4913. CString m_check3; // 自动删除客人精修片;
  4914. CString m_check4; // 自动删除客人设计片;
  4915. CString m_edit1; // 多少个月后删除原片;
  4916. CString m_edit2; // 多少个月后删除初修片;
  4917. CString m_edit3; // 多少个月后删除精修片;
  4918. CString m_edit4; // 多少个月后删除设计片;
  4919. CString m_bakserver1; // 自动备份客人原片的备份机器;
  4920. CString m_bakserver2; // 自动备份客人初修片的备份机器
  4921. CString m_bakserver3; // 自动备份客人精修片的备份机器;
  4922. CString m_bakserver4; // 自动备份客人设计片的备份机器;
  4923. // CDBServerDlg::m_bakserver5 : 自动备份系统数据的备份机器;
  4924. // 1.从version表中获取状态信息;
  4925. CRstversion tableOfVersion;
  4926. tableOfVersion.m_pDatabase = g_curdb;
  4927. tableOfVersion.Open();
  4928. if (!tableOfVersion.IsEOF())
  4929. {
  4930. m_check1 = tableOfVersion.m_check1;
  4931. m_check2 = tableOfVersion.m_check2;
  4932. m_check3 = tableOfVersion.m_check3;
  4933. m_check4 = tableOfVersion.m_check4;
  4934. m_edit1 = tableOfVersion.m_edit1;
  4935. m_edit2 = tableOfVersion.m_edit2;
  4936. m_edit3 = tableOfVersion.m_edit3;
  4937. m_edit4 = tableOfVersion.m_edit4;
  4938. m_bakserver1 = tableOfVersion.m_bakserver1;
  4939. m_bakserver2 = tableOfVersion.m_bakserver2;
  4940. m_bakserver3 = tableOfVersion.m_bakserver3;
  4941. m_bakserver4 = tableOfVersion.m_bakserver4;
  4942. m_bakserver5 = tableOfVersion.m_bakserver5;
  4943. }
  4944. tableOfVersion.Close();
  4945. // 2.
  4946. g_bakinfo = "资料未备份";
  4947. g_bakphoto = "照片未备份";
  4948. WriteTextLog("开始备份数据库");
  4949. if (!m_bakserver5.IsEmpty()) // 自动备份系统数据的备份机器;
  4950. {
  4951. CString bakpath;
  4952. CString localname;
  4953. localname = g_localname;
  4954. #ifdef CHILD_VERSION
  4955. if (m_bakserver5.Find(":") == -1 && m_bakserver5 != "")
  4956. m_bakserver5 = "\\\\" + m_bakserver5 + "\\数据备份(儿童管理软件)$";
  4957. if (1)//localname.CompareNoCase (m_bakserver5)==0 || CompareIP(localname, m_bakserver5)==0)
  4958. GetPathFromNetShareName("数据备份(儿童管理软件)$", m_bakserver5);
  4959. #else
  4960. if (m_bakserver5.Find(":") == -1 && m_bakserver5 != "")
  4961. m_bakserver5 = "\\\\" + m_bakserver5 + "\\数据备份(管理软件)$";
  4962. if (1)//localname.CompareNoCase (m_bakserver5)==0 || CompareIP(localname, m_bakserver5)==0)
  4963. GetPathFromNetShareName("数据备份(管理软件)$", m_bakserver5);
  4964. #endif
  4965. WriteTextLog(m_bakserver5);
  4966. if (::CheckFolderFileExist(m_bakserver5))
  4967. BakData(m_bakserver5, 1, 1);
  4968. }
  4969. WriteTextLog("数据库备份完成"); // Jeff:只是备份数据库;
  4970. BOOL bcheck1 = atoi(m_check1);
  4971. BOOL bcheck2 = atoi(m_check2);
  4972. BOOL bcheck3 = atoi(m_check3);
  4973. BOOL bcheck4 = atoi(m_check4);
  4974. #if 0 // Jeff:old code;
  4975. if (!(bcheck1 || bcheck2 || bcheck3 || bcheck4))
  4976. {
  4977. return;
  4978. }
  4979. #else
  4980. // 四个同时为假,退出删除操作;
  4981. if (!(bcheck1 | bcheck2 | bcheck3 | bcheck4))
  4982. {
  4983. return;
  4984. }
  4985. #endif
  4986. int edit1 = atoi(m_edit1);
  4987. int edit2 = atoi(m_edit2);
  4988. int edit3 = atoi(m_edit3);
  4989. int edit4 = atoi(m_edit4);
  4990. // path 4种类型相片的存储目录;
  4991. CStringArray patharray;
  4992. {
  4993. char server[50];
  4994. DWORD leng = 50;
  4995. ::GetComputerName(server, &leng);
  4996. CString spathserver = server;
  4997. CString g_path1;
  4998. CString g_path2;
  4999. CString g_path3;
  5000. CString g_path4;
  5001. g_path1 = g_path2 = g_path3 = g_path4 = server;
  5002. g_path1 = "\\\\" + g_path1 + "\\客户原片(管理软件)$";
  5003. g_path2 = "\\\\" + g_path2 + "\\修好的片(管理软件)$";
  5004. g_path3 = "\\\\" + g_path3 + "\\设计好的片(管理软件)$";
  5005. g_path4 = "\\\\" + g_path4 + "\\精修好的片(管理软件)$";
  5006. GetPathFromNetShareName("客户原片(管理软件)$", g_path1);
  5007. GetPathFromNetShareName("修好的片(管理软件)$", g_path2);
  5008. GetPathFromNetShareName("设计好的片(管理软件)$", g_path3);
  5009. GetPathFromNetShareName("精修好的片(管理软件)$", g_path4);
  5010. patharray.Add(g_path1);
  5011. patharray.Add(g_path2);
  5012. patharray.Add(g_path4);
  5013. patharray.Add(g_path3);
  5014. }
  5015. if (patharray.GetSize() == 0)
  5016. return;
  5017. CArray<CDatabase*, CDatabase*>dbarray2;
  5018. dbarray2.Copy(g_dbHistoryArray);
  5019. dbarray2.InsertAt(0, &g_db);
  5020. //------------------------------------------------------------------------------------------------------------------------
  5021. WriteTextLog("开始删除取件后照片");
  5022. for (int n = 0; n < min(3, dbarray2.GetSize()); n++)
  5023. {
  5024. g_curdb = dbarray2.ElementAt(n);
  5025. CArray<CStringArray, CStringArray>strArrayOfPhoto2BeDel;
  5026. CString filter = "status3='OK' and time5 is not null and time5<>''";
  5027. CRecordset myset(g_curdb);
  5028. CString sql = "select count(*) as cot from dindan";
  5029. if (!filter.IsEmpty())
  5030. sql += " where " + filter;
  5031. myset.Open(CRecordset::forwardOnly, sql);
  5032. myset.GetFieldValue("cot", sql);
  5033. myset.Close();
  5034. int count = atol(sql);
  5035. if (count == 0)continue;
  5036. strArrayOfPhoto2BeDel.SetSize(count, 1);
  5037. CRstDindanForm rsSt;
  5038. rsSt.m_pDatabase = g_curdb;
  5039. if (!filter.IsEmpty())
  5040. rsSt.m_strFilter = filter;
  5041. rsSt.Open();
  5042. INT_PTR nIndex = 0;
  5043. while (!rsSt.IsEOF())
  5044. {
  5045. strArrayOfPhoto2BeDel.ElementAt(nIndex).RemoveAll();
  5046. strArrayOfPhoto2BeDel.ElementAt(nIndex).Add(rsSt.id);
  5047. strArrayOfPhoto2BeDel.ElementAt(nIndex).Add(rsSt.time5);
  5048. nIndex++;
  5049. rsSt.MoveNext();
  5050. if (strArrayOfPhoto2BeDel.GetSize() <= nIndex)break;
  5051. }
  5052. rsSt.Close();
  5053. strArrayOfPhoto2BeDel.SetSize(nIndex, 1);
  5054. CString time5;
  5055. CString id;
  5056. CTime curtm = CTime::GetCurrentTime();
  5057. CString strtime;
  5058. for (int i = 0; i < strArrayOfPhoto2BeDel.GetSize(); i++)
  5059. {
  5060. id = strArrayOfPhoto2BeDel.ElementAt(i).ElementAt(0);
  5061. time5 = strArrayOfPhoto2BeDel.ElementAt(i).ElementAt(1);
  5062. if (bcheck1)//原片
  5063. {
  5064. CTimeSpan sp(edit1 * 30, 0, 0, 0);
  5065. CTime tm = curtm - sp;
  5066. strtime = tm.Format("%Y-%m-%d");
  5067. if (strtime > time5) // Jeff,这种比较是否正确???
  5068. {
  5069. if (DelPhoto1(patharray.ElementAt(0), strArrayOfPhoto2BeDel.ElementAt(i).ElementAt(0)))
  5070. WriteTextLog("原片" + patharray.ElementAt(0) + "\\" + strArrayOfPhoto2BeDel.ElementAt(i).ElementAt(0));
  5071. // DelPhoto1(patharray2.ElementAt (0),g_List1array.ElementAt (i).ElementAt (0));
  5072. }
  5073. }
  5074. if (bcheck2)
  5075. {
  5076. CTimeSpan sp(edit2 * 30, 0, 0, 0);
  5077. CTime tm = curtm - sp;
  5078. strtime = tm.Format("%Y-%m-%d");
  5079. if (strtime > time5)
  5080. {
  5081. DelPhoto1(patharray.ElementAt(1), strArrayOfPhoto2BeDel.ElementAt(i).ElementAt(0));
  5082. // DelPhoto1(patharray2.ElementAt (2),g_List1array.ElementAt (i).ElementAt (0));
  5083. }
  5084. }
  5085. if (bcheck3)
  5086. {
  5087. CTimeSpan sp(edit3 * 30, 0, 0, 0);
  5088. CTime tm = curtm - sp;
  5089. strtime = tm.Format("%Y-%m-%d");
  5090. if (strtime > time5)
  5091. {
  5092. DelPhoto1(patharray.ElementAt(2), strArrayOfPhoto2BeDel.ElementAt(i).ElementAt(0));
  5093. // DelPhoto1(patharray2.ElementAt (2),g_List1array.ElementAt (i).ElementAt (0));
  5094. }
  5095. }
  5096. if (bcheck4)
  5097. {
  5098. CTimeSpan sp(edit4 * 30, 0, 0, 0);
  5099. CTime tm = curtm - sp;
  5100. strtime = tm.Format("%Y-%m-%d");
  5101. if (strtime > time5)
  5102. {
  5103. DelPhoto1(patharray.ElementAt(3), strArrayOfPhoto2BeDel.ElementAt(i).ElementAt(0));
  5104. }
  5105. }
  5106. }
  5107. }
  5108. //------------------------------------------------------------------------------------------------------------------------
  5109. g_curdb = &g_db;
  5110. #ifdef ENTERPRISE_VERSION // Jeff:若是集团版,会再次删除本店已取件的历史订单一次。多操作了一次!
  5111. WriteTextLog("本店查完,开始检查分店");
  5112. CString g_domain;
  5113. CArray<CStringArray, CStringArray>g_List1array;
  5114. CString autorunpath = g_mainpath + "\\branchdindan.dat";
  5115. CFile fp;
  5116. if (fp.Open(autorunpath, CFile::modeRead))
  5117. {
  5118. int nMessageLen = fp.GetLength();
  5119. BYTE *pData = new BYTE[nMessageLen];
  5120. fp.Read(pData, nMessageLen);
  5121. fp.Close();
  5122. BYTE *szChatMessage = pData;
  5123. int count;
  5124. memcpy(&count, szChatMessage + (nMessageLen - sizeof(int)), sizeof(int));
  5125. CMemFile memfile;
  5126. memfile.Attach(szChatMessage, nMessageLen);
  5127. CArchive ar(&memfile, CArchive::load);
  5128. g_List1array.SetSize(count);
  5129. for (int ii = 0; ii < g_List1array.GetSize(); ii++)
  5130. {
  5131. g_List1array.ElementAt(ii).Serialize(ar);
  5132. }
  5133. ar.Close();
  5134. memfile.Detach();
  5135. delete[]pData;
  5136. }
  5137. CString time5, id;
  5138. CTime curtm = CTime::GetCurrentTime();
  5139. CString strtime;
  5140. for (int i = 0; i < g_List1array.GetSize(); i++)
  5141. {
  5142. g_domain = "\\" + g_List1array.ElementAt(i).ElementAt(0);
  5143. if (g_domain.Find(".ly.com") == -1)continue;
  5144. id = g_List1array.ElementAt(i).ElementAt(1);
  5145. time5 = g_List1array.ElementAt(i).ElementAt(2);
  5146. if (bcheck1)//原片
  5147. {
  5148. CTimeSpan sp(edit1 * 30, 0, 0, 0);
  5149. CTime tm = curtm - sp;
  5150. strtime = tm.Format("%Y-%m-%d");
  5151. if (strtime > time5)
  5152. {
  5153. if (DelPhoto1(patharray.ElementAt(0) + g_domain, id))
  5154. WriteTextLog("分店原片" + patharray.ElementAt(0) + g_domain + "\\" + id);
  5155. }
  5156. }
  5157. if (bcheck2)
  5158. {
  5159. CTimeSpan sp(edit2 * 30, 0, 0, 0);
  5160. CTime tm = curtm - sp;
  5161. strtime = tm.Format("%Y-%m-%d");
  5162. if (strtime > time5)
  5163. {
  5164. DelPhoto1(patharray.ElementAt(1) + g_domain, id);
  5165. // DelPhoto1(patharray2.ElementAt (2),id);
  5166. }
  5167. }
  5168. if (bcheck3)
  5169. {
  5170. CTimeSpan sp(edit3 * 30, 0, 0, 0);
  5171. CTime tm = curtm - sp;
  5172. strtime = tm.Format("%Y-%m-%d");
  5173. if (strtime > time5)
  5174. {
  5175. DelPhoto1(patharray.ElementAt(2) + g_domain, id);
  5176. // DelPhoto1(patharray2.ElementAt (2),id);
  5177. }
  5178. }
  5179. if (bcheck4)
  5180. {
  5181. CTimeSpan sp(edit4 * 30, 0, 0, 0);
  5182. CTime tm = curtm - sp;
  5183. strtime = tm.Format("%Y-%m-%d");
  5184. if (strtime > time5)
  5185. {
  5186. DelPhoto1(patharray.ElementAt(3) + g_domain, id);
  5187. }
  5188. }
  5189. }
  5190. g_curdb = &g_db;
  5191. #endif
  5192. WriteTextLog("检查删除照片完成");
  5193. }
  5194. catch (...)
  5195. {
  5196. WriteTextLog("出错在函数AutoDelPhoto中");
  5197. }
  5198. g_curdb = &g_db;
  5199. }
  5200. //------------------------------------------------------------------
  5201. // Remark by Jeff:2014.10.11
  5202. // 函数:DelPhoto1
  5203. // 描述:删除指定路径下的订单文件夹;
  5204. // 参数:
  5205. // path: 指定要删除文件的根目录;
  5206. // strOrderNumber: 将要删除的订单号文件夹;
  5207. // 返回:
  5208. //-----------------------------------------------------------------
  5209. BOOL CDBServerDlg::DelPhoto1(CString path, CString strOrderNumber)
  5210. {
  5211. if (path == "")
  5212. return 0;
  5213. if (::CheckFolderFileExist(path + "\\" + strOrderNumber))
  5214. {
  5215. DeleteDirectory(path + "\\" + strOrderNumber);
  5216. return 1;
  5217. }
  5218. }
  5219. //-----------------------------------------------------------------------
  5220. // Remark by Jeff 2014.10.22
  5221. // 函数:BakPhoto
  5222. // 描述:对影楼相片进行备份和删除取件相片
  5223. // 参数:#
  5224. // 返回:#
  5225. //
  5226. // 调用关系:
  5227. // 1.BakPhoto()由CDBServerDlg::SetTimer(4) 调用,调用频率2分钟,周期数直到程序结束。
  5228. // 2.CDBServerDlg::SetTimer(4) 由 CDBServerDlg::SetTimer(2) 调用,调用频率10毫秒,只有一个周期。
  5229. // 3.CDBServerDlg::SetTimer(2) 由 CDBServerDlg::OnInitDialog() 调用.
  5230. //-----------------------------------------------------------------------
  5231. void CDBServerDlg::BakPhoto() // Jeff:备份相片/删除取件相片;
  5232. {
  5233. try
  5234. {
  5235. g_curdb = &g_db;
  5236. CString m_bak1, m_bak2, m_bak3, m_bak4, m_bak6, m_baktime; // Jeff:m_bak6自动备份完毕后自动关机;
  5237. CString m_bakserver1, m_bakserver2, m_bakserver3, m_bakserver4;
  5238. CString msgcheck4, msgtime, msgphones, msgphones2, msgcompanyname;
  5239. CString balance, msgaccount;
  5240. {
  5241. MyLock lock("dbaccessxiao");
  5242. CRstversion rsSt;
  5243. rsSt.m_pDatabase = g_curdb;
  5244. rsSt.Open();
  5245. if (!rsSt.IsEOF())
  5246. {
  5247. m_bak1 = rsSt.m_bak1;
  5248. m_bak2 = rsSt.m_bak2;
  5249. m_bak3 = rsSt.m_bak3;
  5250. m_bak4 = rsSt.m_bak4;
  5251. m_bakserver1 = rsSt.m_bakserver1;
  5252. m_bakserver2 = rsSt.m_bakserver2;
  5253. m_bakserver3 = rsSt.m_bakserver3;
  5254. m_bakserver4 = rsSt.m_bakserver4;
  5255. m_bak6 = rsSt.m_bak6;
  5256. m_baktime = rsSt.m_baktime;
  5257. msgcheck4 = rsSt.msgcheck4;
  5258. msgtime = rsSt.msgtime;
  5259. msgphones = rsSt.msgphones;
  5260. msgphones2 = rsSt.msgphones2;
  5261. msgcompanyname = rsSt.msgcompanyname;
  5262. balance = rsSt.msgbalance;
  5263. msgaccount = rsSt.msgaccount;
  5264. }
  5265. rsSt.Close();
  5266. }
  5267. /////////////检测发短信回财务
  5268. if (msgphones2.IsEmpty() == 0)
  5269. {
  5270. MyLock lock("dbaccessxiao");
  5271. CStringArray array, timearray;
  5272. CString timestamp;
  5273. timestamp = CTime::GetCurrentTime().Format("%Y-%m-%d");
  5274. timestamp += "%";
  5275. CRecordset myset(g_curdb);
  5276. CString sql = "select phones,timestamp from sendregreceive where [timestamp] like '" + timestamp + "' and [content]='001' and [status]='OK'";
  5277. myset.Open(CRecordset::forwardOnly, sql);
  5278. CString phones;
  5279. while (!myset.IsEOF())
  5280. {
  5281. myset.GetFieldValue("phones", phones);
  5282. myset.GetFieldValue("timestamp", timestamp);
  5283. if (msgphones2.Find(phones) != -1)
  5284. {
  5285. array.Add(phones);
  5286. timearray.Add(timestamp);
  5287. }
  5288. myset.MoveNext();
  5289. }
  5290. myset.Close();
  5291. if (array.GetSize())
  5292. {
  5293. int i = 0;
  5294. CString sql;
  5295. for ( i = 0; i < array.GetSize(); i++)
  5296. {
  5297. sql = "update sendregreceive set [status]='' where [timestamp]='" + timearray.ElementAt(i) + "'";
  5298. MyExecuteSQL(&g_db, sql);
  5299. }
  5300. CArray<CStringArray, CStringArray>List11array;
  5301. CArray<CStringArray, CStringArray>List2array;
  5302. CArray<CStringArray, CStringArray>List3array;
  5303. CArray<CStringArray, CStringArray>other2salearray;
  5304. CArray<CStringArray, CStringArray>memberarray;
  5305. CString strdate = CTime::GetCurrentTime().Format("%Y-%m-%d");
  5306. CArray<CDatabase*, CDatabase*>dbarraytemp;
  5307. dbarraytemp.Copy(g_dbHistoryArray);
  5308. while (dbarraytemp.GetSize()>1)
  5309. {
  5310. int last = dbarraytemp.GetSize() - 1;
  5311. dbarraytemp.RemoveAt(last);
  5312. }
  5313. dbarraytemp.InsertAt(0, &g_db);
  5314. for (int a = dbarraytemp.GetSize() - 1; a >= 0; a--)
  5315. {
  5316. g_curdb = dbarraytemp.ElementAt(a);
  5317. CString filter = "[dat]='" + strdate + "'";
  5318. filter = "[dat]='" + strdate + "' and ([sale2type] is null or [sale2type]='')";
  5319. {
  5320. CRecordset myset(g_curdb);
  5321. CString sql = "select count(*) as cot from singleincome"; if (!filter.IsEmpty())sql += " where " + filter;
  5322. myset.Open(CRecordset::forwardOnly, sql);
  5323. myset.GetFieldValue("cot", sql);
  5324. myset.Close();
  5325. int count = atol(sql);
  5326. int oldsize = List2array.GetSize();
  5327. List2array.SetSize(oldsize + count, 1);
  5328. CRstIncomeInput rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  5329. rsSt.Open();
  5330. int ii = 0;
  5331. while (!rsSt.IsEOF())
  5332. {
  5333. List2array.ElementAt(oldsize + ii).RemoveAll();
  5334. List2array.ElementAt(oldsize + ii).Add(rsSt.id);
  5335. List2array.ElementAt(oldsize + ii).Add(rsSt.name);
  5336. List2array.ElementAt(oldsize + ii).Add(rsSt.money);
  5337. List2array.ElementAt(oldsize + ii).Add(rsSt.date);
  5338. List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
  5339. List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
  5340. List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
  5341. List2array.ElementAt(oldsize + ii).Add(rsSt.bz);
  5342. List2array.ElementAt(oldsize + ii).Add(rsSt.sale2type);
  5343. ii++;
  5344. rsSt.MoveNext(); if (List2array.GetSize() <= ii)break;
  5345. }
  5346. rsSt.Close(); List2array.SetSize(oldsize + ii, 1);
  5347. }
  5348. filter = "[dat]='" + strdate + "'";
  5349. {
  5350. CRecordset myset(g_curdb);
  5351. CString sql = "select count(*) as cot from gudingfeiyong"; if (!filter.IsEmpty())sql += " where " + filter;
  5352. myset.Open(CRecordset::forwardOnly, sql);
  5353. myset.GetFieldValue("cot", sql);
  5354. myset.Close();
  5355. int count = atol(sql);
  5356. int oldsize = List3array.GetSize();
  5357. List3array.SetSize(oldsize + count, 1);
  5358. CRstPayOutInput rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  5359. rsSt.Open();
  5360. int ii = 0;
  5361. while (!rsSt.IsEOF())
  5362. {
  5363. List3array.ElementAt(oldsize + ii).RemoveAll();
  5364. List3array.ElementAt(oldsize + ii).Add(rsSt.id);
  5365. List3array.ElementAt(oldsize + ii).Add(rsSt.name);
  5366. List3array.ElementAt(oldsize + ii).Add(rsSt.money);
  5367. List3array.ElementAt(oldsize + ii).Add(rsSt.date);
  5368. List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
  5369. List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
  5370. List3array.ElementAt(oldsize + ii).Add(rsSt.bz);
  5371. ii++;
  5372. rsSt.MoveNext(); if (List3array.GetSize() <= ii)break;
  5373. }
  5374. rsSt.Close(); List3array.SetSize(oldsize + ii, 1);
  5375. }
  5376. filter = "[date]='" + strdate + "'";
  5377. {
  5378. CRecordset myset(g_curdb);
  5379. CString sql = "select count(*) as cot from dindanbukuan"; if (!filter.IsEmpty())sql += " where " + filter;
  5380. myset.Open(CRecordset::forwardOnly, sql);
  5381. myset.GetFieldValue("cot", sql);
  5382. myset.Close();
  5383. int count = atol(sql);
  5384. int oldsize = List11array.GetSize();
  5385. List11array.SetSize(oldsize + count, 1);
  5386. CRstBuKuan rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  5387. rsSt.Open();
  5388. int ii = 0;
  5389. while (!rsSt.IsEOF())
  5390. {
  5391. List11array.ElementAt(oldsize + ii).RemoveAll();
  5392. List11array.ElementAt(oldsize + ii).Add(rsSt.m_id);
  5393. List11array.ElementAt(oldsize + ii).Add(rsSt.m_ren);
  5394. List11array.ElementAt(oldsize + ii).Add(rsSt.m_money);
  5395. List11array.ElementAt(oldsize + ii).Add(rsSt.m_bz);
  5396. List11array.ElementAt(oldsize + ii).Add(rsSt.m_kind);
  5397. List11array.ElementAt(oldsize + ii).Add(rsSt.m_date);
  5398. ii++;
  5399. rsSt.MoveNext(); if (List11array.GetSize() <= ii)break;
  5400. }
  5401. rsSt.Close(); List11array.SetSize(oldsize + ii, 1);
  5402. }
  5403. filter = "[date]='" + strdate + "'";
  5404. {
  5405. CRecordset myset(g_curdb);
  5406. CString sql = "select count(*) as cot from singleincomemoneyview"; if (!filter.IsEmpty())sql += " where " + filter;
  5407. myset.Open(CRecordset::forwardOnly, sql);
  5408. myset.GetFieldValue("cot", sql);
  5409. myset.Close();
  5410. int count = atol(sql);
  5411. int oldsize = other2salearray.GetSize();
  5412. other2salearray.SetSize(oldsize + count, 1);
  5413. CRstsingleincomemoneyview rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  5414. rsSt.Open();
  5415. int ii = 0;
  5416. while (!rsSt.IsEOF())
  5417. {
  5418. other2salearray.ElementAt(oldsize + ii).RemoveAll();
  5419. other2salearray.ElementAt(oldsize + ii).Add(rsSt.name);
  5420. other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
  5421. other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
  5422. other2salearray.ElementAt(oldsize + ii).Add(rsSt.sale2type);
  5423. other2salearray.ElementAt(oldsize + ii).Add(rsSt.money);
  5424. other2salearray.ElementAt(oldsize + ii).Add(rsSt.date);
  5425. other2salearray.ElementAt(oldsize + ii).Add(rsSt.clerk);
  5426. other2salearray.ElementAt(oldsize + ii).Add(rsSt.paytype);
  5427. other2salearray.ElementAt(oldsize + ii).Add(rsSt.autoid);
  5428. other2salearray.ElementAt(oldsize + ii).Add(rsSt.financecheck);
  5429. ii++;
  5430. rsSt.MoveNext(); if (other2salearray.GetSize() <= ii)break;
  5431. }
  5432. rsSt.Close(); other2salearray.SetSize(oldsize + ii, 1);
  5433. }
  5434. filter = "[date]='" + strdate + "'";
  5435. {
  5436. CRecordset myset(g_curdb);
  5437. CString sql = "select count(*) as cot from memberview"; if (!filter.IsEmpty())sql += " where " + filter;
  5438. myset.Open(CRecordset::forwardOnly, sql);
  5439. myset.GetFieldValue("cot", sql);
  5440. myset.Close();
  5441. int count = atol(sql);
  5442. int oldsize = memberarray.GetSize();
  5443. memberarray.SetSize(oldsize + count, 1);
  5444. memberviewReg rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  5445. rsSt.Open();
  5446. DWORD ii = 0;
  5447. while (!rsSt.IsEOF())
  5448. {
  5449. memberarray.ElementAt(oldsize + ii).RemoveAll();
  5450. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_id);
  5451. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_memberno);
  5452. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_name);
  5453. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_money);
  5454. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_date);
  5455. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_clerk);
  5456. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_financecheck);
  5457. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_moneytype);
  5458. ii++;
  5459. rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
  5460. }
  5461. rsSt.Close(); memberarray.SetSize(oldsize + ii, 1);
  5462. }
  5463. }//
  5464. g_curdb = &g_db;
  5465. CString str;
  5466. int pos = 0;
  5467. int dindanshu = 0;
  5468. float income = 0;
  5469. float incomedd = 0;
  5470. float incomebk = 0;
  5471. float incomehq = 0;
  5472. float incomeqt = 0;
  5473. float payout = 0;
  5474. for (i = 0; i < List11array.GetSize(); i++)
  5475. {
  5476. str = List11array.ElementAt(i).ElementAt(2);
  5477. income += atof(str);
  5478. // income2+=atof(str);
  5479. if (List11array.ElementAt(i).ElementAt(3) == "预约收款")
  5480. {
  5481. incomedd += atof(str);
  5482. dindanshu++;
  5483. }
  5484. else if (List11array.ElementAt(i).ElementAt(3) == "预约补款")
  5485. {
  5486. incomebk += atof(str);
  5487. }
  5488. else
  5489. {
  5490. incomehq += atof(str);
  5491. }
  5492. pos++;
  5493. }
  5494. for (i = 0; i < List2array.GetSize(); i++)
  5495. {
  5496. str = List2array.ElementAt(i).ElementAt(2);
  5497. income += atof(str);
  5498. /* if(List2array.ElementAt (i).ElementAt (8)!="")
  5499. {
  5500. income2+=atof(str);
  5501. }*/
  5502. if (List2array.ElementAt(i).ElementAt(8) == "")
  5503. {
  5504. incomeqt += atof(str);
  5505. }
  5506. pos++;
  5507. }
  5508. for (i = 0; i < List3array.GetSize(); i++)
  5509. {
  5510. str = List3array.ElementAt(i).ElementAt(2);
  5511. payout += atof(str);
  5512. pos++;
  5513. }
  5514. for (i = 0; i < other2salearray.GetSize(); i++)
  5515. {
  5516. str = other2salearray.ElementAt(i).ElementAt(4);
  5517. income += atof(str);
  5518. incomehq += atof(str);
  5519. pos++;
  5520. }
  5521. for (i = 0; i < memberarray.GetSize(); i++)
  5522. {
  5523. str = memberarray.ElementAt(i).ElementAt(3);
  5524. income += atof(str);
  5525. pos++;
  5526. }
  5527. CTime tm = CTime::GetCurrentTime();
  5528. CString content = msgcompanyname + tm.Format("%Y-%m-%d");
  5529. content += "财报:";
  5530. str.Format("%d", (int)income);
  5531. ::ConvertToPrice(str);
  5532. content += "收:" + str;
  5533. str.Format("%d", (int)incomedd);
  5534. ::ConvertToPrice(str);
  5535. content += "定:" + str;
  5536. str.Format("%d", (int)incomebk);
  5537. ::ConvertToPrice(str);
  5538. content += "补:" + str;
  5539. str.Format("%d", (int)incomehq);
  5540. ::ConvertToPrice(str);
  5541. content += "后:" + str;
  5542. str.Format("%d", (int)incomeqt);
  5543. ::ConvertToPrice(str);
  5544. content += "其它:" + str;
  5545. str.Format("%d", (int)payout);
  5546. ::ConvertToPrice(str);
  5547. content += "支出:" + str;
  5548. str.Format("%d", (int)(income - payout));
  5549. ::ConvertToPrice(str);
  5550. content += "净收:" + str;
  5551. str.Format("%d", dindanshu);
  5552. content += "定单:" + str;
  5553. if (msgaccount != "")
  5554. {
  5555. if (atoi(balance) < 200)
  5556. {
  5557. content += "您的余额小于两百条,请及时充值。联系电话4006067068";
  5558. }
  5559. else if (atoi(balance) < 500)
  5560. {
  5561. content += "您的余额小于五百条,请及时充值。联系电话4006067068";
  5562. }
  5563. else if (atoi(balance) < 800)
  5564. {
  5565. content += "您的余额小于八百条,请及时充值。联系电话4006067068";
  5566. }
  5567. else if (atoi(balance) < 1000)
  5568. {
  5569. content += "您的余额小于一千条,请及时充值。联系电话4006067068";
  5570. }
  5571. }
  5572. int count = GetLengthEx(content) / MSG_LENGTH;
  5573. if (GetLengthEx(content) % MSG_LENGTH)
  5574. count++;
  5575. int phonenum = 0;
  5576. phonenum = 1;
  5577. count *= phonenum;
  5578. CString scount;
  5579. scount.Format("%d", count);
  5580. CString timestamp = tm.Format("%Y%m%d%H%M%S");
  5581. for (i = 0; i < 1; i++)
  5582. {
  5583. sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + array.ElementAt(i) + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  5584. MyExecuteSQL(&g_db, sql);
  5585. }
  5586. }
  5587. }
  5588. /////////////
  5589. if (atoi(msgcheck4) && msgphones != "")
  5590. {//发老板短信
  5591. if (atoi(msgtime) <= CTime::GetCurrentTime().GetHour())
  5592. {
  5593. MyLock lock("dbaccessxiao");
  5594. CString timestamp;
  5595. timestamp = CTime::GetCurrentTime().Format("%Y%m%d");
  5596. timestamp += "%";
  5597. CRecordset myset(g_curdb);
  5598. CString sql = "select count(*) as cot from sendreg where [timestamp] like '" + timestamp + "' and [phones]='" + msgphones + "' and [isautosend]='3'";
  5599. myset.Open(CRecordset::forwardOnly, sql);
  5600. myset.GetFieldValue("cot", sql);
  5601. myset.Close();
  5602. int count = atol(sql);
  5603. if (count == 0)
  5604. {
  5605. CArray<CStringArray, CStringArray>List11array;
  5606. CArray<CStringArray, CStringArray>List2array;
  5607. CArray<CStringArray, CStringArray>List3array;
  5608. CArray<CStringArray, CStringArray>other2salearray;
  5609. CArray<CStringArray, CStringArray>memberarray;
  5610. CString strdate = CTime::GetCurrentTime().Format("%Y-%m-%d");
  5611. CArray<CDatabase*, CDatabase*>dbarraytemp;
  5612. dbarraytemp.Copy(g_dbHistoryArray);
  5613. while (dbarraytemp.GetSize() > 1)
  5614. {
  5615. int last = dbarraytemp.GetSize() - 1;
  5616. dbarraytemp.RemoveAt(last);
  5617. }
  5618. dbarraytemp.InsertAt(0, &g_db);
  5619. for (int a = dbarraytemp.GetSize() - 1; a >= 0; a--)
  5620. {
  5621. g_curdb = dbarraytemp.ElementAt(a);
  5622. CString filter = "[dat]='" + strdate + "'";
  5623. filter = "[dat]='" + strdate + "' and ([sale2type] is null or [sale2type]='')";
  5624. {
  5625. CRecordset myset(g_curdb);
  5626. CString sql = "select count(*) as cot from singleincome"; if (!filter.IsEmpty())sql += " where " + filter;
  5627. myset.Open(CRecordset::forwardOnly, sql);
  5628. myset.GetFieldValue("cot", sql);
  5629. myset.Close();
  5630. int count = atol(sql);
  5631. int oldsize = List2array.GetSize();
  5632. List2array.SetSize(oldsize + count, 1);
  5633. CRstIncomeInput rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  5634. rsSt.Open();
  5635. int ii = 0;
  5636. while (!rsSt.IsEOF())
  5637. {
  5638. List2array.ElementAt(oldsize + ii).RemoveAll();
  5639. List2array.ElementAt(oldsize + ii).Add(rsSt.id);
  5640. List2array.ElementAt(oldsize + ii).Add(rsSt.name);
  5641. List2array.ElementAt(oldsize + ii).Add(rsSt.money);
  5642. List2array.ElementAt(oldsize + ii).Add(rsSt.date);
  5643. List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
  5644. List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
  5645. List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
  5646. List2array.ElementAt(oldsize + ii).Add(rsSt.bz);
  5647. List2array.ElementAt(oldsize + ii).Add(rsSt.sale2type);
  5648. ii++;
  5649. rsSt.MoveNext(); if (List2array.GetSize() <= ii)break;
  5650. }
  5651. rsSt.Close(); List2array.SetSize(oldsize + ii, 1);
  5652. }
  5653. filter = "[dat]='" + strdate + "'";
  5654. {
  5655. CRecordset myset(g_curdb);
  5656. CString sql = "select count(*) as cot from gudingfeiyong"; if (!filter.IsEmpty())sql += " where " + filter;
  5657. myset.Open(CRecordset::forwardOnly, sql);
  5658. myset.GetFieldValue("cot", sql);
  5659. myset.Close();
  5660. int count = atol(sql);
  5661. int oldsize = List3array.GetSize();
  5662. List3array.SetSize(oldsize + count, 1);
  5663. CRstPayOutInput rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  5664. rsSt.Open();
  5665. int ii = 0;
  5666. while (!rsSt.IsEOF())
  5667. {
  5668. List3array.ElementAt(oldsize + ii).RemoveAll();
  5669. List3array.ElementAt(oldsize + ii).Add(rsSt.id);
  5670. List3array.ElementAt(oldsize + ii).Add(rsSt.name);
  5671. List3array.ElementAt(oldsize + ii).Add(rsSt.money);
  5672. List3array.ElementAt(oldsize + ii).Add(rsSt.date);
  5673. List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
  5674. List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
  5675. List3array.ElementAt(oldsize + ii).Add(rsSt.bz);
  5676. ii++;
  5677. rsSt.MoveNext(); if (List3array.GetSize() <= ii)break;
  5678. }
  5679. rsSt.Close(); List3array.SetSize(oldsize + ii, 1);
  5680. }
  5681. filter = "[date]='" + strdate + "'";
  5682. {
  5683. CRecordset myset(g_curdb);
  5684. CString sql = "select count(*) as cot from dindanbukuan"; if (!filter.IsEmpty())sql += " where " + filter;
  5685. myset.Open(CRecordset::forwardOnly, sql);
  5686. myset.GetFieldValue("cot", sql);
  5687. myset.Close();
  5688. int count = atol(sql);
  5689. int oldsize = List11array.GetSize();
  5690. List11array.SetSize(oldsize + count, 1);
  5691. CRstBuKuan rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  5692. rsSt.Open();
  5693. int ii = 0;
  5694. while (!rsSt.IsEOF())
  5695. {
  5696. List11array.ElementAt(oldsize + ii).RemoveAll();
  5697. List11array.ElementAt(oldsize + ii).Add(rsSt.m_id);
  5698. List11array.ElementAt(oldsize + ii).Add(rsSt.m_ren);
  5699. List11array.ElementAt(oldsize + ii).Add(rsSt.m_money);
  5700. List11array.ElementAt(oldsize + ii).Add(rsSt.m_bz);
  5701. List11array.ElementAt(oldsize + ii).Add(rsSt.m_kind);
  5702. List11array.ElementAt(oldsize + ii).Add(rsSt.m_date);
  5703. ii++;
  5704. rsSt.MoveNext(); if (List11array.GetSize() <= ii)break;
  5705. }
  5706. rsSt.Close(); List11array.SetSize(oldsize + ii, 1);
  5707. }
  5708. filter = "[date]='" + strdate + "'";
  5709. {
  5710. CRecordset myset(g_curdb);
  5711. CString sql = "select count(*) as cot from singleincomemoneyview"; if (!filter.IsEmpty())sql += " where " + filter;
  5712. myset.Open(CRecordset::forwardOnly, sql);
  5713. myset.GetFieldValue("cot", sql);
  5714. myset.Close();
  5715. int count = atol(sql);
  5716. int oldsize = other2salearray.GetSize();
  5717. other2salearray.SetSize(oldsize + count, 1);
  5718. CRstsingleincomemoneyview rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  5719. rsSt.Open();
  5720. int ii = 0;
  5721. while (!rsSt.IsEOF())
  5722. {
  5723. other2salearray.ElementAt(oldsize + ii).RemoveAll();
  5724. other2salearray.ElementAt(oldsize + ii).Add(rsSt.name);
  5725. other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
  5726. other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
  5727. other2salearray.ElementAt(oldsize + ii).Add(rsSt.sale2type);
  5728. other2salearray.ElementAt(oldsize + ii).Add(rsSt.money);
  5729. other2salearray.ElementAt(oldsize + ii).Add(rsSt.date);
  5730. other2salearray.ElementAt(oldsize + ii).Add(rsSt.clerk);
  5731. other2salearray.ElementAt(oldsize + ii).Add(rsSt.paytype);
  5732. other2salearray.ElementAt(oldsize + ii).Add(rsSt.autoid);
  5733. other2salearray.ElementAt(oldsize + ii).Add(rsSt.financecheck);
  5734. ii++;
  5735. rsSt.MoveNext(); if (other2salearray.GetSize() <= ii)break;
  5736. }
  5737. rsSt.Close(); other2salearray.SetSize(oldsize + ii, 1);
  5738. }
  5739. filter = "[date]='" + strdate + "'";
  5740. {
  5741. CRecordset myset(g_curdb);
  5742. CString sql = "select count(*) as cot from memberview"; if (!filter.IsEmpty())sql += " where " + filter;
  5743. myset.Open(CRecordset::forwardOnly, sql);
  5744. myset.GetFieldValue("cot", sql);
  5745. myset.Close();
  5746. int count = atol(sql);
  5747. int oldsize = memberarray.GetSize();
  5748. memberarray.SetSize(oldsize + count, 1);
  5749. memberviewReg rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  5750. rsSt.Open();
  5751. DWORD ii = 0;
  5752. while (!rsSt.IsEOF())
  5753. {
  5754. memberarray.ElementAt(oldsize + ii).RemoveAll();
  5755. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_id);
  5756. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_memberno);
  5757. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_name);
  5758. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_money);
  5759. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_date);
  5760. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_clerk);
  5761. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_financecheck);
  5762. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_moneytype);
  5763. ii++;
  5764. rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
  5765. }
  5766. rsSt.Close(); memberarray.SetSize(oldsize + ii, 1);
  5767. }
  5768. }//
  5769. g_curdb = &g_db;
  5770. CString str;
  5771. int pos = 0;
  5772. int dindanshu = 0;
  5773. float income = 0;
  5774. float incomedd = 0;
  5775. float incomebk = 0;
  5776. float incomehq = 0;
  5777. float incomeqt = 0;
  5778. float payout = 0;
  5779. int i = 0;
  5780. for (i = 0; i < List11array.GetSize(); i++)
  5781. {
  5782. str = List11array.ElementAt(i).ElementAt(2);
  5783. income += atof(str);
  5784. // income2+=atof(str);
  5785. if (List11array.ElementAt(i).ElementAt(3) == "预约收款")
  5786. {
  5787. incomedd += atof(str);
  5788. dindanshu++;
  5789. }
  5790. else if (List11array.ElementAt(i).ElementAt(3) == "预约补款")
  5791. {
  5792. incomebk += atof(str);
  5793. }
  5794. else
  5795. {
  5796. incomehq += atof(str);
  5797. }
  5798. pos++;
  5799. }
  5800. for (i = 0; i < List2array.GetSize(); i++)
  5801. {
  5802. str = List2array.ElementAt(i).ElementAt(2);
  5803. income += atof(str);
  5804. /* if(List2array.ElementAt (i).ElementAt (8)!="")
  5805. {
  5806. income2+=atof(str);
  5807. }*/
  5808. if (List2array.ElementAt(i).ElementAt(8) == "")
  5809. {
  5810. incomeqt += atof(str);
  5811. }
  5812. pos++;
  5813. }
  5814. for (i = 0; i < List3array.GetSize(); i++)
  5815. {
  5816. str = List3array.ElementAt(i).ElementAt(2);
  5817. payout += atof(str);
  5818. pos++;
  5819. }
  5820. for (i = 0; i < other2salearray.GetSize(); i++)
  5821. {
  5822. str = other2salearray.ElementAt(i).ElementAt(4);
  5823. income += atof(str);
  5824. incomehq += atof(str);
  5825. pos++;
  5826. }
  5827. for (i = 0; i < memberarray.GetSize(); i++)
  5828. {
  5829. str = memberarray.ElementAt(i).ElementAt(3);
  5830. income += atof(str);
  5831. pos++;
  5832. }
  5833. CTime tm = CTime::GetCurrentTime();
  5834. CString content = msgcompanyname + tm.Format("%Y-%m-%d");
  5835. content += "财报:";
  5836. str.Format("%d", (int)income);
  5837. ::ConvertToPrice(str);
  5838. content += "收:" + str;
  5839. str.Format("%d", (int)incomedd);
  5840. ::ConvertToPrice(str);
  5841. content += "定:" + str;
  5842. str.Format("%d", (int)incomebk);
  5843. ::ConvertToPrice(str);
  5844. content += "补:" + str;
  5845. str.Format("%d", (int)incomehq);
  5846. ::ConvertToPrice(str);
  5847. content += "后:" + str;
  5848. str.Format("%d", (int)incomeqt);
  5849. ::ConvertToPrice(str);
  5850. content += "其它:" + str;
  5851. str.Format("%d", (int)payout);
  5852. ::ConvertToPrice(str);
  5853. content += "支出:" + str;
  5854. str.Format("%d", (int)(income - payout));
  5855. ::ConvertToPrice(str);
  5856. content += "净收:" + str;
  5857. str.Format("%d", dindanshu);
  5858. content += "定单:" + str;
  5859. if (msgaccount != "")
  5860. {
  5861. if (atoi(balance) < 200)
  5862. {
  5863. content += "您的余额小于两百条,请及时充值。联系电话4006067068";
  5864. }
  5865. else if (atoi(balance) < 500)
  5866. {
  5867. content += "您的余额小于五百条,请及时充值。联系电话4006067068";
  5868. }
  5869. else if (atoi(balance) < 800)
  5870. {
  5871. content += "您的余额小于八百条,请及时充值。联系电话4006067068";
  5872. }
  5873. else if (atoi(balance) < 1000)
  5874. {
  5875. content += "您的余额小于一千条,请及时充值。联系电话4006067068";
  5876. }
  5877. }
  5878. int count = GetLengthEx(content) / MSG_LENGTH;
  5879. if (GetLengthEx(content) % MSG_LENGTH)
  5880. count++;
  5881. int phonenum = 0;
  5882. str = msgphones;
  5883. pos = str.Find(",");
  5884. if (pos != -1)
  5885. {
  5886. while (pos != -1)
  5887. {
  5888. phonenum++;
  5889. str = str.Right(str.GetLength() - pos - 1);
  5890. pos = str.Find(",");
  5891. }
  5892. phonenum++;
  5893. }
  5894. else
  5895. phonenum = 1;
  5896. count *= phonenum;
  5897. CString scount;
  5898. scount.Format("%d", count);
  5899. timestamp = tm.Format("%Y%m%d%H%M%S");
  5900. sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + msgphones + "','" + content + "','" + timestamp + "','" + scount + "','0','0','3','系统自动发送')";
  5901. MyExecuteSQL(&g_db, sql);
  5902. }
  5903. }
  5904. }
  5905. BOOL bcheck1 = atoi(m_bak1);
  5906. BOOL bcheck2 = atoi(m_bak2);
  5907. BOOL bcheck3 = atoi(m_bak3);
  5908. BOOL bcheck4 = atoi(m_bak4);
  5909. int hour;
  5910. hour = CTime::GetCurrentTime().GetHour();
  5911. // Jeff.这里不合理.如果条件不成立,那当天的数据就不会执行。存在一定安全问题。
  5912. if (atoi(m_baktime) <= hour)
  5913. {
  5914. CStdioFile fp;
  5915. if (fp.Open(g_mainpath + "\\log.txt", CFile::modeRead))
  5916. {
  5917. CString date;
  5918. fp.ReadString(date);
  5919. date.TrimRight("\r\n");
  5920. if (date == CTime::GetCurrentTime().Format("%Y-%m-%d"))
  5921. {
  5922. fp.Close();
  5923. return;
  5924. }
  5925. fp.Close();
  5926. }
  5927. if (g_bConvertHisAll)
  5928. {
  5929. WriteTextLog("转历史数据中, 备份退出");
  5930. return;
  5931. }
  5932. g_bakdate = CTime::GetCurrentTime().Format("%Y-%m-%d");
  5933. KillTimer(4);
  5934. WriteTextLog("备份开始...");
  5935. AutoDelPhoto();
  5936. AutoDelBakPhoto();
  5937. LoadThumbImages2();
  5938. }
  5939. }
  5940. catch (...)
  5941. {
  5942. WriteTextLog("出错在函数bakphoto中");
  5943. }
  5944. }
  5945. void CDBServerDlg::ShutDown() //Jeff:备份完毕后执行的关机函数;
  5946. {
  5947. try
  5948. {
  5949. g_curdb = &g_db;
  5950. CString m_bak6;
  5951. {
  5952. CRecordset myset(g_curdb);
  5953. CString sql = "select * from [version]";
  5954. myset.Open(CRecordset::forwardOnly, sql);
  5955. myset.GetFieldValue("bak6", m_bak6);
  5956. myset.Close();
  5957. }
  5958. OnServerStop(); // 停止服务;
  5959. // Jeff.关闭数据库连接,若关机前关闭了数据库的连接,则客户端进行订单无法实现数据库的操作;
  5960. // Jeff.在关机前,不能关闭数据库连接;
  5961. g_db.Close();
  5962. for (int i = 0; i < g_dbHistoryArray.GetSize(); i++)
  5963. {
  5964. g_dbHistoryArray.ElementAt(i)->Close();
  5965. delete g_dbHistoryArray.ElementAt(i);
  5966. }
  5967. ReleaseBranchDB();
  5968. WriteTextLog("备份完成");
  5969. while (m_bRunning)
  5970. {
  5971. ::Sleep(1000);
  5972. }
  5973. ////////////////
  5974. g_tisks = ::GetTickCount() - g_tisks;
  5975. CString str;
  5976. str.Format("耗时:%d分钟", g_tisks / 60000);
  5977. CStdioFile fp;
  5978. fp.Open(g_mainpath + "\\log.txt", CFile::modeCreate | CFile::modeWrite);
  5979. CTime tm = CTime::GetCurrentTime();
  5980. if (0)//tm.GetHour ()<5)
  5981. {
  5982. CTimeSpan sp(1, 0, 0, 0);
  5983. tm -= sp;
  5984. fp.WriteString(tm.Format("%Y-%m-%d"));
  5985. fp.WriteString("\r\n");
  5986. fp.WriteString(CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"));
  5987. fp.WriteString(str);
  5988. }
  5989. else
  5990. {
  5991. fp.WriteString(g_bakdate);
  5992. fp.WriteString("\r\n");
  5993. fp.WriteString(tm.Format("%Y-%m-%d %H:%M:%S"));
  5994. fp.WriteString(str);
  5995. }
  5996. fp.WriteString("\r\n");
  5997. fp.WriteString(g_bakinfo);
  5998. fp.WriteString("\r\n");
  5999. fp.WriteString(g_bakphoto);
  6000. fp.Close();
  6001. // OnButton3();
  6002. // Jeff.备份完成后自动关机;
  6003. if (atoi(m_bak6))
  6004. {
  6005. #if 1
  6006. // Jeff.关闭运行中的线程;
  6007. TerminateThread();
  6008. TerminateThread2();
  6009. // Jeff.关闭AutoRun.exe程序;
  6010. DWORD id = FindAppProcessID("AutoRun.exe");
  6011. if (id != -1)
  6012. {
  6013. HANDLE ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
  6014. if (ProcessHandle)TerminateProcess(ProcessHandle, 0);
  6015. }
  6016. // Jeff.移除托盘图标;
  6017. m_TrayIcon.RemoveIcon();
  6018. if (g_pSkinData)delete[]g_pSkinData; g_pSkinData = NULL;
  6019. // Jeff.关闭计算机;
  6020. MyExitWindows();
  6021. #else // Jeff.开启定时关机功能;
  6022. SetTimer(11, 60000, NULL);// 1分钟检测一次是否到达关机时间;
  6023. #endif
  6024. }
  6025. else//重启
  6026. {
  6027. TerminateThread();
  6028. TerminateThread2();
  6029. m_TrayIcon.RemoveIcon();
  6030. if (g_pSkinData)
  6031. delete[]g_pSkinData;
  6032. g_pSkinData = NULL;
  6033. WriteTextLog("备份完成,服务器重启");
  6034. CDialog::OnCancel();
  6035. }
  6036. }
  6037. catch (...)
  6038. {
  6039. WriteTextLog("出错在函数shutdown中");
  6040. }
  6041. }
  6042. void CDBServerDlg::MyExitWindows()
  6043. {
  6044. try
  6045. {
  6046. UINT t = EWX_SHUTDOWN | EWX_FORCE;
  6047. OSVERSIONINFO osv; //定义一个操作系统信息的结构体
  6048. osv.dwOSVersionInfoSize = sizeof OSVERSIONINFO;
  6049. GetVersionEx(&osv); //查询当前操作系统
  6050. if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT) //判断是否是2000/NT
  6051. {
  6052. //下面为向操作系统获取权限操作
  6053. HANDLE hProcess, hToken;
  6054. TOKEN_PRIVILEGES Privileges;
  6055. LUID luid;
  6056. hProcess = GetCurrentProcess();
  6057. //下面为打开当前进程对话
  6058. OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES, &hToken);
  6059. Privileges.PrivilegeCount = 1;
  6060. LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &luid);
  6061. Privileges.Privileges[0].Luid = luid;
  6062. Privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
  6063. AdjustTokenPrivileges(hToken, FALSE, &Privileges, NULL, NULL, NULL);
  6064. ExitWindowsEx(t, 0);
  6065. }
  6066. else
  6067. {
  6068. ExitWindowsEx(t, 0);//调用ExitWindowsEx关闭机器。
  6069. PostQuitMessage(0);
  6070. }
  6071. }
  6072. catch (...)
  6073. {
  6074. WriteTextLog("出错在函数exitwindows中");
  6075. }
  6076. }
  6077. void CDBServerDlg::OnAutorun()
  6078. {
  6079. // TODO: Add your command handler code here
  6080. g_bAutoRun = !g_bAutoRun;
  6081. CString version = _T("Version 1.0");
  6082. AfxGetApp()->WriteProfileInt(version, "brun", g_bAutoRun);
  6083. TCHAR szKey[MAX_PATH];
  6084. HKEY hKey = 0;
  6085. DWORD disp = 0;
  6086. lstrcpy(szKey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
  6087. if (g_bAutoRun)
  6088. {
  6089. int lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
  6090. if (lResult == ERROR_SUCCESS)
  6091. {
  6092. TCHAR szDir[MAX_PATH];
  6093. ::GetModuleFileName(NULL, szDir, MAX_PATH);
  6094. lResult = RegSetValueEx(hKey, "YLGLDBSERVER", 0, REG_SZ, (const unsigned char*)szDir, lstrlen(szDir));
  6095. RegCloseKey(hKey);
  6096. }
  6097. }
  6098. else
  6099. {
  6100. int lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
  6101. if (lResult == ERROR_SUCCESS)
  6102. {
  6103. RegDeleteValue(hKey, "YLGLDBSERVER");
  6104. RegDeleteKey(hKey, "YLGLDBSERVER");
  6105. RegCloseKey(hKey);
  6106. }
  6107. }
  6108. }
  6109. void CDBServerDlg::GetFileDate()
  6110. {
  6111. CStringArray filesarray;
  6112. CStringArray filesarray2;
  6113. filesarray.Add("AutoUpdate.exe"); // 1.
  6114. filesarray.Add("skin\\1.lia");
  6115. filesarray.Add("skin\\2.lia");
  6116. filesarray.Add("skin\\3.lia");
  6117. filesarray.Add("skin\\4.lia");
  6118. filesarray.Add("skin\\10.lia");
  6119. filesarray.Add("skin\\logo.jpg");
  6120. filesarray.Add("skin\\标题-选片.jpg");
  6121. filesarray.Add("skin\\标题-看设计.jpg");
  6122. filesarray.Add("图片\\欢迎.jpg"); // 10.
  6123. filesarray.Add("图片\\连接.jpg");
  6124. filesarray.Add("图片\\标题.jpg");
  6125. filesarray.Add("图片\\背景.jpg");
  6126. filesarray.Add("图片-红色风格\\欢迎.jpg");
  6127. filesarray.Add("图片-红色风格\\连接.jpg");
  6128. filesarray.Add("图片-红色风格\\标题.jpg");
  6129. filesarray.Add("图片-红色风格\\背景.jpg");
  6130. filesarray.Add("图片-红色风格\\选片.jpg");
  6131. filesarray.Add("图片-红色风格\\看设计.jpg");
  6132. filesarray.Add("skin\\1-red.lia"); // 20.
  6133. filesarray.Add("skin\\2-red.lia");
  6134. filesarray.Add("skin\\10-red.lia");
  6135. filesarray.Add("skin\\6.lia");
  6136. filesarray.Add("图片\\掌中宝.jpg");
  6137. filesarray.Add("regsvr32.exe"); // 25.
  6138. filesarray.Add("MSCHRT20.OCX"); // 26. // Jeff.2014.09.06.添加MSCHRT20.OCX,由服务器传递;
  6139. ///////////////
  6140. filesarray2.Add("AutoUpdate.exe");
  6141. filesarray2.Add("skin\\1.lia");
  6142. filesarray2.Add("skin\\2.lia");
  6143. filesarray2.Add("skin\\3.lia");
  6144. filesarray2.Add("skin\\4.lia");
  6145. filesarray2.Add("skin\\5.lia");
  6146. filesarray2.Add("skin\\10.lia");
  6147. filesarray2.Add("skin\\5-red.lia");
  6148. filesarray2.Add("skin\\10-red.lia");
  6149. filesarray2.Add("图片\\logo.jpg");
  6150. filesarray2.Add("图片\\标题-选片.jpg");
  6151. filesarray2.Add("图片\\标题-看设计.jpg");
  6152. filesarray2.Add("图片\\选片.jpg");
  6153. filesarray2.Add("图片\\看设计.jpg");
  6154. filesarray2.Add("图片\\欢迎.jpg");
  6155. filesarray2.Add("图片\\连接.jpg");
  6156. filesarray2.Add("图片\\标题.jpg");
  6157. filesarray2.Add("图片\\背景.jpg");
  6158. filesarray2.Add("图片-红色风格\\欢迎.jpg");
  6159. filesarray2.Add("图片-红色风格\\连接.jpg");
  6160. filesarray2.Add("图片-红色风格\\标题.jpg");
  6161. filesarray2.Add("图片-红色风格\\背景.jpg");
  6162. filesarray2.Add("skin\\6.lia");
  6163. filesarray2.Add("图片\\掌中宝.jpg");
  6164. filesarray2.Add("regsvr32.exe");
  6165. filesarray2.Add("MSCHRT20.OCX"); // 26. // Jeff.2014.09.06.添加MSCHRT20.OCX,由服务器传递;
  6166. int i = 0;
  6167. for ( i = 0; i < filesarray.GetSize(); i++)
  6168. {
  6169. g_filedatearray.Add(GetModifyTime(g_mainpath + "\\系统文件\\" + filesarray.ElementAt(i)));
  6170. }
  6171. g_filedatearraynew.Copy(filesarray2);
  6172. for (i = 0; i < filesarray2.GetSize(); i++)
  6173. {
  6174. g_filedatearraynew.Add(GetFileSize(g_mainpath + "\\系统文件\\" + filesarray2.ElementAt(i)));
  6175. }
  6176. }
  6177. //extern CString g_sdomain;
  6178. #ifdef ENTERPRISE_VERSION
  6179. CString g_bMain;
  6180. #endif
  6181. void CDBServerDlg::LoadBranchInfo()
  6182. {
  6183. }
  6184. void CDBServerDlg::ReleaseBranchDB()
  6185. {
  6186. }
  6187. //savebranchinfo
  6188. void CDBServerDlg::LoadBranchInfo2()
  6189. {
  6190. }
  6191. int __cdecl CompareByLabel6(const void *elem1, const void *elem2)
  6192. {
  6193. CStringArray *p1 = (CStringArray*)elem1;
  6194. CStringArray *p2 = (CStringArray*)elem2;
  6195. return atoi(p1->ElementAt(5)) > atoi(p2->ElementAt(5));
  6196. }
  6197. //--------------------------------------------------------------
  6198. // Remark by Jeff 2014.12.16
  6199. // 函数:CheckMemberMsg
  6200. // 描述:
  6201. // 参数:
  6202. // 返回:
  6203. //
  6204. // 调用关系:
  6205. // 1.CheckMemberMsg() 只由 CDBServerDlg::SetTimer(4) 调用,调用频率2分钟,周期数直到程序结束。
  6206. // 2.CDBServerDlg::SetTimer(4) 由 CDBServerDlg::SetTimer(2) 调用,调用频率10毫秒,只有一个周期。
  6207. // 3.CDBServerDlg::SetTimer(2) 由 CDBServerDlg::OnInitDialog() 调用.
  6208. //--------------------------------------------------------------
  6209. void CDBServerDlg::CheckMemberMsg() // Jeff.由定时器SetTimer两分钟执行一次
  6210. {
  6211. try
  6212. {
  6213. g_curdb = &g_db;
  6214. CString sql = "delete from sendreg where [log]='0/0'";
  6215. MyExecuteSQL(&g_db, sql);
  6216. {
  6217. CStringArray idarray;
  6218. CString timestamp;
  6219. CTime tm = CTime::GetCurrentTime();
  6220. tm -= CTimeSpan(0, 1, 0, 0);
  6221. timestamp = tm.Format("%Y%m%d%H%M%S");
  6222. CRecordset myset(g_curdb);
  6223. CString sql = "select [autoid] from sendregdelay where [timestamp]<'" + timestamp + "'";
  6224. myset.Open(CRecordset::forwardOnly, sql);
  6225. while (!myset.IsEOF())
  6226. {
  6227. myset.GetFieldValue("autoid", sql);
  6228. idarray.Add(sql);
  6229. myset.MoveNext();
  6230. }
  6231. myset.Close();
  6232. for (int i = 0; i < idarray.GetSize(); i++)
  6233. {
  6234. // Jeff.deal
  6235. //sql.Format("insert into [db].[dbo].sendreg([timestamp],[msgcount],[log],[status],[issended],[isautosend],[phones],[content],[ren]) select [timestamp],[msgcount],[log],[status],[issended],[isautosend],[phones],[content],[ren] from [db].[dbo].sendregdelay where [autoid]=%d", atol(idarray.ElementAt(i)));
  6236. sql.Format("insert into sendreg([msgtype],[timestamp],[msgcount],[log],[status],[issended],[isautosend],[phones],[content],[ren]) select [msgtype],[timestamp],[msgcount],[log],[status],[issended],[isautosend],[phones],[content],[ren] from sendregdelay where [autoid]=%d", atol(idarray.ElementAt(i)));
  6237. MyExecuteSQL(&g_db, sql);
  6238. sql.Format("delete from sendregdelay where [autoid]=%d", atol(idarray.ElementAt(i)));
  6239. MyExecuteSQL(&g_db, sql);
  6240. }
  6241. }
  6242. int covertrate = 100;
  6243. CString spoint;
  6244. {
  6245. CRecordset myset(g_curdb);
  6246. CString sql = "select * from version";
  6247. myset.Open(CRecordset::forwardOnly, sql);
  6248. myset.GetFieldValue("rate2", sql);
  6249. myset.Close();
  6250. covertrate = atoi(sql);
  6251. if (covertrate == 0)covertrate = 100;
  6252. }
  6253. CString filter;
  6254. CArray<CStringArray, CStringArray>rulearray;
  6255. CArray<CStringArray, CStringArray>memberarray;
  6256. {
  6257. CRecordset myset(g_curdb);
  6258. CString sql = "select count(*) as cot from msgtemp2";
  6259. if (!filter.IsEmpty())sql += " where " + filter;
  6260. myset.Open(CRecordset::forwardOnly, sql);
  6261. myset.GetFieldValue("cot", sql);
  6262. myset.Close();
  6263. int count = atol(sql);
  6264. rulearray.SetSize(count, 1);
  6265. CRstmsgtemp2 rsSt; rsSt.m_pDatabase = g_curdb;
  6266. if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  6267. rsSt.Open();
  6268. DWORD ii = 0;
  6269. while (!rsSt.IsEOF())
  6270. {
  6271. rulearray.ElementAt(ii).RemoveAll();
  6272. rulearray.ElementAt(ii).Add(rsSt.name);
  6273. rulearray.ElementAt(ii).Add(rsSt.content1);
  6274. rulearray.ElementAt(ii).Add(rsSt.content2);
  6275. rulearray.ElementAt(ii).Add(rsSt.check1);
  6276. rulearray.ElementAt(ii).Add(rsSt.check2);
  6277. rulearray.ElementAt(ii).Add(rsSt.point);
  6278. ii++;
  6279. rsSt.MoveNext();
  6280. if (rulearray.GetSize() <= ii)break;
  6281. }
  6282. rsSt.Close(); rulearray.SetSize(ii, 1);
  6283. }
  6284. if (rulearray.GetSize() == 0)return;
  6285. qsort(static_cast<void*>(&rulearray[0]), rulearray.GetSize(), sizeof(rulearray[0]), CompareByLabel6);
  6286. /////////////
  6287. {
  6288. CRecordset myset(g_curdb);
  6289. CString sql = "select count(*) as cot from membermanage"; if (!filter.IsEmpty())sql += " where " + filter;
  6290. myset.Open(CRecordset::forwardOnly, sql);
  6291. myset.GetFieldValue("cot", sql);
  6292. myset.Close();
  6293. memberarray.SetSize(atol(sql), 1);
  6294. RstMemberReg rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  6295. rsSt.Open();
  6296. DWORD ii = 0;
  6297. if (covertrate != 100)
  6298. {
  6299. while (!rsSt.IsEOF())
  6300. {
  6301. memberarray.ElementAt(ii).RemoveAll();
  6302. memberarray.ElementAt(ii).Add(rsSt.m_memberno);
  6303. memberarray.ElementAt(ii).Add(rsSt.m_name);
  6304. memberarray.ElementAt(ii).Add(rsSt.m_sex);
  6305. memberarray.ElementAt(ii).Add(rsSt.m_phone);
  6306. spoint.Format("%d", atoi(rsSt.m_money)*covertrate / 100);
  6307. memberarray.ElementAt(ii).Add(spoint);
  6308. memberarray.ElementAt(ii).Add(rsSt.m_sendmark1);
  6309. memberarray.ElementAt(ii).Add(rsSt.m_sendmark2);
  6310. ii++;
  6311. rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
  6312. }
  6313. }
  6314. else
  6315. {
  6316. while (!rsSt.IsEOF())
  6317. {
  6318. memberarray.ElementAt(ii).RemoveAll();
  6319. memberarray.ElementAt(ii).Add(rsSt.m_memberno);
  6320. memberarray.ElementAt(ii).Add(rsSt.m_name);
  6321. memberarray.ElementAt(ii).Add(rsSt.m_sex);
  6322. memberarray.ElementAt(ii).Add(rsSt.m_phone);
  6323. memberarray.ElementAt(ii).Add(rsSt.m_money);
  6324. memberarray.ElementAt(ii).Add(rsSt.m_sendmark1);
  6325. memberarray.ElementAt(ii).Add(rsSt.m_sendmark2);
  6326. ii++;
  6327. rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
  6328. }
  6329. }
  6330. rsSt.Close(); memberarray.SetSize(ii, 1);
  6331. }
  6332. CString memberno, name, sex, phone, point, mark1, mark2, rulename, rulecheck1, rulecheck2, rulepoint, rulecontent1, rulecontent2;
  6333. for (int i = 0; i < memberarray.GetSize(); i++)
  6334. {
  6335. memberno = memberarray.ElementAt(i).ElementAt(0);
  6336. name = memberarray.ElementAt(i).ElementAt(1);
  6337. sex = memberarray.ElementAt(i).ElementAt(2);
  6338. phone = memberarray.ElementAt(i).ElementAt(3);
  6339. point = memberarray.ElementAt(i).ElementAt(4);
  6340. mark1 = "," + memberarray.ElementAt(i).ElementAt(5) + ",";
  6341. mark2 = "," + memberarray.ElementAt(i).ElementAt(6) + ",";
  6342. if (atoi(point) == 0)continue;
  6343. if (phone.IsEmpty())continue;
  6344. if (-1 == CheckPhoneType(phone))continue;
  6345. int j = 0;
  6346. for ( j = 0; j < rulearray.GetSize(); j++)
  6347. {
  6348. if (mark1.GetLength()>4000)break;
  6349. rulename = "," + rulearray.ElementAt(j).ElementAt(0) + ",";
  6350. rulecontent1 = name + rulearray.ElementAt(j).ElementAt(1);
  6351. rulecontent2 = name + rulearray.ElementAt(j).ElementAt(2);
  6352. rulecheck1 = rulearray.ElementAt(j).ElementAt(3);
  6353. rulecheck2 = rulearray.ElementAt(j).ElementAt(4);
  6354. rulepoint = rulearray.ElementAt(j).ElementAt(5);
  6355. if (atoi(rulecheck1) == 0 && atoi(rulecheck2) == 0)continue;
  6356. if (atoi(rulecheck1))
  6357. {
  6358. if (rulecontent1.IsEmpty())continue;
  6359. if (mark1.Find(rulename) != -1)break;
  6360. if (atoi(point) >= atoi(rulepoint))continue;
  6361. if (atoi(point) < atoi(rulepoint) * 80 / 100)continue;
  6362. // if(sex=="男")
  6363. // rulecontent1.Replace ("xxx先生/女士", name+"先生");
  6364. // else
  6365. // rulecontent1.Replace ("xxx先生/女士", name+"女士");
  6366. int count = GetLengthEx(rulecontent1) / MSG_LENGTH;
  6367. if (GetLengthEx(rulecontent1) % MSG_LENGTH)
  6368. count++;
  6369. int phonenum = 1;
  6370. count *= phonenum;
  6371. CString scount;
  6372. scount.Format("%d", count);
  6373. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  6374. CString sql;
  6375. mark1.TrimLeft(",");
  6376. mark1.TrimRight(",");
  6377. if (mark1.IsEmpty() == 0)
  6378. mark1 += ",";
  6379. rulename.TrimLeft(",");
  6380. rulename.TrimRight(",");
  6381. mark1 += rulename;
  6382. sql = "update membermanage set sendmark1='" + mark1 + "' where memberno='" + memberno + "'";
  6383. MyExecuteSQL(&g_db, sql);
  6384. mark1 = "," + mark1 + ",";
  6385. sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + phone + "','" + rulecontent1 + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  6386. MyExecuteSQL(&g_db, sql);
  6387. }
  6388. }
  6389. ///////////////////
  6390. BOOL bSended = 0;
  6391. for (j = 0; j < rulearray.GetSize(); j++)
  6392. {
  6393. if (mark2.GetLength() > 4000)break;
  6394. if (bSended)break;
  6395. rulename = "," + rulearray.ElementAt(j).ElementAt(0) + ",";
  6396. rulecontent1 = name + rulearray.ElementAt(j).ElementAt(1);
  6397. rulecontent2 = name + rulearray.ElementAt(j).ElementAt(2);
  6398. rulecheck1 = rulearray.ElementAt(j).ElementAt(3);
  6399. rulecheck2 = rulearray.ElementAt(j).ElementAt(4);
  6400. rulepoint = rulearray.ElementAt(j).ElementAt(5);
  6401. if (atoi(rulecheck1) == 0 && atoi(rulecheck2) == 0)continue;
  6402. if (atoi(rulecheck2))
  6403. {
  6404. if (rulecontent2.IsEmpty())continue;
  6405. if (mark2.Find(rulename) != -1)break;
  6406. if (atoi(point) < atoi(rulepoint))continue;
  6407. // if(sex=="男")
  6408. // rulecontent2.Replace ("xxx先生/女士", name+"先生");
  6409. // else
  6410. // rulecontent2.Replace ("xxx先生/女士", name+"女士");
  6411. int count = GetLengthEx(rulecontent2) / MSG_LENGTH;
  6412. if (GetLengthEx(rulecontent2) % MSG_LENGTH)
  6413. count++;
  6414. int phonenum = 1;
  6415. count *= phonenum;
  6416. CString scount;
  6417. scount.Format("%d", count);
  6418. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  6419. CString sql;
  6420. mark2.TrimLeft(",");
  6421. mark2.TrimRight(",");
  6422. if (mark2.IsEmpty() == 0)
  6423. mark2 += ",";
  6424. rulename.TrimLeft(",");
  6425. rulename.TrimRight(",");
  6426. mark2 += rulename;
  6427. sql = "update membermanage set sendmark2='" + mark2 + "' where memberno='" + memberno + "'";
  6428. MyExecuteSQL(&g_db, sql);
  6429. mark2 = "," + mark2 + ",";
  6430. sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + phone + "','" + rulecontent2 + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  6431. MyExecuteSQL(&g_db, sql);
  6432. bSended = 1;
  6433. }
  6434. }
  6435. }
  6436. }
  6437. #if 1
  6438. catch (...)
  6439. {
  6440. WriteTextLog("出错2");
  6441. }
  6442. #else // Jeff.add
  6443. catch (CDBException *e)
  6444. {
  6445. WriteTextLog(e->m_strError);
  6446. e->Delete();
  6447. }
  6448. #endif
  6449. }
  6450. void CDBServerDlg::CheckBakState() // Jeff.检查数据库bakstate表;
  6451. {
  6452. try
  6453. {
  6454. g_curdb = &g_db;
  6455. CString filter;
  6456. CArray<CStringArray, CStringArray> strArray;
  6457. CRecordset myset(g_curdb);
  6458. CString sql = "select count(*) as cot from bakstate";
  6459. if (!filter.IsEmpty())
  6460. sql += " where " + filter;
  6461. myset.Open(CRecordset::forwardOnly, sql);
  6462. myset.GetFieldValue("cot", sql);
  6463. myset.Close();
  6464. int count = atol(sql);
  6465. strArray.SetSize(count, 1);
  6466. CRstbakstate rsSt;
  6467. rsSt.m_pDatabase = g_curdb;
  6468. if (!filter.IsEmpty())
  6469. rsSt.m_strFilter = filter;
  6470. rsSt.Open();
  6471. int ii = 0;
  6472. while (!rsSt.IsEOF())
  6473. {
  6474. strArray.ElementAt(ii).RemoveAll();
  6475. strArray.ElementAt(ii).Add(rsSt.date);
  6476. strArray.ElementAt(ii).Add(rsSt.photo);
  6477. strArray.ElementAt(ii).Add(rsSt.info);
  6478. ii++;
  6479. rsSt.MoveNext();
  6480. if (strArray.GetSize() <= ii)
  6481. break;
  6482. }
  6483. rsSt.Close(); strArray.SetSize(ii, 1);
  6484. while (strArray.GetSize() > 7)
  6485. {
  6486. CString sql = "delete from bakstate where [date]='" + strArray.ElementAt(0).ElementAt(0) + "'";
  6487. MyExecuteSQL(&g_db, sql);
  6488. strArray.RemoveAt(0);
  6489. }
  6490. CString path;
  6491. path.Format("%s\\log.txt", g_mainpath);
  6492. if (::PathFileExists(path))
  6493. {
  6494. CString str;
  6495. CStdioFile fp;
  6496. if (fp.Open(path, CFile::modeRead))
  6497. {
  6498. CString temp;
  6499. fp.ReadString(temp);
  6500. CString date = temp; date.TrimRight();
  6501. while (!feof(fp.m_pStream))
  6502. {
  6503. fp.ReadString(temp);
  6504. str += temp;
  6505. }
  6506. fp.Close();
  6507. if (date.GetLength() != 10)return;
  6508. BOOL bBak = 0;
  6509. int i = 0;
  6510. for ( i = 0; i < strArray.GetSize(); i++)
  6511. {
  6512. if (date == strArray.ElementAt(i).ElementAt(0))
  6513. {
  6514. bBak = 1;
  6515. break;
  6516. }
  6517. }
  6518. if (bBak == 0)
  6519. {
  6520. CString state1 = "0";
  6521. CString state2 = "0";
  6522. if (str.Find("照片备份成功") != -1)state1 = "1";
  6523. if (str.Find("资料备份成功") != -1)state2 = "1";
  6524. sql = "insert into bakstate([date],[photo],[info])values('" + date + "','" + state1 + "','" + state2 + "')";
  6525. MyExecuteSQL(&g_db, sql);
  6526. }
  6527. else
  6528. {
  6529. CString state1 = "0";
  6530. CString state2 = "0";
  6531. if (str.Find("照片备份成功") != -1)state1 = "1";
  6532. if (str.Find("资料备份成功") != -1)state2 = "1";
  6533. sql = "update bakstate set [photo]='" + state1 + "',[info]='" + state2 + "' where [date]='" + date + "'";
  6534. MyExecuteSQL(&g_db, sql);
  6535. }
  6536. //判断昨天
  6537. CTime tm = CTime::GetCurrentTime();
  6538. CTimeSpan dt(1, 0, 0, 0);
  6539. tm -= dt;
  6540. CString yesterday = tm.Format("%Y-%m-%d");
  6541. for (i = 0; i < strArray.GetSize(); i++)
  6542. {
  6543. if (yesterday == strArray.ElementAt(i).ElementAt(0))return;
  6544. }
  6545. if (yesterday == date)return;
  6546. sql = "insert into bakstate([date],[photo],[info])values('" + yesterday + "','0','0')";
  6547. MyExecuteSQL(&g_db, sql);
  6548. }
  6549. else
  6550. {
  6551. CTime tm = CTime::GetCurrentTime();
  6552. CTimeSpan dt(1, 0, 0, 0);
  6553. tm -= dt;
  6554. sql = "insert into bakstate([date],[photo],[info])values('" + tm.Format("%Y-%m-%d") + "','0','0')";
  6555. MyExecuteSQL(&g_db, sql);
  6556. }
  6557. }
  6558. else
  6559. {
  6560. CTime tm = CTime::GetCurrentTime();
  6561. CTimeSpan dt(1, 0, 0, 0);
  6562. tm -= dt;
  6563. for (int i = 0; i < strArray.GetSize(); i++)
  6564. {
  6565. if (tm.Format("%Y-%m-%d") == strArray.ElementAt(i).ElementAt(0))return;
  6566. }
  6567. sql = "insert into bakstate([date],[photo],[info])values('" + tm.Format("%Y-%m-%d") + "','0','0')";
  6568. MyExecuteSQL(&g_db, sql);
  6569. }
  6570. }
  6571. catch (...)
  6572. {
  6573. WriteTextLog("出错3");
  6574. }
  6575. }
  6576. //数据备份
  6577. CString CDBServerDlg::GetRegCode(int m_id, int m_time1, int m_time2)
  6578. {
  6579. return "";
  6580. }
  6581. int g_ndogtimes = 0;
  6582. void CDBServerDlg::CheckRegCode() // 检查注册码信息;
  6583. {
  6584. }
  6585. BOOL IsCtrlDown()
  6586. {
  6587. short state = GetKeyState(VK_LCONTROL);
  6588. BYTE sta = (BYTE)(state >> 8);
  6589. state = GetKeyState(VK_RCONTROL);
  6590. BYTE sta2 = (BYTE)(state >> 8);
  6591. if (sta || sta2)
  6592. return 1;
  6593. else
  6594. return 0;
  6595. }
  6596. //extern CTime GetTmFromStr(CString date);
  6597. BOOL CDBServerDlg::PreTranslateMessage(MSG* pMsg)
  6598. {
  6599. if (pMsg->message == WM_KEYDOWN)
  6600. {
  6601. switch (pMsg->wParam)
  6602. {
  6603. case 67:
  6604. AfxMessageBox("c");
  6605. break;
  6606. case VK_F8:
  6607. if (IsCtrlDown())GenYLGL();
  6608. break;
  6609. case VK_F9:
  6610. if (IsCtrlDown())
  6611. {
  6612. CString g_domain;
  6613. CArray<CStringArray, CStringArray>g_List1array;
  6614. CString autorunpath = g_mainpath + "\\branchdindan.dat";
  6615. CFile fp;
  6616. if (fp.Open(autorunpath, CFile::modeRead))
  6617. {
  6618. int nMessageLen = fp.GetLength();
  6619. BYTE *pData = new BYTE[nMessageLen];
  6620. fp.Read(pData, nMessageLen);
  6621. fp.Close();
  6622. BYTE *szChatMessage = pData;
  6623. int count;
  6624. memcpy(&count, szChatMessage + (nMessageLen - sizeof(int)), sizeof(int));
  6625. CMemFile memfile;
  6626. memfile.Attach(szChatMessage, nMessageLen);
  6627. CArchive ar(&memfile, CArchive::load);
  6628. g_List1array.SetSize(count);
  6629. for (int ii = 0; ii < g_List1array.GetSize(); ii++)
  6630. {
  6631. g_List1array.ElementAt(ii).Serialize(ar);
  6632. }
  6633. ar.Close();
  6634. memfile.Detach();
  6635. delete[]pData;
  6636. }
  6637. CString time5, id;
  6638. for (int i = 0; i < g_List1array.GetSize(); i++)
  6639. {
  6640. g_domain = "\\" + g_List1array.ElementAt(i).ElementAt(0);
  6641. id = g_List1array.ElementAt(i).ElementAt(1);
  6642. time5 = g_List1array.ElementAt(i).ElementAt(2);
  6643. WriteTextLog(g_domain + "\\" + id + time5);
  6644. }
  6645. }
  6646. break;
  6647. #ifdef LYFZ_VERSION
  6648. case VK_F7:
  6649. if (IsCtrlDown())
  6650. {
  6651. if (AfxMessageBox("是否继续?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return 1;
  6652. CStringArray array1;
  6653. CRstDindanForm rsSt; rsSt.m_pDatabase = &g_db;
  6654. rsSt.Open();
  6655. while (!rsSt.IsEOF())
  6656. {
  6657. array1.Add(rsSt.id);
  6658. rsSt.MoveNext();
  6659. }
  6660. rsSt.Close();
  6661. CString id, sql;
  6662. sql.Format("update dindan set status5='%s'", "无");
  6663. MyExecuteSQL(&g_db, sql);
  6664. BOOL bHasPhoto = 0;
  6665. for (int i = 0; i < array1.GetSize(); i++)
  6666. {
  6667. id = array1.ElementAt(i);
  6668. bHasPhoto = 0;
  6669. CRstClientPhoto rsSt;
  6670. rsSt.m_strFilter = "id='" + id + "'";
  6671. rsSt.Open();
  6672. if (rsSt.photo.m_dwDataLength>0)
  6673. {
  6674. bHasPhoto = 1;
  6675. }
  6676. rsSt.Close();
  6677. if (bHasPhoto)
  6678. {
  6679. sql.Format("update dindan set status5='%s' where id='%s'", "有", id);
  6680. MyExecuteSQL(&g_db, sql);
  6681. }
  6682. }
  6683. AfxMessageBox("完成");
  6684. }
  6685. break;
  6686. #endif
  6687. case VK_F2:
  6688. if (IsCtrlDown())
  6689. {
  6690. SelYear dlg;
  6691. if (dlg.DoModal() != IDOK)return 1;
  6692. int year = dlg.m_year;
  6693. int hisyear = CTime::GetCurrentTime().GetYear() - 1;
  6694. if (year == hisyear)
  6695. {
  6696. AfxMessageBox("不能选该年");
  6697. return 1;
  6698. }
  6699. CString str;
  6700. str.Format("此操作将%d年数据导入%d中, 确认吗?", year, hisyear);
  6701. if (AfxMessageBox(str, MB_YESNO | MB_ICONINFORMATION) != IDYES)return 1;
  6702. CDatabase *pdb = GetDB(year);
  6703. if (pdb == NULL)
  6704. {
  6705. str.Format("没有找到%d, 操作失败", year);
  6706. AfxMessageBox(str); return 1;
  6707. }
  6708. str.Format("开始%d->%d", year, hisyear);
  6709. WriteTextLog(str);
  6710. CheckHistoryData(pdb, year);
  6711. str.Format("%d->%d完成", year, hisyear);
  6712. WriteTextLog(str);
  6713. }
  6714. break;
  6715. case VK_F3:
  6716. if (IsCtrlDown())
  6717. {
  6718. SelYear dlg;
  6719. if (dlg.DoModal() != IDOK)return 1;
  6720. int year = dlg.m_year;
  6721. int hisyear = CTime::GetCurrentTime().GetYear() - 1;
  6722. if (year == hisyear)
  6723. {
  6724. AfxMessageBox("不能选该年");
  6725. return 1;
  6726. }
  6727. CString str;
  6728. str.Format("此操作将%d年数据导入%d中(当前数据库中没有的订单全转), 确认吗?", year, hisyear);
  6729. if (AfxMessageBox(str, MB_YESNO | MB_ICONINFORMATION) != IDYES)return 1;
  6730. CDatabase *pdb = GetDB(year);
  6731. if (pdb == NULL)
  6732. {
  6733. str.Format("没有找到%d, 操作失败", year);
  6734. AfxMessageBox(str); return 1;
  6735. }
  6736. str.Format("开始%d->%d", year, hisyear);
  6737. WriteTextLog(str);
  6738. CheckHistoryData(pdb, year, 1);
  6739. str.Format("%d->%d完成", year, hisyear);
  6740. WriteTextLog(str);
  6741. }
  6742. break;
  6743. case VK_F1:
  6744. CString str;
  6745. if (g_conniparray.GetSize() == 0)str = "当前无客户端连接至服务器!";
  6746. for (int i = 0; i < g_conniparray.GetSize(); i++)
  6747. {
  6748. str += "\r\n连接ip:" + g_conniparray.ElementAt(i);
  6749. }
  6750. AfxMessageBox(str);
  6751. #ifdef CONNCOUNT_VERSION
  6752. // CStringArray g_conniparray;
  6753. #endif
  6754. return 1;
  6755. }
  6756. }
  6757. return CDialog::PreTranslateMessage(pMsg);
  6758. }
  6759. void CDBServerDlg::GenUPhoneData()
  6760. {
  6761. return;
  6762. MyLock lock("processChatMessageRequestxiao");
  6763. CArray<int, int>codearray;
  6764. codearray.Add(80);
  6765. codearray.Add(90);
  6766. codearray.Add(11);
  6767. codearray.Add(138);
  6768. codearray.Add(24);
  6769. codearray.Add(181);
  6770. codearray.Add(65);
  6771. codearray.Add(56);
  6772. codearray.Add(179);
  6773. codearray.Add(53);
  6774. CFile fp;
  6775. CString savepath, g_path1;
  6776. char server[50];
  6777. DWORD leng = 50;
  6778. ::GetComputerName(server, &leng);
  6779. g_path1 = server;
  6780. g_path1 = "\\\\" + g_path1 + "\\电话录音(管理软件)$";
  6781. GetPathFromNetShareName("电话录音(管理软件)$", g_path1);
  6782. if (g_path1.IsEmpty())
  6783. {
  6784. WriteTextLog("获取电精灵数据出错");
  6785. return;
  6786. }
  6787. try
  6788. {
  6789. int aa = 0;
  6790. g_curdb = &g_db;
  6791. savepath.Format("%s\\uphonedata%d.dat", g_path1, aa);
  6792. ::DeleteFile(savepath); // 删除 uphonedata%d.dat 文件;
  6793. if (fp.Open(savepath, CFile::modeCreate | CFile::modeWrite) == 0)
  6794. {
  6795. WriteTextLog("更新来电精灵数据出错");
  6796. return;
  6797. }
  6798. CConnectSocket consock;
  6799. consock.m_pConndb = &g_db;
  6800. for (int i = 0; i < codearray.GetSize(); i++)
  6801. {
  6802. BYTE code = codearray.ElementAt(i);
  6803. DWORD length, arraysize;
  6804. BYTE *pReturn = NULL;
  6805. consock.GetDataFromCode(code, &pReturn, length, arraysize, "");
  6806. fp.Write(&code, sizeof(BYTE));
  6807. fp.Write(&length, sizeof(DWORD));
  6808. fp.Write(&arraysize, sizeof(DWORD));
  6809. fp.Write(pReturn, length);
  6810. }
  6811. fp.Close();
  6812. }
  6813. catch (...)
  6814. {
  6815. WriteTextLog("获取来电精灵数据出错");
  6816. }
  6817. }
  6818. //initlia
  6819. void CDBServerDlg::LoadHistoryDB() // 加载历史数据库;
  6820. {
  6821. CString path;
  6822. CString sql;
  6823. sql = "delete from historydb";
  6824. MyExecuteSQL(&g_db, sql);
  6825. CDatabase g_masterdb;
  6826. try
  6827. {
  6828. CString strCon;
  6829. strCon.Format(_T("driver={SQL Server};Server=%s;DATABASE=master;%s"), g_strdbServrename, g_strdbpsw);
  6830. g_masterdb.OpenEx(strCon, CDatabase::noOdbcDialog);
  6831. }
  6832. catch (CDBException * e)
  6833. {
  6834. e->Delete();
  6835. }
  6836. for (int i = CTime::GetCurrentTime().GetYear() - 1; i >= 2009; i--)
  6837. {
  6838. CDatabase *db = new CDatabase;
  6839. try
  6840. {
  6841. CString strCon;
  6842. strCon.Format(_T("driver={SQL Server};Server=%s;DATABASE=%d;%s"), g_strdbServrename, i, g_strdbpsw);
  6843. db->OpenEx(strCon, CDatabase::noOdbcDialog);
  6844. g_nYearArray.Add(i);
  6845. g_dbHistoryArray.Add(db);
  6846. sql.Format("insert into [historydb]([year])values('%d')", i);
  6847. MyExecuteSQL(&g_db, sql);
  6848. }
  6849. catch (CDBException * e)
  6850. {
  6851. CString strPathOfYearmdf;
  6852. CString strPathOfYearldf;
  6853. CString sql;
  6854. strPathOfYearmdf.Format("%s\\数据\\%d.mdf", g_mainpath, i);
  6855. strPathOfYearldf.Format("%s\\数据\\%d_log.LDF", g_mainpath, i);
  6856. if (PathFileExists(strPathOfYearmdf))
  6857. {
  6858. BOOL bLog = 0;
  6859. if (PathFileExists(strPathOfYearldf))
  6860. {
  6861. bLog = 1;
  6862. }
  6863. g_masterdb.SetQueryTimeout(600);
  6864. if (bLog)
  6865. sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", i, strPathOfYearmdf, strPathOfYearldf);
  6866. else
  6867. sql.Format("exec sp_attach_db '%d',@filename1='%s'", i, strPathOfYearmdf);
  6868. try
  6869. {
  6870. g_masterdb.ExecuteSQL(sql);
  6871. }
  6872. catch (CDBException * e)
  6873. {
  6874. WriteTextLog(e->m_strError);
  6875. WriteTextLog("历史数据库初始化失败!!");
  6876. g_masterdb.SetQueryTimeout(100);
  6877. e->Delete();
  6878. break;
  6879. }
  6880. g_masterdb.SetQueryTimeout(100);
  6881. CString strCon;
  6882. strCon.Format(_T("driver={SQL Server};Server=%s;DATABASE=%d;%s"), g_strdbServrename, i, g_strdbpsw);
  6883. db->OpenEx(strCon, CDatabase::noOdbcDialog);
  6884. g_nYearArray.Add(i);
  6885. g_dbHistoryArray.Add(db);
  6886. sql.Format("insert into [historydb]([year])values('%d')", i);
  6887. MyExecuteSQL(&g_db, sql);
  6888. }
  6889. else
  6890. {
  6891. e->Delete();
  6892. break;
  6893. }
  6894. }
  6895. }
  6896. g_masterdb.Close();
  6897. }
  6898. void CDBServerDlg::AddOneConn()
  6899. {
  6900. try
  6901. {
  6902. MyLock lock("AddOneConnxiao");
  6903. if (g_nDBCount >= 200)
  6904. {
  6905. WriteTextLog("连接超数!"); return;
  6906. }
  6907. CDatabase *db = new CDatabase;
  6908. //if(AddConn(db, "db")==0)// Jeff.deal;
  6909. if (AddConn(db, g_szDBName) == 0)
  6910. {
  6911. return;
  6912. }
  6913. g_pDB[g_nDBCount] = db;
  6914. CString dbname;
  6915. for (int i = 0; i < g_nYearArray.GetSize(); i++)
  6916. {
  6917. dbname.Format("%d", g_nYearArray.ElementAt(i));
  6918. CDatabase *db = new CDatabase;
  6919. AddConn(db, dbname);
  6920. g_pHistoryDBarray[g_nDBCount].Add(db);
  6921. }
  6922. g_nDBCount++;
  6923. }
  6924. catch (...)
  6925. {
  6926. WriteTextLog("AddOneConn error");
  6927. }
  6928. }
  6929. void GetOneConn(CDatabase **m_pdb, CArray<CDatabase*, CDatabase*>*m_dbarray, CConnectThread *pThread)
  6930. {
  6931. MyLock lock("GetOneConnxiao");
  6932. ll: for (int i = 0; i < 200; i++)
  6933. {
  6934. if (g_pDB[i] != NULL && g_pThreadPt[i] == NULL)
  6935. {
  6936. *m_pdb = g_pDB[i];
  6937. m_dbarray->Copy(g_pHistoryDBarray[i]);
  6938. g_pThreadPt[i] = pThread;
  6939. return;
  6940. }
  6941. }
  6942. if (g_nDBCount >= 200)
  6943. {
  6944. WriteTextLog("连接超数2!");
  6945. *m_pdb = &g_db;
  6946. m_dbarray->Copy(g_dbHistoryArray);
  6947. return;
  6948. }
  6949. g_pMainWnd->AddOneConn();
  6950. ::Sleep(1000);
  6951. goto ll;
  6952. }
  6953. void CDBServerDlg::CheckConnCount()
  6954. {
  6955. int count = 0;
  6956. for (int i = 0; i < 200; i++)
  6957. {
  6958. if (g_pDB[i] != NULL && g_pThreadPt[i] == NULL)
  6959. {
  6960. count++;
  6961. if (count > 9)
  6962. return;
  6963. }
  6964. }
  6965. AddOneConn();
  6966. }
  6967. //delete from 背景.jpg
  6968. void CDBServerDlg::RestoreHQ()
  6969. {
  6970. CString sql;
  6971. g_curdb = &g_db;
  6972. DWORD ii = 0;
  6973. CArray<CStringArray, CStringArray>g_List1array;
  6974. {
  6975. CRecordset myset(g_curdb);
  6976. CString sql = "select count(*) as cot from dindan";
  6977. myset.Open(CRecordset::forwardOnly, sql);
  6978. myset.GetFieldValue("cot", sql);
  6979. myset.Close();
  6980. int count = atol(sql);
  6981. g_List1array.SetSize(count, 1);
  6982. CRstDindanForm rsSt; rsSt.m_pDatabase = g_curdb;
  6983. rsSt.Open();
  6984. ii = 0;
  6985. while (!rsSt.IsEOF())
  6986. {
  6987. g_List1array.ElementAt(ii).RemoveAll();
  6988. g_List1array.ElementAt(ii).Add(rsSt.id);
  6989. ii++;
  6990. rsSt.MoveNext(); if (g_List1array.GetSize() <= ii)break;
  6991. }
  6992. rsSt.Close(); g_List1array.SetSize(ii, 1);
  6993. }
  6994. for (int i = 0; i < g_List1array.GetSize(); i++)
  6995. {
  6996. // int ret=TransDinDan(pdb1, pdb2, g_List1array.ElementAt (i).ElementAt (0), lastyear);
  6997. // Jeff.deal;
  6998. //sql.Format("SELECT distinct [name],[count] FROM [db].[dbo].[dindansp2] where id='%s' and name in(select spname from shangpin where splb='婚庆服务')", g_List1array.ElementAt (i).ElementAt (0));
  6999. sql.Format("SELECT distinct [name],[count] FROM [dbo].[dindansp2] where id='%s' and name in(select spname from shangpin where splb='婚庆服务')", g_List1array.ElementAt(i).ElementAt(0));
  7000. CRecordset myset(g_curdb);
  7001. myset.Open(CRecordset::forwardOnly, sql);
  7002. CStringArray namearray;
  7003. CStringArray countarray;
  7004. while (!myset.IsEOF())
  7005. {
  7006. sql = "";
  7007. myset.GetFieldValue("name", sql);
  7008. namearray.Add(sql);
  7009. sql = "";
  7010. myset.GetFieldValue("count", sql);
  7011. countarray.Add(sql);
  7012. myset.MoveNext();
  7013. }
  7014. myset.Close();
  7015. for (int j = 0; j < namearray.GetSize(); j++)
  7016. {
  7017. CString spid, spjiage2;
  7018. // WriteTextLog("name:"+namearray.ElementAt (j));
  7019. // Jeff.deal;
  7020. //sql.Format("SELECT [spid],[spjiage2] FROM [db].[dbo].[shangpin] where spname='%s'", namearray.ElementAt (j));
  7021. sql.Format("SELECT [spid],[spjiage2] FROM [dbo].[shangpin] where spname='%s'", namearray.ElementAt(j));
  7022. //WriteTextLog(sql);
  7023. CRecordset myset(g_curdb);
  7024. myset.Open(CRecordset::forwardOnly, sql);
  7025. if (!myset.IsEOF())
  7026. {
  7027. myset.GetFieldValue("spid", spid);
  7028. myset.GetFieldValue("spjiage2", spjiage2);
  7029. }
  7030. myset.Close();
  7031. // Jeff.deal;
  7032. //sql.Format("SELECT count(*) as cot FROM [db].[dbo].[dindansp] where name='%s' and id='%s' and kind='2'", namearray.ElementAt (j), g_List1array.ElementAt (i).ElementAt (0));
  7033. sql.Format("SELECT count(*) as cot FROM [dbo].[dindansp] where name='%s' and id='%s' and kind='2'", namearray.ElementAt(j), g_List1array.ElementAt(i).ElementAt(0));
  7034. myset.Open(CRecordset::forwardOnly, sql);
  7035. sql = "";
  7036. if (!myset.IsEOF())
  7037. {
  7038. myset.GetFieldValue("cot", sql);
  7039. }
  7040. myset.Close();
  7041. if (atoi(sql))continue;
  7042. sql.Format("insert into [dindansp]([id],[name],[shuliang],[price],[spid],[kind])values('%s','%s','%s','%s','%s','%s')",
  7043. g_List1array.ElementAt(i).ElementAt(0), namearray.ElementAt(j), countarray.ElementAt(j), spjiage2, spid, "2");
  7044. //WriteTextLog(sql);
  7045. g_db.ExecuteSQL(sql);
  7046. }
  7047. }
  7048. }
  7049. void CDBServerDlg::ManagePhoto()
  7050. {
  7051. // CClientCenter dlg1;
  7052. // dlg1.DoModal ();
  7053. ShowPic3 dlg;
  7054. dlg.DoModal();
  7055. }
  7056. //数据备份(管理软件)$
  7057. //--------------------------------------------------------------------------
  7058. // Remark by Jeff:2014.10.22
  7059. // 函数:AutoDelBakPhoto
  7060. // 描述:自动删除取件后的订单备份相片,包括客户备份原片、备份初修片、备份精修片、备份设计片。
  7061. // 参数:#
  7062. // 返回:#
  7063. //
  7064. // 调用关系:
  7065. // 1.AutoDelBakPhoto()由 BakPhoto()调用。
  7066. // 2.BakPhoto() 由CDBServerDlg::SetTimer(4) 调用,调用频率2分钟,周期数直到程序结束。
  7067. // 3.CDBServerDlg::SetTimer(4) 由 CDBServerDlg::SetTimer(2) 调用,调用频率10毫秒,只有一个周期。
  7068. // 4.CDBServerDlg::SetTimer(2) 由 CDBServerDlg::OnInitDialog() 调用.
  7069. //
  7070. //--------------------------------------------------------------------------
  7071. void CDBServerDlg::AutoDelBakPhoto()
  7072. {
  7073. try
  7074. {
  7075. g_curdb = &g_db;
  7076. CString m_check1, m_check2, m_check3, m_check4;
  7077. CString m_edit1, m_edit2, m_edit3, m_edit4;
  7078. CString g_path1;
  7079. CString g_path2;
  7080. CString g_path3;
  7081. CString g_path4;
  7082. CString m_bakserver1, m_bakserver2, m_bakserver3, m_bakserver4;
  7083. {
  7084. CRstversion rsSt; rsSt.m_pDatabase = g_curdb;
  7085. rsSt.Open();
  7086. if (!rsSt.IsEOF())
  7087. {
  7088. m_check1 = rsSt.m_delcheck1;
  7089. m_check2 = rsSt.m_delcheck2;
  7090. m_check3 = rsSt.m_delcheck3;
  7091. m_check4 = rsSt.m_delcheck4;
  7092. m_edit1 = rsSt.m_deledit1;
  7093. m_edit2 = rsSt.m_deledit2;
  7094. m_edit3 = rsSt.m_deledit3;
  7095. m_edit4 = rsSt.m_deledit4;
  7096. g_path1 = rsSt.m_bakserver1;
  7097. g_path2 = rsSt.m_bakserver2;
  7098. g_path4 = rsSt.m_bakserver3;
  7099. g_path3 = rsSt.m_bakserver4;
  7100. }
  7101. rsSt.Close();
  7102. }
  7103. BOOL bcheck1 = atoi(m_check1);
  7104. BOOL bcheck2 = atoi(m_check2);
  7105. BOOL bcheck3 = atoi(m_check3);
  7106. BOOL bcheck4 = atoi(m_check4);
  7107. if (!(bcheck1 || bcheck2 || bcheck3 || bcheck4))
  7108. {
  7109. return;
  7110. }
  7111. int edit1 = atoi(m_edit1);
  7112. int edit2 = atoi(m_edit2);
  7113. int edit3 = atoi(m_edit3);
  7114. int edit4 = atoi(m_edit4);
  7115. //path
  7116. CStringArray patharray;
  7117. {
  7118. #ifdef CHILD_VERSION
  7119. if (g_path1.Find(":") == -1 && g_path1 != "")
  7120. g_path1 = "\\\\" + g_path1 + "\\客户原片备份(儿童管理软件)$";
  7121. if (1)//(localname.CompareNoCase (g_path1)==0 || CompareIP(localname, g_path1)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\客户原片备份(儿童管理软件)$"))
  7122. GetPathFromNetShareName("客户原片备份(儿童管理软件)$", g_path1);
  7123. if (g_path2.Find(":") == -1 && g_path2 != "")
  7124. g_path2 = "\\\\" + g_path2 + "\\修好的片备份(儿童管理软件)$";
  7125. if (1)//((localname.CompareNoCase (g_path2)==0 || CompareIP(localname, g_path2)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\修好的片备份(儿童管理软件)$"))
  7126. GetPathFromNetShareName("修好的片备份(儿童管理软件)$", g_path2);
  7127. if (g_path4.Find(":") == -1 && g_path4 != "")
  7128. g_path4 = "\\\\" + g_path4 + "\\精修好的片备份(儿童管理软件)$";
  7129. if (1)//((localname.CompareNoCase (g_path4)==0 || CompareIP(localname, g_path4)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\精修好的片备份(儿童管理软件)$"))
  7130. GetPathFromNetShareName("精修好的片备份(儿童管理软件)$", g_path4);
  7131. if (g_path3.Find(":") == -1 && g_path3 != "")
  7132. g_path3 = "\\\\" + g_path3 + "\\设计好的片备份(儿童管理软件)$";
  7133. if (1)//((localname.CompareNoCase (g_path3)==0 || CompareIP(localname, g_path3)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\设计好的片备份(儿童管理软件)$"))
  7134. GetPathFromNetShareName("设计好的片备份(儿童管理软件)$", g_path3);
  7135. #else
  7136. if (g_path1.Find(":") == -1 && g_path1 != "")
  7137. g_path1 = "\\\\" + g_path1 + "\\客户原片备份(管理软件)$";
  7138. if (1)//((localname.CompareNoCase (g_path1)==0 || CompareIP(localname, g_path1)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\客户原片备份(管理软件)$"))
  7139. GetPathFromNetShareName("客户原片备份(管理软件)$", g_path1);
  7140. if (g_path2.Find(":") == -1 && g_path2 != "")
  7141. g_path2 = "\\\\" + g_path2 + "\\修好的片备份(管理软件)$";
  7142. if (1)//((localname.CompareNoCase (g_path2)==0 || CompareIP(localname, g_path2)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\修好的片备份(管理软件)$"))
  7143. GetPathFromNetShareName("修好的片备份(管理软件)$", g_path2);
  7144. if (g_path4.Find(":") == -1 && g_path4 != "")
  7145. g_path4 = "\\\\" + g_path4 + "\\精修好的片备份(管理软件)$";
  7146. if (1)//((localname.CompareNoCase (g_path4)==0 || CompareIP(localname, g_path4)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\精修好的片备份(管理软件)$"))
  7147. GetPathFromNetShareName("精修好的片备份(管理软件)$", g_path4);
  7148. if (g_path3.Find(":") == -1 && g_path3 != "")
  7149. g_path3 = "\\\\" + g_path3 + "\\设计好的片备份(管理软件)$";
  7150. if (1)//((localname.CompareNoCase (g_path3)==0 || CompareIP(localname, g_path3)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\设计好的片备份(管理软件)$"))
  7151. GetPathFromNetShareName("设计好的片备份(管理软件)$", g_path3);
  7152. #endif
  7153. patharray.Add(g_path1);
  7154. patharray.Add(g_path2);
  7155. patharray.Add(g_path4);
  7156. patharray.Add(g_path3);
  7157. }
  7158. if (patharray.GetSize() == 0)return;
  7159. CArray<CDatabase*, CDatabase*>dbarray2;
  7160. dbarray2.Copy(g_dbHistoryArray);
  7161. dbarray2.InsertAt(0, &g_db);
  7162. WriteTextLog("开始删除取件后的备份照片");
  7163. for (int n = 0; n < min(3, dbarray2.GetSize()); n++)
  7164. {
  7165. g_curdb = dbarray2.ElementAt(n);
  7166. DWORD ii = 0;
  7167. CArray<CStringArray, CStringArray>g_List1array;
  7168. {
  7169. CString filter = "status3='OK' and time5 is not null and time5<>''";
  7170. CRecordset myset(g_curdb);
  7171. CString sql = "select count(*) as cot from dindan"; if (!filter.IsEmpty())sql += " where " + filter;
  7172. myset.Open(CRecordset::forwardOnly, sql);
  7173. myset.GetFieldValue("cot", sql);
  7174. myset.Close();
  7175. int count = atol(sql);
  7176. if (count == 0)continue;
  7177. g_List1array.SetSize(count, 1);
  7178. CRstDindanForm rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  7179. rsSt.Open();
  7180. ii = 0;
  7181. while (!rsSt.IsEOF())
  7182. {
  7183. g_List1array.ElementAt(ii).RemoveAll();
  7184. g_List1array.ElementAt(ii).Add(rsSt.id);
  7185. g_List1array.ElementAt(ii).Add(rsSt.time5);
  7186. ii++;
  7187. rsSt.MoveNext(); if (g_List1array.GetSize() <= ii)break;
  7188. }
  7189. rsSt.Close();
  7190. g_List1array.SetSize(ii, 1);
  7191. CString time5, id;
  7192. CTime curtm = CTime::GetCurrentTime();
  7193. CString strtime;
  7194. for (int i = 0; i < g_List1array.GetSize(); i++)
  7195. {
  7196. id = g_List1array.ElementAt(i).ElementAt(0);
  7197. time5 = g_List1array.ElementAt(i).ElementAt(1);
  7198. if (bcheck1)//原片
  7199. {
  7200. CTimeSpan sp(edit1 * 30, 0, 0, 0);
  7201. CTime tm = curtm - sp;
  7202. strtime = tm.Format("%Y-%m-%d");
  7203. if (strtime > time5)
  7204. {
  7205. if (DelPhoto1(patharray.ElementAt(0), g_List1array.ElementAt(i).ElementAt(0)))
  7206. WriteTextLog("原片备份" + patharray.ElementAt(0) + "\\" + g_List1array.ElementAt(i).ElementAt(0));
  7207. // DelPhoto1(patharray2.ElementAt (0),g_List1array.ElementAt (i).ElementAt (0));
  7208. }
  7209. }
  7210. if (bcheck2)
  7211. {
  7212. CTimeSpan sp(edit2 * 30, 0, 0, 0);
  7213. CTime tm = curtm - sp;
  7214. strtime = tm.Format("%Y-%m-%d");
  7215. if (strtime > time5)
  7216. {
  7217. DelPhoto1(patharray.ElementAt(1), g_List1array.ElementAt(i).ElementAt(0));
  7218. // DelPhoto1(patharray2.ElementAt (2),g_List1array.ElementAt (i).ElementAt (0));
  7219. }
  7220. }
  7221. if (bcheck3)
  7222. {
  7223. CTimeSpan sp(edit3 * 30, 0, 0, 0);
  7224. CTime tm = curtm - sp;
  7225. strtime = tm.Format("%Y-%m-%d");
  7226. if (strtime > time5)
  7227. {
  7228. DelPhoto1(patharray.ElementAt(2), g_List1array.ElementAt(i).ElementAt(0));
  7229. // DelPhoto1(patharray2.ElementAt (2),g_List1array.ElementAt (i).ElementAt (0));
  7230. }
  7231. }
  7232. if (bcheck4)
  7233. {
  7234. CTimeSpan sp(edit4 * 30, 0, 0, 0);
  7235. CTime tm = curtm - sp;
  7236. strtime = tm.Format("%Y-%m-%d");
  7237. if (strtime > time5)
  7238. {
  7239. DelPhoto1(patharray.ElementAt(3), g_List1array.ElementAt(i).ElementAt(0));
  7240. }
  7241. }
  7242. }
  7243. }
  7244. }
  7245. g_curdb = &g_db;
  7246. #ifdef ENTERPRISE_VERSION
  7247. WriteTextLog("本店查完,开始检查分店备份");
  7248. CString g_domain;
  7249. CArray<CStringArray, CStringArray>g_List1array;
  7250. CString autorunpath = g_mainpath + "\\branchdindan.dat";
  7251. CFile fp;
  7252. if (fp.Open(autorunpath, CFile::modeRead))
  7253. {
  7254. int nMessageLen = fp.GetLength();
  7255. BYTE *pData = new BYTE[nMessageLen];
  7256. fp.Read(pData, nMessageLen);
  7257. fp.Close();
  7258. BYTE *szChatMessage = pData;
  7259. int count;
  7260. memcpy(&count, szChatMessage+(nMessageLen-sizeof(int)), sizeof(int));
  7261. CMemFile memfile;
  7262. memfile.Attach (szChatMessage, nMessageLen);
  7263. CArchive ar(&memfile, CArchive::load);
  7264. g_List1array.SetSize(count);
  7265. for(int ii=0; ii<g_List1array.GetSize (); ii++)
  7266. {
  7267. g_List1array.ElementAt (ii).Serialize (ar);
  7268. }
  7269. ar.Close();
  7270. memfile.Detach ();
  7271. delete []pData;
  7272. }
  7273. CString time5,id;
  7274. CTime curtm=CTime::GetCurrentTime ();
  7275. CString strtime;
  7276. for(int i=0; i<g_List1array.GetSize (); i++)
  7277. {
  7278. g_domain="\\"+g_List1array.ElementAt (i).ElementAt (0);
  7279. if(g_domain.Find (".ly.com")==-1)continue;
  7280. id=g_List1array.ElementAt (i).ElementAt (1);
  7281. time5=g_List1array.ElementAt (i).ElementAt (2);
  7282. if(bcheck1)//原片
  7283. {
  7284. CTimeSpan sp(edit1*30, 0, 0, 0);
  7285. CTime tm=curtm-sp;
  7286. strtime=tm.Format ("%Y-%m-%d");
  7287. if(strtime>time5)
  7288. {
  7289. if(DelPhoto1(patharray.ElementAt (0)+g_domain,id))
  7290. WriteTextLog("分店原片备份"+ patharray.ElementAt (0)+g_domain+"\\"+id );
  7291. }
  7292. }
  7293. if(bcheck2)
  7294. {
  7295. CTimeSpan sp(edit2*30, 0, 0, 0);
  7296. CTime tm=curtm-sp;
  7297. strtime=tm.Format ("%Y-%m-%d");
  7298. if(strtime>time5)
  7299. {
  7300. DelPhoto1(patharray.ElementAt (1)+g_domain,id);
  7301. // DelPhoto1(patharray2.ElementAt (2),id);
  7302. }
  7303. }
  7304. if(bcheck3)
  7305. {
  7306. CTimeSpan sp(edit3*30, 0, 0, 0);
  7307. CTime tm=curtm-sp;
  7308. strtime=tm.Format ("%Y-%m-%d");
  7309. if(strtime>time5)
  7310. {
  7311. DelPhoto1(patharray.ElementAt (2)+g_domain,id);
  7312. // DelPhoto1(patharray2.ElementAt (2),id);
  7313. }
  7314. }
  7315. if(bcheck4)
  7316. {
  7317. CTimeSpan sp(edit4*30, 0, 0, 0);
  7318. CTime tm=curtm-sp;
  7319. strtime=tm.Format ("%Y-%m-%d");
  7320. if(strtime>time5)
  7321. {
  7322. DelPhoto1(patharray.ElementAt (3)+g_domain,id);
  7323. }
  7324. }
  7325. }
  7326. g_curdb = &g_db;
  7327. #endif
  7328. WriteTextLog("检查删除备份照片完成");
  7329. }
  7330. catch (...)
  7331. {
  7332. WriteTextLog("出错在函数AutoDelBakPhoto中");
  7333. }
  7334. g_curdb = &g_db;
  7335. }
  7336. //10.lia
  7337. //----------------------------------------------------------------------------
  7338. // Remark by Jeff 2014.10.22
  7339. // 函数:GenYLGL
  7340. // 描述:调用本地客户端;
  7341. // 参数:#
  7342. // 返回:#
  7343. //
  7344. // 调用关系:
  7345. // 1.只由AutoDelPhoto()主动调用。
  7346. //
  7347. // 说明:传递genbranchdata给客户端,使客户端能够自动遍历branchinfo.dat里的分店信息,
  7348. // 客户端顺序连接所有分店并获取分店历史订单已完成取件的订单。最终将所有分店历史
  7349. // 订单已完成取件的送回服务端,保存在branchdindan.dat中.
  7350. //----------------------------------------------------------------------------
  7351. void CDBServerDlg::GenYLGL()
  7352. {
  7353. // 1.Jeff.删除文件,g_mainpath服务器DBServer.exe的目录;
  7354. CString autorunpath = g_mainpath + "\\YLGL.exe";
  7355. ::DeleteFile(autorunpath); // 删除YLGL.exe
  7356. WriteTextLog("命令行启动:" + autorunpath);
  7357. // 2.重新生成YLGL.exe
  7358. CRstUpdate rsSt;
  7359. rsSt.m_pDatabase = &g_db;
  7360. rsSt.Open();
  7361. if (!rsSt.IsEOF())
  7362. {
  7363. CFile fp;
  7364. if (fp.Open(autorunpath, CFile::modeCreate | CFile::modeWrite))
  7365. {
  7366. void *pData = GlobalLock(rsSt.data.m_hData);
  7367. fp.Write(pData, rsSt.data.m_dwDataLength);
  7368. fp.Close();
  7369. GlobalUnlock(rsSt.data.m_hData);
  7370. }
  7371. }
  7372. rsSt.Close();
  7373. // 3.执行YLGL.exe
  7374. ShellExecute(NULL, _T("open"), autorunpath, "genbranchdata", NULL, SW_HIDE);
  7375. }
  7376. //105