예제 #1
0
 public async Task AddClipsAndHeadersForPlaylist(Playlist playlist)
 {
     if (ServiceAccessor.ConnectedToInternet())
     {
         playlist.clips = new BindableCollection<Clip>();
         ClipResponse response = await ServiceAccessor.GetPlaylistClipsAndHeaders(playlist.playlistId);
         if (response.status == SERVICE_RESPONSE.SUCCESS)
         {
             playlist.clips = response.clips;
             playlist.displayColumns = response.DisplayColumns;
         }
         else
         {
         }
     }
 }
예제 #2
0
        public async Task RemoveDownloadFromModel(Playlist playlist, BindableCollection<Season> currentModel)
        {
            long newSize = 0;
            foreach (Playlist pl in downloadedPlaylists)
            {
                newSize += pl.totalFilesSize;
            }
            diskSpaceFromDownloads = new DiskSpaceResponse { totalBytes = newSize, formattedSize =FormatBytes(newSize) };
            BindableCollection<Season> newModel = currentModel;
            foreach (Season s in currentModel)
            {
                BindableCollection<Game> newGames = s.games;
                foreach (Game g in s.games)
                {
                    BindableCollection<Category> newCategories = g.categories;
                    foreach (Category c in g.categories)
                    {
                        BindableCollection<Playlist> newPlaylists = c.playlists;
                        Playlist foundPL = c.playlists.Where(u => u.playlistId == playlist.playlistId).FirstOrDefault();
                        if (foundPL != null)
                        {
                            newPlaylists.Remove(foundPL);
                            if (newPlaylists.Count == 0)
                            {
                                newCategories.Remove(c);
                                break;
                            }
                        }
                    }
                    g.categories = newCategories;
                    if (g.categories.Count == 0)
                    {
                        newGames.Remove(g);
                        break;
                    }
                }
                s.games = newGames;
                if (s.games.Count == 0)
                {
                    newModel.Remove(s);
                    break;
                }
            }
            var userFolder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync(AppDataAccessor.GetUsername(), Windows.Storage.CreationCollisionOption.OpenIfExists);
            StorageFile completeModelFile = await userFolder.CreateFileAsync("CompleteModel", Windows.Storage.CreationCollisionOption.OpenIfExists);
            string complete = JsonConvert.SerializeObject(newModel);
            await Windows.Storage.FileIO.WriteTextAsync(completeModelFile, complete);

        }
예제 #3
0
        public async void LogPlaylistDownloadRemoved(Playlist playlist)
        {
            LogEntry entry = new LogEntry();
            entry.Function = Function.Download.ToString();
            entry.Operation = Operation.Cutup.ToString();
            entry.Error = null;
            entry.Method = "PlaylistDownloadRemoved";
            entry.ErrorLevel = ErrorLevel.Info.ToString();

            entry.AttributesDictionary = new Dictionary<string, object>();
            entry.AttributesDictionary.Add("Method", "PlaylistDownloadRemoved");
            entry.AttributesDictionary.Add("Playlist", playlist.playlistId);
            entry.AttributesDictionary.Add("RemovedOn", DateTime.Now);

            entry.Attributes = JsonConvert.SerializeObject(entry.AttributesDictionary);
            entry.AttributesDictionary = null;

            ServiceAccessor.MakeApiCallLog(ServiceAccessor.URL_SERVICE_LOG, JsonConvert.SerializeObject(entry));
        }
예제 #4
0
 public async Task RemoveDownload(Playlist playlist)
 {
     BindableCollection<Season> currentModel = await GetDownloadsModel();
     try
     {
         playlist.downloadedThumbnailLocation = null;
         foreach (Clip c in playlist.clips)
         {
             foreach (Angle a in c.angles)
             {
                 a.isPreloaded = false;
                 a.preloadFile = null;
             }
         }
         var userFolder = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFolderAsync(AppDataAccessor.GetUsername());
         var playlistFolder = await userFolder.GetFolderAsync(playlist.playlistId);
         await playlistFolder.DeleteAsync();
         Playlist dlPlaylist = downloadedPlaylists.Where(u => u.playlistId == playlist.playlistId).FirstOrDefault();
         if (dlPlaylist != null)
         {
             downloadedPlaylists.Remove(dlPlaylist);
         }
     }
     catch (Exception)
     {
         //should only fail if the folder does not exist - meaning its already deleted
     }
     await RemoveDownloadFromModel(playlist, currentModel);
 }
