private void ConnectJRiver(ProgressInfo progress) { progress.result = false; progress.subtitle = "Starting MediaCenter"; progress.Update(true); if (!jrAPI.Connect()) { return; } progress.subtitle = "Reading fields"; progress.Update(); jrAPI.getFields(); // syntax highlighter foreach (var tab in expressionTabs) { tab.highlighter = new ELSyntax(jrAPI.FieldsHighlight, settings.ExtraFunctions); } progress.subtitle = "Reading playlists"; progress.Update(true); var lists = jrAPI.getPlaylists(settings.PlaylistFilter, !settings.FastStart).ToList(); progress.result = true; }
private void LoadPlaylist(ProgressInfo progress) { JRPlaylist pl = progress.args[0] as JRPlaylist; pl.Files = new List <JRFile>(); progress.totalItems = pl.Count; int i = 0; List <string> fields = new List <string>(); foreach (var f in state.TableFields) { if (jrAPI.FieldMap.TryGetValue(f.ToLower(), out string name)) { fields.Add(name); } } foreach (var file in jrAPI.getFiles(pl, fields)) { pl.Files.Add(file); progress.currentItem = ++i; progress.subtitle = $"{file.Name} ({file.Year})"; progress.Update(false); } }
public static void DoUpgrade(ProgressInfo progress) { try { string tmpFile = Path.Combine(Path.GetTempPath(), $"Zelda.{LatestVersion.version}.tmp"); if (File.Exists(tmpFile)) { File.Delete(tmpFile); } using (var client = new WebClient()) { progress.subtitle = "downloading new version"; progress.Update(); client.Headers.Add("User-Agent", "Microsoft .Net HttpClient"); client.DownloadFile(LatestVersion.package, tmpFile); progress.subtitle = "upgrading"; string currEXE = Assembly.GetEntryAssembly().Location; string bakFile = Path.ChangeExtension(currEXE, ".bak"); if (File.Exists(bakFile)) { File.Delete(bakFile); } File.Move(currEXE, bakFile); File.Move(tmpFile, currEXE); progress.result = true; restartNeeded = true; progress.subtitle = "starting new version"; Application.Restart(); return; } } catch { } progress.result = false; }