private void initialize() { this.startAccountAlarmButton = iAccountAlarmView.getStartAccountAlarmButton(); this.accountEventHandler = iAccountAlarmView.getAccountEventHandler(); this.startAccountAlarmButton.Click += startAccountAlarmButton_Click; }
protected virtual void OnStateChanged() { AccountEventHandler handler = ConnectionStateChanged; if (handler != null) { handler(this); } }
private void InvokeVerified(SysCheckType type, bool verified) { AccountEventHandler handler = Verified; if (handler != null) { handler(type, verified); } }
private void axKHOpenAPI1_OnEventConnect(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnEventConnectEvent e) { if (e.nErrCode == 0) { /** * 로그인 성공시: * - progressbar update * - DB를 접속해서 어제 수집한 종목들을 gridview에 추가해 준다. * - Handler 들을 초기화한다? */ toolStripProgressBar.Value = 100; logger.Info($"로그인 성공. {DateTime.Now}"); toolStripStatusLabel.Text = $"로그인 성공. {DateTime.Now}"; opw00018EventHandler = new Opw00018EventHandler(this, axKHOpenAPI1); conditionEventHandler = new ConditionEventHandler(this, axKHOpenAPI1); accountEventHandler = new AccountEventHandler(this, axKHOpenAPI1); collectItemsViewController = new CollectItemsViewController(this); accountAlarmViewController = new AccountAlarmViewController(this); settingsViewController = new SettingsViewController(this, this); chejanViewController = new ChejanViewController(this); } }
private void initialize() { this.accountEventHandler = iAccountAlarmView.getAccountEventHandler(); this.noMonitoringAccountListBox = iSettingsView.getNoMonitoringAccountListBox(); this.monitoringAccountListBox = iSettingsView.getMonitoringAccountListBox(); this.addAccountToMonitoringButton = iSettingsView.getAddAccountToMonitoringButton(); this.deleteAccountToMonitoringButton = iSettingsView.getDeleteAccountToMonitoringButton(); this.monitoringAccountSaveButton = iSettingsView.getMonitoringAccountSaveButton(); this.addAccountToMonitoringButton.Click += addAccountToMonitoringButton_Click; this.deleteAccountToMonitoringButton.Click += deleteAccountToMonitoringButton_Click; this.monitoringAccountSaveButton.Click += monitoringAccountSaveButton_Click; /** * ListBox 가 초기화 되는 과정 * - 우선 GetLoginInfo("ACCLIST"); 로 가져온다 * - 기존에 감시계좌로 설정된 계좌가 있는지 json 파일을 뒤져서 가져온다. * - 있으면 monitoringAccountListBox 에 표현한다. * - 없으면 가져온 계좌를 noMonitoringAccountListBox 에 표현한다. */ accounts = this.accountEventHandler.getAccountList(); if (!File.Exists(Application.StartupPath + "\\accounts.json")) { /** * account.json 파일이 없을 때는 파일을 만들어준다. 다만 여기서는 그냥 빈 파일만 생성한다. * 그리고 계좌리스트를 noMonitoringAccountListBox에 로드한다. */ FileStream f = File.Create(Application.StartupPath + "\\accounts.json"); logger.Info("File Created!! " + Application.StartupPath + "\\accounts.json"); f.Close(); loadAccountListToNoMonitoringAccountListBox(); } else { /** * account.json 파일이 있다면 accountList key 가 있는지 확인한다. * 있다면 accounts 에서 account.json 에 있는 계좌를 빼서 noMonitoringAccountListBox 에 표현 * 없다면 accounts 를 monitoringAccountListBox 에 표현 (catch 절 안에서 하면 됨) */ logger.Info("File Exists!! " + Application.StartupPath + "\\accounts.json"); try { StreamReader r = new StreamReader(Application.StartupPath + "\\accounts.json"); string json = r.ReadToEnd(); r.Close(); var readJson = JObject.Parse(json.ToString()); if (readJson.ContainsKey("accountList")) { //COMPLETE. accountList가 있다면 //accounts 에서 account.json 에 있는 계좌를 빼서 noMonitoringAccountListBox 에 표현 var jArr = JArray.Parse(readJson["accountList"].ToString()); foreach (var i in jArr) { monitoringAccountListBox.Items.Add(i.ToString().Replace("\"", "")); } foreach (var j in accounts) { //accounts 에 있지만 account.json에 없는 계좌는 noMonitoringAccountListBox 에 표현 if (!monitoringAccountListBox.Items.Contains(j.accountNumber)) { noMonitoringAccountListBox.Items.Add(j.accountNumber); } } } else { throw new Exception(); } } catch (Exception exception) { logger.Error(exception.Message.ToString()); loadAccountListToNoMonitoringAccountListBox(); } } }