| @@ -13,6 +13,8 @@ using CSVDownloader.File; | |||||
| using CSVDownloader.Store; | using CSVDownloader.Store; | ||||
| using CSVDownloader.Store.CreditCSVData; | using CSVDownloader.Store.CreditCSVData; | ||||
| using CSVDownloader.Store.QRCSVData; | using CSVDownloader.Store.QRCSVData; | ||||
| using CSVDownloader.Store.ElectronicMoneyDataStore; | |||||
| using CSVDownloader.Web; | using CSVDownloader.Web; | ||||
| using CSVDownloader.Exceptions; | using CSVDownloader.Exceptions; | ||||
| @@ -68,6 +70,10 @@ namespace CSVDownloader { | |||||
| private DaitoQRDataStore daito_qr_store_; | private DaitoQRDataStore daito_qr_store_; | ||||
| private CreditCSVDataGMOStore gmo_credit_store_; | |||||
| private GMOElectronicMoneyDataStore gmo_electronic_money_store_; | |||||
| private ParkingCreditCardAgenciesSpotIDErrorDAO parking_credit_card_agencies_spotID_error_dao_; | private ParkingCreditCardAgenciesSpotIDErrorDAO parking_credit_card_agencies_spotID_error_dao_; | ||||
| private IConfigReader config_; | private IConfigReader config_; | ||||
| @@ -82,6 +88,8 @@ namespace CSVDownloader { | |||||
| private Dictionary<Code.CreditAgent, QRCSVDataStore> qr_datastore_map_ = new Dictionary<Code.CreditAgent, QRCSVDataStore>(); | private Dictionary<Code.CreditAgent, QRCSVDataStore> qr_datastore_map_ = new Dictionary<Code.CreditAgent, QRCSVDataStore>(); | ||||
| private Dictionary<Code.CreditAgent, ElectronicMoneyCSVDataStore> electronic_money_datastore_map_ = new Dictionary<Code.CreditAgent, ElectronicMoneyCSVDataStore>(); | |||||
| private int save_chunk_num_ = 100; | private int save_chunk_num_ = 100; | ||||
| @@ -119,6 +127,8 @@ namespace CSVDownloader { | |||||
| itec_credit_store_ = new ItecCreditDataStore(conn_); | itec_credit_store_ = new ItecCreditDataStore(conn_); | ||||
| hello_techno_credit_store_ = new HelloTechnoCreditDataStore(conn_); | hello_techno_credit_store_ = new HelloTechnoCreditDataStore(conn_); | ||||
| daito_qr_store_ = new DaitoQRDataStore(conn_); | daito_qr_store_ = new DaitoQRDataStore(conn_); | ||||
| gmo_credit_store_ = new CreditCSVDataGMOStore(conn_); | |||||
| gmo_electronic_money_store_ = new GMOElectronicMoneyDataStore(conn_); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger_.Error("DB接続失敗"); | logger_.Error("DB接続失敗"); | ||||
| @@ -185,11 +195,20 @@ namespace CSVDownloader { | |||||
| // HelloTechno | // HelloTechno | ||||
| { | { | ||||
| var controller = new HelloTechnoController(driver_); | |||||
| //var controller = new HelloTechnoController(driver_); | |||||
| //var dic = parking_credit_card_agencies_spotID_dao_.GetDictionary(controller.GetCreditAgent()); | |||||
| //controller.SetParkingDic(dic); | |||||
| //web_controller_list_.Add(controller); | |||||
| //credit_datastore_map_.Add(controller.GetCreditAgent(), hello_techno_credit_store_); | |||||
| } | |||||
| // HelloTechno(GMO) | |||||
| { | |||||
| var controller = new GMOController(driver_); | |||||
| var dic = parking_credit_card_agencies_spotID_dao_.GetDictionary(controller.GetCreditAgent()); | var dic = parking_credit_card_agencies_spotID_dao_.GetDictionary(controller.GetCreditAgent()); | ||||
| controller.SetParkingDic(dic); | controller.SetParkingDic(dic); | ||||
| web_controller_list_.Add(controller); | web_controller_list_.Add(controller); | ||||
| credit_datastore_map_.Add(controller.GetCreditAgent(), hello_techno_credit_store_); | |||||
| credit_datastore_map_.Add(controller.GetCreditAgent(), gmo_credit_store_); | |||||
| electronic_money_datastore_map_.Add(controller.GetCreditAgent(), gmo_electronic_money_store_); | |||||
| } | } | ||||
| @@ -250,6 +269,7 @@ namespace CSVDownloader { | |||||
| bool list_get_success = true; | bool list_get_success = true; | ||||
| List<CreditCSVData> credit_info_list = null; | List<CreditCSVData> credit_info_list = null; | ||||
| List<QRCSVData> qr_info_list = null; | List<QRCSVData> qr_info_list = null; | ||||
| List<ElectronicMoneyCSVData> electronic_money_info_list = null; | |||||
| try { | try { | ||||
| credit_info_list = web_controller.GetCreditCSVDataList(); | credit_info_list = web_controller.GetCreditCSVDataList(); | ||||
| @@ -266,6 +286,13 @@ namespace CSVDownloader { | |||||
| parking_credit_card_agencies_spotID_error_dao_.Save(e.GetList()); | parking_credit_card_agencies_spotID_error_dao_.Save(e.GetList()); | ||||
| } | } | ||||
| try { | |||||
| electronic_money_info_list = web_controller.GetElectronicMoneyCSVDataList(); | |||||
| } catch (SpotNameNotMatchException e) { | |||||
| list_get_success = false; | |||||
| parking_credit_card_agencies_spotID_error_dao_.Save(e.GetList()); | |||||
| } | |||||
| if (!list_get_success) { | if (!list_get_success) { | ||||
| throw new Exception("データリスト取得失敗"); | throw new Exception("データリスト取得失敗"); | ||||
| @@ -274,6 +301,7 @@ namespace CSVDownloader { | |||||
| // データ保存 | // データ保存 | ||||
| int delete_count_credit = 0; | int delete_count_credit = 0; | ||||
| int delete_count_qr = 0; | int delete_count_qr = 0; | ||||
| int delete_count_electronic_money = 0; | |||||
| transaction_ = conn_.BeginTransaction(); | transaction_ = conn_.BeginTransaction(); | ||||
| // クレジット | // クレジット | ||||
| @@ -310,14 +338,33 @@ namespace CSVDownloader { | |||||
| ShowCurrentCount(current_count); | ShowCurrentCount(current_count); | ||||
| } | } | ||||
| } | } | ||||
| // 電子マネー | |||||
| if (0 < electronic_money_info_list.Count) { | |||||
| ShowTotalCount(electronic_money_info_list.Count); | |||||
| var store = electronic_money_datastore_map_[agent]; | |||||
| delete_count_electronic_money = store.Delete(from, to); | |||||
| var current_count = 0; | |||||
| ShowCurrentCount(current_count); | |||||
| var chunk_data_list = electronic_money_info_list.Select((ElectronicMoneyCSVData data, int index) => new { data, index }) | |||||
| .GroupBy(x => x.index / save_chunk_num_) | |||||
| .Select(g => g.Select(r => r.data)); | |||||
| foreach (var data_list in chunk_data_list) { | |||||
| var list = data_list.ToList(); | |||||
| store.Save(list); | |||||
| current_count += list.Count; | |||||
| ShowCurrentCount(current_count); | |||||
| } | |||||
| } | |||||
| // コミット処理 | // コミット処理 | ||||
| transaction_.Commit(); | transaction_.Commit(); | ||||
| logger_.Info($"削除件数 CREDIT:{delete_count_credit}"); | |||||
| logger_.Info($"削除件数 QR: {delete_count_qr}"); | |||||
| logger_.Info($"登録件数 CREDIT:{credit_info_list.Count}"); | |||||
| logger_.Info($"登録件数 QR :{qr_info_list.Count}"); | |||||
| logger_.Info($"削除件数 CREDIT :{delete_count_credit}"); | |||||
| logger_.Info($"削除件数 QR :{delete_count_qr}"); | |||||
| logger_.Info($"削除件数 電子マネー :{delete_count_electronic_money}"); | |||||
| logger_.Info($"登録件数 CREDIT :{credit_info_list.Count}"); | |||||
| logger_.Info($"登録件数 QR :{qr_info_list.Count}"); | |||||
| logger_.Info($"登録件数 電子マネー :{electronic_money_info_list.Count}"); | |||||
| web_controller.Archive(GetArchiveFilename(agent, DateTime.Now)); | web_controller.Archive(GetArchiveFilename(agent, DateTime.Now)); | ||||
| // 履歴の登録 | // 履歴の登録 | ||||
| @@ -327,6 +374,7 @@ namespace CSVDownloader { | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| // ロールバック処理 | // ロールバック処理 | ||||
| logger_.Error(e.Message); | logger_.Error(e.Message); | ||||
| logger_.Error(e.StackTrace); | |||||
| if (transaction_ != null) { | if (transaction_ != null) { | ||||
| transaction_.Rollback(); | transaction_.Rollback(); | ||||
| } | } | ||||
| @@ -394,6 +442,9 @@ namespace CSVDownloader { | |||||
| throw new Exception($"ログイン情報不足 password {agent.ToString()}"); | throw new Exception($"ログイン情報不足 password {agent.ToString()}"); | ||||
| } | } | ||||
| login_info.company_name = config_.Read(sesction, "company"); | |||||
| return login_info; | return login_info; | ||||
| } | } | ||||
| @@ -0,0 +1,155 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using System.Data; | |||||
| using System.Linq; | |||||
| using MySql.Data.MySqlClient; | |||||
| namespace CSVDownloader.Store.CreditCSVData { | |||||
| class CreditCSVDataGMO : CreditCSVData { | |||||
| public String customer_code = ""; | |||||
| public String output_datetime = ""; | |||||
| public String processing_code = ""; | |||||
| public String operation_code = ""; | |||||
| public String return_code = ""; | |||||
| public String device_no = ""; | |||||
| public String target_company_code = ""; | |||||
| public String target_company_sub_code = ""; | |||||
| public String device_trade_no = ""; | |||||
| public DateTime processing_date = DateTime.Today; | |||||
| public String approval_no = ""; | |||||
| public int amount = 0; | |||||
| public int tax_send_amount = 0; | |||||
| public String customer_name = ""; | |||||
| public String shop_name = ""; | |||||
| public String cancel_receipt_no = ""; | |||||
| public String split_count_info = ""; | |||||
| public String paying_type = ""; | |||||
| public enum ColName { | |||||
| SpotID = 100, | |||||
| CustomerCode = 0, | |||||
| OutputDatetime, | |||||
| ProcessingCode, | |||||
| OperationCode, | |||||
| ReturnCode, | |||||
| DeviceNo, | |||||
| TargetCompanyCode, | |||||
| TargetCompanySubCode, | |||||
| DeviceTradeNo, | |||||
| ProcessingDate, | |||||
| ApprovalNo, | |||||
| Amount, | |||||
| TaxSendAmount, | |||||
| CustomerName, | |||||
| ShopName, | |||||
| CancelReceiptNo, | |||||
| SplitCountInfo, | |||||
| PayingType, | |||||
| UpdDate, | |||||
| UpdStaff, | |||||
| RegDate, | |||||
| RegStaff, | |||||
| }; | |||||
| } | |||||
| class CreditCSVDataGMOStore : CreditCSVDataStore { | |||||
| private static readonly String table_name_ = "creditcard_download_data_gmo"; | |||||
| private String delete_sql_ = $"delete from {table_name_} where " + | |||||
| $"{CreditCSVDataGMO.ColName.ProcessingDate} between " + | |||||
| $"@From{CreditCSVDataGMO.ColName.ProcessingDate} and " + | |||||
| $"@To{CreditCSVDataGMO.ColName.ProcessingDate};"; | |||||
| public CreditCSVDataGMOStore(MySqlConnection conn) : base(conn) { | |||||
| } | |||||
| public override void Save(List<CreditCSVData> list) { | |||||
| Code.ResultCode ret; | |||||
| var table = new DataTable(); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.SpotID.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.CustomerCode.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.OutputDatetime.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.ProcessingCode.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.OperationCode.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.ReturnCode.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.DeviceNo.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.TargetCompanyCode.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.TargetCompanySubCode.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.DeviceTradeNo.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.ProcessingDate.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.ApprovalNo.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.Amount.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.TaxSendAmount.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.CustomerName.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.ShopName.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.CancelReceiptNo.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.SplitCountInfo.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.PayingType.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.UpdStaff.ToString()); | |||||
| table.Columns.Add(CreditCSVDataGMO.ColName.RegStaff.ToString()); | |||||
| foreach (CreditCSVDataGMO data in list) { | |||||
| var row = table.NewRow(); | |||||
| row[CreditCSVDataGMO.ColName.SpotID.ToString()] = data.spot_id; | |||||
| row[CreditCSVDataGMO.ColName.CustomerCode.ToString()] = data.customer_code; | |||||
| row[CreditCSVDataGMO.ColName.OutputDatetime.ToString()] = data.output_datetime; | |||||
| row[CreditCSVDataGMO.ColName.ProcessingCode.ToString()] = data.processing_code; | |||||
| row[CreditCSVDataGMO.ColName.OperationCode.ToString()] = data.operation_code; | |||||
| row[CreditCSVDataGMO.ColName.ReturnCode.ToString()] = data.return_code; | |||||
| row[CreditCSVDataGMO.ColName.DeviceNo.ToString()] = data.device_no; | |||||
| row[CreditCSVDataGMO.ColName.TargetCompanyCode.ToString()] = data.target_company_code; | |||||
| row[CreditCSVDataGMO.ColName.TargetCompanySubCode.ToString()] = data.target_company_sub_code; | |||||
| row[CreditCSVDataGMO.ColName.DeviceTradeNo.ToString()] = data.device_trade_no; | |||||
| row[CreditCSVDataGMO.ColName.ProcessingDate.ToString()] = data.processing_date; | |||||
| row[CreditCSVDataGMO.ColName.ApprovalNo.ToString()] = data.approval_no; | |||||
| row[CreditCSVDataGMO.ColName.Amount.ToString()] = data.amount; | |||||
| row[CreditCSVDataGMO.ColName.TaxSendAmount.ToString()] = data.tax_send_amount; | |||||
| row[CreditCSVDataGMO.ColName.CustomerName.ToString()] = data.customer_name; | |||||
| row[CreditCSVDataGMO.ColName.ShopName.ToString()] = data.shop_name; | |||||
| row[CreditCSVDataGMO.ColName.CancelReceiptNo.ToString()] = data.cancel_receipt_no; | |||||
| row[CreditCSVDataGMO.ColName.SplitCountInfo.ToString()] = data.split_count_info; | |||||
| row[CreditCSVDataGMO.ColName.PayingType.ToString()] = data.paying_type; | |||||
| row[CreditCSVDataGMO.ColName.UpdStaff.ToString()] = data.upd_staff; | |||||
| row[CreditCSVDataGMO.ColName.RegStaff.ToString()] = data.reg_staff; | |||||
| table.Rows.Add(row); | |||||
| } | |||||
| ret = BulkInsertData(table_name_, table); | |||||
| if (ret != Code.ResultCode.OK) { | |||||
| throw new Exception("登録失敗 GMOクレジット"); | |||||
| } | |||||
| } | |||||
| public override int Delete(DateTime from, DateTime to) { | |||||
| var bindlist = new List<(String, object)> { | |||||
| ("From"+CreditCSVDataGMO.ColName.ProcessingDate.ToString(), from.ToString("yyyy-MM-dd")), | |||||
| ("To"+CreditCSVDataGMO.ColName.ProcessingDate.ToString(), to.AddDays(1).ToString("yyyy-MM-dd")) | |||||
| }; | |||||
| var delete_count = DeleteData(delete_sql_, bindlist); | |||||
| if (delete_count == -1) { | |||||
| throw new Exception("削除失敗 GMOクレジット"); | |||||
| } | |||||
| return delete_count; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,26 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using MySql.Data.MySqlClient; | |||||
| namespace CSVDownloader.Store.ElectronicMoneyDataStore { | |||||
| class ElectronicMoneyCSVData { | |||||
| public String spot_id = ""; | |||||
| public DateTime upd_date = DateTime.Now; | |||||
| public String upd_staff = "auto_tool"; | |||||
| public DateTime reg_date = DateTime.Now; | |||||
| public String reg_staff = "auto_tool"; | |||||
| } | |||||
| abstract class ElectronicMoneyCSVDataStore : MySQL { | |||||
| public ElectronicMoneyCSVDataStore(MySqlConnection conn) : base(conn) { | |||||
| } | |||||
| abstract public void Save(List<ElectronicMoneyCSVData> list); | |||||
| abstract public int Delete(DateTime from, DateTime to); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,168 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Data; | |||||
| using MySql.Data.MySqlClient; | |||||
| namespace CSVDownloader.Store.ElectronicMoneyDataStore { | |||||
| class GMOElectronicMoneyData : ElectronicMoneyCSVData { | |||||
| public String customer_code = ""; | |||||
| public String acquirer_id = ""; | |||||
| public String acquirer_name = ""; | |||||
| public String customer_id = ""; | |||||
| public String customer_name = ""; | |||||
| public String shop_name = ""; | |||||
| public String device_id = ""; | |||||
| public String host_device_id = ""; | |||||
| public String device_no = ""; | |||||
| public DateTime adjust_datetime = DateTime.Now; | |||||
| public String trade_code = ""; | |||||
| public int amount = 0; | |||||
| public int auto_charge_amount = 0; | |||||
| public int before_deposit = 0; | |||||
| public String brand = ""; | |||||
| public String card_id = ""; | |||||
| public String trade_status = ""; | |||||
| public String last_proccesing_datetime = ""; | |||||
| public String point = ""; | |||||
| public String trade_no = ""; | |||||
| public String origin_trade_no = ""; | |||||
| public enum ColName { | |||||
| SpotID = 100, | |||||
| CustomerCode = 0, | |||||
| AcquirerID, | |||||
| AcquirerName, | |||||
| CustomerID, CustomerName, | |||||
| ShopName, | |||||
| DeviceID, | |||||
| HostDeviceID, | |||||
| DeviceNo, | |||||
| AdjustDatetime, | |||||
| TradeCode, | |||||
| Amount, | |||||
| AutoChargeAmount, | |||||
| BeforeDeposit, | |||||
| Brand, | |||||
| CardID, | |||||
| TradeStatus, | |||||
| LastProccesingDatetime, | |||||
| Point, | |||||
| TradeNo, | |||||
| OriginTradeNo, | |||||
| UpdDate, | |||||
| UpdStaff, | |||||
| RegDate, | |||||
| RegStaff | |||||
| }; | |||||
| } | |||||
| class GMOElectronicMoneyDataStore : ElectronicMoneyCSVDataStore { | |||||
| private static readonly String table_name_ = "electronic_money_download_data_gmo"; | |||||
| private String delete_sql_ = $"delete from {table_name_} where " + | |||||
| $"{GMOElectronicMoneyData.ColName.AdjustDatetime.ToString()} between " + | |||||
| $"@From{GMOElectronicMoneyData.ColName.AdjustDatetime.ToString()} and " + | |||||
| $"@To{GMOElectronicMoneyData.ColName.AdjustDatetime.ToString()};"; | |||||
| public GMOElectronicMoneyDataStore(MySqlConnection conn) : base(conn) { | |||||
| } | |||||
| public override void Save(List<ElectronicMoneyCSVData> list) { | |||||
| Code.ResultCode ret; | |||||
| var table = new DataTable(); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.SpotID}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.CustomerCode}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.AcquirerID}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.AcquirerName}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.CustomerID}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.CustomerName}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.ShopName}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.DeviceID}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.HostDeviceID}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.DeviceNo}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.AdjustDatetime}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.TradeCode}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.Amount}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.AutoChargeAmount}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.BeforeDeposit}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.Brand}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.CardID}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.TradeStatus}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.LastProccesingDatetime}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.Point}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.TradeNo}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.OriginTradeNo}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.UpdDate}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.UpdStaff}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.RegDate}"); | |||||
| table.Columns.Add($"{GMOElectronicMoneyData.ColName.RegStaff}"); | |||||
| foreach (GMOElectronicMoneyData data in list) { | |||||
| var row = table.NewRow(); | |||||
| row[$"{GMOElectronicMoneyData.ColName.SpotID}"] = data.spot_id; | |||||
| row[$"{GMOElectronicMoneyData.ColName.CustomerCode}"] = data.customer_code; | |||||
| row[$"{GMOElectronicMoneyData.ColName.AcquirerID}"] = data.acquirer_id; | |||||
| row[$"{GMOElectronicMoneyData.ColName.AcquirerName}"] = data.acquirer_name; | |||||
| row[$"{GMOElectronicMoneyData.ColName.CustomerID}"] = data.customer_id; | |||||
| row[$"{GMOElectronicMoneyData.ColName.CustomerName}"] = data.customer_name; | |||||
| row[$"{GMOElectronicMoneyData.ColName.ShopName}"] = data.shop_name; | |||||
| row[$"{GMOElectronicMoneyData.ColName.DeviceID}"] = data.device_id; | |||||
| row[$"{GMOElectronicMoneyData.ColName.HostDeviceID}"] = data.host_device_id; | |||||
| row[$"{GMOElectronicMoneyData.ColName.DeviceNo}"] = data.device_no; | |||||
| row[$"{GMOElectronicMoneyData.ColName.AdjustDatetime}"] = data.adjust_datetime; | |||||
| row[$"{GMOElectronicMoneyData.ColName.TradeCode}"] = data.trade_code; | |||||
| row[$"{GMOElectronicMoneyData.ColName.Amount}"] = data.amount; | |||||
| row[$"{GMOElectronicMoneyData.ColName.AutoChargeAmount}"] = data.auto_charge_amount; | |||||
| row[$"{GMOElectronicMoneyData.ColName.BeforeDeposit}"] = data.before_deposit; | |||||
| row[$"{GMOElectronicMoneyData.ColName.Brand}"] = data.brand; | |||||
| row[$"{GMOElectronicMoneyData.ColName.CardID}"] = data.card_id; | |||||
| row[$"{GMOElectronicMoneyData.ColName.TradeStatus}"] = data.trade_status; | |||||
| row[$"{GMOElectronicMoneyData.ColName.LastProccesingDatetime}"] = data.last_proccesing_datetime; | |||||
| row[$"{GMOElectronicMoneyData.ColName.Point}"] = data.point; | |||||
| row[$"{GMOElectronicMoneyData.ColName.TradeNo}"] = data.trade_no; | |||||
| row[$"{GMOElectronicMoneyData.ColName.OriginTradeNo}"] = data.origin_trade_no; | |||||
| row[$"{GMOElectronicMoneyData.ColName.UpdDate}"] = data.upd_date; | |||||
| row[$"{GMOElectronicMoneyData.ColName.UpdStaff}"] = data.upd_staff; | |||||
| row[$"{GMOElectronicMoneyData.ColName.RegDate}"] = data.reg_date; | |||||
| row[$"{GMOElectronicMoneyData.ColName.RegStaff}"] = data.reg_staff; | |||||
| table.Rows.Add(row); | |||||
| } | |||||
| ret = BulkInsertData(table_name_, table); | |||||
| if (ret != Code.ResultCode.OK) { | |||||
| throw new Exception("登録失敗 GMO 電子マネー"); | |||||
| } | |||||
| } | |||||
| public override int Delete(DateTime from, DateTime to) { | |||||
| var bindlist = new List<(String, object)> { | |||||
| ("From"+GMOElectronicMoneyData.ColName.AdjustDatetime.ToString(), from.ToString("yyyy-MM-dd")), | |||||
| ("To"+GMOElectronicMoneyData.ColName.AdjustDatetime.ToString(), to.AddDays(1).ToString("yyyy-MM-dd")) | |||||
| }; | |||||
| var delete_count = DeleteData(delete_sql_, bindlist); | |||||
| if (delete_count == -1) { | |||||
| throw new Exception("削除失敗 大都QR"); | |||||
| } | |||||
| return delete_count; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,345 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.IO; | |||||
| using System.IO.Compression; | |||||
| using System.Threading; | |||||
| using System.Text; | |||||
| using OpenQA.Selenium; | |||||
| using OpenQA.Selenium.Chrome; | |||||
| using OpenQA.Selenium.Support.UI; | |||||
| using CSVDownloader.Code; | |||||
| using CSVDownloader.Store.ElectronicMoneyDataStore; | |||||
| using CSVDownloader.Store.CreditCSVData; | |||||
| using CSVDownloader.Exceptions; | |||||
| using ExpectedConditions = OpenQA.Selenium.Support.UI.ExpectedConditions; | |||||
| using System.Globalization; | |||||
| namespace CSVDownloader.Web { | |||||
| class GMOController : WebController { | |||||
| private readonly String url_ = "https://webinq.gmo-fg.net/KessaisyoukaiGUI/#no-back"; | |||||
| private readonly String filename_zip = "gmo.zip"; | |||||
| private readonly String filename_credit = "gmo_credit.csv"; | |||||
| private readonly String filename_electronic_money = "gmo_electronic_money.csv"; | |||||
| private enum XpathKey { | |||||
| INPUT_LOGIN_CUSTOMER_CODE, | |||||
| INPUT_LOGIN_USERNAME, | |||||
| INPUT_LOGIN_PASSWORD, | |||||
| BUTTON_LOGIN, | |||||
| FRAME_MAIN, | |||||
| LOADING, | |||||
| PROGRESS, | |||||
| INPUT_FROM_DATE, | |||||
| INPUT_TO_DATE, | |||||
| BUTTON_SEARCH, | |||||
| BUTTON_DOWNLOAD_ZIP, | |||||
| BUTTON_LOGOUT, | |||||
| }; | |||||
| private IDictionary<XpathKey, string> xpath_map_ = new Dictionary<XpathKey, string>() | |||||
| { | |||||
| {XpathKey.INPUT_LOGIN_CUSTOMER_CODE,@"//*[@id='companyCode']"}, | |||||
| {XpathKey.INPUT_LOGIN_USERNAME,@"//*[@id='userName']"}, | |||||
| {XpathKey.INPUT_LOGIN_PASSWORD,@"//*[@id='password']"}, | |||||
| {XpathKey.BUTTON_LOGIN,@"//*[@id='loginForm']//input[@type='submit']"}, | |||||
| {XpathKey.FRAME_MAIN,@"//*[@id='main']"}, | |||||
| {XpathKey.INPUT_FROM_DATE,@"//*[@id='_searchDateFrom']"}, | |||||
| {XpathKey.INPUT_TO_DATE,@"//*[@id='_searchDateTo']"}, | |||||
| {XpathKey.BUTTON_SEARCH,$"//*[@id='Content']//input[@value='検索']" }, | |||||
| {XpathKey.BUTTON_DOWNLOAD_ZIP,$"//*[@id='Content']//input[@value='実売上取引出力']" }, | |||||
| {XpathKey.BUTTON_LOGOUT,@"//a[@href='javascript:logout();']" }, | |||||
| {XpathKey.LOADING,@"//*[@id='loadingFont']"}, | |||||
| {XpathKey.PROGRESS,@"//*[@id='progress']"}, | |||||
| }; | |||||
| public GMOController(ChromeDriver driver) : base(driver) { | |||||
| agent_ = CreditAgent.HT; | |||||
| } | |||||
| public override ResultCode Login(LoginInfo info) { | |||||
| try { | |||||
| driver_.Navigate().GoToUrl(url_); | |||||
| Send(xpath_map_[XpathKey.INPUT_LOGIN_CUSTOMER_CODE], info.company_name); | |||||
| Send(xpath_map_[XpathKey.INPUT_LOGIN_USERNAME], info.user_name); | |||||
| Send(xpath_map_[XpathKey.INPUT_LOGIN_PASSWORD], info.password); | |||||
| Click(xpath_map_[XpathKey.BUTTON_LOGIN]); | |||||
| CloseAlert(); | |||||
| // ログイン後の「端末決済データダウンロード」が表示されることを確認する。 | |||||
| SwitchToMainFrame(); | |||||
| wait_.Until(ExpectedConditions.ElementToBeClickable(By.XPath(xpath_map_[XpathKey.BUTTON_DOWNLOAD_ZIP]))); | |||||
| SwitchToFrame(); | |||||
| } catch (Exception e) { | |||||
| logger_.Error(e.Message); | |||||
| return ResultCode.NG; | |||||
| } | |||||
| return ResultCode.OK; | |||||
| } | |||||
| public override ResultCode Download(DateTime from, DateTime to) { | |||||
| SwitchToMainFrame(); | |||||
| // 承認処理日のFrom-Toを入力 | |||||
| Clear(xpath_map_[XpathKey.INPUT_FROM_DATE]); | |||||
| Clear(xpath_map_[XpathKey.INPUT_TO_DATE]); | |||||
| Send(xpath_map_[XpathKey.INPUT_FROM_DATE], from.ToString("yyyy/MM/dd")); | |||||
| Send(xpath_map_[XpathKey.INPUT_TO_DATE], to.ToString("yyyy/MM/dd")); | |||||
| // ダウンロード開始 | |||||
| Click(xpath_map_[XpathKey.BUTTON_SEARCH]); | |||||
| wait_.Until(ExpectedConditions.InvisibilityOfElementLocated(By.XPath(xpath_map_[XpathKey.LOADING]))); | |||||
| Click(xpath_map_[XpathKey.BUTTON_DOWNLOAD_ZIP]); | |||||
| CloseAlert(); | |||||
| var long_wait = new WebDriverWait(driver_, TimeSpan.FromSeconds(360)); | |||||
| long_wait.Until(ExpectedConditions.InvisibilityOfElementLocated(By.XPath(xpath_map_[XpathKey.PROGRESS]))); | |||||
| WaitForDownload(filename_zip); | |||||
| // 解凍 | |||||
| ArchiveExtract(); | |||||
| SwitchToFrame(); | |||||
| return ResultCode.OK; | |||||
| } | |||||
| public override ResultCode Logout() { | |||||
| try { | |||||
| Click(xpath_map_[XpathKey.BUTTON_LOGOUT]); | |||||
| } catch (Exception e) { | |||||
| logger_.Error(e.Message); | |||||
| return ResultCode.NG; | |||||
| } | |||||
| return ResultCode.OK; | |||||
| } | |||||
| public override List<CreditCSVData> GetCreditCSVDataList() { | |||||
| var result_list = new List<CreditCSVData>(); | |||||
| var list = GetFileContents(filename_credit); | |||||
| bool failed_flg = false; | |||||
| var failed_parking_name_hs_table = new HashSet<String>(); | |||||
| foreach (var line in list) { | |||||
| var parking_name = line[(int)CreditCSVDataGMO.ColName.ShopName]; | |||||
| try { | |||||
| int amount = 0; | |||||
| int.TryParse(line[(int)CreditCSVDataGMO.ColName.Amount], out amount); | |||||
| int tax_send_amount = 0; | |||||
| int.TryParse(line[(int)CreditCSVDataGMO.ColName.TaxSendAmount], out tax_send_amount); | |||||
| DateTime processing_date; | |||||
| DateTime.TryParseExact(line[(int)CreditCSVDataGMO.ColName.ProcessingDate], "yyMMdd", null, DateTimeStyles.None, out processing_date); | |||||
| result_list.Add(new CreditCSVDataGMO() { | |||||
| spot_id = GetSpotID(parking_name), | |||||
| customer_code = line[(int)CreditCSVDataGMO.ColName.CustomerCode], | |||||
| output_datetime = line[(int)CreditCSVDataGMO.ColName.OutputDatetime], | |||||
| processing_code = line[(int)CreditCSVDataGMO.ColName.ProcessingCode], | |||||
| operation_code = line[(int)CreditCSVDataGMO.ColName.OperationCode], | |||||
| return_code = line[(int)CreditCSVDataGMO.ColName.ReturnCode], | |||||
| device_no = line[(int)CreditCSVDataGMO.ColName.DeviceNo], | |||||
| target_company_code = line[(int)CreditCSVDataGMO.ColName.TargetCompanyCode], | |||||
| target_company_sub_code = line[(int)CreditCSVDataGMO.ColName.TargetCompanySubCode], | |||||
| device_trade_no = line[(int)CreditCSVDataGMO.ColName.DeviceTradeNo], | |||||
| processing_date = processing_date, | |||||
| approval_no = line[(int)CreditCSVDataGMO.ColName.ApprovalNo], | |||||
| amount = amount, | |||||
| tax_send_amount = tax_send_amount, | |||||
| customer_name = line[(int)CreditCSVDataGMO.ColName.CustomerName], | |||||
| shop_name = line[(int)CreditCSVDataGMO.ColName.ShopName], | |||||
| cancel_receipt_no = line[(int)CreditCSVDataGMO.ColName.CancelReceiptNo], | |||||
| split_count_info = line[(int)CreditCSVDataGMO.ColName.SplitCountInfo], | |||||
| paying_type = line[(int)CreditCSVDataGMO.ColName.PayingType], | |||||
| }); | |||||
| } catch (ArgumentException) { | |||||
| failed_parking_name_hs_table.Add(parking_name); | |||||
| failed_flg = true; | |||||
| continue; | |||||
| } | |||||
| } | |||||
| 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); | |||||
| } | |||||
| return result_list; | |||||
| } | |||||
| public override List<ElectronicMoneyCSVData> GetElectronicMoneyCSVDataList() { | |||||
| var result_list = new List<ElectronicMoneyCSVData>(); | |||||
| var list = GetFileContents(filename_electronic_money); | |||||
| bool failed_flg = false; | |||||
| var failed_parking_name_hs_table = new HashSet<String>(); | |||||
| foreach (var line in list) { | |||||
| var parking_name = line[(int)GMOElectronicMoneyData.ColName.ShopName]; | |||||
| try { | |||||
| int amount = 0; | |||||
| int.TryParse(line[(int)GMOElectronicMoneyData.ColName.Amount], out amount); | |||||
| int auto_charge_amount = 0; | |||||
| int.TryParse(line[(int)GMOElectronicMoneyData.ColName.AutoChargeAmount], out auto_charge_amount); | |||||
| int before_deposit = 0; | |||||
| int.TryParse(line[(int)GMOElectronicMoneyData.ColName.BeforeDeposit], out before_deposit); | |||||
| //DateTime adjust_datetime; | |||||
| //DateTime.TryParseExact(line[(int)GMOElectronicMoneyData.ColName.AdjustDatetime], "yyMMdd", null, DateTimeStyles.None, out adjust_datetime); | |||||
| result_list.Add(new GMOElectronicMoneyData() { | |||||
| spot_id = GetSpotID(parking_name), | |||||
| customer_code = line[(int)GMOElectronicMoneyData.ColName.CustomerCode], | |||||
| acquirer_id = line[(int)GMOElectronicMoneyData.ColName.AcquirerID], | |||||
| acquirer_name = line[(int)GMOElectronicMoneyData.ColName.AcquirerName], | |||||
| customer_id = line[(int)GMOElectronicMoneyData.ColName.CustomerID], | |||||
| customer_name = line[(int)GMOElectronicMoneyData.ColName.CustomerName], | |||||
| shop_name = line[(int)GMOElectronicMoneyData.ColName.ShopName], | |||||
| device_id = line[(int)GMOElectronicMoneyData.ColName.DeviceID], | |||||
| host_device_id = line[(int)GMOElectronicMoneyData.ColName.HostDeviceID], | |||||
| device_no = line[(int)GMOElectronicMoneyData.ColName.DeviceNo], | |||||
| adjust_datetime = DateTime.Parse(line[(int)GMOElectronicMoneyData.ColName.AdjustDatetime]), | |||||
| trade_code = line[(int)GMOElectronicMoneyData.ColName.TradeCode], | |||||
| amount = amount, | |||||
| auto_charge_amount = auto_charge_amount, | |||||
| before_deposit = before_deposit, | |||||
| brand = line[(int)GMOElectronicMoneyData.ColName.Brand], | |||||
| card_id = line[(int)GMOElectronicMoneyData.ColName.CardID], | |||||
| trade_status = line[(int)GMOElectronicMoneyData.ColName.TradeStatus], | |||||
| last_proccesing_datetime = line[(int)GMOElectronicMoneyData.ColName.LastProccesingDatetime], | |||||
| point = line[(int)GMOElectronicMoneyData.ColName.Point], | |||||
| trade_no = line[(int)GMOElectronicMoneyData.ColName.TradeNo], | |||||
| origin_trade_no = line[(int)GMOElectronicMoneyData.ColName.OriginTradeNo], | |||||
| }); | |||||
| } catch (ArgumentException) { | |||||
| failed_parking_name_hs_table.Add(parking_name); | |||||
| failed_flg = true; | |||||
| continue; | |||||
| } | |||||
| } | |||||
| 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); | |||||
| } | |||||
| return result_list; | |||||
| } | |||||
| private List<String[]> GetFileContents(String filename) { | |||||
| var list = new List<String[]>(); | |||||
| var dir = new DirectoryInfo(DriverFactory.GetDownloadDir()); | |||||
| var config = new CSVConfig() { | |||||
| header = true, | |||||
| }; | |||||
| config.remove_char.Add("\""); | |||||
| var sjis_enc = Encoding.GetEncoding("Shift-JIS"); | |||||
| foreach (var file in dir.GetFiles()) { | |||||
| if (file.Name.Contains(filename)) { | |||||
| var result = ReadCsv(file.FullName, config, sjis_enc); | |||||
| list.AddRange(result); | |||||
| } | |||||
| } | |||||
| return list; | |||||
| } | |||||
| private void ArchiveExtract() { | |||||
| using (ZipArchive archive = ZipFile.OpenRead(Path.Combine(DriverFactory.GetDownloadDir(), filename_zip))) { | |||||
| foreach (ZipArchiveEntry entry in archive.Entries) { | |||||
| if (entry.FullName.Contains("FEP")) { | |||||
| entry.ExtractToFile(Path.Combine(DriverFactory.GetDownloadDir(), filename_credit)); | |||||
| } | |||||
| if (entry.FullName.Contains("DEN")) { | |||||
| entry.ExtractToFile(Path.Combine(DriverFactory.GetDownloadDir(), filename_electronic_money)); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| private void SwitchToMainFrame() { | |||||
| SwitchToFrame(xpath_map_[XpathKey.FRAME_MAIN]); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -2,6 +2,7 @@ | |||||
| namespace CSVDownloader.Web { | namespace CSVDownloader.Web { | ||||
| class LoginInfo { | class LoginInfo { | ||||
| public String company_name = ""; | |||||
| public String user_name = ""; | public String user_name = ""; | ||||
| public String password = ""; | public String password = ""; | ||||
| } | } | ||||
| @@ -12,6 +12,8 @@ using OpenQA.Selenium.Support.UI; | |||||
| using CSVDownloader.Code; | using CSVDownloader.Code; | ||||
| using CSVDownloader.Store.CreditCSVData; | using CSVDownloader.Store.CreditCSVData; | ||||
| using CSVDownloader.Store.QRCSVData; | using CSVDownloader.Store.QRCSVData; | ||||
| using CSVDownloader.Store.ElectronicMoneyDataStore; | |||||
| using ExpectedConditions = OpenQA.Selenium.Support.UI.ExpectedConditions; | using ExpectedConditions = OpenQA.Selenium.Support.UI.ExpectedConditions; | ||||
| namespace CSVDownloader.Web { | namespace CSVDownloader.Web { | ||||
| @@ -85,6 +87,10 @@ namespace CSVDownloader.Web { | |||||
| return new List<QRCSVData>(); | return new List<QRCSVData>(); | ||||
| } | } | ||||
| public virtual List<ElectronicMoneyCSVData> GetElectronicMoneyCSVDataList() { | |||||
| return new List<ElectronicMoneyCSVData>(); | |||||
| } | |||||
| protected void Click(String xpath, bool wait = true) { | protected void Click(String xpath, bool wait = true) { | ||||
| if (wait) { | if (wait) { | ||||
| @@ -116,6 +122,14 @@ namespace CSVDownloader.Web { | |||||
| Wait(interval_milisec_); | Wait(interval_milisec_); | ||||
| } | } | ||||
| protected void Clear(String xpath) { | |||||
| var ele = wait_.Until(ExpectedConditions.ElementExists(By.XPath(xpath))); | |||||
| ele.Clear(); | |||||
| Wait(interval_milisec_); | |||||
| } | |||||
| protected void Select(String xpath, String value) { | protected void Select(String xpath, String value) { | ||||
| try { | try { | ||||
| @@ -293,5 +307,19 @@ namespace CSVDownloader.Web { | |||||
| } | } | ||||
| } | } | ||||
| protected void CloseAlert() { | |||||
| try { | |||||
| var alert = wait_.Until(ExpectedConditions.AlertIsPresent()); | |||||
| alert.Accept(); | |||||
| } catch (Exception) { | |||||
| logger_.Info("アラート表示なし"); | |||||
| return; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| } | } | ||||