diff --git a/CSVDownloader/Program.cs b/CSVDownloader/Program.cs
index d21ff84..c309195 100644
--- a/CSVDownloader/Program.cs
+++ b/CSVDownloader/Program.cs
@@ -3,12 +3,14 @@ using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Linq;
+using System.Text.RegularExpressions;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
using SeleniumExtras.WaitHelpers;
+using CSVDownloader.Code;
using CSVDownloader.File;
using CSVDownloader.Store;
using CSVDownloader.Store.CreditCSVData;
@@ -33,7 +35,7 @@ namespace CSVDownloader {
var exe_directory_path = Path.GetDirectoryName(exe_path);
Directory.SetCurrentDirectory(exe_directory_path);
- var controller = new Controller();
+ var controller = new Controller(args);
String ret = controller.Start();
@@ -95,6 +97,58 @@ namespace CSVDownloader {
private int save_chunk_num_ = 100;
+ // パラメータあり起動時の動作条件------ START
+ private bool hasParam_ = false;
+ private DateTime paramDateFrom_ = DateTime.Today;
+ private DateTime paramDateTo_ = DateTime.Today;
+ private string paramAgentCode_ = "";
+ // パラメータあり起動時の動作条件------ END
+
+ public Controller(string[] args) {
+
+ // 引数なしは通常動作
+ if (args.Count() == 0) {
+ return;
+ }
+
+ // 開始終了日付指定 決済会社コード指定
+ if (args.Count() == 3) {
+
+ DateTime from = DateTime.Today;
+ DateTime to = DateTime.Today;
+
+ var fromStr = args[0];
+ var toStr = args[1];
+
+ var dateReg = new Regex(@"^\d{4}/\d{2}/\d{2}$");
+
+ if (dateReg.IsMatch(fromStr) && !DateTime.TryParse(fromStr, out from)) {
+ throw new Exception("起動引数不正 FROM 日付フォーマット");
+ }
+ if (dateReg.IsMatch(toStr) && !DateTime.TryParse(toStr, out to)) {
+ throw new Exception("起動引数不正 TO 日付フォーマット");
+ }
+
+ if (to < from) {
+ throw new Exception("起動引数不正 FROMが大きい");
+ }
+
+ hasParam_ = true;
+ paramDateFrom_ = from;
+ paramDateTo_ = to;
+ paramAgentCode_ = args[2];
+
+ var message = $"★★★★★★起動引数あり FROM:{fromStr} TO:{toStr} AGENT:{paramAgentCode_}★★★★★★";
+ Console.WriteLine(message);
+ logger_.Info(message);
+
+ return;
+ }
+
+ throw new Exception("起動引数不正");
+ }
+
+
public String Start() {
Console.WriteLine("★★★★★★自動CSVダウンロード 起動★★★★★");
logger_.Info("★★★★★★自動CSVダウンロード 起動★★★★★");
@@ -172,21 +226,25 @@ namespace CSVDownloader {
// CREVAS
{
var controller = new DaitoController(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(), daito_credit_store_);
- qr_datastore_map_.Add(controller.GetCreditAgent(), daito_qr_store_);
- electronic_money_datastore_map_.Add(controller.GetCreditAgent(), daito_electronic_money_store_);
+ if (!hasParam_ || paramAgentCode_ == controller.GetCreditAgentCode()) {
+ 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(), daito_credit_store_);
+ qr_datastore_map_.Add(controller.GetCreditAgent(), daito_qr_store_);
+ electronic_money_datastore_map_.Add(controller.GetCreditAgent(), daito_electronic_money_store_);
+ }
}
// Zeus
{
var controller = new ZeusController(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(), zeus_credit_store_);
+ if (!hasParam_ || paramAgentCode_ == controller.GetCreditAgentCode()) {
+ 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(), zeus_credit_store_);
+ }
}
// Itec
{
@@ -208,11 +266,13 @@ namespace CSVDownloader {
// HelloTechno(GMO)
{
var controller = new GMOController(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(), gmo_credit_store_);
- electronic_money_datastore_map_.Add(controller.GetCreditAgent(), gmo_electronic_money_store_);
+ if (!hasParam_ || paramAgentCode_ == controller.GetCreditAgentCode()) {
+ 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(), gmo_credit_store_);
+ electronic_money_datastore_map_.Add(controller.GetCreditAgent(), gmo_electronic_money_store_);
+ }
}
@@ -381,7 +441,11 @@ namespace CSVDownloader {
web_controller.Archive(GetArchiveFilename(agent, DateTime.Now));
// 履歴の登録
- history_dao_.Save(agent, DateTime.Now);
+ if (!hasParam_) {
+ history_dao_.Save(agent, DateTime.Now);
+ } else {
+ logger_.Info("パラメータ指定起動のため、取得履歴は保存しない");
+ }
logger_.Info($"ダウンロード終了 対象:{agent}");
} catch (Exception e) {
@@ -406,6 +470,14 @@ namespace CSVDownloader {
///
///
private (DateTime, DateTime) GetFromTo(Code.CreditAgent agent, List history) {
+
+
+ // 起動パラメータがある場合はそれを設定する
+ if (hasParam_) {
+ return (paramDateFrom_, paramDateTo_);
+ }
+
+
DateTime from, to;
if (agent == Code.CreditAgent.Zeus) {
diff --git a/CSVDownloader/Web/WebController.cs b/CSVDownloader/Web/WebController.cs
index bafb6b7..6189dd9 100644
--- a/CSVDownloader/Web/WebController.cs
+++ b/CSVDownloader/Web/WebController.cs
@@ -51,6 +51,10 @@ namespace CSVDownloader.Web {
return agent_;
}
+ public string GetCreditAgentCode() {
+ return CreditAgenciesMap.GetID(agent_);
+ }
+
abstract public ResultCode Login(LoginInfo login_info);
abstract public ResultCode Download(DateTime from, DateTime to);