public override Task UpdateAsync(UpdateParameter parameter) { var dao = new PeercastDao(Address); return dao.SetMetaAsync(parameter.Name, parameter.Genre, parameter.Description, parameter.ContactUrl, parameter.Comment, parameter.TrackArtist, parameter.TrackTitle, parameter.TrackAlbum, parameter.TrackGenre, parameter.TrackContact) .ContinueWith(t => dao.Dispose()); }
private Task<XmlStatus> GetXmlStatusAsync() { var dao = new PeercastDao(Address); return dao.GetViewXmlAsync().ContinueWith(t => { dao.Dispose(); return new XmlStatus(t.Result); }); }
private void SetYellowPagesAwait(PeercastDao dao, string yellowPagesAddress) { var nvc = GetSettingsAwait(dao); var ypParam = nvc.Single(x => x.Key == "yp"); if (yellowPagesAddress == ypParam.Value) return; nvc.Remove(ypParam); nvc.Add(new KeyValuePair<string, string>("yp", yellowPagesAddress)); dao.ApplyAsync(nvc).Wait(); }
public override Task<Tuple<string, int>> BroadcastAsync(YellowPages yellowPages, BroadcastParameter parameter) { return Task.Factory.StartNew(() => { using (var dao = new PeercastDao(Address)) { SetYellowPagesAwait(dao, yellowPages.Url); var status = new XmlStatus(dao.GetViewXmlAsync().Result); if (status.Exists(parameter.Name)) { throw new PeerCastException("同名のチャンネルが既にあります。"); } dao.FetchAsync(parameter.StreamUrl, parameter.Name, parameter.Genre, parameter.Description, parameter.ContactUrl, parameter.Type).Wait(); var tuple = Repeat(() => { var afterStatus = new XmlStatus(dao.GetViewXmlAsync().Result); return GetChannelInfo(afterStatus, parameter.Name); }); if (NullId == tuple.Item1) { dao.StopAsync(tuple.Item1).Wait(); throw new PeerCastException("チャンネルの作成に失敗しました。" + Environment.NewLine + "エンコードが開始されているか、またはストリームURLが正しいか確認してください。"); } dao.SetMetaAsync(parameter.Name, parameter.Genre, parameter.Description, parameter.ContactUrl, parameter.Comment, parameter.TrackArtist, parameter.TrackTitle, parameter.TrackAlbum, parameter.TrackGenre, parameter.TrackContact).Wait(); return tuple; } }); }
private IList<KeyValuePair<string, string>> GetSettingsAwait(PeercastDao dao) { return new SettingsHtmlParser().Parse(dao.GetSettingsHtmlAsync().Result); }
public override Task StopAsync(string id) { var dao = new PeercastDao(Address); return dao.StopAsync(id).ContinueWith(t => dao.Dispose()); }