public void WillSendEmail() { //string message = $@"{DateTime.Now.ToLongDateString()} There was a problem processing GoogleFinance. \n\n{"This is a test."}"; string message = string.Format(@"JJ,\nI updated the Dropbox minute and daily data. \nThe process completed at {0}\n Files were copied.\n\nNick\n\nThis message was auto generated by the MarketData program. Do not reply to the sending address.", DateTime.Now.ToLongDateString()); Notifications n = new Notifications(); var ret = n.CustomEmail("*****@*****.**", "Dropbox files have been updated", message); Assert.IsTrue(ret); }
/// <summary> /// Entry point into the console app /// </summary> private static void Main(string[] args) { try { //foreach (String s2 in Environment.GetEnvironmentVariables().Keys) // Console.WriteLine(s2 + "=" + Environment.GetEnvironmentVariable(s2).ToString()); Arguments commandLine = new Arguments(args); if (args[0] == "-r") RenameInteriorFiles(); else { GetHelp(commandLine); // Defalult to minute unless the user specifies eod var resolution = GetResolution(commandLine); var runmode = GetRunmode(commandLine); var destinationDirectory = GetDestinationDirectory(commandLine); var defaultInputFile = GetDefaultInputFile(commandLine); DisplayInteractiveInstructions(runmode); GetOptionsInteractive(runmode, ref defaultInputFile, ref destinationDirectory, ref resolution); if (runmode == Enums.Runmode.Automatic) { Console.WriteLine("1. Source file for ticker symbol and exchange list: \n" + defaultInputFile); Console.WriteLine("2. Destination LEAN Data directory: \n" + destinationDirectory); Console.WriteLine("3. Both minute and eod will run. "); } //Validate the user input: Validate(defaultInputFile, destinationDirectory, resolution.ToString()); //Remove the final slash to make the path building easier: defaultInputFile = StripFinalSlash(defaultInputFile); destinationDirectory = StripFinalSlash(destinationDirectory); string[] validatedArgs = new string[3]; validatedArgs[0] = defaultInputFile; validatedArgs[1] = destinationDirectory; validatedArgs[2] = resolution.ToString(); Console.WriteLine("Processing Files ..."); if (runmode == Enums.Runmode.Automatic) { validatedArgs[2] = "minute"; Task.Run(async () => { await MainAsync(validatedArgs); }).Wait(); validatedArgs[2] = "eod"; Task.Run(async () => { await MainAsync(validatedArgs); }).Wait(); FileCopier fc = new FileCopier(); int filescopied = fc.CopyFiles(); string message = string.Format(@"JJ,\nI updated the Dropbox minute and daily data. \nThe process completed at {0}\n{1} Files were copied.\n\nNick\n\nThis message was auto generated by the MarketData program. Do not reply to the sending address.", DateTime.Now.ToLongDateString(), filescopied); Notifications n = new Notifications(); n.CustomEmail("*****@*****.**", "Dropbox files have been updated", message); } else { Task.Run(async () => { await MainAsync(validatedArgs); }).Wait(); } } // if auto, just run the thing and exit //if (runmode == Enums.Runmode.Automatic) //{ //} } catch (Exception ex) { Console.WriteLine(ex.Message + ex.StackTrace); string message = string.Format(@"{0} There was a problem processing GoogleFinance. \n\n{1}", DateTime.Now.ToLongDateString(), ex.Message + "\n" + ex.StackTrace); Notifications n = new Notifications(); n.CustomEmail("*****@*****.**", "error processing Google Finance download", message); } finally { Console.WriteLine("Done. Press any key to exit."); Console.ReadKey(); } }
private async Task GetMinuteAndDailyData() { Cursor currentCursor = Cursor.Current; currentCursor = Cursors.WaitCursor; var destinationDirectory = Config.GetDefaultDownloadDirectory(); var defaultInputFile = Config.GetDefaultInputFile(); string[] validatedArgs = new string[3]; validatedArgs[0] = defaultInputFile; validatedArgs[1] = destinationDirectory; richTextBoxData.Text = "Processing Files ...\n"; richTextBoxData.Refresh(); validatedArgs[2] = "minute"; Logger logger = new Logger("errors.txt"); try { FileInfo tickerListInfo = new FileInfo(validatedArgs[0]); string directory = validatedArgs[1]; MinuteDownloader minuteDownloader = new MinuteDownloader(tickerListInfo, directory) { FormatAsMilliseconds = true, SplitDays = true, ZipOutput = true, logger = new Logger("MinuteLog.txt") }; await minuteDownloader.DownloadDataFromListAsync(); tickerListInfo = new FileInfo(validatedArgs[0]); directory = validatedArgs[1]; AllDataDownloader downloader = new AllDataDownloader(tickerListInfo, directory) { ZipOutput = true, logger = new Logger("DailyLogger.txt") }; await downloader.DownloadDataFromListAsync(); CopyFiles(); string message = string.Format(@"JJ,\nI updated the Dropbox minute and daily data. \nThe process completed at {0}\n Files were copied.\n\nNick\n\nThis message was auto generated by the MarketData program. Do not reply to the sending address.", DateTime.Now.ToLongDateString()); Notifications n = new Notifications(); if (n.CustomEmail("*****@*****.**", "Dropbox files have been updated", message)) { richTextBoxData.Text += "Email Sent\n"; } } catch (Exception ex) { logger.Log(ex.Message + ex.StackTrace); } finally { Cursor.Current = currentCursor; } }