12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937 |
- /****************************************************************/
- /* */
- /* ApplicationDlg.cpp */
- /* */
- /* Implementation of the CDBServerDlg class. */
- /* This class is a part of the Date Server. */
- /* */
- /* Programmed by LYFZ van der Meer */
- /* Copyright LYFZ Software Solutions 2002 */
- /* http://www.LYFZvandermeer.nl */
- /* */
- /* Last updated: 10 july 2002 */
- /* */
- /****************************************************************/
- //在ApplicationDlg.cpp文件中实现主窗口界面的设计。及其主窗口相应控件的功能和参数的映射。 D4F876E2-w78F-22D5-q98A-Y0B0D07B847C
- #include "stdafx.h"
- #include "DBServer.h"
- #include "theDBServer.h"
- #include "DBServerDlg.h"
- #include "UserAccountsDlg.h"
- #include "WizardPages.h"
- #include "AboutDlg.h"
- #include <afxpriv.h>
- #include <process.h>
- //#include "Shlwapi.h"
- #include "ClientCenter.h"
- #include "MyLock.h"
- #include "mysqldata.h"
- #include "./helper/ffsco.h"
- //#include <tlhelp32.h>
- #include "ShowPic3.h"
- #include "DogTimeOutDlg.h"
- #include "InputAuthDlg.h"
- #include "ConnectThread.h"
- #pragma comment(lib, "NETAPI32.LIB ")
- #include "SelYear.h"
- /*********ErrorExit(...)函数头文件************/
- //#include <strsafe.h>
- /***********************************/
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #define LIMITCOUNT 1 //历史数据每次转10个 autorun
- extern BOOL g_bSteal;
- extern BOOL g_bConvertHisAll;
- extern CDBServer theApp;
- extern CtheDBServer theServer;
- #define WM_ICON_NOTIFY WM_USER+12
- CDBServerDlg *g_pMainWnd = NULL;
- //#define IPC_CUSTOM_MSG2 _T("{D4F876E2-w78F-22D5-q98A-Y0B0D07B847C}")
- #define IPC_CUSTOM_MSG2 _T("{E4F876E2-Q78F-22D5-C98A-Y0B0D07B847C}")
- UINT g_wmClose = RegisterWindowMessage(IPC_CUSTOM_MSG2);
- //extern BOOL EncryptFile2(BYTE *buffer, DWORD leng, PCHAR szPassword);
- //extern CStringArray g_conniparray;
- CArray<CDatabase*, CDatabase*>g_pHistoryDBarray[200];
- CDatabase *g_pDB[200];
- CConnectThread *g_pThreadPt[200];
- int g_nDBCount = 0;
- /////////////////////////////////////////////////////////////////////////////
- // CDBServerDlg dialog
- #pragma comment(lib, "Shlwapi.lib")
- extern DWORD g_nSendCode;
- extern BOOL g_bReturned;
- DWORD GetLastDirTime(CString dir)
- {
- try
- {
- CString path = dir;
- path.TrimRight("\\");
- path += "\\";
- path += "modifytime";
- CStdioFile fp;
- if (::PathFileExists(path))
- {
- fp.Open(path, CFile::modeRead);
- fp.ReadString(path);
- fp.Close();
- path.TrimLeft(); path.TrimRight();
- path.Replace("-", "");
- return atoi(path);
- }
- else
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(dir), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- CString path;
- DWORD maxdate = 0;
- for (it = coo.begin(); coo.end() != it; it++)
- {
- if (g_pMainWnd->m_bTerminate2)return 99999999; // Jeff.奇葩的返回值!
- path = (*it).c_str();
- maxdate = max(maxdate, atol(GetModifyTime2(path)));
- }
- return maxdate;
- }
- }
- catch (...)
- {
- WriteTextLog("出错");
- }
- }
- static UINT auIDStatusBar[] =
- {
- ID_SEPARATOR,
- ID_INDICATOR_DATA_RECEIVED,
- ID_INDICATOR_DATA_SEND,
- ID_INDICATOR_ONLINELED,
- ID_INDICATOR_OFFLINELED
- };
- /********************************************************************/
- /* */
- /* Function name : CDBServerDlg::CDBServerDlg */
- /* Description : Constructor */
- /* */
- /********************************************************************/
- CDBServerDlg::CDBServerDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CDBServerDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDBServerDlg)
- //}}AFX_DATA_INIT
- m_hIcon = AfxGetApp()->LoadIcon(IDI_DBServer);
- m_bTerminate = false;
- m_bRunning = false;
- m_hThread = NULL;
- m_bTerminate2 = false;
- m_bRunning2 = false;
- m_hThread2 = NULL;
- hInst = NULL;
- CString version = _T("Version 1.0");
- g_bAutoRun = AfxGetApp()->GetProfileInt(version, "brun", 0);
- for (int i = 0; i < 200; i++)
- {
- g_pDB[i] = NULL;
- g_pThreadPt[i] = NULL;
- }
- }
- /********************************************************************/
- /* */
- /* Function name : CDBServerDlg::~CDBServerDlg */
- /* Description : Destructor */
- /* */
- /********************************************************************/
- CDBServerDlg::~CDBServerDlg()
- {
- for (int i = 0; i < 200; i++)
- {
- CDatabase *db = g_pDB[i];
- if (db)
- {
- db->Close();
- delete db;
- }
- for (int j = 0; j < g_pHistoryDBarray[i].GetSize(); j++)
- {
- CDatabase *db = g_pHistoryDBarray[i].ElementAt(j);
- if (db)
- {
- db->Close();
- delete db;
- }
- }
- g_pHistoryDBarray[i].RemoveAll();
- }
- }
- /********************************************************************/
- /* */
- /* Function name : CDBServerDlg::DoDataExchange */
- /* Description : Called by the framework to exchange and validate */
- /* dialog data. */
- /* */
- /********************************************************************/
- void CDBServerDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDBServerDlg)
- DDX_Control(pDX, IDC_INFOBAR, m_InfobarCtrl);
- DDX_Control(pDX, IDC_OUTLOOKBAR, m_OutlookBar);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDBServerDlg, CDialog)
- //{{AFX_MSG_MAP(CDBServerDlg)
- ON_WM_DESTROY()
- ON_COMMAND(ID_SERVER_START, OnServerStart)
- ON_UPDATE_COMMAND_UI(ID_SERVER_START, OnUpdateServerStart)
- ON_COMMAND(ID_SERVER_STOP, OnServerStop)
- ON_UPDATE_COMMAND_UI(ID_SERVER_STOP, OnUpdateServerStop)
- ON_COMMAND(ID_SERVER_EXIT, OnServerExit)
- ON_NOTIFY(NM_CLICK, IDC_OUTLOOKBAR, OnClickOutlookBar)
- ON_NOTIFY(LVN_KEYDOWN, IDC_OUTLOOKBAR, OnKeydownOutlookBar)
- ON_COMMAND(ID_USER_ACCOUNTS, OnUserAccounts)
- ON_WM_CLOSE()
- ON_COMMAND(IDC_VIEW_TRACE, OnViewTrace)
- ON_COMMAND(IDC_VIEW_ONLINE_USERS, OnViewOnlineUsers)
- ON_COMMAND(IDC_VIEW_CONFIGURATION, OnViewConfiguration)
- ON_UPDATE_COMMAND_UI(IDC_VIEW_TRACE, OnUpdateViewTrace)
- ON_UPDATE_COMMAND_UI(IDC_VIEW_ONLINE_USERS, OnUpdateViewOnlineUsers)
- ON_UPDATE_COMMAND_UI(IDC_VIEW_CONFIGURATION, OnUpdateViewConfiguration)
- ON_COMMAND(IDC_VIEW_STATISTICS, OnViewStatistics)
- ON_UPDATE_COMMAND_UI(IDC_VIEW_STATISTICS, OnUpdateViewStatistics)
- ON_COMMAND(IDC_VIEW_SECURITY, OnViewSecurity)
- ON_UPDATE_COMMAND_UI(IDC_VIEW_SECURITY, OnUpdateViewSecurity)
- ON_COMMAND(ID_ACCOUNT_WIZARD, OnAccountWizard)
- ON_WM_TIMER()
- ON_COMMAND(IDM_OPEN, OnOpen)
- ON_COMMAND(IDM_EXIT, OnExit)
- ON_COMMAND(IDM_AUTORUN, OnAutorun)
- //}}AFX_MSG_MAP
- ON_MESSAGE(WM_ICON_NOTIFY, OnTrayNotification)
- ON_REGISTERED_MESSAGE(g_wmClose, OnAbortClose)
- END_MESSAGE_MAP()
- LRESULT CDBServerDlg::OnAbortClose(WPARAM wParam, LPARAM lParam)
- {
- if (wParam == 2)
- {
- WriteTextLog("连接失败,服务将重启");
- OnExit2();
- }
- else if (wParam == 3)//更新分店
- {
- LoadBranchInfo();
- }
- return 1;
- }
- BOOL CDBServerDlg::OnInitDialog()
- {
- g_pMainWnd = this;
- CDialog::OnInitDialog();
- char server[50];
- DWORD leng = 50;
- ::GetComputerName(server, &leng);
- g_localip = server;
- MyGetIPByName(g_localip);
- // setup listview ctrl, so that it looks like the outbar control
- SetupOutlookBar();
- // Add statusbar to the dialog
- CreateStatusbar();
- CRect rect;
- GetDlgItem(IDC_STATIC1)->GetWindowRect(rect);
- ScreenToClient(rect);
- rect.right += 4;
- GetDlgItem(IDC_STATIC1)->MoveWindow(rect);
- // create property pages
- m_TracePage.Create(IDD_PROPPAGE_TRACE, this);
- m_OnlineUsersPage.Create(IDD_PROPPAGE_ONLINE, this);
- m_ConfigurationPage.Create(IDD_PROPPAGE_CONFIGURATION, this);
- m_StatisticsPage.Create(IDD_PROPPAGE_STATISTICS, this);
- m_SecurityPage.Create(IDD_PROPPAGE_SECURITY, this);
- // activate main page
- ActivatePage(0);
- // Set the icon for this dialog.
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
- g_curdb = &g_db;
- OnButton1(); // Jeff 初始化服务端,内含定时器1;
- GetFileDate(); // Jeff获取文件信息;
- //LoadDB();
- LoadHistoryDB();//Jeff加载历史数据库;
- int aaaa = 30;
- while (aaaa--)
- AddOneConn();//添加数据库连接;
- SetTimer(2, 10, NULL);
- CheckBakState();// 检查相片备份情况
- hInst = LoadLibrary("SENSAPI.DLL"); //加载动态库 ;
- if (hInst)
- {
- typedef BOOL(WINAPI *MYFUNC)(LPDWORD);
- MYFUNC IsNetworkConnect = NULL;
- //取得IsNetworkAlive函数指针
- IsNetworkConnect = (MYFUNC)GetProcAddress(hInst, "IsNetworkAlive");
- if (IsNetworkConnect)
- {
- DWORD dwActiveWan = 1;
- if (IsNetworkConnect(&dwActiveWan))
- m_bNetWorkOK = 1;
- else
- m_bNetWorkOK = 0;
- SetTimer(5, 10000, NULL);
- }
- else
- m_bNetWorkOK = 0;
- }
- else
- m_bNetWorkOK = 0;
- return TRUE;
- }
- /********************************************************************/
- /* */
- /* Function name : OnDestroy */
- /* Description : Handle WM_DESTROY message */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnDestroy()
- {
- OnServerStop();
- KillTimer(1);
- KillTimer(2);
- KillTimer(3);
- KillTimer(4);
- KillTimer(5);
- KillTimer(6);
- KillTimer(7);
- KillTimer(8);
- CDialog::OnDestroy();
- }
- /********************************************************************/
- /* */
- /* Function name : OnServerStart */
- /* Description : Start Date Server -> start listening on port 21 */
- /* */
- /********************************************************************/
- //启动数据服务器,使其在21号端口侦听
- void CDBServerDlg::OnServerStart()
- {
- ServerStart();
- }
- BOOL CDBServerDlg::ServerStart()
- {
- if (theServer.Start())
- {
- m_wndStatusBar.SetPaneText(0, "数据服务已启动", TRUE);
- SetOnlineLed(TRUE);
- SetOfflineLed(FALSE);
- WriteTextLog("启动成功");
- return 1;
- }
- else
- {
- WriteTextLog("启动失败");
- CDialog::OnCancel();
- return 0;
- }
- }
- /********************************************************************/
- /* */
- /* Function name : OnUpdateServerStart */
- /* Description : Update 'Start' status */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnUpdateServerStart(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(!theServer.IsActive());
- }
- /********************************************************************/
- /* */
- /* Function name : OnServerStop */
- /* Description : Stop Date Server */
- /* */
- /********************************************************************/
- //停止服务器
- void CDBServerDlg::OnServerStop()
- {
- theServer.Stop();
- m_wndStatusBar.SetPaneText(0, "数据服务已停止", TRUE);
- SetOnlineLed(FALSE);
- SetOfflineLed(TRUE);
- }
- /********************************************************************/
- /* */
- /* Function name : OnUpdateServerStop */
- /* Description : Update 'Stop' status */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnUpdateServerStop(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(theServer.IsActive());
- }
- /********************************************************************/
- /* */
- /* Function name : OnServerExit */
- /* Description : Let's get out of here... */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnServerExit()
- {
- OnCancel();
- }
- /********************************************************************/
- /* */
- /* Function name : CDBServerDlg::SetupOutlookBar */
- /* Description : Initialize listview, change color/iconspacing to */
- /* make it look a little bit like the outlook bar. */
- /* */
- /********************************************************************/
- void CDBServerDlg::SetupOutlookBar()
- {
- // create Imagelist
- m_ImageList.Create(32, 32, ILC_COLOR16 | ILC_MASK, 1, 4);
- HICON hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_LOG));
- m_ImageList.Add(hIcon);
- hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ONLINE_USERS));
- m_ImageList.Add(hIcon);
- hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_CONFIGURATION));
- m_ImageList.Add(hIcon);
- hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_SECURITY));
- m_ImageList.Add(hIcon);
- hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_STATISTICS));
- m_ImageList.Add(hIcon);
- m_OutlookBar.SetImageList(&m_ImageList, LVSIL_NORMAL);
- CRect rc;
- m_OutlookBar.GetClientRect(rc);
- // set new icon spacing
- m_OutlookBar.SetIconSpacing(rc.Width(), 64);
- // change colors
- m_OutlookBar.SetTextColor(RGB(255, 255, 255));
- m_OutlookBar.SetTextBkColor(RGB(128, 128, 128));
- m_OutlookBar.SetBkColor(RGB(128, 128, 128));
- // insert items
- m_OutlookBar.InsertColumn(0, "OutlookBar");
- m_OutlookBar.InsertItem(0, "服务器日志", 0);
- m_OutlookBar.InsertItem(1, "在线用户", 1);
- m_OutlookBar.InsertItem(2, "关于", 2);
- m_OutlookBar.InsertItem(3, "功能区", 3);
- /* m_OutlookBar.InsertItem(4, "Security", 4);*/
- // m_OutlookBar.SetExtendedStyle(LVS_EX_TRACKSELECT);
- }
- /********************************************************************/
- /* */
- /* Function name : CDBServerDlg::MoveChilds */
- /* Description : Move child windows into place holder area. */
- /* */
- /********************************************************************/
- void CDBServerDlg::MoveChilds()
- {
- // position property pages
- CRect rcDlgs;
- // get dialog area rect
- GetDlgItem(IDC_DIALOG_AREA)->GetWindowRect(rcDlgs);
- ScreenToClient(rcDlgs);
- m_ConfigurationPage.MoveWindow(rcDlgs);
- m_TracePage.MoveWindow(rcDlgs);
- m_OnlineUsersPage.MoveWindow(rcDlgs);
- m_StatisticsPage.MoveWindow(rcDlgs);
- m_SecurityPage.MoveWindow(rcDlgs);
- }
- /********************************************************************/
- /* */
- /* Function name : CDBServerDlg::ActivatePage */
- /* Description : Called when an icon on the outlookbar is pressed.*/
- /* */
- /********************************************************************/
- void CDBServerDlg::ActivatePage(int nIndex)
- {
- switch (nIndex)
- {
- case 0:
- m_OnlineUsersPage.ShowWindow(SW_HIDE);
- m_ConfigurationPage.ShowWindow(SW_HIDE);
- m_StatisticsPage.ShowWindow(SW_HIDE);
- m_SecurityPage.ShowWindow(SW_HIDE);
- m_TracePage.ShowWindow(SW_SHOW);
- m_InfobarCtrl.SetText("服务器日志");
- break;
- case 1:
- m_TracePage.ShowWindow(SW_HIDE);
- m_ConfigurationPage.ShowWindow(SW_HIDE);
- m_StatisticsPage.ShowWindow(SW_HIDE);
- m_SecurityPage.ShowWindow(SW_HIDE);
- m_OnlineUsersPage.RefreshData();
- m_OnlineUsersPage.ShowWindow(SW_SHOW);
- m_InfobarCtrl.SetText("在线用户");
- break;
- case 2:
- m_OnlineUsersPage.ShowWindow(SW_HIDE);
- m_TracePage.ShowWindow(SW_HIDE);
- m_StatisticsPage.ShowWindow(SW_HIDE);
- m_SecurityPage.ShowWindow(SW_HIDE);
- m_ConfigurationPage.ShowWindow(SW_SHOW);
- m_InfobarCtrl.SetText("关于");
- break;
- case 4:
- m_OnlineUsersPage.ShowWindow(SW_HIDE);
- m_TracePage.ShowWindow(SW_HIDE);
- m_ConfigurationPage.ShowWindow(SW_HIDE);
- m_SecurityPage.ShowWindow(SW_HIDE);
- m_StatisticsPage.ShowWindow(SW_SHOW);
- m_InfobarCtrl.SetText("Statistics");
- break;
- case 3:
- m_OnlineUsersPage.ShowWindow(SW_HIDE);
- m_TracePage.ShowWindow(SW_HIDE);
- m_ConfigurationPage.ShowWindow(SW_HIDE);
- m_SecurityPage.ShowWindow(SW_SHOW);
- m_StatisticsPage.ShowWindow(SW_HIDE);
- m_InfobarCtrl.SetText("功能区");
- break;
- default:
- break;
- }
- MoveChilds();
- }
- /********************************************************************/
- /* */
- /* Function name : CDBServerDlg::OnClickOutlookBar */
- /* Description : User clicked on our listview -> activate page. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnClickOutlookBar(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // get index of selected item
- int nIndex = m_OutlookBar.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
- if (nIndex == -1)
- return;
- ActivatePage(nIndex);
- *pResult = 0;
- }
- /********************************************************************/
- /* */
- /* Function name : CDBServerDlg::OnKeydownOutlookBar */
- /* Description : User pressed a key -> activate page. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnKeydownOutlookBar(NMHDR* pNMHDR, LRESULT* pResult)
- {
- LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR;
- // get index of selected item
- int nIndex = m_OutlookBar.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
- if (nIndex == -1)
- return;
- if (pLVKeyDow->wVKey == VK_DOWN)
- {
- if (m_OutlookBar.GetItemCount() - 1 > nIndex)
- {
- ActivatePage(nIndex + 1);
- }
- }
- else
- if (pLVKeyDow->wVKey == VK_UP)
- {
- if (nIndex > 0)
- {
- ActivatePage(nIndex - 1);
- }
- }
- else
- if (pLVKeyDow->wVKey == VK_NEXT)
- {
- ActivatePage(m_OutlookBar.GetItemCount() - 1);
- }
- else
- if (pLVKeyDow->wVKey == VK_PRIOR)
- {
- ActivatePage(0);
- }
- *pResult = 0;
- }
- /********************************************************************/
- /* */
- /* Function name : CreateStatusbar */
- /* Description : This function creates a statusbar on a dialogbox.*/
- /* */
- /********************************************************************/
- BOOL CDBServerDlg::CreateStatusbar()
- {
- // Create the Toolbar and attach the resource
- if (!m_wndToolBar.Create(this) || !m_wndToolBar.LoadToolBar(IDR_TOOLBAR1))
- {
- TRACE0("Failed to Create Dialog Toolbar\n");
- return FALSE;
- }
- m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);
- // Make it flat.
- m_wndToolBar.ModifyStyle(0, m_wndToolBar.GetStyle() | TBSTYLE_FLAT);
- // Create status bar at the bottom of the dialog window
- if (m_wndStatusBar.Create(this))
- {
- m_wndStatusBar.SetIndicators(auIDStatusBar, sizeof(auIDStatusBar) / sizeof(UINT));
- m_wndStatusBar.SetPaneText(0, "Date Server is offline", TRUE);
- // Make a sunken or recessed border around the first pane
- m_wndStatusBar.SetPaneInfo(0, m_wndStatusBar.GetItemID(0), SBPS_STRETCH, NULL);
- SetOnlineLed(FALSE);
- SetOfflineLed(FALSE);
- m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_ONLINELED), ID_INDICATOR_ONLINELED, SBPS_NOBORDERS, 14);
- // m_wndStatusBar.GetStatusBarCtrl().SetTipText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_ONLINELED), "This status light is green when the server is online");
- m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_OFFLINELED), ID_INDICATOR_OFFLINELED, SBPS_NOBORDERS, 14);
- // m_wndStatusBar.GetStatusBarCtrl().SetTipText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_OFFLINELED), "This status light is green when the server is online");
- }
- // We need to resize the dialog to make room for control bars.
- // First, figure out how big the control bars are.
- CRect rcClientStart;
- CRect rcClientNow;
- GetClientRect(rcClientStart);
- RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0, reposQuery, rcClientNow);
- // Now move all the controls so they are in the same relative
- // position within the remaining client area as they would be
- // with no control bars.
- CPoint ptOffset(rcClientNow.left - rcClientStart.left, rcClientNow.top - rcClientStart.top);
- CRect rcChild;
- CWnd* pwndChild = GetWindow(GW_CHILD);
- while (pwndChild)
- {
- pwndChild->GetWindowRect(rcChild);
- ScreenToClient(rcChild);
- rcChild.OffsetRect(ptOffset);
- pwndChild->MoveWindow(rcChild, FALSE);
- pwndChild = pwndChild->GetNextWindow();
- }
- // Adjust the dialog window dimensions
- CRect rcWindow;
- GetWindowRect(rcWindow);
- rcWindow.right += rcClientStart.Width() - rcClientNow.Width();
- rcWindow.bottom += rcClientStart.Height() - rcClientNow.Height();
- MoveWindow(rcWindow, FALSE);
- // And position the control bars
- RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
- return TRUE;
- }
- /********************************************************************/
- /* */
- /* Function name : OnUserAccounts */
- /* Description : Show user accounts. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnUserAccounts()
- {
- CUserAccountsDlg dlg;
- theServer.m_UserManager.GetUserList(dlg.m_UserArray);
- if (dlg.DoModal() == IDOK)
- {
- theServer.m_UserManager.UpdateUserList(dlg.m_UserArray);
- }
- }
- /********************************************************************/
- /* */
- /* Function name : OnFTPUserConnected */
- /* Description : A user has connected to our server. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnFTPUserConnected(DWORD nThreadID, LPCTSTR lpszUser, LPCSTR lpszAddress)
- {
- m_OnlineUsersPage.AddUser(nThreadID, lpszUser, lpszAddress);
- }
- /********************************************************************/
- /* */
- /* Function name : OnFTPUserDisconnected */
- /* Description : A user has disconnected from our server. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnFTPUserDisconnected(DWORD nThreadID, LPCTSTR lpszUser)
- {
- m_OnlineUsersPage.RemoveUser(nThreadID);
- }
- /********************************************************************/
- /* */
- /* Function name : OnFTPStatusChange */
- /* Description : FTP Status changed. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnFTPStatusChange(int nType, LPCTSTR lpszText)
- {
- m_TracePage.AddTraceLine(nType, lpszText);
- switch (nType)
- {
- case 3:
- theApp.m_LogFile << error_lvl << date << time << lpszText << endl;
- break;
- default:
- theApp.m_LogFile << trace_lvl << date << time << lpszText << endl;
- break;
- }
- }
- /********************************************************************/
- /* */
- /* Function name : OnFTPReceivedBytesChange */
- /* Description : Number of received bytes has changed. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnFTPReceivedBytesChange(int nBytes)
- {
- m_StatisticsPage.SetValue(6, FormatSize(nBytes, 0));
- CString strStatus;
- strStatus.Format("%s received", FormatSize(nBytes, 0));
- m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_DATA_RECEIVED), strStatus, TRUE);
- CClientDC dc(this);
- CSize size = dc.GetTextExtent(strStatus);
- m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_DATA_RECEIVED), ID_INDICATOR_DATA_RECEIVED, SBPS_NORMAL, size.cx);
- }
- /********************************************************************/
- /* */
- /* Function name : OnFTPSentBytesChange */
- /* Description : Number of sent bytes has changed. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnFTPSentBytesChange(int nBytes)
- {
- m_StatisticsPage.SetValue(7, FormatSize(nBytes, 0));
- CString strStatus;
- strStatus.Format("%s sent", FormatSize(nBytes, 0));
- m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_DATA_SEND), strStatus, TRUE);
- CClientDC dc(this);
- CSize size = dc.GetTextExtent(strStatus);
- m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_DATA_SEND), ID_INDICATOR_DATA_SEND, SBPS_NORMAL, size.cx);
- }
- /********************************************************************/
- /* */
- /* Function name : OnViewTrace */
- /* Description : Handle menu selection. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnViewTrace()
- {
- ActivatePage(0);
- }
- /********************************************************************/
- /* */
- /* Function name : OnViewOnlineUsers */
- /* Description : Handle menu selection. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnViewOnlineUsers()
- {
- ActivatePage(1);
- }
- /********************************************************************/
- /* */
- /* Function name : OnViewConfiguration */
- /* Description : Handle menu selection. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnViewConfiguration()
- {
- ActivatePage(2);
- }
- /********************************************************************/
- /* */
- /* Function name : OnViewStatistics */
- /* Description : Handle menu selection. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnViewStatistics()
- {
- ActivatePage(3);
- }
- /********************************************************************/
- /* */
- /* Function name : OnViewSecurity */
- /* Description : Handle menu selection. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnViewSecurity()
- {
- ActivatePage(4);
- }
- /********************************************************************/
- /* */
- /* Function name : OnUpdateViewTrace */
- /* Description : Update menu state of Trace item. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnUpdateViewTrace(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(m_TracePage.IsWindowVisible());
- }
- /********************************************************************/
- /* */
- /* Function name : OnUpdateViewOnlineUsers */
- /* Description : Update menu state of Online Users item. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnUpdateViewOnlineUsers(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(m_OnlineUsersPage.IsWindowVisible());
- }
- /********************************************************************/
- /* */
- /* Function name : OnUpdateViewConfiguration */
- /* Description : Update menu state of Configuration item. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnUpdateViewConfiguration(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(m_ConfigurationPage.IsWindowVisible());
- }
- /********************************************************************/
- /* */
- /* Function name : OnUpdateViewStatistics */
- /* Description : Update menu state of Statistics item. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnUpdateViewStatistics(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(m_StatisticsPage.IsWindowVisible());
- }
- /********************************************************************/
- /* */
- /* Function name : OnUpdateViewSecurity */
- /* Description : Update menu state of Security item. */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnUpdateViewSecurity(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(m_SecurityPage.IsWindowVisible());
- }
- /********************************************************************/
- /* */
- /* Function name : SetOnlineLed */
- /* Description : Turn online LED on/off. */
- /* */
- /********************************************************************/
- void CDBServerDlg::SetOnlineLed(BOOL bOnline)
- {
- HICON hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(),
- bOnline ? MAKEINTRESOURCE(IDI_LED_GREEN) : MAKEINTRESOURCE(IDI_LED_OFF),
- IMAGE_ICON, 16, 16, LR_SHARED);
- m_wndStatusBar.GetStatusBarCtrl().SetIcon(m_wndStatusBar.CommandToIndex(ID_INDICATOR_ONLINELED), hIcon);
- m_wndStatusBar.GetStatusBarCtrl().Invalidate();
- m_wndStatusBar.GetStatusBarCtrl().UpdateWindow();
- DestroyIcon(hIcon);
- }
- /********************************************************************/
- /* */
- /* Function name : SetOfflineLed */
- /* Description : Turn offline LED on/off. */
- /* */
- /********************************************************************/
- void CDBServerDlg::SetOfflineLed(BOOL bOffline)
- {
- HICON hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(),
- bOffline ? MAKEINTRESOURCE(IDI_LED_RED) : MAKEINTRESOURCE(IDI_LED_OFF),
- IMAGE_ICON, 16, 16, LR_SHARED);
- m_wndStatusBar.GetStatusBarCtrl().SetIcon(m_wndStatusBar.CommandToIndex(ID_INDICATOR_OFFLINELED), hIcon);
- m_wndStatusBar.GetStatusBarCtrl().Invalidate();
- m_wndStatusBar.GetStatusBarCtrl().UpdateWindow();
- DestroyIcon(hIcon);
- }
- void CDBServerDlg::OnFTPStatisticChange(int nType, int nValue)
- {
- m_StatisticsPage.SetValue(nType, nValue);
- }
- /********************************************************************/
- /* */
- /* Function name : FormatSize */
- /* Description : Format size, the way explorer diplays it */
- /* */
- /********************************************************************/
- char* CDBServerDlg::FormatSize(DWORD dwSizeLow, DWORD dwSizeHigh)
- {
- static char szBuff[100];
- unsigned __int64 nFileSize = ((unsigned __int64)(((DWORD)(dwSizeLow)) |
- ((unsigned __int64)((DWORD)(dwSizeHigh))) << 32));
- unsigned __int64 kb = 0;
- if (nFileSize > 1024)
- {
- kb = nFileSize / 1024;
- if (nFileSize % 1024)
- kb++;
- }
- // make it a string
- _ui64tot(kb, szBuff, 10);
- // add thousand seperators
- int nLength = lstrlen(szBuff);
- if (nLength > 3)
- {
- LPCTSTR ptr = szBuff;
- ptr += (nLength - 1);
- char szTemp[100];
- LPTSTR ptrTemp = szTemp;
- for (int i = 0; i < nLength; i++)
- {
- if (i && ((i % 3) == 0))
- {
- if (*ptrTemp != ',')
- {
- *ptrTemp = ',';
- ptrTemp = _tcsinc(ptrTemp);
- }
- }
- *ptrTemp = *ptr;
- ptrTemp = _tcsinc(ptrTemp);
- ptr = _tcsdec(szBuff, ptr);
- }
- // terminate string
- *ptrTemp = '\0';
- // reverse string
- _tcsrev(szTemp);
- lstrcpy(szBuff, szTemp);
- }
- // add 'KB' to it
- lstrcat(szBuff, " KB");
- return szBuff;
- }
- /********************************************************************/
- /* */
- /* Function name : OnAccountWizard */
- /* Description : Launch New Account Wizard */
- /* */
- /********************************************************************/
- void CDBServerDlg::OnAccountWizard()
- {
- CBitmap bmpHeader, bmpWatermark;
- VERIFY(bmpHeader.LoadBitmap(IDB_BANNER));
- VERIFY(bmpWatermark.LoadBitmap(IDB_WATERMARK));
- // show windows 2000-like wizard
- CWizardSheet wizSheet("New Account Wizard", this, 0, bmpWatermark, NULL, bmpHeader);
- wizSheet.m_psh.hInstance = ::GetModuleHandle(NULL);
- if (wizSheet.DoModal() == ID_WIZFINISH)
- {
- CArray<CUser, CUser&> m_UserArray;
- theServer.m_UserManager.GetUserList(m_UserArray);
- int nIndex = -1;
- for (int i = 0; i < m_UserArray.GetSize(); i++)
- {
- // if it already exists -> update it
- if (m_UserArray[i].m_strName.CompareNoCase(wizSheet.m_Page1.m_strAccountName) == 0)
- {
- nIndex = i;
- break;
- }
- }
- // add new account ?
- if (nIndex == -1)
- {
- CUser user;
- nIndex = m_UserArray.Add(user);
- }
- m_UserArray[nIndex].m_bAccountDisabled = FALSE;
- m_UserArray[nIndex].m_strName = wizSheet.m_Page1.m_strAccountName;
- m_UserArray[nIndex].m_strPassword = wizSheet.m_Page2.m_strPassword;
- // add home directory
- CDirectory directory;
- directory.m_strDir = wizSheet.m_Page3.m_strHomeDirectory;
- directory.m_strAlias = "";
- directory.m_bIsHomeDir = TRUE;
- directory.m_bAllowCreateDirectory = wizSheet.m_Page4.m_bAllowCreateDirectory;
- directory.m_bAllowDelete = wizSheet.m_Page4.m_bAllowDelete;
- directory.m_bAllowDownload = wizSheet.m_Page4.m_bAllowDownload;
- directory.m_bAllowRename = wizSheet.m_Page4.m_bAllowRename;
- directory.m_bAllowUpload = wizSheet.m_Page4.m_bAllowUpload;
- directory.m_strAlias = "";
- m_UserArray[nIndex].m_DirectoryArray.Add(directory);
- // update
- theServer.m_UserManager.UpdateUserList(m_UserArray);
- }
- }
- void CDBServerDlg::OnCancel()
- {
- }
- void CDBServerDlg::OnOK()
- {
- }
- void CDBServerDlg::OnButton1()
- {
- // TODO: Add your control notification handler code here
- try
- {
- theServer.Initialize(this);
- if (ServerStart() == 0)
- return;
- if (g_pSkinData == NULL)
- InitLia();
- /////////////////////
- CString logdays;
- MyLock lock("dbaccessxiao");
- CRecordset myset(&g_db);
- CString sql = "select logdays from version";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("logdays", logdays);
- myset.Close();
- int days = 180;
- if (logdays == "1个月")
- days = 31;
- else if (logdays == "2个月")
- days = 61;
- else if (logdays == "3个月")
- days = 92;
- else
- days = 183;
- CTime tm = CTime::GetCurrentTime();
- CTimeSpan dt(days, 0, 0, 0);
- tm -= dt;
- CString date = tm.Format("%Y-%m-%d");
- ///////////////////
- tm = CTime::GetCurrentTime();
- CTimeSpan dt2(183, 0, 0, 0);
- tm -= dt2;
- date = tm.Format("%Y%m%d%H%M%S");
- sql = "delete from sendreg where [status]='OK' and [timestamp]<'" + date + "'";
- g_db.ExecuteSQL(sql);
- //////////////////////////////////
- sql = "select version from version";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("version", sql);
- myset.Close();
- m_ConfigurationPage.m_versionno = "00" + sql;
- m_ConfigurationPage.UpdateData(0);
- /////////////////////
- }
- catch (...)
- {
- WriteTextLog("出错1");
- }
- }
- void CDBServerDlg::OnClose()
- {
- m_TrayIcon.Create(this, WM_ICON_NOTIFY, "影楼管理系统服务器", m_hIcon, IDR_MENUtray); //构造
- ShowWindow(SW_HIDE); //隐藏窗口
- }
- LRESULT CDBServerDlg::OnTrayNotification(WPARAM wParam, LPARAM lParam)
- {
- return m_TrayIcon.OnTrayNotification(wParam, lParam);
- }
- void CDBServerDlg::OnOpen()
- {
- ShowWindow(SW_SHOW);
- }
- void CDBServerDlg::OnExit2()
- {
- try
- {
- TerminateThread();
- TerminateThread2();
- m_TrayIcon.RemoveIcon();
- if (g_pSkinData)delete[]g_pSkinData; g_pSkinData = NULL;
- g_db.Close();
- for (int i = 0; i < g_dbHistoryArray.GetSize(); i++)
- {
- g_dbHistoryArray.ElementAt(i)->Close();
- delete g_dbHistoryArray.ElementAt(i);
- }
- ReleaseBranchDB();
- }
- catch (...)
- {
- WriteTextLog("出错在函数OnExit2中");
- }
- CDialog::OnCancel();
- }
- void CDBServerDlg::OnExit()
- {
- try
- {
- TerminateThread();
- TerminateThread2();
- DWORD id = FindAppProcessID("AutoRun.exe");
- if (id != -1)
- {
- HANDLE ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
- if (ProcessHandle)TerminateProcess(ProcessHandle, 0);
- }
- m_TrayIcon.RemoveIcon();
- if (g_pSkinData)delete[]g_pSkinData; g_pSkinData = NULL;
- g_db.Close();
- for (int i = 0; i < g_dbHistoryArray.GetSize(); i++)
- {
- g_dbHistoryArray.ElementAt(i)->Close();
- delete g_dbHistoryArray.ElementAt(i);
- }
- ReleaseBranchDB();
- }
- catch (...)
- {
- WriteTextLog("出错在函数OnExit中");
- }
- CDialog::OnCancel();
- }
- void CDBServerDlg::OnTimer(UINT nIDEvent) //定时器;
- {
- try
- {
- if (nIDEvent == 1)
- {
- KillTimer(nIDEvent);
- LoadThumbImages();
- }
- else if (nIDEvent == 2)
- {
- KillTimer(nIDEvent);
- OnClose();// 托盘显示;
- try
- {
- CheckHistoryData(); // Jeff:back history db data;
- LoadBranchInfo2();
- }
- catch (...)
- {
- }
- SetTimer(1, 2 * 60 * 1000, NULL);
- SetTimer(4, 1000 * 60 * 2, NULL);
- SetTimer(7, 1000 * 60 * 60 * 1, NULL);
- SetTimer(8, 3000, NULL);
- SetTimer(9, 10000, NULL);
- }
- else if (nIDEvent == 3)
- {
- g_pMainWnd->KillTimer(3);
- DWORD id = FindAppProcessID("MsgServer.exe");
- if (id != -1)
- {
- HANDLE ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
- if (ProcessHandle)
- TerminateProcess(ProcessHandle, 0);
- }
- CString autorunpath = g_mainpath + "\\MsgServer.exe";
- ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
- }
- else if (nIDEvent == 4) //Jeff.这里也有自动启动MsgServer.exe服务处理,而且是2分钟/次的频率;
- {
- UpdateDate();
- CheckMemberMsg();
- BakPhoto();
- }
- else if (nIDEvent == 5)
- {
- typedef BOOL(WINAPI *MYFUNC)(LPDWORD);
- MYFUNC IsNetworkConnect = NULL;
- //取得IsNetworkAlive函数指针
- IsNetworkConnect = (MYFUNC)GetProcAddress(hInst, "IsNetworkAlive");
- if (IsNetworkConnect)
- {
- DWORD dwActiveWan = 1;
- BOOL state;
- if (IsNetworkConnect(&dwActiveWan))
- state = 1;
- else
- state = 0;
- if (m_bNetWorkOK != state)
- {
- KillTimer(nIDEvent);
- WriteTextLog("网络断开");
- OnExit2();
- }
- }
- }
- else if (nIDEvent == 6)
- {
- KillTimer(nIDEvent);
- ShutDown();
- }
- else if (nIDEvent == 7)
- {
- CheckBakState();
- GenUPhoneData();
- }
- else if (nIDEvent == 8)
- {
- CheckConnCount();
- }
- #if 0 // Jeff.开启定时关机功能
- else if ( nIDEvent == 11)
- {
- g_curdb=&g_db;
- CString m_bak6;
- CString strShutDownTime;
- CRecordset myset(g_curdb);
- CString sql="select * from [version]";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFiledVale("ShutDownTime",strShutDownTime);
- myset.Close();
- CTime tShutDownTime(
- CTime::GetCurrentTime().GetYear(),
- CTime::GetCurrentTime().GetMonth(),
- CTime::GetCurrentTime().GetDay(),
- atoi(strShutDownTime.Left(2)),
- atoi(strShutDownTime.Right(2)),
- 0);
- if (CTime::GetCurrentTime() >= tShutDownTime)
- {
- MyExitWindows();
- }
- }
- #endif
- }
- catch (...)
- {
- WriteTextLog("出错在函数Timer中");
- }
- }
- void LoadImageFromBuf(Image **img, BYTE *pData, DWORD leng)//g_bakserver1
- {
- try
- {
- if (pData == NULL)return;
- if (*img)delete *img;
- *img = NULL;
- // Allocate global memory on which to create stream
- HGLOBAL m_hMem = GlobalAlloc(GMEM_MOVEABLE, leng);
- if (m_hMem == NULL)return;
- BYTE* pmem = (BYTE*)GlobalLock(m_hMem);
- memcpy(pmem, pData, leng);
- IStream* pstm;
- CreateStreamOnHGlobal(m_hMem, TRUE, &pstm);
- // load from stream
- *img = Gdiplus::Image::FromStream(pstm);
- // free/release stuff
- GlobalUnlock(m_hMem);
- pstm->Release();
- }
- catch (...)
- {
- }
- }
- void LoadImageFromBuf(Image **img, CString path)
- {
- try
- {
- CFile fp;
- if (fp.Open(path, CFile::modeRead))
- {
- DWORD leng = fp.GetLength();
- BYTE *pData = new BYTE[leng];
- fp.Read(pData, leng);
- fp.Close();
- LoadImageFromBuf(img, pData, leng);
- delete[]pData;
- }
- }
- catch (...)
- {
- }
- }
- void LoadImageFromRes(Image **img, LPCTSTR lpszResourceName, LPCTSTR ResourceType)
- {
- try
- {
- HGLOBAL hGlobal = NULL;
- HRSRC hSource = NULL;
- LPVOID lpVoid = NULL;
- int nSize = 0;
- BOOL bResult = FALSE;
- hSource = FindResource(NULL, lpszResourceName, ResourceType);
- if (hSource == NULL)return;
- hGlobal = LoadResource(NULL, hSource);
- if (hGlobal == NULL)return;
- lpVoid = LockResource(hGlobal);
- if (lpVoid == NULL)return;
- nSize = (UINT)SizeofResource(NULL, hSource);
- LoadImageFromBuf(img, (BYTE*)hGlobal, nSize);
- UnlockResource(hGlobal); // 16Bit Windows Needs This
- FreeResource(hGlobal); // 16Bit Windows Needs This (32Bit - Automatic Release)
- }
- catch (...)
- {
- }
- }
- // ---------------------------------------------------------------------------------------------------------------------------------------------------------------
- // TimeAt: 2014-09-15 AM;
- // Remark: Jeff;
- // 函数:GenSPhoto
- // 描述:对指定文件夹内的相片生成S或M缩略图;
- // 参数:
- // dir: 需要生成缩略图的文件目录;
- // bMPhoto: 是否生成M缩略图;
- // 其它:
- // 在生成缩略图前,记录jpg文件总数nOldCount,每生成一个缩略图nOldCount++;
- // 最后全部图生成完毕,获取新的jpg文件总数nNewCount,if(nOldCount == nNewCount)则表示所有相片已生成缩略图完毕,生成ok文件表示成功生成缩略图;
- //
- // 函数调用全局参数:
- // g_bSteal:意义未明!
- //
- // 注意:该函数非线程安全!
- // 非线程安全:
- // 获取文件总数nOldCount结束后,若有新文件在本函数以外其他函数或进程、线程被添加,则生成缩略图完成后再次获取文件总数nNewCount就不会与nOldCount++后的结果相等;
- // 而实际上本次缩略图已生成完毕。
- // ---------------------------------------------------------------------------------------------------------------------------------------------------------------
- void GenSPhoto(CString dir, BOOL bMPhoto) // 参数:bMPhoto:是否生成M缩略图;
- {
- // 如果是公告附件目录退出;
- if (dir.Find("公告附件") != -1)return;
- // 如果不是客户原片或修好的片目录,设置bMPhoto参数为0,不生成M缩略图;
- if (dir.Find("客户原片(管理软件)$") != -1 || dir.Find("修好的片(管理软件)$") != -1)
- {
- }
- else
- bMPhoto = 0;
- // 对指定文件目录dir进行指定后缀jpg文件遍历;
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(dir), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- int oldsize = coo.size();
- CString path, temp, spath, mpath;
- for (it = coo.begin(); coo.end() != it; it++)
- {
- try
- {
- if (g_pMainWnd->m_bTerminate)return;
- // 遍历到的jpg文件如果是缩略图则不处理,继续遍历;
- path = (*it).c_str();
- spath = path.Left(path.ReverseFind('\\') + 1);
- mpath = spath;
- spath += "s";
- mpath += "m";
- temp = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
- if (temp.GetAt(0) == 's')continue;
- if (temp.GetAt(0) == 'm')continue;
- spath += path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
- mpath += path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
- if (g_bSteal)
- {
- Image *pImg = NULL;
- ::LoadImageFromBuf(&pImg, path);
- if (pImg == NULL)continue;
- if (pImg->GetWidth() == 0)continue; // Jeff.continue前未释放pImg;
- delete pImg;
- EncryptFile3(path);
- if (path.Find("客户原片") != -1)
- {
- int pos = path.Find("管理软件)$");
- if (pos != -1)
- {
- path = g_bakserver1 + path.Right(path.GetLength() - pos - 10);
- EncryptFile3(path);
- }
- }
- else if (path.Find("修好的片") != -1)
- {
- int pos = path.Find("管理软件)$");
- if (pos != -1)
- {
- path = g_bakserver2 + path.Right(path.GetLength() - pos - 10);
- EncryptFile3(path);
- }
- }
- else if (path.Find("精修好的片") != -1)
- {
- int pos = path.Find("管理软件)$");
- if (pos != -1)
- {
- path = g_bakserver3 + path.Right(path.GetLength() - pos - 10);
- EncryptFile3(path);
- }
- }
- else if (path.Find("设计好的片") != -1)
- {
- int pos = path.Find("管理软件)$");
- if (pos != -1)
- {
- path = g_bakserver4 + path.Right(path.GetLength() - pos - 10);
- EncryptFile3(path);
- }
- }
- oldsize++;
- }
- else if (!CheckFileExist(spath))
- {
- Image *pImg = NULL;
- ::LoadImageFromBuf(&pImg, path);
- if (pImg == NULL)continue;
- if (pImg->GetWidth() == 0)continue; // Jeff.返回前未释放pImg;
- CRect rc(0, 0, 100, 90);
- RectFitDes(pImg->GetWidth(), pImg->GetHeight(), rc);
- Image *simg = pImg->GetThumbnailImage(rc.Width(), rc.Height(), NULL, NULL);
- if (simg == NULL)continue;// Jeff.返回前未释放pImg;
- Image *simg2 = NULL;
- if (bMPhoto)
- {
- CRect rc2(0, 0, 2000, 2000);
- RectFitDes(pImg->GetWidth(), pImg->GetHeight(), rc2);
- simg2 = pImg->GetThumbnailImage(rc2.Width(), rc2.Height(), NULL, NULL);
- if (simg2 == NULL)continue;// Jeff.返回前未释放pImg;
- }
- Graphics graphic(simg);//防止GetThumbnailImage影响质量
- graphic.Clear(Color(255, 255, 255, 255));
- graphic.DrawImage(pImg, 0, 0, simg->GetWidth(), simg->GetHeight());
- if (bMPhoto)
- {
- Graphics graphic2(simg2);//防止GetThumbnailImage影响质量
- graphic2.Clear(Color(255, 255, 255, 255));
- graphic2.DrawImage(pImg, 0, 0, simg2->GetWidth(), simg2->GetHeight());
- }
- ///////////////////////////////
- UINT totalBufferSize;
- UINT numProperties;
- pImg->GetPropertySize(&totalBufferSize, &numProperties);
- // Allocate the buffer that will receive the property items.
- PropertyItem* pAllItems = (PropertyItem*)malloc(totalBufferSize);
- // Fill the buffer.
- pImg->GetAllPropertyItems(totalBufferSize, numProperties, pAllItems);
- // Print the id data member of each property item.
- for (UINT j = 0; j < numProperties; ++j)
- {
- if (PropertyTagOrientation == pAllItems[j].id)
- {
- short* ptrLong = (short*)(pAllItems[j].value);
- int ret = (int)*ptrLong;
- // CString str;
- // str.Format ("%d", ret);
- // AfxMessageBox(str);
- if (ret == 8)
- {
- if (simg2)simg2->RotateFlip(Rotate270FlipNone);
- simg->RotateFlip(Rotate270FlipNone);
- }
- else if (ret == 6)
- {
- if (simg2)simg2->RotateFlip(Rotate90FlipNone);
- simg->RotateFlip(Rotate90FlipNone);
- }
- break;
- }
- }
- free(pAllItems);
- ///////////////////////////////
- ::SaveImageToFile(simg, spath); oldsize++;
- delete simg;
- delete pImg;
- if (bMPhoto)
- {
- ::SaveImageToFile2(simg2, mpath, 100); oldsize++;
- delete simg2;
- }
- }
- }
- catch (...)
- {
- WriteTextLog("出错在函数GenSPhoto中");
- }
- }
- try
- {
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(dir), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- int newsize = coo.size();
- if (oldsize == newsize)
- {
- path = dir + "\\ok";
- CFile fp;
- fp.Open(path, CFile::modeCreate | CFile::modeWrite);
- fp.Close();
- }
- }
- catch (...)
- {
- WriteTextLog("出错在函数GenSPhoto2中");
- }
- }
- //--------------------------------------------------------------------------------
- // Remark by Jeff 2014.10.22
- // 函数:
- // 描述:
- // dir:客户原片、修好的片、精修片、设计片目录的订单文件夹路径;
- // desdir:dir对就的备份目录;
- // 参数:
- // 返回:
- //
- // 调用关系:
- // 1.
- // 2.
- // 3.
- //--------------------------------------------------------------------------------
- BOOL BakAllPhoto(CString dir, CString desdir, CString g_path1, CString g_path2, CString g_path3, CString g_path4)
- {
- try
- {
- CString childdir;
- CString srcdir = dir;
- srcdir.MakeLower();
- if (srcdir.Find(g_path1) != -1)
- childdir = srcdir.Right(srcdir.GetLength() - g_path1.GetLength());
- else if (srcdir.Find(g_path2) != -1)
- childdir = srcdir.Right(srcdir.GetLength() - g_path2.GetLength());
- else if (srcdir.Find(g_path3) != -1)
- childdir = srcdir.Right(srcdir.GetLength() - g_path3.GetLength());
- else if (srcdir.Find(g_path4) != -1)
- childdir = srcdir.Right(srcdir.GetLength() - g_path4.GetLength());
- else
- {
- WriteTextLog("备份出错-目录未找到!");
- return 0;
- }
- /* srcdir.TrimLeft ("\\");
- srcdir.Delete (srcdir.Find ('\\'));
- if(srcdir.Find ('\\')==-1)
- childdir="";
- else
- childdir=srcdir.Right (srcdir.GetLength ()-srcdir.Find ('\\'));*/
- childdir.TrimLeft("\\");
- childdir.TrimRight("\\");
- while (childdir.Find('\\') != -1)
- {
- desdir += "\\";
- desdir += childdir.Left(childdir.Find('\\'));
- //if(CheckFolderFileExist (desdir)==0)
- {
- // if(!
- CreateDirectory(desdir, NULL);//)return;
- }
- childdir = childdir.Right(childdir.GetLength() - childdir.Find('\\') - 1);
- }
- desdir += "\\";
- desdir += childdir;
- //if(CheckFolderFileExist (desdir)==0)
- {
- // if(!
- CreateDirectory(desdir, NULL);//)return;
- }
- desdir += "\\";
- // Jeff.进行相片复制操作;
- using namespace helper_coffs;
- ffsco o;
- o.dirs(0);
- o.find(LPCSTR(dir), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- CString path, temp, despath;
- for (it = coo.begin(); coo.end() != it; it++)
- {
- try
- {
- if (g_pMainWnd->m_bTerminate2)return 0;
- path = (*it).c_str();
- temp = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
- if (temp.GetAt(0) == 's')continue;
- despath = desdir + path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
- if (CheckFileExist(despath))
- {
- /* HANDLE hFile=CreateFile(path,GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
- HANDLE hFile2=CreateFile(despath,GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
- FILETIME ftWrite,ftWrite2;
- if(GetFileTime(hFile, NULL, NULL, &ftWrite)==0)
- {
- CloseHandle(hFile);
- CloseHandle(hFile2);
- return;
- }
- if(GetFileTime(hFile2, NULL, NULL, &ftWrite2)==0)
- {
- CloseHandle(hFile);
- CloseHandle(hFile2);
- return;
- }
- CloseHandle(hFile);
- CloseHandle(hFile2);
- if(ftWrite.dwHighDateTime!=ftWrite2.dwHighDateTime || ftWrite.dwLowDateTime!=ftWrite2.dwLowDateTime)
- {*/
- if (::CopyFile(path, despath, 0))
- g_bakphoto = "照片备份成功";
- // }
- }
- else
- {
- if (::CopyFile(path, despath, 0))
- g_bakphoto = "照片备份成功";
- }
- }
- catch (...)
- {
- }
- }
- }
- catch (...)
- {
- WriteTextLog("出错在函数BakAllPhoto中");
- return 0;
- }
- return 1;
- }
- //--------------------------------------------------------------------------------
- // Remark by Jeff 2014.10.22
- // 函数:
- // 描述:
- // 参数:
- // 返回:
- //
- // 调用关系:
- // 1.
- // 2.
- // 3.
- //--------------------------------------------------------------------------------
- unsigned __stdcall LoadThumbNail(LPVOID lpParam)
- {
- BOOL bMphoto = 0;
- if (g_bSteal == 0)
- {
- CRecordset myset(&g_db);
- CString sql = "select * from version";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("setcheck15", sql);
- myset.Close();
- bMphoto = atoi(sql);
- }
- CDBServerDlg *pDlg = (CDBServerDlg*)lpParam;
- try
- {
- CString g_path1;
- CString g_path2;
- CString g_path3;
- CString g_path4;
- char server[50];
- DWORD leng = 50;
- ::GetComputerName(server, &leng);
- g_path1 = g_path2 = g_path3 = g_path4 = server;
- if (g_path2.IsEmpty())return 0;
- g_path1 = "\\\\" + g_path1 + "\\客户原片(管理软件)$";
- g_path2 = "\\\\" + g_path2 + "\\修好的片(管理软件)$";
- g_path3 = "\\\\" + g_path3 + "\\设计好的片(管理软件)$";
- g_path4 = "\\\\" + g_path4 + "\\精修好的片(管理软件)$";
- GetPathFromNetShareName("客户原片(管理软件)$", g_path1);
- GetPathFromNetShareName("修好的片(管理软件)$", g_path2);
- GetPathFromNetShareName("设计好的片(管理软件)$", g_path3);
- GetPathFromNetShareName("精修好的片(管理软件)$", g_path4);
- CStringArray dirarray;
- CString path, path2;
- using namespace helper_coffs;
- CString patharray[4] = { g_path1, g_path2, g_path3, g_path4 };
- // Remark:Jeff.
- // 遍历原片、修好片、设计片、精修片目录,查看是否有ok或ok.dat文件存在;
- // 说明:ok文件在客户端再次导入相片时会被删除;
- // 只有服务端生成小图后,ok才被重新生成;
- int i = 0;
- for ( i = 0; i < 4; i++)
- {
- if (pDlg->m_bTerminate)
- {
- break;
- }
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(patharray[i]), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- it = coo.begin();
- it++;
- for (; coo.end() != it; it++)
- {
- if (pDlg->m_bTerminate)
- {
- break;
- }
- path = (*it).c_str();
- path.TrimRight("\\");
- path2 = path;
- path2 += "\\ok2.dat";
- path += "\\ok";
- if (CheckFileExist(path2) && path2.Find(".ly.com") == -1)
- {
- ::DeleteFile(path); // 删除ok文件;
- ::DeleteFile(path2); // 删除ok.dat文件;
- }
- // g_bCheckAll g_bSteal的意义???
- if (g_bCheckAll || g_bSteal)
- {
- if (FindArray(&dirarray, (*it).c_str()) == -1)
- dirarray.Add((*it).c_str());
- }
- else if (CheckFileExist(path) == 0)
- {
- if (FindArray(&dirarray, (*it).c_str()) == -1)
- dirarray.Add((*it).c_str());
- }
- }
- }
- for (i = 0; i < dirarray.GetSize(); i++)
- {
- if (pDlg->m_bTerminate)
- {
- break;
- }
- GenSPhoto(dirarray.ElementAt(i), bMphoto);
- }
- }
- catch (...)
- {
- WriteTextLog("出错在函数GenThumb中");
- }
- pDlg->m_bRunning = false;
- pDlg->m_bTerminate = false;
- pDlg->SetTimer(1, 60 * 1000, NULL);
- _endthreadex(0);
- return 0;
- }
- //--------------------------------------------------------------------------------
- // Remark by Jeff 2014.10.22
- // 函数:LoadThumbNail2
- // 描述:线程函数,备份相片.
- // 参数:
- // 返回:
- //
- // 调用关系:
- // 1.
- // 2.
- // 3.
- //--------------------------------------------------------------------------------
- unsigned __stdcall LoadThumbNail2(LPVOID lpParam)//备份
- {
- CDBServerDlg *pDlg = (CDBServerDlg*)lpParam;
- int step = 1;
- BOOL bError = 0;
- try
- {
- g_tisks = ::GetTickCount();
- WriteTextLog("开始备份照片");
- CDatabase *g_curdb = &g_db;
- // CRstPath rsSt;
- CString g_path1;
- CString g_path2;
- CString g_path3;
- CString g_path4;
- g_path1 = g_path2 = g_path3 = g_path4 = g_localname;
- CString localname = g_localname;
- g_path1 = "\\\\" + g_path1 + "\\客户原片(管理软件)$";
- g_path2 = "\\\\" + g_path2 + "\\修好的片(管理软件)$";
- g_path3 = "\\\\" + g_path3 + "\\设计好的片(管理软件)$";
- g_path4 = "\\\\" + g_path4 + "\\精修好的片(管理软件)$";
- GetPathFromNetShareName("客户原片(管理软件)$", g_path1);
- GetPathFromNetShareName("修好的片(管理软件)$", g_path2);
- GetPathFromNetShareName("设计好的片(管理软件)$", g_path3);
- GetPathFromNetShareName("精修好的片(管理软件)$", g_path4);
- step = 2;
- g_path1.MakeLower();
- g_path2.MakeLower();
- g_path3.MakeLower();
- g_path4.MakeLower();
- CString m_bak1, m_bak2, m_bak3, m_bak4; // 是否备份(指定的备份目录是否需要备份);
- CString m_bak11, m_bak22, m_bak33, m_bak44; // 是否备份(集团版的分店备份目录是否需要备份??);
- CString m_bakserver1, m_bakserver2, m_bakserver3, m_bakserver4; // 相片备份目录 ;
- {
- MyLock lock("dbaccessxiao");
- CRstversion rsSt;
- rsSt.m_pDatabase = g_curdb;
- rsSt.Open();
- if (!rsSt.IsEOF())
- {
- m_bak1 = rsSt.m_bak1;
- m_bak2 = rsSt.m_bak2;
- m_bak3 = rsSt.m_bak3;
- m_bak4 = rsSt.m_bak4;
- m_bakserver1 = rsSt.m_bakserver1;
- m_bakserver2 = rsSt.m_bakserver2;
- m_bakserver3 = rsSt.m_bakserver3;
- m_bakserver4 = rsSt.m_bakserver4;
- m_bak11 = rsSt.bak11;
- m_bak22 = rsSt.bak22;
- m_bak33 = rsSt.bak33;
- m_bak44 = rsSt.bak44;
- }
- rsSt.Close();
- step = 3;
- }
- #ifdef CHILD_VERSION
- if (m_bakserver1.Find(":") == -1 && m_bakserver1 != "")
- m_bakserver1 = "\\\\" + m_bakserver1 + "\\客户原片备份(儿童管理软件)$";
- if (1)//(localname.CompareNoCase (m_bakserver1)==0 || CompareIP(localname, m_bakserver1)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\客户原片备份(儿童管理软件)$"))
- GetPathFromNetShareName("客户原片备份(儿童管理软件)$", m_bakserver1);
- if (m_bakserver2.Find(":") == -1 && m_bakserver2 != "")
- m_bakserver2 = "\\\\" + m_bakserver2 + "\\修好的片备份(儿童管理软件)$";
- if (1)//((localname.CompareNoCase (m_bakserver2)==0 || CompareIP(localname, m_bakserver2)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\修好的片备份(儿童管理软件)$"))
- GetPathFromNetShareName("修好的片备份(儿童管理软件)$", m_bakserver2);
- if (m_bakserver3.Find(":") == -1 && m_bakserver3 != "")
- m_bakserver3 = "\\\\" + m_bakserver3 + "\\精修好的片备份(儿童管理软件)$";
- if (1)//((localname.CompareNoCase (m_bakserver3)==0 || CompareIP(localname, m_bakserver3)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\精修好的片备份(儿童管理软件)$"))
- GetPathFromNetShareName("精修好的片备份(儿童管理软件)$", m_bakserver3);
- if (m_bakserver4.Find(":") == -1 && m_bakserver4 != "")
- m_bakserver4 = "\\\\" + m_bakserver4 + "\\设计好的片备份(儿童管理软件)$";
- if (1)//((localname.CompareNoCase (m_bakserver4)==0 || CompareIP(localname, m_bakserver4)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\设计好的片备份(儿童管理软件)$"))
- GetPathFromNetShareName("设计好的片备份(儿童管理软件)$", m_bakserver4);
- #else
- if (m_bakserver1.Find(":") == -1 && m_bakserver1 != "")
- m_bakserver1 = "\\\\" + m_bakserver1 + "\\客户原片备份(管理软件)$";
- if (1)//((localname.CompareNoCase (m_bakserver1)==0 || CompareIP(localname, m_bakserver1)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\客户原片备份(管理软件)$"))
- GetPathFromNetShareName("客户原片备份(管理软件)$", m_bakserver1);
- if (m_bakserver2.Find(":") == -1 && m_bakserver2 != "")
- m_bakserver2 = "\\\\" + m_bakserver2 + "\\修好的片备份(管理软件)$";
- if (1)//((localname.CompareNoCase (m_bakserver2)==0 || CompareIP(localname, m_bakserver2)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\修好的片备份(管理软件)$"))
- GetPathFromNetShareName("修好的片备份(管理软件)$", m_bakserver2);
- if (m_bakserver3.Find(":") == -1 && m_bakserver3 != "")
- m_bakserver3 = "\\\\" + m_bakserver3 + "\\精修好的片备份(管理软件)$";
- if (1)//((localname.CompareNoCase (m_bakserver3)==0 || CompareIP(localname, m_bakserver3)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\精修好的片备份(管理软件)$"))
- GetPathFromNetShareName("精修好的片备份(管理软件)$", m_bakserver3);
- if (m_bakserver4.Find(":") == -1 && m_bakserver4 != "")
- m_bakserver4 = "\\\\" + m_bakserver4 + "\\设计好的片备份(管理软件)$";
- if (1)//((localname.CompareNoCase (m_bakserver4)==0 || CompareIP(localname, m_bakserver4)==0) && CheckFolderFileExist("\\\\"+m_bakserver1+"\\设计好的片备份(管理软件)$"))
- GetPathFromNetShareName("设计好的片备份(管理软件)$", m_bakserver4);
- #endif
- WriteTextLog(m_bakserver1); WriteTextLog(m_bakserver2); WriteTextLog(m_bakserver3); WriteTextLog(m_bakserver4);
- step = 4;
- CStringArray dirarray;
- CString str, path;
- using namespace helper_coffs;
- BOOL bcheck1 = atoi(m_bak1);
- BOOL bcheck2 = atoi(m_bak2);
- BOOL bcheck3 = atoi(m_bak3);
- BOOL bcheck4 = atoi(m_bak4);
- BOOL bcheck11 = atoi(m_bak11);
- BOOL bcheck22 = atoi(m_bak22);
- BOOL bcheck33 = atoi(m_bak33);
- BOOL bcheck44 = atoi(m_bak44);
- // 下列4变量应该使用结构体保存;
- CString patharray[4] = { g_path1, g_path2, g_path4, g_path3 };
- BOOL bcheck[4] = { bcheck1, bcheck2, bcheck3, bcheck4 };
- // 集团版;
- BOOL bcheckbranch[4] = { bcheck11, bcheck22, bcheck33, bcheck44 };
- CString patharray2[4] = { m_bakserver1, m_bakserver2, m_bakserver3, m_bakserver4 };
- CArray<int, int>posarray;
- int i = 0;
- for ( i = 0; i < 4; i++)
- {
- if (pDlg->m_bTerminate2)
- {
- break;
- }
- // if(!CheckFolderFileExist (patharray[i]))continue;
- // if(!CheckFolderFileExist (patharray2[i]))continue;
- if (bcheck[i] == 0)continue; // Jeff,跳过没有设置备份要求的相片;
- if (patharray2[i] == "")continue; // Jeff.跳过没有备份目录的备份;
- if (!::CheckFolderFileExist(patharray2[i]))continue; // Jeff.跳过备份目录不对的备份;
- if (!::CheckFolderFileExist(patharray[i]))continue; // Jeff.跳过源目录不对的备份;
- // 获取订单文件夹路径全名;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(patharray[i]), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- it = coo.begin();
- it++;
- for (; coo.end() != it; it++)
- {
- if (pDlg->m_bTerminate2)
- {
- break;
- }
- str = (*it).c_str();
- if (str.Find(".ly.com") != -1 && bcheckbranch[i] == 0)continue;
- if (FindArray(&dirarray, str) == -1)
- {
- dirarray.Add(str);
- posarray.Add(i);
- }
- }
- }
- step = 5;
- // Jeff.对每个订单文件夹进行相片复制操作;
- bError = 0;
- for (i = 0; i<dirarray.GetSize(); i++)
- {
- if (pDlg->m_bTerminate2)break;
- CTime tm = CTime::GetCurrentTime();
- tm -= CTimeSpan(10, 0, 0, 0);
- CString date = tm.Format("%Y%m%d");
- DWORD dirdate = GetLastDirTime(dirarray.ElementAt(i));
- if (pDlg->m_bTerminate2)break;
- CString ss;
- if (dirdate>atol(date))
- {
- // ss.Format ("%d>%d", dirdate, atol(date));
- // WriteTextLog(ss);
- // WriteTextLog(dirarray.ElementAt (i));
- step = 6;
- if (0 == BakAllPhoto(dirarray.ElementAt(i), patharray2[posarray.ElementAt(i)], g_path1, g_path2, g_path3, g_path4))
- bError = 1;
- CString path = dirarray.ElementAt(i);
- path.TrimRight("\\"); path += "\\";
- path += "modifytime";
- CStdioFile fp;
- if (!::PathFileExists(path))
- {
- fp.Open(path, CFile::modeCreate | CFile::modeWrite);
- fp.WriteString(CTime::GetCurrentTime().Format("%Y-%m-%d"));
- fp.Close();
- }
- }
- else
- {
- step = 7;
- CString path = dirarray.ElementAt(i);
- path.TrimRight("\\"); path += "\\";
- path += "modifytime";
- CStdioFile fp;
- if (!::PathFileExists(path))
- {
- step = 8;
- // CString ss;
- // ss.Format ("出错在函数备份照片中-step:%d,文件:%s", step, path);
- // WriteTextLog(ss);
- fp.Open(path, CFile::modeCreate | CFile::modeWrite);
- fp.WriteString(CTime::GetCurrentTime().Format("%Y-%m-%d"));
- fp.Close();
- }
- }
- }
- if (bError)
- g_bakphoto = "照片备份失败";
- else
- g_bakphoto = "照片备份成功";
- step = 9;
- }
- catch (CException *e)
- {
- TCHAR szError[1024] = { 0 };
- e->GetErrorMessage(szError, 1024);
- WriteTextLog(CString(szError));
- e->Delete();
- if (step != 8)
- {
- CString ss;
- ss.Format("出错在函数备份照片中-step:%d", step);
- WriteTextLog(ss);
- g_bakphoto = "照片备份出错";
- }
- else
- {
- if (bError)
- g_bakphoto = "照片备份失败";
- else
- g_bakphoto = "照片备份成功";
- }
- }
- pDlg->SetTimer(6, 3000, NULL);
- pDlg->m_bRunning2 = false;
- pDlg->m_bTerminate2 = false;
- _endthreadex(0);
- return 0;
- }
- void CDBServerDlg::LoadThumbImages()
- {
- if (m_bRunning)return;
- TerminateThread();
- m_bRunning = true;
- m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
- }
- //--------------------------------------------------------------
- // Remark by Jeff 2014.10.22
- // 函数:LoadThumbImages2
- // 描述:
- // 参数:
- // 返回:
- //
- // 调用关系:
- // 1.LoadThumbImages2() 只由 BakPhoto() 调用;
- // 2.BakPhoto()由CDBServerDlg::SetTimer(4) 调用,调用频率2分钟,周期数直到程序结束。
- // 3.CDBServerDlg::SetTimer(4) 由 CDBServerDlg::SetTimer(2) 调用,调用频率10毫秒,只有一个周期。
- // 4.CDBServerDlg::SetTimer(2) 由 CDBServerDlg::OnInitDialog() 调用.
- //--------------------------------------------------------------
- void CDBServerDlg::LoadThumbImages2()
- {
- if (m_bRunning2)return;
- TerminateThread2();
- m_bRunning2 = true;
- m_hThread2 = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail2, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID2);
- }
- BOOL CDBServerDlg::TerminateThread()
- {
- try
- {
- if (!m_bRunning)
- return TRUE;
- m_bTerminate = true;
- for (;;)
- {
- if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
- break;
- MSG msg;
- while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
- {
- if (!AfxGetApp()->PumpMessage())
- break;
- }
- }
- ::CloseHandle(m_hThread);
- m_bRunning = false;
- return TRUE;
- }
- catch (...)
- {
- WriteTextLog("出错在函数TerminateThread中");
- }
- }
- BOOL CDBServerDlg::TerminateThread2()
- {
- try
- {
- if (!m_bRunning2)
- return TRUE;
- m_bTerminate2 = true;
- for (;;)
- {
- if (::WaitForSingleObject(m_hThread2, 0) == WAIT_OBJECT_0)
- break;
- MSG msg;
- while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
- {
- if (!AfxGetApp()->PumpMessage())
- break;
- }
- }
- ::CloseHandle(m_hThread2);
- m_bRunning2 = false;
- return TRUE;
- }
- catch (...)
- {
- WriteTextLog("出错在函数TerminateThread2中");
- }
- }
- void CDBServerDlg::InitLia()
- {
- if (g_pSkinData)
- delete[]g_pSkinData;
- g_pSkinData = NULL;
- HGLOBAL hGlobal = NULL;
- HRSRC hSource = NULL;
- LPVOID lpBuffer = NULL;
- BOOL bResult = FALSE;
- // 1.定位我们的自定义资源,这里因为我们是从本模块定位资源,所以将句柄简单地置为NULL即可
- hSource = FindResource(NULL, MAKEINTRESOURCE(LIA004), _T("SOFTKEY"));
- if (hSource == NULL)
- {
- WriteTextLog(_T("定位资源失败"));
- return;
- }
- // 2.获取资源的大小;
- g_SkinLeng = (UINT)SizeofResource(NULL, hSource);
- // 3.加载资源;
- hGlobal = LoadResource(NULL, hSource);
- if (hGlobal == NULL)
- {
- WriteTextLog(_T("加载资源失败"));
- return;
- }
- // 4.锁定资源,获取buffer;
- lpBuffer = LockResource(hGlobal);
- if (lpBuffer == NULL)
- {
- WriteTextLog(_T("锁定资源失败"));
- return;
- }
- g_pSkinData = new BYTE[g_SkinLeng];
- memcpy(g_pSkinData, lpBuffer, g_SkinLeng);
- UnlockResource(hGlobal);
- FreeResource(hGlobal);
- }
- BOOL CheckExistDinDan(CString id)
- {
- CRecordset myset(&g_db);
- CString sql = "select count(*) as cot from dindan where id='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- return atol(sql);
- }
- //CString g_nCurConvertDBName="db"; // Jeff.deal
- CString g_nCurConvertDBName(g_szDBName);
- /************************************************************************/
- /* [函数]:CheckHistoryData
- /* [描述]:将被检测的数据库已完成的订单数据转到历史数据库中,并删除被检测的数据库已完成的订单;
- /* [参数]:
- /* pSrcdb: 源数据库,用于被转历史的数据库;
- /* nSrcYear: 源数据库的年份;
- /* bMode2: 转储模式:0=年度完成的订单; 1=年度所有订单,包含未完成订单;
- /* [返回]:void
- /*
- /************************************************************************/
- void CDBServerDlg::CheckHistoryData(CDatabase *pSrcdb /* = NULL */, int nSrcYear /* = 0 */, BOOL bMode2 /* = 0*/)//历史备份;
- {
- #if JEFF_TEST_ON
- // 取消转将当前数据库完成订单的记录转到年份数据库中,此步直接返回;
- return;
- #endif
- try
- {
- //g_nCurConvertDBName="db";
- g_nCurConvertDBName = g_szDBName;
- if (pSrcdb != NULL)
- {
- g_bConvertHisAll = 1;
- g_nCurConvertDBName.Format("%d", nSrcYear);
- if (bMode2)
- {
- // MessageBox(g_nCurConvertDBName);
- }
- }
- if (g_bConvertHisAll)
- {
- DWORD id = FindAppProcessID("AutoRun.exe");
- if (id != -1)
- {
- HANDLE ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
- if (ProcessHandle)
- TerminateProcess(ProcessHandle, 0);
- }
- ShowWindow(SW_HIDE);
- WriteTextLog("全部转历史开始");
- }
- CString sql;
- g_curdb = &g_db;
- if (pSrcdb != NULL)
- g_curdb = pSrcdb;
- // 1.获取去年年份值 lastyear
- CTime tm = CTime::GetCurrentTime();
- int lastyear = tm.GetYear() - 1;
- CString strdate, strdate2;
- strdate.Format("%04d-%02d-%02d", lastyear, 1, 1);
- strdate2.Format("%04d-%02d-%02d", lastyear, 12, 31);
- CString filter = "time1>='" + strdate + "' and time1<='" + strdate2 + "' and status3='OK'";
- DWORD ii = 0;
- CArray<CStringArray, CStringArray> strOrderNumberArray; //用于记录订单单号;
- // 2.获取得订单号,并存储在CArray<CStringArray,CStringArray>
- if (bMode2)// 存储即将转为历史数据库的所有年度订单的数据库记录(包含未完成);
- {
- CString filter = "time1>='" + strdate + "' and time1<='" + strdate2 + "'";
- // AfxMessageBox(filter);
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from dindan"; // 订单单数;
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- // AfxMessageBox(sql);
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstDindanForm rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- //if(CheckExistDinDan(rsSt.id)==0)
- {
- strOrderNumberArray.ElementAt(ii).Add(rsSt.id);
- ii++;
- }
- rsSt.MoveNext();
- if (strOrderNumberArray.GetSize() <= ii)
- break;
- }
- rsSt.Close();
- strOrderNumberArray.SetSize(ii, 1);
- }
- else// 存储即将转为历史数据库的已完成订单的年度数据库记录;
- {
- // 有多少订单完成的;
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from dindan";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstDindanForm rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- strOrderNumberArray.ElementAt(ii).Add(rsSt.id);
- ii++;
- rsSt.MoveNext();
- if (strOrderNumberArray.GetSize() <= ii)
- break;
- }
- rsSt.Close();
- strOrderNumberArray.SetSize(ii, 1);
- }
- // 3.获取该年份名称的数据库;
- CDatabase *pLastYeardb = GetDB(lastyear);
- if (pLastYeardb == NULL)
- {
- CheckYear(lastyear);
- return;
- }
- CDatabase *pdb2Transfer = g_curdb; // pdb2Transfer需要转为成历史数据库的数据库;
- pLastYeardb = GetDB(lastyear); // pLastYeardb往年历史数据库;
- if (pLastYeardb == NULL)
- {
- // Jeff数据库中,没有历史数据库存在,退出历史转换任务;
- return;
- }
- // 4.根据订单号,遍历数据;
- int i = 0;
- for ( i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- // if("20121013-005"!=g_List1array.ElementAt (i).ElementAt (0))continue;
- // TransDinDan返回:1表示正常, 100及以上表示源数据库里记录 > 目标数据库记录;
- // TransDinDan将源数据库中的订单数据insert into 到目标数据库中;
- int ret = TransDinDan(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear);
- if (ret == 1)
- {
- // ret == 1表示源数据库将订单数据插入到目标数据库成功,则删除源数据库中的订单数据;
- sql = "delete from dindan where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
- MyExecuteSQL(g_curdb, sql);
- sql = "delete from dindansp where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
- MyExecuteSQL(g_curdb, sql);
- sql = "delete from photoprint where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
- MyExecuteSQL(g_curdb, sql);
- sql = "delete from dindanbukuan where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
- MyExecuteSQL(g_curdb, sql);
- sql = "delete from dindanbukuan2 where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
- MyExecuteSQL(g_curdb, sql);
- sql = "delete from client where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
- MyExecuteSQL(g_curdb, sql);
- sql = "delete from burncdreg where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
- MyExecuteSQL(g_curdb, sql);
- sql = "delete from digitalwork where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
- MyExecuteSQL(g_curdb, sql);
- sql = "delete from mywork where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
- MyExecuteSQL(g_curdb, sql);
- sql = "delete from dindanjd where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
- MyExecuteSQL(g_curdb, sql);
- sql = "delete from dindansp2 where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
- MyExecuteSQL(g_curdb, sql);
- sql = "delete from dindansp3 where id='" + strOrderNumberArray.ElementAt(i).ElementAt(0) + "'";
- MyExecuteSQL(g_curdb, sql);
- }
- else
- {
- // ret=105,已经转过,但是2014被删除过,然后再次转时发现2014里没有记录;待定;
- sql.Format("ret:%d", ret);
- WriteTextLog("转历史失败" + strOrderNumberArray.ElementAt(i).ElementAt(0) + sql);
- }
- #ifdef LIMITCOUNT
- if (g_bConvertHisAll == 0)
- {
- if (i > 100)break;
- }
- #endif
- }
- ////////////////////////////支出
- //WriteTextLog("支出");
- strdate.Format("%04d-%02d-%02d", lastyear, 1, 1);
- strdate2.Format("%04d-%02d-%02d", lastyear, 12, 31);
- filter = "dat>='" + strdate + "' and dat<='" + strdate2 + "'";
- {
- strOrderNumberArray.RemoveAll();
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from gudingfeiyong";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstPayOutInput rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- strOrderNumberArray.ElementAt(ii).Add(rsSt.id);
- ii++;
- rsSt.MoveNext(); if (strOrderNumberArray.GetSize() <= ii)break;
- }
- rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
- }
- for (i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- if (TransPayOut(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
- {
- {
- sql.Format("delete from gudingfeiyong where id=%d", atol(strOrderNumberArray.ElementAt(i).ElementAt(0)));
- MyExecuteSQL(g_curdb, sql);
- }
- }
- #ifdef LIMITCOUNT
- if (g_bConvertHisAll == 0)
- {
- if (i > 100)break;
- }
- #endif
- }
- ////////////////////////////其它收入
- strdate.Format("%04d-%02d-%02d", lastyear, 1, 1);
- strdate2.Format("%04d-%02d-%02d", lastyear, 12, 31);
- filter = "dat>='" + strdate + "' and dat<='" + strdate2 + "'";
- {
- strOrderNumberArray.RemoveAll();
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from singleincome";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstIncomeInput rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- if (atoi(rsSt.balance) == 0)
- strOrderNumberArray.ElementAt(ii).Add(rsSt.id);
- else
- {
- rsSt.MoveNext(); continue;
- }
- ii++;
- rsSt.MoveNext();
- if (strOrderNumberArray.GetSize() <= ii)break;
- }
- rsSt.Close();
- strOrderNumberArray.SetSize(ii, 1);
- }
- for (i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- if (TransIncome(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
- {
- {
- sql.Format("delete from singleincome where id=%d", atol(strOrderNumberArray.ElementAt(i).ElementAt(0)));
- MyExecuteSQL(g_curdb, sql);
- sql.Format("delete from singleincomemoney where [id]='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
- MyExecuteSQL(g_curdb, sql);
- }
- }
- #ifdef LIMITCOUNT
- if (g_bConvertHisAll == 0)
- {
- if (i > 100)break;
- }
- #endif
- }
- ////////////////////////////其它二销收款
- filter = "id not in(select id from singleincome)";
- {
- strOrderNumberArray.RemoveAll();
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from singleincomemoney";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstsingleincomemoney rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- strOrderNumberArray.ElementAt(ii).Add(rsSt.id);
- ii++;
- rsSt.MoveNext();
- if (strOrderNumberArray.GetSize() <= ii)
- break;
- }
- rsSt.Close();
- strOrderNumberArray.SetSize(ii, 1);
- }
- ////////////////////////////其它二销收款
- for (i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- if (TransIncomeMoney(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
- {
- {
- sql.Format("delete from singleincomemoney where [id]='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
- MyExecuteSQL(g_curdb, sql);
- }
- }
- #ifdef LIMITCOUNT
- if (i > 100)break;
- #endif
- }
- ///1/////////////////////////client2phonerecord 2010-08-09 16:22:16
- strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
- strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
- filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
- {
- strOrderNumberArray.RemoveAll();
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from client2phonerecord"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstclient2phonerecord rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
- ii++;
- rsSt.MoveNext();
- if (strOrderNumberArray.GetSize() <= ii)
- break;
- }
- rsSt.Close();
- strOrderNumberArray.SetSize(ii, 1);
- }
- for (i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- if (Transclient2phonerecord(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
- {
- {
- sql.Format("delete from client2phonerecord where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
- MyExecuteSQL(g_curdb, sql);
- }
- }
- #ifdef LIMITCOUNT
- if (g_bConvertHisAll == 0)
- {
- if (i > 100)break;
- }
- #endif
- }
- ///////////////////////////
- ////////////////////////////client2phonerecordout 2010-08-09 16:22:16
- strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
- strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
- filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
- {
- strOrderNumberArray.RemoveAll();
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from client2phonerecordout";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstclient2phonerecordout rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
- ii++;
- rsSt.MoveNext(); if (strOrderNumberArray.GetSize() <= ii)break;
- }
- rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
- }
- for (i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- if (Transclient2phonerecordout(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
- {
- {
- sql.Format("delete from client2phonerecordout where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
- MyExecuteSQL(g_curdb, sql);
- }
- }
- #ifdef LIMITCOUNT
- if (g_bConvertHisAll == 0)
- {
- if (i > 100)break;
- }
- #endif
- }
- ///1/////////////////////////client3phonerecord 2010-08-09 16:22:16
- strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
- strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
- filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
- {
- strOrderNumberArray.RemoveAll();
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from client3phonerecord";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstclient3phonerecord rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
- ii++;
- rsSt.MoveNext();
- if (strOrderNumberArray.GetSize() <= ii)
- break;
- }
- rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
- }
- for (i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- if (Transclient3phonerecord(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
- {
- {
- sql.Format("delete from client3phonerecord where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
- MyExecuteSQL(g_curdb, sql);
- }
- }
- #ifdef LIMITCOUNT
- if (g_bConvertHisAll == 0)
- {
- if (i > 100)break;
- }
- #endif
- }
- ///////////////////////////
- ////////////////////////////client3phonerecordout 2010-08-09 16:22:16
- strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
- strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
- filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
- {
- strOrderNumberArray.RemoveAll();
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from client3phonerecordout";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstclient3phonerecordout rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
- ii++;
- rsSt.MoveNext(); if (strOrderNumberArray.GetSize() <= ii)break;
- }
- rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
- }
- for (i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- if (Transclient3phonerecordout(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
- {
- {
- sql.Format("delete from client3phonerecordout where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
- MyExecuteSQL(g_curdb, sql);
- }
- }
- #ifdef LIMITCOUNT
- if (g_bConvertHisAll == 0)
- {
- if (i > 100)break;
- }
- #endif
- }
- ///////////////////////////
- ////////////////////////////employeephonerecord 2010-08-09 16:22:16
- strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
- strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
- filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
- {
- strOrderNumberArray.RemoveAll();
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from employeephonerecord";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstemployeephonerecord rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
- ii++;
- rsSt.MoveNext();
- if (strOrderNumberArray.GetSize() <= ii)
- break;
- }
- rsSt.Close();
- strOrderNumberArray.SetSize(ii, 1);
- }
- for (i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- if (Transemployeephonerecord(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
- {
- {
- sql.Format("delete from employeephonerecord where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
- MyExecuteSQL(g_curdb, sql);
- }
- }
- #ifdef LIMITCOUNT
- if (g_bConvertHisAll == 0)
- {
- if (i > 100)break;
- }
- #endif
- }
- ///////////////////////////
- ////////////////////////////employeephonerecordout 2010-08-09 16:22:16
- strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
- strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
- filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
- {
- strOrderNumberArray.RemoveAll();
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from employeephonerecordout";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstemployeephonerecordout rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
- ii++;
- rsSt.MoveNext();
- if (strOrderNumberArray.GetSize() <= ii)
- break;
- }
- rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
- }
- for (i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- if (Transemployeephonerecordout(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
- {
- {
- sql.Format("delete from employeephonerecordout where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
- MyExecuteSQL(g_curdb, sql);
- }
- }
- #ifdef LIMITCOUNT
- if (g_bConvertHisAll == 0)
- {
- if (i > 100)break;
- }
- #endif
- }
- ///////////////////////////
- ////////////////////////////phonerecord 2010-08-09 16:22:16
- strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
- strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
- filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
- {
- strOrderNumberArray.RemoveAll();
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from phonerecord";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstphonerecord rsSt; rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
- ii++;
- rsSt.MoveNext();
- if (strOrderNumberArray.GetSize() <= ii)
- break;
- }
- rsSt.Close();
- strOrderNumberArray.SetSize(ii, 1);
- }
- for (i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- if (Transphonerecord(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
- {
- {
- sql.Format("delete from phonerecord where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
- MyExecuteSQL(g_curdb, sql);
- }
- }
- #ifdef LIMITCOUNT
- if (g_bConvertHisAll == 0)
- {
- if (i > 100)break;
- }
- #endif
- }
- ///////////////////////////
- ////////////////////////////phonerecordout 2010-08-09 16:22:16
- strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
- strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
- filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
- {
- strOrderNumberArray.RemoveAll();
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from phonerecordout";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstphonerecordout rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
- ii++;
- rsSt.MoveNext(); if (strOrderNumberArray.GetSize() <= ii)break;
- }
- rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
- }
- for (i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- if (Transphonerecordout(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
- {
- {
- sql.Format("delete from phonerecordout where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
- MyExecuteSQL(g_curdb, sql);
- }
- }
- #ifdef LIMITCOUNT
- if (g_bConvertHisAll == 0)
- {
- if (i > 100)break;
- }
- #endif
- }
- ///////////////////////////
- ////////////////////////////unknownphonerecord 2010-08-09 16:22:16
- strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
- strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
- filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
- {
- strOrderNumberArray.RemoveAll();
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from unknownphonerecord";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstunknownphonerecord rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
- ii++;
- rsSt.MoveNext(); if (strOrderNumberArray.GetSize() <= ii)break;
- }
- rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
- }
- for (i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- if (Transunknownphonerecord(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
- {
- {
- sql.Format("delete from unknownphonerecord where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
- MyExecuteSQL(g_curdb, sql);
- }
- }
- #ifdef LIMITCOUNT
- if (g_bConvertHisAll == 0)
- {
- if (i > 100)break;
- }
- #endif
- }
- ///////////////////////////
- ////////////////////////////unknownphonerecordout 2010-08-09 16:22:16
- strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
- strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
- filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
- {
- strOrderNumberArray.RemoveAll();
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from unknownphonerecordout";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstunknownphonerecordout rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
- ii++;
- rsSt.MoveNext();
- if (strOrderNumberArray.GetSize() <= ii)
- break;
- }
- rsSt.Close();
- strOrderNumberArray.SetSize(ii, 1);
- }
- for (i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- if (Transunknownphonerecordout(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
- {
- {
- sql.Format("delete from unknownphonerecordout where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
- MyExecuteSQL(g_curdb, sql);
- }
- }
- #ifdef LIMITCOUNT
- if (g_bConvertHisAll == 0)
- {
- if (i > 100)break;
- }
- #endif
- }
- ///////////////////////////
- ////////////////////////////misscallrecord 2010-08-09 16:22:16
- strdate.Format("%04d-%02d-%02d 00:00:00", lastyear, 1, 1);
- strdate2.Format("%04d-%02d-%02d 99:99:99", lastyear, 12, 31);
- filter = "datetime>='" + strdate + "' and datetime<='" + strdate2 + "'";
- {
- strOrderNumberArray.RemoveAll();
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from misscallrecord";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- CRstmisscallrecord rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- strOrderNumberArray.ElementAt(ii).Add(rsSt.datetime);
- ii++;
- rsSt.MoveNext();
- if (strOrderNumberArray.GetSize() <= ii)
- break;
- }
- rsSt.Close();
- strOrderNumberArray.SetSize(ii, 1);
- }
- for (i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- if (Transmisscallrecord(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
- {
- {
- sql.Format("delete from misscallrecord where datetime='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
- MyExecuteSQL(g_curdb, sql);
- }
- }
- #ifdef LIMITCOUNT
- if (g_bConvertHisAll == 0)
- {
- if (i > 100)break;
- }
- #endif
- }
- ///////////////////////////
- ////////////////////////////sendreg
- strdate.Format("%04d%02d%02d000000", lastyear, 1, 1);
- strdate2.Format("%04d%02d%02d999999", lastyear, 12, 31);
- filter = "timestamp>='" + strdate + "' and timestamp<='" + strdate2 + "' and issended='OK'";
- {
- strOrderNumberArray.RemoveAll();
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from sendreg";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strOrderNumberArray.SetSize(count, 1);
- RstSendReg rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- strOrderNumberArray.ElementAt(ii).RemoveAll();
- strOrderNumberArray.ElementAt(ii).Add(rsSt.m_timestamp);
- ii++;
- rsSt.MoveNext(); if (strOrderNumberArray.GetSize() <= ii)break;
- }
- rsSt.Close(); strOrderNumberArray.SetSize(ii, 1);
- }
- for (i = 0; i < strOrderNumberArray.GetSize(); i++)
- {
- if (TransSendReg(pdb2Transfer, pLastYeardb, strOrderNumberArray.ElementAt(i).ElementAt(0), lastyear))
- {
- {
- sql.Format("delete from sendreg where [timestamp]='%s'", strOrderNumberArray.ElementAt(i).ElementAt(0));
- MyExecuteSQL(g_curdb, sql);
- }
- }
- #ifdef LIMITCOUNT
- if (g_bConvertHisAll == 0)
- {
- if (i > 100)break;
- }
- #endif
- }
- ///////////////////////////
- }
- catch (...)
- {
- WriteTextLog("出错在函数TransHisData中");
- }
- if (g_bConvertHisAll)WriteTextLog("转换完成!");
- g_bConvertHisAll = 0;
- /////////////////////////生成来电精灵数据
- //return;
- /* g_sendhead.code[0]=80;
- g_sendhead.code[1]=90;
- g_sendhead.code[2]=11;
- g_sendhead.code[3]=138;
- g_sendhead.code[4]=24;
- g_sendhead.code[0]=181;
- g_sendhead.code[0]=65;
- g_sendhead.code[0]=56;*/
- MyLock lock("processChatMessageRequestxiao");
- CArray<int, int>codearray;
- codearray.Add(80);
- codearray.Add(90);
- codearray.Add(11);
- codearray.Add(138);
- codearray.Add(24);
- codearray.Add(181);
- codearray.Add(65);
- codearray.Add(56);
- codearray.Add(179);
- codearray.Add(53);
- CFile fp;
- CString savepath, g_path1;
- char server[50];
- DWORD leng = 50;
- ::GetComputerName(server, &leng);
- g_path1 = server;
- g_path1 = "\\\\" + g_path1 + "\\电话录音(管理软件)$";
- GetPathFromNetShareName("电话录音(管理软件)$", g_path1);
- if (g_path1.IsEmpty())return;
- try
- {
- CArray<CDatabase*, CDatabase*>dbarraytemp;
- dbarraytemp.Copy(g_dbHistoryArray);
- dbarraytemp.InsertAt(0, &g_db);
- for (int aa = 0; aa < dbarraytemp.GetSize(); aa++)
- {
- g_curdb = dbarraytemp.ElementAt(aa);
- savepath.Format("%s\\uphonedata%d.dat", g_path1, aa);
- ::DeleteFile(savepath); // 删除uphonedata.dat文件;
- if (fp.Open(savepath, CFile::modeCreate | CFile::modeWrite) == 0)
- {
- WriteTextLog("更新来电精灵数据出错");
- return;
- }
- CConnectSocket consock;
- consock.m_pConndb = g_curdb;
- for (int i = 0; i < codearray.GetSize(); i++)
- {
- BYTE code = codearray.ElementAt(i);
- DWORD length, arraysize;
- BYTE *pReturn = NULL;
- consock.GetDataFromCode(code, &pReturn, length, arraysize, "");
- fp.Write(&code, sizeof(BYTE));
- fp.Write(&length, sizeof(DWORD));
- fp.Write(&arraysize, sizeof(DWORD));
- fp.Write(pReturn, length);
- }
- fp.Close();
- }
- g_curdb = &g_db;
- }
- catch (CException *e)
- {
- TCHAR szError[1024] = { 0 };
- e->GetErrorMessage(szError, 1024);
- WriteTextLog(CString(szError));
- WriteTextLog("获取来电精灵数据出错");
- e->Delete();
- }
- WriteTextLog("转历史数据完成");
- }
- //------------------------------------------------------------------------------------
- // Jeff remark
- // 函数:CheckYear
- // 描述:
- // 1.检查指定年份的历史数据库mdf文件是否存在,存在则直接附加
- // 2.不存在,则使用null.mdf文件拷贝创建历史年份数据库mdf并附加;
- // 参数:
- // year:被检查年份值;
- // 返回:void
- //------------------------------------------------------------------------------------
- #if JEFF_TEST_ON
- void CDBServerDlg::CheckYear(int year)
- {
- try
- {
- #ifdef SQLSERVER_VERSION
- CString sql;
- // 1.判断年份数据库是否存在;
- CString strPathOfYearmdf;
- CString strPathOfYearldf;
- strPathOfYearmdf.Format("%s\\数据\\%d.mdf", g_mainpath, year);
- strPathOfYearldf.Format("%s\\数据\\%d_log.ldf", g_mainpath, year);
- CString strPathOfnulldbmdf = g_mainpath + "\\数据\\dbnull.mdf";
- CString strPathOfnulldbldf = g_mainpath + "\\数据\\dbnull_log.ldf";
- if (PathFileExists(strPathOfYearmdf) == TRUE)
- {
- if (PathFileExists(strPathOfYearldf) == TRUE)
- {
- sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", year, strPathOfYearmdf, strPathOfYearldf);
- }
- else
- {
- // 此时要删除dbnull_log.ldf文件;
- // 因为如果2015没有对应的ldf文件,在逻辑名仍为dbnull没有改为2015时,他会使用dbnull_log.ldf做为2015数据库的日志文件;
- // 这样造成其他数据库在使用dbnull时会产生错误;
- DeleteFile(strPathOfnulldbldf);
- sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
- }
- g_db.SetQueryTimeout(600);
- try
- {
- g_db.ExecuteSQL(sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("历史数据库初始化失败!");
- e->Delete();
- return;
- }
- }
- else
- {
- // 判断dbnull.mdf文件是否存在;
- if (PathFileExists(strPathOfnulldbmdf) == FALSE)
- {
- WriteTextLog("空数据库丢失!");
- return;
- }
- // 判断拷贝mdf文件是否失败;
- if (FALSE == CopyFile(strPathOfnulldbmdf, strPathOfYearmdf, 1))
- {
- DWORD dwError = ::GetLastError();
- CString strDescription;
- strDescription.Format("dbnull.mdf拷贝为%d.mdf失败", year);
- ErrorExit(strDescription, dwError);
- return;
- }
- else
- {
- DeleteFile(strPathOfYearldf); // 删除%d_log.LDF文件;
- if (PathFileExists(strPathOfnulldbldf) == TRUE)
- {
- if (FALSE == CopyFile(strPathOfnulldbldf, strPathOfYearldf, 1))
- {
- DWORD dwError = ::GetLastError();
- CString strDescription;
- strDescription.Format("null.mdf拷贝为%d.mdf", year);
- ErrorExit(strDescription, dwError);
- // 此时要删除dbnull_log.ldf文件;
- // 因为如果2015没有对应的ldf文件,在逻辑名仍为dbnull没有改为2015时,他会使用dbnull_log.ldf做为2015数据库的日志文件;
- // 这样造成其他数据库在使用dbnull时会产生错误;
- DeleteFile(strPathOfnulldbldf);
- sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
- }
- else
- {
- sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", year, strPathOfYearmdf, strPathOfYearldf);
- }
- }
- else
- {
- // 此时要删除dbnull_log.ldf文件;
- // 因为如果2015没有对应的ldf文件,在逻辑名仍为dbnull没有改为2015时,他会使用dbnull_log.ldf做为2015数据库的日志文件;
- // 这样造成其他数据库在使用dbnull时会产生错误;
- DeleteFile(strPathOfnulldbldf);
- sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
- }
- g_db.SetQueryTimeout(600);
- try
- {
- g_db.ExecuteSQL(sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("历史数据库初始化失败!");
- e->Delete();
- return;
- }
- }
- }
- // 附加成功后,修改逻辑名称;
- sql.Format("alter database [%d] modify file(name='dbnull',newname='%d')", year, year);
- try
- {
- g_db.ExecuteSQL(sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("修改历史数据库主文件逻辑名失败,请手动修改!");
- e->Delete();
- }
- sql.Format("alter database [%d] modify file(name='dbnull_log',newname='%d_log')", year, year);
- try
- {
- g_db.ExecuteSQL(sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("修改历史数据库日志文件逻辑名失败,请手动修改!");
- e->Delete();
- }
- OnExit2();
- #else
- CString path,sql;
- path.Format ("%s\\数据\\%d.mdb", g_mainpath, year);
- if(::PathFileExists (path)==0)
- {
- CString nulldb=g_mainpath+"\\数据\\dbnull.mdb";
- ::CopyFile (nulldb, path, 1);
- CDatabase *db=new CDatabase;
- CString strCon;
- strCon.Format("DRIVER=Microsoft Access Driver (*.mdb);DSN='';DBQ=%s;PWD=lijialyfz",path);
- if(db->OpenEx(strCon,CDatabase::noOdbcDialog))
- {
- g_nYearArray.Add (year);
- g_dbHistoryArray.Add (db);
- sql.Format ("insert into historydb([year])values('%d')", year);
- MyExecuteSQL(&g_db, sql);
- }
- else
- delete db;
- }
- #endif
- }
- catch (...)
- {
- WriteTextLog("出错在函数CheckYear中");
- }
- }
- #else
- void CDBServerDlg::CheckYear(int year)
- {
- try
- {
- #ifdef SQLSERVER_VERSION
- CString strPathOfYearmdf;
- CString strPathOfYearldf;
- CString sql;
- strPathOfYearmdf.Format("%s\\数据\\%d.mdf", g_mainpath, year);
- strPathOfYearldf.Format("%s\\数据\\%d_log.LDF", g_mainpath, year);
- ::DeleteFile(strPathOfYearldf); // 删除%d_log.LDF文件;
- {
- CString strPathOfnulldbmdf = g_mainpath + "\\数据\\dbnull.mdf";
- CString strPathOfnulldbldf = g_mainpath + "\\数据\\dbnull_log.LDF";
- ::DeleteFile(strPathOfnulldbldf); // 删除%d_log.LDF文件;
- // 1.判断null.mdf文件是否存在;
- if (::PathFileExists(strPathOfnulldbmdf) == 0)
- {
- WriteTextLog("空数据库丢失!");
- return;
- }
- // 2.若年份mdf文件不存在,用null.mdf复制一份年份mdf数据库文件;
- BOOL bCopyed = 0;
- if (::PathFileExists(strPathOfYearmdf) == 0)
- {
- #if 0
- ::CopyFile(nulldb, path, 1);
- bCopyed=1;
- #else // Jeff add:判断拷贝文件失败的原因;
- if (!::CopyFile(strPathOfnulldbmdf, strPathOfYearmdf, 1))
- {
- DWORD dwError = ::GetLastError();
- CString strDescription;
- strDescription.Format("null.mdf拷贝为%d.mdf", year);
- ErrorExit(strDescription, dwError);
- // return;//直接返回;
- }
- else
- {
- bCopyed = 1;
- }
- #endif
- }
- if (::PathFileExists(strPathOfYearmdf) == 0)
- {
- WriteTextLog("拷贝数据库文件失败!");
- return;
- }
- BOOL bLog = 0;
- if (::PathFileExists(strPathOfnulldbldf))
- {
- bLog = 1;
- }
- // .将年份数据库mdf附加到数据库里;
- CString sql;
- if (bCopyed)
- {
- if (bLog)
- sql.Format("exec sp_attach_db '%s',@filename1='%s',@filename2='%s'", "dbnull", strPathOfYearmdf, strPathOfYearldf);
- else
- sql.Format("exec sp_attach_db '%s',@filename1='%s'", "dbnull", strPathOfYearmdf);
- g_db.SetQueryTimeout(600);
- try
- {
- g_db.ExecuteSQL(sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("历史数据库初始化失败!");
- e->Delete();
- }
- sql.Format("exec sp_renamedb '%s','%d'", "dbnull", year); g_db.ExecuteSQL(sql);
- }
- else // 没有执行CopyFile,年份mdf原本就存在;
- {
- if (bLog)
- sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", year, strPathOfYearmdf, strPathOfYearldf);
- else
- sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
- g_db.SetQueryTimeout(600);
- try
- {
- g_db.ExecuteSQL(sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("历史数据库初始化失败!");
- e->Delete();
- }
- }
- OnExit2();
- /* g_db.SetQueryTimeout(100);
- CDatabase *db=new CDatabase;
- try
- {
- CString strCon;
- strCon.Format(_T("driver={SQL Server};Server=%s;DATABASE=%d;%s"), g_sservrename,year,g_sdbpsw);
- db->OpenEx(strCon,CDatabase::noOdbcDialog);
- g_nYearArray.Add (year);
- dbarray.Add (db);
- sql.Format ("insert into [historydb]([year])values('%d')", year);
- MyExecuteSQL(&g_db, sql);
- }
- catch(CDBException * e)
- {
- delete db;
- WriteTextLog(e->m_strError);
- WriteTextLog("历史数据库打开失败!");
- }*/
- }
- #else
- CString path,sql;
- path.Format ("%s\\数据\\%d.mdb", g_mainpath, year);
- if(::PathFileExists (path)==0)
- {
- CString nulldb=g_mainpath+"\\数据\\dbnull.mdb";
- ::CopyFile (nulldb, path, 1);
- CDatabase *db=new CDatabase;
- CString strCon;
- strCon.Format("DRIVER=Microsoft Access Driver (*.mdb);DSN='';DBQ=%s;PWD=lijialyfz",path);
- if(db->OpenEx(strCon,CDatabase::noOdbcDialog))
- {
- g_nYearArray.Add (year);
- g_dbHistoryArray.Add (db);
- sql.Format ("insert into historydb([year])values('%d')", year);
- MyExecuteSQL(&g_db, sql);
- }
- else
- delete db;
- }
- #endif
- }
- catch (...)
- {
- WriteTextLog("出错在函数CheckYear中");
- }
- }
- #endif
- CDatabase* CDBServerDlg::GetDB(int year)
- {
- try
- {
- for (int i = 0; i < g_nYearArray.GetSize(); i++)
- {
- if (g_nYearArray.ElementAt(i) == year)
- {
- return g_dbHistoryArray.ElementAt(i);
- }
- }
- return NULL;
- }
- catch (...)
- {
- WriteTextLog("出错在函数GetDB中");
- }
- }
- /************************************************************************/
- /* mark by Jeff;
- /* 函数:CheckDinDanExist
- /* 描述:
- /* 参数:
- /* pBeConverted_db:(源)
- /* pToConverted_db:(目标)
- /* strOderNumber:
- /* pRetArray:
- /*
- /* 返回:1表示正常,100及以上表示源数据库里记录 > 目标数据库记录;
- /*
- /************************************************************************/
- BOOL CDBServerDlg::CheckDinDanExist(CDatabase *pBeConverted_db, CDatabase *pToConverted_db, CString strOderNumber, CStringArray *pRetArray)
- {
- try
- {
- pRetArray->RemoveAll();
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from dindan where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from dindan where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)//100
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from dindansp where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from dindansp where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)//101
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from dindanbukuan where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from dindanbukuan where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)//102
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from dindanbukuan2 where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from dindanbukuan2 where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)//103
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from photoprint where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from photoprint where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)//104
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from client where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from client where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)//105
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from burncdreg where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from burncdreg where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)//7
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from digitalwork where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from digitalwork where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)//8
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from mywork where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from mywork where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)//9
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from dindanjd where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from dindanjd where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)//10
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from dindansp2 where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from dindansp2 where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from dindansp3 where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from dindansp3 where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- for (int i = 0; i < pRetArray->GetSize(); i++)
- {
- if (pRetArray->ElementAt(i) == "0")return 100 + i;
- }
- return 1;
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("出错在函数check1中");
- e->Delete();
- }
- return 100;
- }
- BOOL CDBServerDlg::CheckPayOutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql.Format("select count(*) as cot from gudingfeiyong where [id]=%d", atol(id));
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from gudingfeiyong where [id]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check2中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckIncomeExist(CDatabase *pdb1, CDatabase *pdb2, CString id, CStringArray *pretarray)
- {
- try
- {
- pretarray->RemoveAll();
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql.Format("select count(*) as cot from singleincome where [id]=%d", atol(id));
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from singleincome where [id]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pretarray->Add("0");
- else
- pretarray->Add("1");
- {
- CRecordset myset(pdb1);
- sql.Format("select count(*) as cot from singleincomemoney where [id]='%s'", id);
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql.Format("select count(*) as cot from singleincomemoney where [id]='%s'", id);
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pretarray->Add("0");
- else
- pretarray->Add("1");
- for (int i = 0; i < pretarray->GetSize(); i++)
- {
- if (pretarray->ElementAt(i) == "0")return 0;
- }
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckIncomeMoneyExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql.Format("select count(*) as cot from singleincomemoney where [id]='%s'", id);
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql.Format("select count(*) as cot from singleincomemoney where [id]='%s'", id);
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- /************************************************************************/
- /* mark by Jeff
- /* 函数:TransDinDan
- /* 描述:
- /* 参数:
- /* pBeConverted_db:被转换的数据库(源);
- /* pToConverted_db:要转到的数据库(目标);
- /* strOrderNumber: 订单号;
- /* nYear: 要转换的年份;
- /*
- /* 返回:
- /************************************************************************/
- int CDBServerDlg::TransDinDan(CDatabase *pBeConverted_db, CDatabase *pToConverted_db, CString strOrderNumber, int nYear)
- {
- int step = 0;
- CStringArray retarray;
- try
- {
- CString sql, str;
- // CheckDinDanExist返回:1表示正常, 100及以上表示源数据库里记录 > 目标数据库记录;
- if (CheckDinDanExist(pBeConverted_db, pToConverted_db, strOrderNumber, &retarray) == 1)
- return 1;
- step = 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- int ret = 1;
- // 以下全是insert into 到目录数据库中;
- CRecordset myset(pBeConverted_db);
- try
- {
- if (retarray.ElementAt(0) == "0")
- {
- sql.Format("insert into [%d].[dbo].[dindan] select * from [%s].[dbo].[dindan] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step2" + e->m_strError);
- e->Delete();
- ret = 2;
- }
- step = 2;
- try
- {
- if (retarray.ElementAt(1) == "0")
- {
- sql.Format("insert into [%d].[dbo].[dindansp] select * from [%s].[dbo].[dindansp] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step3" + e->m_strError);
- e->Delete();
- ret = 3;
- }
- step = 3;
- try
- {
- if (retarray.ElementAt(2) == "0")
- {
- 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);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step4" + e->m_strError);
- e->Delete();
- ret = 4;
- }
- step = 4;
- try
- {
- if (retarray.ElementAt(3) == "0")
- {
- 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);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step5" + e->m_strError);
- e->Delete();
- ret = 5;
- }
- step = 5;
- try
- {
- if (retarray.ElementAt(4) == "0")
- {
- sql.Format("insert into [%d].[dbo].[photoprint] select * from [%s].[dbo].[photoprint] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step6" + e->m_strError);
- e->Delete();
- ret = 6;
- }
- step = 6;
- try
- {
- if (retarray.ElementAt(5) == "0")
- {
- sql.Format("insert into [%d].[dbo].[client] select * from [%s].[dbo].[client] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step7" + e->m_strError);
- e->Delete();
- ret = 7;
- }
- step = 7;
- try
- {
- if (retarray.ElementAt(6) == "0")
- {
- sql.Format("insert into [%d].[dbo].[burncdreg] select * from [%s].[dbo].[burncdreg] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step8" + e->m_strError);
- e->Delete();
- ret = 8;
- }
- step = 8;
- try
- {
- if (retarray.ElementAt(7) == "0")
- {
- sql.Format("insert into [%d].[dbo].[digitalwork] select * from [%s].[dbo].[digitalwork] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step9" + e->m_strError);
- e->Delete();
- ret = 9;
- }
- step = 9;
- try
- {
- if (retarray.ElementAt(8) == "0")
- {
- sql.Format("insert into [%d].[dbo].[mywork] select * from [%s].[dbo].[mywork] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step10" + e->m_strError);
- e->Delete();
- ret = 10;
- }
- step = 10;
- try
- {
- if (retarray.ElementAt(9) == "0")
- {
- sql.Format("insert into [%d].[dbo].[dindanjd] select * from [%s].[dbo].[dindanjd] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step11" + e->m_strError);
- e->Delete();
- ret = 11;
- }
- step = 11;
- try
- {
- if (retarray.ElementAt(10) == "0")
- {
- sql.Format("insert into [%d].[dbo].[dindansp2] select * from [%s].[dbo].[dindansp2] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step12" + e->m_strError);
- e->Delete();
- ret = 12;
- }
- step = 12;
- try
- {
- if (retarray.ElementAt(11) == "0")
- {
- sql.Format("insert into [%d].[dbo].[dindansp3] select * from [%s].[dbo].[dindansp3] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step13" + e->m_strError);
- e->Delete();
- ret = 13;
- }
- if (ret != 1)return 200 + ret;
- // 插入到目标数据库后再到目标数据库里查询是否存在;
- return CheckDinDanExist(pBeConverted_db, pToConverted_db, strOrderNumber, &retarray);
- }
- catch (...)
- {
- CString str;
- str.Format("%d size:%d", step, retarray.GetSize());
- WriteTextLog("出错在函数trans1中-" + str);
- }
- return 0;
- }
- BOOL CDBServerDlg::TransPayOut(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckPayOutExist(pdb1, pdb2, id))return 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[gudingfeiyong] select * from [%s].[dbo].[gudingfeiyong] where id=%d", year, g_nCurConvertDBName, atol(id));
- MyExecuteSQL(pdb1, sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- e->Delete();
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckPayOutExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans2中");
- }
- return 0;
- }
- //singleincome
- BOOL CDBServerDlg::TransIncome(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- CStringArray retarray;
- if (CheckIncomeExist(pdb1, pdb2, id, &retarray))return 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- if (retarray.ElementAt(0) == "0")
- {
- sql.Format("insert into [%d].[dbo].[singleincome] select * from [%s].[dbo].[singleincome] where id=%d", year, g_nCurConvertDBName, atol(id));
- MyExecuteSQL(pdb1, sql);
- }
- }
- catch (...)
- {
- ret = 0;
- }
- try
- {
- if (retarray.ElementAt(1) == "0")
- {
- sql.Format("insert into [%d].[dbo].[singleincomemoney] select * from [%s].[dbo].[singleincomemoney] where id='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- e->Delete();
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckIncomeExist(pdb1, pdb2, id, &retarray);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::TransIncomeMoney(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckIncomeMoneyExist(pdb1, pdb2, id))return 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[singleincomemoney] select * from [%s].[dbo].[singleincomemoney] where id='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- e->Delete();
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckIncomeMoneyExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Checkclient2phonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from client2phonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from client2phonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transclient2phonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (Checkclient2phonerecordExist(pdb1, pdb2, id))return 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[client2phonerecord] select * from [%s].[dbo].[client2phonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return Checkclient2phonerecordExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Checkclient3phonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from client3phonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from client3phonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transclient3phonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (Checkclient3phonerecordExist(pdb1, pdb2, id))return 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[client3phonerecord] select * from [%s].[dbo].[client3phonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return Checkclient3phonerecordExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Checkclient2phonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from client2phonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from client2phonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transclient2phonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (Checkclient2phonerecordoutExist(pdb1, pdb2, id))return 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[client2phonerecordout] select * from [%s].[dbo].[client2phonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return Checkclient2phonerecordoutExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Checkclient3phonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from client3phonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from client3phonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transclient3phonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (Checkclient3phonerecordoutExist(pdb1, pdb2, id))return 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[client3phonerecordout] select * from [%s].[dbo].[client3phonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return Checkclient3phonerecordoutExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckemployeephonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from employeephonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from employeephonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transemployeephonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckemployeephonerecordExist(pdb1, pdb2, id))return 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[employeephonerecord] select * from [%s].[dbo].[employeephonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckemployeephonerecordExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckemployeephonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from employeephonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from employeephonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transemployeephonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckemployeephonerecordoutExist(pdb1, pdb2, id))return 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[employeephonerecordout] select * from [%s].[dbo].[employeephonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckemployeephonerecordoutExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckphonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from phonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from phonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transphonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckphonerecordExist(pdb1, pdb2, id))return 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[phonerecord] select * from [%s].[dbo].[phonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckphonerecordExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckphonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from phonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from phonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transphonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckphonerecordoutExist(pdb1, pdb2, id))return 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[phonerecordout] select * from [%s].[dbo].[phonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckphonerecordoutExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckunknownphonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from unknownphonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from unknownphonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transunknownphonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckunknownphonerecordExist(pdb1, pdb2, id))return 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[unknownphonerecord] select * from [%s].[dbo].[unknownphonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckunknownphonerecordExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckunknownphonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from unknownphonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from unknownphonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transunknownphonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckunknownphonerecordoutExist(pdb1, pdb2, id))return 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[unknownphonerecordout] select * from [%s].[dbo].[unknownphonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckunknownphonerecordoutExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckmisscallrecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from misscallrecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from misscallrecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transmisscallrecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckmisscallrecordExist(pdb1, pdb2, id))return 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[misscallrecord] select * from [%s].[dbo].[misscallrecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckmisscallrecordExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckSendReg(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql.Format("select count(*) as cot from sendreg where [timestamp]='%s'", id);
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql.Format("select count(*) as cot from sendreg where [timestamp]='%s'", id);
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::TransSendReg(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckSendReg(pdb1, pdb2, id))return 1;
- CString temp;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[sendreg] select * from [%s].[dbo].[sendreg] where [timestamp]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckSendReg(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- void CDBServerDlg::MyExecuteSQL(CDatabase* pdb, CString sql)
- {
- try
- {
- MyLock lock("dbaccessxiao");
- pdb->ExecuteSQL(sql);
- }
- catch (...)
- {
- // WriteTextLog("出错在函数executesql中");
- }
- }
- void CDBServerDlg::UpdateDate()
- {
- try
- {
- /* CString tm,sql;
- tm=CTime::GetCurrentTime ().Format ("%Y-%m-%d");
- sql.Format ("update version set curdate='%s'",tm);
- MyExecuteSQL(&g_db, sql);
- */
- /* CTime tm2=CTime::GetCurrentTime ();
- CTimeSpan dt2(365, 0, 0, 0);
- tm2-=dt2;
- tm=tm2.Format ("%Y%m%d%H%M%S");
- sql.Format ("delete from sendreg where timestamp<'%s'",tm);
- MyExecuteSQL(&g_db, sql);*/
- HWND hwnd = ::FindWindow(NULL, "AutoRun.exe - 应用程序错误");
- if (hwnd)
- {
- HWND child = ::FindWindowEx(hwnd, 0, NULL, "确定");
- CWnd *pWnd = CWnd::FromHandle(child);
- ::PostMessage(hwnd, WM_COMMAND, pWnd->GetDlgCtrlID(), (LPARAM)child);
- }
- CString autorunpath = g_mainpath + "\\AutoRun.exe";
- if (0 == g_bConvertHisAll)
- ShellExecute(NULL, _T("open"), g_mainpath + "\\AutoRun.exe", NULL, NULL, SW_HIDE);
- autorunpath = g_mainpath + "\\MsgServer.exe";
- ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
- #ifdef ENTERPRISE_VERSION
- autorunpath = g_mainpath + "\\DataSyncReceive.exe";
- ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
- autorunpath = g_mainpath + "\\DataSyncSend.exe";
- ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
- autorunpath = g_mainpath + "\\CPhotoFTPReceive.exe";
- ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
- autorunpath = g_mainpath + "\\CPhotoFTPSend.exe";
- ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
- #endif
- }
- catch (...)
- {
- WriteTextLog("出错在函数UpdateDate中");
- }
- }
- BOOL CheckDateOK(CString str)
- {
- try
- {
- CString tip;
- int i;
- CString demo = CTime::GetCurrentTime().Format("%Y-%m-%d");
- if (str.GetLength() != demo.GetLength())
- goto ll;
- //2009-01-01
- if (str.GetAt(4) != '-')
- goto ll;
- if (str.GetAt(7) != '-')
- goto ll;
- for (i = 0; i < str.GetLength(); i++)
- {
- if (i == 4 || i == 7)continue;
- if (str.GetAt(i) < '0' || str.GetAt(i) > '9')
- goto ll;
- }
- return 1;
- ll:
- return 0;
- }
- catch (...)
- {
- WriteTextLog("出错");
- }
- }
- //--------------------------------------------------------------------------
- // Remark by Jeff:2014.10.22
- // 函数:AutoDelPhoto
- // 描述:自动删除取件后的订单相片,包括客户原片、初修片、精修片、设计片。(不含备份相片)
- // 参数:#
- // 返回:#
- //
- // 调用关系:
- // 1.AutoDelPhoto()由 BakPhoto()调用。
- // 2.BakPhoto()由CDBServerDlg::SetTimer(4) 调用,调用频率2分钟,周期数直到程序结束。
- // 3.CDBServerDlg::SetTimer(4) 由 CDBServerDlg::SetTimer(2) 调用,调用频率10毫秒,只有一个周期。
- // 4.CDBServerDlg::SetTimer(2) 由 CDBServerDlg::OnInitDialog() 调用.
- //
- //--------------------------------------------------------------------------
- void CDBServerDlg::AutoDelPhoto() // Jeff自动删除取件后的订单相片;
- {
- try
- {
- #ifdef ENTERPRISE_VERSION
- GenYLGL();
- #endif
- g_curdb = &g_db;
- CString m_check1; // 自动删除客人原片;
- CString m_check2; // 自动删除客人初修片;
- CString m_check3; // 自动删除客人精修片;
- CString m_check4; // 自动删除客人设计片;
- CString m_edit1; // 多少个月后删除原片;
- CString m_edit2; // 多少个月后删除初修片;
- CString m_edit3; // 多少个月后删除精修片;
- CString m_edit4; // 多少个月后删除设计片;
- CString m_bakserver1; // 自动备份客人原片的备份机器;
- CString m_bakserver2; // 自动备份客人初修片的备份机器
- CString m_bakserver3; // 自动备份客人精修片的备份机器;
- CString m_bakserver4; // 自动备份客人设计片的备份机器;
- // CDBServerDlg::m_bakserver5 : 自动备份系统数据的备份机器;
- // 1.从version表中获取状态信息;
- CRstversion tableOfVersion;
- tableOfVersion.m_pDatabase = g_curdb;
- tableOfVersion.Open();
- if (!tableOfVersion.IsEOF())
- {
- m_check1 = tableOfVersion.m_check1;
- m_check2 = tableOfVersion.m_check2;
- m_check3 = tableOfVersion.m_check3;
- m_check4 = tableOfVersion.m_check4;
- m_edit1 = tableOfVersion.m_edit1;
- m_edit2 = tableOfVersion.m_edit2;
- m_edit3 = tableOfVersion.m_edit3;
- m_edit4 = tableOfVersion.m_edit4;
- m_bakserver1 = tableOfVersion.m_bakserver1;
- m_bakserver2 = tableOfVersion.m_bakserver2;
- m_bakserver3 = tableOfVersion.m_bakserver3;
- m_bakserver4 = tableOfVersion.m_bakserver4;
- m_bakserver5 = tableOfVersion.m_bakserver5;
- }
- tableOfVersion.Close();
- // 2.
- g_bakinfo = "资料未备份";
- g_bakphoto = "照片未备份";
- WriteTextLog("开始备份数据库");
- if (!m_bakserver5.IsEmpty()) // 自动备份系统数据的备份机器;
- {
- CString bakpath;
- CString localname;
- localname = g_localname;
- #ifdef CHILD_VERSION
- if (m_bakserver5.Find(":") == -1 && m_bakserver5 != "")
- m_bakserver5 = "\\\\" + m_bakserver5 + "\\数据备份(儿童管理软件)$";
- if (1)//localname.CompareNoCase (m_bakserver5)==0 || CompareIP(localname, m_bakserver5)==0)
- GetPathFromNetShareName("数据备份(儿童管理软件)$", m_bakserver5);
- #else
- if (m_bakserver5.Find(":") == -1 && m_bakserver5 != "")
- m_bakserver5 = "\\\\" + m_bakserver5 + "\\数据备份(管理软件)$";
- if (1)//localname.CompareNoCase (m_bakserver5)==0 || CompareIP(localname, m_bakserver5)==0)
- GetPathFromNetShareName("数据备份(管理软件)$", m_bakserver5);
- #endif
- WriteTextLog(m_bakserver5);
- if (::CheckFolderFileExist(m_bakserver5))
- BakData(m_bakserver5, 1, 1);
- }
- WriteTextLog("数据库备份完成"); // Jeff:只是备份数据库;
- BOOL bcheck1 = atoi(m_check1);
- BOOL bcheck2 = atoi(m_check2);
- BOOL bcheck3 = atoi(m_check3);
- BOOL bcheck4 = atoi(m_check4);
- #if 0 // Jeff:old code;
- if (!(bcheck1 || bcheck2 || bcheck3 || bcheck4))
- {
- return;
- }
- #else
- // 四个同时为假,退出删除操作;
- if (!(bcheck1 | bcheck2 | bcheck3 | bcheck4))
- {
- return;
- }
- #endif
- int edit1 = atoi(m_edit1);
- int edit2 = atoi(m_edit2);
- int edit3 = atoi(m_edit3);
- int edit4 = atoi(m_edit4);
- // path 4种类型相片的存储目录;
- CStringArray patharray;
- {
- char server[50];
- DWORD leng = 50;
- ::GetComputerName(server, &leng);
- CString spathserver = server;
- CString g_path1;
- CString g_path2;
- CString g_path3;
- CString g_path4;
- g_path1 = g_path2 = g_path3 = g_path4 = server;
- g_path1 = "\\\\" + g_path1 + "\\客户原片(管理软件)$";
- g_path2 = "\\\\" + g_path2 + "\\修好的片(管理软件)$";
- g_path3 = "\\\\" + g_path3 + "\\设计好的片(管理软件)$";
- g_path4 = "\\\\" + g_path4 + "\\精修好的片(管理软件)$";
- GetPathFromNetShareName("客户原片(管理软件)$", g_path1);
- GetPathFromNetShareName("修好的片(管理软件)$", g_path2);
- GetPathFromNetShareName("设计好的片(管理软件)$", g_path3);
- GetPathFromNetShareName("精修好的片(管理软件)$", g_path4);
- patharray.Add(g_path1);
- patharray.Add(g_path2);
- patharray.Add(g_path4);
- patharray.Add(g_path3);
- }
- if (patharray.GetSize() == 0)
- return;
- CArray<CDatabase*, CDatabase*>dbarray2;
- dbarray2.Copy(g_dbHistoryArray);
- dbarray2.InsertAt(0, &g_db);
- //------------------------------------------------------------------------------------------------------------------------
- WriteTextLog("开始删除取件后照片");
- for (int n = 0; n < min(3, dbarray2.GetSize()); n++)
- {
- g_curdb = dbarray2.ElementAt(n);
- CArray<CStringArray, CStringArray>strArrayOfPhoto2BeDel;
- CString filter = "status3='OK' and time5 is not null and time5<>''";
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from dindan";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- if (count == 0)continue;
- strArrayOfPhoto2BeDel.SetSize(count, 1);
- CRstDindanForm rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- INT_PTR nIndex = 0;
- while (!rsSt.IsEOF())
- {
- strArrayOfPhoto2BeDel.ElementAt(nIndex).RemoveAll();
- strArrayOfPhoto2BeDel.ElementAt(nIndex).Add(rsSt.id);
- strArrayOfPhoto2BeDel.ElementAt(nIndex).Add(rsSt.time5);
- nIndex++;
- rsSt.MoveNext();
- if (strArrayOfPhoto2BeDel.GetSize() <= nIndex)break;
- }
- rsSt.Close();
- strArrayOfPhoto2BeDel.SetSize(nIndex, 1);
- CString time5;
- CString id;
- CTime curtm = CTime::GetCurrentTime();
- CString strtime;
- for (int i = 0; i < strArrayOfPhoto2BeDel.GetSize(); i++)
- {
- id = strArrayOfPhoto2BeDel.ElementAt(i).ElementAt(0);
- time5 = strArrayOfPhoto2BeDel.ElementAt(i).ElementAt(1);
- if (bcheck1)//原片
- {
- CTimeSpan sp(edit1 * 30, 0, 0, 0);
- CTime tm = curtm - sp;
- strtime = tm.Format("%Y-%m-%d");
- if (strtime > time5) // Jeff,这种比较是否正确???
- {
- if (DelPhoto1(patharray.ElementAt(0), strArrayOfPhoto2BeDel.ElementAt(i).ElementAt(0)))
- WriteTextLog("原片" + patharray.ElementAt(0) + "\\" + strArrayOfPhoto2BeDel.ElementAt(i).ElementAt(0));
- // DelPhoto1(patharray2.ElementAt (0),g_List1array.ElementAt (i).ElementAt (0));
- }
- }
- if (bcheck2)
- {
- CTimeSpan sp(edit2 * 30, 0, 0, 0);
- CTime tm = curtm - sp;
- strtime = tm.Format("%Y-%m-%d");
- if (strtime > time5)
- {
- DelPhoto1(patharray.ElementAt(1), strArrayOfPhoto2BeDel.ElementAt(i).ElementAt(0));
- // DelPhoto1(patharray2.ElementAt (2),g_List1array.ElementAt (i).ElementAt (0));
- }
- }
- if (bcheck3)
- {
- CTimeSpan sp(edit3 * 30, 0, 0, 0);
- CTime tm = curtm - sp;
- strtime = tm.Format("%Y-%m-%d");
- if (strtime > time5)
- {
- DelPhoto1(patharray.ElementAt(2), strArrayOfPhoto2BeDel.ElementAt(i).ElementAt(0));
- // DelPhoto1(patharray2.ElementAt (2),g_List1array.ElementAt (i).ElementAt (0));
- }
- }
- if (bcheck4)
- {
- CTimeSpan sp(edit4 * 30, 0, 0, 0);
- CTime tm = curtm - sp;
- strtime = tm.Format("%Y-%m-%d");
- if (strtime > time5)
- {
- DelPhoto1(patharray.ElementAt(3), strArrayOfPhoto2BeDel.ElementAt(i).ElementAt(0));
- }
- }
- }
- }
- //------------------------------------------------------------------------------------------------------------------------
- g_curdb = &g_db;
- #ifdef ENTERPRISE_VERSION // Jeff:若是集团版,会再次删除本店已取件的历史订单一次。多操作了一次!
- WriteTextLog("本店查完,开始检查分店");
- CString g_domain;
- CArray<CStringArray, CStringArray>g_List1array;
- CString autorunpath = g_mainpath + "\\branchdindan.dat";
- CFile fp;
- if (fp.Open(autorunpath, CFile::modeRead))
- {
- int nMessageLen = fp.GetLength();
- BYTE *pData = new BYTE[nMessageLen];
- fp.Read(pData, nMessageLen);
- fp.Close();
- BYTE *szChatMessage = pData;
- int count;
- memcpy(&count, szChatMessage + (nMessageLen - sizeof(int)), sizeof(int));
- CMemFile memfile;
- memfile.Attach(szChatMessage, nMessageLen);
- CArchive ar(&memfile, CArchive::load);
- g_List1array.SetSize(count);
- for (int ii = 0; ii < g_List1array.GetSize(); ii++)
- {
- g_List1array.ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- delete[]pData;
- }
- CString time5, id;
- CTime curtm = CTime::GetCurrentTime();
- CString strtime;
- for (int i = 0; i < g_List1array.GetSize(); i++)
- {
- g_domain = "\\" + g_List1array.ElementAt(i).ElementAt(0);
- if (g_domain.Find(".ly.com") == -1)continue;
- id = g_List1array.ElementAt(i).ElementAt(1);
- time5 = g_List1array.ElementAt(i).ElementAt(2);
- if (bcheck1)//原片
- {
- CTimeSpan sp(edit1 * 30, 0, 0, 0);
- CTime tm = curtm - sp;
- strtime = tm.Format("%Y-%m-%d");
- if (strtime > time5)
- {
- if (DelPhoto1(patharray.ElementAt(0) + g_domain, id))
- WriteTextLog("分店原片" + patharray.ElementAt(0) + g_domain + "\\" + id);
- }
- }
- if (bcheck2)
- {
- CTimeSpan sp(edit2 * 30, 0, 0, 0);
- CTime tm = curtm - sp;
- strtime = tm.Format("%Y-%m-%d");
- if (strtime > time5)
- {
- DelPhoto1(patharray.ElementAt(1) + g_domain, id);
- // DelPhoto1(patharray2.ElementAt (2),id);
- }
- }
- if (bcheck3)
- {
- CTimeSpan sp(edit3 * 30, 0, 0, 0);
- CTime tm = curtm - sp;
- strtime = tm.Format("%Y-%m-%d");
- if (strtime > time5)
- {
- DelPhoto1(patharray.ElementAt(2) + g_domain, id);
- // DelPhoto1(patharray2.ElementAt (2),id);
- }
- }
- if (bcheck4)
- {
- CTimeSpan sp(edit4 * 30, 0, 0, 0);
- CTime tm = curtm - sp;
- strtime = tm.Format("%Y-%m-%d");
- if (strtime > time5)
- {
- DelPhoto1(patharray.ElementAt(3) + g_domain, id);
- }
- }
- }
- g_curdb = &g_db;
- #endif
- WriteTextLog("检查删除照片完成");
- }
- catch (...)
- {
- WriteTextLog("出错在函数AutoDelPhoto中");
- }
- g_curdb = &g_db;
- }
- //------------------------------------------------------------------
- // Remark by Jeff:2014.10.11
- // 函数:DelPhoto1
- // 描述:删除指定路径下的订单文件夹;
- // 参数:
- // path: 指定要删除文件的根目录;
- // strOrderNumber: 将要删除的订单号文件夹;
- // 返回:
- //-----------------------------------------------------------------
- BOOL CDBServerDlg::DelPhoto1(CString path, CString strOrderNumber)
- {
- if (path == "")
- return 0;
- if (::CheckFolderFileExist(path + "\\" + strOrderNumber))
- {
- DeleteDirectory(path + "\\" + strOrderNumber);
- return 1;
- }
- }
- //-----------------------------------------------------------------------
- // Remark by Jeff 2014.10.22
- // 函数:BakPhoto
- // 描述:对影楼相片进行备份和删除取件相片
- // 参数:#
- // 返回:#
- //
- // 调用关系:
- // 1.BakPhoto()由CDBServerDlg::SetTimer(4) 调用,调用频率2分钟,周期数直到程序结束。
- // 2.CDBServerDlg::SetTimer(4) 由 CDBServerDlg::SetTimer(2) 调用,调用频率10毫秒,只有一个周期。
- // 3.CDBServerDlg::SetTimer(2) 由 CDBServerDlg::OnInitDialog() 调用.
- //-----------------------------------------------------------------------
- void CDBServerDlg::BakPhoto() // Jeff:备份相片/删除取件相片;
- {
- try
- {
- g_curdb = &g_db;
- CString m_bak1, m_bak2, m_bak3, m_bak4, m_bak6, m_baktime; // Jeff:m_bak6自动备份完毕后自动关机;
- CString m_bakserver1, m_bakserver2, m_bakserver3, m_bakserver4;
- CString msgcheck4, msgtime, msgphones, msgphones2, msgcompanyname;
- CString balance, msgaccount;
- {
- MyLock lock("dbaccessxiao");
- CRstversion rsSt;
- rsSt.m_pDatabase = g_curdb;
- rsSt.Open();
- if (!rsSt.IsEOF())
- {
- m_bak1 = rsSt.m_bak1;
- m_bak2 = rsSt.m_bak2;
- m_bak3 = rsSt.m_bak3;
- m_bak4 = rsSt.m_bak4;
- m_bakserver1 = rsSt.m_bakserver1;
- m_bakserver2 = rsSt.m_bakserver2;
- m_bakserver3 = rsSt.m_bakserver3;
- m_bakserver4 = rsSt.m_bakserver4;
- m_bak6 = rsSt.m_bak6;
- m_baktime = rsSt.m_baktime;
- msgcheck4 = rsSt.msgcheck4;
- msgtime = rsSt.msgtime;
- msgphones = rsSt.msgphones;
- msgphones2 = rsSt.msgphones2;
- msgcompanyname = rsSt.msgcompanyname;
- balance = rsSt.msgbalance;
- msgaccount = rsSt.msgaccount;
- }
- rsSt.Close();
- }
- /////////////检测发短信回财务
- if (msgphones2.IsEmpty() == 0)
- {
- MyLock lock("dbaccessxiao");
- CStringArray array, timearray;
- CString timestamp;
- timestamp = CTime::GetCurrentTime().Format("%Y-%m-%d");
- timestamp += "%";
- CRecordset myset(g_curdb);
- CString sql = "select phones,timestamp from sendregreceive where [timestamp] like '" + timestamp + "' and [content]='001' and [status]='OK'";
- myset.Open(CRecordset::forwardOnly, sql);
- CString phones;
- while (!myset.IsEOF())
- {
- myset.GetFieldValue("phones", phones);
- myset.GetFieldValue("timestamp", timestamp);
- if (msgphones2.Find(phones) != -1)
- {
- array.Add(phones);
- timearray.Add(timestamp);
- }
- myset.MoveNext();
- }
- myset.Close();
- if (array.GetSize())
- {
- int i = 0;
- CString sql;
- for ( i = 0; i < array.GetSize(); i++)
- {
- sql = "update sendregreceive set [status]='' where [timestamp]='" + timearray.ElementAt(i) + "'";
- MyExecuteSQL(&g_db, sql);
- }
- CArray<CStringArray, CStringArray>List11array;
- CArray<CStringArray, CStringArray>List2array;
- CArray<CStringArray, CStringArray>List3array;
- CArray<CStringArray, CStringArray>other2salearray;
- CArray<CStringArray, CStringArray>memberarray;
- CString strdate = CTime::GetCurrentTime().Format("%Y-%m-%d");
- CArray<CDatabase*, CDatabase*>dbarraytemp;
- dbarraytemp.Copy(g_dbHistoryArray);
- while (dbarraytemp.GetSize()>1)
- {
- int last = dbarraytemp.GetSize() - 1;
- dbarraytemp.RemoveAt(last);
- }
- dbarraytemp.InsertAt(0, &g_db);
- for (int a = dbarraytemp.GetSize() - 1; a >= 0; a--)
- {
- g_curdb = dbarraytemp.ElementAt(a);
- CString filter = "[dat]='" + strdate + "'";
- filter = "[dat]='" + strdate + "' and ([sale2type] is null or [sale2type]='')";
- {
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from singleincome"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = List2array.GetSize();
- List2array.SetSize(oldsize + count, 1);
- CRstIncomeInput rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- List2array.ElementAt(oldsize + ii).RemoveAll();
- List2array.ElementAt(oldsize + ii).Add(rsSt.id);
- List2array.ElementAt(oldsize + ii).Add(rsSt.name);
- List2array.ElementAt(oldsize + ii).Add(rsSt.money);
- List2array.ElementAt(oldsize + ii).Add(rsSt.date);
- List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
- List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
- List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
- List2array.ElementAt(oldsize + ii).Add(rsSt.bz);
- List2array.ElementAt(oldsize + ii).Add(rsSt.sale2type);
- ii++;
- rsSt.MoveNext(); if (List2array.GetSize() <= ii)break;
- }
- rsSt.Close(); List2array.SetSize(oldsize + ii, 1);
- }
- filter = "[dat]='" + strdate + "'";
- {
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from gudingfeiyong"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = List3array.GetSize();
- List3array.SetSize(oldsize + count, 1);
- CRstPayOutInput rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- List3array.ElementAt(oldsize + ii).RemoveAll();
- List3array.ElementAt(oldsize + ii).Add(rsSt.id);
- List3array.ElementAt(oldsize + ii).Add(rsSt.name);
- List3array.ElementAt(oldsize + ii).Add(rsSt.money);
- List3array.ElementAt(oldsize + ii).Add(rsSt.date);
- List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
- List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
- List3array.ElementAt(oldsize + ii).Add(rsSt.bz);
- ii++;
- rsSt.MoveNext(); if (List3array.GetSize() <= ii)break;
- }
- rsSt.Close(); List3array.SetSize(oldsize + ii, 1);
- }
- filter = "[date]='" + strdate + "'";
- {
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from dindanbukuan"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = List11array.GetSize();
- List11array.SetSize(oldsize + count, 1);
- CRstBuKuan rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- List11array.ElementAt(oldsize + ii).RemoveAll();
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_id);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_ren);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_money);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_bz);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_kind);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_date);
- ii++;
- rsSt.MoveNext(); if (List11array.GetSize() <= ii)break;
- }
- rsSt.Close(); List11array.SetSize(oldsize + ii, 1);
- }
- filter = "[date]='" + strdate + "'";
- {
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from singleincomemoneyview"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = other2salearray.GetSize();
- other2salearray.SetSize(oldsize + count, 1);
- CRstsingleincomemoneyview rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- other2salearray.ElementAt(oldsize + ii).RemoveAll();
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.name);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.sale2type);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.money);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.date);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.clerk);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.paytype);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.autoid);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.financecheck);
- ii++;
- rsSt.MoveNext(); if (other2salearray.GetSize() <= ii)break;
- }
- rsSt.Close(); other2salearray.SetSize(oldsize + ii, 1);
- }
- filter = "[date]='" + strdate + "'";
- {
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from memberview"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = memberarray.GetSize();
- memberarray.SetSize(oldsize + count, 1);
- memberviewReg rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- DWORD ii = 0;
- while (!rsSt.IsEOF())
- {
- memberarray.ElementAt(oldsize + ii).RemoveAll();
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_id);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_memberno);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_name);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_money);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_date);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_clerk);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_financecheck);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_moneytype);
- ii++;
- rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
- }
- rsSt.Close(); memberarray.SetSize(oldsize + ii, 1);
- }
- }//
- g_curdb = &g_db;
- CString str;
- int pos = 0;
- int dindanshu = 0;
- float income = 0;
- float incomedd = 0;
- float incomebk = 0;
- float incomehq = 0;
- float incomeqt = 0;
- float payout = 0;
- for (i = 0; i < List11array.GetSize(); i++)
- {
- str = List11array.ElementAt(i).ElementAt(2);
- income += atof(str);
- // income2+=atof(str);
- if (List11array.ElementAt(i).ElementAt(3) == "预约收款")
- {
- incomedd += atof(str);
- dindanshu++;
- }
- else if (List11array.ElementAt(i).ElementAt(3) == "预约补款")
- {
- incomebk += atof(str);
- }
- else
- {
- incomehq += atof(str);
- }
- pos++;
- }
- for (i = 0; i < List2array.GetSize(); i++)
- {
- str = List2array.ElementAt(i).ElementAt(2);
- income += atof(str);
- /* if(List2array.ElementAt (i).ElementAt (8)!="")
- {
- income2+=atof(str);
- }*/
- if (List2array.ElementAt(i).ElementAt(8) == "")
- {
- incomeqt += atof(str);
- }
- pos++;
- }
- for (i = 0; i < List3array.GetSize(); i++)
- {
- str = List3array.ElementAt(i).ElementAt(2);
- payout += atof(str);
- pos++;
- }
- for (i = 0; i < other2salearray.GetSize(); i++)
- {
- str = other2salearray.ElementAt(i).ElementAt(4);
- income += atof(str);
- incomehq += atof(str);
- pos++;
- }
- for (i = 0; i < memberarray.GetSize(); i++)
- {
- str = memberarray.ElementAt(i).ElementAt(3);
- income += atof(str);
- pos++;
- }
- CTime tm = CTime::GetCurrentTime();
- CString content = msgcompanyname + tm.Format("%Y-%m-%d");
- content += "财报:";
- str.Format("%d", (int)income);
- ::ConvertToPrice(str);
- content += "收:" + str;
- str.Format("%d", (int)incomedd);
- ::ConvertToPrice(str);
- content += "定:" + str;
- str.Format("%d", (int)incomebk);
- ::ConvertToPrice(str);
- content += "补:" + str;
- str.Format("%d", (int)incomehq);
- ::ConvertToPrice(str);
- content += "后:" + str;
- str.Format("%d", (int)incomeqt);
- ::ConvertToPrice(str);
- content += "其它:" + str;
- str.Format("%d", (int)payout);
- ::ConvertToPrice(str);
- content += "支出:" + str;
- str.Format("%d", (int)(income - payout));
- ::ConvertToPrice(str);
- content += "净收:" + str;
- str.Format("%d", dindanshu);
- content += "定单:" + str;
- if (msgaccount != "")
- {
- if (atoi(balance) < 200)
- {
- content += "您的余额小于两百条,请及时充值。联系电话4006067068";
- }
- else if (atoi(balance) < 500)
- {
- content += "您的余额小于五百条,请及时充值。联系电话4006067068";
- }
- else if (atoi(balance) < 800)
- {
- content += "您的余额小于八百条,请及时充值。联系电话4006067068";
- }
- else if (atoi(balance) < 1000)
- {
- content += "您的余额小于一千条,请及时充值。联系电话4006067068";
- }
- }
- int count = GetLengthEx(content) / MSG_LENGTH;
- if (GetLengthEx(content) % MSG_LENGTH)
- count++;
- int phonenum = 0;
- phonenum = 1;
- count *= phonenum;
- CString scount;
- scount.Format("%d", count);
- CString timestamp = tm.Format("%Y%m%d%H%M%S");
- for (i = 0; i < 1; i++)
- {
- sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + array.ElementAt(i) + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
- MyExecuteSQL(&g_db, sql);
- }
- }
- }
- /////////////
- if (atoi(msgcheck4) && msgphones != "")
- {//发老板短信
- if (atoi(msgtime) <= CTime::GetCurrentTime().GetHour())
- {
- MyLock lock("dbaccessxiao");
- CString timestamp;
- timestamp = CTime::GetCurrentTime().Format("%Y%m%d");
- timestamp += "%";
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from sendreg where [timestamp] like '" + timestamp + "' and [phones]='" + msgphones + "' and [isautosend]='3'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- if (count == 0)
- {
- CArray<CStringArray, CStringArray>List11array;
- CArray<CStringArray, CStringArray>List2array;
- CArray<CStringArray, CStringArray>List3array;
- CArray<CStringArray, CStringArray>other2salearray;
- CArray<CStringArray, CStringArray>memberarray;
- CString strdate = CTime::GetCurrentTime().Format("%Y-%m-%d");
- CArray<CDatabase*, CDatabase*>dbarraytemp;
- dbarraytemp.Copy(g_dbHistoryArray);
- while (dbarraytemp.GetSize() > 1)
- {
- int last = dbarraytemp.GetSize() - 1;
- dbarraytemp.RemoveAt(last);
- }
- dbarraytemp.InsertAt(0, &g_db);
- for (int a = dbarraytemp.GetSize() - 1; a >= 0; a--)
- {
- g_curdb = dbarraytemp.ElementAt(a);
- CString filter = "[dat]='" + strdate + "'";
- filter = "[dat]='" + strdate + "' and ([sale2type] is null or [sale2type]='')";
- {
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from singleincome"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = List2array.GetSize();
- List2array.SetSize(oldsize + count, 1);
- CRstIncomeInput rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- List2array.ElementAt(oldsize + ii).RemoveAll();
- List2array.ElementAt(oldsize + ii).Add(rsSt.id);
- List2array.ElementAt(oldsize + ii).Add(rsSt.name);
- List2array.ElementAt(oldsize + ii).Add(rsSt.money);
- List2array.ElementAt(oldsize + ii).Add(rsSt.date);
- List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
- List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
- List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
- List2array.ElementAt(oldsize + ii).Add(rsSt.bz);
- List2array.ElementAt(oldsize + ii).Add(rsSt.sale2type);
- ii++;
- rsSt.MoveNext(); if (List2array.GetSize() <= ii)break;
- }
- rsSt.Close(); List2array.SetSize(oldsize + ii, 1);
- }
- filter = "[dat]='" + strdate + "'";
- {
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from gudingfeiyong"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = List3array.GetSize();
- List3array.SetSize(oldsize + count, 1);
- CRstPayOutInput rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- List3array.ElementAt(oldsize + ii).RemoveAll();
- List3array.ElementAt(oldsize + ii).Add(rsSt.id);
- List3array.ElementAt(oldsize + ii).Add(rsSt.name);
- List3array.ElementAt(oldsize + ii).Add(rsSt.money);
- List3array.ElementAt(oldsize + ii).Add(rsSt.date);
- List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
- List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
- List3array.ElementAt(oldsize + ii).Add(rsSt.bz);
- ii++;
- rsSt.MoveNext(); if (List3array.GetSize() <= ii)break;
- }
- rsSt.Close(); List3array.SetSize(oldsize + ii, 1);
- }
- filter = "[date]='" + strdate + "'";
- {
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from dindanbukuan"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = List11array.GetSize();
- List11array.SetSize(oldsize + count, 1);
- CRstBuKuan rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- List11array.ElementAt(oldsize + ii).RemoveAll();
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_id);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_ren);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_money);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_bz);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_kind);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_date);
- ii++;
- rsSt.MoveNext(); if (List11array.GetSize() <= ii)break;
- }
- rsSt.Close(); List11array.SetSize(oldsize + ii, 1);
- }
- filter = "[date]='" + strdate + "'";
- {
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from singleincomemoneyview"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = other2salearray.GetSize();
- other2salearray.SetSize(oldsize + count, 1);
- CRstsingleincomemoneyview rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- other2salearray.ElementAt(oldsize + ii).RemoveAll();
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.name);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.sale2type);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.money);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.date);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.clerk);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.paytype);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.autoid);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.financecheck);
- ii++;
- rsSt.MoveNext(); if (other2salearray.GetSize() <= ii)break;
- }
- rsSt.Close(); other2salearray.SetSize(oldsize + ii, 1);
- }
- filter = "[date]='" + strdate + "'";
- {
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from memberview"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = memberarray.GetSize();
- memberarray.SetSize(oldsize + count, 1);
- memberviewReg rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- DWORD ii = 0;
- while (!rsSt.IsEOF())
- {
- memberarray.ElementAt(oldsize + ii).RemoveAll();
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_id);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_memberno);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_name);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_money);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_date);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_clerk);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_financecheck);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_moneytype);
- ii++;
- rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
- }
- rsSt.Close(); memberarray.SetSize(oldsize + ii, 1);
- }
- }//
- g_curdb = &g_db;
- CString str;
- int pos = 0;
- int dindanshu = 0;
- float income = 0;
- float incomedd = 0;
- float incomebk = 0;
- float incomehq = 0;
- float incomeqt = 0;
- float payout = 0;
- int i = 0;
- for (i = 0; i < List11array.GetSize(); i++)
- {
- str = List11array.ElementAt(i).ElementAt(2);
- income += atof(str);
- // income2+=atof(str);
- if (List11array.ElementAt(i).ElementAt(3) == "预约收款")
- {
- incomedd += atof(str);
- dindanshu++;
- }
- else if (List11array.ElementAt(i).ElementAt(3) == "预约补款")
- {
- incomebk += atof(str);
- }
- else
- {
- incomehq += atof(str);
- }
- pos++;
- }
- for (i = 0; i < List2array.GetSize(); i++)
- {
- str = List2array.ElementAt(i).ElementAt(2);
- income += atof(str);
- /* if(List2array.ElementAt (i).ElementAt (8)!="")
- {
- income2+=atof(str);
- }*/
- if (List2array.ElementAt(i).ElementAt(8) == "")
- {
- incomeqt += atof(str);
- }
- pos++;
- }
- for (i = 0; i < List3array.GetSize(); i++)
- {
- str = List3array.ElementAt(i).ElementAt(2);
- payout += atof(str);
- pos++;
- }
- for (i = 0; i < other2salearray.GetSize(); i++)
- {
- str = other2salearray.ElementAt(i).ElementAt(4);
- income += atof(str);
- incomehq += atof(str);
- pos++;
- }
- for (i = 0; i < memberarray.GetSize(); i++)
- {
- str = memberarray.ElementAt(i).ElementAt(3);
- income += atof(str);
- pos++;
- }
- CTime tm = CTime::GetCurrentTime();
- CString content = msgcompanyname + tm.Format("%Y-%m-%d");
- content += "财报:";
- str.Format("%d", (int)income);
- ::ConvertToPrice(str);
- content += "收:" + str;
- str.Format("%d", (int)incomedd);
- ::ConvertToPrice(str);
- content += "定:" + str;
- str.Format("%d", (int)incomebk);
- ::ConvertToPrice(str);
- content += "补:" + str;
- str.Format("%d", (int)incomehq);
- ::ConvertToPrice(str);
- content += "后:" + str;
- str.Format("%d", (int)incomeqt);
- ::ConvertToPrice(str);
- content += "其它:" + str;
- str.Format("%d", (int)payout);
- ::ConvertToPrice(str);
- content += "支出:" + str;
- str.Format("%d", (int)(income - payout));
- ::ConvertToPrice(str);
- content += "净收:" + str;
- str.Format("%d", dindanshu);
- content += "定单:" + str;
- if (msgaccount != "")
- {
- if (atoi(balance) < 200)
- {
- content += "您的余额小于两百条,请及时充值。联系电话4006067068";
- }
- else if (atoi(balance) < 500)
- {
- content += "您的余额小于五百条,请及时充值。联系电话4006067068";
- }
- else if (atoi(balance) < 800)
- {
- content += "您的余额小于八百条,请及时充值。联系电话4006067068";
- }
- else if (atoi(balance) < 1000)
- {
- content += "您的余额小于一千条,请及时充值。联系电话4006067068";
- }
- }
- int count = GetLengthEx(content) / MSG_LENGTH;
- if (GetLengthEx(content) % MSG_LENGTH)
- count++;
- int phonenum = 0;
- str = msgphones;
- pos = str.Find(",");
- if (pos != -1)
- {
- while (pos != -1)
- {
- phonenum++;
- str = str.Right(str.GetLength() - pos - 1);
- pos = str.Find(",");
- }
- phonenum++;
- }
- else
- phonenum = 1;
- count *= phonenum;
- CString scount;
- scount.Format("%d", count);
- timestamp = tm.Format("%Y%m%d%H%M%S");
- sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + msgphones + "','" + content + "','" + timestamp + "','" + scount + "','0','0','3','系统自动发送')";
- MyExecuteSQL(&g_db, sql);
- }
- }
- }
- BOOL bcheck1 = atoi(m_bak1);
- BOOL bcheck2 = atoi(m_bak2);
- BOOL bcheck3 = atoi(m_bak3);
- BOOL bcheck4 = atoi(m_bak4);
- int hour;
- hour = CTime::GetCurrentTime().GetHour();
- // Jeff.这里不合理.如果条件不成立,那当天的数据就不会执行。存在一定安全问题。
- if (atoi(m_baktime) <= hour)
- {
- CStdioFile fp;
- if (fp.Open(g_mainpath + "\\log.txt", CFile::modeRead))
- {
- CString date;
- fp.ReadString(date);
- date.TrimRight("\r\n");
- if (date == CTime::GetCurrentTime().Format("%Y-%m-%d"))
- {
- fp.Close();
- return;
- }
- fp.Close();
- }
- if (g_bConvertHisAll)
- {
- WriteTextLog("转历史数据中, 备份退出");
- return;
- }
- g_bakdate = CTime::GetCurrentTime().Format("%Y-%m-%d");
- KillTimer(4);
- WriteTextLog("备份开始...");
- AutoDelPhoto();
- AutoDelBakPhoto();
- LoadThumbImages2();
- }
- }
- catch (...)
- {
- WriteTextLog("出错在函数bakphoto中");
- }
- }
- void CDBServerDlg::ShutDown() //Jeff:备份完毕后执行的关机函数;
- {
- try
- {
- g_curdb = &g_db;
- CString m_bak6;
- {
- CRecordset myset(g_curdb);
- CString sql = "select * from [version]";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("bak6", m_bak6);
- myset.Close();
- }
- OnServerStop(); // 停止服务;
- // Jeff.关闭数据库连接,若关机前关闭了数据库的连接,则客户端进行订单无法实现数据库的操作;
- // Jeff.在关机前,不能关闭数据库连接;
- g_db.Close();
- for (int i = 0; i < g_dbHistoryArray.GetSize(); i++)
- {
- g_dbHistoryArray.ElementAt(i)->Close();
- delete g_dbHistoryArray.ElementAt(i);
- }
- ReleaseBranchDB();
- WriteTextLog("备份完成");
- while (m_bRunning)
- {
- ::Sleep(1000);
- }
- ////////////////
- g_tisks = ::GetTickCount() - g_tisks;
- CString str;
- str.Format("耗时:%d分钟", g_tisks / 60000);
- CStdioFile fp;
- fp.Open(g_mainpath + "\\log.txt", CFile::modeCreate | CFile::modeWrite);
- CTime tm = CTime::GetCurrentTime();
- if (0)//tm.GetHour ()<5)
- {
- CTimeSpan sp(1, 0, 0, 0);
- tm -= sp;
- fp.WriteString(tm.Format("%Y-%m-%d"));
- fp.WriteString("\r\n");
- fp.WriteString(CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"));
- fp.WriteString(str);
- }
- else
- {
- fp.WriteString(g_bakdate);
- fp.WriteString("\r\n");
- fp.WriteString(tm.Format("%Y-%m-%d %H:%M:%S"));
- fp.WriteString(str);
- }
- fp.WriteString("\r\n");
- fp.WriteString(g_bakinfo);
- fp.WriteString("\r\n");
- fp.WriteString(g_bakphoto);
- fp.Close();
- // OnButton3();
- // Jeff.备份完成后自动关机;
- if (atoi(m_bak6))
- {
- #if 1
- // Jeff.关闭运行中的线程;
- TerminateThread();
- TerminateThread2();
- // Jeff.关闭AutoRun.exe程序;
- DWORD id = FindAppProcessID("AutoRun.exe");
- if (id != -1)
- {
- HANDLE ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
- if (ProcessHandle)TerminateProcess(ProcessHandle, 0);
- }
- // Jeff.移除托盘图标;
- m_TrayIcon.RemoveIcon();
- if (g_pSkinData)delete[]g_pSkinData; g_pSkinData = NULL;
- // Jeff.关闭计算机;
- MyExitWindows();
- #else // Jeff.开启定时关机功能;
- SetTimer(11, 60000, NULL);// 1分钟检测一次是否到达关机时间;
- #endif
- }
- else//重启
- {
- TerminateThread();
- TerminateThread2();
- m_TrayIcon.RemoveIcon();
- if (g_pSkinData)
- delete[]g_pSkinData;
- g_pSkinData = NULL;
- WriteTextLog("备份完成,服务器重启");
- CDialog::OnCancel();
- }
- }
- catch (...)
- {
- WriteTextLog("出错在函数shutdown中");
- }
- }
- void CDBServerDlg::MyExitWindows()
- {
- try
- {
- UINT t = EWX_SHUTDOWN | EWX_FORCE;
- OSVERSIONINFO osv; //定义一个操作系统信息的结构体
- osv.dwOSVersionInfoSize = sizeof OSVERSIONINFO;
- GetVersionEx(&osv); //查询当前操作系统
- if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT) //判断是否是2000/NT
- {
- //下面为向操作系统获取权限操作
- HANDLE hProcess, hToken;
- TOKEN_PRIVILEGES Privileges;
- LUID luid;
- hProcess = GetCurrentProcess();
- //下面为打开当前进程对话
- OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES, &hToken);
- Privileges.PrivilegeCount = 1;
- LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &luid);
- Privileges.Privileges[0].Luid = luid;
- Privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
- AdjustTokenPrivileges(hToken, FALSE, &Privileges, NULL, NULL, NULL);
- ExitWindowsEx(t, 0);
- }
- else
- {
- ExitWindowsEx(t, 0);//调用ExitWindowsEx关闭机器。
- PostQuitMessage(0);
- }
- }
- catch (...)
- {
- WriteTextLog("出错在函数exitwindows中");
- }
- }
- void CDBServerDlg::OnAutorun()
- {
- // TODO: Add your command handler code here
- g_bAutoRun = !g_bAutoRun;
- CString version = _T("Version 1.0");
- AfxGetApp()->WriteProfileInt(version, "brun", g_bAutoRun);
- TCHAR szKey[MAX_PATH];
- HKEY hKey = 0;
- DWORD disp = 0;
- lstrcpy(szKey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
- if (g_bAutoRun)
- {
- int lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
- if (lResult == ERROR_SUCCESS)
- {
- TCHAR szDir[MAX_PATH];
- ::GetModuleFileName(NULL, szDir, MAX_PATH);
- lResult = RegSetValueEx(hKey, "YLGLDBSERVER", 0, REG_SZ, (const unsigned char*)szDir, lstrlen(szDir));
- RegCloseKey(hKey);
- }
- }
- else
- {
- int lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
- if (lResult == ERROR_SUCCESS)
- {
- RegDeleteValue(hKey, "YLGLDBSERVER");
- RegDeleteKey(hKey, "YLGLDBSERVER");
- RegCloseKey(hKey);
- }
- }
- }
- void CDBServerDlg::GetFileDate()
- {
- CStringArray filesarray;
- CStringArray filesarray2;
- filesarray.Add("AutoUpdate.exe"); // 1.
- filesarray.Add("skin\\1.lia");
- filesarray.Add("skin\\2.lia");
- filesarray.Add("skin\\3.lia");
- filesarray.Add("skin\\4.lia");
- filesarray.Add("skin\\10.lia");
- filesarray.Add("skin\\logo.jpg");
- filesarray.Add("skin\\标题-选片.jpg");
- filesarray.Add("skin\\标题-看设计.jpg");
- filesarray.Add("图片\\欢迎.jpg"); // 10.
- filesarray.Add("图片\\连接.jpg");
- filesarray.Add("图片\\标题.jpg");
- filesarray.Add("图片\\背景.jpg");
- filesarray.Add("图片-红色风格\\欢迎.jpg");
- filesarray.Add("图片-红色风格\\连接.jpg");
- filesarray.Add("图片-红色风格\\标题.jpg");
- filesarray.Add("图片-红色风格\\背景.jpg");
- filesarray.Add("图片-红色风格\\选片.jpg");
- filesarray.Add("图片-红色风格\\看设计.jpg");
- filesarray.Add("skin\\1-red.lia"); // 20.
- filesarray.Add("skin\\2-red.lia");
- filesarray.Add("skin\\10-red.lia");
- filesarray.Add("skin\\6.lia");
- filesarray.Add("图片\\掌中宝.jpg");
- filesarray.Add("regsvr32.exe"); // 25.
- filesarray.Add("MSCHRT20.OCX"); // 26. // Jeff.2014.09.06.添加MSCHRT20.OCX,由服务器传递;
- ///////////////
- filesarray2.Add("AutoUpdate.exe");
- filesarray2.Add("skin\\1.lia");
- filesarray2.Add("skin\\2.lia");
- filesarray2.Add("skin\\3.lia");
- filesarray2.Add("skin\\4.lia");
- filesarray2.Add("skin\\5.lia");
- filesarray2.Add("skin\\10.lia");
- filesarray2.Add("skin\\5-red.lia");
- filesarray2.Add("skin\\10-red.lia");
- filesarray2.Add("图片\\logo.jpg");
- filesarray2.Add("图片\\标题-选片.jpg");
- filesarray2.Add("图片\\标题-看设计.jpg");
- filesarray2.Add("图片\\选片.jpg");
- filesarray2.Add("图片\\看设计.jpg");
- filesarray2.Add("图片\\欢迎.jpg");
- filesarray2.Add("图片\\连接.jpg");
- filesarray2.Add("图片\\标题.jpg");
- filesarray2.Add("图片\\背景.jpg");
- filesarray2.Add("图片-红色风格\\欢迎.jpg");
- filesarray2.Add("图片-红色风格\\连接.jpg");
- filesarray2.Add("图片-红色风格\\标题.jpg");
- filesarray2.Add("图片-红色风格\\背景.jpg");
- filesarray2.Add("skin\\6.lia");
- filesarray2.Add("图片\\掌中宝.jpg");
- filesarray2.Add("regsvr32.exe");
- filesarray2.Add("MSCHRT20.OCX"); // 26. // Jeff.2014.09.06.添加MSCHRT20.OCX,由服务器传递;
- int i = 0;
- for ( i = 0; i < filesarray.GetSize(); i++)
- {
- g_filedatearray.Add(GetModifyTime(g_mainpath + "\\系统文件\\" + filesarray.ElementAt(i)));
- }
- g_filedatearraynew.Copy(filesarray2);
- for (i = 0; i < filesarray2.GetSize(); i++)
- {
- g_filedatearraynew.Add(GetFileSize(g_mainpath + "\\系统文件\\" + filesarray2.ElementAt(i)));
- }
- }
- //extern CString g_sdomain;
- #ifdef ENTERPRISE_VERSION
- CString g_bMain;
- #endif
- void CDBServerDlg::LoadBranchInfo()
- {
- }
- void CDBServerDlg::ReleaseBranchDB()
- {
- }
- //savebranchinfo
- void CDBServerDlg::LoadBranchInfo2()
- {
- }
- int __cdecl CompareByLabel6(const void *elem1, const void *elem2)
- {
- CStringArray *p1 = (CStringArray*)elem1;
- CStringArray *p2 = (CStringArray*)elem2;
- return atoi(p1->ElementAt(5)) > atoi(p2->ElementAt(5));
- }
- //--------------------------------------------------------------
- // Remark by Jeff 2014.12.16
- // 函数:CheckMemberMsg
- // 描述:
- // 参数:
- // 返回:
- //
- // 调用关系:
- // 1.CheckMemberMsg() 只由 CDBServerDlg::SetTimer(4) 调用,调用频率2分钟,周期数直到程序结束。
- // 2.CDBServerDlg::SetTimer(4) 由 CDBServerDlg::SetTimer(2) 调用,调用频率10毫秒,只有一个周期。
- // 3.CDBServerDlg::SetTimer(2) 由 CDBServerDlg::OnInitDialog() 调用.
- //--------------------------------------------------------------
- void CDBServerDlg::CheckMemberMsg() // Jeff.由定时器SetTimer两分钟执行一次
- {
- try
- {
- g_curdb = &g_db;
- CString sql = "delete from sendreg where [log]='0/0'";
- MyExecuteSQL(&g_db, sql);
- {
- CStringArray idarray;
- CString timestamp;
- CTime tm = CTime::GetCurrentTime();
- tm -= CTimeSpan(0, 1, 0, 0);
- timestamp = tm.Format("%Y%m%d%H%M%S");
- CRecordset myset(g_curdb);
- CString sql = "select [autoid] from sendregdelay where [timestamp]<'" + timestamp + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- while (!myset.IsEOF())
- {
- myset.GetFieldValue("autoid", sql);
- idarray.Add(sql);
- myset.MoveNext();
- }
- myset.Close();
- for (int i = 0; i < idarray.GetSize(); i++)
- {
- // Jeff.deal
- //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)));
- 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)));
- MyExecuteSQL(&g_db, sql);
- sql.Format("delete from sendregdelay where [autoid]=%d", atol(idarray.ElementAt(i)));
- MyExecuteSQL(&g_db, sql);
- }
- }
- int covertrate = 100;
- CString spoint;
- {
- CRecordset myset(g_curdb);
- CString sql = "select * from version";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("rate2", sql);
- myset.Close();
- covertrate = atoi(sql);
- if (covertrate == 0)covertrate = 100;
- }
- CString filter;
- CArray<CStringArray, CStringArray>rulearray;
- CArray<CStringArray, CStringArray>memberarray;
- {
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from msgtemp2";
- if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- rulearray.SetSize(count, 1);
- CRstmsgtemp2 rsSt; rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- DWORD ii = 0;
- while (!rsSt.IsEOF())
- {
- rulearray.ElementAt(ii).RemoveAll();
- rulearray.ElementAt(ii).Add(rsSt.name);
- rulearray.ElementAt(ii).Add(rsSt.content1);
- rulearray.ElementAt(ii).Add(rsSt.content2);
- rulearray.ElementAt(ii).Add(rsSt.check1);
- rulearray.ElementAt(ii).Add(rsSt.check2);
- rulearray.ElementAt(ii).Add(rsSt.point);
- ii++;
- rsSt.MoveNext();
- if (rulearray.GetSize() <= ii)break;
- }
- rsSt.Close(); rulearray.SetSize(ii, 1);
- }
- if (rulearray.GetSize() == 0)return;
- qsort(static_cast<void*>(&rulearray[0]), rulearray.GetSize(), sizeof(rulearray[0]), CompareByLabel6);
- /////////////
- {
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from membermanage"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- memberarray.SetSize(atol(sql), 1);
- RstMemberReg rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- DWORD ii = 0;
- if (covertrate != 100)
- {
- while (!rsSt.IsEOF())
- {
- memberarray.ElementAt(ii).RemoveAll();
- memberarray.ElementAt(ii).Add(rsSt.m_memberno);
- memberarray.ElementAt(ii).Add(rsSt.m_name);
- memberarray.ElementAt(ii).Add(rsSt.m_sex);
- memberarray.ElementAt(ii).Add(rsSt.m_phone);
- spoint.Format("%d", atoi(rsSt.m_money)*covertrate / 100);
- memberarray.ElementAt(ii).Add(spoint);
- memberarray.ElementAt(ii).Add(rsSt.m_sendmark1);
- memberarray.ElementAt(ii).Add(rsSt.m_sendmark2);
- ii++;
- rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
- }
- }
- else
- {
- while (!rsSt.IsEOF())
- {
- memberarray.ElementAt(ii).RemoveAll();
- memberarray.ElementAt(ii).Add(rsSt.m_memberno);
- memberarray.ElementAt(ii).Add(rsSt.m_name);
- memberarray.ElementAt(ii).Add(rsSt.m_sex);
- memberarray.ElementAt(ii).Add(rsSt.m_phone);
- memberarray.ElementAt(ii).Add(rsSt.m_money);
- memberarray.ElementAt(ii).Add(rsSt.m_sendmark1);
- memberarray.ElementAt(ii).Add(rsSt.m_sendmark2);
- ii++;
- rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
- }
- }
- rsSt.Close(); memberarray.SetSize(ii, 1);
- }
- CString memberno, name, sex, phone, point, mark1, mark2, rulename, rulecheck1, rulecheck2, rulepoint, rulecontent1, rulecontent2;
- for (int i = 0; i < memberarray.GetSize(); i++)
- {
- memberno = memberarray.ElementAt(i).ElementAt(0);
- name = memberarray.ElementAt(i).ElementAt(1);
- sex = memberarray.ElementAt(i).ElementAt(2);
- phone = memberarray.ElementAt(i).ElementAt(3);
- point = memberarray.ElementAt(i).ElementAt(4);
- mark1 = "," + memberarray.ElementAt(i).ElementAt(5) + ",";
- mark2 = "," + memberarray.ElementAt(i).ElementAt(6) + ",";
- if (atoi(point) == 0)continue;
- if (phone.IsEmpty())continue;
- if (-1 == CheckPhoneType(phone))continue;
- int j = 0;
- for ( j = 0; j < rulearray.GetSize(); j++)
- {
- if (mark1.GetLength()>4000)break;
- rulename = "," + rulearray.ElementAt(j).ElementAt(0) + ",";
- rulecontent1 = name + rulearray.ElementAt(j).ElementAt(1);
- rulecontent2 = name + rulearray.ElementAt(j).ElementAt(2);
- rulecheck1 = rulearray.ElementAt(j).ElementAt(3);
- rulecheck2 = rulearray.ElementAt(j).ElementAt(4);
- rulepoint = rulearray.ElementAt(j).ElementAt(5);
- if (atoi(rulecheck1) == 0 && atoi(rulecheck2) == 0)continue;
- if (atoi(rulecheck1))
- {
- if (rulecontent1.IsEmpty())continue;
- if (mark1.Find(rulename) != -1)break;
- if (atoi(point) >= atoi(rulepoint))continue;
- if (atoi(point) < atoi(rulepoint) * 80 / 100)continue;
- // if(sex=="男")
- // rulecontent1.Replace ("xxx先生/女士", name+"先生");
- // else
- // rulecontent1.Replace ("xxx先生/女士", name+"女士");
- int count = GetLengthEx(rulecontent1) / MSG_LENGTH;
- if (GetLengthEx(rulecontent1) % MSG_LENGTH)
- count++;
- int phonenum = 1;
- count *= phonenum;
- CString scount;
- scount.Format("%d", count);
- CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
- CString sql;
- mark1.TrimLeft(",");
- mark1.TrimRight(",");
- if (mark1.IsEmpty() == 0)
- mark1 += ",";
- rulename.TrimLeft(",");
- rulename.TrimRight(",");
- mark1 += rulename;
- sql = "update membermanage set sendmark1='" + mark1 + "' where memberno='" + memberno + "'";
- MyExecuteSQL(&g_db, sql);
- mark1 = "," + mark1 + ",";
- sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + phone + "','" + rulecontent1 + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
- MyExecuteSQL(&g_db, sql);
- }
- }
- ///////////////////
- BOOL bSended = 0;
- for (j = 0; j < rulearray.GetSize(); j++)
- {
- if (mark2.GetLength() > 4000)break;
- if (bSended)break;
- rulename = "," + rulearray.ElementAt(j).ElementAt(0) + ",";
- rulecontent1 = name + rulearray.ElementAt(j).ElementAt(1);
- rulecontent2 = name + rulearray.ElementAt(j).ElementAt(2);
- rulecheck1 = rulearray.ElementAt(j).ElementAt(3);
- rulecheck2 = rulearray.ElementAt(j).ElementAt(4);
- rulepoint = rulearray.ElementAt(j).ElementAt(5);
- if (atoi(rulecheck1) == 0 && atoi(rulecheck2) == 0)continue;
- if (atoi(rulecheck2))
- {
- if (rulecontent2.IsEmpty())continue;
- if (mark2.Find(rulename) != -1)break;
- if (atoi(point) < atoi(rulepoint))continue;
- // if(sex=="男")
- // rulecontent2.Replace ("xxx先生/女士", name+"先生");
- // else
- // rulecontent2.Replace ("xxx先生/女士", name+"女士");
- int count = GetLengthEx(rulecontent2) / MSG_LENGTH;
- if (GetLengthEx(rulecontent2) % MSG_LENGTH)
- count++;
- int phonenum = 1;
- count *= phonenum;
- CString scount;
- scount.Format("%d", count);
- CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
- CString sql;
- mark2.TrimLeft(",");
- mark2.TrimRight(",");
- if (mark2.IsEmpty() == 0)
- mark2 += ",";
- rulename.TrimLeft(",");
- rulename.TrimRight(",");
- mark2 += rulename;
- sql = "update membermanage set sendmark2='" + mark2 + "' where memberno='" + memberno + "'";
- MyExecuteSQL(&g_db, sql);
- mark2 = "," + mark2 + ",";
- sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + phone + "','" + rulecontent2 + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
- MyExecuteSQL(&g_db, sql);
- bSended = 1;
- }
- }
- }
- }
- #if 1
- catch (...)
- {
- WriteTextLog("出错2");
- }
- #else // Jeff.add
- catch (CDBException *e)
- {
- WriteTextLog(e->m_strError);
- e->Delete();
- }
- #endif
- }
- void CDBServerDlg::CheckBakState() // Jeff.检查数据库bakstate表;
- {
- try
- {
- g_curdb = &g_db;
- CString filter;
- CArray<CStringArray, CStringArray> strArray;
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from bakstate";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strArray.SetSize(count, 1);
- CRstbakstate rsSt;
- rsSt.m_pDatabase = g_curdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- strArray.ElementAt(ii).RemoveAll();
- strArray.ElementAt(ii).Add(rsSt.date);
- strArray.ElementAt(ii).Add(rsSt.photo);
- strArray.ElementAt(ii).Add(rsSt.info);
- ii++;
- rsSt.MoveNext();
- if (strArray.GetSize() <= ii)
- break;
- }
- rsSt.Close(); strArray.SetSize(ii, 1);
- while (strArray.GetSize() > 7)
- {
- CString sql = "delete from bakstate where [date]='" + strArray.ElementAt(0).ElementAt(0) + "'";
- MyExecuteSQL(&g_db, sql);
- strArray.RemoveAt(0);
- }
- CString path;
- path.Format("%s\\log.txt", g_mainpath);
- if (::PathFileExists(path))
- {
- CString str;
- CStdioFile fp;
- if (fp.Open(path, CFile::modeRead))
- {
- CString temp;
- fp.ReadString(temp);
- CString date = temp; date.TrimRight();
- while (!feof(fp.m_pStream))
- {
- fp.ReadString(temp);
- str += temp;
- }
- fp.Close();
- if (date.GetLength() != 10)return;
- BOOL bBak = 0;
- int i = 0;
- for ( i = 0; i < strArray.GetSize(); i++)
- {
- if (date == strArray.ElementAt(i).ElementAt(0))
- {
- bBak = 1;
- break;
- }
- }
- if (bBak == 0)
- {
- CString state1 = "0";
- CString state2 = "0";
- if (str.Find("照片备份成功") != -1)state1 = "1";
- if (str.Find("资料备份成功") != -1)state2 = "1";
- sql = "insert into bakstate([date],[photo],[info])values('" + date + "','" + state1 + "','" + state2 + "')";
- MyExecuteSQL(&g_db, sql);
- }
- else
- {
- CString state1 = "0";
- CString state2 = "0";
- if (str.Find("照片备份成功") != -1)state1 = "1";
- if (str.Find("资料备份成功") != -1)state2 = "1";
- sql = "update bakstate set [photo]='" + state1 + "',[info]='" + state2 + "' where [date]='" + date + "'";
- MyExecuteSQL(&g_db, sql);
- }
- //判断昨天
- CTime tm = CTime::GetCurrentTime();
- CTimeSpan dt(1, 0, 0, 0);
- tm -= dt;
- CString yesterday = tm.Format("%Y-%m-%d");
- for (i = 0; i < strArray.GetSize(); i++)
- {
- if (yesterday == strArray.ElementAt(i).ElementAt(0))return;
- }
- if (yesterday == date)return;
- sql = "insert into bakstate([date],[photo],[info])values('" + yesterday + "','0','0')";
- MyExecuteSQL(&g_db, sql);
- }
- else
- {
- CTime tm = CTime::GetCurrentTime();
- CTimeSpan dt(1, 0, 0, 0);
- tm -= dt;
- sql = "insert into bakstate([date],[photo],[info])values('" + tm.Format("%Y-%m-%d") + "','0','0')";
- MyExecuteSQL(&g_db, sql);
- }
- }
- else
- {
- CTime tm = CTime::GetCurrentTime();
- CTimeSpan dt(1, 0, 0, 0);
- tm -= dt;
- for (int i = 0; i < strArray.GetSize(); i++)
- {
- if (tm.Format("%Y-%m-%d") == strArray.ElementAt(i).ElementAt(0))return;
- }
- sql = "insert into bakstate([date],[photo],[info])values('" + tm.Format("%Y-%m-%d") + "','0','0')";
- MyExecuteSQL(&g_db, sql);
- }
- }
- catch (...)
- {
- WriteTextLog("出错3");
- }
- }
- //数据备份
- CString CDBServerDlg::GetRegCode(int m_id, int m_time1, int m_time2)
- {
- return "";
- }
- int g_ndogtimes = 0;
- void CDBServerDlg::CheckRegCode() // 检查注册码信息;
- {
-
- }
- BOOL IsCtrlDown()
- {
- short state = GetKeyState(VK_LCONTROL);
- BYTE sta = (BYTE)(state >> 8);
- state = GetKeyState(VK_RCONTROL);
- BYTE sta2 = (BYTE)(state >> 8);
- if (sta || sta2)
- return 1;
- else
- return 0;
- }
- //extern CTime GetTmFromStr(CString date);
- BOOL CDBServerDlg::PreTranslateMessage(MSG* pMsg)
- {
- if (pMsg->message == WM_KEYDOWN)
- {
- switch (pMsg->wParam)
- {
- case 67:
- AfxMessageBox("c");
- break;
- case VK_F8:
- if (IsCtrlDown())GenYLGL();
- break;
- case VK_F9:
- if (IsCtrlDown())
- {
- CString g_domain;
- CArray<CStringArray, CStringArray>g_List1array;
- CString autorunpath = g_mainpath + "\\branchdindan.dat";
- CFile fp;
- if (fp.Open(autorunpath, CFile::modeRead))
- {
- int nMessageLen = fp.GetLength();
- BYTE *pData = new BYTE[nMessageLen];
- fp.Read(pData, nMessageLen);
- fp.Close();
- BYTE *szChatMessage = pData;
- int count;
- memcpy(&count, szChatMessage + (nMessageLen - sizeof(int)), sizeof(int));
- CMemFile memfile;
- memfile.Attach(szChatMessage, nMessageLen);
- CArchive ar(&memfile, CArchive::load);
- g_List1array.SetSize(count);
- for (int ii = 0; ii < g_List1array.GetSize(); ii++)
- {
- g_List1array.ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- delete[]pData;
- }
- CString time5, id;
- for (int i = 0; i < g_List1array.GetSize(); i++)
- {
- g_domain = "\\" + g_List1array.ElementAt(i).ElementAt(0);
- id = g_List1array.ElementAt(i).ElementAt(1);
- time5 = g_List1array.ElementAt(i).ElementAt(2);
- WriteTextLog(g_domain + "\\" + id + time5);
- }
- }
- break;
- #ifdef LYFZ_VERSION
- case VK_F7:
- if (IsCtrlDown())
- {
- if (AfxMessageBox("是否继续?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return 1;
- CStringArray array1;
- CRstDindanForm rsSt; rsSt.m_pDatabase = &g_db;
- rsSt.Open();
- while (!rsSt.IsEOF())
- {
- array1.Add(rsSt.id);
- rsSt.MoveNext();
- }
- rsSt.Close();
- CString id, sql;
- sql.Format("update dindan set status5='%s'", "无");
- MyExecuteSQL(&g_db, sql);
- BOOL bHasPhoto = 0;
- for (int i = 0; i < array1.GetSize(); i++)
- {
- id = array1.ElementAt(i);
- bHasPhoto = 0;
- CRstClientPhoto rsSt;
- rsSt.m_strFilter = "id='" + id + "'";
- rsSt.Open();
- if (rsSt.photo.m_dwDataLength>0)
- {
- bHasPhoto = 1;
- }
- rsSt.Close();
- if (bHasPhoto)
- {
- sql.Format("update dindan set status5='%s' where id='%s'", "有", id);
- MyExecuteSQL(&g_db, sql);
- }
- }
- AfxMessageBox("完成");
- }
- break;
- #endif
- case VK_F2:
- if (IsCtrlDown())
- {
- SelYear dlg;
- if (dlg.DoModal() != IDOK)return 1;
- int year = dlg.m_year;
- int hisyear = CTime::GetCurrentTime().GetYear() - 1;
- if (year == hisyear)
- {
- AfxMessageBox("不能选该年");
- return 1;
- }
- CString str;
- str.Format("此操作将%d年数据导入%d中, 确认吗?", year, hisyear);
- if (AfxMessageBox(str, MB_YESNO | MB_ICONINFORMATION) != IDYES)return 1;
- CDatabase *pdb = GetDB(year);
- if (pdb == NULL)
- {
- str.Format("没有找到%d, 操作失败", year);
- AfxMessageBox(str); return 1;
- }
- str.Format("开始%d->%d", year, hisyear);
- WriteTextLog(str);
- CheckHistoryData(pdb, year);
- str.Format("%d->%d完成", year, hisyear);
- WriteTextLog(str);
- }
- break;
- case VK_F3:
- if (IsCtrlDown())
- {
- SelYear dlg;
- if (dlg.DoModal() != IDOK)return 1;
- int year = dlg.m_year;
- int hisyear = CTime::GetCurrentTime().GetYear() - 1;
- if (year == hisyear)
- {
- AfxMessageBox("不能选该年");
- return 1;
- }
- CString str;
- str.Format("此操作将%d年数据导入%d中(当前数据库中没有的订单全转), 确认吗?", year, hisyear);
- if (AfxMessageBox(str, MB_YESNO | MB_ICONINFORMATION) != IDYES)return 1;
- CDatabase *pdb = GetDB(year);
- if (pdb == NULL)
- {
- str.Format("没有找到%d, 操作失败", year);
- AfxMessageBox(str); return 1;
- }
- str.Format("开始%d->%d", year, hisyear);
- WriteTextLog(str);
- CheckHistoryData(pdb, year, 1);
- str.Format("%d->%d完成", year, hisyear);
- WriteTextLog(str);
- }
- break;
- case VK_F1:
- CString str;
- if (g_conniparray.GetSize() == 0)str = "当前无客户端连接至服务器!";
- for (int i = 0; i < g_conniparray.GetSize(); i++)
- {
- str += "\r\n连接ip:" + g_conniparray.ElementAt(i);
- }
- AfxMessageBox(str);
- #ifdef CONNCOUNT_VERSION
- // CStringArray g_conniparray;
- #endif
- return 1;
- }
- }
- return CDialog::PreTranslateMessage(pMsg);
- }
- void CDBServerDlg::GenUPhoneData()
- {
- return;
- MyLock lock("processChatMessageRequestxiao");
- CArray<int, int>codearray;
- codearray.Add(80);
- codearray.Add(90);
- codearray.Add(11);
- codearray.Add(138);
- codearray.Add(24);
- codearray.Add(181);
- codearray.Add(65);
- codearray.Add(56);
- codearray.Add(179);
- codearray.Add(53);
- CFile fp;
- CString savepath, g_path1;
- char server[50];
- DWORD leng = 50;
- ::GetComputerName(server, &leng);
- g_path1 = server;
- g_path1 = "\\\\" + g_path1 + "\\电话录音(管理软件)$";
- GetPathFromNetShareName("电话录音(管理软件)$", g_path1);
- if (g_path1.IsEmpty())
- {
- WriteTextLog("获取电精灵数据出错");
- return;
- }
- try
- {
- int aa = 0;
- g_curdb = &g_db;
- savepath.Format("%s\\uphonedata%d.dat", g_path1, aa);
- ::DeleteFile(savepath); // 删除 uphonedata%d.dat 文件;
- if (fp.Open(savepath, CFile::modeCreate | CFile::modeWrite) == 0)
- {
- WriteTextLog("更新来电精灵数据出错");
- return;
- }
- CConnectSocket consock;
- consock.m_pConndb = &g_db;
- for (int i = 0; i < codearray.GetSize(); i++)
- {
- BYTE code = codearray.ElementAt(i);
- DWORD length, arraysize;
- BYTE *pReturn = NULL;
- consock.GetDataFromCode(code, &pReturn, length, arraysize, "");
- fp.Write(&code, sizeof(BYTE));
- fp.Write(&length, sizeof(DWORD));
- fp.Write(&arraysize, sizeof(DWORD));
- fp.Write(pReturn, length);
- }
- fp.Close();
- }
- catch (...)
- {
- WriteTextLog("获取来电精灵数据出错");
- }
- }
- //initlia
- void CDBServerDlg::LoadHistoryDB() // 加载历史数据库;
- {
- CString path;
- CString sql;
- sql = "delete from historydb";
- MyExecuteSQL(&g_db, sql);
- CDatabase g_masterdb;
- try
- {
- CString strCon;
- strCon.Format(_T("driver={SQL Server};Server=%s;DATABASE=master;%s"), g_strdbServrename, g_strdbpsw);
- g_masterdb.OpenEx(strCon, CDatabase::noOdbcDialog);
- }
- catch (CDBException * e)
- {
- e->Delete();
- }
- for (int i = CTime::GetCurrentTime().GetYear() - 1; i >= 2009; i--)
- {
- CDatabase *db = new CDatabase;
- try
- {
- CString strCon;
- strCon.Format(_T("driver={SQL Server};Server=%s;DATABASE=%d;%s"), g_strdbServrename, i, g_strdbpsw);
- db->OpenEx(strCon, CDatabase::noOdbcDialog);
- g_nYearArray.Add(i);
- g_dbHistoryArray.Add(db);
- sql.Format("insert into [historydb]([year])values('%d')", i);
- MyExecuteSQL(&g_db, sql);
- }
- catch (CDBException * e)
- {
- CString strPathOfYearmdf;
- CString strPathOfYearldf;
- CString sql;
- strPathOfYearmdf.Format("%s\\数据\\%d.mdf", g_mainpath, i);
- strPathOfYearldf.Format("%s\\数据\\%d_log.LDF", g_mainpath, i);
- if (PathFileExists(strPathOfYearmdf))
- {
- BOOL bLog = 0;
- if (PathFileExists(strPathOfYearldf))
- {
- bLog = 1;
- }
- g_masterdb.SetQueryTimeout(600);
- if (bLog)
- sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", i, strPathOfYearmdf, strPathOfYearldf);
- else
- sql.Format("exec sp_attach_db '%d',@filename1='%s'", i, strPathOfYearmdf);
- try
- {
- g_masterdb.ExecuteSQL(sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("历史数据库初始化失败!!");
- g_masterdb.SetQueryTimeout(100);
- e->Delete();
- break;
- }
- g_masterdb.SetQueryTimeout(100);
- CString strCon;
- strCon.Format(_T("driver={SQL Server};Server=%s;DATABASE=%d;%s"), g_strdbServrename, i, g_strdbpsw);
- db->OpenEx(strCon, CDatabase::noOdbcDialog);
- g_nYearArray.Add(i);
- g_dbHistoryArray.Add(db);
- sql.Format("insert into [historydb]([year])values('%d')", i);
- MyExecuteSQL(&g_db, sql);
- }
- else
- {
- e->Delete();
- break;
- }
- }
- }
- g_masterdb.Close();
- }
- void CDBServerDlg::AddOneConn()
- {
- try
- {
- MyLock lock("AddOneConnxiao");
- if (g_nDBCount >= 200)
- {
- WriteTextLog("连接超数!"); return;
- }
- CDatabase *db = new CDatabase;
- //if(AddConn(db, "db")==0)// Jeff.deal;
- if (AddConn(db, g_szDBName) == 0)
- {
- return;
- }
- g_pDB[g_nDBCount] = db;
- CString dbname;
- for (int i = 0; i < g_nYearArray.GetSize(); i++)
- {
- dbname.Format("%d", g_nYearArray.ElementAt(i));
- CDatabase *db = new CDatabase;
- AddConn(db, dbname);
- g_pHistoryDBarray[g_nDBCount].Add(db);
- }
- g_nDBCount++;
- }
- catch (...)
- {
- WriteTextLog("AddOneConn error");
- }
- }
- void GetOneConn(CDatabase **m_pdb, CArray<CDatabase*, CDatabase*>*m_dbarray, CConnectThread *pThread)
- {
- MyLock lock("GetOneConnxiao");
- ll: for (int i = 0; i < 200; i++)
- {
- if (g_pDB[i] != NULL && g_pThreadPt[i] == NULL)
- {
- *m_pdb = g_pDB[i];
- m_dbarray->Copy(g_pHistoryDBarray[i]);
- g_pThreadPt[i] = pThread;
- return;
- }
- }
- if (g_nDBCount >= 200)
- {
- WriteTextLog("连接超数2!");
- *m_pdb = &g_db;
- m_dbarray->Copy(g_dbHistoryArray);
- return;
- }
- g_pMainWnd->AddOneConn();
- ::Sleep(1000);
- goto ll;
- }
- void CDBServerDlg::CheckConnCount()
- {
- int count = 0;
- for (int i = 0; i < 200; i++)
- {
- if (g_pDB[i] != NULL && g_pThreadPt[i] == NULL)
- {
- count++;
- if (count > 9)
- return;
- }
- }
- AddOneConn();
- }
- //delete from 背景.jpg
- void CDBServerDlg::RestoreHQ()
- {
- CString sql;
- g_curdb = &g_db;
- DWORD ii = 0;
- CArray<CStringArray, CStringArray>g_List1array;
- {
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from dindan";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- g_List1array.SetSize(count, 1);
- CRstDindanForm rsSt; rsSt.m_pDatabase = g_curdb;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- g_List1array.ElementAt(ii).RemoveAll();
- g_List1array.ElementAt(ii).Add(rsSt.id);
- ii++;
- rsSt.MoveNext(); if (g_List1array.GetSize() <= ii)break;
- }
- rsSt.Close(); g_List1array.SetSize(ii, 1);
- }
- for (int i = 0; i < g_List1array.GetSize(); i++)
- {
- // int ret=TransDinDan(pdb1, pdb2, g_List1array.ElementAt (i).ElementAt (0), lastyear);
- // Jeff.deal;
- //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));
- 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));
- CRecordset myset(g_curdb);
- myset.Open(CRecordset::forwardOnly, sql);
- CStringArray namearray;
- CStringArray countarray;
- while (!myset.IsEOF())
- {
- sql = "";
- myset.GetFieldValue("name", sql);
- namearray.Add(sql);
- sql = "";
- myset.GetFieldValue("count", sql);
- countarray.Add(sql);
- myset.MoveNext();
- }
- myset.Close();
- for (int j = 0; j < namearray.GetSize(); j++)
- {
- CString spid, spjiage2;
- // WriteTextLog("name:"+namearray.ElementAt (j));
- // Jeff.deal;
- //sql.Format("SELECT [spid],[spjiage2] FROM [db].[dbo].[shangpin] where spname='%s'", namearray.ElementAt (j));
- sql.Format("SELECT [spid],[spjiage2] FROM [dbo].[shangpin] where spname='%s'", namearray.ElementAt(j));
- //WriteTextLog(sql);
- CRecordset myset(g_curdb);
- myset.Open(CRecordset::forwardOnly, sql);
- if (!myset.IsEOF())
- {
- myset.GetFieldValue("spid", spid);
- myset.GetFieldValue("spjiage2", spjiage2);
- }
- myset.Close();
- // Jeff.deal;
- //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));
- 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));
- myset.Open(CRecordset::forwardOnly, sql);
- sql = "";
- if (!myset.IsEOF())
- {
- myset.GetFieldValue("cot", sql);
- }
- myset.Close();
- if (atoi(sql))continue;
- sql.Format("insert into [dindansp]([id],[name],[shuliang],[price],[spid],[kind])values('%s','%s','%s','%s','%s','%s')",
- g_List1array.ElementAt(i).ElementAt(0), namearray.ElementAt(j), countarray.ElementAt(j), spjiage2, spid, "2");
- //WriteTextLog(sql);
- g_db.ExecuteSQL(sql);
- }
- }
- }
- void CDBServerDlg::ManagePhoto()
- {
- // CClientCenter dlg1;
- // dlg1.DoModal ();
- ShowPic3 dlg;
- dlg.DoModal();
- }
- //数据备份(管理软件)$
- //--------------------------------------------------------------------------
- // Remark by Jeff:2014.10.22
- // 函数:AutoDelBakPhoto
- // 描述:自动删除取件后的订单备份相片,包括客户备份原片、备份初修片、备份精修片、备份设计片。
- // 参数:#
- // 返回:#
- //
- // 调用关系:
- // 1.AutoDelBakPhoto()由 BakPhoto()调用。
- // 2.BakPhoto() 由CDBServerDlg::SetTimer(4) 调用,调用频率2分钟,周期数直到程序结束。
- // 3.CDBServerDlg::SetTimer(4) 由 CDBServerDlg::SetTimer(2) 调用,调用频率10毫秒,只有一个周期。
- // 4.CDBServerDlg::SetTimer(2) 由 CDBServerDlg::OnInitDialog() 调用.
- //
- //--------------------------------------------------------------------------
- void CDBServerDlg::AutoDelBakPhoto()
- {
- try
- {
- g_curdb = &g_db;
- CString m_check1, m_check2, m_check3, m_check4;
- CString m_edit1, m_edit2, m_edit3, m_edit4;
- CString g_path1;
- CString g_path2;
- CString g_path3;
- CString g_path4;
- CString m_bakserver1, m_bakserver2, m_bakserver3, m_bakserver4;
- {
- CRstversion rsSt; rsSt.m_pDatabase = g_curdb;
- rsSt.Open();
- if (!rsSt.IsEOF())
- {
- m_check1 = rsSt.m_delcheck1;
- m_check2 = rsSt.m_delcheck2;
- m_check3 = rsSt.m_delcheck3;
- m_check4 = rsSt.m_delcheck4;
- m_edit1 = rsSt.m_deledit1;
- m_edit2 = rsSt.m_deledit2;
- m_edit3 = rsSt.m_deledit3;
- m_edit4 = rsSt.m_deledit4;
- g_path1 = rsSt.m_bakserver1;
- g_path2 = rsSt.m_bakserver2;
- g_path4 = rsSt.m_bakserver3;
- g_path3 = rsSt.m_bakserver4;
- }
- rsSt.Close();
- }
- BOOL bcheck1 = atoi(m_check1);
- BOOL bcheck2 = atoi(m_check2);
- BOOL bcheck3 = atoi(m_check3);
- BOOL bcheck4 = atoi(m_check4);
- if (!(bcheck1 || bcheck2 || bcheck3 || bcheck4))
- {
- return;
- }
- int edit1 = atoi(m_edit1);
- int edit2 = atoi(m_edit2);
- int edit3 = atoi(m_edit3);
- int edit4 = atoi(m_edit4);
- //path
- CStringArray patharray;
- {
- #ifdef CHILD_VERSION
- if (g_path1.Find(":") == -1 && g_path1 != "")
- g_path1 = "\\\\" + g_path1 + "\\客户原片备份(儿童管理软件)$";
- if (1)//(localname.CompareNoCase (g_path1)==0 || CompareIP(localname, g_path1)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\客户原片备份(儿童管理软件)$"))
- GetPathFromNetShareName("客户原片备份(儿童管理软件)$", g_path1);
- if (g_path2.Find(":") == -1 && g_path2 != "")
- g_path2 = "\\\\" + g_path2 + "\\修好的片备份(儿童管理软件)$";
- if (1)//((localname.CompareNoCase (g_path2)==0 || CompareIP(localname, g_path2)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\修好的片备份(儿童管理软件)$"))
- GetPathFromNetShareName("修好的片备份(儿童管理软件)$", g_path2);
- if (g_path4.Find(":") == -1 && g_path4 != "")
- g_path4 = "\\\\" + g_path4 + "\\精修好的片备份(儿童管理软件)$";
- if (1)//((localname.CompareNoCase (g_path4)==0 || CompareIP(localname, g_path4)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\精修好的片备份(儿童管理软件)$"))
- GetPathFromNetShareName("精修好的片备份(儿童管理软件)$", g_path4);
- if (g_path3.Find(":") == -1 && g_path3 != "")
- g_path3 = "\\\\" + g_path3 + "\\设计好的片备份(儿童管理软件)$";
- if (1)//((localname.CompareNoCase (g_path3)==0 || CompareIP(localname, g_path3)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\设计好的片备份(儿童管理软件)$"))
- GetPathFromNetShareName("设计好的片备份(儿童管理软件)$", g_path3);
- #else
- if (g_path1.Find(":") == -1 && g_path1 != "")
- g_path1 = "\\\\" + g_path1 + "\\客户原片备份(管理软件)$";
- if (1)//((localname.CompareNoCase (g_path1)==0 || CompareIP(localname, g_path1)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\客户原片备份(管理软件)$"))
- GetPathFromNetShareName("客户原片备份(管理软件)$", g_path1);
- if (g_path2.Find(":") == -1 && g_path2 != "")
- g_path2 = "\\\\" + g_path2 + "\\修好的片备份(管理软件)$";
- if (1)//((localname.CompareNoCase (g_path2)==0 || CompareIP(localname, g_path2)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\修好的片备份(管理软件)$"))
- GetPathFromNetShareName("修好的片备份(管理软件)$", g_path2);
- if (g_path4.Find(":") == -1 && g_path4 != "")
- g_path4 = "\\\\" + g_path4 + "\\精修好的片备份(管理软件)$";
- if (1)//((localname.CompareNoCase (g_path4)==0 || CompareIP(localname, g_path4)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\精修好的片备份(管理软件)$"))
- GetPathFromNetShareName("精修好的片备份(管理软件)$", g_path4);
- if (g_path3.Find(":") == -1 && g_path3 != "")
- g_path3 = "\\\\" + g_path3 + "\\设计好的片备份(管理软件)$";
- if (1)//((localname.CompareNoCase (g_path3)==0 || CompareIP(localname, g_path3)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\设计好的片备份(管理软件)$"))
- GetPathFromNetShareName("设计好的片备份(管理软件)$", g_path3);
- #endif
- patharray.Add(g_path1);
- patharray.Add(g_path2);
- patharray.Add(g_path4);
- patharray.Add(g_path3);
- }
- if (patharray.GetSize() == 0)return;
- CArray<CDatabase*, CDatabase*>dbarray2;
- dbarray2.Copy(g_dbHistoryArray);
- dbarray2.InsertAt(0, &g_db);
- WriteTextLog("开始删除取件后的备份照片");
- for (int n = 0; n < min(3, dbarray2.GetSize()); n++)
- {
- g_curdb = dbarray2.ElementAt(n);
- DWORD ii = 0;
- CArray<CStringArray, CStringArray>g_List1array;
- {
- CString filter = "status3='OK' and time5 is not null and time5<>''";
- CRecordset myset(g_curdb);
- CString sql = "select count(*) as cot from dindan"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- if (count == 0)continue;
- g_List1array.SetSize(count, 1);
- CRstDindanForm rsSt; rsSt.m_pDatabase = g_curdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- g_List1array.ElementAt(ii).RemoveAll();
- g_List1array.ElementAt(ii).Add(rsSt.id);
- g_List1array.ElementAt(ii).Add(rsSt.time5);
- ii++;
- rsSt.MoveNext(); if (g_List1array.GetSize() <= ii)break;
- }
- rsSt.Close();
- g_List1array.SetSize(ii, 1);
- CString time5, id;
- CTime curtm = CTime::GetCurrentTime();
- CString strtime;
- for (int i = 0; i < g_List1array.GetSize(); i++)
- {
- id = g_List1array.ElementAt(i).ElementAt(0);
- time5 = g_List1array.ElementAt(i).ElementAt(1);
- if (bcheck1)//原片
- {
- CTimeSpan sp(edit1 * 30, 0, 0, 0);
- CTime tm = curtm - sp;
- strtime = tm.Format("%Y-%m-%d");
- if (strtime > time5)
- {
- if (DelPhoto1(patharray.ElementAt(0), g_List1array.ElementAt(i).ElementAt(0)))
- WriteTextLog("原片备份" + patharray.ElementAt(0) + "\\" + g_List1array.ElementAt(i).ElementAt(0));
- // DelPhoto1(patharray2.ElementAt (0),g_List1array.ElementAt (i).ElementAt (0));
- }
- }
- if (bcheck2)
- {
- CTimeSpan sp(edit2 * 30, 0, 0, 0);
- CTime tm = curtm - sp;
- strtime = tm.Format("%Y-%m-%d");
- if (strtime > time5)
- {
- DelPhoto1(patharray.ElementAt(1), g_List1array.ElementAt(i).ElementAt(0));
- // DelPhoto1(patharray2.ElementAt (2),g_List1array.ElementAt (i).ElementAt (0));
- }
- }
- if (bcheck3)
- {
- CTimeSpan sp(edit3 * 30, 0, 0, 0);
- CTime tm = curtm - sp;
- strtime = tm.Format("%Y-%m-%d");
- if (strtime > time5)
- {
- DelPhoto1(patharray.ElementAt(2), g_List1array.ElementAt(i).ElementAt(0));
- // DelPhoto1(patharray2.ElementAt (2),g_List1array.ElementAt (i).ElementAt (0));
- }
- }
- if (bcheck4)
- {
- CTimeSpan sp(edit4 * 30, 0, 0, 0);
- CTime tm = curtm - sp;
- strtime = tm.Format("%Y-%m-%d");
- if (strtime > time5)
- {
- DelPhoto1(patharray.ElementAt(3), g_List1array.ElementAt(i).ElementAt(0));
- }
- }
- }
- }
- }
- g_curdb = &g_db;
- #ifdef ENTERPRISE_VERSION
- WriteTextLog("本店查完,开始检查分店备份");
- CString g_domain;
- CArray<CStringArray, CStringArray>g_List1array;
- CString autorunpath = g_mainpath + "\\branchdindan.dat";
- CFile fp;
- if (fp.Open(autorunpath, CFile::modeRead))
- {
- int nMessageLen = fp.GetLength();
- BYTE *pData = new BYTE[nMessageLen];
- fp.Read(pData, nMessageLen);
- fp.Close();
- BYTE *szChatMessage = pData;
- int count;
- memcpy(&count, szChatMessage+(nMessageLen-sizeof(int)), sizeof(int));
- CMemFile memfile;
- memfile.Attach (szChatMessage, nMessageLen);
- CArchive ar(&memfile, CArchive::load);
- g_List1array.SetSize(count);
- for(int ii=0; ii<g_List1array.GetSize (); ii++)
- {
- g_List1array.ElementAt (ii).Serialize (ar);
- }
- ar.Close();
- memfile.Detach ();
- delete []pData;
- }
- CString time5,id;
- CTime curtm=CTime::GetCurrentTime ();
- CString strtime;
- for(int i=0; i<g_List1array.GetSize (); i++)
- {
- g_domain="\\"+g_List1array.ElementAt (i).ElementAt (0);
- if(g_domain.Find (".ly.com")==-1)continue;
- id=g_List1array.ElementAt (i).ElementAt (1);
- time5=g_List1array.ElementAt (i).ElementAt (2);
- if(bcheck1)//原片
- {
- CTimeSpan sp(edit1*30, 0, 0, 0);
- CTime tm=curtm-sp;
- strtime=tm.Format ("%Y-%m-%d");
- if(strtime>time5)
- {
- if(DelPhoto1(patharray.ElementAt (0)+g_domain,id))
- WriteTextLog("分店原片备份"+ patharray.ElementAt (0)+g_domain+"\\"+id );
- }
- }
- if(bcheck2)
- {
- CTimeSpan sp(edit2*30, 0, 0, 0);
- CTime tm=curtm-sp;
- strtime=tm.Format ("%Y-%m-%d");
- if(strtime>time5)
- {
- DelPhoto1(patharray.ElementAt (1)+g_domain,id);
- // DelPhoto1(patharray2.ElementAt (2),id);
- }
- }
- if(bcheck3)
- {
- CTimeSpan sp(edit3*30, 0, 0, 0);
- CTime tm=curtm-sp;
- strtime=tm.Format ("%Y-%m-%d");
- if(strtime>time5)
- {
- DelPhoto1(patharray.ElementAt (2)+g_domain,id);
- // DelPhoto1(patharray2.ElementAt (2),id);
- }
- }
- if(bcheck4)
- {
- CTimeSpan sp(edit4*30, 0, 0, 0);
- CTime tm=curtm-sp;
- strtime=tm.Format ("%Y-%m-%d");
- if(strtime>time5)
- {
- DelPhoto1(patharray.ElementAt (3)+g_domain,id);
- }
- }
- }
- g_curdb = &g_db;
- #endif
- WriteTextLog("检查删除备份照片完成");
- }
- catch (...)
- {
- WriteTextLog("出错在函数AutoDelBakPhoto中");
- }
- g_curdb = &g_db;
- }
- //10.lia
- //----------------------------------------------------------------------------
- // Remark by Jeff 2014.10.22
- // 函数:GenYLGL
- // 描述:调用本地客户端;
- // 参数:#
- // 返回:#
- //
- // 调用关系:
- // 1.只由AutoDelPhoto()主动调用。
- //
- // 说明:传递genbranchdata给客户端,使客户端能够自动遍历branchinfo.dat里的分店信息,
- // 客户端顺序连接所有分店并获取分店历史订单已完成取件的订单。最终将所有分店历史
- // 订单已完成取件的送回服务端,保存在branchdindan.dat中.
- //----------------------------------------------------------------------------
- void CDBServerDlg::GenYLGL()
- {
- // 1.Jeff.删除文件,g_mainpath服务器DBServer.exe的目录;
- CString autorunpath = g_mainpath + "\\YLGL.exe";
- ::DeleteFile(autorunpath); // 删除YLGL.exe
- WriteTextLog("命令行启动:" + autorunpath);
- // 2.重新生成YLGL.exe
- CRstUpdate rsSt;
- rsSt.m_pDatabase = &g_db;
- rsSt.Open();
- if (!rsSt.IsEOF())
- {
- CFile fp;
- if (fp.Open(autorunpath, CFile::modeCreate | CFile::modeWrite))
- {
- void *pData = GlobalLock(rsSt.data.m_hData);
- fp.Write(pData, rsSt.data.m_dwDataLength);
- fp.Close();
- GlobalUnlock(rsSt.data.m_hData);
- }
- }
- rsSt.Close();
- // 3.执行YLGL.exe
- ShellExecute(NULL, _T("open"), autorunpath, "genbranchdata", NULL, SW_HIDE);
- }
- //105
|