| @@ -0,0 +1,20 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Text; | |||
| using CSVDownloader.Store; | |||
| namespace CSVDownloader.Exceptions { | |||
| class SpotNameNotMatchException : Exception { | |||
| private List<ParkingCreditCardAgenciesSpotIDError> error_list_; | |||
| public SpotNameNotMatchException(List<ParkingCreditCardAgenciesSpotIDError> error_list) { | |||
| error_list_ = error_list; | |||
| } | |||
| public List<ParkingCreditCardAgenciesSpotIDError> GetList() { | |||
| return new List<ParkingCreditCardAgenciesSpotIDError>(error_list_); | |||
| } | |||
| } | |||
| } | |||
| @@ -14,6 +14,7 @@ using CSVDownloader.Store; | |||
| using CSVDownloader.Store.CreditCSVData; | |||
| using CSVDownloader.Store.QRCSVData; | |||
| using CSVDownloader.Web; | |||
| using CSVDownloader.Exceptions; | |||
| using MySql.Data.MySqlClient; | |||
| @@ -67,6 +68,8 @@ namespace CSVDownloader { | |||
| private DaitoQRDataStore daito_qr_store_; | |||
| private ParkingCreditCardAgenciesSpotIDErrorDAO parking_credit_card_agencies_spotID_error_dao_; | |||
| private IConfigReader config_; | |||
| private ChromeDriver driver_; | |||
| @@ -110,6 +113,7 @@ namespace CSVDownloader { | |||
| parking_credit_card_agencies_spotID_dao_ = new ParkingCreditCardAgenciesSpotIDDAO(conn_); | |||
| parking_credit_card_agencies_spotID_error_dao_ = new ParkingCreditCardAgenciesSpotIDErrorDAO(conn_); | |||
| daito_credit_store_ = new DaitoCreitDataStore(conn_); | |||
| zeus_credit_store_ = new ZeusCreditDataStore(conn_); | |||
| itec_credit_store_ = new ItecCreditDataStore(conn_); | |||
| @@ -122,6 +126,9 @@ namespace CSVDownloader { | |||
| return "DBへのコネクト失敗"; | |||
| } | |||
| // エラーリストを初期化する(全削除) | |||
| parking_credit_card_agencies_spotID_error_dao_.DeleteAll(); | |||
| // サイトごとにコントローラーを用意する。 | |||
| MakeConttollers(); | |||
| @@ -232,11 +239,6 @@ namespace CSVDownloader { | |||
| } | |||
| logger_.Info("ログアウト成功"); | |||
| // データ保存 | |||
| int delete_count_credit = 0; | |||
| int delete_count_qr = 0; | |||
| transaction_ = conn_.BeginTransaction(); | |||
| // ロード画面の表示 | |||
| var load_html_path = Path.GetFullPath(@"static\html\load.html"); | |||
| @@ -244,8 +246,35 @@ namespace CSVDownloader { | |||
| // データリストの取得 | |||
| var credit_info_list = web_controller.GetCreditCSVDataList(); | |||
| var qr_info_list = web_controller.GetQRCSVDataList(); | |||
| // 取得に失敗したものはエラーリストとして登録する。 | |||
| bool list_get_success = true; | |||
| List<CreditCSVData> credit_info_list = null; | |||
| List<QRCSVData> qr_info_list = null; | |||
| try { | |||
| credit_info_list = web_controller.GetCreditCSVDataList(); | |||
| } catch (SpotNameNotMatchException e) { | |||
| list_get_success = false; | |||
| parking_credit_card_agencies_spotID_error_dao_.Save(e.GetList()); | |||
| } | |||
| try { | |||
| qr_info_list = web_controller.GetQRCSVDataList(); | |||
| } catch (SpotNameNotMatchException e) { | |||
| list_get_success = false; | |||
| parking_credit_card_agencies_spotID_error_dao_.Save(e.GetList()); | |||
| } | |||
| if (!list_get_success) { | |||
| throw new Exception("データリスト取得失敗"); | |||
| } | |||
| // データ保存 | |||
| int delete_count_credit = 0; | |||
| int delete_count_qr = 0; | |||
| transaction_ = conn_.BeginTransaction(); | |||
| // クレジット | |||
| if (0 < credit_info_list.Count) { | |||
| @@ -0,0 +1,118 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Text; | |||
| using System.Data; | |||
| using MySql.Data.MySqlClient; | |||
| namespace CSVDownloader.Store { | |||
| class ParkingCreditCardAgenciesSpotIDError { | |||
| public string creditcard_agencies_id = ""; | |||
| public string creditcard_agencies_spot_name = ""; | |||
| public DateTime upd_date = DateTime.Now; | |||
| public string upd_staff = "auto_tool"; | |||
| public DateTime reg_date = DateTime.Now; | |||
| public string reg_staff = "auto_tool"; | |||
| public enum ColName { | |||
| CreditcardAgenciesID, | |||
| CreditcardAgenciesSpotName, | |||
| UpdDate, | |||
| UpdStaff, | |||
| RegDate, | |||
| RegStaff | |||
| }; | |||
| } | |||
| class ParkingCreditCardAgenciesSpotIDErrorDAO : MySQL { | |||
| private static readonly string table_name_ = "parking_creditcard_agencies_spotid_error"; | |||
| public ParkingCreditCardAgenciesSpotIDErrorDAO(MySqlConnection conn) : base(conn) { | |||
| } | |||
| public void Save(List<ParkingCreditCardAgenciesSpotIDError> list) { | |||
| Code.ResultCode ret; | |||
| var table = new DataTable(); | |||
| table.Columns.Add(ParkingCreditCardAgenciesSpotIDError.ColName.CreditcardAgenciesID.ToString()); | |||
| table.Columns.Add(ParkingCreditCardAgenciesSpotIDError.ColName.CreditcardAgenciesSpotName.ToString()); | |||
| table.Columns.Add(ParkingCreditCardAgenciesSpotIDError.ColName.UpdStaff.ToString()); | |||
| table.Columns.Add(ParkingCreditCardAgenciesSpotIDError.ColName.RegStaff.ToString()); | |||
| foreach (ParkingCreditCardAgenciesSpotIDError data in list) { | |||
| var row = table.NewRow(); | |||
| row[ParkingCreditCardAgenciesSpotIDError.ColName.CreditcardAgenciesID.ToString()] = data.creditcard_agencies_id; | |||
| row[ParkingCreditCardAgenciesSpotIDError.ColName.CreditcardAgenciesSpotName.ToString()] = data.creditcard_agencies_spot_name; | |||
| row[ParkingCreditCardAgenciesSpotIDError.ColName.UpdStaff.ToString()] = data.upd_staff; | |||
| row[ParkingCreditCardAgenciesSpotIDError.ColName.RegStaff.ToString()] = data.reg_staff; | |||
| table.Rows.Add(row); | |||
| } | |||
| ret = BulkInsertData(table_name_, table); | |||
| if (ret != Code.ResultCode.OK) { | |||
| throw new Exception("登録失敗 紐づけエラー"); | |||
| } | |||
| } | |||
| public bool Exists(Code.CreditAgent agent, String spot_name) { | |||
| string code = Code.CreditAgenciesMap.GetID(agent); | |||
| var tbl = new DataTable(); | |||
| string replace_id = "@id"; | |||
| string replace_spot_name = "@spot_name"; | |||
| string sql = $"select count(*) from {table_name_} " + | |||
| $"where CreditcardAgenciesID = {replace_id} ;" + | |||
| $"CreditcardAgenciesSpotName = {replace_spot_name};"; | |||
| using (var adpt = new MySqlDataAdapter(sql, conn_)) { | |||
| adpt.SelectCommand.Parameters.AddWithValue(replace_id, code); | |||
| adpt.SelectCommand.Parameters.AddWithValue(replace_spot_name, spot_name); | |||
| adpt.SelectCommand.Prepare(); | |||
| adpt.Fill(tbl); | |||
| } | |||
| return 0 < int.Parse(tbl.Rows[0][0].ToString()); | |||
| } | |||
| public int DeleteAll() { | |||
| var bind_list = new List<(string, object)>(); | |||
| string sql = $"delete from {table_name_} "; | |||
| return DeleteData(sql, bind_list); | |||
| } | |||
| public int Delete(Code.CreditAgent agent, String spot_name) { | |||
| string code = Code.CreditAgenciesMap.GetID(agent); | |||
| var bind_list = new List<(string, object)>(); | |||
| string replace_id = "@id"; | |||
| string replace_spot_name = "@spot_name"; | |||
| string sql = $"delete from {table_name_} " + | |||
| $"where CreditcardAgenciesID = {replace_id} ;" + | |||
| $"CreditcardAgenciesSpotName = {replace_spot_name};"; | |||
| bind_list.Add((replace_id, code)); | |||
| bind_list.Add((replace_spot_name, spot_name)); | |||
| return DeleteData(sql, bind_list); | |||
| } | |||
| } | |||
| } | |||
| @@ -8,6 +8,7 @@ using OpenQA.Selenium.Chrome; | |||
| using CSVDownloader.Code; | |||
| using CSVDownloader.Store.CreditCSVData; | |||
| using CSVDownloader.Store.QRCSVData; | |||
| using CSVDownloader.Exceptions; | |||
| using ExpectedConditions = OpenQA.Selenium.Support.UI.ExpectedConditions; | |||
| @@ -159,16 +160,20 @@ namespace CSVDownloader.Web { | |||
| } | |||
| if (failed_flg) { | |||
| var error_list = new List<Store.ParkingCreditCardAgenciesSpotIDError>(); | |||
| logger_.Error("失敗駐車場名"); | |||
| foreach (var ele in failed_parking_name_hs_table) { | |||
| error_list.Add(new Store.ParkingCreditCardAgenciesSpotIDError() { | |||
| creditcard_agencies_id = CreditAgenciesMap.GetID(agent_), | |||
| creditcard_agencies_spot_name = ele | |||
| }); | |||
| logger_.Error($"駐車場 \"{ele}\""); | |||
| } | |||
| throw new Exception("データ作成失敗"); | |||
| throw new SpotNameNotMatchException(error_list); | |||
| } | |||
| return result_list; | |||
| } | |||
| @@ -206,13 +211,18 @@ namespace CSVDownloader.Web { | |||
| } | |||
| if (failed_flg) { | |||
| logger_.Error("失敗駐車場名"); | |||
| var error_list = new List<Store.ParkingCreditCardAgenciesSpotIDError>(); | |||
| logger_.Error("失敗駐車場名"); | |||
| foreach (var ele in failed_parking_name_hs_table) { | |||
| error_list.Add(new Store.ParkingCreditCardAgenciesSpotIDError() { | |||
| creditcard_agencies_id = CreditAgenciesMap.GetID(agent_), | |||
| creditcard_agencies_spot_name = ele | |||
| }); | |||
| logger_.Error($"駐車場 \"{ele}\""); | |||
| } | |||
| throw new Exception("データ作成失敗"); | |||
| throw new SpotNameNotMatchException(error_list); | |||
| } | |||
| @@ -7,6 +7,8 @@ using OpenQA.Selenium.Chrome; | |||
| using CSVDownloader.Code; | |||
| using CSVDownloader.Store.CreditCSVData; | |||
| using CSVDownloader.Exceptions; | |||
| using ExpectedConditions = OpenQA.Selenium.Support.UI.ExpectedConditions; | |||
| namespace CSVDownloader.Web { | |||
| @@ -201,14 +203,20 @@ namespace CSVDownloader.Web { | |||
| if (failed_flg) { | |||
| logger_.Error("失敗駐車場名"); | |||
| if (failed_flg) { | |||
| var error_list = new List<Store.ParkingCreditCardAgenciesSpotIDError>(); | |||
| logger_.Error("失敗駐車場名"); | |||
| foreach (var ele in failed_parking_name_hs_table) { | |||
| error_list.Add(new Store.ParkingCreditCardAgenciesSpotIDError() { | |||
| creditcard_agencies_id = CreditAgenciesMap.GetID(agent_), | |||
| creditcard_agencies_spot_name = ele | |||
| }); | |||
| logger_.Error($"駐車場 \"{ele}\""); | |||
| } | |||
| foreach (var ele in failed_parking_name_hs_table) { | |||
| logger_.Error($"駐車場 \"{ele}\""); | |||
| throw new SpotNameNotMatchException(error_list); | |||
| } | |||
| throw new Exception("データ作成失敗"); | |||
| } | |||
| } | |||
| @@ -7,6 +7,8 @@ using OpenQA.Selenium.Chrome; | |||
| using CSVDownloader.Code; | |||
| using CSVDownloader.Store.CreditCSVData; | |||
| using CSVDownloader.Exceptions; | |||
| using ExpectedConditions = OpenQA.Selenium.Support.UI.ExpectedConditions; | |||
| namespace CSVDownloader.Web { | |||
| @@ -175,14 +177,20 @@ namespace CSVDownloader.Web { | |||
| } | |||
| if (failed_flg) { | |||
| logger_.Error("失敗駐車場名"); | |||
| foreach (var ele in failed_parking_name_hs_table) { | |||
| logger_.Error($"駐車場 \"{ele}\""); | |||
| if (failed_flg) { | |||
| var error_list = new List<Store.ParkingCreditCardAgenciesSpotIDError>(); | |||
| logger_.Error("失敗駐車場名"); | |||
| foreach (var ele in failed_parking_name_hs_table) { | |||
| error_list.Add(new Store.ParkingCreditCardAgenciesSpotIDError() { | |||
| creditcard_agencies_id = CreditAgenciesMap.GetID(agent_), | |||
| creditcard_agencies_spot_name = ele | |||
| }); | |||
| logger_.Error($"駐車場 \"{ele}\""); | |||
| } | |||
| throw new SpotNameNotMatchException(error_list); | |||
| } | |||
| throw new Exception("データ作成失敗"); | |||
| } | |||
| return result_list; | |||
| @@ -7,6 +7,8 @@ using OpenQA.Selenium.Chrome; | |||
| using CSVDownloader.Code; | |||
| using CSVDownloader.Store.CreditCSVData; | |||
| using CSVDownloader.Exceptions; | |||
| using ExpectedConditions = OpenQA.Selenium.Support.UI.ExpectedConditions; | |||
| namespace CSVDownloader.Web { | |||
| @@ -226,14 +228,20 @@ namespace CSVDownloader.Web { | |||
| if (failed_flg) { | |||
| logger_.Error("失敗駐車場名"); | |||
| if (failed_flg) { | |||
| var error_list = new List<Store.ParkingCreditCardAgenciesSpotIDError>(); | |||
| logger_.Error("失敗駐車場名"); | |||
| foreach (var ele in failed_parking_name_hs_table) { | |||
| error_list.Add(new Store.ParkingCreditCardAgenciesSpotIDError() { | |||
| creditcard_agencies_id = CreditAgenciesMap.GetID(agent_), | |||
| creditcard_agencies_spot_name = ele | |||
| }); | |||
| logger_.Error($"駐車場 \"{ele}\""); | |||
| } | |||
| foreach (var ele in failed_parking_name_hs_table) { | |||
| logger_.Error($"駐車場 \"{ele}\""); | |||
| throw new SpotNameNotMatchException(error_list); | |||
| } | |||
| throw new Exception("データ作成失敗"); | |||
| } | |||
| } | |||