예제 #5
0
        public async void GameSelected(ItemClickEventArgs eventArgs)
        {
            PageIsEnabled = false;
            ProgressRingIsActive = true;
            ProgressRingVisibility = Visibility.Visible;

            GameViewModel gameViewModel = (GameViewModel)eventArgs.ClickedItem;
            Season seasonToPass = new Season() { name=selectedSeason.name, owningTeam = selectedSeason.owningTeam, seasonId = selectedSeason.seasonId, year = selectedSeason.year, games = new BindableCollection<Game>() }; //Because we're changing the games in this season, we need to make a copy.
            seasonToPass.games.Add(gameViewModel.GameModel);

            if (!gameViewModel.IsLastViewed)
            {
                try
                {
                    await gameViewModel.FetchPlaylists;
                    navigationService.NavigateToViewModel<SectionViewModel>(new PageParameter { season = seasonToPass, hubGroups = Groups, playlist = new Playlist() });

                    if (gameViewModel.IsNextGame)
                    {
                        Logger.Instance.LogGameSelected(gameViewModel.GameModel, Logger.LOG_GAME_NEXT);
                    }
                    else if (gameViewModel.IsPreviousGame)
                    {
                        Logger.Instance.LogGameSelected(gameViewModel.GameModel, Logger.LOG_GAME_PREVIOUS);
                    }
                    else
                    {
                        Logger.Instance.LogGameSelected(gameViewModel.GameModel);
                    }
                }
                catch
                {
                    navigationService.NavigateToViewModel<ErrorViewModel>();
                }
            }
            else
            {
                Playlist downloadedPlaylist = DownloadAccessor.Instance.downloadedPlaylists.Where(u => u.playlistId == gameViewModel.GameModel.gameId).FirstOrDefault();
                if (downloadedPlaylist != null)
                {
                    navigationService.NavigateToViewModel<VideoPlayerViewModel>(new PageParameter { season = seasonToPass, hubGroups = Groups, playlist = downloadedPlaylist });
                    Logger.Instance.LogLastViewedClick(downloadedPlaylist);
                }
                else
                {
                    ClipResponse response = await ServiceAccessor.GetPlaylistClipsAndHeaders(gameViewModel.GameModel.gameId);
                    Playlist lastViewedPlaylist = new Playlist { playlistId = gameViewModel.GameModel.gameId, name = gameViewModel.GameModel.opponent, thumbnailLocation = gameViewModel.Thumbnail, clips = response.clips, displayColumns = response.DisplayColumns, clipCount = response.clips.Count };
                    navigationService.NavigateToViewModel<VideoPlayerViewModel>(new PageParameter { season = seasonToPass, hubGroups = Groups, playlist = lastViewedPlaylist });
                    Logger.Instance.LogLastViewedClick(lastViewedPlaylist);
                }
            }
            
        }
예제 #6
0
 public PlaylistViewModel(Playlist playlist)
 {
     PlaylistModel = playlist;
     DownloadedIcon_Visibility = Visibility.Collapsed;
 }
예제 #7
0
 public static Playlist FromDTO(PlaylistDTO playlistDTO)
 {
     Playlist playlist = new Playlist();
     playlist.playlistId = playlistDTO.PlaylistId;
     playlist.clipCount = playlistDTO.ClipCount;
     playlist.name = playlistDTO.Name;
     playlist.thumbnailLocation = playlistDTO.Thumbnailpath;
     return playlist;
 }
예제 #8
0
 public static Playlist Copy(Playlist toCopy)
 {
     Playlist playlist = new Playlist { playlistId = toCopy.playlistId, clipCount = toCopy.clipCount, name = toCopy.name, thumbnailLocation = toCopy.thumbnailLocation, displayColumns = toCopy.displayColumns, totalFilesSize = toCopy.totalFilesSize };
     BindableCollection<Clip> clips = new BindableCollection<Clip>();
     foreach (Clip c in toCopy.clips)
     {
         Clip clip = new Clip { breakDownData = c.breakDownData, clipId = c.clipId, order = c.order };
         BindableCollection<Angle> angles = new BindableCollection<Angle>();
         foreach (Angle a in c.angles)
         {
             Angle angle = new Angle { angleName = a.angleName, angleType = null, clipAngleId = a.clipAngleId, duration = a.duration, fileLocation = a.fileLocation, isPreloaded = a.isPreloaded, preloadFile = a.preloadFile, thumbnailLocation = a.thumbnailLocation, fileSize =a.fileSize };
             angles.Add(angle);
         }
         clip.angles = angles;
         clips.Add(clip);
     }
     playlist.clips = clips;
     return playlist;
 }