Mercurial > mercurial > hgweb_searcher03.cgi
annotate src/bprint.cpp @ 22:92188f60323d default tip
Implement Masking function on Preview Dialog.
| author | pyon@macmini |
|---|---|
| date | Sat, 04 Apr 2015 17:23:46 +0900 |
| parents | a2ad87cad48b |
| children |
| rev | line source |
|---|---|
| 2 | 1 // Filename : bprint.cpp |
| 22 | 2 // Last Change: 2015-04-04 11:06:15. |
| 2 | 3 // |
| 4 | |
| 5 #include "bprint.h" | |
| 6 #include "marksheet.h" | |
| 3 | 7 #include "dndfile.h" |
| 2 | 8 #include "db.h" |
| 9 | |
| 10 FrameBatchPrint::FrameBatchPrint( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | |
| 11 : wxDialog( parent, id, title, pos, size, style ) | |
| 12 { | |
| 13 this->SetSizeHints( wxDefaultSize, wxDefaultSize ); | |
| 14 this->SetBackgroundColour( wxColour( wxT("WHEAT") ) ); | |
| 15 | |
| 16 wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL ); | |
| 17 | |
| 18 m_grid = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); | |
| 19 | |
| 20 // Grid | |
| 21 m_grid->CreateGrid( 25, 4 ); | |
| 22 m_grid->EnableEditing( true ); | |
| 23 m_grid->EnableGridLines( true ); | |
| 24 m_grid->EnableDragGridSize( false ); | |
| 25 m_grid->SetMargins( 0, 0 ); | |
| 26 | |
| 27 // Columns | |
| 28 m_grid->EnableDragColMove( false ); | |
| 29 m_grid->EnableDragColSize( true ); | |
| 30 m_grid->SetColLabelSize( 30 ); | |
| 31 m_grid->SetColLabelValue( 0, wxT("被保険者番号") ); | |
| 32 m_grid->SetColLabelValue( 1, wxT("氏名") ); | |
| 33 m_grid->SetColLabelValue( 2, wxT("最新フォルダ") ); | |
| 34 m_grid->SetColLabelValue( 3, wxT("ステータス") ); | |
| 35 m_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); | |
| 36 m_grid->SetColSize( 0, 100 ); | |
| 37 m_grid->SetColSize( 1, 100 ); | |
| 38 m_grid->SetColSize( 2, 220 ); | |
| 8 | 39 m_grid->SetColSize( 3, 90 ); |
| 3 | 40 m_grid->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_ALWAYS ); |
| 2 | 41 |
| 42 // Rows | |
| 43 m_grid->EnableDragRowSize( true ); | |
| 44 m_grid->SetRowLabelSize( 30 ); | |
| 45 m_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); | |
| 46 | |
| 47 // Cell Defaults | |
| 48 m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_CENTRE ); | |
| 49 bSizerTop->Add( m_grid, 1, wxALL|wxEXPAND, 5 ); | |
| 50 | |
| 51 wxBoxSizer* bSizerButton = new wxBoxSizer( wxVERTICAL ); | |
| 52 | |
| 53 bSizerButton->Add( 0, 20, 0, 0, 5 ); | |
| 54 | |
| 55 m_buttonClear = new wxButton( this, ID_BPCLEAR, wxT("クリア"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 56 bSizerButton->Add( m_buttonClear, 0, wxALL, 5 ); | |
| 57 | |
|
12
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
58 m_buttonMaskPrint = new wxButton( this, ID_BPFFMP, wxT("FFMP"), wxDefaultPosition, wxDefaultSize, 0 ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
59 bSizerButton->Add( m_buttonMaskPrint, 0, wxALL, 5 ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
60 |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
61 m_buttonPrint = new wxButton( this, ID_BPPRINT, wxT("一括印刷"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 2 | 62 bSizerButton->Add( m_buttonPrint, 0, wxALL, 5 ); |
|
12
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
63 |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
64 m_buttonLdLog = new wxButton( this, ID_BPLDLOG, wxT("一括印刷ログ"), wxDefaultPosition, wxDefaultSize, 0 ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
65 bSizerButton->Add( m_buttonLdLog, 0, wxALL, 5 ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
66 |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
67 bSizerButton->Add( 0, 20, 0, 0, 5 ); |
| 2 | 68 |
| 69 bSizerButton->Add( 0, 20, 0, 0, 5 ); | |
| 70 | |
| 71 m_buttonClose = new wxButton( this, wxID_CANCEL, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 ); | |
| 72 m_buttonClose->SetDefault(); | |
| 73 bSizerButton->Add( m_buttonClose, 0, wxALL, 5 ); | |
| 74 | |
| 75 bSizerTop->Add( bSizerButton, 0, wxEXPAND, 5 ); | |
| 76 | |
| 77 this->SetSizer( bSizerTop ); | |
| 78 this->Layout(); | |
| 79 | |
| 80 this->Centre( wxBOTH ); | |
| 81 | |
| 3 | 82 this->SetDropTarget( new DnDFile( m_grid ) ); |
| 2 | 83 SetGridReadOnly(); |
| 84 } | |
| 85 | |
| 86 FrameBatchPrint::~FrameBatchPrint() | |
| 87 { | |
| 88 } | |
| 89 | |
| 90 // Event Table | |
| 91 BEGIN_EVENT_TABLE( FrameBatchPrint, wxDialog ) | |
| 92 EVT_GRID_CELL_CHANGING( FrameBatchPrint::OnInput ) | |
| 93 EVT_BUTTON( ID_BPCLEAR, FrameBatchPrint::OnClear ) | |
|
12
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
94 EVT_BUTTON( ID_BPFFMP, FrameBatchPrint::OnMaskPrint ) |
| 2 | 95 EVT_BUTTON( ID_BPPRINT, FrameBatchPrint::OnPrint ) |
|
12
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
96 EVT_BUTTON( ID_BPLDLOG, FrameBatchPrint::OnLoadLog ) |
| 2 | 97 END_EVENT_TABLE() |
| 98 | |
| 99 // Event Handlers & Functions | |
| 100 /* 氏名などを表示 */ | |
| 101 void FrameBatchPrint::OnInput( wxGridEvent& event ) | |
| 102 { | |
| 103 wxString hhsno = event.GetString(); | |
| 104 int r = event.GetRow(); | |
| 105 for ( int c = 1; c < m_grid->GetNumberCols(); c++ ) | |
| 106 m_grid->SetCellValue( r, c, wxEmptyString ); | |
| 107 | |
| 108 wxArrayString info = wxSplit( GetHhsInfoByHhsNo( hhsno ), '_', '\\' ); | |
| 109 wxArrayString path = GetPathByHhsNo( hhsno ); | |
| 110 | |
| 111 if ( info.IsEmpty() ) info.Add( wxEmptyString ); | |
| 112 if ( path.IsEmpty() ) { | |
| 13 | 113 wxMessageBox( wxT("審査会がありません.") ); |
| 2 | 114 path.Add( wxEmptyString ); |
| 115 } | |
| 116 | |
| 117 m_grid->SetCellValue( r, 1, info[0] ); | |
| 118 m_grid->SetCellValue( r, 2, path[0] ); | |
| 119 } | |
| 120 | |
| 121 /* グリッドをクリア */ | |
| 122 void FrameBatchPrint::OnClear( wxCommandEvent& WXUNUSED(event) ) | |
| 123 { | |
| 124 m_grid->ClearGrid(); | |
| 125 } | |
| 126 | |
| 22 | 127 /* CSVファイルから一括読込み */ |
| 128 void FrameBatchPrint::LoadCSV( wxString file ) | |
| 129 { | |
| 130 m_grid->ClearGrid(); | |
| 131 | |
| 132 // ファイルから被保番リストを生成 | |
| 133 wxTextFile csv; | |
| 134 csv.Open( file ); | |
| 135 | |
| 136 wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") ); | |
| 137 wxArrayString hhs; | |
| 138 for ( int n = 0; n < csv.GetLineCount(); n++ ) { | |
| 139 wxString hhsno = csv.GetLine( n ).BeforeFirst( ',', NULL ); | |
| 140 if ( ! reHhs.Matches( hhsno ) ) | |
| 141 continue; | |
| 142 hhs.Add( hhsno ); | |
| 143 } | |
| 144 csv.Close(); | |
| 145 | |
| 146 // | |
| 147 int d = hhs.GetCount() - m_grid->GetNumberRows(); | |
| 148 if ( d > 0 ) | |
| 149 m_grid->AppendRows( d, true ); | |
| 150 | |
| 151 // グリッドに情報を読込み | |
| 152 wxArrayString res = GetHhsInfoAndPathByHhsNoList( hhs ); | |
| 153 for ( int r = 0; r < res.GetCount(); r++ ) { | |
| 154 wxArrayString data = wxSplit( res[r], '_', '\\' ); | |
| 155 m_grid->SetCellValue( r, 0, data[0] ); | |
| 156 m_grid->SetCellValue( r, 1, data[1] ); | |
| 157 m_grid->SetCellValue( r, 2, data[2] ); | |
| 158 } | |
| 159 } | |
| 160 | |
| 2 | 161 /* 一括印刷処理 */ |
| 162 void FrameBatchPrint::OnPrint( wxCommandEvent& WXUNUSED(event) ) | |
| 163 { | |
| 164 wxPrintDialogData pd; | |
| 165 wxPrinter p( &pd ); | |
| 166 p.PrintDialog( NULL ); | |
| 6 | 167 wxArrayString log; |
| 2 | 168 |
| 169 for ( int r = 0; r < m_grid->GetNumberRows(); r++ ) { | |
| 170 wxString path = m_grid->GetCellValue( r, 2 ); | |
| 171 | |
| 172 // 印刷用の html を作成 | |
| 173 if ( path.IsEmpty() ) continue; | |
| 174 | |
| 175 wxDir dir( path ); | |
| 176 if ( !dir.IsOpened() ) return; | |
| 177 | |
| 178 wxString html; | |
|
12
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
179 html = wxT("<html><body>\n"); |
| 2 | 180 |
| 181 wxString file; | |
| 182 bool cout = dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES ); | |
| 4 | 183 bool notyet_mask = true; |
| 2 | 184 int n = 0; |
| 185 wxString tmpdir = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH; | |
| 186 while ( cout ) { | |
| 187 file = path + wxFILE_SEP_PATH + file; | |
| 188 file.Replace( wxFILE_SEP_PATH, wxT("/") ); | |
| 189 wxString tmpjpg = wxString::Format( wxT("%stmp%d.jpg"), tmpdir, n ); | |
| 190 | |
| 5 | 191 if ( notyet_mask && IsMarksheet( file, m_zmin, m_zmax, m_lmin, m_lmax ) ) { // マークシート表面をマスクする |
| 2 | 192 wxImage img_org( file, wxBITMAP_TYPE_JPEG ); |
| 193 int ver = GetMarksheetVersion( file ); | |
| 194 if ( ver == 2 ) { | |
| 195 img_org.SetRGB( m_mask1, 255, 255, 255 ); // cm name | |
| 196 img_org.SetRGB( m_mask2, 255, 255, 255 ); // cm no. | |
| 197 img_org.SetRGB( m_mask3, 255, 255, 255 ); // barcode | |
| 198 } | |
| 199 else { // 古いマークシート ver == 1 | |
| 200 img_org.SetRGB( m_mask1old, 255, 255, 255 ); // cm name | |
| 201 img_org.SetRGB( m_mask2old, 255, 255, 255 ); // cm no. | |
| 202 img_org.SetRGB( m_mask3old, 255, 255, 255 ); // barcode | |
| 203 } | |
| 204 img_org.SaveFile( tmpjpg ); | |
| 8 | 205 notyet_mask = false; |
| 2 | 206 } |
| 207 else { | |
| 208 wxCopyFile( file, tmpjpg, true ); | |
| 209 } | |
| 210 html = html + wxT("<img src=\"") + tmpjpg + wxT("\" width=\"750\" height=\"1060\"/>"); | |
| 21 | 211 html = html + wxT("<div align=right><font size=-2><u>") + m_grid->GetCellValue( r, 0 ) + wxT("</u></font></div>"); |
| 212 | |
| 2 | 213 cout = dir.GetNext( &file ); |
| 214 n++; | |
| 215 } | |
| 216 html = html + wxT("</body></html>"); | |
| 217 | |
| 218 // start printing | |
| 219 wxHtmlPrintout hpout( wxT("Searcher03") ); | |
| 220 hpout.SetMargins( 0, 0, 0, 0, 0 ); | |
| 221 | |
| 222 hpout.SetHtmlText( html, wxEmptyString, false ); | |
| 223 p.Print( NULL, &hpout, false ); | |
| 224 | |
| 8 | 225 wxString pst = wxT("処理済"); |
| 226 wxString logmsg = path; | |
| 227 if ( notyet_mask ) { | |
| 228 pst.Append( wxT(" 非マスク") ); | |
| 229 logmsg.Append( wxT(" not mask") ); | |
| 230 } | |
| 231 m_grid->SetCellValue( r, 3, pst ); | |
| 232 log.Add( logmsg ); | |
| 2 | 233 } |
| 6 | 234 WriteLog( log ); |
| 2 | 235 } |
| 236 | |
|
12
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
237 /* 一枚目強制マスク印刷 */ |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
238 void FrameBatchPrint::OnMaskPrint( wxCommandEvent& WXUNUSED(event) ) |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
239 { |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
240 wxArrayInt rows = m_grid->GetSelectedRows(); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
241 if ( rows.GetCount() != 1 ) { |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
242 wxMessageDialog md( this, wxT("1件のみ選択してください."), wxT("Message"), wxOK|wxICON_INFORMATION ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
243 md.ShowModal(); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
244 return; |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
245 } |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
246 |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
247 wxString path = m_grid->GetCellValue( rows[0], 2 ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
248 wxDir dir( path ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
249 if ( !dir.IsOpened() ) return; |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
250 |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
251 wxPrintDialogData pd; |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
252 wxPrinter p( &pd ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
253 p.PrintDialog( NULL ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
254 |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
255 // 印刷用の html を作成 |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
256 wxString file; |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
257 if ( dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES ) ) { |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
258 wxString tmpdir = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH; |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
259 file = path + wxFILE_SEP_PATH + file; |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
260 file.Replace( wxFILE_SEP_PATH, wxT("/") ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
261 wxString tmpjpg = wxString::Format( wxT("%stmp.jpg"), tmpdir ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
262 |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
263 wxImage img_org( file, wxBITMAP_TYPE_JPEG ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
264 img_org.SetRGB( m_mask1, 255, 255, 255 ); // cm name |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
265 img_org.SetRGB( m_mask2, 255, 255, 255 ); // cm no. |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
266 img_org.SetRGB( m_mask3, 255, 255, 255 ); // barcode |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
267 img_org.SaveFile( tmpjpg ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
268 |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
269 wxString html; |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
270 html = wxT("<html><body>\n"); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
271 html = html + wxT("<img src=\"") + tmpjpg + wxT("\" width=\"750\" height=\"1060\"/>"); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
272 html = html + wxT("</body></html>"); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
273 |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
274 // start printing |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
275 wxHtmlPrintout hpout( wxT("Searcher03") ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
276 hpout.SetMargins( 0, 0, 0, 0, 0 ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
277 hpout.SetHtmlText( html, wxEmptyString, false ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
278 p.Print( NULL, &hpout, false ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
279 } |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
280 } |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
281 |
| 2 | 282 /* 入力禁止 */ |
| 283 void FrameBatchPrint::SetGridReadOnly( void ) | |
| 284 { | |
| 285 for ( int r = 0; r < m_grid->GetNumberRows(); r++ ) | |
| 286 for ( int c = 1; c < m_grid->GetNumberCols(); c++ ) | |
| 287 m_grid->SetReadOnly( r, c, true ); | |
| 288 } | |
| 289 | |
|
12
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
290 /* 印刷ログ表示 */ |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
291 void FrameBatchPrint::OnLoadLog( wxCommandEvent& WXUNUSED(event) ) |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
292 { |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
293 wxFileDialog fd( this, wxT("Choose a file"), wxT("log"), wxEmptyString, wxT("log files (*.log)|bp_*.log"), wxFD_OPEN|wxFD_FILE_MUST_EXIST ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
294 if ( fd.ShowModal() == wxID_CANCEL ) |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
295 return; |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
296 |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
297 m_grid->ClearGrid(); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
298 |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
299 wxTextFile logfile; |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
300 logfile.Open( fd.GetPath() ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
301 |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
302 // |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
303 int d = logfile.GetLineCount() - m_grid->GetNumberRows(); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
304 if ( d > 0 ) |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
305 m_grid->AppendRows( d, true ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
306 |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
307 wxArrayString hhsno; |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
308 wxString hhs, path, stat; |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
309 for ( int n = 0; n < logfile.GetLineCount(); n++ ) { |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
310 hhs = logfile[n].AfterLast( wxFILE_SEP_PATH ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
311 stat = hhs.AfterFirst( ' ' ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
312 hhs = hhs.BeforeFirst( ' ' ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
313 path = logfile[n]; |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
314 if ( !stat.IsEmpty() ) { |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
315 path = path.BeforeFirst( ' ' ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
316 } |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
317 m_grid->SetCellValue( n, 0, hhs ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
318 m_grid->SetCellValue( n, 2, path ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
319 m_grid->SetCellValue( n, 3, stat ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
320 hhsno.Add( hhs ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
321 } |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
322 for ( int n = 0; n < hhsno.GetCount(); n++ ) { |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
323 wxArrayString info = wxSplit( GetHhsInfoByHhsNo( hhsno[n] ), '_', '\\' ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
324 m_grid->SetCellValue( n, 1, info[0] ); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
325 } |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
326 logfile.Close(); |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
327 } |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
328 |
|
52958cd4a073
Implement Force Mask button in Batch Print Mode.
pyon@macmini
parents:
8
diff
changeset
|
329 /* 印刷ログ出力 */ |
| 6 | 330 void FrameBatchPrint::WriteLog( wxArrayString logline ) |
| 331 { | |
| 332 wxDateTime now = wxDateTime::Now(); | |
| 333 wxString log_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("log") + wxFILE_SEP_PATH + wxT("bp_") + now.Format( wxT("%Y%m%d%H%M%S.log") ); | |
| 334 wxTextFile file( log_file ); | |
| 335 file.Create(); | |
| 336 wxTextFile logfile; | |
| 337 logfile.Open( log_file ); | |
| 2 | 338 |
| 6 | 339 for ( int n = 0; n < logline.GetCount(); n++ ) { |
| 340 logfile.AddLine( logline[n] ); | |
| 341 } | |
| 342 logfile.Write(); | |
| 343 logfile.Close(); | |
| 344 } | |
| 345 |
