DBServerDlg.cpp 192 KB

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