16
|
1 // Filename : update.cpp
|
20
|
2 // Last Change: 08-Dec-2014.
|
16
|
3
|
|
4 #include "update.h"
|
|
5
|
20
|
6 int CheckNewFiles( wxString shared )
|
16
|
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 );
|
20
|
15 if ( !fn.IsFileReadable() ) {
|
|
16 wxMessageBox( wxT("共有ファイルにアクセスできなかったので終了します。") );
|
|
17 return 1;
|
|
18 }
|
16
|
19 wxDateTime nt = fn.GetModificationTime();
|
|
20
|
|
21 if ( nt - ct > wxTimeSpan::Week() ) {
|
|
22 wxMessageDialog md( NULL, wxT("インデックスが古くなっています.\n新しいインデックスを取得しますか?"), wxT("Information"), wxYES_NO|wxOK_DEFAULT );
|
|
23 if ( md.ShowModal() == wxID_YES ) {
|
|
24 GetFile( cfile, nfile );
|
|
25 }
|
|
26 }
|
|
27 else {
|
|
28 if ( ct - nt > wxTimeSpan::Day() )
|
|
29 PutFile( nfile, cfile );
|
|
30 }
|
|
31
|
|
32 // hhs
|
|
33 cfile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("hhs.db");
|
|
34 fn.Assign( cfile );
|
|
35 ct = fn.GetModificationTime();
|
|
36
|
|
37 nfile = shared + wxFILE_SEP_PATH + wxT("hhs.db");
|
|
38 fn.Assign( nfile );
|
|
39 nt = fn.GetModificationTime();
|
|
40
|
|
41 if ( nt - ct > wxTimeSpan::Week() ) {
|
|
42 wxMessageDialog md( NULL, wxT("被保険者情報の最新版があります.\n被保険者情報を取得しますか?"), wxT("Information"), wxYES_NO|wxOK_DEFAULT );
|
|
43 if ( md.ShowModal() == wxID_YES ) {
|
|
44 GetFile( cfile, nfile );
|
|
45 }
|
|
46 }
|
|
47 else {
|
|
48 if ( ct - nt > wxTimeSpan::Day() )
|
|
49 PutFile( nfile, cfile );
|
|
50 }
|
20
|
51
|
|
52 return 0;
|
16
|
53 }
|
|
54
|
|
55 void GetFile( wxString target, wxString newfile )
|
|
56 {
|
|
57 wxCopyFile( newfile, target, true );
|
|
58 wxMessageBox( wxT("アップデート完了.") );
|
|
59 }
|
|
60
|
|
61 void PutFile( wxString newfile, wxString target )
|
|
62 {
|
|
63 wxCopyFile( target, newfile, true );
|
|
64 }
|
|
65
|