/// <summary> /// Processes the alerts full. /// </summary> /// <param name="force">if set to <c>true</c> [force].</param> public void ProcessAlertsFull(bool force = false) { int successCount = 0; int failCount = 0; int tradingDate = DateHelper.DateToInt(DateTime.Now); StringBuilder resultString = new StringBuilder(); List <Alert> alertList; _auditBLL.Create(new AuditLog { ActionMessage = "Start Process", ExtraData = "", ActionType = ActionType.ProcessAlert.ToString(), ActionResult = "Start to process alerts for " + tradingDate.ToString() }); Console.WriteLine("Start to process alerts for " + tradingDate.ToString()); alertList = _unit.DataContext.Alert.Where(a => a.IsActive).ToList(); if (force) { new AlertResultBLL(_unit).DeleteAlertResultByAlert(DateHelper.DateToInt(DateTime.Now), null); } foreach (var a in alertList) { try { ProcessAlert(a, tradingDate); successCount++; resultString.Append(string.Format("successfully process alert for alert id {0}, shareid {1}, tradingdate {2}\n", a.Id, a.ShareId, tradingDate.ToString())); Console.WriteLine("successfully process alert for alert id {0}, shareid {1}, tradingdate {2}", a.Id, a.ShareId, tradingDate.ToString()); } catch (Exception ex) { failCount++; resultString.Append(string.Format("Failed to process alert for alert id {0}, shareid {1}, tradingdate {2}\n", a.Id, a.ShareId, tradingDate.ToString())); Console.WriteLine(string.Format("Failed to process alert for alert id {0}, shareid {1}, tradingdate {2}", a.Id, a.ShareId, tradingDate.ToString())); Console.WriteLine("error details: " + ex.ToString()); } } _auditBLL.Create(new AuditLog { ActionMessage = resultString.ToString(), ActionTime = DateTime.Now, ExtraData = "", ActionType = ActionType.ProcessAlert.ToString(), ActionResult = string.Format("Success: {0}; Failed {1}", successCount, failCount) }); Console.WriteLine("Success: {0}; Failed {1}", successCount, failCount); LogHelper.Info(_log, resultString.ToString()); }
/// <summary> /// Loads the daily CSV from gmail. /// </summary> public void LoadDailyCSVFromGmail() { string eodEmailAccount = ConfigurationManager.AppSettings["EODEmailAccount"]; string eodEmailPassword = ConfigurationManager.AppSettings["EODEmailPassword"]; try { var mailRepository = new MailRepository( "imap.gmail.com", 993, true, eodEmailAccount, eodEmailPassword ); var emailList = mailRepository.GetUnreadMails("inbox"); foreach (Message email in emailList) { if (email.Attachments.Count > 0 && email.Subject == "Daily Historical Data") { foreach (MimePart attachment in email.Attachments) { string result = System.Text.Encoding.UTF8.GetString(attachment.BinaryContent); SaveTickerCSVToLocal(attachment.ContentName, result); //UploadDailyPriceTickerCSVToAzure(attachment.ContentName, result); _auditBLL.Create(new AuditLog { ActionMessage = "Success upload ASX EOD to Azure", ExtraData = "", ActionType = ActionType.UploadEODToAzure.ToString(), ActionResult = "" }); } } } } catch (Exception ex) { LogHelper.Error(_log, "Error on uploading EOD csv."); LogHelper.Error(_log, ex.ToString()); throw; } }
public void UploadShareProfileFromYahooAll() { int successCount = 0; int failCount = 0; StringBuilder resultString = new StringBuilder(); List <Share> shareList = (new ShareBLL(_unit)).GetList().ToList(); foreach (Share s in shareList) { try { UploadShareProfileFromYahoo(s.Symbol); successCount++; Debug.WriteLine(successCount.ToString() + " " + string.Format("successfully upload stock info for {0} \n", s.Symbol)); resultString.Append(string.Format("successfully upload stock info for {0} \n", s.Symbol)); } catch (Exception ex) { failCount++; resultString.Append(string.Format("Fail to upload stock info for {0} \n {1}", s.Symbol, ex.ToString())); } } _auditBLL.Create(new AuditLog { ActionMessage = resultString.ToString(), ActionTime = DateTime.Now, ExtraData = "", ActionType = ActionType.UploadShareInfo.ToString(), ActionResult = string.Format("Success: {0}; Failed {1}", successCount, failCount) }); LogHelper.Info(_log, resultString.ToString()); }