# HG changeset patch # User pyon@macmini # Date 1587476635 -32400 # Node ID 169936fed61be6fd9db469354f4058155cf4a4b9 # Parent 6ec28d3c3e00e2dd3349d6e4203346f9777b1969 small changes. diff -r 6ec28d3c3e00 -r 169936fed61b src/kaigo/horori/horori.fbp --- a/src/kaigo/horori/horori.fbp Sat Apr 18 21:10:29 2020 +0900 +++ b/src/kaigo/horori/horori.fbp Tue Apr 21 22:43:55 2020 +0900 @@ -620,7 +620,7 @@ MoveFrame - 990,1000 + 1114,1000 wxDEFAULT_FRAME_STYLE ; ; forward_declare @@ -1054,6 +1054,7 @@ + OnName @@ -1119,7 +1120,7 @@ 5 - 2 + 1 5 wxALL|wxALIGN_BOTTOM 2 @@ -1186,6 +1187,70 @@ OnHno + + 5 + 1 + 6 + wxALL|wxALIGN_BOTTOM + 2 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + 255,0,0 + 1 + + 0 + 0 + wxID_ANY + > 999999999 + 0 + + 0 + + + 0 + + 1 + m_staticTextHnoMsg + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + 5 6 @@ -1640,7 +1705,7 @@ 5 1 5 - wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL + wxALL|wxALIGN_CENTER_VERTICAL 6 1 @@ -3038,7 +3103,7 @@ - + 0 wxAUI_MGR_DEFAULT 217,217,217 @@ -3066,7 +3131,7 @@ wxTAB_TRAVERSAL 1 OnClose - + wxBOTH @@ -3077,14 +3142,14 @@ wxFLEX_GROWMODE_SPECIFIED none 0 - + 5 1 0 wxEXPAND | wxALL 0 11 - + 1 1 1 @@ -3433,11 +3498,11 @@ wxHSCROLL|wxVSCROLL - + バッチ印刷 1 - + 1 1 1 @@ -3488,7 +3553,7 @@ wxTAB_TRAVERSAL - + wxBOTH @@ -3756,7 +3821,7 @@ - + メンテナンス 0 diff -r 6ec28d3c3e00 -r 169936fed61b src/kaigo/horori/merger/src/merger.cpp --- a/src/kaigo/horori/merger/src/merger.cpp Sat Apr 18 21:10:29 2020 +0900 +++ b/src/kaigo/horori/merger/src/merger.cpp Tue Apr 21 22:43:55 2020 +0900 @@ -1,5 +1,5 @@ // Filename : merger.cpp -// Last Change: 2020-04-16 木 13:50:02. +// Last Change: 2020-04-21 火 11:16:12. // #include #include @@ -324,10 +324,11 @@ void MergeFrame::OnAclS(wxCommandEvent& WXUNUSED(event)) { int r = m_dataViewListCtrlParam->GetSelectedRow(); - if (r == wxNOT_FOUND || r == m_dataViewListCtrlParam->GetItemCount() - 1) - return; + if (r == wxNOT_FOUND) return; MaskLocSet(); + if (r == m_dataViewListCtrlParam->GetItemCount() - 1) return; + m_dataViewListCtrlParam->SelectRow(r + 1); if (r > 3) m_dataViewListCtrlParam->LineDown(); ShowImages(); diff -r 6ec28d3c3e00 -r 169936fed61b src/kaigo/horori/mover/include/mover.h --- a/src/kaigo/horori/mover/include/mover.h Sat Apr 18 21:10:29 2020 +0900 +++ b/src/kaigo/horori/mover/include/mover.h Tue Apr 21 22:43:55 2020 +0900 @@ -1,5 +1,5 @@ // Filename : mover.h -// Last Change: 2020-04-15 12:02:47. +// Last Change: 2020-04-21 11:50:30. // #pragma once @@ -67,6 +67,9 @@ HhsHash m_hhash; wxArrayString m_sss; wxString m_addr, m_port; + int m_offx, m_offy; + wxString m_maxhno; + wxString m_curms; // current marksheet protected: wxDirPickerCtrl* m_dirPicker; @@ -84,6 +87,7 @@ wxStaticBitmap* m_bitmapHno; wxTextCtrl* m_textCtrlHno; + wxStaticText* m_staticTextHnoMsg; wxListView* m_listViewThumb; @@ -101,6 +105,7 @@ virtual void OnAuto(wxCommandEvent& event); virtual void OnListChar(wxKeyEvent& event); virtual void OnSelect(wxDataViewEvent& event); + virtual void OnName(wxCommandEvent& event); virtual void OnHnoChar(wxKeyEvent& event); virtual void OnHno(wxCommandEvent& event); virtual void OnCheck(wxCommandEvent& event); @@ -114,8 +119,10 @@ void LoadDefaultImages(); void LoadDB(); void AutoDetect(); + void SelectItem(int r); void ThumbnailPaper(); - wxString AnalizeHhsno(wxString file); + wxString AnalizeHhsno(wxString file, int offx, int offy); + void MoveLookWin(int x, int y); public: MoveFrame(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL); diff -r 6ec28d3c3e00 -r 169936fed61b src/kaigo/horori/mover/mover.conf --- a/src/kaigo/horori/mover/mover.conf Sat Apr 18 21:10:29 2020 +0900 +++ b/src/kaigo/horori/mover/mover.conf Tue Apr 21 22:43:55 2020 +0900 @@ -20,7 +20,7 @@ mhnov4=596x514+1378+311 [Dirs] -work=C:\\Users\\nintei\\Desktop\\test\\work +work=C:\\Users\\nintei\\Desktop\\nst\\work [Server] addr=192.168.21.163 diff -r 6ec28d3c3e00 -r 169936fed61b src/kaigo/horori/mover/src/mover.cpp --- a/src/kaigo/horori/mover/src/mover.cpp Sat Apr 18 21:10:29 2020 +0900 +++ b/src/kaigo/horori/mover/src/mover.cpp Tue Apr 21 22:43:55 2020 +0900 @@ -1,5 +1,5 @@ // Filename : mover.cpp -// Last Change: 2020-04-15 水 13:04:36. +// Last Change: 2020-04-21 火 17:03:11. // #include #include @@ -21,6 +21,7 @@ m_buttonAuto->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MoveFrame::OnAuto), NULL, this); m_dataViewListCtrl->Connect(wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler(MoveFrame::OnSelect), NULL, this); m_dataViewListCtrl->Connect(wxEVT_CHAR, wxKeyEventHandler(MoveFrame::OnListChar), NULL, this); + m_textCtrlName->Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MoveFrame::OnName), NULL, this); m_textCtrlHno->Connect(wxEVT_CHAR, wxKeyEventHandler(MoveFrame::OnHnoChar), NULL, this); m_textCtrlHno->Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MoveFrame::OnHno), NULL, this); m_checkBox->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(MoveFrame::OnCheck), NULL, this); @@ -36,6 +37,7 @@ m_buttonAuto->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MoveFrame::OnAuto), NULL, this); m_dataViewListCtrl->Disconnect(wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler(MoveFrame::OnSelect), NULL, this); m_dataViewListCtrl->Disconnect(wxEVT_CHAR, wxKeyEventHandler(MoveFrame::OnListChar), NULL, this); + m_textCtrlName->Disconnect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MoveFrame::OnName), NULL, this); m_textCtrlHno->Disconnect(wxEVT_CHAR, wxKeyEventHandler(MoveFrame::OnHnoChar), NULL, this); m_textCtrlHno->Disconnect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MoveFrame::OnHno), NULL, this); m_checkBox->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(MoveFrame::OnCheck), NULL, this); @@ -78,7 +80,7 @@ gbSizer->Add(m_bitmapName, wxGBPosition(1, 1), wxGBSpan(1, 4), wxALL, 5); wxFont font(24, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD); - m_textCtrlName = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(580, -1), 0); + m_textCtrlName = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(580, -1), wxTE_PROCESS_ENTER); m_textCtrlName->SetFont(font); gbSizer->Add(m_textCtrlName, wxGBPosition(1, 5), wxGBSpan(1, 4), wxALL|wxALIGN_BOTTOM, 5); @@ -88,7 +90,12 @@ m_textCtrlHno = new wxTextCtrl(this, wxID_ANY, wxT("0123456789"), wxDefaultPosition, wxSize(200, -1), wxTE_PROCESS_ENTER); m_textCtrlHno->SetMaxLength(10); m_textCtrlHno->SetFont(font); - gbSizer->Add(m_textCtrlHno, wxGBPosition(2, 5), wxGBSpan(1, 4), wxALL|wxALIGN_BOTTOM, 5); + gbSizer->Add(m_textCtrlHno, wxGBPosition(2, 5), wxGBSpan(1, 1), wxALL|wxALIGN_BOTTOM, 5); + + m_staticTextHnoMsg = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); + m_staticTextHnoMsg->SetForegroundColour(wxColour(255, 0, 0)); + m_staticTextHnoMsg->SetFont(font); + gbSizer->Add(m_staticTextHnoMsg, wxGBPosition(2, 6), wxGBSpan(1, 1), wxALL|wxALIGN_BOTTOM, 5); m_bitmapTk = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(RIGHT_W, RIGHT_H1), 0); gbSizer->Add(m_bitmapTk, wxGBPosition(3, 1), wxGBSpan(1, 6), wxALL, 5); @@ -191,6 +198,7 @@ for (int i = 0; i < hhsfile.GetLineCount(); i++) { wxArrayString buf = wxSplit(hhsfile.GetLine(i), ',', '\\'); m_hhash[buf[0]] = wxString::Format(wxT("%s (%s)"), buf[2], buf[3]); + if (m_maxhno.Cmp(buf[0]) < 0) m_maxhno = buf[0]; } hhsfile.Close(); } @@ -201,7 +209,7 @@ wxDir dir(m_dirPicker->GetPath()); if (!dir.IsOpened()) return; - wxString dirname, imagefn; + wxString dirname, fn; bool cont = dir.GetFirst(&dirname, wxEmptyString, wxDIR_DIRS); wxVector data; @@ -211,12 +219,12 @@ wxDir subdir(m_dirPicker->GetPath() + wxFILE_SEP_PATH + dirname); if (!subdir.IsOpened()) return; - subdir.GetFirst(&imagefn, wxT("*.tif"), wxDIR_FILES); - imagefn = m_dirPicker->GetPath() + wxFILE_SEP_PATH + dirname + wxFILE_SEP_PATH + imagefn; - wxString hhsno = AnalizeHhsno(imagefn); + subdir.GetFirst(&fn, wxT("*.tif"), wxDIR_FILES); + fn = m_dirPicker->GetPath() + wxFILE_SEP_PATH + dirname + wxFILE_SEP_PATH + fn; + wxString hno = AnalizeHhsno(fn, 0, 0); - data.push_back(wxVariant(hhsno)); - data.push_back(wxVariant(m_hhash[hhsno])); + data.push_back(wxVariant(hno)); + data.push_back(wxVariant(m_hhash[hno])); //data.push_back(wxVariant(false)); m_dataViewListCtrl->AppendItem(data); @@ -229,6 +237,66 @@ wxMessageBox(wxT("自動認識終了")); } +void MoveFrame::SelectItem(int r) +{ + m_dataViewListCtrl->SelectRow(r); + + m_offx = 0; + m_offy = 0; + m_listViewThumb->DeleteAllItems(); + + wxString dirno = m_dataViewListCtrl->GetTextValue(r, 0); + wxString hno = m_dataViewListCtrl->GetTextValue(r, 1); + wxString hname = m_dataViewListCtrl->GetTextValue(r, 2); + + wxString img_path = m_dirPicker->GetPath() + wxFILE_SEP_PATH + dirno; + wxDir dir(img_path); + if (!dir.IsOpened()) return; + + wxString fn; + bool cont = dir.GetFirst(&fn, wxT("*.tif"), wxDIR_FILES); + + m_curms = img_path + wxFILE_SEP_PATH + fn; + wxImage image(m_curms, wxBITMAP_TYPE_TIFF); + wxImage img_buf; + wxBitmap bmp_buf; + + img_buf = image.GetSubImage(wxRect(HNAME_X, HNAME_Y, HNAME_W, HNAME_H)); + bmp_buf = img_buf.Scale(HNAME_WW, HNAME_WH, wxIMAGE_QUALITY_HIGH); + m_bitmapName->SetBitmap(bmp_buf); + + img_buf = image.GetSubImage(wxRect(HNO_X, HNO_Y, HNO_W, HNO_H)); + bmp_buf = img_buf.Scale(HNO_WW, HNO_WH, wxIMAGE_QUALITY_HIGH); + m_bitmapHno->SetBitmap(bmp_buf); + + m_textCtrlName->SetValue(hname); + m_textCtrlHno->SetValue(hno); + m_staticTextHnoMsg->SetLabel(wxEmptyString); + if (hno.Cmp(m_maxhno) > 0) m_staticTextHnoMsg->SetLabel(wxString::Format(wxT("> %s !"), m_maxhno)); + + wxImageList* imglist = new wxImageList(THUMB_W, THUMB_H); + m_listViewThumb->SetImageList(imglist, wxIMAGE_LIST_NORMAL); + for (int i = 0; cont; i++) { + wxString buf = img_path + wxFILE_SEP_PATH + fn; + wxImage img(buf, wxBITMAP_TYPE_TIFF); + bmp_buf = img.Scale(THUMB_W, THUMB_H, wxIMAGE_QUALITY_HIGH); + imglist->Add(bmp_buf); + m_listViewThumb->InsertItem(i, fn, i); + + if (i == 2) { + wxImage im = img.GetSubImage(wxRect(0, 0, img.GetWidth() - 1, 300)); // 2480x300 + bmp_buf = im.Scale(RIGHT_W, RIGHT_H1, wxIMAGE_QUALITY_HIGH); + m_bitmapTk->SetBitmap(bmp_buf); + } + if (i == 3) { + wxImage im = img.GetSubImage(wxRect(0, 20, img.GetWidth() - 1, 700)); // 2480x500 + bmp_buf = im.Scale(RIGHT_W, RIGHT_H2, wxIMAGE_QUALITY_HIGH); + m_bitmapIk->SetBitmap(bmp_buf); + } + cont = dir.GetNext(&fn); + } +} + void MoveFrame::ThumbnailPaper() { wxString path = m_dirPicker->GetPath(); @@ -256,11 +324,11 @@ wxMessageBox(wxString::Format(wxT("%d files found."), n)); } -wxString MoveFrame::AnalizeHhsno(wxString file) +wxString MoveFrame::AnalizeHhsno(wxString file, int offx, int offy) { wxImage image(file, wxBITMAP_TYPE_TIFF); - int sx = MS_X; // start x - int sy = MS_Y; + int sx = MS_X + offx; // start x + int sy = MS_Y + offy; int bw = MS_W / 10; // block width int bh = MS_H / 10; int area = bw * bh; @@ -272,7 +340,7 @@ int max_n; float max, bk; - wxString hhsno; + wxString hno; for (int c = 0; c < 10; c++) { max = 0.0; max_n = -1; @@ -294,10 +362,35 @@ } black = 0; } - hhsno.Append(wxString::Format(wxT("%d"), max_n)); + hno.Append(wxString::Format(wxT("%d"), max_n)); } - return hhsno; + return hno; +} + +void MoveFrame::MoveLookWin(int x, int y) +{ + m_offx += x * 5; + m_offy += y * 5; + + wxImage image(m_curms, wxBITMAP_TYPE_TIFF); + wxImage img_buf; + wxBitmap bmp_buf; + + img_buf = image.GetSubImage(wxRect(HNAME_X + m_offx, HNAME_Y + m_offy, HNAME_W, HNAME_H)); + bmp_buf = img_buf.Scale(HNAME_WW, HNAME_WH, wxIMAGE_QUALITY_HIGH); + m_bitmapName->SetBitmap(bmp_buf); + + img_buf = image.GetSubImage(wxRect(HNO_X + m_offx, HNO_Y + m_offy, HNO_W, HNO_H)); + bmp_buf = img_buf.Scale(HNO_WW, HNO_WH, wxIMAGE_QUALITY_HIGH); + m_bitmapHno->SetBitmap(bmp_buf); + + wxString hno = AnalizeHhsno(m_curms, m_offx, m_offy); + m_textCtrlName->SetValue(m_hhash[hno]); + m_textCtrlHno->SetValue(hno); + + m_staticTextHnoMsg->SetLabel(wxEmptyString); + if (hno.Cmp(m_maxhno) > 0) m_staticTextHnoMsg->SetLabel(wxString::Format(wxT("> %s !"), m_maxhno)); } /* Event Handlers */ @@ -321,64 +414,17 @@ return; } + m_offx = 0; + m_offy = 0; AutoDetect(); - m_dataViewListCtrl->SelectRow(0); + SelectItem(0); m_dataViewListCtrl->SetFocus(); } void MoveFrame::OnSelect(wxDataViewEvent& WXUNUSED(event)) { - m_listViewThumb->DeleteAllItems(); - int r = m_dataViewListCtrl->GetSelectedRow(); - wxString dirno = m_dataViewListCtrl->GetTextValue(r, 0); - wxString hno = m_dataViewListCtrl->GetTextValue(r, 1); - wxString hname = m_dataViewListCtrl->GetTextValue(r, 2); - - wxString img_path = m_dirPicker->GetPath() + wxFILE_SEP_PATH + dirno; - wxDir dir(img_path); - if (!dir.IsOpened()) return; - - wxString fn; - bool cont = dir.GetFirst(&fn, wxT("*.tif"), wxDIR_FILES); - - wxString buf = img_path + wxFILE_SEP_PATH + fn; - wxImage image(buf, wxBITMAP_TYPE_TIFF); - wxImage img_buf; - wxBitmap bmp_buf; - - img_buf = image.GetSubImage(wxRect(HNAME_X, HNAME_Y, HNAME_W, HNAME_H)); - bmp_buf = img_buf.Scale(HNAME_WW, HNAME_WH, wxIMAGE_QUALITY_HIGH); - m_bitmapName->SetBitmap(bmp_buf); - - img_buf = image.GetSubImage(wxRect(HNO_X, HNO_Y, HNO_W, HNO_H)); - bmp_buf = img_buf.Scale(HNO_WW, HNO_WH, wxIMAGE_QUALITY_HIGH); - m_bitmapHno->SetBitmap(bmp_buf); - - m_textCtrlName->SetValue(hname); - m_textCtrlHno->SetValue(hno); - - wxImageList* imglist = new wxImageList(THUMB_W, THUMB_H); - m_listViewThumb->SetImageList(imglist, wxIMAGE_LIST_NORMAL); - for (int i = 0; cont; i++) { - buf = img_path + wxFILE_SEP_PATH + fn; - wxImage img(buf, wxBITMAP_TYPE_TIFF); - bmp_buf = img.Scale(THUMB_W, THUMB_H, wxIMAGE_QUALITY_HIGH); - imglist->Add(bmp_buf); - m_listViewThumb->InsertItem(i, fn, i); - - if (i == 2) { - wxImage im = img.GetSubImage(wxRect(0, 0, img.GetWidth() - 1, 300)); // 2480x300 - bmp_buf = im.Scale(RIGHT_W, RIGHT_H1, wxIMAGE_QUALITY_HIGH); - m_bitmapTk->SetBitmap(bmp_buf); - } - if (i == 3) { - wxImage im = img.GetSubImage(wxRect(0, 20, img.GetWidth() - 1, 700)); // 2480x500 - bmp_buf = im.Scale(RIGHT_W, RIGHT_H2, wxIMAGE_QUALITY_HIGH); - m_bitmapIk->SetBitmap(bmp_buf); - } - cont = dir.GetNext(&fn); - } + SelectItem(r); } void MoveFrame::OnListChar(wxKeyEvent& event) @@ -387,37 +433,54 @@ int key = event.GetKeyCode(); switch (key) { - case WXK_F5: { - break; - } case WXK_UP: { if (mod == wxMOD_CONTROL) { - wxMessageBox("up"); + MoveLookWin(0, 1); return; } + break; } case WXK_DOWN: { if (mod == wxMOD_CONTROL) { - wxMessageBox("down"); + MoveLookWin(0, -1); return; } + break; } case WXK_RIGHT: { if (mod == wxMOD_CONTROL) { - wxMessageBox("right"); + MoveLookWin(-1, 0); return; } + break; } case WXK_LEFT: { if (mod == wxMOD_CONTROL) { - wxMessageBox("left"); - break; + MoveLookWin(1, 0); + return; } + break; + } + case WXK_RETURN: { + int r = m_dataViewListCtrl->GetSelectedRow(); + m_dataViewListCtrl->SetTextValue(m_textCtrlHno->GetValue(), r, 1); + m_dataViewListCtrl->SetTextValue(m_textCtrlName->GetValue(), r, 2); + //if (r != m_dataViewListCtrl->GetItemCount() - 1) SelectItem(r + 1); + return; } } event.Skip(); } +void MoveFrame::OnName(wxCommandEvent& WXUNUSED(event)) +{ + int r = m_dataViewListCtrl->GetSelectedRow(); + m_dataViewListCtrl->SetTextValue(m_textCtrlHno->GetValue(), r, 1); + m_dataViewListCtrl->SetTextValue(m_textCtrlName->GetValue(), r, 2); + //if (r != m_dataViewListCtrl->GetItemCount() - 1) SelectItem(r + 1); + m_dataViewListCtrl->SetFocus(); +} + void MoveFrame::OnHnoChar(wxKeyEvent& event) { // num-key '-' as BackSpace @@ -451,6 +514,9 @@ } m_dataViewListCtrl->SetTextValue(hno, r, 1); m_dataViewListCtrl->SetTextValue(m_hhash[hno], r, 2); + + //if (r != m_dataViewListCtrl->GetItemCount() - 1) SelectItem(r + 1); + m_dataViewListCtrl->SetFocus(); } void MoveFrame::OnCheck(wxCommandEvent& WXUNUSED(event)) diff -r 6ec28d3c3e00 -r 169936fed61b src/kaigo/horori/searcher/include/net.h --- a/src/kaigo/horori/searcher/include/net.h Sat Apr 18 21:10:29 2020 +0900 +++ b/src/kaigo/horori/searcher/include/net.h Tue Apr 21 22:43:55 2020 +0900 @@ -1,5 +1,5 @@ // Filename : net.h -// Last Change: 2020-03-30 15:05:58. +// Last Change: 2020-04-21 13:44:57. // #pragma once @@ -73,10 +73,53 @@ file_ostream.Close(); } ret = true; + //wxDELETE(httpStream); } - //wxDELETE(httpStream); get.Close(); return ret; }; +bool HttpPostFile(wxString addr, wxString port, wxString url, wxString file) +{ + bool ret = false; + + wxMemoryBuffer buf; + wxByte b[8192]; + wxFFile f; + if (!f.Open(file, wxT("rb"))) { + wxMessageBox(wxT("Cannot open file.")); + return ret; + } + for (;;) { + size_t len = f.Read(b, sizeof(b)); + if ((size_t)wxInvalidOffset == len) { + return ret; + } + if (len == 0) break; // success + buf.AppendData(b, len); + } + f.Close(); + + wxHTTP post; + post.SetTimeout(30); + post.SetFlags(wxSOCKET_WAITALL|wxSOCKET_BLOCK); + post.SetPostBuffer(wxT("application/gzip"), buf); + + while (!post.Connect(addr, wxAtoi(port))) + wxSleep(1); + + wxInputStream *httpStream = post.GetInputStream(url); + if (httpStream != NULL) { + wxString res; + wxStringOutputStream out_stream(&res); + httpStream->Read(out_stream); + wxDELETE(httpStream); + //wxMessageBox(res); + ret = true; + } + + post.Close(); + return ret; +}; + diff -r 6ec28d3c3e00 -r 169936fed61b src/kaigo/horori/searcher/include/searcher.h --- a/src/kaigo/horori/searcher/include/searcher.h Sat Apr 18 21:10:29 2020 +0900 +++ b/src/kaigo/horori/searcher/include/searcher.h Tue Apr 21 22:43:55 2020 +0900 @@ -1,5 +1,5 @@ // Filename : searcher.h -// Last Change: 2020-04-17 金 16:09:33. +// Last Change: 2020-04-21 火 09:23:17. // #pragma once @@ -73,6 +73,7 @@ { private: wxString m_workdir; + wxString m_hhscsv; wxString m_addr, m_port; wxRect m_mask1, m_mask2, m_mask3; int m_searchmode; diff -r 6ec28d3c3e00 -r 169936fed61b src/kaigo/horori/searcher/include/utils.h --- a/src/kaigo/horori/searcher/include/utils.h Sat Apr 18 21:10:29 2020 +0900 +++ b/src/kaigo/horori/searcher/include/utils.h Tue Apr 21 22:43:55 2020 +0900 @@ -1,5 +1,5 @@ // Filename : utils.h -// Last Change: 2020-03-18 15:00:33. +// Last Change: 2020-04-21 09:30:58. // #pragma once @@ -7,4 +7,6 @@ wxRect Geo2Rect(wxString geo); wxRect ZeroRect(); +bool TarDir(wxString dir, wxString tarfile); +bool Gzip(wxString infile, wxString gzfile); diff -r 6ec28d3c3e00 -r 169936fed61b src/kaigo/horori/searcher/searcher.conf --- a/src/kaigo/horori/searcher/searcher.conf Sat Apr 18 21:10:29 2020 +0900 +++ b/src/kaigo/horori/searcher/searcher.conf Tue Apr 21 22:43:55 2020 +0900 @@ -12,4 +12,5 @@ [Misc] workdir=C:\\Users\\nintei\\Desktop\\nst\\work +uphhscsv=C:\\Users\\nintei\\Desktop\\test\\サーチャー用だ!.csv diff -r 6ec28d3c3e00 -r 169936fed61b src/kaigo/horori/searcher/server/searcher.go --- a/src/kaigo/horori/searcher/server/searcher.go Sat Apr 18 21:10:29 2020 +0900 +++ b/src/kaigo/horori/searcher/server/searcher.go Tue Apr 21 22:43:55 2020 +0900 @@ -1,10 +1,12 @@ /* - Last Change: 2020-04-17 金 17:04:25. + Last Change: 2020-04-21 火 13:59:52. */ package main import ( + "bytes" + "compress/gzip" "encoding/csv" "fmt" "io" @@ -86,12 +88,13 @@ // Http-Handler http.HandleFunc("/h/", hhs_handler) // Get /h/0800012345 -> name:addr:20200101#20210701#... http.HandleFunc("/hn/", hhsnm_handler) // Get /h/0800012345:0800098765:... -> name1:name2:... - http.HandleFunc("/ht/", hhstm_handler) // Get /ht -> 20200314 + http.HandleFunc("/ht/", hhstm_handler) // Get /ht/ -> 2020-03-14 12:34 http.HandleFunc("/ha/", hhsdb_handler) // Get /ha/ -> hhsdb.csv for Mover http.HandleFunc("/i/", image_handler) // Get /i/20200110/0800012345.tgz http.HandleFunc("/r/", recent_handler) // Get /r/0800012345:0800067890:0800099999:... -> 0800012345,name1,20200101:0800067890,name2,20210405:... http.HandleFunc("/d/", index_handler) // Get /d/20xx -> 20xx0401:2020xx0408:... , /d/20xx0401 -> 0800012345:0800098765:... - http.HandleFunc("/u/", uphhsdb_handler) // Get /u/ -> ? + http.HandleFunc("/u/", uphhsdb_handler) // POST /u/ + http.HandleFunc("/ui/", upimage_handler) // POST /ui/20200401/0800012345.tgz log.Fatal(http.ListenAndServe(server, nil)) } @@ -178,9 +181,13 @@ w.Write([]byte(strings.Join(buf, ":"))) } -/* Get /ht > 20200314 */ +/* Get /ht/ -> 2020-03-14 12:34 */ func hhstm_handler(w http.ResponseWriter, r *http.Request) { date := "" + if fi, err := os.Stat(hhsdb); err == nil { + t := fi.ModTime() + date = t.Format("2006-01-02 15:04") + } w.Write([]byte(date)) } @@ -239,21 +246,78 @@ w.Write([]byte(buf[1:])) } -/* /u */ +/* POST /u/ */ func uphhsdb_handler(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodPost { + http.NotFound(w, r) + return + } + server_root := filepath.Dir(os.Args[0]) - file := filepath.Join(server_root, "db", hhsdb) + file := filepath.Join(server_root, hhsdb) f, err := os.Create(file) if err != nil { http.NotFound(w, r) return } + defer f.Close() + + b, err := ioutil.ReadAll(r.Body) + r.Body.Close() + if err != nil { + http.NotFound(w, r) + return + } + + br := bytes.NewReader(b) + zr, err := gzip.NewReader(br) + if err != nil { + http.NotFound(w, r) + return + } + n, err := io.Copy(f, zr) + + if err := zr.Close(); err != nil { + http.NotFound(w, r) + return + } + + w.Write([]byte(fmt.Sprintf("%d bytes are recieved.\n", n))) + + loadDB(); +} + +/* POST /ui/20200401/0800012345.tgz */ +func upimage_handler(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodPost { + http.NotFound(w, r) + return + } + + uri := r.URL.Path[len("/ui/"):] + ymd := uri[0:8] + tgz := uri[9:] + + server_root := filepath.Dir(os.Args[0]) + dir := filepath.Join(server_root, "images", ymd) + + if _, err := os.Stat(dir); os.IsNotExist(err) { + os.Mkdir(dir, 0644) + } + + file := filepath.Join(server_root, "images", ymd, tgz) + f, err := os.Create(file) + if err != nil { + http.NotFound(w, r) + return + } + defer f.Close() + n, err := io.Copy(f, r.Body) if err != nil { http.NotFound(w, r) return } - f.Close() w.Write([]byte(fmt.Sprintf("%d bytes are recieved.\n", n))) } diff -r 6ec28d3c3e00 -r 169936fed61b src/kaigo/horori/searcher/src/searcher.cpp --- a/src/kaigo/horori/searcher/src/searcher.cpp Sat Apr 18 21:10:29 2020 +0900 +++ b/src/kaigo/horori/searcher/src/searcher.cpp Tue Apr 21 22:43:55 2020 +0900 @@ -1,5 +1,5 @@ // Filename : searcher.cpp -// Last Change: 2020-04-17 金 16:22:32. +// Last Change: 2020-04-21 火 17:00:42. // #include #include @@ -468,7 +468,43 @@ void SearchFrame::OnUploadHhsDB(wxCommandEvent& WXUNUSED(event)) { - wxMessageBox("uph"); + wxString incsv = m_filePickerHhsDB->GetPath(); + wxString outcsv = m_workdir + wxFILE_SEP_PATH + wxT("hhsdb.csv"); + wxString outgz = outcsv + wxT(".gz"); + if (wxFileExists(outcsv)) wxRemoveFile(outcsv); + + wxFFile input, output; + if (!input.Open(incsv)) { + wxMessageBox(wxT("Cannot open file.")); + return; + } + + if (!output.Open(outcsv, wxT("w"))) { + wxMessageBox(wxT("Cannot create file.")); + return; + } + + wxString buf; + wxCSConv cust(wxT("cp932")); + input.ReadAll(&buf, cust); + input.Close(); + + output.Write(buf); + output.Close(); + + Gzip(outcsv, outgz); + + wxString url = wxT("/u/"); + if (HttpPostFile(m_addr, m_port, url, outgz)) { + wxString url = wxT("/ht/"); + wxString date = HttpGetText(m_addr, m_port, url); + m_textCtrlLastHhsDB->SetValue(date); + wxMessageBox(wxT("upload done.")); + } else { + wxMessageBox(wxT("upload failed.")); + } + wxRemoveFile(outcsv); + wxRemoveFile(outgz); } void SearchFrame::OnUploadImage(wxCommandEvent& WXUNUSED(event)) @@ -487,6 +523,24 @@ wxMessageBox(wxT("bad date")); return; } + + wxDir ymd_dir(ymddir); + if (!ymd_dir.IsOpened()) return; + + wxString ccn; + bool cont = dir.GetFirst(&ccndir, wxEmptyString, wxDIR_DIRS); + while (cont) { + wxDir ccn_dir(ymddir + wxFILE_SEP_PATH + ccn); + wxString hno; + bool cont2 = ccndir.GetFirst(&hno, wxEmptyString, wxDIR_DIRS); + while (cont2) { + wxString d = ymddir + wxFILE_SEP_PATH + ccn + wxFILE_SEP_PATH + hno; + wxString tar = m_workdir + wxFILE_SEP_PATH + hno + wxT(".tar"); + TarDir(d, tar); + cont2 = ccn_dir.GetNext(&hno); + } + cont = ymd_dir.GetNext(&dirname); + } } void SearchFrame::OnRead(wxCommandEvent& WXUNUSED(event)) @@ -683,7 +737,7 @@ gbSizerBatch->SetFlexibleDirection(wxBOTH); gbSizerBatch->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); - m_filePicker = new wxFilePickerCtrl(m_panelBatch, wxID_ANY, wxEmptyString, wxT("Select a file"), wxT("*.csv"), wxDefaultPosition, wxSize(300, -1), wxFLP_CHANGE_DIR|wxFLP_FILE_MUST_EXIST|wxFLP_OPEN|wxFLP_SMALL|wxFLP_USE_TEXTCTRL); + m_filePicker = new wxFilePickerCtrl(m_panelBatch, wxID_ANY, wxEmptyString, wxT("Select a file"), wxT("*.csv"), wxDefaultPosition, wxSize(300, -1), wxFLP_FILE_MUST_EXIST|wxFLP_OPEN|wxFLP_SMALL|wxFLP_USE_TEXTCTRL); gbSizerBatch->Add(m_filePicker, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL|wxALIGN_CENTER_VERTICAL, 5); m_buttonRead = new wxButton(m_panelBatch, wxID_ANY, wxT("読込み"), wxDefaultPosition, wxDefaultSize, 0); @@ -805,7 +859,7 @@ m_staticTextHhsDB = new wxStaticText(m_panelMainte, wxID_ANY, wxT("被保険者CSV"), wxDefaultPosition, wxDefaultSize, 0); gbSizerDB->Add(m_staticTextHhsDB, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5); - m_filePickerHhsDB = new wxFilePickerCtrl(m_panelMainte, wxID_ANY, wxEmptyString, wxT("Select a file"), wxT("*.*"), wxDefaultPosition, wxSize(200,-1), wxFLP_CHANGE_DIR|wxFLP_FILE_MUST_EXIST|wxFLP_OPEN|wxFLP_SMALL|wxFLP_USE_TEXTCTRL); + m_filePickerHhsDB = new wxFilePickerCtrl(m_panelMainte, wxID_ANY, wxEmptyString, wxT("Select a file"), wxT("*.csv"), wxDefaultPosition, wxSize(200,-1), wxFLP_FILE_MUST_EXIST|wxFLP_OPEN|wxFLP_SMALL|wxFLP_USE_TEXTCTRL); gbSizerDB->Add(m_filePickerHhsDB, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALL|wxALIGN_CENTER_VERTICAL, 5); m_buttonRegHhs = new wxButton(m_panelMainte, wxID_ANY, wxT("アップロード"), wxDefaultPosition, wxDefaultSize, 0); @@ -904,6 +958,7 @@ conf->SetPath(wxT("/Misc")); conf->Read(wxT("workdir"), &m_workdir); + conf->Read(wxT("uphhscsv"), &m_hhscsv); delete conf; @@ -924,9 +979,15 @@ m_staticBitmap4->SetParentWidows(this, m_notebook); m_staticBitmap5->SetParentWidows(this, m_notebook); + m_filePickerHhsDB->SetPath(m_hhscsv); + wxString url = wxT("/ht/"); + wxString date = HttpGetText(m_addr, m_port, url); + m_textCtrlLastHhsDB->SetValue(date); + m_searchmode = 0; m_buttonHist->Enable(false); + m_textCtrlPasswd->SetValue("a"); } void SearchFrame::SetHhsInfo(wxString h) diff -r 6ec28d3c3e00 -r 169936fed61b src/kaigo/horori/searcher/src/utils.cpp --- a/src/kaigo/horori/searcher/src/utils.cpp Sat Apr 18 21:10:29 2020 +0900 +++ b/src/kaigo/horori/searcher/src/utils.cpp Tue Apr 21 22:43:55 2020 +0900 @@ -1,7 +1,11 @@ // Filename : utils.cpp -// Last Change: 2020-03-18 15:01:12. +// Last Change: 2020-04-21 16:50:37. // #include +#include +#include +#include +#include #include "utils.h" wxRect Geo2Rect(wxString geo) @@ -26,3 +30,40 @@ return rect; } +bool TarDir(wxString dir, wxString tarfile) +{ + if (!wxDirExists(dir)) { + wxMessageBox(wxT("bad directoy")); + return false; + } + + wxDir d(dir); + if (!d.IsOpened()) return false; + + wxFFileOutputStream out(tarfile); + wxTarOutputStream tar(out); + + wxString filename; + bool cont = d.GetFirst(&filename, wxEmptyString, wxDIR_FILES); + while (cont) { + wxTarEntry entry(filename); + tar.PutNextEntry(&entry); + wxFFileInputStream in(dir + wxFILE_SEP_PATH + filename); + tar.Write(in); + cont = d.GetNext(&filename); + } + tar.Close(); + return true; +} + +bool Gzip(wxString infile, wxString gzfile) +{ + wxFileInputStream istream(infile); + wxFileOutputStream ostream(gzfile); + wxZlibOutputStream zstream(ostream, -1, wxZLIB_GZIP); + + zstream.Write(istream); + zstream.Close(); + return true; +} +