Mercurial > mercurial > hgweb_searcher03.cgi
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/update.cpp Thu Jun 19 18:46:11 2014 +0900 @@ -0,0 +1,59 @@ +// Filename : update.cpp +// Last Change: 19-Jun-2014. + +#include "update.h" + +void CheckNewFiles( wxString shared ) +{ + // index + wxString cfile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); + wxFileName fn( cfile ); + wxDateTime ct = fn.GetModificationTime(); + + wxString nfile = shared + wxFILE_SEP_PATH + wxT("ccn.db"); + fn.Assign( nfile ); + wxDateTime nt = fn.GetModificationTime(); + + if ( nt - ct > wxTimeSpan::Week() ) { + wxMessageDialog md( NULL, wxT("インデックスが古くなっています.\n新しいインデックスを取得しますか?"), wxT("Information"), wxYES_NO|wxOK_DEFAULT ); + if ( md.ShowModal() == wxID_YES ) { + GetFile( cfile, nfile ); + } + } + else { + if ( ct - nt > wxTimeSpan::Day() ) + PutFile( nfile, cfile ); + } + + // hhs + cfile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("hhs.db"); + fn.Assign( cfile ); + ct = fn.GetModificationTime(); + + nfile = shared + wxFILE_SEP_PATH + wxT("hhs.db"); + fn.Assign( nfile ); + nt = fn.GetModificationTime(); + + if ( nt - ct > wxTimeSpan::Week() ) { + wxMessageDialog md( NULL, wxT("被保険者情報の最新版があります.\n被保険者情報を取得しますか?"), wxT("Information"), wxYES_NO|wxOK_DEFAULT ); + if ( md.ShowModal() == wxID_YES ) { + GetFile( cfile, nfile ); + } + } + else { + if ( ct - nt > wxTimeSpan::Day() ) + PutFile( nfile, cfile ); + } +} + +void GetFile( wxString target, wxString newfile ) +{ + wxCopyFile( newfile, target, true ); + wxMessageBox( wxT("アップデート完了.") ); +} + +void PutFile( wxString newfile, wxString target ) +{ + wxCopyFile( target, newfile, true ); +} +