public static List <PriceCurvesModel> GetNordpoolMarketCurves(DateTime dateTime) { var file = string.Format(@"mcp_data_report_{0}-00_00_00", dateTime.ToString("dd-MM-yyyy")); string filePath = GetAppDataServerPathWith(@"\NordpoolSpot\" + file); var dd = new DataDownloader(); var er = new Utils.ExcelReader(); Stream fs; List <PriceCurvesModel> priceCurvesModels; /* If it doesn't exist, download it */ if (!File.Exists(filePath + ".json")) { var data = dd.DownloadFile(file + ".xls"); fs = new MemoryStream(data); priceCurvesModels = er.ReadNordPoolSpotPriceCurves(fs); fs.Dispose(); Commons.SaveFileAsJson(filePath + ".json", priceCurvesModels); } else { var json = File.ReadAllText(filePath + ".json"); priceCurvesModels = JsonConvert.DeserializeObject <List <PriceCurvesModel> >(json); } return(priceCurvesModels); }
protected override void OnContinue() { DataDownloader.DownloadFile(Session.settingsPath); CovidData data = CovidData.LoadJson(); GraphGenerator.GenerateGraph(1200, 1200, data.getNewCasesForDays(14)); EmailSender.sendMail(); timer.Change(3600000, Timeout.Infinite); }
public async Task TestCleanup() { await instance.DownloadFile(new Uri("http://datasets.azurewebsites.net/Resources/test.zip"), output).ConfigureAwait(false); var result = Directory.Exists(output); Assert.IsTrue(result); var files = Directory.GetFiles(output); Assert.AreEqual(1, files.Length); }
public static async Task Main(string[] args) { NLog.LogManager.LoadConfiguration("nlog.config"); starter = new AutoStarter(ApplicationLogging.LoggerFactory, "Sentiment analysis", args); starter.LoggerFactory.AddNLog(); starter.RegisterCommand <TestingCommand, TestingConfig>("test"); starter.RegisterCommand <TrainCommand, TrainingConfig>("train"); starter.RegisterCommand <BoostrapCommand, BootsrapConfig>("boot"); var configuration = new ConfigurationHandler(); var resourcesPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), configuration.GetConfiguration("Resources")); if (Directory.Exists(resourcesPath)) { log.LogInformation("Resources folder {0} found.", resourcesPath); } else { var dataDownloader = new DataDownloader(ApplicationLogging.LoggerFactory); Task download = dataDownloader.DownloadFile(new Uri(configuration.GetConfiguration("dataset")), resourcesPath); await download.ConfigureAwait(false); } #if NET472 var fPreviousExecutionState = NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS | NativeMethods.ES_SYSTEM_REQUIRED); if (fPreviousExecutionState == 0) { log.LogError("SetThreadExecutionState failed."); return; } #endif try { source = new CancellationTokenSource(); task = starter.StartAsync(source.Token); System.Console.WriteLine("Please press CTRL+C to break..."); System.Console.CancelKeyPress += ConsoleOnCancelKeyPress; await starter.Status.LastOrDefaultAsync(); System.Console.WriteLine("Exiting..."); } catch (Exception e) { System.Console.WriteLine(e); } }