public async Task Setup(Linker _linker, IProgress <string> progress) { linker = _linker; logger.Info("Loading Online Data..."); progress.Report("Loading Online Data..."); // Load Data from API data = OnlineData.LoadData(await FetchURLData(linker.minerManager.GetDataURL())); }
public async Task InstallMiner(string id, IProgress <string> progress) { OnlineData onlineData = linker.networkManager.data; if (linker.networkManager.data.miners.ContainsKey(id) && linker.networkManager.data.miners[id] != null) { // Get data for miner to install OnlineMiner minerToInstall = linker.networkManager.data.miners[id]; string downloadPath = Path.GetDataDirectory() + minerToInstall.fileNameZip; // If it's a direct zip, use direct file downloadPath if (minerToInstall.fileNameZip == Config.NO_ZIP_KW) { downloadPath = Path.GetDataDirectory() + minerToInstall.fileNameMine; } logger.Info("Downloading miner \"" + id + "\""); progress.Report("Downloading miner \"" + id + "\""); // Download the file async await linker.networkManager.DownloadFileAsync(downloadPath, minerToInstall.downloadURL); logger.Info("Installing miner \"" + id + "\""); progress.Report("Installing miner \"" + id + "\""); // Get Install Path string installPath = Path.GetMinerDirectory(id); minerToInstall.installPath = installPath; // If the file isn't a zip, create a folder instead if (minerToInstall.fileNameZip == Config.NO_ZIP_KW) { await linker.networkManager.InstallInFolder(downloadPath, installPath); } // If the file IS a zip, extract it else { // Extract the zip async await linker.networkManager.ExtractZipFile(downloadPath, installPath); } // Add it to list of installed data.installed.Add(id, minerToInstall); // Save file await data.SaveAsync(); logger.Info("Finished installing miner \"" + id + "\""); progress.Report("Finished installing miner \"" + id + "\""); } else { logger.Error("No miner found with id " + id); progress.Report("No miner found with id " + id); } }
public async Task Setup(Linker _linker, IProgress <ProgressReport> progress) { linker = _linker; logger.Info("Loading Online Data..."); progress.Report(new ProgressReport("Loading Online Data...")); // Load Data from API try { data = OnlineData.LoadData(await FetchURLData(linker.minerManager.GetDataURL())); } catch (WebException e) { progress.Report(new ProgressReport("Could not load Online Data at " + linker.minerManager.GetDataURL(), e)); } }
// Loads the given JSON data into a LocalData object public static OnlineData LoadData(string jsonData) { OnlineData data = JsonConvert.DeserializeObject <OnlineData>(jsonData); return(data); }