} // Run private void RunOnce() { this.cashRequestsToAlert.Clear(); this.db.ForEachResult <ResetCashRequest>( rcr => this.cashRequestsToAlert.Add(rcr), "LoadResetCashRequests", CommandSpecies.StoredProcedure, new QueryParameter("@TimeSlice", this.timeSlice) ); if (this.cashRequestsToAlert.Count < 1) { this.log.Info("No cash requests to alert on."); return; } // if this.log.Info("{0} found to alert on.", Grammar.Number(this.cashRequestsToAlert.Count, "cash request")); var tbl = new Table(); tbl.Append( new Thead().Append( new Tr() .Append(new Th().Append(new Text("Cash request ID"))) .Append(new Th().Append(new Text("Decision time"))) .Append(new Th().Append(new Text("Decision"))) .Append(new Th().Append(new Text("Customer ID"))) .Append(new Th().Append(new Text("Customer name"))) .Append(new Th().Append(new Text("Customer email"))) .Append(new Th().Append(new Text("Underwriter ID"))) .Append(new Th().Append(new Text("Underwriter name"))) .Append(new Th().Append(new Text("Note"))) ) ); var tbody = new Tbody(); tbl.Append(tbody); foreach (var rcr in this.cashRequestsToAlert) { string note; try { this.db.ExecuteNonQuery( "RestoreResetCashRequest", CommandSpecies.StoredProcedure, new QueryParameter("@CashRequestID", rcr.CashRequestID) ); note = "Restored."; } catch (Exception e) { this.log.Alert(e, "Failed to restore cash request {0}.", rcr.CashRequestID); note = "Restoring failed: " + e.Message; } // try tbody.Append(new Tr() .Append(new Td().Append(new Text(rcr.CashRequestID.ToString()))) .Append(new Td().Append(new Text(rcr.DecisionTime.ToString("d/MMM/yyyy H:mm:ss", culture)))) .Append(new Td().Append(new Text(rcr.Decision.ToString()))) .Append(new Td().Append(new Text(rcr.CustomerID.ToString()))) .Append(new Td().Append(new Text(rcr.CustomerName))) .Append(new Td().Append(new Text(rcr.CustomerEmail))) .Append(new Td().Append(new Text(rcr.UnderwriterID.ToString()))) .Append(new Td().Append(new Text(rcr.UnderwriterName))) .Append(new Td().Append(new Text(note))) ); } // for each var email = new Html(); email .Append(new Head()) .Append(tbl); this.log.Debug("Sending an email..."); Mailer.SendMail( sender, Password, "#Alert - reset cash requests " + DateTime.Now.ToString("d/MMM/yyyy H:mm:ss", culture), email.ToString(), string.Join(",", this.alertList), this.log ); this.log.Debug("Sent."); } // RunOnce
} // CreateUiExtReport private void ProcessTableReportRow(ReportQuery rptDef, SafeReader sr, Tbody oTbody, int lineCounter, List <string> oColumnTypes) { var oTr = new Tr().Add <Class>(lineCounter % 2 == 0 ? "Odd" : "Even"); oTbody.Append(oTr); var oClassesToApply = new List <string>(); for (int columnIndex = 0; columnIndex < rptDef.Columns.Length; columnIndex++) { ColumnInfo col = rptDef.Columns[columnIndex]; var oValue = sr.ColumnOrDefault(col.FieldName); if (col.IsVisible) { var oTd = new Td(); oTr.Append(oTd); if (IsNumber(oValue)) { ATag oInnerTag = new Text(NumStr(oValue, col.Format(IsInt(oValue) ? 0 : 2))); if (col.ValueType == ValueType.UserID || col.ValueType == ValueType.BrokerID) { var oLink = new A(); oLink.Append(oInnerTag); oLink.Target.Append("_blank"); var titleText = "Open this customer in underwriter."; if (col.ValueType == ValueType.UserID) { oLink.Href.Append("https://" + UnderwriterSite + "/UnderWriter/Customers?customerid=" + oValue); } else { oLink.Href.Append("https://" + UnderwriterSite + "/UnderWriter/Customers#broker/" + oValue); titleText = "Open this broker in underwriter."; } oLink.Alt.Append(titleText); oLink.Title.Append(titleText); oInnerTag = oLink; if (oColumnTypes != null) { oColumnTypes[columnIndex] = "user-id"; } } else { if (oColumnTypes != null) { oColumnTypes[columnIndex] = "formatted-num"; } } // if user id oTd.Add <Class>("R").Append(oInnerTag); } else { oTd.Add <Class>("L").Append(new Text(oValue.ToString())); if ((oColumnTypes != null) && (oValue is DateTime)) { oColumnTypes[columnIndex] = "date"; } } // if } else { if (col.ValueType == ValueType.CssClass) { oClassesToApply.Add(oValue.ToString()); } } // if } // for each column if (oClassesToApply.Count > 0) { oTr.ApplyToChildren <Class>(string.Join(" ", oClassesToApply.ToArray())); } } // ProcessTableReportRow