Пример #1
0
        public static void SendTickReportData(Dictionary <string, TickReportData> data, Delivery deliveryMethod)
        {
            //TODO: Refactor this pile
            foreach (string s in Directory.GetFiles(TempGraphsDirectory))
            {
                File.Delete(s);
            }
            NotifDownloader.DownloadAndSaveChartFile(data.Keys.ToArray(), TempGraphsDirectory);
            if (deliveryMethod.Equals(Delivery.FTP))
            {
                NotifFTP.DeleteFiles("graphs");
                NotifFTP.UploadFiles(Directory.GetFiles(TempGraphsDirectory), "graphs");
            }
            //TODO: Refactor this pile

            int           count       = 1;
            string        html        = GetResourceFromPath(TickReportDataHtmlPath);
            StringBuilder sb          = new StringBuilder();
            string        tableFormat = @"<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td><td>{7}</td><td>{8}</td><td>{9}</td><td><img src='graphs/{10}.png'/></td></tr>";

            foreach (var key in data.Keys.OrderBy(x => x.ToLower()))
            {
                var tickData = data[key];
                var rsi5     = (tickData.RSI5D == -1) ? "-" : tickData.RSI5D.ToString();
                sb.Append(string.Format(tableFormat, tickData.HasPosition, count++, tickData.Symbol, tickData.PrevClose, tickData.CurrentVolume, tickData.CurrentPrice, ChangeInText(tickData.ChangeInPrice), rsi5, tickData.MACD5DHistogram, tickData.MACD5DBuySell, tickData.Symbol));
            }

            html = html.Replace("<!--data-->", sb.ToString());
            html = html.Replace("<!--css-->", GetResourceFromPath(CSSStylePath));
            html = html.Replace("<!--js-->", GetResourceFromPath(TableSortJS));
            html = html.Replace("<!--rundate-->", DateTime.Now.ToString());

            Send(html, deliveryMethod, @"C:\temp\intraday.html", "FIRPy 2.0 Intraday");
        }
Пример #2
0
 private static void Send(string html, Delivery deliveryMethod, string filePathAndName, string subject)
 {
     if (deliveryMethod.Equals(Delivery.FileServer))
     {
         File.WriteAllText(filePathAndName, html);
     }
     else if (deliveryMethod.Equals(Delivery.Email))
     {
         File.WriteAllText(filePathAndName, html);
         NotifEmailer.SendEmail(subject, "Message Attached", filePathAndName);
     }
     else if (deliveryMethod.Equals(Delivery.FTP))
     {
         File.WriteAllText(filePathAndName, html);
         NotifFTP.UploadFile(filePathAndName);
     }
 }