protected override void SavePlayHistory(int duration, int position) { var parentId = _playInfo.ChannelDetailInfo.Id; var parentName = _playInfo.ChannelDetailInfo.Title; var image = _playInfo.ChannelDetailInfo.ImageUri; var subId = ChannelUtils.CreateChannelId(_playInfo.ProgramIndex, _playInfo.ChannelDetailInfo); var subName = ChannelUtils.CreateChannelTitle(_playInfo.ProgramIndex, _playInfo.ChannelDetailInfo, true); var index = ChannelUtils.CreateComonIndex(_playInfo.ProgramIndex, _playInfo.ChannelDetailInfo); if (parentId <= 0) { return; } var localInfo = new CloudDataInfo(); localInfo.ProgramIndex = index; localInfo.ImageUri = image; localInfo.Id = parentId; localInfo.Name = parentName; localInfo.SubId = subId; localInfo.SubName = subName; localInfo.VideoType = 3; localInfo.Pos = position; localInfo.Duration = duration; LocalRecentFactory.Instance.InsertLocalRecord(localInfo); }
private void ApplicationBarFav_Click(object sender, EventArgs e) { try { if (_dataSource != null && _favBar.Text == "收藏") { var v = new CloudDataInfo() { Id = _dataSource.Id, Name = _dataSource.Title, SubId = _dataSource.Id, SubName = _dataSource.Title, Mark = _dataSource.Mark, Duration = (int)(_dataSource.Duration * 60), ImageUri = _dataSource.ImageUri }; LocalFavoritesFactory.Instance.InsertLocalRecord(v); _favBar.IsEnabled = false; _favBar.Text = "已收藏"; TileUtils.CreateBasicToast("收藏成功!"); } } catch { TileUtils.CreateBasicToast("收藏失败!"); } }
private void favourite_Click(object sender, RoutedEventArgs e) { try { if (_dataSource != null && favourite.Style == App.Current.Resources["FavoriteAppButton"] as Style) { var v = new CloudDataInfo() { Id = _dataSource.Id, Name = _dataSource.Title, SubId = _dataSource.Id, SubName = _dataSource.Title, Mark = _dataSource.Mark, Duration = (int)(_dataSource.Duration * 60), ImageUri = _dataSource.ImageUri }; LocalFavoritesFactory.Instance.InsertLocalRecord(v); favourite.Style = App.Current.Resources["HasFavoriteAppButton"] as Style; TileUtils.CreateToastNotifications("收藏成功!"); BottomAppBar.IsOpen = false; } } catch { TileUtils.CreateToastNotifications("收藏失败!"); } }
private static void SaveLocalData(CloudDataInfo data) { var path = Application.persistentDataPath + "/CloudDataInfo.bin"; var json = JsonConvert.SerializeObject(data); byte[] bytes = Encoding.UTF8.GetBytes(json); File.WriteAllBytes(path, bytes); Debug.Log(Application.persistentDataPath + "/CloudDataInfo.bin 저장완료. >> " + DateTime.Now.ToString()); }
public static void SetCloudDataToUser(CloudDataInfo data) { if (!string.IsNullOrEmpty(data.UserData)) { Debug.Log("서버 UserData 로컬 저장 중"); string decryptData = DataSecurityManager.DecryptData(data.UserData); SaveCloudPlayer(decryptData); } }
/// <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 { } }); }
public static void GetFromDatabase() { RestClient.Get <CloudDataInfo>(databaseURL + "/" + localId + ".json").Progress(p => { ShowProgressCircle(p); Debug.Log("DB에서 데이터 받는중 .. " + p); }).Done(response => { Debugging.Log(localId + " 의 DB가져오기 성공 > " + response.name); gameInfo = response; lastSaveTime = response.lastSavedTime; SetCloudDataToLocal(); UI_StartManager.instance.ShowStartUI(true); }); }
/// <summary> /// 更新频道的分集索引 /// </summary> /// <param name="record"></param> private void UpdateProgramIndex(CloudDataInfo record) { if (record.SubId != 0 && record.SubId != record.Id) { var name = record.SubName; var names = name.Split(_splitSeparator, StringSplitOptions.RemoveEmptyEntries); int result = 0; foreach (var n in names) { if (int.TryParse(n, out result)) { break; } } record.ProgramIndex = result - 1; return; } record.ProgramIndex = -1; }
private void WriteXmlItem(XmlWriter xmlWriter, CloudDataInfo item) { xmlWriter.WriteStartElement("Item"); xmlWriter.WriteAttributeString("UUID", item.UUID); xmlWriter.WriteAttributeString("Device", item.Device.ToString()); xmlWriter.WriteAttributeString("DeviceHistory", item.DeviceHistory.ToString()); xmlWriter.WriteAttributeString("Id", item.Id.ToString()); xmlWriter.WriteAttributeString("ClId", item.ClId.ToString()); xmlWriter.WriteAttributeString("Name", item.Name); xmlWriter.WriteAttributeString("SubName", item.SubName); xmlWriter.WriteAttributeString("SubId", item.SubId.ToString()); xmlWriter.WriteAttributeString("Pos", item.Pos.ToString()); xmlWriter.WriteAttributeString("Duration", item.Duration.ToString()); xmlWriter.WriteAttributeString("ModifyTime", item.ModifyTime.ToString()); xmlWriter.WriteAttributeString("Property", item.Property.ToString()); xmlWriter.WriteAttributeString("VideoType", item.VideoType.ToString()); xmlWriter.WriteAttributeString("Bt", item.Bt.ToString()); xmlWriter.WriteAttributeString("Mode", item.Mode.ToString()); xmlWriter.WriteEndElement(); }
/// <summary> /// 插入一条本地数据,如果存在则更新 /// </summary> /// <param name="record"></param> /// <returns></returns> public void InsertLocalRecord(CloudDataInfo record) { record.Device = Device; record.ModifyTime = DateTime.Now.Subtract(DateTime.Parse("1601,1,1")).Ticks + CloudFactoryBase.TimeInterval; var index = DataInfos.IndexOf(record); if (index != -1) { var local = DataInfos[index]; record.UUID = local.UUID; UpdateDeviceHistory(local); record.DeviceHistory = local.DeviceHistory; local = record; local.DataType = CloudInfoEnum.Update; DataInfos.RemoveAt(index); DataInfos.Insert(0, local); } else { record.UUID = Guid.NewGuid().ToString(); if (DataInfos.Count >= MaxCount) { var removeIndex = DataInfos.Count - 1; var removeInfo = DataInfos[removeIndex]; removeInfo.DataType = CloudInfoEnum.Delete; _postFactory.AddDeleteInfo(removeInfo); DataInfos.RemoveAt(removeIndex); } record.DataType = CloudInfoEnum.Add; UpdateDeviceHistory(record); DataInfos.Insert(0, record); } PostChange(); SubmitChange(); if (LocalChangeAction != null) { LocalChangeAction(); } }
private void LocalInit() { isServerLogin = false; var path = Application.persistentDataPath + "/CloudDataInfo.bin"; if (File.Exists(path)) { byte[] bytes = File.ReadAllBytes(path); var json = Encoding.UTF8.GetString(bytes); gameInfo = JsonConvert.DeserializeObject <CloudDataInfo>(json); SetCloudDataToLocal(); } else { gameInfo = new CloudDataInfo(); gameInfo.SetDataToCloud(localId, playerName, DateTime.Now.ToString()); var json = JsonConvert.SerializeObject(gameInfo); byte[] bytes = Encoding.UTF8.GetBytes(json); File.WriteAllBytes(path, bytes); } }
/// <summary> /// 插入一条云端数据,如果存在则更新 /// </summary> /// <param name="record"></param> /// <returns></returns> private void InsertCloudRecord(CloudDataInfo record) { var index = DataInfos.IndexOf(record); if (record.Id <= 0) { if (index == -1) { _updateImageCount--; } record.DataType = CloudInfoEnum.Delete; return; } if (index != -1) { var local = DataInfos[index]; if (local.ModifyTime > record.ModifyTime) { local.DataType = CloudInfoEnum.Update; UpdateDeviceHistory(record); local.UUID = record.UUID; } else { UpdateProgramIndex(record); record.ImageUri = local.ImageUri; local = record; local.DataType = CloudInfoEnum.Normal; DataInfos[index] = local; } } else { record.DataType = CloudInfoEnum.Normal; UpdateProgramIndex(record); UpdateImageUri(record); } }
protected override void SavePlayHistory(int duration, int position) { var parentId = _downloadInfo.ParentId; var parentName = _downloadInfo.ParentName; var image = _downloadInfo.ImageUri; var subId = _downloadInfo.ChannelId; var subName = _downloadInfo.Title; var index = _downloadInfo.ProgramIndex; var localInfo = new CloudDataInfo(); localInfo.ProgramIndex = index; localInfo.ImageUri = image; localInfo.Id = parentId; localInfo.Name = parentName; localInfo.SubId = subId; localInfo.SubName = subName; localInfo.VideoType = 3; localInfo.Pos = position; localInfo.Duration = duration; LocalRecentFactory.Instance.InsertLocalRecord(localInfo); }
public static void SetCloudDataToMission(CloudDataInfo data) { Debug.Log("서버 MissionData 로컬 저장 중"); SaveCloudData(data.MissionData); }
/// <summary> /// 更新DeviceHistory字段,逻辑或当前设备 /// </summary> /// <param name="record"></param> private void UpdateDeviceHistory(CloudDataInfo record) { record.DeviceHistory = record.DeviceHistory | Device; }
public static void SetCloudDataToSkill(CloudDataInfo data) { Debug.Log("서버 SkillData 로컬 저장 중"); SaveCloudData(data.SkillData); }
public static void SetCloudDataToAbility(CloudDataInfo data) { Debug.Log("서버 AbiltyData 로컬 저장 중"); SaveCloudData(data.AbilityData); }
protected override CloudArgs AnalysisData(System.Xml.XmlReader reader) { if (_webClient.ResponseHeaders != null) { string date = _webClient.ResponseHeaders["Date"]; if (date != null) { DateTime serverTime = DateTime.Parse(date); TimeInterval = DateTime.Now.Subtract(serverTime).Ticks; } } var args = new CloudArgs(); args.Datas = new List <CloudDataInfo>(); while (reader.Read()) { if (reader.Name == "root") { if (Method == HttpMethod.Get) { reader.MoveToAttribute("etag"); Etag = reader.ReadContentAsString(); } reader.MoveToAttribute("ret"); int ret = reader.ReadContentAsInt(); reader.MoveToAttribute("msg"); string msg = reader.ReadContentAsString(); if (ret == 0) { args.message = msg; return(args); } } if (reader.Name == Type) { while (reader.Read()) { if (reader.Name == "Item") { try { var infoSync = new CloudDataInfo(); if (reader.MoveToAttribute("UUID")) { infoSync.UUID = reader.ReadContentAsString(); } if (reader.MoveToAttribute("Device")) { infoSync.Device = reader.ReadContentAsInt(); } if (reader.MoveToAttribute("DeviceHistory")) { infoSync.DeviceHistory = reader.ReadContentAsInt(); } if (reader.MoveToAttribute("Id")) { infoSync.Id = reader.ReadContentAsInt(); } //reader.MoveToAttribute("ClId"); //infoSync.ClId = reader.ReadContentAsInt(); if (reader.MoveToAttribute("Name")) { infoSync.Name = reader.ReadContentAsString(); } if (reader.MoveToAttribute("SubName")) { infoSync.SubName = reader.ReadContentAsString(); } if (reader.MoveToAttribute("SubId")) { infoSync.SubId = reader.ReadContentAsInt(); } if (reader.MoveToAttribute("Pos")) { infoSync.Pos = reader.ReadContentAsInt(); } if (reader.MoveToAttribute("Duration")) { infoSync.Duration = reader.ReadContentAsInt(); } if (reader.MoveToAttribute("ModifyTime")) { infoSync.ModifyTime = reader.ReadContentAsLong(); } //reader.MoveToAttribute("Property"); //infoSync.Property = reader.ReadContentAsInt(); //reader.MoveToAttribute("VideoType"); //infoSync.VideoType = reader.ReadContentAsInt(); //reader.MoveToAttribute("Bt"); //infoSync.Bt = reader.ReadContentAsInt(); //reader.MoveToAttribute("Mode"); //infoSync.Mode = reader.ReadContentAsInt(); args.Datas.Add(infoSync); } catch { } } } } } return(args); }
public void AddDeleteInfo(CloudDataInfo deleteInfo) { _needDeletes.Add(deleteInfo); }
public static void SetCloudDataToMap(CloudDataInfo data) { Debug.Log("서버 MapData 로컬 저장 중"); SaveCloudData(data.MapData); }
public static void SetCloudDataToItem(CloudDataInfo data) { Debug.Log("서버 ItemData 로컬 저장 중"); SaveCloudData(data.ItemData); }
// 데이터 처리 private string GameInfoToString(CloudDataInfo data) { return(JsonConvert.SerializeObject(data)); }
public static void SetCloudDataToHero(CloudDataInfo data) { Debug.Log("서버 HeroData 로컬 저장 중"); SaveCloudData(data.HeroData); }