public override async System.Threading.Tasks.Task Init() { await base.Init(); if (DataInfos.Count <= 0) { var sina = new SocialDataInfo() { Type = SocialType.SINA, IsBinded = false }; var tencent = new SocialDataInfo() { Type = SocialType.TENCENT, IsBinded = false }; var renren = new SocialDataInfo() { Type = SocialType.RENREN, IsBinded = false }; DataInfos.Add(sina); DataInfos.Add(tencent); DataInfos.Add(renren); SubmitChange(); } }
/// <summary> /// 插入一条记录 /// </summary> /// <param name="record"></param> public virtual async void InsertRecord(M record) { await CheckData(); DataInfos.Add(record); SubmitChange(); }
/// <summary> /// 更新频道缩略图与评分信息 /// </summary> /// <param name="record"></param> private void UpdateImageUri(CloudDataInfo record) { var vid = record.SubId == 0 ? record.Id : record.SubId; var uri = string.Format("{0}detail.api?ver=2&auth={1}&platform={2}&vid={3}", EpgUtils.VodHost, EpgUtils.Auth, EpgUtils.PlatformName, vid); HttpAsyncUtils.HttpGet(uri, null, null, response => { try { using (var reader = XmlReader.Create(new StringReader(response))) { if (reader.ReadToFollowing("imgurl")) { record.ImageUri = reader.ReadElementContentAsString(); } if (reader.ReadToFollowing("mark")) { record.Mark = reader.ReadElementContentAsDouble(); } } lock (_lock) { _updateImageList.Add(record); if (_updateImageList.Count >= _updateImageCount) { var list = _updateImageList.OrderByDescending(v => v.ModifyTime); _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { try { foreach (var v in list) { if (DataInfos.Count >= MaxCount) { _postFactory.AddDeleteInfo(v); } else { DataInfos.Add(v); } } SubmitChange(); if (LocalChangeAction != null) { LocalChangeAction(); } } catch { } }); } } } catch { } }); }