/// <summary> /// Get the interested tradingDay. If today is Friday, and freq is Weekly, the whole week days is returned. /// Or, if freq is Daily, only today is returned. /// </summary> /// <param name="client_"></param> /// <param name="date_"></param> /// <param name="freq_"></param> /// <returns>The interested days.</returns> private List <string> prepareAndUpdateDate(Client client_, string date_, ReportFrequency freq_) { List <string> dateSpan = DateTimeUtil.getDateSpan(date_, freq_, StoredProcMgr.MANAGER.getTradingDays()); StoredProcMgr.MANAGER.updateTmpTradingDay(freq_, dateSpan); return(dateSpan); }
public void addClientToMail(Client client_, ReportFrequency freq_) { string freq = freq_ == ReportFrequency.NONE ? "" : freq_.ToString(); body += (freq + " ClientReport " + client_.getClientName() + "(" + client_.getAccountId() + ") ClientOrder " + client_.getTradeCount() + " "); body += Environment.NewLine; }
private static bool isInSameRange(string anchor_, string target_, ReportFrequency freq_) { if (ReportFrequency.WEEKLY == freq_) { return(isSameWeek(anchor_, target_)); } else { return(isSameMonth(anchor_, target_)); } }
public override string ToCSV() { string outputStr = null; outputStr += "\"" + ReportFrequency.ToString() + "\","; outputStr += "\"" + ReportTypeOutput.ReportTypeStr(ReportType) + "\","; outputStr += "\"\","; outputStr += "\"" + ReportMessage + "\","; outputStr += "\"" + Path + "\""; return(outputStr); }
/// <summary> /// Generate and send client report /// </summary> /// <param name="client_">Client info, containing trades.</param> /// <param name="dateSpan_">tradingDays.</param> /// <returns>to whom the report is sent. Will log it and write this info to email.</returns> private void doReport(Client client_, List <string> dateSpan_, ReportFrequency frequency_) { excelHelper.before(client_, dateSpan_); string fileDir = excelHelper.createWorkSheet(client_); fileMgr.recordAnExcel(fileDir); string toList = ReportSenderMgr.SENDER.sendClientReport(client_, dateSpan_, fileDir); ReportSenderMgr.SENDER.getExecReportSender().addClientToMail(client_, frequency_); ReportSenderMgr.SENDER.getExecReportSender().addMessage(toList); }
/// <summary> /// Prepare and send report /// </summary> /// <param name="client_">The client</param> /// <param name="date_">tradingDay</param> /// <param name="freq_">Report frequency</param> private void prepareSendReport(Client client_, string date_, ReportFrequency freq_) { List <string> dateSpan = prepareAndUpdateDate(client_, date_, freq_); bool hasTrades = prepareClientTrades(client_); logger.Info(client_.getClientName() + " of date " + date_ + " has trades :" + hasTrades); if (hasTrades) { doReport(client_, dateSpan, freq_); } }
/* * Set TmpTradingDay whenever the target dates are known. * */ public void updateTmpTradingDay(ReportFrequency freq_, List <string> dateSpan_) { if (freq_ == lastUpdateFreq) { return; } else { clientOrderProc.updateTmpTradingDay(dateSpan_, connection); lastUpdateFreq = freq_; } }
public override string ToString() { string outputStr = null; outputStr += ReportFrequency.ToString() + '\t'; outputStr += _delimiterFlag.ToString() + '\t'; outputStr += ReportTypeOutput.ReportTypeStr(ReportType) + '\t'; outputStr += PathResolves.ToString() + '\t'; outputStr += ReportMessage + '\t'; outputStr += Path + '\t'; return(outputStr); }
private StoredProcMgr() { this.tradingDayProc = new StoredProcGetTradingDay(); this.clientOrderProc = new StoredProcClientOrder(); this.exchangeOrderProc = new StoredProcExchangeOrder(); this.conditionOrderProc = new StoredProcConditionOrder(); this.engineListProc = new StoredProcGetEngineList(); this.clientsProc = new StoredProcGetClients(); this.newClientProc = new StoredProcGetNewClient(); this.multiplierProc = new StoredProcGetMultiplier(); this.lastUpdateFreq = ReportFrequency.NONE; }
protected override void parseResult(SqlDataReader reader_) { while (reader_.Read()) { string accountId = reader_["accountId"].ToString(); string clientName = reader_["clientName"].ToString(); string email = reader_["email"].ToString(); string repsentEmail = reader_["repsentEmail"].ToString(); bool sendToClient = reader_["sendToClient"].ToString().Equals(ISVALID) ? true : false; //bool mergeOrder = reader_["mergeOrder"].ToString().Equals(ISVALID) ? true : false; string freq = reader_["reportFrequency"].ToString().ToUpper(); ReportFrequency frequency = (ReportFrequency)System.Enum.Parse(typeof(ReportFrequency), freq); bool isValid = reader_["isValid"].ToString().Equals(ISVALID) ? true : false; string clientAbbr = reader_["clientAbbreviation"].ToString(); clientList.Add(new Client(accountId, clientName, email, repsentEmail, sendToClient, frequency, isValid, clientAbbr)); } }
// FIXME Better in another seperate class? public static List <string> getDateSpan(string anchor_, ReportFrequency freq_, List <string> tradingDays_) { List <string> dateSpan = new List <string>(); if (ReportFrequency.NONE == freq_) { return(dateSpan); } else if (ReportFrequency.DAILY == freq_) { dateSpan.Add(anchor_); return(dateSpan); } else { return(getDateRange(anchor_, freq_, tradingDays_)); } }
/// <summary> /// Construct a client, which is read from database /// </summary> /// <param name="accountId_">Client AccountId</param> /// <param name="clientName_">client name, say the company name</param> /// <param name="email_">Client Email</param> /// <param name="repsentEmail_">Representative Email, one guy of our own who covers this client</param> /// <param name="sendToClient_">If true, send report to client; if false, send to representative</param> /// <param name="mergeOrders_">If true, same stock, same day should be merged as one order; false otherwise</param> /// <param name="frequency_">Report frequency</param> /// <param name="isValid_">If this client is valid</param> public Client(string accountId_, string clientName_, string email_, string repsentEmail_, bool sendToClient_, ReportFrequency frequency_, bool isValid_, string clientAbbr_) { accountId = accountId_; clientName = clientName_; email = email_; repsentEmail = repsentEmail_; sendToClient = sendToClient_; //mergeOrders = mergeOrders_; frequency = frequency_; isValid = isValid_; this.clientAbbr = clientAbbr_; tradingDays = new List <string>(); ccList = new List <string>(); trades = new List <SavedClientOrder>(); }
private static List <string> getDateRange(string anchor_, ReportFrequency freq_, List <string> tradingDays_) { List <string> weekDays = new List <string>(); int idx = tradingDays_.IndexOf(anchor_); string targetDay = null; for (int i = idx; i >= 0; i--) { targetDay = tradingDays_[i]; if (isInSameRange(anchor_, targetDay, freq_)) { weekDays.Add(targetDay); } else { break; } } return(weekDays); }
private static ParameterValue DateTimeRangeParameterForReportFrequency(ReportFrequency reportFrequency) { return new ParameterValue(DateTimeRangeParameterName, reportFrequency == ReportFrequency.Daily ? YesterdayDateTimeRangeValue : LastSevenDaysDateTimeRangeValue); }
private static IEnumerable<ParameterValue> DateTimeRangeParameterArrayForReportFrequency(ReportFrequency reportFrequency) { return new[] { DateTimeRangeParameterForReportFrequency(reportFrequency) }; }
/// <summary> /// Parses the settings string into its configuration settings. /// </summary> /// <param name="settings"></param> private void ParseSettings(string settings) { XmlDocument doc = new XmlDocument(); doc.LoadXml(settings); // Get whether reporting is enabled. enabled = Boolean.Parse(doc.DocumentElement.GetAttribute("enabled")); if (Enabled) { // Get the frequency of the report generation. XmlElement element = doc.DocumentElement.SelectSingleNode("generate") as XmlElement; if (element != null) { string s = element.GetAttribute("frequency"); if (s != String.Empty) { frequency = ( ReportFrequency )Enum.Parse( typeof(ReportFrequency), s, true); } else { log.Error("Invalid report settings format. No frequency attribute was specified."); } } else { log.Error("Invalid report settings format. No generate element was specified."); } // All frequencies will have a time specified. XmlElement child = element.SelectSingleNode("time") as XmlElement; if (child != null) { DateTime dt = DateTime.Parse(child.InnerText); timeOfDay = new TimeSpan(dt.Hour, dt.Minute, 0); } else { log.Error("Invalid report settings format. No time element was specified."); } // Depending on the frequency type, the time parameters will be different. switch (frequency) { case ReportFrequency.Daily: break; case ReportFrequency.Weekly: // Get the day of the week. child = element.SelectSingleNode("dayofweek") as XmlElement; if (child != null) { weekday = ( DayOfWeek )Enum.Parse(typeof(DayOfWeek), child.InnerText, true); } else { log.Error("Invalid report settings format. No day of week element was specified."); } break; case ReportFrequency.Monthly: // Get the day of the month. child = element.SelectSingleNode("dayofmonth") as XmlElement; if (child != null) { dayOfMonth = Convert.ToInt32(child.InnerText); } else { log.Error("Invalid report settings format. No day of month element was specified."); } break; } // Get the report location information. element = doc.DocumentElement.SelectSingleNode("location") as XmlElement; if (element != null) { isiFolder = (element.InnerText == "ifolder") ? true : false; } else { log.Error("Invalid report settings format. No location element was specified."); } // Get the report format. element = doc.DocumentElement.SelectSingleNode("format") as XmlElement; if (element != null) { format = ( ReportFormat )Enum.Parse(typeof(ReportFormat), element.InnerText, true); } else { log.Error("Invalid report settings format. No format element was specified."); } } }