comparison src/myframe.cpp @ 21:eb3f5c7c990f

small changes.
author pyon@macmini
date Mon, 25 Jul 2011 05:20:55 +0900
parents b67c74848dd0
children 05f76f9f9186
comparison
equal deleted inserted replaced
20:39f9f1c7618c 21:eb3f5c7c990f
1 // Filename : mainframe.cpp 1 // Filename : mainframe.cpp
2 // Last Change: 06-Jul-2011. 2 // Last Change: 22-Jul-2011.
3 // 3 //
4 #include "wx/html/htmprint.h" 4 #include "wx/html/htmprint.h"
5 #include "wx/print.h" 5 #include "wx/print.h"
6 6
7 #include "symbol.h" 7 #include "symbol.h"
8 #include "common.h" 8 #include "common.h"
9 #include "myframe.h" 9 #include "myframe.h"
10 #include "ccnframe.h"
10 #include "hhsdb.h" 11 #include "hhsdb.h"
11 #include "htmlhelp.h" 12 #include "htmlhelp.h"
12 #include "main.h" 13 #include "main.h"
13 #include "wx/wxsqlite3.h" 14 #include "wx/wxsqlite3.h"
14 15
712 */ 713 */
713 714
714 /* インデックス作成 */ 715 /* インデックス作成 */
715 void MyFrame::OnMkIndex(wxCommandEvent& WXUNUSED(event)) 716 void MyFrame::OnMkIndex(wxCommandEvent& WXUNUSED(event))
716 { 717 {
717 wxDateTime dt = m_datePicker->GetValue(); 718 FrameHhsDB *f = (FrameHhsDB*)FindWindowById( ID_HHSDB );
718 wxString month = dt.Format(wxT("%m")); 719
719 wxString year = dt.Format(wxT("%Y")); 720 if ( f == NULL ) {
720 if ( month.IsSameAs(wxT("01")) || month.IsSameAs(wxT("02")) || month.IsSameAs(wxT("03")) ) { 721 FrameHhsDB *hhsdb = new FrameHhsDB( this, ID_HHSDB );
721 long y; 722 hhsdb->Show(true);
722 year.ToLong( &y, 10 ); 723 }
723 y--; 724 else {
724 year = wxString::Format(wxT("%d"),y); 725 f->Raise();
725 } 726 }
726 wxString pathroot = wxGetApp().rootdir + wxFILE_SEP_PATH + year + dt.Format(wxT("\\%Y%m%d")); 727 return;
727 wxDir rootd(pathroot);
728 if ( !wxDir::Exists(pathroot) ) {
729 wxMessageBox( wxT("フォルダが存在しません.")+pathroot );
730 return;
731 }
732
733 wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 200, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
734 pd.SetSize( wxSize(320,140) );
735 int count=0;
736
737 wxString ccndir;
738 bool cont = rootd.GetFirst( &ccndir, wxT("*.*"), wxDIR_DIRS );
739 while ( cont ) {
740 wxString gszFile = wxGetCwd() + wxT("/db/ccn.db");
741 wxSQLite3Database ccndb;
742 ccndb.Open( gszFile );
743
744 wxSQLite3Statement stmt = ccndb.PrepareStatement("INSERT OR REPLACE INTO ccn VALUES( ?, datetime('now','localtime') )");
745 stmt.Bind( 1, dt.Format(wxT("%Y-%m-%d")) );
746 stmt.ExecuteQuery();
747
748 stmt.Finalize();
749
750 wxDir ccnd( pathroot + wxFILE_SEP_PATH + ccndir );
751 if ( !ccnd.IsOpened() ) return;
752 wxString hhsdir;
753 bool c = ccnd.GetFirst( &hhsdir, wxT("*.*"), wxDIR_DIRS );
754 wxRegEx reHhs(wxT("^0[1238][0-9]{8}$")); // 被保番チェック
755 while ( c ) {
756 if ( reHhs.Matches(hhsdir) ) {
757 wxString path = pathroot + wxFILE_SEP_PATH + ccndir + wxFILE_SEP_PATH + hhsdir;
758
759 stmt = ccndb.PrepareStatement("INSERT OR REPLACE INTO path VALUES( ?, ? )");
760 stmt.Bind( 1, hhsdir );
761 stmt.Bind( 2, path );
762 stmt.ExecuteQuery();
763
764 stmt.Finalize();
765 }
766 c = ccnd.GetNext(&hhsdir);
767 pd.Update( count++, hhsdir+wxT("@")+ccndir+wxT("を処理しました.") );
768 }
769 ccndb.Close();
770
771 cont = rootd.GetNext(&ccndir);
772 }
773 wxMessageBox(wxT("インデックス作成が終了しました."));
774 } 728 }
775 729
776 /* インデックス更新一覧 */ 730 /* インデックス更新一覧 */
777 void MyFrame::OnListCcn(wxCommandEvent& WXUNUSED(event)) 731 void MyFrame::OnListCcn(wxCommandEvent& WXUNUSED(event))
778 { 732 {