Mercurial > mercurial > hgweb_searcher03.cgi
comparison src/update.cpp @ 16:1ba97995f642
Get/Put DB files to shared-directory.
| author | pyon@macmini |
|---|---|
| date | Thu, 19 Jun 2014 18:46:11 +0900 |
| parents | |
| children | 226774bf49fc |
comparison
equal
deleted
inserted
replaced
| 15:de222bc84e48 | 16:1ba97995f642 |
|---|---|
| 1 // Filename : update.cpp | |
| 2 // Last Change: 19-Jun-2014. | |
| 3 | |
| 4 #include "update.h" | |
| 5 | |
| 6 void CheckNewFiles( wxString shared ) | |
| 7 { | |
| 8 // index | |
| 9 wxString cfile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); | |
| 10 wxFileName fn( cfile ); | |
| 11 wxDateTime ct = fn.GetModificationTime(); | |
| 12 | |
| 13 wxString nfile = shared + wxFILE_SEP_PATH + wxT("ccn.db"); | |
| 14 fn.Assign( nfile ); | |
| 15 wxDateTime nt = fn.GetModificationTime(); | |
| 16 | |
| 17 if ( nt - ct > wxTimeSpan::Week() ) { | |
| 18 wxMessageDialog md( NULL, wxT("インデックスが古くなっています.\n新しいインデックスを取得しますか?"), wxT("Information"), wxYES_NO|wxOK_DEFAULT ); | |
| 19 if ( md.ShowModal() == wxID_YES ) { | |
| 20 GetFile( cfile, nfile ); | |
| 21 } | |
| 22 } | |
| 23 else { | |
| 24 if ( ct - nt > wxTimeSpan::Day() ) | |
| 25 PutFile( nfile, cfile ); | |
| 26 } | |
| 27 | |
| 28 // hhs | |
| 29 cfile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("hhs.db"); | |
| 30 fn.Assign( cfile ); | |
| 31 ct = fn.GetModificationTime(); | |
| 32 | |
| 33 nfile = shared + wxFILE_SEP_PATH + wxT("hhs.db"); | |
| 34 fn.Assign( nfile ); | |
| 35 nt = fn.GetModificationTime(); | |
| 36 | |
| 37 if ( nt - ct > wxTimeSpan::Week() ) { | |
| 38 wxMessageDialog md( NULL, wxT("被保険者情報の最新版があります.\n被保険者情報を取得しますか?"), wxT("Information"), wxYES_NO|wxOK_DEFAULT ); | |
| 39 if ( md.ShowModal() == wxID_YES ) { | |
| 40 GetFile( cfile, nfile ); | |
| 41 } | |
| 42 } | |
| 43 else { | |
| 44 if ( ct - nt > wxTimeSpan::Day() ) | |
| 45 PutFile( nfile, cfile ); | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 void GetFile( wxString target, wxString newfile ) | |
| 50 { | |
| 51 wxCopyFile( newfile, target, true ); | |
| 52 wxMessageBox( wxT("アップデート完了.") ); | |
| 53 } | |
| 54 | |
| 55 void PutFile( wxString newfile, wxString target ) | |
| 56 { | |
| 57 wxCopyFile( target, newfile, true ); | |
| 58 } | |
| 59 |
