Mercurial > mercurial > hgweb_searcher2.cgi
comparison src/myframe.cpp @ 11:07adad93df84
ver2.9 Add Name-View
| author | pyon@macmini |
|---|---|
| date | Thu, 23 Jun 2011 20:13:34 +0900 |
| parents | 24e0775af32e |
| children | 9452ed888d10 |
comparison
equal
deleted
inserted
replaced
| 10:24e0775af32e | 11:07adad93df84 |
|---|---|
| 1 // Filename : mainframe.cpp | 1 // Filename : mainframe.cpp |
| 2 // Last Change: 22-Jun-2011. | 2 // Last Change: 23-Jun-2011. |
| 3 // | 3 // |
| 4 | 4 |
| 5 #include "symbol.h" | 5 #include "symbol.h" |
| 6 #include "common.h" | 6 #include "common.h" |
| 7 #include "myframe.h" | 7 #include "myframe.h" |
| 161 h->Show(true); | 161 h->Show(true); |
| 162 g->Show(false); | 162 g->Show(false); |
| 163 | 163 |
| 164 wxRegEx reHhs(wxT("^0[1238][0-9]{8}$")); // 1:被保番チェック | 164 wxRegEx reHhs(wxT("^0[1238][0-9]{8}$")); // 1:被保番チェック |
| 165 wxRegEx reCno(wxT("^[0-9]{1,2}$")); // 2:開くフォルダの番号 | 165 wxRegEx reCno(wxT("^[0-9]{1,2}$")); // 2:開くフォルダの番号 |
| 166 wxRegEx rePrint(wxT("^.[0-9]{1,2}$")); // 3:印刷するフォルダの番号 | 166 wxRegEx rePrint(wxT("^\.[0-9]*$")); // 3:印刷するフォルダの番号 |
| 167 | 167 |
| 168 wxString cmd; | 168 wxString cmd; |
| 169 cmd = this->GetLineText(0); | 169 cmd = this->GetLineText(0); |
| 170 int cond = 0; | 170 int cond = 0; |
| 171 if ( reHhs.Matches( cmd ) ) | 171 if ( reHhs.Matches( cmd ) ) |
| 220 hr->LoadPage( wxT("html/notfound.html") ); | 220 hr->LoadPage( wxT("html/notfound.html") ); |
| 221 mf->m_statusBar->SetStatusText( wxT("データが存在しません."), 0 ); | 221 mf->m_statusBar->SetStatusText( wxT("データが存在しません."), 0 ); |
| 222 return; | 222 return; |
| 223 } | 223 } |
| 224 | 224 |
| 225 // HTML 生成 | |
| 226 path.Clear(); | 225 path.Clear(); |
| 227 htmlbody = wxT("<html><body>"); | |
| 228 htmlbody += wxT("該当者: "); | |
| 229 htmlbody += wxT("<b>") + name + wxT("</b>"); | |
| 230 htmlbody += wxT(" ( ") + hhs + wxT(" )"); | |
| 231 htmlbody += wxT("<br /><br />検索結果"); | |
| 232 htmlbody += wxT("<table border=1>"); | |
| 233 htmlbody += wxT("<tr bgcolor=\"#ffcc33\"><th>番号</th><th>日付</th><th>フォルダ</th></tr>"); | |
| 234 | |
| 235 wxRegEx reDate(wxT("(^.*20[0-9]{2}.)(20[0-9]{2})([0-2][0-9])([0-9]{2})(.*$)")); | 226 wxRegEx reDate(wxT("(^.*20[0-9]{2}.)(20[0-9]{2})([0-2][0-9])([0-9]{2})(.*$)")); |
| 236 | 227 |
| 237 int i=1; | 228 int i=1; |
| 238 int clrflg = 1; | 229 int clrflg = -1; |
| 239 while ( q.NextRow() ) { | 230 while ( q.NextRow() ) { |
| 240 wxString filepath; | 231 wxString filepath = q.GetString(0); |
| 241 filepath = q.GetString(0); | |
| 242 // 氏名画像生成 | 232 // 氏名画像生成 |
| 243 if ( 0 ) { | 233 wxDir dir(filepath); |
| 244 wxDir dir(filepath); | 234 wxString file; |
| 245 wxString file; | 235 if ( !dir.IsOpened() ) return; |
| 246 if ( !dir.IsOpened() ) return; | 236 |
| 247 | 237 if ( clrflg == -1 ) { |
| 248 bool cout = dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES ); | 238 bool cout = dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES ); |
| 249 if ( cout ) { | 239 if ( cout ) { |
| 250 wxString s = filepath + wxFILE_SEP_PATH + file; | 240 wxString s = filepath + wxFILE_SEP_PATH + file; |
| 251 wxImage img_org( s, wxBITMAP_TYPE_JPEG ); | 241 wxImage img_org( s, wxBITMAP_TYPE_JPEG ); |
| 252 wxImage img_name; | 242 wxImage img_name; |
| 253 img_name = img_org.GetSubImage( wxRect( wxPoint(328,556), wxSize(626,288) ) ); | 243 img_name = img_org.GetSubImage( wxRect( wxPoint(328,556), wxSize(626,288) ) ); |
| 254 img_name.Scale( 92, 200 ); | 244 img_name = img_name.Scale( 200, 92 ); |
| 255 img_name.SaveFile( wxT("tmp/tmp.jpg") ); | 245 img_name.SaveFile( wxT("tmp/tmp.jpg") ); |
| 246 | |
| 247 // HTML生成 | |
| 248 htmlbody = wxT("<html><body>"); | |
| 249 htmlbody += wxT("<table border=0>"); | |
| 250 htmlbody += wxT("<tr bgcolor=\"#ffffcc\"><td>該当者: </td><td></td></tr>"); | |
| 251 htmlbody += wxT("<tr><td><b>") + name + wxT("</b></td>"); | |
| 252 htmlbody += wxT("<td> ( ") + hhs + wxT(" )") + wxT("</td></tr>"); | |
| 253 htmlbody += wxT("</table><br /><br />"); | |
| 254 htmlbody += wxT("<table border=0>"); | |
| 255 htmlbody += wxT("<tr><td bgcolor=\"#ffffcc\">番号1の画像情報:</td></tr>"); | |
| 256 htmlbody += wxT("<tr><td><img src=\"tmp/tmp.jpg\" /></td></tr>"); | |
| 257 htmlbody += wxT("</table>"); | |
| 258 htmlbody += wxT("<br /><br />検索結果"); | |
| 259 htmlbody += wxT("<table border=1>"); | |
| 260 htmlbody += wxT("<tr bgcolor=\"#ffcc33\"><th>番号</th><th>日付</th><th>フォルダ</th></tr>"); | |
| 256 } | 261 } |
| 257 } | 262 clrflg = 1; |
| 263 } | |
| 258 | 264 |
| 259 path.Add(filepath); | 265 path.Add(filepath); |
| 260 wxString date = filepath; | 266 wxString date = filepath; |
| 261 reDate.ReplaceAll( &date, wxT("\\2-\\3-\\4") ); | 267 reDate.ReplaceAll( &date, wxT("\\2-\\3-\\4") ); |
| 262 | 268 |
| 277 path.Shrink(); | 283 path.Shrink(); |
| 278 | 284 |
| 279 htmlbody += wxT("</table>"); | 285 htmlbody += wxT("</table>"); |
| 280 htmlbody += wxT("<br />"); | 286 htmlbody += wxT("<br />"); |
| 281 htmlbody += wxT("<div>"); | 287 htmlbody += wxT("<div>"); |
| 282 htmlbody += wxT("番号1の画像情報"); | |
| 283 htmlbody += wxT("<img src=\"tmp/name.jpg\" />"); | |
| 284 htmlbody += wxT("</div>"); | |
| 285 htmlbody += wxT("<div>"); | |
| 286 htmlbody += wxT("フォルダを開くには,番号を入力してください.<br />"); | 288 htmlbody += wxT("フォルダを開くには,番号を入力してください.<br />"); |
| 287 htmlbody += wxT("他の被保険者を検索するには,被保番を入力してください."); | 289 htmlbody += wxT("他の被保険者を検索するには,被保番を入力してください."); |
| 288 htmlbody += wxT("</div>"); | 290 htmlbody += wxT("</div>"); |
| 289 htmlbody += wxT("</body></html>"); | 291 htmlbody += wxT("</body></html>"); |
| 290 | 292 |
| 299 cmd.ToLong( &val, 10 ); | 301 cmd.ToLong( &val, 10 ); |
| 300 val--; | 302 val--; |
| 301 if ( path.IsEmpty() | 303 if ( path.IsEmpty() |
| 302 || val < 0 | 304 || val < 0 |
| 303 || val > path.GetCount()-1 ) { | 305 || val > path.GetCount()-1 ) { |
| 304 mf->m_statusBar->SetStatusText( wxT("不適切な入力です."), 0 ); | 306 mf->m_statusBar->SetStatusText( wxT("不適切な入力です.警告コード2"), 0 ); |
| 305 break; | 307 break; |
| 306 } | 308 } |
| 307 wxString execmd = wxT("explorer ") + path[val]; | 309 wxString execmd = wxT("explorer ") + path[val]; |
| 308 wxExecute( execmd ); | 310 wxExecute( execmd ); |
| 309 mf->m_statusBar->SetStatusText( wxEmptyString, 0 ); | 311 mf->m_statusBar->SetStatusText( wxEmptyString, 0 ); |
| 310 | 312 |
| 311 // 検索履歴をログに保存 | 313 // 検索履歴をログに保存 |
| 312 wxString logfn = wxGetCwd() + wxT("/tmp/log.txt"); | 314 wxString logfn = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("log.txt"); |
| 313 wxTextFile logFile; | 315 wxTextFile logFile; |
| 314 logFile.Open( logfn ); | 316 logFile.Open( logfn ); |
| 315 wxDateTime now = wxDateTime::Now(); | 317 wxDateTime now = wxDateTime::Now(); |
| 316 wxString log = now.Format() + wxT(" " ) + cmd + wxT(" ") + path[val]; | 318 wxString log = now.Format() + wxT(" " ) + cmd + wxT(" ") + path[val]; |
| 317 logFile.AddLine( log ); | 319 logFile.AddLine( log ); |
| 320 | 322 |
| 321 break; | 323 break; |
| 322 } | 324 } |
| 323 // ファイル印刷 | 325 // ファイル印刷 |
| 324 case 3: { | 326 case 3: { |
| 327 this->SetSelection( 0, this->GetLastPosition() ); | |
| 328 if ( path.IsEmpty() ) { | |
| 329 mf->m_statusBar->SetStatusText( wxT("不適切な入力です.警告コード3"), 0 ); | |
| 330 break; | |
| 331 } | |
| 332 wxMessageBox(wxT("333")); | |
| 325 break; | 333 break; |
| 326 } | 334 } |
| 327 // 制御用コマンド | 335 // 制御用コマンド |
| 328 case 0: { | 336 case 0: { |
| 329 | 337 |
