123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326 |
- #include "stdafx.h"
- #include "DBServer.h"
- #include "theDBServer.h"
- #include "DBServerDlg.h"
- #include "AboutDlg.h"
- #include <afxpriv.h>
- #include <process.h>
- #include "ClientCenter.h"
- #include "MyLock.h"
- #include "mysqldata.h"
- #include "./helper/ffsco.h"
- #include "ShowPic3.h"
- #include "my32.h"
- #include "SoftKey.h"
- #include "DogTimeOutDlg.h"
- #include "InputAuthDlg.h"
- #include "AdoImplSvr.h"
- #include "CreateSmallPhoto.h"
- #include "PhotoBackupMgr.h"
- #include <WinSvc.h>
- #include "ConnectThread.h"
- #pragma comment(lib, "NETAPI32.LIB ")
- #include "SelYear.h"
- #include "BranchInfo.h"
- using namespace helper_coffs;
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #define LIMITCOUNT 1
- extern BOOL g_bSteal;
- extern BOOL g_bConvertHisAll;
- extern CDBServer theApp;
- extern CtheDBServer theServer;
- #define WM_ICON_NOTIFY WM_USER+12
- CDBServerDlg *g_pMainWnd = NULL;
- #define IPC_CUSTOM_MSG2 _T("{E4F876E2-Q78F-22D5-C98A-Y0B0D07B847C}")
- UINT g_wmClose = RegisterWindowMessage(IPC_CUSTOM_MSG2);
- CArray<CDatabase*, CDatabase*>g_pHistoryDBarray[200];
- CDatabase *g_pDB[200];
- CConnectThread *g_pThreadPt[200];
- int g_nDBCount = 0;
- #pragma comment(lib, "Shlwapi.lib")
- extern DWORD g_nSendCode;
- extern BOOL g_bReturned;
- static UINT auIDStatusBar[] =
- {
- ID_SEPARATOR,
- ID_INDICATOR_DATA_RECEIVED,
- ID_INDICATOR_DATA_SEND,
- ID_INDICATOR_ONLINELED,
- ID_INDICATOR_OFFLINELED
- };
- CDBServerDlg::CDBServerDlg(CWnd* pParent ): CDialog(CDBServerDlg::IDD, pParent)
- {
- m_hIcon = AfxGetApp()->LoadIcon(IDI_DBServer);
- m_bTerminate = false;
- m_bRunning = false;
- m_hThread = NULL;
- hInst = NULL;
- CString version = _T("Version 1.0");
- g_bAutoRun = AfxGetApp()->GetProfileInt(version, "brun", 0);
- m_hExitCheckSvc = NULL;
- m_hWaitTimeOut = NULL;
- m_hCheckSvcThread = NULL;
- m_bStartCheckSvc = FALSE;
- for (int i = 0; i < 200; i++)
- {
- g_pDB[i] = NULL;
- g_pThreadPt[i] = NULL;
- }
- }
- CDBServerDlg::~CDBServerDlg()
- {
- for (int i = 0; i < 200; i++)
- {
- CDatabase *db = g_pDB[i];
- if (db)
- {
- db->Close();
- delete db;
- }
- for (int j = 0; j < g_pHistoryDBarray[i].GetSize(); j++)
- {
- CDatabase *db = g_pHistoryDBarray[i].ElementAt(j);
- if (db)
- {
- db->Close();
- delete db;
- }
- }
- g_pHistoryDBarray[i].RemoveAll();
- }
- }
- void CDBServerDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
-
- DDX_Control(pDX, IDC_INFOBAR, m_InfobarCtrl);
- DDX_Control(pDX, IDC_OUTLOOKBAR, m_OutlookBar);
-
- }
- BEGIN_MESSAGE_MAP(CDBServerDlg, CDialog)
-
- ON_WM_DESTROY()
- ON_COMMAND(ID_SERVER_START, OnServerStart)
- ON_UPDATE_COMMAND_UI(ID_SERVER_START, OnUpdateServerStart)
- ON_COMMAND(ID_SERVER_STOP, OnServerStop)
- ON_UPDATE_COMMAND_UI(ID_SERVER_STOP, OnUpdateServerStop)
- ON_COMMAND(ID_SERVER_EXIT, OnServerExit)
- ON_NOTIFY(NM_CLICK, IDC_OUTLOOKBAR, OnClickOutlookBar)
- ON_NOTIFY(LVN_KEYDOWN, IDC_OUTLOOKBAR, OnKeydownOutlookBar)
- ON_COMMAND(ID_USER_ACCOUNTS, OnUserAccounts)
- ON_WM_CLOSE()
- ON_COMMAND(IDC_VIEW_TRACE, OnViewTrace)
- ON_COMMAND(IDC_VIEW_ONLINE_USERS, OnViewOnlineUsers)
- ON_COMMAND(IDC_VIEW_CONFIGURATION, OnViewConfiguration)
- ON_UPDATE_COMMAND_UI(IDC_VIEW_TRACE, OnUpdateViewTrace)
- ON_UPDATE_COMMAND_UI(IDC_VIEW_ONLINE_USERS, OnUpdateViewOnlineUsers)
- ON_UPDATE_COMMAND_UI(IDC_VIEW_CONFIGURATION, OnUpdateViewConfiguration)
- ON_COMMAND(IDC_VIEW_STATISTICS, OnViewStatistics)
- ON_UPDATE_COMMAND_UI(IDC_VIEW_STATISTICS, OnUpdateViewStatistics)
- ON_COMMAND(IDC_VIEW_SECURITY, OnViewSecurity)
- ON_UPDATE_COMMAND_UI(IDC_VIEW_SECURITY, OnUpdateViewSecurity)
- ON_COMMAND(ID_ACCOUNT_WIZARD, OnAccountWizard)
- ON_WM_TIMER()
- ON_COMMAND(IDM_OPEN, OnOpen)
- ON_COMMAND(IDM_EXIT, OnExit)
- ON_COMMAND(IDM_AUTORUN, OnAutorun)
- ON_COMMAND(IDM_STARTBAKSVC, OnStartBackupSvc)
- ON_COMMAND(IDM_STARTDELSVC, OnStartDelPhotoSvc)
- ON_COMMAND(IDM_STOPBAKSVC, OnStopBackupSvc)
- ON_COMMAND(IDM_STOPDELSVC, OnStopDelPhotoSvc)
- ON_COMMAND(IDM_AUTOCHECKSVC, OnAutoCheckSvc)
-
- ON_MESSAGE(WM_ICON_NOTIFY, OnTrayNotification)
- ON_REGISTERED_MESSAGE(g_wmClose, OnAbortClose)
- END_MESSAGE_MAP()
- LRESULT CDBServerDlg::OnAbortClose(WPARAM wParam, LPARAM lParam)
- {
- if (wParam == 2)
- {
- WriteTextLog("连接失败,服务将重启");
- OnExit2();
- }
- else if (wParam == 3)
- {
- LoadBranchInfo();
- }
- return 1;
- }
- BOOL CDBServerDlg::OnInitDialog()
- {
- g_pMainWnd = this;
- CDialog::OnInitDialog();
- char server[50];
- DWORD leng = 50;
- ::GetComputerName(server, &leng);
- g_localip = server;
- MyGetIPByName(g_localip);
-
- SetupOutlookBar();
-
- CreateStatusbar();
- CRect rect;
- GetDlgItem(IDC_STATIC1)->GetWindowRect(rect);
- ScreenToClient(rect);
- rect.right += 4;
- GetDlgItem(IDC_STATIC1)->MoveWindow(rect);
-
- m_TracePage.Create(IDD_PROPPAGE_TRACE, this);
- m_OnlineUsersPage.Create(IDD_PROPPAGE_ONLINE, this);
- m_ConfigurationPage.Create(IDD_PROPPAGE_CONFIGURATION, this);
- m_StatisticsPage.Create(IDD_PROPPAGE_STATISTICS, this);
- m_SecurityPage.Create(IDD_PROPPAGE_SECURITY, this);
-
- ActivatePage(0);
-
- SetIcon(m_hIcon, TRUE);
- SetIcon(m_hIcon, FALSE);
-
- ENCODE_START
- #ifndef _DEBUG
- #ifdef TIMEDOG_VERSION
- try
- {
- CheckRegCode();
- DWORD id;
- TCHAR HKey[50]="ffffffff",LKey[50]="ffffffff";
- TCHAR OutTime[50];
- TCHAR DevicePath[ 260];
- if(FindPort(0,DevicePath)!=0)
- exit(1);
-
- TCHAR year[10],month[10],day[10],hour[10],minute[10],second[10];
- ReadTimeAuthFromEprom(HKey,LKey, OutTime, &id, 30128, HKey, LKey, DevicePath);
- CString str=OutTime;
- CString temp="年";
- int pos=str.Find (temp);
- temp=str.Left (pos);
- str=str.Right (str.GetLength ()-pos-2);
- strcpy(year, temp.GetBuffer (0));temp.ReleaseBuffer ();
- temp="月";
- pos=str.Find (temp);
- temp=str.Left (pos);
- str=str.Right (str.GetLength ()-pos-2);
- strcpy(month, temp.GetBuffer (0));temp.ReleaseBuffer ();
- temp="日";
- pos=str.Find (temp);
- temp=str.Left (pos);
- str=str.Right (str.GetLength ()-pos-2);
- strcpy(day, temp.GetBuffer (0));temp.ReleaseBuffer ();
- temp="小时";
- pos=str.Find (temp);
- temp=str.Left (pos);
- str=str.Right (str.GetLength ()-pos-4);
- strcpy(hour, temp.GetBuffer (0));temp.ReleaseBuffer ();
- temp="分钟";
- pos=str.Find (temp);
- temp=str.Left (pos);
- str=str.Right (str.GetLength ()-pos-4);
- strcpy(minute, temp.GetBuffer (0));temp.ReleaseBuffer ();
- temp="0";
- strcpy(second, temp.GetBuffer (0));temp.ReleaseBuffer ();
- long time1=ConvertStringToTimerReal(year, month, day, hour, minute, second);
- GetRunTimer(year, month, day, hour, minute, second, DevicePath);
- long time2=ConvertStringToTimerReal(year, month, day, hour, minute, second);
-
- g_dwSoftRunTime = time1 - time2;
- if( (time1-time2) <0)
- {
- AfxMessageBox("加密锁已过期, 请与经销商联系!!!");
- InputAuthDlg authdlg;
- authdlg.m_id=id;
- authdlg.m_time1=time1;
- authdlg.m_time2=time2;
- if(authdlg.DoModal ()!=IDOK)
- {
- CDialog::OnCancel ();
- return false;
- }
- }
- else if((time1-time2) < 288000 )
- {
- DogTimeOutDlg dlg;
- dlg.hour=(time1-time2)/3600;
- if(dlg.DoModal ()==IDOK)
- {
- InputAuthDlg authdlg;
- authdlg.m_id=id;
- authdlg.m_time1=time1;
- authdlg.m_time2=time2;
- authdlg.DoModal ();
- }
- }
- BOOL bOK=1;
- int d[8];double f[8];
- char s0[50]="",s1[50]="",s2[50]="",s3[50]="",s4[50]="",s5[50]="",s6[50]="",s7[50]="";
-
-
- int ret=0;
- ret=ytSoftKey.checktime(&d[0],&d[1],&d[2],&d[3],&d[4],&d[5],&d[6],&d[7],
- &f[0],&f[1],&f[2],&f[3],&f[4],&f[5],&f[6],&f[7],
- s0,s1,s2,s3,s4,s5,s6,s7);
- if(ret!=0 && ret!=-43)
- {
- bOK=0;
- }
-
- if(bOK)
- {
- str=GetRegCode(id, time1, time2);
- char path[MAX_PATH];
- ::GetSystemDirectory (path, MAX_PATH);
- CString sysdir=path;
- sysdir+="\\regcode.txt";
- CStdioFile fp;
- if(fp.Open (sysdir, CFile::modeWrite|CFile::modeCreate))
- {
- fp.WriteString (str);
- fp.Close ();
- }
- }
-
- }
- catch(...)
- {
- }
- #endif
- #endif
- ENCODE_END
- OnButton1();
- GetFileDate();
- LoadHistoryDB();
- SetTimer(4, 1000, NULL);
- SetTimer(2, 10, NULL);
-
- hInst = LoadLibrary("SENSAPI.DLL");
- if (hInst)
- {
- typedef BOOL(WINAPI *MYFUNC)(LPDWORD);
- MYFUNC IsNetworkConnect = NULL;
-
- IsNetworkConnect = (MYFUNC)GetProcAddress(hInst, "IsNetworkAlive");
- if (IsNetworkConnect)
- {
- DWORD dwActiveWan = 1;
- if (IsNetworkConnect(&dwActiveWan))
- m_bNetWorkOK = 1;
- else
- m_bNetWorkOK = 0;
- SetTimer(5, 10000, NULL);
- }
- else
- m_bNetWorkOK = 0;
- }
- else
- m_bNetWorkOK = 0;
- if ( !CBranchInfo::GetInstance() )
- {
- AfxMessageBox(_T("内存分配错误"));
- return FALSE;
- }
- if ( !CBranchInfo::GetInstance()->InitCatalog(g_dwDBServerPort, g_szDBSource, g_szDBAccount, g_szDBPassWord, g_szDBName) )
- {
- AfxMessageBox(_T("初始化数据库连接对象失败"));
- return FALSE;
- }
- CBranchInfo::GetInstance()->GetTblVersion();
- CBranchInfo::GetInstance()->GetTblCatalogInfo();
- CBranchInfo::GetInstance()->GetTblNetShareInfo();
-
-
- if(g_bAutoCheckSvc == TRUE)
- {
- m_hExitCheckSvc = CreateEvent(NULL, FALSE, FALSE, NULL);
- m_hWaitTimeOut = CreateEvent(NULL, FALSE, FALSE, NULL);
- SetEvent(m_hWaitTimeOut);
- unsigned int nThreadID = 0;
- m_bStartCheckSvc = TRUE;
- m_hCheckSvcThread = (HANDLE)_beginthreadex(NULL, 0, CheckSvcWork, this, 0, &nThreadID);
- }
- return TRUE;
- }
- void CDBServerDlg::OnDestroy()
- {
- OnServerStop();
- KillTimer(1);
- KillTimer(2);
- KillTimer(3);
- KillTimer(4);
- KillTimer(5);
- KillTimer(6);
- KillTimer(7);
- KillTimer(8);
- CDialog::OnDestroy();
- }
- void CDBServerDlg::OnServerStart()
- {
- ServerStart();
- }
- BOOL CDBServerDlg::ServerStart()
- {
- if (theServer.Start())
- {
- m_wndStatusBar.SetPaneText(0, "数据服务已启动", TRUE);
- SetOnlineLed(TRUE);
- SetOfflineLed(FALSE);
- WriteTextLog("启动成功");
- return 1;
- }
- else
- {
- WriteTextLog("启动失败");
- CDialog::OnCancel();
- return 0;
- }
- }
- void CDBServerDlg::OnUpdateServerStart(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(!theServer.IsActive());
- }
- void CDBServerDlg::OnServerStop()
- {
- theServer.Stop();
- m_wndStatusBar.SetPaneText(0, "数据服务已停止", TRUE);
- SetOnlineLed(FALSE);
- SetOfflineLed(TRUE);
- }
- void CDBServerDlg::OnUpdateServerStop(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(theServer.IsActive());
- }
- void CDBServerDlg::OnServerExit()
- {
- OnCancel();
- }
- void CDBServerDlg::SetupOutlookBar()
- {
- m_ImageList.Create(32, 32, ILC_COLOR16 | ILC_MASK, 1, 4);
- HICON hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_LOG));
- m_ImageList.Add(hIcon);
- hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ONLINE_USERS));
- m_ImageList.Add(hIcon);
- hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_CONFIGURATION));
- m_ImageList.Add(hIcon);
- hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_SECURITY));
- m_ImageList.Add(hIcon);
- hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_STATISTICS));
- m_ImageList.Add(hIcon);
- m_OutlookBar.SetImageList(&m_ImageList, LVSIL_NORMAL);
- CRect rc;
- m_OutlookBar.GetClientRect(rc);
-
- m_OutlookBar.SetIconSpacing(rc.Width(), 64);
-
- m_OutlookBar.SetTextColor(RGB(255, 255, 255));
- m_OutlookBar.SetTextBkColor(RGB(128, 128, 128));
- m_OutlookBar.SetBkColor(RGB(128, 128, 128));
-
- m_OutlookBar.InsertColumn(0, "OutlookBar");
- m_OutlookBar.InsertItem(0, "服务器日志", 0);
- m_OutlookBar.InsertItem(1, "在线用户", 1);
- m_OutlookBar.InsertItem(2, "关于", 2);
- m_OutlookBar.InsertItem(3, "功能区", 3);
- }
- void CDBServerDlg::MoveChilds()
- {
-
- CRect rcDlgs;
-
- GetDlgItem(IDC_DIALOG_AREA)->GetWindowRect(rcDlgs);
- ScreenToClient(rcDlgs);
- m_ConfigurationPage.MoveWindow(rcDlgs);
- m_TracePage.MoveWindow(rcDlgs);
- m_OnlineUsersPage.MoveWindow(rcDlgs);
- m_StatisticsPage.MoveWindow(rcDlgs);
- m_SecurityPage.MoveWindow(rcDlgs);
- }
- void CDBServerDlg::ActivatePage(int nIndex)
- {
- switch (nIndex)
- {
- case 0:
- m_OnlineUsersPage.ShowWindow(SW_HIDE);
- m_ConfigurationPage.ShowWindow(SW_HIDE);
- m_StatisticsPage.ShowWindow(SW_HIDE);
- m_SecurityPage.ShowWindow(SW_HIDE);
- m_TracePage.ShowWindow(SW_SHOW);
- m_InfobarCtrl.SetText("服务器日志");
- break;
- case 1:
- m_TracePage.ShowWindow(SW_HIDE);
- m_ConfigurationPage.ShowWindow(SW_HIDE);
- m_StatisticsPage.ShowWindow(SW_HIDE);
- m_SecurityPage.ShowWindow(SW_HIDE);
- m_OnlineUsersPage.RefreshData();
- m_OnlineUsersPage.ShowWindow(SW_SHOW);
- m_InfobarCtrl.SetText("在线用户");
- break;
- case 2:
- m_OnlineUsersPage.ShowWindow(SW_HIDE);
- m_TracePage.ShowWindow(SW_HIDE);
- m_StatisticsPage.ShowWindow(SW_HIDE);
- m_SecurityPage.ShowWindow(SW_HIDE);
- m_ConfigurationPage.ShowWindow(SW_SHOW);
- m_InfobarCtrl.SetText("关于");
- break;
- case 4:
- m_OnlineUsersPage.ShowWindow(SW_HIDE);
- m_TracePage.ShowWindow(SW_HIDE);
- m_ConfigurationPage.ShowWindow(SW_HIDE);
- m_SecurityPage.ShowWindow(SW_HIDE);
- m_StatisticsPage.ShowWindow(SW_SHOW);
- m_InfobarCtrl.SetText("Statistics");
- break;
- case 3:
- m_OnlineUsersPage.ShowWindow(SW_HIDE);
- m_TracePage.ShowWindow(SW_HIDE);
- m_ConfigurationPage.ShowWindow(SW_HIDE);
- m_SecurityPage.ShowWindow(SW_SHOW);
- m_StatisticsPage.ShowWindow(SW_HIDE);
- m_InfobarCtrl.SetText("功能区");
- break;
- default:
- break;
- }
- MoveChilds();
- }
- void CDBServerDlg::OnClickOutlookBar(NMHDR* pNMHDR, LRESULT* pResult)
- {
-
- int nIndex = m_OutlookBar.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
- if (nIndex == -1)
- return;
- ActivatePage(nIndex);
- *pResult = 0;
- }
- void CDBServerDlg::OnKeydownOutlookBar(NMHDR* pNMHDR, LRESULT* pResult)
- {
- LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR;
-
- int nIndex = m_OutlookBar.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
- if (nIndex == -1)
- return;
- if (pLVKeyDow->wVKey == VK_DOWN)
- {
- if (m_OutlookBar.GetItemCount() - 1 > nIndex)
- {
- ActivatePage(nIndex + 1);
- }
- }
- else if (pLVKeyDow->wVKey == VK_UP)
- {
- if (nIndex > 0)
- {
- ActivatePage(nIndex - 1);
- }
- }
- else if (pLVKeyDow->wVKey == VK_NEXT)
- {
- ActivatePage(m_OutlookBar.GetItemCount() - 1);
- }
- else if (pLVKeyDow->wVKey == VK_PRIOR)
- {
- ActivatePage(0);
- }
- *pResult = 0;
- }
- BOOL CDBServerDlg::CreateStatusbar()
- {
-
- if (!m_wndToolBar.Create(this) || !m_wndToolBar.LoadToolBar(IDR_TOOLBAR1))
- {
- TRACE0("Failed to Create Dialog Toolbar\n");
- return FALSE;
- }
- m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);
-
- m_wndToolBar.ModifyStyle(0, m_wndToolBar.GetStyle() | TBSTYLE_FLAT);
-
- if (m_wndStatusBar.Create(this))
- {
- m_wndStatusBar.SetIndicators(auIDStatusBar, sizeof(auIDStatusBar) / sizeof(UINT));
- m_wndStatusBar.SetPaneText(0, "Date Server is offline", TRUE);
-
- m_wndStatusBar.SetPaneInfo(0, m_wndStatusBar.GetItemID(0), SBPS_STRETCH, NULL);
- SetOnlineLed(FALSE);
- SetOfflineLed(FALSE);
- m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_ONLINELED), ID_INDICATOR_ONLINELED, SBPS_NOBORDERS, 14);
-
- m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_OFFLINELED), ID_INDICATOR_OFFLINELED, SBPS_NOBORDERS, 14);
-
- }
-
-
- CRect rcClientStart;
- CRect rcClientNow;
- GetClientRect(rcClientStart);
- RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0, reposQuery, rcClientNow);
-
-
-
- CPoint ptOffset(rcClientNow.left - rcClientStart.left, rcClientNow.top - rcClientStart.top);
- CRect rcChild;
- CWnd* pwndChild = GetWindow(GW_CHILD);
- while (pwndChild)
- {
- pwndChild->GetWindowRect(rcChild);
- ScreenToClient(rcChild);
- rcChild.OffsetRect(ptOffset);
- pwndChild->MoveWindow(rcChild, FALSE);
- pwndChild = pwndChild->GetNextWindow();
- }
-
- CRect rcWindow;
- GetWindowRect(rcWindow);
- rcWindow.right += rcClientStart.Width() - rcClientNow.Width();
- rcWindow.bottom += rcClientStart.Height() - rcClientNow.Height();
- MoveWindow(rcWindow, FALSE);
-
- RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
- return TRUE;
- }
- void CDBServerDlg::OnUserAccounts()
- {
-
- }
- void CDBServerDlg::OnFTPUserConnected(DWORD nThreadID, LPCTSTR lpszUser, LPCSTR lpszAddress)
- {
- m_OnlineUsersPage.AddUser(nThreadID, lpszUser, lpszAddress);
- }
- void CDBServerDlg::OnFTPUserDisconnected(DWORD nThreadID, LPCTSTR lpszUser)
- {
- m_OnlineUsersPage.RemoveUser(nThreadID);
- }
- void CDBServerDlg::OnFTPStatusChange(int nType, LPCTSTR lpszText)
- {
- m_TracePage.AddTraceLine(nType, lpszText);
- switch (nType)
- {
- case 3:
- theApp.m_LogFile << error_lvl << date << time << lpszText << endl;
- break;
- default:
- theApp.m_LogFile << trace_lvl << date << time << lpszText << endl;
- break;
- }
- }
- void CDBServerDlg::OnFTPReceivedBytesChange(int nBytes)
- {
- m_StatisticsPage.SetValue(6, FormatSize(nBytes, 0));
- CString strStatus;
- strStatus.Format("%s received", FormatSize(nBytes, 0));
- m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_DATA_RECEIVED), strStatus, TRUE);
- CClientDC dc(this);
- CSize size = dc.GetTextExtent(strStatus);
- m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_DATA_RECEIVED), ID_INDICATOR_DATA_RECEIVED, SBPS_NORMAL, size.cx);
- }
- void CDBServerDlg::OnFTPSentBytesChange(int nBytes)
- {
- m_StatisticsPage.SetValue(7, FormatSize(nBytes, 0));
- CString strStatus;
- strStatus.Format("%s sent", FormatSize(nBytes, 0));
- m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_DATA_SEND), strStatus, TRUE);
- CClientDC dc(this);
- CSize size = dc.GetTextExtent(strStatus);
- m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_DATA_SEND), ID_INDICATOR_DATA_SEND, SBPS_NORMAL, size.cx);
- }
- void CDBServerDlg::OnViewTrace()
- {
- ActivatePage(0);
- }
- void CDBServerDlg::OnViewOnlineUsers()
- {
- ActivatePage(1);
- }
- void CDBServerDlg::OnViewConfiguration()
- {
- ActivatePage(2);
- }
- void CDBServerDlg::OnViewStatistics()
- {
- ActivatePage(3);
- }
- void CDBServerDlg::OnViewSecurity()
- {
- ActivatePage(4);
- }
- void CDBServerDlg::OnUpdateViewTrace(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(m_TracePage.IsWindowVisible());
- }
- void CDBServerDlg::OnUpdateViewOnlineUsers(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(m_OnlineUsersPage.IsWindowVisible());
- }
- void CDBServerDlg::OnUpdateViewConfiguration(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(m_ConfigurationPage.IsWindowVisible());
- }
- void CDBServerDlg::OnUpdateViewStatistics(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(m_StatisticsPage.IsWindowVisible());
- }
- void CDBServerDlg::OnUpdateViewSecurity(CCmdUI* pCmdUI)
- {
- pCmdUI->SetRadio(m_SecurityPage.IsWindowVisible());
- }
- void CDBServerDlg::SetOnlineLed(BOOL bOnline)
- {
- HICON hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(),
- bOnline ? MAKEINTRESOURCE(IDI_LED_GREEN) : MAKEINTRESOURCE(IDI_LED_OFF),
- IMAGE_ICON, 16, 16, LR_SHARED);
- m_wndStatusBar.GetStatusBarCtrl().SetIcon(m_wndStatusBar.CommandToIndex(ID_INDICATOR_ONLINELED), hIcon);
- m_wndStatusBar.GetStatusBarCtrl().Invalidate();
- m_wndStatusBar.GetStatusBarCtrl().UpdateWindow();
- DestroyIcon(hIcon);
- }
- void CDBServerDlg::SetOfflineLed(BOOL bOffline)
- {
- HICON hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(),
- bOffline ? MAKEINTRESOURCE(IDI_LED_RED) : MAKEINTRESOURCE(IDI_LED_OFF),
- IMAGE_ICON, 16, 16, LR_SHARED);
- m_wndStatusBar.GetStatusBarCtrl().SetIcon(m_wndStatusBar.CommandToIndex(ID_INDICATOR_OFFLINELED), hIcon);
- m_wndStatusBar.GetStatusBarCtrl().Invalidate();
- m_wndStatusBar.GetStatusBarCtrl().UpdateWindow();
- DestroyIcon(hIcon);
- }
- void CDBServerDlg::OnFTPStatisticChange(int nType, int nValue)
- {
- m_StatisticsPage.SetValue(nType, nValue);
- }
- char* CDBServerDlg::FormatSize(DWORD dwSizeLow, DWORD dwSizeHigh)
- {
- static char szBuff[100];
- unsigned __int64 nFileSize = ((unsigned __int64)(((DWORD)(dwSizeLow)) |
- ((unsigned __int64)((DWORD)(dwSizeHigh))) << 32));
- unsigned __int64 kb = 0;
- if (nFileSize > 1024)
- {
- kb = nFileSize / 1024;
- if (nFileSize % 1024)
- kb++;
- }
-
- _ui64tot(kb, szBuff, 10);
-
- int nLength = lstrlen(szBuff);
- if (nLength > 3)
- {
- LPCTSTR ptr = szBuff;
- ptr += (nLength - 1);
- char szTemp[100];
- LPTSTR ptrTemp = szTemp;
- for (int i = 0; i < nLength; i++)
- {
- if (i && ((i % 3) == 0))
- {
- if (*ptrTemp != ',')
- {
- *ptrTemp = ',';
- ptrTemp = _tcsinc(ptrTemp);
- }
- }
- *ptrTemp = *ptr;
- ptrTemp = _tcsinc(ptrTemp);
- ptr = _tcsdec(szBuff, ptr);
- }
-
- *ptrTemp = '\0';
-
- _tcsrev(szTemp);
- lstrcpy(szBuff, szTemp);
- }
-
- lstrcat(szBuff, " KB");
- return szBuff;
- }
- void CDBServerDlg::OnAccountWizard()
- {
- }
- void CDBServerDlg::OnCancel()
- {
- }
- void CDBServerDlg::OnOK()
- {
- }
- void CDBServerDlg::OnButton1()
- {
-
- try
- {
- theServer.Initialize(this);
- if (ServerStart() == 0)
- return;
- if (g_pSkinData == NULL)
- InitLia();
-
-
- CDatabase *pdb = NULL;
- ODBCConnGuard ConnGuard(pdb, -1, 3000);
- if ( pdb == NULL)
- return;
- CRecordset myset(pdb);
- #if 0
- CString logdays;
- CString sql = "select logdays from version";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("logdays", logdays);
- myset.Close();
- int days = 180;
- if (logdays == "1个月")
- days = 31;
- else if (logdays == "2个月")
- days = 61;
- else if (logdays == "3个月")
- days = 92;
- else
- days = 183;
- CTime tm = CTime::GetCurrentTime();
- CTimeSpan dt(240, 0, 0, 0);
- tm -= dt;
- CString date = tm.Format("%Y-%m-%d");
-
- sql = _T("DROP TRIGGER ON_DELETE_USER_LOGS");
- pdb->ExecuteSQL(sql);
- sql = "delete from [log] where [date]<'" + date + "'";
- pdb->ExecuteSQL(sql);
-
- sql = _T("CREATE TRIGGER ON_DELETE_USER_LOGS ON [dbo].[log] FOR DELETE AS BEGIN rollback; END");
- pdb->ExecuteSQL(sql);
- #endif
-
- CTime tm = CTime::GetCurrentTime();
- CTimeSpan dt2(183, 0, 0, 0);
- tm -= dt2;
- CString date = tm.Format("%Y%m%d%H%M%S");
- CString sql = "delete from sendreg where [status]='OK' and [timestamp]<'" + date + "'";
- pdb->ExecuteSQL(sql);
-
- sql = "select version from version";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("version", sql);
- myset.Close();
- m_ConfigurationPage.m_versionno = sql;
- m_ConfigurationPage.UpdateData(0);
-
- }
- catch (CException *e)
- {
- TCHAR szError[1024] = { 0 };
- e->GetErrorMessage(szError, 1024);
- WriteTextLog(CString(szError));
- e->Delete();
- }
- }
- void CDBServerDlg::OnClose()
- {
- m_TrayIcon.Create(this, WM_ICON_NOTIFY, "影楼管理系统服务器", m_hIcon, IDR_MENUtray);
- ShowWindow(SW_HIDE);
- }
- LRESULT CDBServerDlg::OnTrayNotification(WPARAM wParam, LPARAM lParam)
- {
- return m_TrayIcon.OnTrayNotification(wParam, lParam);
- }
- void CDBServerDlg::OnOpen()
- {
- ShowWindow(SW_SHOW);
- }
- void CDBServerDlg::OnExit2()
- {
- try
- {
- TerminateThread();
- m_TrayIcon.RemoveIcon();
- if (g_pSkinData)delete[]g_pSkinData; g_pSkinData = NULL;
-
- for (int i = 0; i < g_dbHistoryArray.GetSize(); i++)
- {
- g_dbHistoryArray.ElementAt(i)->Close();
- delete g_dbHistoryArray.ElementAt(i);
- }
- ReleaseBranchDB();
- }
- catch (...)
- {
- WriteTextLog("出错在函数OnExit2中");
- }
- CDialog::OnCancel();
- }
- void CDBServerDlg::OnExit()
- {
- try
- {
-
- TerminateCheckWork();
-
- if(CreateSmallPhoto::GetInstance()->IsCreating())
- {
- if(AfxMessageBox("温馨提示:生成小图还未完成确定要退出程序吗", MB_YESNO|MB_ICONSTOP) == IDNO)
- return;
- CreateSmallPhoto::GetInstance()->TerminateThread();
- }
- TerminateThread();
- DWORD id = FindAppProcessID("AutoRun.exe");
- if (id != -1)
- {
- HANDLE ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
- if (ProcessHandle)TerminateProcess(ProcessHandle, 0);
- }
- m_TrayIcon.RemoveIcon();
- if (g_pSkinData)delete[]g_pSkinData; g_pSkinData = NULL;
- ReleaseBranchDB();
- }
- catch (...)
- {
- WriteTextLog("出错在函数OnExit中");
- }
- CDialog::OnCancel();
- }
- void CDBServerDlg::OnTimer(UINT nIDEvent)
- {
- try
- {
- if (nIDEvent == 1)
- {
- KillTimer(nIDEvent);
- LoadThumbImages();
- }
- else if (nIDEvent == 2)
- {
- KillTimer(nIDEvent);
- OnClose();
- try
- {
- CheckHistoryData();
- LoadBranchInfo();
- }
- catch (...)
- {
- }
- SetTimer(1, 2 * 60 * 1000, NULL);
- SetTimer(4, 1000 * 60 * 2, NULL);
- SetTimer(7, 1000 * 60 * 60 * 1, NULL);
- SetTimer(8, 3000, NULL);
- SetTimer(9, 10000, NULL);
- }
- else if (nIDEvent == 3)
- {
- g_pMainWnd->KillTimer(3);
- HANDLE hMutex = ::OpenMutex(NULL, FALSE, _T("lyfzSMSHandle"));
- if (GetLastError() == ERROR_FILE_NOT_FOUND)
- {
- CString autorunpath = g_mainpath + _T("\\SMSHandle.exe");
- ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
- }
- if(hMutex) CloseHandle(hMutex);
- }
- else if (nIDEvent == 4)
- {
- UpdateDate();
- CheckMemberMsg();
- BakPhoto();
- }
- else if (nIDEvent == 5)
- {
- typedef BOOL(WINAPI *MYFUNC)(LPDWORD);
- MYFUNC IsNetworkConnect = NULL;
-
- IsNetworkConnect = (MYFUNC)GetProcAddress(hInst, "IsNetworkAlive");
- if (IsNetworkConnect)
- {
- DWORD dwActiveWan = 1;
- BOOL state;
- if (IsNetworkConnect(&dwActiveWan))
- state = 1;
- else
- state = 0;
- if (m_bNetWorkOK != state)
- {
- KillTimer(nIDEvent);
- WriteTextLog("网络断开");
- OnExit2();
- }
- }
- }
- else if (nIDEvent == 6)
- {
- KillTimer(nIDEvent);
- ShutDown();
- }
- else if (nIDEvent == 7)
- {
-
- GenUPhoneData();
- }
- else if (nIDEvent == 8)
- {
- CheckConnCount();
- }
- }
- catch (...)
- {
- WriteTextLog("出错在函数Timer中");
- }
- }
- void LoadImageFromBuf(Image **img, BYTE *pData, DWORD leng)
- {
- try
- {
- if (pData == NULL)return;
- if (*img)delete *img;
- *img = NULL;
-
- HGLOBAL m_hMem = GlobalAlloc(GMEM_MOVEABLE, leng);
- if (m_hMem == NULL)return;
- BYTE* pmem = (BYTE*)GlobalLock(m_hMem);
- memcpy(pmem, pData, leng);
- IStream* pstm;
- CreateStreamOnHGlobal(m_hMem, TRUE, &pstm);
-
- *img = Gdiplus::Image::FromStream(pstm);
-
- GlobalUnlock(m_hMem);
- pstm->Release();
- }
- catch (...)
- {
- }
- }
- void LoadImageFromBuf(Image **img, CString path)
- {
- try
- {
- CFile fp;
- if (fp.Open(path, CFile::modeRead))
- {
- DWORD leng = fp.GetLength();
- BYTE *pData = new BYTE[leng];
- fp.Read(pData, leng);
- fp.Close();
- LoadImageFromBuf(img, pData, leng);
- delete[]pData;
- }
- }
- catch (...)
- {
- }
- }
- void LoadImageFromRes(Image **img, LPCTSTR lpszResourceName, LPCTSTR ResourceType)
- {
- try
- {
- HGLOBAL hGlobal = NULL;
- HRSRC hSource = NULL;
- LPVOID lpVoid = NULL;
- int nSize = 0;
- BOOL bResult = FALSE;
- hSource = FindResource(NULL, lpszResourceName, ResourceType);
- if (hSource == NULL)return;
- hGlobal = LoadResource(NULL, hSource);
- if (hGlobal == NULL)return;
- lpVoid = LockResource(hGlobal);
- if (lpVoid == NULL)return;
- nSize = (UINT)SizeofResource(NULL, hSource);
- LoadImageFromBuf(img, (BYTE*)hGlobal, nSize);
- UnlockResource(hGlobal);
- FreeResource(hGlobal);
- }
- catch (...)
- {
- }
- }
- void GenSPhoto(CString dir, BOOL bMPhoto)
- {
-
- if (dir.Find("公告附件") != -1)return;
-
- if (dir.Find("客户原片(管理软件)$") != -1 || dir.Find("修好的片(管理软件)$") != -1)
- {
- }
- else
- bMPhoto = 0;
-
-
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(dir), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- int oldsize = coo.size();
- CString path, temp, spath, mpath;
- for (it = coo.begin(); coo.end() != it; it++)
- {
- try
- {
- if (g_pMainWnd->m_bTerminate)return;
-
- path = (*it).c_str();
- spath = path.Left(path.ReverseFind('\\') + 1);
- mpath = spath;
- spath += "s";
- mpath += "m";
- temp = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
- if (temp.GetAt(0) == 's')continue;
- if (temp.GetAt(0) == 'm')continue;
- spath += path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
- mpath += path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
- if (g_bSteal)
- {
- Image *pImg = NULL;
- ::LoadImageFromBuf(&pImg, path);
- if (pImg == NULL)continue;
- if (pImg->GetWidth() == 0)continue;
- delete pImg;
- EncryptFile3(path);
- if (path.Find("客户原片") != -1)
- {
- int pos = path.Find("管理软件)$");
- if (pos != -1)
- {
- path = g_bakserver1 + path.Right(path.GetLength() - pos - 10);
- EncryptFile3(path);
- }
- }
- else if (path.Find("修好的片") != -1)
- {
- int pos = path.Find("管理软件)$");
- if (pos != -1)
- {
- path = g_bakserver2 + path.Right(path.GetLength() - pos - 10);
- EncryptFile3(path);
- }
- }
- else if (path.Find("精修好的片") != -1)
- {
- int pos = path.Find("管理软件)$");
- if (pos != -1)
- {
- path = g_bakserver3 + path.Right(path.GetLength() - pos - 10);
- EncryptFile3(path);
- }
- }
- else if (path.Find("设计好的片") != -1)
- {
- int pos = path.Find("管理软件)$");
- if (pos != -1)
- {
- path = g_bakserver4 + path.Right(path.GetLength() - pos - 10);
- EncryptFile3(path);
- }
- }
- oldsize++;
- }
- else if (!CheckFileExist(spath))
- {
- Image *pImg = NULL;
- ::LoadImageFromBuf(&pImg, path);
- if (pImg == NULL)continue;
- if (pImg->GetWidth() == 0)
- {
-
- if (pImg)
- delete pImg;
- pImg = NULL;
- continue;
- }
- CRect rc(0, 0, 100, 90);
- RectFitDes(pImg->GetWidth(), pImg->GetHeight(), rc);
- Image *simg = pImg->GetThumbnailImage(rc.Width(), rc.Height(), NULL, NULL);
- if (simg == NULL)
- {
- if (pImg)
- delete pImg;
- pImg = NULL;
- continue;
- }
- Image *simg2 = NULL;
- if (bMPhoto)
- {
- CRect rc2(0, 0, 2000, 2000);
- RectFitDes(pImg->GetWidth(), pImg->GetHeight(), rc2);
- simg2 = pImg->GetThumbnailImage(rc2.Width(), rc2.Height(), NULL, NULL);
- if (simg2 == NULL)
- {
- if (pImg)
- delete pImg;
- pImg = NULL;
- continue;
- }
- }
- Graphics graphic(simg);
- graphic.Clear(Color(255, 255, 255, 255));
- graphic.DrawImage(pImg, 0, 0, simg->GetWidth(), simg->GetHeight());
- if (bMPhoto)
- {
- Graphics graphic2(simg2);
- graphic2.Clear(Color(255, 255, 255, 255));
- graphic2.DrawImage(pImg, 0, 0, simg2->GetWidth(), simg2->GetHeight());
- }
-
- UINT totalBufferSize;
- UINT numProperties;
- pImg->GetPropertySize(&totalBufferSize, &numProperties);
-
- PropertyItem* pAllItems = (PropertyItem*)malloc(totalBufferSize);
-
- pImg->GetAllPropertyItems(totalBufferSize, numProperties, pAllItems);
-
- for (UINT j = 0; j < numProperties; ++j)
- {
- if (PropertyTagOrientation == pAllItems[j].id)
- {
- short* ptrLong = (short*)(pAllItems[j].value);
- int ret = (int)*ptrLong;
-
-
-
- if (ret == 8)
- {
- if (simg2)simg2->RotateFlip(Rotate270FlipNone);
- simg->RotateFlip(Rotate270FlipNone);
- }
- else if (ret == 6)
- {
- if (simg2)simg2->RotateFlip(Rotate90FlipNone);
- simg->RotateFlip(Rotate90FlipNone);
- }
- break;
- }
- }
- free(pAllItems);
-
- ::SaveImageToFile(simg, spath); oldsize++;
- delete simg;
- delete pImg;
- if (bMPhoto)
- {
- ::SaveImageToFile2(simg2, mpath, 100); oldsize++;
- delete simg2;
- }
- }
- }
- catch (...)
- {
- WriteTextLog("出错在函数GenSPhoto中");
- }
- }
- try
- {
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(dir), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- int newsize = coo.size();
- if (oldsize == newsize)
- {
- path = dir + "\\ok";
- CFile fp;
- fp.Open(path, CFile::modeCreate | CFile::modeWrite);
- fp.Close();
- }
- }
- catch (...)
- {
- WriteTextLog("出错在函数GenSPhoto2中");
- }
- }
- unsigned __stdcall LoadThumbNail(LPVOID lpParam)
- {
- BOOL bMphoto = 0;
- if (g_bSteal == 0)
- {
- CDatabase *pMaindb = NULL;
- ODBCConnGuard ConnGuard(pMaindb , -1, 3000);
- if ( pMaindb )
- {
- try
- {
- CRecordset myset(pMaindb);
- CString sql = "select * from version";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("setcheck15", sql);
- myset.Close();
- bMphoto = atoi(sql);
- }
- catch (CDBException* e)
- {
- WriteTextLog(_T("LoadThumbNail:%s"),e->m_strError);
- e->Delete();
- }
-
- }
- }
- CString initialPhotoPath = _T("");
- CString initialModifyPath = _T("");
- CString designPhotoPath = _T("");
- CString excellentModifyPath = _T("");
- char server[50] = {0};
- DWORD leng = 50;
- ::GetComputerName(server, &leng);
- initialPhotoPath = initialModifyPath = designPhotoPath = excellentModifyPath = server;
- initialPhotoPath = "\\\\" + initialPhotoPath + "\\客户原片(管理软件)$";
- initialModifyPath = "\\\\" + initialModifyPath + "\\修好的片(管理软件)$";
- designPhotoPath = "\\\\" + designPhotoPath + "\\设计好的片(管理软件)$";
- excellentModifyPath = "\\\\" + excellentModifyPath + "\\精修好的片(管理软件)$";
- GetPathFromNetShareName("客户原片(管理软件)$", initialPhotoPath);
- GetPathFromNetShareName("修好的片(管理软件)$", initialModifyPath);
- GetPathFromNetShareName("设计好的片(管理软件)$", designPhotoPath);
- GetPathFromNetShareName("精修好的片(管理软件)$", excellentModifyPath);
- int i = 0;
- CDBServerDlg *pDlg = (CDBServerDlg*)lpParam;
- try
- {
- CStringArray dirarray;
-
-
-
-
- if(CBranchInfo::GetInstance()->m_TblNetShareInfo.size() != 0)
- {
- vector<TblNetShareInfo*>::iterator iter = CBranchInfo::GetInstance()->m_TblNetShareInfo.begin();
- for(; iter != CBranchInfo::GetInstance()->m_TblNetShareInfo.end();)
- {
- TblNetShareInfo* p = (*iter);
- if(p != NULL)
- {
- CString strDir = p->szShareDirectory;
- if(strDir.Find(_T("$\\")) != -1)
- strDir = strDir.TrimRight(_T("\\"));
- pDlg->CheckOkFileExistence(strDir, dirarray);
- }
- ++iter;
- }
- CString patharray[2] = { designPhotoPath, excellentModifyPath };
-
- for (i = 0; i < 2; i++)
- {
- if (pDlg->m_bTerminate)
- break;
- pDlg->CheckOkFileExistence(patharray[i], dirarray);
- }
- }
- else
- {
- CString patharray[4] = { initialPhotoPath, initialModifyPath, designPhotoPath, excellentModifyPath };
- for (i = 0; i < 4; i++)
- {
- if (pDlg->m_bTerminate)
- break;
- pDlg->CheckOkFileExistence(patharray[i], dirarray);
- }
- }
-
- for (i = 0; i < dirarray.GetSize(); i++)
- {
- if (pDlg->m_bTerminate)
- break;
- GenSPhoto(dirarray.ElementAt(i), bMphoto);
- }
- }
- catch (...)
- {
- WriteTextLog("出错在函数GenThumb中");
- }
- pDlg->m_bRunning = false;
- pDlg->m_bTerminate = false;
- pDlg->SetTimer(1, 60 * 1000, NULL);
- _endthreadex(0);
- return 0;
- }
- BOOL CDBServerDlg::CheckOkFileExistence(const CString& strPath, CStringArray& arr)
- {
- CString path(_T("")), path2(_T(""));
- if(strPath == _T(""))
- return FALSE;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(strPath), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- it = coo.begin();
- it++;
- for(; coo.end() != it; it++)
- {
- if (m_bTerminate)
- break;
- path = (*it).c_str();
- path.TrimRight("\\");
- path2 = path;
- path2 += "\\ok2.dat";
- path += "\\ok";
- if (CheckFileExist(path2) && path2.Find(".ly.com") == -1)
- {
- ::DeleteFile(path);
- ::DeleteFile(path2);
- }
-
-
- if (g_bCheckAll || g_bSteal)
- {
- if (FindArray(&arr, (*it).c_str()) == -1)
- arr.Add((*it).c_str());
- }
- else if (CheckFileExist(path) == 0)
- {
- if (FindArray(&arr, (*it).c_str()) == -1)
- arr.Add((*it).c_str());
- }
- }
- return 1;
- }
- void CDBServerDlg::LoadThumbImages()
- {
- if (m_bRunning)return;
- TerminateThread();
- m_bRunning = true;
- m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail, (LPVOID)this, 0, &m_dwThreadID);
- }
- BOOL CDBServerDlg::TerminateThread()
- {
- try
- {
- if (!m_bRunning)
- return TRUE;
- m_bTerminate = true;
- for (;;)
- {
- if (::WaitForSingleObject(m_hThread, INFINITE) == WAIT_OBJECT_0)
- break;
- }
- ::CloseHandle(m_hThread);
- m_bRunning = false;
- return TRUE;
- }
- catch (...)
- {
- WriteTextLog("出错在函数TerminateThread中");
- }
- return TRUE;
- }
- void CDBServerDlg::InitLia()
- {
- try
- {
-
-
- BYTE *pReturnData = NULL;
- DWORD dwReturnLen;
- DWORD count2;
- BYTE byCode = 104;
- CConnectSocket consock;
- ODBCConnGuard ConnGuard(consock.m_pConndb, -1, 3000);
- if ( consock.m_pConndb == NULL )
- return;
- consock.GetDataFromCode(byCode, &pReturnData, dwReturnLen, count2, "");
- if (pReturnData == NULL || dwReturnLen == 0)
- return;
- DWORD readbytes = 0;
- CArray<DWORD, DWORD> ArrayOfLen;
- CArray<DWORD, DWORD> ArrayOfBtnLen;
- BYTE *pArrayPointer = NULL;
- DWORD dwPointerLen = 0;
- DWORD leng;
- memcpy(&leng, pReturnData + readbytes, sizeof(DWORD));
- readbytes += sizeof(DWORD);
- BYTE *pFtData = new BYTE[leng];
- memcpy(pFtData, pReturnData + readbytes, leng);
- readbytes += leng;
- CMemFile memfile;
- memfile.Attach(pFtData, leng);
- CArchive ar(&memfile, CArchive::load);
- ArrayOfLen.Serialize(ar);
- ar.Close();
- memfile.Detach();
- memcpy(&leng, pReturnData + readbytes, sizeof(DWORD));
- readbytes += sizeof(DWORD);
- BYTE *pFtData2 = new BYTE[leng];
- memcpy(pFtData2, pReturnData + readbytes, leng);
- readbytes += leng;
- CMemFile memfile2;
- memfile2.Attach(pFtData2, leng);
- CArchive ar2(&memfile2, CArchive::load);
- ArrayOfBtnLen.Serialize(ar2);
- ar2.Close();
- memfile2.Detach();
- delete[]pFtData;
- delete[]pFtData2;
- DWORD count;
- memcpy(&count, pReturnData + readbytes, sizeof(DWORD));
- readbytes += sizeof(DWORD);
- dwPointerLen = count*sizeof(RESDATA2);
- pArrayPointer = new BYTE[dwPointerLen];
- int i = 0;
- for (i = 0; i < count; i++)
- {
- memcpy(pArrayPointer + i*sizeof(RESDATA2), pReturnData + readbytes, sizeof(RESDATA2));
- readbytes += sizeof(RESDATA2);
- }
- for (i = 0; i < ArrayOfLen.GetSize(); i += 8)
- {
- DWORD leng1, leng2, leng3, leng4, leng5, leng6, leng7, leng8;
- leng1 = ArrayOfLen.ElementAt(i);
- leng2 = ArrayOfLen.ElementAt(i + 1);
- leng3 = ArrayOfLen.ElementAt(i + 2);
- leng4 = ArrayOfLen.ElementAt(i + 3);
- leng5 = ArrayOfLen.ElementAt(i + 4);
- leng6 = ArrayOfLen.ElementAt(i + 5);
- leng7 = ArrayOfLen.ElementAt(i + 6);
- leng8 = ArrayOfLen.ElementAt(i + 7);
- if (i % 4 == 0)
- DeCodelong1((int&)leng1, (int&)leng2, (int&)leng3, (int&)leng4, (int&)leng5, (int&)leng6, (int&)leng7, (int&)leng8);
- else if (i % 4 == 1)
- DeCodelong2((int&)leng1, (int&)leng2, (int&)leng3, (int&)leng4, (int&)leng5, (int&)leng6, (int&)leng7, (int&)leng8);
- else if (i % 4 == 2)
- DeCodelong3((int&)leng1, (int&)leng2, (int&)leng3, (int&)leng4, (int&)leng5, (int&)leng6, (int&)leng7, (int&)leng8);
- else
- DeCodelong4((int&)leng1, (int&)leng2, (int&)leng3, (int&)leng4, (int&)leng5, (int&)leng6, (int&)leng7, (int&)leng8);
- ArrayOfLen.SetAt(i, leng1);
- ArrayOfLen.SetAt(i + 1, leng2);
- ArrayOfLen.SetAt(i + 2, leng3);
- ArrayOfLen.SetAt(i + 3, leng4);
- ArrayOfLen.SetAt(i + 4, leng5);
- ArrayOfLen.SetAt(i + 5, leng6);
- ArrayOfLen.SetAt(i + 6, leng7);
- ArrayOfLen.SetAt(i + 7, leng8);
- }
- delete[]pReturnData;
- if (g_pSkinData)
- delete[]g_pSkinData;
- g_pSkinData = NULL;
- DWORD length;
- BYTE *pData;
- DWORD length2;
- BYTE *pData2;
- CMemFile mStoreFile;
- CArchive arStore(&mStoreFile, CArchive::store);
- ArrayOfLen.Serialize(arStore);
- arStore.Close();
- length = mStoreFile.GetLength();
- pData = mStoreFile.Detach();
- CMemFile mStoreFile1;
- CArchive arStore1(&mStoreFile1, CArchive::store);
- ArrayOfBtnLen.Serialize(arStore1);
- arStore1.Close();
- length2 = mStoreFile1.GetLength();
- pData2 = mStoreFile1.Detach();
- g_SkinLeng = length + length2 + dwPointerLen + 3 * sizeof(DWORD);
- g_pSkinData = new BYTE[g_SkinLeng];
- readbytes = 0;
- memcpy(g_pSkinData + readbytes, &length, sizeof(DWORD));
- readbytes += sizeof(DWORD);
- memcpy(g_pSkinData + readbytes, pData, length);
- readbytes += length;
- memcpy(g_pSkinData + readbytes, &length2, sizeof(DWORD));
- readbytes += sizeof(DWORD);
- memcpy(g_pSkinData + readbytes, pData2, length2);
- readbytes += length2;
- memcpy(g_pSkinData + readbytes, &dwPointerLen, sizeof(DWORD));
- readbytes += sizeof(DWORD);
- memcpy(g_pSkinData + readbytes, pArrayPointer, dwPointerLen);
- readbytes += dwPointerLen;
- delete[]pArrayPointer;
- }
- catch (...)
- {
- WriteTextLog("出错在函数InitLia中");
- }
- }
- BOOL CheckExistDinDan(CString id)
- {
- CDatabase *pMaindb = NULL;
- ODBCConnGuard ConnGuard(pMaindb, -1, 30000);
- if ( pMaindb == NULL )
- return FALSE;
- CRecordset myset(pMaindb);
- CString sql = "select count(*) as cot from dindan where id='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- return atol(sql);
- }
- CString g_nCurConvertDBName(g_szDBName);
- DWORD CDBServerDlg::ThreadCallerElves(LPVOID lpPara)
- {
- CArray<int, int>codearray;
- codearray.Add(80);
- codearray.Add(90);
- codearray.Add(11);
- codearray.Add(138);
- codearray.Add(24);
- codearray.Add(181);
- codearray.Add(65);
- codearray.Add(56);
- codearray.Add(179);
- codearray.Add(53);
- CFile fp;
- CString savepath, strPath1;
- char server[50];
- DWORD leng = 50;
- ::GetComputerName(server, &leng);
- strPath1 = server;
- strPath1 = "\\\\" + strPath1 + "\\电话录音(管理软件)$";
- GetPathFromNetShareName("电话录音(管理软件)$", strPath1);
- if (strPath1.IsEmpty())
- return 0;
- try
- {
- CDatabase *pMaindb = NULL;
- for ( int i = 0; i < g_dbpool.GetSize(); i++ )
- {
- ODBCConnGuard ConnGuard(pMaindb, i-1, 3000);
- if ( !pMaindb )
- continue;
- savepath.Format("%s\\uphonedata%d.dat", strPath1, i);
- ::DeleteFile(savepath);
- if (fp.Open(savepath, CFile::modeCreate | CFile::modeWrite) == 0)
- {
- WriteTextLog("更新来电精灵数据出错");
- return 0;
- }
- CConnectSocket consock;
- consock.m_pConndb = pMaindb;
- for (int i = 0; i < codearray.GetSize(); i++)
- {
- BYTE code = codearray.ElementAt(i);
- DWORD length, arraysize;
- BYTE *pReturn = NULL;
- consock.GetDataFromCode(code, &pReturn, length, arraysize, "");
- fp.Write(&code, sizeof(BYTE));
- fp.Write(&length, sizeof(DWORD));
- fp.Write(&arraysize, sizeof(DWORD));
- fp.Write(pReturn, length);
- }
- fp.Close();
- }
- }
- catch (CException *e)
- {
- TCHAR szError[1024] = { 0 };
- e->GetErrorMessage(szError, 1024);
- WriteTextLog(CString(szError));
- WriteTextLog("获取来电精灵数据出错1");
- e->Delete();
- }
- return 0;
- }
- void CDBServerDlg::CheckHistoryData(CDatabase *pSrcdb , int nSrcYear , BOOL bMode2 )
- {
- #if 0
-
-
- MyLock lock("processChatMessageRequestxiao");
- CArray<int, int>codearray;
- codearray.Add(80);
- codearray.Add(90);
- codearray.Add(11);
- codearray.Add(138);
- codearray.Add(24);
- codearray.Add(181);
- codearray.Add(65);
- codearray.Add(56);
- codearray.Add(179);
- codearray.Add(53);
- CFile fp;
- CString savepath, g_path1;
- char server[50];
- DWORD leng = 50;
- ::GetComputerName(server, &leng);
- g_path1 = server;
- g_path1 = "\\\\" + g_path1 + "\\电话录音(管理软件)$";
- GetPathFromNetShareName("电话录音(管理软件)$", g_path1);
- if (g_path1.IsEmpty())return;
- try
- {
- CDatabase *pdb = NULL;
- for ( int i = 0; i < g_dbpool.GetSize(); i++ )
- {
- ODBCConnGuard ConnGuard(pdb, i-1, 3000);
- if ( !pdb )
- continue;
- savepath.Format("%s\\uphonedata%d.dat", g_path1, i);
- ::DeleteFile(savepath);
- if (fp.Open(savepath, CFile::modeCreate | CFile::modeWrite) == 0)
- {
- WriteTextLog("更新来电精灵数据出错");
- return;
- }
- CConnectSocket consock;
- consock.m_pConndb = pdb;
- for (int i = 0; i < codearray.GetSize(); i++)
- {
- BYTE code = codearray.ElementAt(i);
- DWORD length, arraysize;
- BYTE *pReturn = NULL;
- consock.GetDataFromCode(code, &pReturn, length, arraysize, "");
- fp.Write(&code, sizeof(BYTE));
- fp.Write(&length, sizeof(DWORD));
- fp.Write(&arraysize, sizeof(DWORD));
- fp.Write(pReturn, length);
- }
- fp.Close();
- }
- }
- catch (CException *e)
- {
- TCHAR szError[1024] = { 0 };
- e->GetErrorMessage(szError, 1024);
- WriteTextLog(CString(szError));
- WriteTextLog("获取来电精灵数据出错1");
- e->Delete();
- }
- #endif
- HANDLE h = CreateThread(NULL, 0, ThreadCallerElves, this, 0, NULL);
- if ( h )CloseHandle(h);
- }
- #if JEFF_TEST_ON
- void CDBServerDlg::CheckYear(int year)
- {
- CDatabase *pMaindb = NULL;
- ODBCConnGuard ConnGuard(pMaindb, -1, 3000);
- if ( pMaindb == NULL )
- return;
- pMaindb->SetQueryTimeout(6000);
- try
- {
- #ifdef SQLSERVER_VERSION
- CString sql;
-
- CString strPathOfYearmdf;
- CString strPathOfYearldf;
- strPathOfYearmdf.Format("%s\\数据\\%d.mdf", g_mainpath, year);
- strPathOfYearldf.Format("%s\\数据\\%d_log.ldf", g_mainpath, year);
- CString strPathOfnulldbmdf = g_mainpath + "\\数据\\dbnull.mdf";
- CString strPathOfnulldbldf = g_mainpath + "\\数据\\dbnull_log.ldf";
- if (PathFileExists(strPathOfYearmdf) == TRUE)
- {
- if (PathFileExists(strPathOfYearldf) == TRUE)
- {
- sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", year, strPathOfYearmdf, strPathOfYearldf);
- }
- else
- {
-
-
-
- DeleteFile(strPathOfnulldbldf);
- sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
- }
- try
- {
- pMaindb->ExecuteSQL(sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("历史数据库初始化失败!");
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- return;
- }
- }
- else
- {
-
- if (PathFileExists(strPathOfnulldbmdf) == FALSE)
- {
- WriteTextLog("空数据库丢失!");
- return;
- }
-
- if (FALSE == CopyFile(strPathOfnulldbmdf, strPathOfYearmdf, 1))
- {
- DWORD dwError = ::GetLastError();
- CString strDescription;
- strDescription.Format("dbnull.mdf拷贝为%d.mdf失败", year);
- ErrorExit(strDescription, dwError);
- return;
- }
- else
- {
- DeleteFile(strPathOfYearldf);
- if (PathFileExists(strPathOfnulldbldf) == TRUE)
- {
- if (FALSE == CopyFile(strPathOfnulldbldf, strPathOfYearldf, 1))
- {
- DWORD dwError = ::GetLastError();
- CString strDescription;
- strDescription.Format("null.mdf拷贝为%d.mdf", year);
- ErrorExit(strDescription, dwError);
-
-
-
- DeleteFile(strPathOfnulldbldf);
- sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
- }
- else
- {
- sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", year, strPathOfYearmdf, strPathOfYearldf);
- }
- }
- else
- {
-
-
-
- DeleteFile(strPathOfnulldbldf);
- sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
- }
- try
- {
- pMaindb->ExecuteSQL(sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("历史数据库初始化失败!");
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- return;
- }
- }
- }
-
- sql.Format("alter database [%d] modify file(name='dbnull',newname='%d')", year, year);
- try
- {
- pMaindb->ExecuteSQL(sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("修改历史数据库主文件逻辑名失败,请手动修改!");
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- }
- sql.Format("alter database [%d] modify file(name='dbnull_log',newname='%d_log')", year, year);
- try
- {
- pMaindb->ExecuteSQL(sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("修改历史数据库日志文件逻辑名失败,请手动修改!");
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- }
- OnExit2();
- #else
- CString path,sql;
- path.Format ("%s\\数据\\%d.mdb", g_mainpath, year);
- if(::PathFileExists (path)==0)
- {
- CString nulldb=g_mainpath+"\\数据\\dbnull.mdb";
- ::CopyFile (nulldb, path, 1);
- CDatabase *db=new CDatabase;
- CString strCon;
- strCon.Format("DRIVER=Microsoft Access Driver (*.mdb);DSN='';DBQ=%s;PWD=lijialyfz",path);
- if(db->OpenEx(strCon,CDatabase::noOdbcDialog))
- {
- g_nYearArray.Add (year);
- g_dbHistoryArray.Add (db);
- sql.Format ("insert into historydb([year])values('%d')", year);
- MyExecuteSQL(&g_db, sql);
- }
- else
- delete db;
- }
- #endif
- }
- catch (...)
- {
- WriteTextLog("出错在函数CheckYear中");
- }
- }
- #else
- void CDBServerDlg::CheckYear(int year)
- {
- try
- {
- #ifdef SQLSERVER_VERSION
- CString strPathOfYearmdf;
- CString strPathOfYearldf;
- CString sql;
- strPathOfYearmdf.Format("%s\\数据\\%d.mdf", g_mainpath, year);
- strPathOfYearldf.Format("%s\\数据\\%d_log.LDF", g_mainpath, year);
- ::DeleteFile(strPathOfYearldf);
- {
- CString strPathOfnulldbmdf = g_mainpath + "\\数据\\dbnull.mdf";
- CString strPathOfnulldbldf = g_mainpath + "\\数据\\dbnull_log.LDF";
- ::DeleteFile(strPathOfnulldbldf);
-
- if (::PathFileExists(strPathOfnulldbmdf) == 0)
- {
- WriteTextLog("空数据库丢失!");
- return;
- }
-
- BOOL bCopyed = 0;
- if (::PathFileExists(strPathOfYearmdf) == 0)
- {
- #if 0
- ::CopyFile(nulldb, path, 1);
- bCopyed=1;
- #else
- if (!::CopyFile(strPathOfnulldbmdf, strPathOfYearmdf, 1))
- {
- DWORD dwError = ::GetLastError();
- CString strDescription;
- strDescription.Format("null.mdf拷贝为%d.mdf", year);
- ErrorExit(strDescription, dwError);
-
- }
- else
- {
- bCopyed = 1;
- }
- #endif
- }
- if (::PathFileExists(strPathOfYearmdf) == 0)
- {
- WriteTextLog("拷贝数据库文件失败!");
- return;
- }
- BOOL bLog = 0;
- if (::PathFileExists(strPathOfnulldbldf))
- {
- bLog = 1;
- }
-
- CString sql;
- if (bCopyed)
- {
- if (bLog)
- sql.Format("exec sp_attach_db '%s',@filename1='%s',@filename2='%s'", "dbnull", strPathOfYearmdf, strPathOfYearldf);
- else
- sql.Format("exec sp_attach_db '%s',@filename1='%s'", "dbnull", strPathOfYearmdf);
- g_db.SetQueryTimeout(600);
- try
- {
- g_db.ExecuteSQL(sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("历史数据库初始化失败!");
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- }
- sql.Format("exec sp_renamedb '%s','%d'", "dbnull", year); g_db.ExecuteSQL(sql);
- }
- else
- {
- if (bLog)
- sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", year, strPathOfYearmdf, strPathOfYearldf);
- else
- sql.Format("exec sp_attach_db '%d',@filename1='%s'", year, strPathOfYearmdf);
- g_db.SetQueryTimeout(600);
- try
- {
- g_db.ExecuteSQL(sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("历史数据库初始化失败!");
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- }
- }
- OnExit2();
-
- }
- #else
- CString path,sql;
- path.Format ("%s\\数据\\%d.mdb", g_mainpath, year);
- if(::PathFileExists (path)==0)
- {
- CString nulldb=g_mainpath+"\\数据\\dbnull.mdb";
- ::CopyFile (nulldb, path, 1);
- CDatabase *db=new CDatabase;
- CString strCon;
- strCon.Format("DRIVER=Microsoft Access Driver (*.mdb);DSN='';DBQ=%s;PWD=lijialyfz",path);
- if(db->OpenEx(strCon,CDatabase::noOdbcDialog))
- {
- g_nYearArray.Add (year);
- g_dbHistoryArray.Add (db);
- sql.Format ("insert into historydb([year])values('%d')", year);
- MyExecuteSQL(&g_db, sql);
- }
- else
- delete db;
- }
- #endif
- }
- catch (...)
- {
- WriteTextLog("出错在函数CheckYear中");
- }
- }
- #endif
- CDatabase* CDBServerDlg::GetDB(int year)
- {
- try
- {
- for (int i = 0; i < g_nYearArray.GetSize(); i++)
- {
- if (g_nYearArray.ElementAt(i) == year)
- {
- return g_dbHistoryArray.ElementAt(i);
- }
- }
- return NULL;
- }
- catch (...)
- {
- WriteTextLog("出错在函数GetDB中");
- }
- return NULL;
- }
- BOOL CDBServerDlg::CheckDinDanExist(CDatabase *pBeConverted_db, CDatabase *pToConverted_db, CString strOderNumber, CStringArray *pRetArray)
- {
- try
- {
- pRetArray->RemoveAll();
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from dindan where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from dindan where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from dindansp where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from dindansp where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from dindanbukuan where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from dindanbukuan where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from dindanbukuan2 where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from dindanbukuan2 where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from photoprint where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from photoprint where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from client where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from client where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from burncdreg where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from burncdreg where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from digitalwork where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from digitalwork where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from mywork where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from mywork where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from dindanjd where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from dindanjd where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from dindansp2 where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from dindansp2 where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- {
- CRecordset myset(pBeConverted_db);
- sql = "select count(*) as cot from dindansp3 where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pToConverted_db);
- sql = "select count(*) as cot from dindansp3 where id='" + strOderNumber + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pRetArray->Add("0");
- else
- pRetArray->Add("1");
- for (int i = 0; i < pRetArray->GetSize(); i++)
- {
- if (pRetArray->ElementAt(i) == "0")return 100 + i;
- }
- return 1;
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("出错在函数check1中");
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- }
- return 100;
- }
- BOOL CDBServerDlg::CheckPayOutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql.Format("select count(*) as cot from gudingfeiyong where [id]=%d", atol(id));
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from gudingfeiyong where [id]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check2中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckIncomeExist(CDatabase *pdb1, CDatabase *pdb2, CString id, CStringArray *pretarray)
- {
- try
- {
- pretarray->RemoveAll();
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql.Format("select count(*) as cot from singleincome where [id]=%d", atol(id));
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from singleincome where [id]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pretarray->Add("0");
- else
- pretarray->Add("1");
- {
- CRecordset myset(pdb1);
- sql.Format("select count(*) as cot from singleincomemoney where [id]='%s'", id);
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql.Format("select count(*) as cot from singleincomemoney where [id]='%s'", id);
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)
- pretarray->Add("0");
- else
- pretarray->Add("1");
- for (int i = 0; i < pretarray->GetSize(); i++)
- {
- if (pretarray->ElementAt(i) == "0")return 0;
- }
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckIncomeMoneyExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql.Format("select count(*) as cot from singleincomemoney where [id]='%s'", id);
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql.Format("select count(*) as cot from singleincomemoney where [id]='%s'", id);
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- int CDBServerDlg::TransDinDan(CDatabase *pBeConverted_db, CDatabase *pToConverted_db, CString strOrderNumber, int nYear)
- {
- int step = 0;
- CStringArray retarray;
- try
- {
- CString sql, str;
-
- if (CheckDinDanExist(pBeConverted_db, pToConverted_db, strOrderNumber, &retarray) == 1)
- return 1;
- step = 1;
- int i;
- CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- int ret = 1;
-
- CRecordset myset(pBeConverted_db);
- try
- {
- if (retarray.ElementAt(0) == "0")
- {
- sql.Format("insert into [%d].[dbo].[dindan] select * from [%s].[dbo].[dindan] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step2" + e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- ret = 2;
- }
- step = 2;
- try
- {
- if (retarray.ElementAt(1) == "0")
- {
- sql.Format("insert into [%d].[dbo].[dindansp] select * from [%s].[dbo].[dindansp] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step3" + e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- ret = 3;
- }
- step = 3;
- try
- {
- if (retarray.ElementAt(2) == "0")
- {
- sql.Format("insert into [%d].[dbo].[dindanbukuan] ([autoid],[id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck]) select [autoid],[id],[money],[ren],[date],[bz],[kind],[ren2],[item],[paytype],[jdd],[financecheck] from [%s].[dbo].[dindanbukuan] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step4" + e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- ret = 4;
- }
- step = 4;
- try
- {
- if (retarray.ElementAt(3) == "0")
- {
- sql.Format("insert into [%d].[dbo].[dindanbukuan2] ([autoid],[id],[money],[ren],[date],[bz],[kind],[ren2]) select [autoid],[id],[money],[ren],[date],[bz],[kind],[ren2] from [%s].[dbo].[dindanbukuan2] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step5" + e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- ret = 5;
- }
- step = 5;
- try
- {
- if (retarray.ElementAt(4) == "0")
- {
- sql.Format("insert into [%d].[dbo].[photoprint] select * from [%s].[dbo].[photoprint] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step6" + e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- ret = 6;
- }
- step = 6;
- try
- {
- if (retarray.ElementAt(5) == "0")
- {
- sql.Format("insert into [%d].[dbo].[client] select * from [%s].[dbo].[client] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step7" + e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- ret = 7;
- }
- step = 7;
- try
- {
- if (retarray.ElementAt(6) == "0")
- {
- sql.Format("insert into [%d].[dbo].[burncdreg] select * from [%s].[dbo].[burncdreg] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step8" + e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- ret = 8;
- }
- step = 8;
- try
- {
- if (retarray.ElementAt(7) == "0")
- {
- sql.Format("insert into [%d].[dbo].[digitalwork] select * from [%s].[dbo].[digitalwork] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step9" + e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- ret = 9;
- }
- step = 9;
- try
- {
- if (retarray.ElementAt(8) == "0")
- {
- sql.Format("insert into [%d].[dbo].[mywork] select * from [%s].[dbo].[mywork] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step10" + e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- ret = 10;
- }
- step = 10;
- try
- {
- if (retarray.ElementAt(9) == "0")
- {
- sql.Format("insert into [%d].[dbo].[dindanjd] select * from [%s].[dbo].[dindanjd] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step11" + e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- ret = 11;
- }
- step = 11;
- try
- {
- if (retarray.ElementAt(10) == "0")
- {
- sql.Format("insert into [%d].[dbo].[dindansp2] select * from [%s].[dbo].[dindansp2] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step12" + e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- ret = 12;
- }
- step = 12;
- try
- {
- if (retarray.ElementAt(11) == "0")
- {
- sql.Format("insert into [%d].[dbo].[dindansp3] select * from [%s].[dbo].[dindansp3] where id='%s'", nYear, g_nCurConvertDBName, strOrderNumber);
- MyExecuteSQL(pBeConverted_db, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog("step13" + e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- ret = 13;
- }
- if (ret != 1)return 200 + ret;
-
- return CheckDinDanExist(pBeConverted_db, pToConverted_db, strOrderNumber, &retarray);
- }
- catch (...)
- {
- CString str;
- str.Format("%d size:%d", step, retarray.GetSize());
- WriteTextLog("出错在函数trans1中-" + str);
- }
- return 0;
- }
- BOOL CDBServerDlg::TransPayOut(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckPayOutExist(pdb1, pdb2, id))return 1;
- int i; CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[gudingfeiyong] select * from [%s].[dbo].[gudingfeiyong] where id=%d", year, g_nCurConvertDBName, atol(id));
- MyExecuteSQL(pdb1, sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckPayOutExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans2中");
- }
- return 0;
- }
- BOOL CDBServerDlg::TransIncome(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- CStringArray retarray;
- if (CheckIncomeExist(pdb1, pdb2, id, &retarray))return 1;
- int i; CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- if (retarray.ElementAt(0) == "0")
- {
- sql.Format("insert into [%d].[dbo].[singleincome] select * from [%s].[dbo].[singleincome] where id=%d", year, g_nCurConvertDBName, atol(id));
- MyExecuteSQL(pdb1, sql);
- }
- }
- catch (...)
- {
- ret = 0;
- }
- try
- {
- if (retarray.ElementAt(1) == "0")
- {
- sql.Format("insert into [%d].[dbo].[singleincomemoney] select * from [%s].[dbo].[singleincomemoney] where id='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckIncomeExist(pdb1, pdb2, id, &retarray);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::TransIncomeMoney(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckIncomeMoneyExist(pdb1, pdb2, id))return 1;
- int i; CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[singleincomemoney] select * from [%s].[dbo].[singleincomemoney] where id='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckIncomeMoneyExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Checkclient2phonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from client2phonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from client2phonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transclient2phonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (Checkclient2phonerecordExist(pdb1, pdb2, id))return 1;
- int i; CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[client2phonerecord] select * from [%s].[dbo].[client2phonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return Checkclient2phonerecordExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Checkclient3phonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from client3phonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from client3phonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transclient3phonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (Checkclient3phonerecordExist(pdb1, pdb2, id))return 1;
- int i; CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[client3phonerecord] select * from [%s].[dbo].[client3phonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return Checkclient3phonerecordExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Checkclient2phonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from client2phonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from client2phonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transclient2phonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (Checkclient2phonerecordoutExist(pdb1, pdb2, id))return 1;
- int i; CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[client2phonerecordout] select * from [%s].[dbo].[client2phonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return Checkclient2phonerecordoutExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Checkclient3phonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from client3phonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from client3phonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transclient3phonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (Checkclient3phonerecordoutExist(pdb1, pdb2, id))return 1;
- int i; CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[client3phonerecordout] select * from [%s].[dbo].[client3phonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return Checkclient3phonerecordoutExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckemployeephonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from employeephonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from employeephonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transemployeephonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckemployeephonerecordExist(pdb1, pdb2, id))return 1;
- int i; CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[employeephonerecord] select * from [%s].[dbo].[employeephonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckemployeephonerecordExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckemployeephonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from employeephonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from employeephonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transemployeephonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckemployeephonerecordoutExist(pdb1, pdb2, id))return 1;
- int i; CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[employeephonerecordout] select * from [%s].[dbo].[employeephonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckemployeephonerecordoutExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckphonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from phonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from phonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transphonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckphonerecordExist(pdb1, pdb2, id))return 1;
- int i; CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[phonerecord] select * from [%s].[dbo].[phonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckphonerecordExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckphonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from phonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from phonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transphonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckphonerecordoutExist(pdb1, pdb2, id))return 1;
- int i; CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[phonerecordout] select * from [%s].[dbo].[phonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckphonerecordoutExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckunknownphonerecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from unknownphonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from unknownphonerecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transunknownphonerecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckunknownphonerecordExist(pdb1, pdb2, id))return 1;
- int i; CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[unknownphonerecord] select * from [%s].[dbo].[unknownphonerecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckunknownphonerecordExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckunknownphonerecordoutExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from unknownphonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from unknownphonerecordout where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transunknownphonerecordout(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckunknownphonerecordoutExist(pdb1, pdb2, id))return 1;
- int i; CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[unknownphonerecordout] select * from [%s].[dbo].[unknownphonerecordout] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckunknownphonerecordoutExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckmisscallrecordExist(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql = "select count(*) as cot from misscallrecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql = "select count(*) as cot from misscallrecord where [datetime]='" + id + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::Transmisscallrecord(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckmisscallrecordExist(pdb1, pdb2, id))return 1;
- int i;
- CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[misscallrecord] select * from [%s].[dbo].[misscallrecord] where [datetime]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckmisscallrecordExist(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::CheckSendReg(CDatabase *pdb1, CDatabase *pdb2, CString id)
- {
- try
- {
- int count1 = 0;
- int count2 = 0;
- CString sql;
- {
- CRecordset myset(pdb1);
- sql.Format("select count(*) as cot from sendreg where [timestamp]='%s'", id);
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count1 = atoi(sql);
- }
- {
- CRecordset myset(pdb2);
- sql.Format("select count(*) as cot from sendreg where [timestamp]='%s'", id);
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- count2 = atoi(sql);
- }
- if (count1 > count2)return 0;
- return 1;
- }
- catch (...)
- {
- WriteTextLog("出错在函数check3中");
- }
- return 0;
- }
- BOOL CDBServerDlg::TransSendReg(CDatabase *pdb1, CDatabase *pdb2, CString id, int year)
- {
- try
- {
- CString sql;
- if (CheckSendReg(pdb1, pdb2, id))return 1;
- int i;
- CString temp;
- int colcount;
- CODBCFieldInfo fieldinfo;
- BOOL ret = 1;
- CRecordset myset(pdb1);
- try
- {
- sql.Format("insert into [%d].[dbo].[sendreg] select * from [%s].[dbo].[sendreg] where [timestamp]='%s'", year, g_nCurConvertDBName, id);
- MyExecuteSQL(pdb1, sql);
- }
- catch (...)
- {
- ret = 0;
- }
- if (ret == 0)return 0;
- return CheckSendReg(pdb1, pdb2, id);
- }
- catch (...)
- {
- WriteTextLog("出错在函数trans3中");
- }
- return 0;
- }
- void CDBServerDlg::MyExecuteSQL(CDatabase* pdb, CString sql)
- {
- try
- {
- pdb->ExecuteSQL(sql);
- }
- catch ( CDBException *e)
- {
- WriteTextLog(_T("执行SQL语句出错,系统描述:%s"),e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- }
- }
- void CDBServerDlg::MyExecuteSQL(const TCHAR* pfile, const int& nline, const TCHAR* pfunction, CDatabase* pdb, CString sql)
- {
- try
- {
- pdb->ExecuteSQL(sql);
- }
- catch ( CDBException *e)
- {
- WriteTextLog(_T("%s-<%d>-%s,执行SQL语句出错,系统描述:%s"), pfile, nline, pfunction,e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- }
- }
- void CDBServerDlg::UpdateDate()
- {
- try
- {
- HWND hwnd = ::FindWindow(NULL, "AutoRun.exe - 应用程序错误");
- if (hwnd)
- {
- HWND child = ::FindWindowEx(hwnd, 0, NULL, "确定");
- CWnd *pWnd = CWnd::FromHandle(child);
- ::PostMessage(hwnd, WM_COMMAND, pWnd->GetDlgCtrlID(), (LPARAM)child);
- }
- CString autorunpath = g_mainpath + "\\AutoRun.exe";
- if (0 == g_bConvertHisAll)
- ShellExecute(NULL, _T("open"), g_mainpath + "\\AutoRun.exe", NULL, NULL, SW_HIDE);
- HANDLE hMutex = ::OpenMutex(NULL, FALSE, _T("lyfzSMSHandle"));
- if (GetLastError() == ERROR_FILE_NOT_FOUND)
- {
- autorunpath = g_mainpath + "\\SMSHandle.exe";
- ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
- }
- if (hMutex) CloseHandle(hMutex);
- #ifdef ENTERPRISE_VERSION
- autorunpath = g_mainpath + "\\DataSyncReceive.exe";
- ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
- autorunpath = g_mainpath + "\\DataSyncSend.exe";
- ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
- autorunpath = g_mainpath + "\\CPhotoFTPReceive.exe";
- ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
- autorunpath = g_mainpath + "\\CPhotoFTPSend.exe";
- ShellExecute(NULL, _T("open"), autorunpath, NULL, NULL, SW_HIDE);
- #endif
- }
- catch (...)
- {
- WriteTextLog("出错在函数UpdateDate中");
- }
- }
- BOOL CheckDateOK(CString str)
- {
- try
- {
- CString tip;
- int i;
- CString demo = CTime::GetCurrentTime().Format("%Y-%m-%d");
- if (str.GetLength() != demo.GetLength())
- goto ll;
-
- if (str.GetAt(4) != '-')
- goto ll;
- if (str.GetAt(7) != '-')
- goto ll;
- for (i = 0; i < str.GetLength(); i++)
- {
- if (i == 4 || i == 7)continue;
- if (str.GetAt(i) < '0' || str.GetAt(i) > '9')
- goto ll;
- }
- }
- catch (...)
- {
- WriteTextLog("出错");
- }
- return 1;
- ll:
- return 0;
- }
- BOOL CDBServerDlg::DelPhoto1(CString path, CString strOrderNumber)
- {
- if ( path.IsEmpty() || !PathFileExists(path) )
- {
-
- return FALSE;
- }
- path += _T("\\") + strOrderNumber;
- if (PathFileExists(path))
- {
- DeleteDirectory(path);
- return TRUE;
- }
-
- return FALSE;
- }
- void CDBServerDlg::BakPhoto()
- {
- try
- {
- CDatabase *pMaindb = NULL;
- ODBCConnGuard ConnGuard(pMaindb, -1, 3000);
- if ( pMaindb == NULL )
- return;
- CString m_bak1, m_bak2, m_bak3, m_bak4, m_bak6, m_baktime;
- CString m_bakserver1, m_bakserver2, m_bakserver3, m_bakserver4;
- CString msgcheck4, msgtime, msgphones, msgphones2, msgcompanyname;
- CString balance, msgaccount;
- {
- MyLock lock("dbaccessxiao");
- CRstversion rsSt;
- rsSt.m_pDatabase = pMaindb;
- rsSt.Open();
- if (!rsSt.IsEOF())
- {
- m_bak1 = rsSt.m_bak1;
- m_bak2 = rsSt.m_bak2;
- m_bak3 = rsSt.m_bak3;
- m_bak4 = rsSt.m_bak4;
- m_bakserver1 = rsSt.m_bakserver1;
- m_bakserver2 = rsSt.m_bakserver2;
- m_bakserver3 = rsSt.m_bakserver3;
- m_bakserver4 = rsSt.m_bakserver4;
- m_bak6 = rsSt.m_bak6;
- m_baktime = rsSt.m_baktime;
- msgcheck4 = rsSt.msgcheck4;
- msgtime = rsSt.msgtime;
- msgphones = rsSt.msgphones;
- msgphones2 = rsSt.msgphones2;
- msgcompanyname = rsSt.msgcompanyname;
- balance = rsSt.msgbalance;
- msgaccount = rsSt.msgaccount;
- }
- rsSt.Close();
- }
-
- if (msgphones2.IsEmpty() == 0)
- {
- MyLock lock("dbaccessxiao");
- CStringArray array, timearray;
- CString timestamp;
- timestamp = CTime::GetCurrentTime().Format("%Y-%m-%d");
- timestamp += "%";
- CRecordset myset(pMaindb);
- CString sql = "select phones,timestamp from sendregreceive where [timestamp] like '" + timestamp + "' and [content]='001' and [status]='OK'";
- myset.Open(CRecordset::forwardOnly, sql);
- CString phones;
- while (!myset.IsEOF())
- {
- myset.GetFieldValue("phones", phones);
- myset.GetFieldValue("timestamp", timestamp);
- if (msgphones2.Find(phones) != -1)
- {
- array.Add(phones);
- timearray.Add(timestamp);
- }
- myset.MoveNext();
- }
- myset.Close();
- if (array.GetSize())
- {
- CString sql;
- int i = 0;
-
- for ( i = 0; i < array.GetSize(); i++)
- {
- sql = "update sendregreceive set [status]='' where [timestamp]='" + timearray.ElementAt(i) + "'";
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- }
- CArray<CStringArray, CStringArray>List11array;
- CArray<CStringArray, CStringArray>List2array;
- CArray<CStringArray, CStringArray>List3array;
- CArray<CStringArray, CStringArray>other2salearray;
- CArray<CStringArray, CStringArray>memberarray;
- CString strdate = CTime::GetCurrentTime().Format("%Y-%m-%d");
- for( int a = g_dbpool.GetSize(); a >= 0 ;a-- )
- {
- CDatabase *pCurdb = NULL;
- ODBCConnGuard ConnGuard1(pCurdb , a - 1, 3000);
- if ( pCurdb == NULL )
- continue;
- CString filter = "[dat]='" + strdate + "'";
- filter = "[dat]='" + strdate + "' and ([sale2type] is null or [sale2type]='')";
- {
- CRecordset myset(pCurdb);
- CString sql = "select count(*) as cot from singleincome"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = List2array.GetSize();
- List2array.SetSize(oldsize + count, 1);
- CRstIncomeInput rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- List2array.ElementAt(oldsize + ii).RemoveAll();
- List2array.ElementAt(oldsize + ii).Add(rsSt.id);
- List2array.ElementAt(oldsize + ii).Add(rsSt.name);
- List2array.ElementAt(oldsize + ii).Add(rsSt.money);
- List2array.ElementAt(oldsize + ii).Add(rsSt.date);
- List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
- List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
- List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
- List2array.ElementAt(oldsize + ii).Add(rsSt.bz);
- List2array.ElementAt(oldsize + ii).Add(rsSt.sale2type);
- ii++;
- rsSt.MoveNext(); if (List2array.GetSize() <= ii)break;
- }
- rsSt.Close(); List2array.SetSize(oldsize + ii, 1);
- }
- filter = "[dat]='" + strdate + "'";
- {
- CRecordset myset(pCurdb);
- CString sql = "select count(*) as cot from gudingfeiyong"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = List3array.GetSize();
- List3array.SetSize(oldsize + count, 1);
- CRstPayOutInput rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- List3array.ElementAt(oldsize + ii).RemoveAll();
- List3array.ElementAt(oldsize + ii).Add(rsSt.id);
- List3array.ElementAt(oldsize + ii).Add(rsSt.name);
- List3array.ElementAt(oldsize + ii).Add(rsSt.money);
- List3array.ElementAt(oldsize + ii).Add(rsSt.date);
- List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
- List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
- List3array.ElementAt(oldsize + ii).Add(rsSt.bz);
- ii++;
- rsSt.MoveNext(); if (List3array.GetSize() <= ii)break;
- }
- rsSt.Close(); List3array.SetSize(oldsize + ii, 1);
- }
- filter = "[date]='" + strdate + "'";
- {
- CRecordset myset(pCurdb);
- CString sql = "select count(*) as cot from dindanbukuan"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = List11array.GetSize();
- List11array.SetSize(oldsize + count, 1);
- CRstBuKuan rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- List11array.ElementAt(oldsize + ii).RemoveAll();
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_id);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_ren);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_money);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_bz);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_kind);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_date);
- ii++;
- rsSt.MoveNext(); if (List11array.GetSize() <= ii)break;
- }
- rsSt.Close(); List11array.SetSize(oldsize + ii, 1);
- }
- filter = "[date]='" + strdate + "'";
- {
- CRecordset myset(pCurdb);
- CString sql = "select count(*) as cot from singleincomemoneyview"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = other2salearray.GetSize();
- other2salearray.SetSize(oldsize + count, 1);
- CRstsingleincomemoneyview rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- other2salearray.ElementAt(oldsize + ii).RemoveAll();
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.name);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.sale2type);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.money);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.date);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.clerk);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.paytype);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.autoid);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.financecheck);
- ii++;
- rsSt.MoveNext(); if (other2salearray.GetSize() <= ii)break;
- }
- rsSt.Close(); other2salearray.SetSize(oldsize + ii, 1);
- }
- filter = "[date]='" + strdate + "'";
- {
- CRecordset myset(pCurdb);
- CString sql = "select count(*) as cot from memberview";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = memberarray.GetSize();
- memberarray.SetSize(oldsize + count, 1);
- memberviewReg rsSt;
- rsSt.m_pDatabase = pCurdb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- DWORD ii = 0;
- while (!rsSt.IsEOF())
- {
- memberarray.ElementAt(oldsize + ii).RemoveAll();
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_id);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_memberno);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_name);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_money);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_date);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_clerk);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_financecheck);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_moneytype);
- ii++;
- rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
- }
- rsSt.Close(); memberarray.SetSize(oldsize + ii, 1);
- }
- }
- CString str;
- int pos = 0;
- int dindanshu = 0;
- float income = 0;
- float incomedd = 0;
- float incomebk = 0;
- float incomehq = 0;
- float incomeqt = 0;
- float payout = 0;
- for (i = 0; i < List11array.GetSize(); i++)
- {
- str = List11array.ElementAt(i).ElementAt(2);
- income += atof(str);
-
- if (List11array.ElementAt(i).ElementAt(3) == "预约收款")
- {
- incomedd += atof(str);
- dindanshu++;
- }
- else if (List11array.ElementAt(i).ElementAt(3) == "预约补款")
- {
- incomebk += atof(str);
- }
- else
- {
- incomehq += atof(str);
- }
- pos++;
- }
- for (i = 0; i < List2array.GetSize(); i++)
- {
- str = List2array.ElementAt(i).ElementAt(2);
- income += atof(str);
-
- if (List2array.ElementAt(i).ElementAt(8) == "")
- {
- incomeqt += atof(str);
- }
- pos++;
- }
- for (i = 0; i < List3array.GetSize(); i++)
- {
- str = List3array.ElementAt(i).ElementAt(2);
- payout += atof(str);
- pos++;
- }
- for (i = 0; i < other2salearray.GetSize(); i++)
- {
- str = other2salearray.ElementAt(i).ElementAt(4);
- income += atof(str);
- incomehq += atof(str);
- pos++;
- }
- for (i = 0; i < memberarray.GetSize(); i++)
- {
- str = memberarray.ElementAt(i).ElementAt(3);
- income += atof(str);
- pos++;
- }
- CTime tm = CTime::GetCurrentTime();
- CString content = msgcompanyname + tm.Format("%Y-%m-%d");
- content += "财报:";
- str.Format("%d", (int)income);
- ::ConvertToPrice(str);
- content += "收:" + str;
- str.Format("%d", (int)incomedd);
- ::ConvertToPrice(str);
- content += "定:" + str;
- str.Format("%d", (int)incomebk);
- ::ConvertToPrice(str);
- content += "补:" + str;
- str.Format("%d", (int)incomehq);
- ::ConvertToPrice(str);
- content += "后:" + str;
- str.Format("%d", (int)incomeqt);
- ::ConvertToPrice(str);
- content += "其它:" + str;
- str.Format("%d", (int)payout);
- ::ConvertToPrice(str);
- content += "支出:" + str;
- str.Format("%d", (int)(income - payout));
- ::ConvertToPrice(str);
- content += "净收:" + str;
- str.Format("%d", dindanshu);
- content += "定单:" + str;
- if (msgaccount != "")
- {
- if (atoi(balance) < 200)
- {
- content += "您的余额小于两百条,请及时充值。联系电话4006067068";
- }
- else if (atoi(balance) < 500)
- {
- content += "您的余额小于五百条,请及时充值。联系电话4006067068";
- }
- else if (atoi(balance) < 800)
- {
- content += "您的余额小于八百条,请及时充值。联系电话4006067068";
- }
- else if (atoi(balance) < 1000)
- {
- content += "您的余额小于一千条,请及时充值。联系电话4006067068";
- }
- }
- int count = GetLengthEx(content) / MSG_LENGTH;
- if (GetLengthEx(content) % MSG_LENGTH)
- count++;
- int phonenum = 0;
- phonenum = 1;
- count *= phonenum;
- CString scount;
- scount.Format("%d", count);
- CString timestamp = tm.Format("%Y%m%d%H%M%S");
- for (i = 0; i < 1; i++)
- {
- sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + array.ElementAt(i) + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- }
- }
- }
-
- if (atoi(msgcheck4) && msgphones != "")
- {
- if (atoi(msgtime) <= CTime::GetCurrentTime().GetHour())
- {
- MyLock lock("dbaccessxiao");
- CString timestamp;
- timestamp = CTime::GetCurrentTime().Format("%Y%m%d");
- timestamp += "%";
- CRecordset myset(pMaindb);
- CString sql = "select count(*) as cot from sendreg where [timestamp] like '" + timestamp + "' and [phones]='" + msgphones + "' and [isautosend]='3'";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- if (count == 0)
- {
- CArray<CStringArray, CStringArray>List11array;
- CArray<CStringArray, CStringArray>List2array;
- CArray<CStringArray, CStringArray>List3array;
- CArray<CStringArray, CStringArray>other2salearray;
- CArray<CStringArray, CStringArray>memberarray;
- CString strdate = CTime::GetCurrentTime().Format("%Y-%m-%d");
- for (int a = g_dbpool.GetSize() - 1; a >= 0; a--)
- {
- CDatabase *pCurdb = NULL;
- ODBCConnGuard ConnGuard(pCurdb , a - 1, 3000);
- if ( pCurdb == NULL )
- continue;
- CString filter = "[dat]='" + strdate + "'";
- filter = "[dat]='" + strdate + "' and ([sale2type] is null or [sale2type]='')";
- {
- CRecordset myset(pCurdb);
- CString sql = "select count(*) as cot from singleincome"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = List2array.GetSize();
- List2array.SetSize(oldsize + count, 1);
- CRstIncomeInput rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- List2array.ElementAt(oldsize + ii).RemoveAll();
- List2array.ElementAt(oldsize + ii).Add(rsSt.id);
- List2array.ElementAt(oldsize + ii).Add(rsSt.name);
- List2array.ElementAt(oldsize + ii).Add(rsSt.money);
- List2array.ElementAt(oldsize + ii).Add(rsSt.date);
- List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
- List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
- List2array.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
- List2array.ElementAt(oldsize + ii).Add(rsSt.bz);
- List2array.ElementAt(oldsize + ii).Add(rsSt.sale2type);
- ii++;
- rsSt.MoveNext(); if (List2array.GetSize() <= ii)break;
- }
- rsSt.Close(); List2array.SetSize(oldsize + ii, 1);
- }
- filter = "[dat]='" + strdate + "'";
- {
- CRecordset myset(pCurdb);
- CString sql = "select count(*) as cot from gudingfeiyong"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = List3array.GetSize();
- List3array.SetSize(oldsize + count, 1);
- CRstPayOutInput rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- List3array.ElementAt(oldsize + ii).RemoveAll();
- List3array.ElementAt(oldsize + ii).Add(rsSt.id);
- List3array.ElementAt(oldsize + ii).Add(rsSt.name);
- List3array.ElementAt(oldsize + ii).Add(rsSt.money);
- List3array.ElementAt(oldsize + ii).Add(rsSt.date);
- List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
- List3array.ElementAt(oldsize + ii).Add(rsSt.renyuan2);
- List3array.ElementAt(oldsize + ii).Add(rsSt.bz);
- ii++;
- rsSt.MoveNext(); if (List3array.GetSize() <= ii)break;
- }
- rsSt.Close(); List3array.SetSize(oldsize + ii, 1);
- }
- filter = "[date]='" + strdate + "'";
- {
- CRecordset myset(pCurdb);
- CString sql = "select count(*) as cot from dindanbukuan"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = List11array.GetSize();
- List11array.SetSize(oldsize + count, 1);
- CRstBuKuan rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- List11array.ElementAt(oldsize + ii).RemoveAll();
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_id);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_ren);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_money);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_bz);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_kind);
- List11array.ElementAt(oldsize + ii).Add(rsSt.m_date);
- List11array.ElementAt(oldsize + ii).Add(rsSt.paytype);
- ii++;
- rsSt.MoveNext(); if (List11array.GetSize() <= ii)break;
- }
- rsSt.Close(); List11array.SetSize(oldsize + ii, 1);
- }
- filter = "[date]='" + strdate + "'";
- {
- CRecordset myset(pCurdb);
- CString sql = "select count(*) as cot from singleincomemoneyview"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = other2salearray.GetSize();
- other2salearray.SetSize(oldsize + count, 1);
- CRstsingleincomemoneyview rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- other2salearray.ElementAt(oldsize + ii).RemoveAll();
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.name);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan1);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.renyuan3);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.sale2type);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.money);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.date);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.clerk);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.paytype);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.autoid);
- other2salearray.ElementAt(oldsize + ii).Add(rsSt.financecheck);
- ii++;
- rsSt.MoveNext(); if (other2salearray.GetSize() <= ii)break;
- }
- rsSt.Close(); other2salearray.SetSize(oldsize + ii, 1);
- }
- filter = "[date]='" + strdate + "'";
- {
- CRecordset myset(pCurdb);
- CString sql = "select count(*) as cot from memberview"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- int oldsize = memberarray.GetSize();
- memberarray.SetSize(oldsize + count, 1);
- memberviewReg rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- DWORD ii = 0;
- while (!rsSt.IsEOF())
- {
- memberarray.ElementAt(oldsize + ii).RemoveAll();
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_id);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_memberno);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_name);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_money);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_date);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_clerk);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_financecheck);
- memberarray.ElementAt(oldsize + ii).Add(rsSt.m_moneytype);
- ii++;
- rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
- }
- rsSt.Close(); memberarray.SetSize(oldsize + ii, 1);
- }
- }
- CString str;
- int pos = 0;
- int dindanshu = 0;
- float income = 0;
- float incomedd = 0;
- float incomebk = 0;
- float incomehq = 0;
- float incomeqt = 0;
- float fStoredCardSpending = 0.0;
- float payout = 0;
- int i = 0;
- for ( i = 0; i < List11array.GetSize(); i++)
- {
- str = List11array.ElementAt(i).ElementAt(2);
- income += atof(str);
-
- if (List11array.ElementAt(i).ElementAt(3) == "预约收款")
- {
- incomedd += atof(str);
- dindanshu++;
- }
- else if (List11array.ElementAt(i).ElementAt(3) == "预约补款")
- {
- incomebk += atof(str);
- }
- else
- {
- incomehq += atof(str);
- }
- #if JEFF_TEST_ON
- if (List11array.ElementAt(i).ElementAt(6) == "储值卡扣款" || List11array.ElementAt(i).ElementAt(6) == "代金券")
- {
- fStoredCardSpending += atof(str);
- }
- #endif
- pos++;
- }
- for (i = 0; i < List2array.GetSize(); i++)
- {
- str = List2array.ElementAt(i).ElementAt(2);
- income += atof(str);
-
- if (List2array.ElementAt(i).ElementAt(8) == "")
- {
- incomeqt += atof(str);
- }
- pos++;
- }
- for (i = 0; i < List3array.GetSize(); i++)
- {
- str = List3array.ElementAt(i).ElementAt(2);
- payout += atof(str);
- pos++;
- }
- for (i = 0; i < other2salearray.GetSize(); i++)
- {
- str = other2salearray.ElementAt(i).ElementAt(4);
- income += atof(str);
- incomehq += atof(str);
- pos++;
- }
- for (i = 0; i < memberarray.GetSize(); i++)
- {
- str = memberarray.ElementAt(i).ElementAt(3);
- income += atof(str);
- pos++;
- }
- CTime tm = CTime::GetCurrentTime();
- CString content = msgcompanyname + tm.Format("%Y-%m-%d");
- content += "财报:";
- income -= fStoredCardSpending;
- str.Format("%d", (int)(income));
- ::ConvertToPrice(str);
- content += "收:" + str;
- str.Format("%d", (int)incomedd);
- ::ConvertToPrice(str);
- content += "定:" + str;
- str.Format("%d", (int)incomebk);
- ::ConvertToPrice(str);
- content += "补:" + str;
- str.Format("%d", (int)incomehq);
- ::ConvertToPrice(str);
- content += "后:" + str;
- str.Format("%d", (int)incomeqt);
- ::ConvertToPrice(str);
- content += "其它:" + str;
- str.Format("%d", (int)payout);
- ::ConvertToPrice(str);
- content += "支出:" + str;
- str.Format("%d", (int)(income - payout));
- ::ConvertToPrice(str);
- content += "净收:" + str;
- str.Format("%d", dindanshu);
- content += "定单:" + str;
- if (msgaccount != "")
- {
- if (atoi(balance) < 200)
- {
- content += "您的余额小于两百条,请及时充值。联系电话4006067068";
- }
- else if (atoi(balance) < 500)
- {
- content += "您的余额小于五百条,请及时充值。联系电话4006067068";
- }
- else if (atoi(balance) < 800)
- {
- content += "您的余额小于八百条,请及时充值。联系电话4006067068";
- }
- else if (atoi(balance) < 1000)
- {
- content += "您的余额小于一千条,请及时充值。联系电话4006067068";
- }
- }
- int count = GetLengthEx(content) / MSG_LENGTH;
- if (GetLengthEx(content) % MSG_LENGTH)
- count++;
- int phonenum = 0;
- str = msgphones;
- pos = str.Find(",");
- if (pos != -1)
- {
- while (pos != -1)
- {
- phonenum++;
- str = str.Right(str.GetLength() - pos - 1);
- pos = str.Find(",");
- }
- phonenum++;
- }
- else
- phonenum = 1;
- count *= phonenum;
- CString scount;
- scount.Format("%d", count);
- timestamp = tm.Format("%Y%m%d%H%M%S");
- sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + msgphones + "','" + content + "','" + timestamp + "','" + scount + "','0','0','3','系统自动发送')";
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- }
- }
- }
- BOOL bcheck1 = atoi(m_bak1);
- BOOL bcheck2 = atoi(m_bak2);
- BOOL bcheck3 = atoi(m_bak3);
- BOOL bcheck4 = atoi(m_bak4);
- }
- catch (CException *e)
- {
- TCHAR szError[1024] = { 0 };
- e->GetErrorMessage(szError, 1024);
- WriteTextLog(CString(szError));
- e->Delete();
- WriteTextLog("出错在函数bakphoto中");
- }
- }
- void CDBServerDlg::ShutDown()
- {
- try
- {
-
- TerminateCheckWork();
- CDatabase *pMaindb = NULL;
- ODBCConnGuard ConnGuard(pMaindb, -1, 3000);
- if ( pMaindb == NULL )
- return;
- CString m_bak6;
- {
- CRecordset myset(pMaindb);
- CString sql = "select * from [version]";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("bak6", m_bak6);
- myset.Close();
- }
- OnServerStop();
-
-
- for (int i = 0; i < g_dbHistoryArray.GetSize(); i++)
- {
- g_dbHistoryArray.ElementAt(i)->Close();
- delete g_dbHistoryArray.ElementAt(i);
- }
- ReleaseBranchDB();
- WriteTextLog("备份完成");
-
- g_tisks = ::GetTickCount() - g_tisks;
- CString str;
- str.Format("耗时:%d分钟", g_tisks / 60000);
- CStdioFile fp;
- fp.Open(g_mainpath + "\\log.txt", CFile::modeCreate | CFile::modeWrite);
- CTime tm = CTime::GetCurrentTime();
- if (0)
- {
- CTimeSpan sp(1, 0, 0, 0);
- tm -= sp;
- fp.WriteString(tm.Format("%Y-%m-%d"));
- fp.WriteString("\r\n");
- fp.WriteString(CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"));
- fp.WriteString(str);
- }
- else
- {
- fp.WriteString(g_bakdate);
- fp.WriteString("\r\n");
- fp.WriteString(tm.Format("%Y-%m-%d %H:%M:%S"));
- fp.WriteString(str);
- }
- fp.WriteString("\r\n");
- fp.WriteString(g_bakinfo);
- fp.WriteString("\r\n");
- fp.WriteString(g_bakphoto);
- fp.Close();
-
-
- if (atoi(m_bak6))
- {
-
- TerminateThread();
-
- DWORD id = FindAppProcessID("AutoRun.exe");
- if (id != -1)
- {
- HANDLE ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
- if (ProcessHandle)TerminateProcess(ProcessHandle, 0);
- }
-
- m_TrayIcon.RemoveIcon();
- if (g_pSkinData)delete[]g_pSkinData; g_pSkinData = NULL;
-
- MyExitWindows();
- }
- else
- {
- TerminateThread();
- m_TrayIcon.RemoveIcon();
- if (g_pSkinData)
- delete[]g_pSkinData;
- g_pSkinData = NULL;
- WriteTextLog("备份完成,服务器重启");
- CDialog::OnCancel();
- }
- }
- catch (...)
- {
- WriteTextLog("出错在函数shutdown中");
- }
- }
- void CDBServerDlg::MyExitWindows()
- {
- try
- {
- UINT t = EWX_SHUTDOWN | EWX_FORCE;
- OSVERSIONINFO osv;
- osv.dwOSVersionInfoSize = sizeof OSVERSIONINFO;
- GetVersionEx(&osv);
- if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT)
- {
-
- HANDLE hProcess, hToken;
- TOKEN_PRIVILEGES Privileges;
- LUID luid;
- hProcess = GetCurrentProcess();
-
- OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES, &hToken);
- Privileges.PrivilegeCount = 1;
- LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &luid);
- Privileges.Privileges[0].Luid = luid;
- Privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
- AdjustTokenPrivileges(hToken, FALSE, &Privileges, NULL, NULL, NULL);
- ExitWindowsEx(t, 0);
- }
- else
- {
- ExitWindowsEx(t, 0);
- PostQuitMessage(0);
- }
- }
- catch (...)
- {
- WriteTextLog("出错在函数exitwindows中");
- }
- }
- void CDBServerDlg::OnAutorun()
- {
-
- g_bAutoRun = !g_bAutoRun;
- CString version = _T("Version 1.0");
- AfxGetApp()->WriteProfileInt(version, "brun", g_bAutoRun);
- TCHAR szKey[MAX_PATH];
- HKEY hKey = 0;
- DWORD disp = 0;
- lstrcpy(szKey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
- if (g_bAutoRun)
- {
- int lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
- if (lResult == ERROR_SUCCESS)
- {
- TCHAR szDir[MAX_PATH];
- ::GetModuleFileName(NULL, szDir, MAX_PATH);
- lResult = RegSetValueEx(hKey, "YLGLDBSERVER", 0, REG_SZ, (const unsigned char*)szDir, lstrlen(szDir));
- RegCloseKey(hKey);
- }
- }
- else
- {
- int lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
- if (lResult == ERROR_SUCCESS)
- {
- RegDeleteValue(hKey, "YLGLDBSERVER");
- RegDeleteKey(hKey, "YLGLDBSERVER");
- RegCloseKey(hKey);
- }
- }
- }
- void CDBServerDlg::GetFileDate()
- {
- CStringArray filesarray;
- CStringArray filesarray2;
- filesarray.Add("AutoUpdate.exe");
- filesarray.Add("skin\\1.lia");
- filesarray.Add("skin\\2.lia");
- filesarray.Add("skin\\3.lia");
- filesarray.Add("skin\\4.lia");
- filesarray.Add("skin\\10.lia");
- filesarray.Add("skin\\logo.jpg");
- filesarray.Add("skin\\标题-选片.jpg");
- filesarray.Add("skin\\标题-看设计.jpg");
- filesarray.Add("图片\\欢迎.jpg");
- filesarray.Add("图片\\连接.jpg");
- filesarray.Add("图片\\标题.jpg");
- filesarray.Add("图片\\背景.jpg");
- filesarray.Add("图片-红色风格\\欢迎.jpg");
- filesarray.Add("图片-红色风格\\连接.jpg");
- filesarray.Add("图片-红色风格\\标题.jpg");
- filesarray.Add("图片-红色风格\\背景.jpg");
- filesarray.Add("图片-红色风格\\选片.jpg");
- filesarray.Add("图片-红色风格\\看设计.jpg");
- filesarray.Add("skin\\1-red.lia");
- filesarray.Add("skin\\2-red.lia");
- filesarray.Add("skin\\10-red.lia");
- filesarray.Add("skin\\6.lia");
- filesarray.Add("图片\\掌中宝.jpg");
- filesarray.Add("regsvr32.exe");
- filesarray.Add("MSCHRT20.OCX");
-
- filesarray2.Add("AutoUpdate.exe");
- filesarray2.Add("skin\\1.lia");
- filesarray2.Add("skin\\2.lia");
- filesarray2.Add("skin\\3.lia");
- filesarray2.Add("skin\\4.lia");
- filesarray2.Add("skin\\5.lia");
- filesarray2.Add("skin\\10.lia");
- filesarray2.Add("skin\\5-red.lia");
- filesarray2.Add("skin\\10-red.lia");
- filesarray2.Add("图片\\logo.jpg");
- filesarray2.Add("图片\\标题-选片.jpg");
- filesarray2.Add("图片\\标题-看设计.jpg");
- filesarray2.Add("图片\\选片.jpg");
- filesarray2.Add("图片\\看设计.jpg");
- filesarray2.Add("图片\\欢迎.jpg");
- filesarray2.Add("图片\\连接.jpg");
- filesarray2.Add("图片\\标题.jpg");
- filesarray2.Add("图片\\背景.jpg");
- filesarray2.Add("图片-红色风格\\欢迎.jpg");
- filesarray2.Add("图片-红色风格\\连接.jpg");
- filesarray2.Add("图片-红色风格\\标题.jpg");
- filesarray2.Add("图片-红色风格\\背景.jpg");
- filesarray2.Add("skin\\6.lia");
- filesarray2.Add("图片\\掌中宝.jpg");
- filesarray2.Add("regsvr32.exe");
- filesarray2.Add("MSCHRT20.OCX");
- int i = 0;
-
- for ( i = 0; i < filesarray.GetSize(); i++)
- {
- g_filedatearray.Add(GetModifyTime(g_mainpath + "\\系统文件\\" + filesarray.ElementAt(i)));
- }
- g_filedatearraynew.Copy(filesarray2);
- for (i = 0; i < filesarray2.GetSize(); i++)
- {
- g_filedatearraynew.Add(GetFileSize(g_mainpath + "\\系统文件\\" + filesarray2.ElementAt(i)));
- }
- }
- #ifdef ENTERPRISE_VERSION
- CString g_bMain;
- #endif
- void CDBServerDlg::LoadBranchInfo()
- {
- #ifdef ENTERPRISE_VERSION
- try
- {
- ReleaseBranchDB();
- CArray<CStringArray, CStringArray>g_List1array;
- {
- MyLock lock("savebranchinfo");
- CFile fp;
- CString path = g_mainpath + "\\branchinfo.dat";
- if (::PathFileExists(path) == 0)
- return;
- fp.Open(path, CFile::modeRead);
- DWORD leng = fp.GetLength();
- if (leng < sizeof(DWORD) * 2)
- {
- fp.Close();
- return;
- }
- DWORD flag = 0;
-
- fp.Seek(-(int)sizeof(DWORD), CFile::end);
- fp.Read(&flag, sizeof(DWORD));
- if (flag != 889900)
- {
- fp.Close();
- return;
- }
- fp.SeekToBegin();
- DWORD arraysize;
- fp.Read(&arraysize, sizeof(DWORD));
- if (arraysize > 20)
- {
- fp.Close();
- return;
- }
- BYTE *pData = new BYTE[leng - sizeof(DWORD)];
- fp.Read(pData, leng - sizeof(DWORD));
- fp.Close();
- CMemFile memfile;
- memfile.Attach(pData, leng - sizeof(DWORD));
- CArchive ar(&memfile, CArchive::load);
- g_List1array.SetSize(arraysize, 1);
- for (int ii = 0; ii < g_List1array.GetSize(); ii++)
- g_List1array.ElementAt(ii).Serialize(ar);
- ar.Close();
- memfile.Detach();
- delete[]pData;
- }
- if (g_List1array.GetSize() == 0)
- return;
-
-
- {
- int value[8];
- double f[8];
- 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("");
-
- int ret = ytSoftKey.getdata(&value[0], &value[1], &value[2], &value[3], &value[4], &value[5], &value[6], &value[7],
- &f[0], &f[1], &f[2], &f[3], &f[4], &f[5], &f[6], &f[7],
- s0, s1, s2, s3, s4, s5, s6, s7);
- if (ret != 0 && ret != -43)
- {
- g_sdomain = "";
- }
- else
- g_sdomain = s1;
- }
- CString str, str2, localname, rights;
- int i = 0;
- for ( i = 0; i < g_List1array.GetSize(); i++)
- {
- if (g_sdomain == g_List1array.ElementAt(i).ElementAt(0))
- {
- if (g_List1array.ElementAt(i).GetSize()>5)
- rights = g_List1array.ElementAt(i).ElementAt(5); break;
- }
- }
- for (i = 0; i < g_List1array.GetSize(); i++)
- {
- CString branchname = g_List1array.ElementAt(i).ElementAt(1);
- CString branchip = g_List1array.ElementAt(i).ElementAt(2);
- CString domain = g_List1array.ElementAt(i).ElementAt(0);
- CString dir = g_mainpath + "\\数据\\" + branchname;
- if (g_sdomain == g_List1array.ElementAt(i).ElementAt(0))
- {
- localname = branchname;
- g_bMain = g_List1array.ElementAt(i).ElementAt(3);
- continue;
- }
- CString branchname2 = "," + branchname + ",";
- if (rights.Find(branchname2) == -1)
- continue;
- #ifdef SQLSERVER_VERSION
- if (1)
- {
-
- g_branchdbarray.Add(NULL);
- g_branchnamearray.Add(branchname);
- g_branchdb2array.Add(NULL);
- g_branchname2array.Add(branchname);
- g_branchiparray.Add(branchip);
- g_branchdomainarray.Add(domain);
-
- }
- #endif
- }
-
- g_branchdbarray.Add(NULL);
- g_branchnamearray.Add(localname);
- g_branchiparray.Add("xxx");
- g_branchdomainarray.Add(g_sdomain);
- }
- catch (...)
- {
- }
- #endif
- }
- void CDBServerDlg::ReleaseBranchDB()
- {
- #ifdef ENTERPRISE_VERSION
- try
- {
- for (int i = 0; i < g_branchdbarray.GetSize(); i++)
- {
- if (g_branchdbarray.ElementAt(i))
- {
- g_branchdbarray.ElementAt(i)->Close();
- delete g_branchdbarray.ElementAt(i);
- }
- }
- g_branchdbarray.RemoveAll();
- g_branchdb2array.RemoveAll();
- g_branchnamearray.RemoveAll();
- g_branchname2array.RemoveAll();
- g_branchiparray.RemoveAll();
- g_branchdomainarray.RemoveAll();
- }
- catch (...)
- {
- WriteTextLog("ReleaseBranchDB出错");
- }
- #endif
- }
- void CDBServerDlg::LoadBranchInfo2()
- {
- #ifdef ENTERPRISE_VERSION
- try
- {
- ReleaseBranchDB();
- CArray<CStringArray, CStringArray>g_List1array;
- {
- MyLock lock("savebranchinfo");
- CFile fp;
- CString path = g_mainpath + "\\branchinfo.dat";
- if (::PathFileExists(path) == 0)
- return;
- fp.Open(path, CFile::modeRead);
- DWORD leng = fp.GetLength();
- if (leng < sizeof(DWORD) * 2)
- {
- fp.Close(); return;
- }
- DWORD flag;
-
- fp.Seek(-(int)sizeof(DWORD), CFile::end);
- fp.Read(&flag, sizeof(DWORD));
- if (flag != 889900)
- {
- fp.Close(); return;
- }
- fp.SeekToBegin();
- DWORD arraysize;
- fp.Read(&arraysize, sizeof(DWORD));
- if (arraysize > 20)
- {
- fp.Close();
- return;
- }
- BYTE *pData = new BYTE[leng - sizeof(DWORD)];
- fp.Read(pData, leng - sizeof(DWORD));
- fp.Close();
- CMemFile memfile;
- memfile.Attach(pData, leng - sizeof(DWORD));
- CArchive ar(&memfile, CArchive::load);
- g_List1array.SetSize(arraysize, 1);
- for (int ii = 0; ii < g_List1array.GetSize(); ii++)
- {
- g_List1array.ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- delete[]pData;
- }
- if (g_List1array.GetSize() == 0)return;
-
-
- {
- int value[8];
- double f[8];
- 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("");
-
- int ret = ytSoftKey.getdata(&value[0], &value[1], &value[2], &value[3], &value[4], &value[5], &value[6], &value[7],
- &f[0], &f[1], &f[2], &f[3], &f[4], &f[5], &f[6], &f[7],
- s0, s1, s2, s3, s4, s5, s6, s7);
- if (ret != 0 && ret != -43)
- {
- g_sdomain = "";
- }
- else
- g_sdomain = s1;
- }
- CString str, str2, localname, rights;
- int i = 0;
- for ( i = 0; i < g_List1array.GetSize(); i++)
- {
- if (g_sdomain == g_List1array.ElementAt(i).ElementAt(0))
- {
- if (g_List1array.ElementAt(i).GetSize()>5)
- rights = g_List1array.ElementAt(i).ElementAt(5); break;
- }
- }
- for (i = 0; i < g_List1array.GetSize(); i++)
- {
- CString branchname = g_List1array.ElementAt(i).ElementAt(1);
- CString branchip = g_List1array.ElementAt(i).ElementAt(2);
- CString domain = g_List1array.ElementAt(i).ElementAt(0);
- CString dir = g_mainpath + "\\数据\\" + branchname;
- if (g_sdomain == g_List1array.ElementAt(i).ElementAt(0))
- {
- localname = branchname;
- g_bMain = g_List1array.ElementAt(i).ElementAt(3);
- continue;
- }
- CString branchname2 = "," + branchname + ",";
- if (rights.Find(branchname2) == -1)
- continue;
- #ifdef SQLSERVER_VERSION
- if (1)
- {
-
- g_branchdbarray.Add(NULL);
- g_branchnamearray.Add(branchname);
- g_branchdb2array.Add(NULL);
- g_branchname2array.Add(branchname);
- g_branchiparray.Add(branchip);
- g_branchdomainarray.Add(domain);
- }
- #endif
- }
- g_branchdbarray.Add(NULL);
- g_branchnamearray.Add(localname);
- g_branchiparray.Add("xxx");
- g_branchdomainarray.Add(g_sdomain);
- }
- catch (...)
- {
- }
- #endif
- }
- int __cdecl CompareByLabel6(const void *elem1, const void *elem2)
- {
- CStringArray *p1 = (CStringArray*)elem1;
- CStringArray *p2 = (CStringArray*)elem2;
- return atoi(p1->ElementAt(5)) > atoi(p2->ElementAt(5));
- }
- void CDBServerDlg::CheckMemberMsg()
- {
- try
- {
- CDatabase *pMaindb = NULL;
- ODBCConnGuard ConnGuard( pMaindb, -1, 3000);
- if ( pMaindb == NULL )
- return;
- CString sql = "delete from sendreg where [log]='0/0'";
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- {
- CStringArray idarray;
- CString timestamp;
- CTime tm = CTime::GetCurrentTime();
- tm -= CTimeSpan(0, 1, 0, 0);
- timestamp = tm.Format("%Y%m%d%H%M%S");
- CRecordset myset(pMaindb);
- CString sql = "select [autoid] from sendregdelay where [timestamp]<'" + timestamp + "'";
- myset.Open(CRecordset::forwardOnly, sql);
- while (!myset.IsEOF())
- {
- myset.GetFieldValue("autoid", sql);
- idarray.Add(sql);
- myset.MoveNext();
- }
- myset.Close();
- for (int i = 0; i < idarray.GetSize(); i++)
- {
-
-
- sql.Format("insert into sendreg([msgtype],[timestamp],[msgcount],[log],[status],[issended],[isautosend],[phones],[content],[ren]) select [msgtype],[timestamp],[msgcount],[log],[status],[issended],[isautosend],[phones],[content],[ren] from sendregdelay where [autoid]=%d", atol(idarray.ElementAt(i)));
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- sql.Format("delete from sendregdelay where [autoid]=%d", atol(idarray.ElementAt(i)));
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- }
- }
- int covertrate = 100;
- CString spoint;
- {
- CRecordset myset(pMaindb);
- CString sql = "select * from version";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("rate2", sql);
- myset.Close();
- covertrate = atoi(sql);
- if (covertrate == 0)covertrate = 100;
- }
- CString filter;
- CArray<CStringArray, CStringArray>rulearray;
- CArray<CStringArray, CStringArray>memberarray;
- {
- CRecordset myset(pMaindb);
- CString sql = "select count(*) as cot from msgtemp2";
- if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- rulearray.SetSize(count, 1);
- CRstmsgtemp2 rsSt;
- rsSt.m_pDatabase = pMaindb;
- if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- DWORD ii = 0;
- while (!rsSt.IsEOF())
- {
- rulearray.ElementAt(ii).RemoveAll();
- rulearray.ElementAt(ii).Add(rsSt.name);
- rulearray.ElementAt(ii).Add(rsSt.content1);
- rulearray.ElementAt(ii).Add(rsSt.content2);
- rulearray.ElementAt(ii).Add(rsSt.check1);
- rulearray.ElementAt(ii).Add(rsSt.check2);
- rulearray.ElementAt(ii).Add(rsSt.point);
- ii++;
- rsSt.MoveNext();
- if (rulearray.GetSize() <= ii)break;
- }
- rsSt.Close(); rulearray.SetSize(ii, 1);
- }
- if (rulearray.GetSize() == 0)return;
- qsort(static_cast<void*>(&rulearray[0]), rulearray.GetSize(), sizeof(rulearray[0]), CompareByLabel6);
-
- {
- CRecordset myset(pMaindb);
- CString sql = "select count(*) as cot from membermanage"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- memberarray.SetSize(atol(sql), 1);
- RstMemberReg rsSt;
- rsSt.m_pDatabase = pMaindb;
- if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.Open();
- DWORD ii = 0;
- if (covertrate != 100)
- {
- while (!rsSt.IsEOF())
- {
- memberarray.ElementAt(ii).RemoveAll();
- memberarray.ElementAt(ii).Add(rsSt.m_memberno);
- memberarray.ElementAt(ii).Add(rsSt.m_name);
- memberarray.ElementAt(ii).Add(rsSt.m_sex);
- memberarray.ElementAt(ii).Add(rsSt.m_phone);
- spoint.Format("%d", atoi(rsSt.m_money)*covertrate / 100);
- memberarray.ElementAt(ii).Add(spoint);
- memberarray.ElementAt(ii).Add(rsSt.m_sendmark1);
- memberarray.ElementAt(ii).Add(rsSt.m_sendmark2);
- ii++;
- rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
- }
- }
- else
- {
- while (!rsSt.IsEOF())
- {
- memberarray.ElementAt(ii).RemoveAll();
- memberarray.ElementAt(ii).Add(rsSt.m_memberno);
- memberarray.ElementAt(ii).Add(rsSt.m_name);
- memberarray.ElementAt(ii).Add(rsSt.m_sex);
- memberarray.ElementAt(ii).Add(rsSt.m_phone);
- memberarray.ElementAt(ii).Add(rsSt.m_money);
- memberarray.ElementAt(ii).Add(rsSt.m_sendmark1);
- memberarray.ElementAt(ii).Add(rsSt.m_sendmark2);
- ii++;
- rsSt.MoveNext(); if (memberarray.GetSize() <= ii)break;
- }
- }
- rsSt.Close(); memberarray.SetSize(ii, 1);
- }
- CString memberno, name, sex, phone, point, mark1, mark2, rulename, rulecheck1, rulecheck2, rulepoint, rulecontent1, rulecontent2;
- for (int i = 0; i < memberarray.GetSize(); i++)
- {
- memberno = memberarray.ElementAt(i).ElementAt(0);
- name = memberarray.ElementAt(i).ElementAt(1);
- sex = memberarray.ElementAt(i).ElementAt(2);
- phone = memberarray.ElementAt(i).ElementAt(3);
- point = memberarray.ElementAt(i).ElementAt(4);
- mark1 = "," + memberarray.ElementAt(i).ElementAt(5) + ",";
- mark2 = "," + memberarray.ElementAt(i).ElementAt(6) + ",";
- if (atoi(point) == 0)continue;
- if (phone.IsEmpty())continue;
- if (-1 == CheckPhoneType(phone))continue;
- int j = 0;
- for ( j = 0; j < rulearray.GetSize(); j++)
- {
- if (mark1.GetLength()>4000)break;
- rulename = "," + rulearray.ElementAt(j).ElementAt(0) + ",";
- rulecontent1 = name + rulearray.ElementAt(j).ElementAt(1);
- rulecontent2 = name + rulearray.ElementAt(j).ElementAt(2);
- rulecheck1 = rulearray.ElementAt(j).ElementAt(3);
- rulecheck2 = rulearray.ElementAt(j).ElementAt(4);
- rulepoint = rulearray.ElementAt(j).ElementAt(5);
- if (atoi(rulecheck1) == 0 && atoi(rulecheck2) == 0)continue;
- if (atoi(rulecheck1))
- {
- if (rulecontent1.IsEmpty())continue;
- if (mark1.Find(rulename) != -1)break;
- if (atoi(point) >= atoi(rulepoint))continue;
- if (atoi(point) < atoi(rulepoint) * 80 / 100)continue;
-
-
-
-
- int count = GetLengthEx(rulecontent1) / MSG_LENGTH;
- if (GetLengthEx(rulecontent1) % MSG_LENGTH)
- count++;
- int phonenum = 1;
- count *= phonenum;
- CString scount;
- scount.Format("%d", count);
- CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
- CString sql;
- mark1.TrimLeft(",");
- mark1.TrimRight(",");
- if (mark1.IsEmpty() == 0)
- mark1 += ",";
- rulename.TrimLeft(",");
- rulename.TrimRight(",");
- mark1 += rulename;
- sql = "update membermanage set sendmark1='" + mark1 + "' where memberno='" + memberno + "'";
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- mark1 = "," + mark1 + ",";
- sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + phone + "','" + rulecontent1 + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- }
- }
-
- BOOL bSended = 0;
- for (j = 0; j < rulearray.GetSize(); j++)
- {
- if (mark2.GetLength() > 4000)break;
- if (bSended)break;
- rulename = "," + rulearray.ElementAt(j).ElementAt(0) + ",";
- rulecontent1 = name + rulearray.ElementAt(j).ElementAt(1);
- rulecontent2 = name + rulearray.ElementAt(j).ElementAt(2);
- rulecheck1 = rulearray.ElementAt(j).ElementAt(3);
- rulecheck2 = rulearray.ElementAt(j).ElementAt(4);
- rulepoint = rulearray.ElementAt(j).ElementAt(5);
- if (atoi(rulecheck1) == 0 && atoi(rulecheck2) == 0)continue;
- if (atoi(rulecheck2))
- {
- if (rulecontent2.IsEmpty())continue;
- if (mark2.Find(rulename) != -1)break;
- if (atoi(point) < atoi(rulepoint))continue;
-
-
-
-
- int count = GetLengthEx(rulecontent2) / MSG_LENGTH;
- if (GetLengthEx(rulecontent2) % MSG_LENGTH)
- count++;
- int phonenum = 1;
- count *= phonenum;
- CString scount;
- scount.Format("%d", count);
- CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
- CString sql;
- mark2.TrimLeft(",");
- mark2.TrimRight(",");
- if (mark2.IsEmpty() == 0)
- mark2 += ",";
- rulename.TrimLeft(",");
- rulename.TrimRight(",");
- mark2 += rulename;
- sql = "update membermanage set sendmark2='" + mark2 + "' where memberno='" + memberno + "'";
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- mark2 = "," + mark2 + ",";
- sql = "insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('" + phone + "','" + rulecontent2 + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- bSended = 1;
- }
- }
- }
- }
- catch (CDBException *e)
- {
- WriteTextLog(_T("%s-<%d>-%s,%s"), __FILE__, __LINE__, __FUNCTION__, e->m_strError);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- }
- }
- void CDBServerDlg::CheckBakState()
- {
- try
- {
- CDatabase* pMaindb = NULL;
- ODBCConnGuard ConnGuard(pMaindb, -1, 3000);
- if ( pMaindb == NULL )
- return;
- CString filter = _T("");
- CArray<CStringArray, CStringArray> strArray;
- CRecordset myset(pMaindb);
- CString sql = "select count(*) as cot from bakstate";
- if (!filter.IsEmpty())
- sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- strArray.SetSize(count, 1);
-
- CRstbakstate rsSt;
- rsSt.m_pDatabase = pMaindb;
- if (!filter.IsEmpty())
- rsSt.m_strFilter = filter;
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- strArray.ElementAt(ii).RemoveAll();
- strArray.ElementAt(ii).Add(rsSt.date);
- strArray.ElementAt(ii).Add(rsSt.photo);
- strArray.ElementAt(ii).Add(rsSt.info);
- ii++;
- rsSt.MoveNext();
- if (strArray.GetSize() <= ii)
- break;
- }
- rsSt.Close();
-
- strArray.SetSize(ii, 1);
- while (strArray.GetSize() > 7)
- {
- CString sql = "delete from bakstate where [date]='" + strArray.ElementAt(0).ElementAt(0) + "'";
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- strArray.RemoveAt(0);
- }
- CString path = _T("");
- path.Format("%s\\log.txt", g_mainpath);
- if (::PathFileExists(path))
- {
- CString str;
- CStdioFile fp;
- if (fp.Open(path, CFile::modeRead))
- {
- CString temp;
- fp.ReadString(temp);
- CString date = temp;
- date.TrimRight();
- while(!feof(fp.m_pStream))
- {
- fp.ReadString(temp);
- str += temp;
- }
- fp.Close();
- if (date.GetLength() != 10)
- return;
- BOOL bBak = 0;
- int i = 0;
- for (int i = 0; i < strArray.GetSize(); i++)
- {
- if (date == strArray.ElementAt(i).ElementAt(0))
- {
- bBak = 1;
- break;
- }
- }
- if (bBak == 0)
- {
- CString state1 = "0";
- CString state2 = "0";
- if (str.Find("照片备份成功") != -1)state1 = "1";
- if (str.Find("资料备份成功") != -1)state2 = "1";
- sql = "insert into bakstate([date],[photo],[info])values('" + date + "','" + state1 + "','" + state2 + "')";
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- }
- else
- {
- CString state1 = "0";
- CString state2 = "0";
- if (str.Find("照片备份成功") != -1)state1 = "1";
- if (str.Find("资料备份成功") != -1)state2 = "1";
- sql = "update bakstate set [photo]='" + state1 + "',[info]='" + state2 + "' where [date]='" + date + "'";
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- }
-
- CTime tm = CTime::GetCurrentTime();
- CTimeSpan dt(1, 0, 0, 0);
- tm -= dt;
- CString yesterday = tm.Format("%Y-%m-%d");
- for (i = 0; i < strArray.GetSize(); i++)
- {
- if (yesterday == strArray.ElementAt(i).ElementAt(0))return;
- }
- if (yesterday == date)return;
- sql = "insert into bakstate([date],[photo],[info])values('" + yesterday + "','0','0')";
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- }
- else
- {
- CTime tm = CTime::GetCurrentTime();
- CTimeSpan dt(1, 0, 0, 0);
- tm -= dt;
- sql = "insert into bakstate([date],[photo],[info])values('" + tm.Format("%Y-%m-%d") + "','0','0')";
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- }
- }
- else
- {
-
- CTime tm = CTime::GetCurrentTime();
- CTimeSpan dt(1, 0, 0, 0);
- tm -= dt;
- for (int i = 0; i < strArray.GetSize(); i++)
- {
- if (tm.Format("%Y-%m-%d") == strArray.ElementAt(i).ElementAt(0))
- return;
- }
- sql = "insert into bakstate([date],[photo],[info])values('" + tm.Format("%Y-%m-%d") + "','0','0')";
- MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pMaindb, sql);
- }
- }
- catch (...)
- {
- WriteTextLog("出错3");
- }
- }
- CString CDBServerDlg::GetRegCode(int m_id, int m_time1, int m_time2)
- {
- TCHAR DevicePath[260];
- if (FindPort(0, DevicePath) != 0)
- return "";
- int version;
- GetIDVersion((DWORD*)&m_id, &version, DevicePath);
- int d[8]; double f[8];
- int idtemp = 123456;
- char s0[50] = "", s1[50] = "", s2[50] = "", s3[50] = "", s4[50] = "", s5[50] = "", s6[50] = "", s7[50] = "";
-
-
- int ret = 0;
- if (ret != 0)
- {
- return "";
- }
-
-
-
-
-
-
- ret = ytSoftKey.timedog1(&m_id, &idtemp, &m_time1, &m_time2, &d[4], &d[5], &d[6], &d[7],
- &f[0], &f[1], &f[2], &f[3], &f[4], &f[5], &f[6], &f[7],
- s0, s1, s2, s3, s4, s5, s6, s7);
- if (ret != 0 && ret != -43)
- {
- return "";
- }
- CString str = "";
- CString temp, temp2;
-
- temp.Format("%d", abs(m_id));
- int leng = temp.GetLength();
- if (m_id < 0)
- temp2 = "1";
- else
- temp2 = "0";
- temp = temp2 + temp;
- temp2.Format("%02d", leng);
- temp = temp2 + temp;
- str += temp;
-
- temp.Format("%d", abs(m_time1));
- leng = temp.GetLength();
- if (m_time1 < 0)
- temp2 = "1";
- else
- temp2 = "0";
- temp = temp2 + temp;
- temp2.Format("%02d", leng);
- temp = temp2 + temp;
- str += temp;
-
- temp.Format("%d", abs(m_time2));
- leng = temp.GetLength();
- if (m_time2 < 0)
- temp2 = "1";
- else
- temp2 = "0";
- temp = temp2 + temp;
- temp2.Format("%02d", leng);
- temp = temp2 + temp;
- str += temp;
-
- temp.Format("%d", abs(idtemp));
- leng = temp.GetLength();
- if (idtemp < 0)
- temp2 = "1";
- else
- temp2 = "0";
- temp = temp2 + temp;
- temp2.Format("%02d", leng);
- temp = temp2 + temp;
- str += temp;
- return str;
- }
- int g_ndogtimes = 0;
- void CDBServerDlg::CheckRegCode()
- {
- char path[MAX_PATH];
- ::GetSystemDirectory(path, MAX_PATH);
- CString sysdir = path;
- sysdir += "\\authcode.txt";
- CStdioFile fp;
- CString authcode;
- if (fp.Open(sysdir, CFile::modeRead))
- {
- fp.ReadString(authcode);
- fp.Close();
- }
- ::DeleteFile(sysdir);
- authcode.TrimLeft();
- authcode.TrimRight();
- authcode.Replace("\n", "");
- authcode.Replace("\r", "");
- if (authcode.GetLength() != 240)
- {
- return;
- }
- TCHAR DevicePath[260];
- if (FindPort(0, DevicePath) != 0)
- return;
- DWORD OutID;
- int version;
- GetIDVersion(&OutID, &version, DevicePath);
- CString str1, str2, str3, str4, str5;
- str1 = authcode.Mid(0, 48);
- str2 = authcode.Mid(48, 48);
- str3 = authcode.Mid(96, 48);
- str4 = authcode.Mid(144, 48);
- str5 = authcode.Mid(192, 48);
-
- int ret = 0;
- if (ret != 0)
- {
- return;
- }
- int d[8]; double f[8];
- char s0[50] = "", s1[50] = "", s2[50] = "", s3[50] = "", s4[50] = "", s5[50] = "", s6[50] = "", s7[50] = "";
-
- sprintf(s0, "%s", str1);
- sprintf(s1, "%s", str2);
- sprintf(s2, "%s", str3);
- sprintf(s3, "%s", str4);
- sprintf(s4, "%s", str5);
-
- ret = ytSoftKey.timedog2(&d[0], &d[1], &d[2], &d[3], &d[4], &d[5], &d[6], &d[7],
- &f[0], &f[1], &f[2], &f[3], &f[4], &f[5], &f[6], &f[7],
- s0, s1, s2, s3, s4, s5, s6, s7);
- if (ret != 0 && ret != -43)
- {
- return;
- }
- str1 = s0;
- str2 = s1;
- str3 = s2;
- str4 = s3;
- str5 = s4;
- authcode = str1;
- authcode += str2;
- authcode += str3;
- authcode += str4;
- authcode += str5;
- str1 += str2;
- str3 += str4;
- DWORD id = atoi(str5.Right(8));
- str5 = str5.Left(12);
- if (id != OutID)
- {
- return;
- }
- TCHAR HKey[50] = "ffffffff", LKey[50] = "ffffffff";
- TCHAR WHKey[41] = "0", WLKey[41] = "0";
- TCHAR year[10], month[10], day[10], hour[10], minute[10], second[10];
- sprintf(WHKey, "%s", str1);
- sprintf(WLKey, "%s", str3);
- CString temp;
- temp = str5.Left(4);
- str5 = str5.Right(8);
- sprintf(year, "%s", temp);
- temp = str5.Left(2);
- str5 = str5.Right(6);
- sprintf(month, "%s", temp);
- temp = str5.Left(2);
- str5 = str5.Right(4);
- sprintf(day, "%s", temp);
- temp = str5.Left(2);
- str5 = str5.Right(2);
- sprintf(hour, "%s", temp);
- sprintf(minute, "%s", str5);
- sprintf(second, "%s", "0");
- ret = WriteTimeAuthToEprom(30128, HKey, LKey, WHKey, WLKey, id, year, month, day, hour, minute, DevicePath);
- if (ret == 0)
- {
- TCHAR year2[10], month2[10], day2[10], hour2[10], minute2[10], second2[10];
- GetRunTimer(year2, month2, day2, hour2, minute2, second2, DevicePath);
- DWORD time1, time2;
- time1 = ConvertStringToTimerReal(year, month, day, hour, minute, second);
- sprintf(second2, "%s", "0");
- time2 = ConvertStringToTimerReal(year2, month2, day2, hour2, minute2, second2);
- if (time1 > time2)
- ConvertTimerToStringReal(time1 - time2, year, month, day, hour, minute, second);
- else
- {
- sprintf(year, "%s", "0");
- sprintf(month, "%s", "0");
- sprintf(day, "%s", "0");
- sprintf(hour, "%s", "0");
- sprintf(minute, "%s", "0");
- }
- g_ndogtimes++;
-
-
-
- }
- else
- {
-
- return;
- }
- }
- BOOL IsCtrlDown()
- {
- short state = GetKeyState(VK_LCONTROL);
- BYTE sta = (BYTE)(state >> 8);
- state = GetKeyState(VK_RCONTROL);
- BYTE sta2 = (BYTE)(state >> 8);
- if (sta || sta2)
- return 1;
- else
- return 0;
- }
- BOOL CDBServerDlg::PreTranslateMessage(MSG* pMsg)
- {
- if (pMsg->message == WM_KEYDOWN)
- {
- switch (pMsg->wParam)
- {
- case 67:
- AfxMessageBox("c");
- break;
- case VK_F8:
- if (IsCtrlDown())GenYLGL();
- break;
- case VK_F9:
- if (IsCtrlDown())
- {
- CString g_domain;
- CArray<CStringArray, CStringArray>g_List1array;
- CString autorunpath = g_mainpath + "\\branchdindan.dat";
- CFile fp;
- if (fp.Open(autorunpath, CFile::modeRead))
- {
- int nMessageLen = fp.GetLength();
- BYTE *pData = new BYTE[nMessageLen];
- fp.Read(pData, nMessageLen);
- fp.Close();
- BYTE *szChatMessage = pData;
- int count;
- memcpy(&count, szChatMessage + (nMessageLen - sizeof(int)), sizeof(int));
- CMemFile memfile;
- memfile.Attach(szChatMessage, nMessageLen);
- CArchive ar(&memfile, CArchive::load);
- g_List1array.SetSize(count);
- for (int ii = 0; ii < g_List1array.GetSize(); ii++)
- {
- g_List1array.ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- memfile.Detach();
- delete[]pData;
- }
- CString time5, id;
- for (int i = 0; i < g_List1array.GetSize(); i++)
- {
- g_domain = "\\" + g_List1array.ElementAt(i).ElementAt(0);
- id = g_List1array.ElementAt(i).ElementAt(1);
- time5 = g_List1array.ElementAt(i).ElementAt(2);
- WriteTextLog(g_domain + "\\" + id + time5);
- }
- }
- break;
- #ifdef LYFZ_VERSION
- case VK_F7:
- if (IsCtrlDown())
- {
- if (AfxMessageBox("是否继续?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return 1;
- CStringArray array1;
- CRstDindanForm rsSt; rsSt.m_pDatabase = &g_db;
- rsSt.Open();
- while (!rsSt.IsEOF())
- {
- array1.Add(rsSt.id);
- rsSt.MoveNext();
- }
- rsSt.Close();
- CString id, sql;
- sql.Format("update dindan set status5='%s'", "无");
- MyExecuteSQL(&g_db, sql);
- BOOL bHasPhoto = 0;
- for (int i = 0; i < array1.GetSize(); i++)
- {
- id = array1.ElementAt(i);
- bHasPhoto = 0;
- CRstClientPhoto rsSt;
- rsSt.m_strFilter = "id='" + id + "'";
- rsSt.Open();
- if (rsSt.photo.m_dwDataLength>0)
- {
- bHasPhoto = 1;
- }
- rsSt.Close();
- if (bHasPhoto)
- {
- sql.Format("update dindan set status5='%s' where id='%s'", "有", id);
- MyExecuteSQL(&g_db, sql);
- }
- }
-
- AfxMessageBox("完成");
- }
- break;
- #endif
- case VK_F2:
- if (IsCtrlDown())
- {
- SelYear dlg;
- if (dlg.DoModal() != IDOK)return 1;
- int year = dlg.m_year;
- int hisyear = CTime::GetCurrentTime().GetYear() - 1;
- if (year == hisyear)
- {
- AfxMessageBox("不能选该年");
- return 1;
- }
- CString str;
- str.Format("此操作将%d年数据导入%d中, 确认吗?", year, hisyear);
- if (AfxMessageBox(str, MB_YESNO | MB_ICONINFORMATION) != IDYES)return 1;
- CDatabase *pdb = GetDB(year);
- if (pdb == NULL)
- {
- str.Format("没有找到%d, 操作失败", year);
- AfxMessageBox(str); return 1;
- }
- str.Format("开始%d->%d", year, hisyear);
- WriteTextLog(str);
- CheckHistoryData(pdb, year);
- str.Format("%d->%d完成", year, hisyear);
- WriteTextLog(str);
- }
- break;
- case VK_F3:
- if (IsCtrlDown())
- {
- SelYear dlg;
- if (dlg.DoModal() != IDOK)return 1;
- int year = dlg.m_year;
- int hisyear = CTime::GetCurrentTime().GetYear() - 1;
- if (year == hisyear)
- {
- AfxMessageBox("不能选该年");
- return 1;
- }
- CString str;
- str.Format("此操作将%d年数据导入%d中(当前数据库中没有的订单全转), 确认吗?", year, hisyear);
- if (AfxMessageBox(str, MB_YESNO | MB_ICONINFORMATION) != IDYES)return 1;
- CDatabase *pdb = GetDB(year);
- if (pdb == NULL)
- {
- str.Format("没有找到%d, 操作失败", year);
- AfxMessageBox(str); return 1;
- }
- str.Format("开始%d->%d", year, hisyear);
- WriteTextLog(str);
- CheckHistoryData(pdb, year, 1);
- str.Format("%d->%d完成", year, hisyear);
- WriteTextLog(str);
- }
- break;
- case VK_F1:
- CString str;
- if (g_conniparray.GetSize() == 0)str = "当前无客户端连接至服务器!";
- for (int i = 0; i < g_conniparray.GetSize(); i++)
- {
- str += "\r\n连接ip:" + g_conniparray.ElementAt(i);
- }
- AfxMessageBox(str);
- #ifdef CONNCOUNT_VERSION
-
- #endif
- return 1;
- }
- }
- return CDialog::PreTranslateMessage(pMsg);
- }
- void CDBServerDlg::GenUPhoneData()
- {
- MyLock lock("processChatMessageRequestxiao");
- CArray<int, int>codearray;
- codearray.Add(80);
- codearray.Add(90);
- codearray.Add(11);
- codearray.Add(138);
- codearray.Add(24);
- codearray.Add(181);
- codearray.Add(65);
- codearray.Add(56);
- codearray.Add(179);
- codearray.Add(53);
- CFile fp;
- CString savepath, g_path1;
- char server[50];
- DWORD leng = 50;
- ::GetComputerName(server, &leng);
- g_path1 = server;
- g_path1 = "\\\\" + g_path1 + "\\电话录音(管理软件)$";
- GetPathFromNetShareName("电话录音(管理软件)$", g_path1);
- if (g_path1.IsEmpty())
- {
- WriteTextLog("获取电精灵数据出错");
- return;
- }
- try
- {
- int aa = 0;
- CDatabase *pMaindb = NULL;
- ODBCConnGuard ConnGuard(pMaindb, -1, 3000);
- if ( pMaindb == NULL )
- return;
- savepath.Format("%s\\uphonedata%d.dat", g_path1, aa);
- ::DeleteFile(savepath);
- if (fp.Open(savepath, CFile::modeCreate | CFile::modeWrite) == 0)
- {
- WriteTextLog("更新来电精灵数据出错");
- return;
- }
- CConnectSocket consock;
- consock.m_pConndb = pMaindb;
- for (int i = 0; i < codearray.GetSize(); i++)
- {
- BYTE code = codearray.ElementAt(i);
- DWORD length, arraysize;
- BYTE *pReturn = NULL;
- consock.GetDataFromCode(code, &pReturn, length, arraysize, "");
- fp.Write(&code, sizeof(BYTE));
- fp.Write(&length, sizeof(DWORD));
- fp.Write(&arraysize, sizeof(DWORD));
- fp.Write(pReturn, length);
- }
- fp.Close();
- }
- catch (...)
- {
- WriteTextLog("获取来电精灵数据出错2");
- }
- }
- void CDBServerDlg::LoadHistoryDB()
- {
- CString path;
- CString sql;
- sql = "delete from historydb";
- CDatabase *pdb = NULL;
- ODBCConnGuard ConnGuard(pdb, -1, 3000);
- if ( pdb ) MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pdb, sql);
- CDatabase g_masterdb;
- try
- {
- CString strCon;
- strCon.Format(DB_SS_CONN_WITHOUT_PORT, g_strdbServrename, _T("master"), g_szDBAccount, g_szDBPassWord);
- g_masterdb.OpenEx(strCon, CDatabase::noOdbcDialog);
- }
- catch (CDBException * e)
- {
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- }
- GetAllCatalogName();
- BOOL bExistCatalog = FALSE;
- TCHAR szdbName[MAX_PATH] = {0};
- for (int i = CTime::GetCurrentTime().GetYear() - 1; i >= 2009; i--)
- {
- #if USE_POOL
- _itot_s(i, szdbName, 10);
- bExistCatalog = FALSE;
- for (int k = 0; k < g_AryAllCatalogName.GetSize(); k++)
- {
- if (g_AryAllCatalogName.ElementAt(k).CompareNoCase(szdbName) == 0)
- {
- bExistCatalog = TRUE;
- break;
- }
- }
- if (bExistCatalog)
- {
- CODBCPool *pdbpool = new CODBCPool;
- if (pdbpool->InitializePool(g_szDBSource, g_dwDBServerPort, g_szDBAccount, g_szDBPassWord, szdbName, g_dwDBPoolDef, g_dwDBPoolMaxCount))
- {
- g_nYearArray.Add(i);
- sql.Format("insert into [historydb]([year])values('%d')", i);
- CDatabase *pdb = NULL;
- ODBCConnGuard ConnGuard(pdb, -1, 3000);
- if (pdb)MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pdb, sql);
- g_dbpool.Add(pdbpool);
- }
- else
- {
- delete pdbpool;
- pdbpool = NULL;
- }
- }
- else
- {
- CString strPathOfYearmdf;
- CString strPathOfYearldf;
- CString sql;
- strPathOfYearmdf.Format("%s\\数据\\%d.mdf", g_mainpath, i);
- strPathOfYearldf.Format("%s\\数据\\%d_log.LDF", g_mainpath, i);
- if (PathFileExists(strPathOfYearmdf))
- {
- BOOL bLog = 0;
- if (PathFileExists(strPathOfYearldf))
- {
- bLog = 1;
- }
- g_masterdb.SetQueryTimeout(600);
- if (bLog)
- sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", i, strPathOfYearmdf, strPathOfYearldf);
- else
- sql.Format("exec sp_attach_db '%d',@filename1='%s'", i, strPathOfYearmdf);
- try
- {
- g_masterdb.ExecuteSQL(sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog("历史数据库初始化失败,%s",e->m_strError);
- g_masterdb.SetQueryTimeout(100);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- break;
- }
- g_masterdb.SetQueryTimeout(100);
- CODBCPool *pdbpool = new CODBCPool;
- if ( pdbpool->InitializePool(g_szDBSource, g_dwDBServerPort, g_szDBAccount, g_szDBPassWord, szdbName, g_dwDBPoolDef, g_dwDBPoolMaxCount))
- {
- g_nYearArray.Add(i);
- sql.Format("insert into [historydb]([year])values('%d')", i);
- CDatabase *pdb = NULL;
- ODBCConnGuard ConnGuard(pdb, -1, 3000);
- if ( pdb )MyExecuteSQL(__FILE__, __LINE__, __FUNCTION__, pdb, sql);
- g_dbpool.Add(pdbpool);
- }
- else
- {
- delete pdbpool;
- }
- }
- }
- #else
- CDatabase *db = new CDatabase;
- try
- {
- CString strCon;
-
- if ( _tcscmp(g_szDBAccount, _T("")) == 0)
- strCon.Format(DB_SW_CONN_WITHOUT_PORT2, g_strdbServrename, i);
- else
- strCon.Format(DB_SS_CONN_WITHOUT_PORT2, g_strdbServrename, i, g_szDBAccount, g_szDBPassWord);
- db->OpenEx(strCon, CDatabase::noOdbcDialog);
- g_nYearArray.Add(i);
- g_dbHistoryArray.Add(db);
- sql.Format("insert into [historydb]([year])values('%d')", i);
- MyExecuteSQL(&g_db, sql);
- }
- catch (CDBException * e)
- {
- #ifdef _DEBUG
- e->ReportError();
- #endif
- CString strPathOfYearmdf;
- CString strPathOfYearldf;
- CString sql;
- strPathOfYearmdf.Format("%s\\数据\\%d.mdf", g_mainpath, i);
- strPathOfYearldf.Format("%s\\数据\\%d_log.LDF", g_mainpath, i);
- if (PathFileExists(strPathOfYearmdf))
- {
- BOOL bLog = 0;
- if (PathFileExists(strPathOfYearldf))
- {
- bLog = 1;
- }
- g_masterdb.SetQueryTimeout(600);
- if (bLog)
- sql.Format("exec sp_attach_db '%d',@filename1='%s',@filename2='%s'", i, strPathOfYearmdf, strPathOfYearldf);
- else
- sql.Format("exec sp_attach_db '%d',@filename1='%s'", i, strPathOfYearmdf);
- try
- {
- g_masterdb.ExecuteSQL(sql);
- }
- catch (CDBException * e)
- {
- WriteTextLog(e->m_strError);
- WriteTextLog("历史数据库初始化失败!!");
- g_masterdb.SetQueryTimeout(100);
- #ifdef _DEBUG
- e->ReportError();
- #endif
- e->Delete();
- break;
- }
- g_masterdb.SetQueryTimeout(100);
- CString strCon;
-
- if ( _tcscmp(g_szDBAccount, _T("")) == 0)
- strCon.Format(DB_SW_CONN_WITHOUT_PORT2, g_strdbServrename, i);
- else
- strCon.Format(DB_SS_CONN_WITHOUT_PORT2, g_strdbServrename, i, g_szDBAccount, g_szDBPassWord);
- db->OpenEx(strCon, CDatabase::noOdbcDialog);
- g_nYearArray.Add(i);
- g_dbHistoryArray.Add(db);
- sql.Format("insert into [historydb]([year])values('%d')", i);
- MyExecuteSQL(&g_db, sql);
- }
- else
- {
-
- e->Delete();
-
- }
- }
- #endif
- }
- g_masterdb.Close();
- }
- void CDBServerDlg::AddOneConn()
- {
- #if 0
- try
- {
- MyLock lock("AddOneConnxiao");
- if (g_nDBCount >= 200)
- {
- WriteTextLog("连接超数!"); return;
- }
- CDatabase *db = new CDatabase;
-
- if (AddConn(db, g_szDBName) == 0)
- return;
- g_pDB[g_nDBCount] = db;
- CString dbname = _T("");
- for (int i = 0; i < g_nYearArray.GetSize(); i++)
- {
- dbname.Format("%d", g_nYearArray.ElementAt(i));
- CDatabase *db = new CDatabase;
- AddConn(db, dbname);
- g_pHistoryDBarray[g_nDBCount].Add(db);
- }
- AddAdoConn();
- g_nDBCount++;
- }
- catch (CException *e)
- {
- TCHAR szError[1024] = { 0 };
- e->GetErrorMessage(szError, 1024);
- WriteTextLog("AddOneConn error" + CString(szError));
- }
- #endif
- }
- void CDBServerDlg::AddAdoConn()
- {
- }
- void GetOneConn(CDatabase **m_pdb, CArray<CDatabase*, CDatabase*>*m_dbarray, CConnectThread *pThread)
- {
- #if 0
- MyLock lock("GetOneConnxiao");
- ll: for (int i = 0; i < 200; i++)
- {
- if (g_pDB[i] != NULL && g_pThreadPt[i] == NULL)
- {
- *m_pdb = g_pDB[i];
- m_dbarray->Copy(g_pHistoryDBarray[i]);
- g_pThreadPt[i] = pThread;
- return;
- }
- }
- if (g_nDBCount >= 200)
- {
- WriteTextLog("连接超数2!");
- *m_pdb = &g_db;
- m_dbarray->Copy(g_dbHistoryArray);
- return;
- }
- g_pMainWnd->AddOneConn();
- ::Sleep(1000);
- goto ll;
- #endif
- }
- void CDBServerDlg::CheckConnCount()
- {
- int count = 0;
- for (int i = 0; i < 200; i++)
- {
- if (g_pDB[i] != NULL && g_pThreadPt[i] == NULL)
- {
- count++;
- if (count > 9)
- return;
- }
- }
- AddOneConn();
- }
- void CDBServerDlg::RestoreHQ()
- {
- CString sql;
- CDatabase *pMaindb = NULL;
- ODBCConnGuard ConnGuard(pMaindb, -1, 3000);
- if ( pMaindb == NULL )
- return;
- DWORD ii = 0;
- CArray<CStringArray, CStringArray>g_List1array;
- {
- CRecordset myset(pMaindb);
- CString sql = "select count(*) as cot from dindan";
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- g_List1array.SetSize(count, 1);
- CRstDindanForm rsSt;
- rsSt.m_pDatabase = pMaindb;
- rsSt.Open();
- ii = 0;
- while (!rsSt.IsEOF())
- {
- g_List1array.ElementAt(ii).RemoveAll();
- g_List1array.ElementAt(ii).Add(rsSt.id);
- ii++;
- rsSt.MoveNext(); if (g_List1array.GetSize() <= ii)break;
- }
- rsSt.Close(); g_List1array.SetSize(ii, 1);
- }
- for (int i = 0; i < g_List1array.GetSize(); i++)
- {
-
-
-
- sql.Format("SELECT distinct [name],[count] FROM [dbo].[dindansp2] where id='%s' and name in(select spname from shangpin where splb='婚庆服务')", g_List1array.ElementAt(i).ElementAt(0));
- CRecordset myset(pMaindb);
- myset.Open(CRecordset::forwardOnly, sql);
- CStringArray namearray;
- CStringArray countarray;
- while (!myset.IsEOF())
- {
- sql = "";
- myset.GetFieldValue("name", sql);
- namearray.Add(sql);
- sql = "";
- myset.GetFieldValue("count", sql);
- countarray.Add(sql);
- myset.MoveNext();
- }
- myset.Close();
- for (int j = 0; j < namearray.GetSize(); j++)
- {
- CString spid, spjiage2;
-
-
-
- sql.Format("SELECT [spid],[spjiage2] FROM [dbo].[shangpin] where spname='%s'", namearray.ElementAt(j));
-
- CRecordset myset(pMaindb);
- myset.Open(CRecordset::forwardOnly, sql);
- if (!myset.IsEOF())
- {
- myset.GetFieldValue("spid", spid);
- myset.GetFieldValue("spjiage2", spjiage2);
- }
- myset.Close();
-
-
- sql.Format("SELECT count(*) as cot FROM [dbo].[dindansp] where name='%s' and id='%s' and kind='2'", namearray.ElementAt(j), g_List1array.ElementAt(i).ElementAt(0));
- myset.Open(CRecordset::forwardOnly, sql);
- sql = "";
- if (!myset.IsEOF())
- {
- myset.GetFieldValue("cot", sql);
- }
- myset.Close();
- if (atoi(sql))continue;
- sql.Format("insert into [dindansp]([id],[name],[shuliang],[price],[spid],[kind])values('%s','%s','%s','%s','%s','%s')",
- g_List1array.ElementAt(i).ElementAt(0), namearray.ElementAt(j), countarray.ElementAt(j), spjiage2, spid, "2");
-
- pMaindb->ExecuteSQL(sql);
- }
- }
- }
- void CDBServerDlg::ManagePhoto()
- {
-
-
- ShowPic3 dlg;
- dlg.DoModal();
- }
- void CDBServerDlg::GenYLGL()
- {
-
- CString autorunpath = g_mainpath + "\\YLGL.exe";
- ::DeleteFile(autorunpath);
- WriteTextLog("命令行启动:" + autorunpath);
-
- CDatabase *pdb = NULL;
- ODBCConnGuard ConnGuard(pdb, -1, 3000);
- if ( pdb = NULL )
- return;
- CRstUpdate rsSt;
- rsSt.m_pDatabase = pdb;
- rsSt.Open();
- if (!rsSt.IsEOF())
- {
- CFile fp;
- if (fp.Open(autorunpath, CFile::modeCreate | CFile::modeWrite))
- {
- void *pData = GlobalLock(rsSt.data.m_hData);
- fp.Write(pData, rsSt.data.m_dwDataLength);
- fp.Close();
- GlobalUnlock(rsSt.data.m_hData);
- }
- }
- rsSt.Close();
-
- ShellExecute(NULL, _T("open"), autorunpath, "genbranchdata", NULL, SW_HIDE);
- }
- unsigned int CDBServerDlg::CheckSvcWork(LPVOID LPARAM)
- {
- CDBServerDlg* p = (CDBServerDlg*)LPARAM;
- if(p != NULL)
- {
- while(1)
- {
-
- int nRet = WaitForSingleObject(p->m_hWaitTimeOut, 60*60*1000);
- if(nRet != WAIT_OBJECT_0 && nRet != WAIT_TIMEOUT)
- {
- WriteTextLog(_T("检测服务3错误:%d\n"), GetLastError());
- break;
- }
- if(WaitForSingleObject(p->m_hExitCheckSvc, 0) == WAIT_OBJECT_0)
- break;
- CString strPath = _T("");
- DWORD dwID = 0;
-
- dwID = FindAppProcessID(_T("lyfzBackupSvc.exe"));
- if(dwID == 0)
- {
- strPath = g_mainpath + _T("\\lyfzBackupSvc.exe");
- CString strCmd = _T("/startsvc");
- SHELLEXECUTEINFO execinfo;
- memset(&execinfo, 0, sizeof(execinfo));
- execinfo.lpFile = strPath;
- execinfo.cbSize = sizeof(execinfo);
- execinfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
- execinfo.nShow = SW_HIDE;
- execinfo.lpParameters = strCmd;
- if(!ShellExecuteEx(&execinfo))
- {
- CString strError = _T("");
- strError.Format(_T("检测服务1错误:%d\n"), GetLastError());
- OutputDebugString(strError);
- }
-
- }
-
- dwID = FindAppProcessID(_T("lyfzDeletePhotoSvc.exe"));
- if(dwID == 0)
- {
- strPath = g_mainpath + _T("\\lyfzDeletePhotoSvc.exe");
- CString strCmd = _T("/startsvc");
- SHELLEXECUTEINFO execinfo;
- memset(&execinfo, 0, sizeof(execinfo));
- execinfo.lpFile = strPath;
- execinfo.cbSize = sizeof(execinfo);
- execinfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
- execinfo.nShow = SW_HIDE;
- execinfo.lpParameters = strCmd;
- if(!ShellExecuteEx(&execinfo))
- {
- WriteTextLog(_T("检测服务2错误:%d\n"), GetLastError());
- }
-
- }
- }
- }
- _endthreadex(0);
- return 0;
- }
- void CDBServerDlg::TerminateCheckWork()
- {
- if(m_hExitCheckSvc)
- SetEvent(m_hExitCheckSvc);
- if(m_hWaitTimeOut)
- SetEvent(m_hWaitTimeOut);
- if(m_hCheckSvcThread)
- {
- WaitForSingleObject(m_hCheckSvcThread, INFINITE);
- CloseHandle(m_hCheckSvcThread);
- }
- m_hCheckSvcThread = NULL;
- if(m_hExitCheckSvc)
- CloseHandle(m_hExitCheckSvc);
- m_hExitCheckSvc = NULL;
- if(m_hWaitTimeOut)
- CloseHandle(m_hWaitTimeOut);
- m_hWaitTimeOut = NULL;
- m_bStartCheckSvc = FALSE;
- }
- void CDBServerDlg::OnStartBackupSvc()
- {
- StartSvc(_T("lyfzBackupSvc.exe"));
- }
- void CDBServerDlg::OnStopBackupSvc()
- {
- StopSvc(_T("lyfz Backup Service"));
- }
- void CDBServerDlg::OnStartDelPhotoSvc()
- {
- StartSvc(_T("lyfzDeletePhotoSvc.exe"));
- }
- void CDBServerDlg::OnStopDelPhotoSvc()
- {
- StopSvc(_T("lyfz Delete Photo Service"));
- }
- int CDBServerDlg::StartSvc( IN LPCSTR lpExeFile)
- {
- CString strPath = _T("");
- DWORD dwID = 0;
-
- dwID = FindAppProcessID(lpExeFile);
- if(dwID == 0)
- {
- strPath = g_mainpath + _T("\\");
- strPath += lpExeFile;
- CString strCmd = _T("/startsvc");
- SHELLEXECUTEINFO execinfo;
- memset(&execinfo, 0, sizeof(execinfo));
- execinfo.lpFile = strPath;
- execinfo.cbSize = sizeof(execinfo);
- execinfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
- execinfo.nShow = SW_HIDE;
- execinfo.lpParameters = strCmd;
- if(!ShellExecuteEx(&execinfo))
- {
- CString strError = _T("");
- strError.Format(_T("检测服务%s错误:%d\n"), lpExeFile, GetLastError());
- OutputDebugString(strError);
- }
- }
- return 1;
- }
- int CDBServerDlg::StopSvc(IN LPCSTR lpSvcName)
- {
- CString strError = _T("");
- SC_HANDLE hSCM = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
- if (hSCM == NULL)
- return 0;
- SC_HANDLE hService = ::OpenService(hSCM, lpSvcName, SERVICE_STOP | SERVICE_QUERY_STATUS);
- if (hService == NULL)
- {
- strError.Format(_T("打开%s服务失败:%d"), lpSvcName, GetLastError());
- OutputDebugString(strError);
- ::CloseServiceHandle(hSCM);
- return 0;
- }
- SERVICE_STATUS status;
- if(!::QueryServiceStatus(hService, &status))
- {
- strError.Format(_T("获取%s服务状态失败:%d"), lpSvcName, GetLastError());
- OutputDebugString(strError);
- ::CloseServiceHandle(hService);
- ::CloseServiceHandle(hSCM);
- return 0;
- }
- if(status.dwCurrentState == SERVICE_STOPPED)
- {
- ::CloseServiceHandle(hService);
- ::CloseServiceHandle(hSCM);
- return 1;
- }
- ControlService(hService, SERVICE_CONTROL_STOP, &status);
- DWORD dwStartTime = GetTickCount();
- DWORD dwTimeout = 30*1000;
- while(1)
- {
- Sleep( status.dwWaitHint );
- if(!::QueryServiceStatus(hService, &status))
- {
- strError.Format(_T("获取%s服务状态失败:%d"), lpSvcName, GetLastError());
- OutputDebugString(strError);
- ::CloseServiceHandle(hService);
- ::CloseServiceHandle(hSCM);
- return 0;
- }
- if ( status.dwCurrentState == SERVICE_STOPPED )
- break;
- if ( GetTickCount() - dwStartTime > dwTimeout )
- {
- strError.Format(_T("停止%s服务超时:%d"), lpSvcName, GetLastError());
- OutputDebugString(strError);
- ::CloseServiceHandle(hService);
- ::CloseServiceHandle(hSCM);
- return 0;
- }
- }
- ::CloseServiceHandle(hService);
- ::CloseServiceHandle(hSCM);
- return 1;
- }
- void CDBServerDlg::OnAutoCheckSvc()
- {
- g_bAutoCheckSvc = !g_bAutoCheckSvc;
- CHAR szFile[MAX_PATH + 1] = "";
- wsprintf(szFile, "%s\\ServiceInfo.ini", g_ModulePath);
- OFSTRUCT ofStruct;
- OpenFile(szFile, &ofStruct, OF_EXIST);
- if (ERROR_FILE_NOT_FOUND == GetLastError())
- return;
- CString strValue = _T("");
- strValue.Format(_T("%d"), g_bAutoCheckSvc);
- WritePrivateProfileString(_T("Back"), _T("AutoCheckSvc"), strValue, szFile);
- if(!g_bAutoCheckSvc)
- {
- TerminateCheckWork();
- }
- else
- {
-
- if(!m_bStartCheckSvc)
- {
- m_hExitCheckSvc = CreateEvent(NULL, FALSE, FALSE, NULL);
- m_hWaitTimeOut = CreateEvent(NULL, FALSE, FALSE, NULL);
- SetEvent(m_hWaitTimeOut);
- unsigned int nThreadID = 0;
- m_bStartCheckSvc = TRUE;
- m_hCheckSvcThread = (HANDLE)_beginthreadex(NULL, 0, CheckSvcWork, this, 0, &nThreadID);
- }
- }
- }
|