// From nasdaq <a href="companies-by-industry.aspx?exchange=NYSE&render=download" rel="nofollow"><b>Download this list</b></a> private async void buttonList_Click(object sender, EventArgs e) { string tickerListFilename = GetTickerListFilepath(); if (tickerListFilename != string.Empty) { FileInfo tickerListInfo = new FileInfo(tickerListFilename); string directory = Config.GetDefaultDownloadDirectory(); directory = GetSaveDirectory(); if (directory.Length > 0) { Cursor currentCursor = Cursor.Current; currentCursor = Cursors.WaitCursor; var caption = buttonList.Text; // update ui buttonList.Text = @"Downloading"; buttonList.Enabled = false; checkBoxDateTime.Checked = true; checkBoxSplitDays.Checked = true; checkBoxZipOutput.Checked = true; try { if (radioButtonMinutes.Checked) { // Save the data to zip files MinuteDownloader minuteDownloader = new MinuteDownloader(tickerListInfo, directory) { FormatAsMilliseconds = true, SplitDays = true, ZipOutput = true, OutputDirectory = directory }; minuteDownloader.logger = new Logger("MinuteLog.txt"); await minuteDownloader.DownloadDataFromListAsync(); } if (radioButtonAllData.Checked) { AllDataDownloader allDataDownloader = new AllDataDownloader(tickerListInfo, directory) { ZipOutput = true, OutputDirectory = directory }; allDataDownloader.logger = new Logger("DailyLog.txt"); await allDataDownloader.DownloadDataFromListAsync(); } } catch (Exception exc) { ErrorFunction(exc.Message, exc); } finally { Cursor.Current = currentCursor; buttonList.Enabled = true; buttonList.Text = caption; MessageBox.Show(@"Done"); } } } }
/// <summary> /// The async portion of the app /// </summary> /// <param name="args">string[] - a validated copy of the command line args</param> /// <returns>nothing</returns> private static async Task MainAsync(string[] args) { Logger logger = new Logger("errors.txt"); if (args[2] == "minute") { try { FileInfo tickerListInfo = new FileInfo(args[0]); string directory = args[1]; MinuteDownloader minuteDownloader = new MinuteDownloader(tickerListInfo, directory) { FormatAsMilliseconds = true, SplitDays = true, ZipOutput = true }; minuteDownloader.logger = new Logger("MinuteLog.txt"); await minuteDownloader.DownloadDataFromListAsync(); } catch (Exception e) { logger.Log(e.Message + e.StackTrace); } } if (args[2].ToLower() == "eod" || args[2].ToLower() == "daily") { try { FileInfo tickerListInfo = new FileInfo(args[0]); string directory = args[1]; AllDataDownloader downloader = new AllDataDownloader(tickerListInfo, directory) { ZipOutput = true }; downloader.logger = new Logger("DailyLogger.txt"); await downloader.DownloadDataFromListAsync(); } catch (Exception e) { logger.Log(e.Message + e.StackTrace); } } }
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; } }