protected override void HandleOnNavigatedTo(NavigationEventArgs e) { base.HandleOnNavigatedTo(e); bool flag = true; if (!this._isInitialized) { this._ownerId = long.Parse(((Page)this).NavigationContext.QueryString["OwnerId"]); this._videoId = long.Parse(((Page)this).NavigationContext.QueryString["VideoId"]); string accessKey = ((Page)this).NavigationContext.QueryString["AccessKey"]; string videoContext = ""; if (((Page)this).NavigationContext.QueryString.ContainsKey("VideoContext")) { videoContext = ((Page)this).NavigationContext.QueryString["VideoContext"]; } VKClient.Common.Backend.DataObjects.Video parameterForIdAndReset = ParametersRepository.GetParameterForIdAndReset("Video") as VKClient.Common.Backend.DataObjects.Video; StatisticsActionSource actionSource = (StatisticsActionSource)Enum.Parse(typeof(StatisticsActionSource), ((Page)this).NavigationContext.QueryString["VideoSource"]); this.InitializeCommentVM(); VideoCommentsViewModel commentsViewModel = new VideoCommentsViewModel(this._ownerId, this._videoId, accessKey, parameterForIdAndReset, actionSource, videoContext); commentsViewModel.PageLoadInfoViewModel.LoadingStateChangedCallback = new Action(this.OnLoadingStateChanged); base.DataContext = (commentsViewModel); commentsViewModel.Reload(true); this.RestoreUnboundState(); this._isInitialized = true; flag = false; } if (!flag && (!e.IsNavigationInitiator || e.NavigationMode != NavigationMode.New)) { WallPostVMCacheManager.TryDeserializeInstance(this._commentVM); } this.ProcessInputData(); this.UpdateAppBar(); }
private static void SetAudioAgentPlaylistImpl(List <AudioObj> tracks, StatisticsActionSource actionSource) { if (tracks == null) { return; } tracks = tracks.Where <AudioObj>((Func <AudioObj, bool>)(track => track.content_restricted == 0)).ToList <AudioObj>(); if (tracks.Count == 0) { return; } //IEnumerable<AudioObj> arg_59_0 = tracks; //Func<AudioObj, string> arg_59_1 = new Func<AudioObj, string>(a => a.UniqueId); //tracks = Enumerable.ToList<AudioObj>(arg_59_0.Distinct(arg_59_1)); // tracks = tracks.Distinct<AudioObj>((Func<AudioObj, string>) (a => a.UniqueId)).ToList<AudioObj>();//todo: bug Playlist playlist1 = new Playlist(); playlist1.Metadata = new Metadata() { LastUpdated = DateTime.Now, ActionSource = actionSource }; List <AudioObj> audioObjList = tracks; playlist1.Tracks = audioObjList; Playlist playlist2 = playlist1; lock (PlaylistManager._lockObj) { try { using (IsolatedStorageFile storeForApplication = IsolatedStorageFile.GetUserStoreForApplication()) { PlaylistManager.metadataAccessMutex.WaitOne(); using (BinaryWriter writer = new BinaryWriter((Stream)storeForApplication.CreateFile(PlaylistManager.PlaylistMetadataFileName))) writer.Write <Metadata>(playlist2.Metadata, false); PlaylistManager.metadataAccessMutex.ReleaseMutex(); PlaylistManager.playlistAccessMutex.WaitOne(); using (BinaryWriter writer = new BinaryWriter((Stream)storeForApplication.CreateFile(PlaylistManager.PlaylistFileName))) writer.Write <Playlist>(playlist2, false); PlaylistManager.playlistAccessMutex.ReleaseMutex(); PlaylistManager._playlistCached = playlist2; } } catch (Exception ex) { Logger.Instance.Error("Failed to set playlist", ex); } } }
public VideoListViewModel(VKList <VideoCatalogItem> list, string sectionId, string next, string name, StatisticsActionSource source, string context) { this._list = list; this._sectionId = sectionId; this._next = next; this._name = name; this._shouldLoadMore = !string.IsNullOrEmpty(this._next); this._source = source; this._context = context; this._videosGenCol = new GenericCollectionViewModel <GetCatalogSectionResponse, CatalogItemViewModel>((ICollectionDataProvider <GetCatalogSectionResponse, CatalogItemViewModel>) this); }
public VideoHeader(VKClient.Common.Backend.DataObjects.Video video, List <MenuItemData> menuItems = null, List <User> knownUsers = null, List <Group> knownGroups = null, StatisticsActionSource source = StatisticsActionSource.undefined, string context = "", bool pickMode = false, long albumId = 0, long messageId = 0) { this.VKVideo = video; this.MessageId = messageId; this.SetMenuItems(menuItems); this._knownUsers = knownUsers ?? new List <User>(); this._knownGroups = knownGroups ?? new List <Group>(); this._pickMode = pickMode; this._albumId = albumId; this._actionSource = source; this._context = context; EventAggregator.Current.Subscribe(this); }
public void Read(BinaryReader reader) { int num1 = reader.ReadInt32(); this.LastUpdated = reader.ReadDateTime(); int num2 = 2; if (num1 < num2) { return; } this.ActionSource = (StatisticsActionSource)reader.ReadInt32(); }
protected override void HandleOnNavigatedTo(NavigationEventArgs e) { base.HandleOnNavigatedTo(e); if (this._isInitialized) { return; } this._section_id = this.NavigationContext.QueryString["SectionId"]; this._next = this.NavigationContext.QueryString["Next"]; this._name = this.NavigationContext.QueryString["Name"]; StatisticsActionSource source = (StatisticsActionSource)int.Parse(this.NavigationContext.QueryString["Source"]); string context = this.NavigationContext.QueryString["Context"]; VKList <VideoCatalogItem> vkList = ParametersRepository.GetParameterForIdAndReset("CatalogItemsToShow") as VKList <VideoCatalogItem>; int num1 = vkList != null ? 1 : 0; if (num1 == 0) { VideoListPage.VideoListData videoListData = new VideoListPage.VideoListData(); CacheManager.TryDeserialize((IBinarySerializable)videoListData, this._section_id + "cached", CacheManager.DataType.CachedData); vkList = new VKList <VideoCatalogItem>() { count = videoListData.count, groups = videoListData.groups, profiles = videoListData.profiles, items = videoListData.items }; } VideoListViewModel videoListViewModel = new VideoListViewModel(vkList ?? new VKList <VideoCatalogItem>(), this._section_id, this._next, this._name, source, context); this.DataContext = (object)videoListViewModel; videoListViewModel.VideosGenCol.LoadData(true, false, (Action <BackendResult <GetCatalogSectionResponse, ResultCode> >)null, false); if (num1 != 0) { VideoListPage.VideoListData videoListData = new VideoListPage.VideoListData(); videoListData.count = vkList.count; videoListData.groups = vkList.groups; videoListData.profiles = vkList.profiles; videoListData.items = vkList.items; string fileId = this._section_id + "cached"; int num2 = 0; int num3 = 0; CacheManager.TrySerializeAsync((IBinarySerializable)videoListData, fileId, num2 != 0, (CacheManager.DataType)num3); } this._isInitialized = true; }
public VideoCommentsViewModel(long ownerId, long videoId, string accessKey, VKClient.Common.Backend.DataObjects.Video video = null, StatisticsActionSource actionSource = StatisticsActionSource.news, string videoContext = "") { this.Resolutions = new List <VideoResolution>(); this._knownCommentsCount = -1; this._lastTimeCompletedPlayRequest = DateTime.MinValue; this.OwnerId = ownerId; this.VideoId = videoId; this._accessKey = accessKey; this.Video = video; this._actionSource = actionSource; this._videoContext = videoContext; if (this.Video != null) { this._catItemVM = new CatalogItemViewModel(new VideoCatalogItem(this.Video), new List <User>(), new List <Group>(), false); this.PublishOpenVideoEvent(); } this.UpdateOwnerInfo(); this.UpdateDescription(); this.InitResolutionsCollection(); EventAggregator.Current.Subscribe(this); }
public UserControlVirtualizable Create(VKClient.Common.Backend.DataObjects.Video video, List <User> knownUsers, List <Group> knownGroups, StatisticsActionSource actionSource, string context) { CatalogItemViewModel catalogItemViewModel1 = new CatalogItemViewModel(new VideoCatalogItem(video), knownUsers, knownGroups, false) { ActionSource = new StatisticsActionSource?(actionSource), VideoContext = context }; CatalogItemUC catalogItemUc = new CatalogItemUC(); CatalogItemViewModel catalogItemViewModel2 = catalogItemViewModel1; catalogItemUc.DataContext = (object)catalogItemViewModel2; return((UserControlVirtualizable)catalogItemUc); }
public static void PlayVideo(VKClient.Common.Backend.DataObjects.Video video, Action callback, int resolution, StatisticsActionSource actionSource = StatisticsActionSource.news, string videoContext = "") { if ((video != null ? video.files : null) == null || video.files.Count == 0) { callback.Invoke(); ExtendedMessageBox.ShowSafe(video == null || video.processing != 0 ? CommonResources.ProcessingVideoError : CommonResources.Conversation_VideoIsNotAvailable); } else { bool isExternal; string uri = VideoPlayerHelper.GetVideoUri(video, resolution, out isExternal); if (string.IsNullOrEmpty(uri)) { callback.Invoke(); ExtendedMessageBox.ShowSafe(video.processing == 0 ? CommonResources.Conversation_VideoIsNotAvailable : CommonResources.ProcessingVideoError); } else { EventAggregator current = EventAggregator.Current; VideoPlayEvent videoPlayEvent = new VideoPlayEvent(); videoPlayEvent.Position = StatisticsVideoPosition.start; int num1 = resolution; videoPlayEvent.quality = num1; string globallyUniqueId = video.GloballyUniqueId; videoPlayEvent.id = globallyUniqueId; int num2 = (int)actionSource; videoPlayEvent.Source = (StatisticsActionSource)num2; string str = videoContext; videoPlayEvent.Context = str; current.Publish(videoPlayEvent); ThreadPool.QueueUserWorkItem((WaitCallback)(o => { Thread.Sleep(500); VideoPlayerHelper.PlayVideo(uri, isExternal, resolution, callback); })); } } }
public void GetComments(long ownerId, long vid, int knownCommentsCount, int offset, int count, StatisticsActionSource actionSource, string context, Action <BackendResult <VideoLikesCommentsData, ResultCode> > callback) { VKRequestsDispatcher.Execute <VideoLikesCommentsData>(string.Format("\r\nvar ownerId={0};\r\nvar vid = {1};\r\nvar countToRead = {4};\r\nvar vidStr= ownerId + \"_\" + vid;\r\n\r\nvar knownCommentsCount = {2};\r\nvar offset = {3};\r\n\r\nvar albums = API.video.getAlbumsByVideo({{\"owner_id\":ownerId, \"video_id\":vid}});\r\n\r\nvar likesAll = API.likes.getList({{ \"type\": \"video\", \"owner_id\":ownerId, \"item_id\":vid, \"count\":10 }});\r\n\r\nvar repostsCount = API.likes.getList({{ \"type\": \"video\", \"owner_id\":ownerId, \"item_id\":vid, \"filter\": \"copies\"}}).count;\r\n\r\nvar comments;\r\n\r\nif (knownCommentsCount == -1)\r\n{{\r\n comments = API.video.getComments({{\"video_id\":vid, \"owner_id\":ownerId, \"offset\":0, \"count\":countToRead, \"sort\":\"desc\", \"need_likes\":1, \"allow_group_comments\":1 }});\r\n}}\r\n\r\nelse\r\n{{\r\n var calculatedOffset = knownCommentsCount - offset - countToRead;\r\n if (calculatedOffset < 0)\r\n{{\r\n calculatedOffset = 0;\r\n}}\r\n comments = API.video.getComments({{\"video_id\":vid, \"owner_id\":ownerId, \"offset\":calculatedOffset, \"count\":countToRead, \"sort\":\"asc\", \"need_likes\":1, \"allow_group_comments\":1}});\r\n\r\n}}\r\n\r\nvar users2 = API.getProfiles({{ \"user_ids\":[email protected]_to_user, \"fields\":\"first_name_dat,last_name_dat\"}});\r\n\r\n\r\nvar likesAllIds = likesAll.items;\r\nvar likesAllCount = likesAll.count;\r\n\r\nvar userLiked = API.likes.isLiked({{\"owner_id\":ownerId, \"type\":\"video\", \"item_id\":vid}});\r\n\r\nvar tags = API.video.getTags({{\"owner_id\":ownerId, \"video_id\":vid}});\r\n\r\n\r\nvar userOrGroupIds = likesAllIds;\r\n\r\n\r\n\r\nuserOrGroupIds = userOrGroupIds + [email protected]_id;\r\n\r\nvar userIds = [];\r\nvar groupIds = [];\r\n\r\nvar i = 0;\r\n\r\nif (ownerId < 0)\r\n{{\r\n var negOwner = -ownerId;\r\n groupIds = groupIds + negOwner;\r\n}}\r\nelse\r\n{{\r\n userIds = userIds + ownerId;\r\n}}\r\n\r\nvar length = userOrGroupIds.length;\r\n\r\nwhile (i < length)\r\n{{\r\n var id = parseInt(userOrGroupIds[i]);\r\n \r\n if (id > 0)\r\n {{\r\n if (userIds.length > 0)\r\n {{\r\n userIds = userIds + \",\";\r\n }}\r\n userIds = userIds + id;\r\n }}\r\n else if (id < 0)\r\n {{\r\n id = -id;\r\n if (groupIds.length > 0)\r\n {{\r\n groupIds = groupIds + \",\";\r\n }}\r\n groupIds = groupIds + id;\r\n }}\r\n \r\n i = i + 1;\r\n}}\r\n\r\nvar users = API.users.get({{\"user_ids\":userIds, \"fields\":\"sex,photo_max,online,online_mobile,friend_status\" }});\r\nvar users3 =API.users.get({{\"user_ids\":userIds, \"fields\":\"first_name_dat,last_name_dat,friend_status\" }}); \r\nvar groups = API.groups.getById({{\"group_ids\":groupIds, \"fields\":\"members_count,photo_100\"}});\r\n\r\n\r\nvar videoRecommendations = API.video.getRecommendations({{count: 8, extended: 1, owner_id: ownerId, video_id: vid, source: \"{5}\", context: \"{6}\"}});\r\n\r\n// for test\r\n//var videoRecomList = API.video.get({{count: 8, extended: 1}});\r\n//var videoRecom = {{\r\n//items: videoRecomList.items,\r\n//count: videoRecomList.count,\r\n//context: \"-1324220032\"\r\n//}};\r\n\r\nreturn {{\"comments\":comments, \"LikesAllIds\":likesAllIds, \"LikesAllCount\":likesAllCount, \"userLiked\":userLiked, \"Users\":users,\"Users2\":users2, \"Users3\": users3, \"Groups\":groups, \"Tags\":tags, \"RepostsCount\":repostsCount, \"Albums\":albums, \"VideoRecommendations\": videoRecommendations}};\r\n", ownerId, vid, knownCommentsCount, offset, count, actionSource, context), callback, (Func <string, VideoLikesCommentsData>)(jsonStr => { jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "Users", false); jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "Users2", false); jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "Users3", false); jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "Groups", false); jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "comments", true); jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "Tags", false); jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "LikesAllIds", false); jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "Albums", false); jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "VideoRecommendations", true); VideoLikesCommentsData response = JsonConvert.DeserializeObject <GenericRoot <VideoLikesCommentsData> >(jsonStr).response; GroupsService.Current.AddCachedGroups((IEnumerable <Group>)response.Groups); if (knownCommentsCount < 0) { response.Comments.Reverse(); } response.Users2.AddRange((IEnumerable <User>)response.Users3); return(response); }), false, true, new CancellationToken?()); }
public GifPlayEvent(string gifId, GifPlayStartType startType, StatisticsActionSource source) { this.GifId = gifId; this.StartType = startType; this.Source = source; }
public static void SetAudioAgentPlaylist(List <AudioObj> tracks, StatisticsActionSource actionSource) { PlaylistManager.SetAudioAgentPlaylistImpl(tracks, actionSource); }