Mercurial > mercurial > hgweb_searcher2.cgi
comparison src/ccnframe.cpp @ 21:eb3f5c7c990f
small changes.
| author | pyon@macmini |
|---|---|
| date | Mon, 25 Jul 2011 05:20:55 +0900 |
| parents | 710be7b6a873 |
| children | 05f76f9f9186 |
comparison
equal
deleted
inserted
replaced
| 20:39f9f1c7618c | 21:eb3f5c7c990f |
|---|---|
| 1 // Filename : ccnframe.cpp | 1 // Filename : ccnframe.cpp |
| 2 // Last Change: 18-Jul-2011. | 2 // Last Change: 23-Jul-2011. |
| 3 // | 3 // |
| 4 | 4 |
| 5 #include "common.h" | 5 #include "common.h" |
| 6 #include "main.h" | |
| 6 #include "ccnframe.h" | 7 #include "ccnframe.h" |
| 8 #include "wx/wxsqlite3.h" | |
| 7 | 9 |
| 8 FrameCcn::FrameCcn( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | 10 FrameCcn::FrameCcn( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) |
| 9 : wxFrame( parent, id, title, pos, size, style ) | 11 : wxFrame( parent, id, title, pos, size, style ) |
| 10 { | 12 { |
| 11 this->SetSizeHints( wxDefaultSize, wxDefaultSize ); | 13 this->SetSizeHints( wxDefaultSize, wxDefaultSize ); |
| 29 fgSizer->Add( 0, 0, 1, wxEXPAND, 5 ); | 31 fgSizer->Add( 0, 0, 1, wxEXPAND, 5 ); |
| 30 | 32 |
| 31 m_staticText3 = new wxStaticText( m_Panel, wxID_ANY, wxT("被保険者"), wxDefaultPosition, wxDefaultSize, 0 ); | 33 m_staticText3 = new wxStaticText( m_Panel, wxID_ANY, wxT("被保険者"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 32 fgSizer->Add( m_staticText3, 0, wxALL, 5 ); | 34 fgSizer->Add( m_staticText3, 0, wxALL, 5 ); |
| 33 | 35 |
| 34 m_listCtrlYmd = new wxListCtrl( m_Panel, ID_YMD, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL ); | 36 m_listCtrlYmd = new wxListCtrl( m_Panel, ID_YMD, wxDefaultPosition, wxSize( 220, -1 ), wxLC_REPORT|wxLC_SINGLE_SEL ); |
| 35 fgSizer->Add( m_listCtrlYmd, 1, wxALL|wxEXPAND, 5 ); | 37 fgSizer->Add( m_listCtrlYmd, 1, wxALL|wxEXPAND, 5 ); |
| 36 | 38 |
| 37 m_staticText4 = new wxStaticText( m_Panel, wxID_ANY, wxT("→"), wxDefaultPosition, wxDefaultSize, 0 ); | 39 m_staticText4 = new wxStaticText( m_Panel, wxID_ANY, wxT("→"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 38 fgSizer->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); | 40 fgSizer->Add( m_staticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); |
| 39 | 41 |
| 40 m_listCtrlCcn = new wxListCtrl( m_Panel, ID_CCN, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL ); | 42 m_listCtrlCcn = new wxListCtrl( m_Panel, ID_CCN, wxDefaultPosition, wxSize( 220, -1 ), wxLC_REPORT|wxLC_SINGLE_SEL ); |
| 41 fgSizer->Add( m_listCtrlCcn, 1, wxALL|wxEXPAND, 5 ); | 43 fgSizer->Add( m_listCtrlCcn, 1, wxALL|wxEXPAND, 5 ); |
| 42 | 44 |
| 43 m_staticText5 = new wxStaticText( m_Panel, wxID_ANY, wxT("→"), wxDefaultPosition, wxDefaultSize, 0 ); | 45 m_staticText5 = new wxStaticText( m_Panel, wxID_ANY, wxT("→"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 44 fgSizer->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); | 46 fgSizer->Add( m_staticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); |
| 45 | 47 |
| 46 m_listCtrlHhs = new wxListCtrl( m_Panel, ID_HHS, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL ); | 48 m_listCtrlHhs = new wxListCtrl( m_Panel, ID_HHS, wxDefaultPosition, wxSize( 220, -1 ), wxLC_REPORT|wxLC_SINGLE_SEL ); |
| 47 fgSizer->Add( m_listCtrlHhs, 1, wxALL|wxEXPAND, 5 ); | 49 fgSizer->Add( m_listCtrlHhs, 1, wxALL|wxEXPAND, 5 ); |
| 48 | 50 |
| 49 bSizer->Add( fgSizer, 1, wxEXPAND, 5 ); | 51 bSizer->Add( fgSizer, 1, wxEXPAND|wxALL, 5 ); |
| 50 | 52 |
| 51 // Index作成 | 53 // Index作成 |
| 52 wxGridBagSizer* gbSizer = new wxGridBagSizer( 0, 0 ); | 54 wxGridBagSizer* gbSizer = new wxGridBagSizer( 0, 0 ); |
| 53 gbSizer->SetFlexibleDirection( wxVERTICAL ); | 55 gbSizer->SetFlexibleDirection( wxVERTICAL ); |
| 54 gbSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); | 56 gbSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); |
| 58 gbSizer->Add( m_btnPrevThu, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 ); | 60 gbSizer->Add( m_btnPrevThu, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 ); |
| 59 | 61 |
| 60 m_btnNextThu = new wxButton( m_Panel, ID_NXTTHU, wxT("次木 >>"), wxDefaultPosition, wxDefaultSize, 0 ); | 62 m_btnNextThu = new wxButton( m_Panel, ID_NXTTHU, wxT("次木 >>"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 61 gbSizer->Add( m_btnNextThu, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 ); | 63 gbSizer->Add( m_btnNextThu, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 ); |
| 62 | 64 |
| 63 m_datePicker = new wxDatePickerCtrl( m_Panel, ID_DTPICKER, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT|wxDP_SHOWCENTURY ); | 65 m_datePicker = new wxDatePickerCtrl( m_Panel, ID_DTPICKER, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DROPDOWN|wxDP_SHOWCENTURY ); |
| 64 gbSizer->Add( m_datePicker, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER|wxALL, 5 ); | 66 gbSizer->Add( m_datePicker, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER|wxALL, 5 ); |
| 65 | 67 |
| 66 m_btnMkIdX = new wxButton( m_Panel, ID_MKIDX, wxT("作成"), wxDefaultPosition, wxDefaultSize, 0 ); | 68 m_btnMkIdX = new wxButton( m_Panel, ID_MKIDX, wxT("作成"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 67 gbSizer->Add( m_btnMkIdX, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 ); | 69 gbSizer->Add( m_btnMkIdX, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 ); |
| 68 | 70 |
| 69 m_btnClose = new wxButton( m_Panel, ID_CLOSE, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 ); | 71 m_btnClose = new wxButton( m_Panel, ID_CLOSE, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 70 gbSizer->Add( m_btnClose, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_BOTTOM|wxALL, 5 ); | 72 gbSizer->Add( m_btnClose, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_BOTTOM|wxALL, 5 ); |
| 71 | 73 |
| 72 bSizer->Add( gbSizer, 0, wxEXPAND, 5 ); | 74 bSizer->Add( gbSizer, 0, wxEXPAND|wxALL, 5 ); |
| 73 | 75 |
| 74 m_Panel->SetSizer( bSizer ); | 76 m_Panel->SetSizer( bSizer ); |
| 75 m_Panel->Layout(); | 77 m_Panel->Layout(); |
| 76 | 78 |
| 79 this->SetSize( 1000, 400 ); | |
| 77 this->Centre( wxBOTH ); | 80 this->Centre( wxBOTH ); |
| 78 InitListCtrl(); | 81 InitListCtrl(); |
| 79 } | 82 } |
| 80 | 83 |
| 81 // Destructor | 84 // Destructor |
| 83 { | 86 { |
| 84 } | 87 } |
| 85 | 88 |
| 86 // Event Table | 89 // Event Table |
| 87 BEGIN_EVENT_TABLE( FrameCcn, wxFrame ) | 90 BEGIN_EVENT_TABLE( FrameCcn, wxFrame ) |
| 88 //EVT_TEXT_ENTER( ID_CMD, MyCmdBox::OnCmd ) | 91 EVT_LIST_ITEM_SELECTED( ID_YMD, FrameCcn::OnSelectYmd ) |
| 92 EVT_LIST_ITEM_SELECTED( ID_CCN, FrameCcn::OnSelectCcn ) | |
| 93 EVT_BUTTON( ID_PRVTHU, FrameCcn::OnPrevThu ) | |
| 94 EVT_BUTTON( ID_NXTTHU, FrameCcn::OnNextThu ) | |
| 95 EVT_BUTTON( ID_MKIDX, FrameCcn::OnMkIndex ) | |
| 96 EVT_BUTTON( ID_CLOSE, FrameCcn::OnClose ) | |
| 89 END_EVENT_TABLE() | 97 END_EVENT_TABLE() |
| 90 | 98 |
| 91 // Event Handlers | 99 // Event Handlers |
| 100 void FrameCcn::OnSelectYmd(wxListEvent& WXUNUSED(event)) | |
| 101 { | |
| 102 m_listCtrlCcn->DeleteAllItems(); | |
| 103 | |
| 104 wxString gszFile = wxGetCwd() + wxT("/db/ccn.db"); | |
| 105 wxSQLite3Database ccndb; | |
| 106 ccndb.Open( gszFile ); | |
| 107 | |
| 108 wxSQLite3Statement stmt = ccndb.PrepareStatement("SELECT path FROM path WHERE hhsno = ?"); | |
| 109 stmt.Bind( 1, wxT("0300012345") ); | |
| 110 wxSQLite3ResultSet q = stmt.ExecuteQuery(); | |
| 111 if ( q.IsNull(0) ) { | |
| 112 return; | |
| 113 } | |
| 114 long r=0; | |
| 115 while ( q.NextRow() ) { | |
| 116 wxString ccn = q.GetString(0); | |
| 117 //wxString cnt = q.GetString(1); | |
| 118 m_listCtrlCcn->InsertItem( r, ccn ); | |
| 119 //m_listCtrlCcn->SetItem( r, 1, cnt, -1 ); | |
| 120 r++; | |
| 121 } | |
| 122 stmt.Finalize(); | |
| 123 ccndb.Close(); | |
| 124 } | |
| 125 | |
| 126 void FrameCcn::OnSelectCcn(wxListEvent& WXUNUSED(event)) | |
| 127 { | |
| 128 m_listCtrlHhs->DeleteAllItems(); | |
| 129 | |
| 130 wxString gszFile = wxGetCwd() + wxT("/db/ccn.db"); | |
| 131 wxSQLite3Database ccndb; | |
| 132 ccndb.Open( gszFile ); | |
| 133 | |
| 134 wxSQLite3Statement stmt = ccndb.PrepareStatement("SELECT ymd, MAX(time) FROM ccn GROUP BY ymd ORDER BY ymd DESC, time DESC"); | |
| 135 wxSQLite3ResultSet q = stmt.ExecuteQuery(); | |
| 136 long r=0; | |
| 137 while ( q.NextRow() ) { | |
| 138 wxString ymd = q.GetString(0); | |
| 139 wxString time = q.GetString(1); | |
| 140 m_listCtrlHhs->InsertItem( r, wxEmptyString ); | |
| 141 m_listCtrlHhs->SetItemText( r, ymd ); | |
| 142 r++; | |
| 143 } | |
| 144 | |
| 145 stmt.Finalize(); | |
| 146 ccndb.Close(); | |
| 147 } | |
| 148 | |
| 149 // 前木 | |
| 150 void FrameCcn::OnPrevThu(wxCommandEvent& WXUNUSED(event)) | |
| 151 { | |
| 152 wxDateTime dt = m_datePicker->GetValue(); | |
| 153 wxDateSpan ds( 0, 0, 0, 1 ); | |
| 154 dt -= ds; | |
| 155 dt.SetToPrevWeekDay( wxDateTime::Thu ); | |
| 156 m_datePicker->SetValue( dt ); | |
| 157 | |
| 158 } | |
| 159 // 次木 | |
| 160 void FrameCcn::OnNextThu(wxCommandEvent& WXUNUSED(event)) | |
| 161 { | |
| 162 wxDateTime dt = m_datePicker->GetValue(); | |
| 163 wxDateSpan ds( 0, 0, 0, 1 ); | |
| 164 dt += ds; | |
| 165 dt.SetToNextWeekDay( wxDateTime::Thu ); | |
| 166 m_datePicker->SetValue( dt ); | |
| 167 } | |
| 168 | |
| 169 /* インデックス作成 */ | |
| 170 void FrameCcn::OnMkIndex(wxCommandEvent& WXUNUSED(event)) | |
| 171 { | |
| 172 wxDateTime dt = m_datePicker->GetValue(); | |
| 173 wxString month = dt.Format(wxT("%m")); | |
| 174 wxString year = dt.Format(wxT("%Y")); | |
| 175 if ( month.IsSameAs(wxT("01")) || month.IsSameAs(wxT("02")) || month.IsSameAs(wxT("03")) ) { | |
| 176 long y; | |
| 177 year.ToLong( &y, 10 ); | |
| 178 y--; | |
| 179 year = wxString::Format(wxT("%d"),y); | |
| 180 } | |
| 181 wxString pathroot = wxGetApp().rootdir + wxFILE_SEP_PATH + year + dt.Format(wxT("\\%Y%m%d")); | |
| 182 wxDir rootd(pathroot); | |
| 183 if ( !wxDir::Exists(pathroot) ) { | |
| 184 wxMessageBox( wxT("フォルダが存在しません.")+pathroot ); | |
| 185 return; | |
| 186 } | |
| 187 | |
| 188 wxProgressDialog pd( wxT("進行状況"), wxT("処理開始..."), 200, this, wxPD_APP_MODAL|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE ); | |
| 189 pd.SetSize( wxSize(320,140) ); | |
| 190 int count=0; | |
| 191 | |
| 192 wxString ccndir; | |
| 193 bool cont = rootd.GetFirst( &ccndir, wxT("*.*"), wxDIR_DIRS ); | |
| 194 while ( cont ) { | |
| 195 wxString gszFile = wxGetCwd() + wxT("/db/ccn.db"); | |
| 196 wxSQLite3Database ccndb; | |
| 197 ccndb.Open( gszFile ); | |
| 198 | |
| 199 wxSQLite3Statement stmt = ccndb.PrepareStatement("INSERT OR REPLACE INTO ccn VALUES( ?, datetime('now','localtime') )"); | |
| 200 stmt.Bind( 1, dt.Format(wxT("%Y-%m-%d")) ); | |
| 201 stmt.ExecuteQuery(); | |
| 202 | |
| 203 stmt.Finalize(); | |
| 204 | |
| 205 wxDir ccnd( pathroot + wxFILE_SEP_PATH + ccndir ); | |
| 206 if ( !ccnd.IsOpened() ) return; | |
| 207 wxString hhsdir; | |
| 208 bool c = ccnd.GetFirst( &hhsdir, wxT("*.*"), wxDIR_DIRS ); | |
| 209 wxRegEx reHhs(wxT("^0[1238][0-9]{8}$")); // 被保番チェック | |
| 210 while ( c ) { | |
| 211 if ( reHhs.Matches(hhsdir) ) { | |
| 212 wxString path = pathroot + wxFILE_SEP_PATH + ccndir + wxFILE_SEP_PATH + hhsdir; | |
| 213 | |
| 214 stmt = ccndb.PrepareStatement("INSERT OR REPLACE INTO path VALUES( ?, ? )"); | |
| 215 stmt.Bind( 1, hhsdir ); | |
| 216 stmt.Bind( 2, path ); | |
| 217 stmt.ExecuteQuery(); | |
| 218 | |
| 219 stmt.Finalize(); | |
| 220 } | |
| 221 c = ccnd.GetNext(&hhsdir); | |
| 222 pd.Update( count++, hhsdir+wxT("@")+ccndir+wxT("を処理しました.") ); | |
| 223 } | |
| 224 ccndb.Close(); | |
| 225 | |
| 226 cont = rootd.GetNext(&ccndir); | |
| 227 } | |
| 228 wxMessageBox(wxT("インデックス作成が終了しました.")); | |
| 229 } | |
| 230 | |
| 231 // 閉じる | |
| 232 void FrameCcn::OnClose(wxCommandEvent& WXUNUSED(event)) | |
| 233 { | |
| 234 this->Close(); | |
| 235 } | |
| 92 | 236 |
| 93 // Functions | 237 // Functions |
| 94 void FrameCcn::InitListCtrl() | 238 void FrameCcn::InitListCtrl() |
| 95 { | 239 { |
| 96 wxListItem itemCol; | 240 wxListItem itemCol; |
| 97 itemCol.SetText( wxT("年-月-日") ); | 241 itemCol.SetText( wxT("年-月-日") ); |
| 98 m_listCtrlYmd->InsertColumn( 0, itemCol ); | 242 m_listCtrlYmd->InsertColumn( 0, itemCol ); |
| 99 m_listCtrlYmd->SetColumnWidth( 0, 100 ); | 243 m_listCtrlYmd->SetColumnWidth( 0, 100 ); |
| 244 itemCol.SetText( wxT("更新時刻") ); | |
| 245 m_listCtrlYmd->InsertColumn( 1, itemCol ); | |
| 246 m_listCtrlYmd->SetColumnWidth( 1, 200 ); | |
| 100 | 247 |
| 101 itemCol.SetText( wxT("合議体名") ); | 248 itemCol.SetText( wxT("合議体名") ); |
| 102 m_listCtrlCcn->InsertColumn( 0, itemCol ); | 249 m_listCtrlCcn->InsertColumn( 0, itemCol ); |
| 103 m_listCtrlCcn->SetColumnWidth( 0, 100 ); | 250 m_listCtrlCcn->SetColumnWidth( 0, 100 ); |
| 104 itemCol.SetText( wxT("件数") ); | 251 itemCol.SetText( wxT("件数") ); |
| 105 m_listCtrlCcn->InsertColumn( 1, itemCol ); | 252 m_listCtrlCcn->InsertColumn( 1, itemCol ); |
| 106 m_listCtrlCcn->SetColumnWidth( 1, 100 ); | 253 m_listCtrlCcn->SetColumnWidth( 1, 100 ); |
| 107 itemCol.SetText( wxT("更新時刻") ); | |
| 108 m_listCtrlCcn->InsertColumn( 2, itemCol ); | |
| 109 m_listCtrlCcn->SetColumnWidth( 2, 100 ); | |
| 110 | 254 |
| 111 itemCol.SetText( wxT("被保険者番号") ); | 255 itemCol.SetText( wxT("被保険者番号") ); |
| 112 m_listCtrlHhs->InsertColumn( 0, itemCol ); | 256 m_listCtrlHhs->InsertColumn( 0, itemCol ); |
| 113 m_listCtrlHhs->SetColumnWidth( 0, 100 ); | 257 m_listCtrlHhs->SetColumnWidth( 0, 100 ); |
| 114 itemCol.SetText( wxT("氏名") ); | 258 itemCol.SetText( wxT("氏名") ); |
| 115 m_listCtrlHhs->InsertColumn( 1, itemCol ); | 259 m_listCtrlHhs->InsertColumn( 1, itemCol ); |
| 116 m_listCtrlHhs->SetColumnWidth( 1, 100 ); | 260 m_listCtrlHhs->SetColumnWidth( 1, 100 ); |
| 117 | 261 |
| 118 m_listCtrlYmd->InsertItem( 0, wxT("aaa") ); | 262 // read from db |
| 119 } | 263 m_listCtrlCcn->DeleteAllItems(); |
| 120 | 264 |
| 265 wxString gszFile = wxGetCwd() + wxT("/db/ccn.db"); | |
| 266 wxSQLite3Database ccndb; | |
| 267 ccndb.Open( gszFile ); | |
| 268 | |
| 269 wxSQLite3Statement stmt = ccndb.PrepareStatement("SELECT ymd, MAX(time) FROM ccn GROUP BY ymd ORDER BY ymd DESC, time DESC"); | |
| 270 wxSQLite3ResultSet q = stmt.ExecuteQuery(); | |
| 271 long r=0; | |
| 272 while ( q.NextRow() ) { | |
| 273 wxString ymd = q.GetString(0); | |
| 274 wxString time = q.GetString(1); | |
| 275 m_listCtrlYmd->InsertItem( r, ymd ); | |
| 276 m_listCtrlYmd->SetItem( r, 1, time, -1 ); | |
| 277 r++; | |
| 278 } | |
| 279 | |
| 280 stmt.Finalize(); | |
| 281 ccndb.Close(); | |
| 282 } | |
| 283 |
