/** * Mutator method that updates the data. Runs a request against the middle tier */ public static void update() { //Updates the main data XmlDocument data_xml = new XmlDocument(); String ret = Functions.MTRequest("AR.MARKET.SHARE.SDR", "", true); if (ret != "") { data_xml.LoadXml(ret); XmlNode root = data_xml.SelectSingleNode("report"); if (root != null) { data.clear(); //< More efficient than GC, since the space is roughly going to be the same foreach (XmlNode transaction in root.SelectNodes("transaction")) { GraphData.Transaction myTransaction = new GraphData.Transaction(); myTransaction.contract_name = Functions.SelectSingleNodeSafe(transaction, "contract_name"); myTransaction.source = Functions.SelectSingleNodeSafe(transaction, "source"); myTransaction.type = Functions.SelectSingleNodeSafe(transaction, "type"); myTransaction.start_date = Functions.SelectSingleNodeSafe(transaction, "start_date"); myTransaction.end_date = Functions.SelectSingleNodeSafe(transaction, "end_date"); myTransaction.exec_time = Functions.SelectSingleNodeSafe(transaction, "exec_time"); myTransaction.strategy = Functions.SelectSingleNodeSafe(transaction, "strategy"); myTransaction.total_volume = Double.Parse(Functions.SelectSingleNodeSafe(transaction, "total_volume")); myTransaction.daily_volume = Double.Parse(Functions.SelectSingleNodeSafe(transaction, "daily_volume")); myTransaction.price = Double.Parse(Functions.SelectSingleNodeSafe(transaction, "price")); myTransaction.premium = Double.Parse(Functions.SelectSingleNodeSafe(transaction, "premium")); myTransaction.strike = Double.Parse(Functions.SelectSingleNodeSafe(transaction, "strike")); myTransaction.unit = Functions.SelectSingleNodeSafe(transaction, "unit"); myTransaction.status = Functions.SelectSingleNodeSafe(transaction, "status"); myTransaction.report_time = Functions.SelectSingleNodeSafe(transaction, "report_time"); data.add(myTransaction); } //Sets the new update timer lastUpdate_ms = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; // Updates the timer with DateTimeOffset implementation of time in milliseconds } } }
public ActionResult Email(FormCollection collection) { String emailAddr = (string)Session["email"]; if (emailAddr == null || String.Empty == emailAddr) { return(Json(new { success = false, responseText = "Email Address is empty or null. Verify cookies." })); Log.Error("Invalid email when sending alert for user: "******"username"]); } try { string server = Functions.GetConfigSetting("email"); MailMessage emailMessage = new MailMessage(); emailMessage.From = new MailAddress(""); emailMessage.Subject = "SDRDataParser Alert: " + Functions.getTime(Session["timeZone"], "hh:mm:sstt", true) + Functions.getTime(Session["timeZone"], " on MMMM dd, yyyy", false); emailMessage.To.Add(emailAddr); emailMessage.IsBodyHtml = true; SmtpClient emailClient = new SmtpClient(server); GraphData.Transaction transaction = new GraphData.Transaction(collection); string htmlString = RenderViewToString("Home", "EmailAlert", transaction, new ControllerContext(this.Request.RequestContext, new HomeController())); emailMessage.Body += htmlString; emailClient.Send(emailMessage); return(Json(new { success = true, responseText = "Successfully sent email alert" })); } catch (Exception e) { Log.Error("An error occured while sending email: " + e.Message); return(Json(new { success = false, responseText = "Error sending email" + e.Message })); } }