Beispiel #1
0
        public ActionResult Index()
        {
            AlbumView av = new AlbumView();

            av.Albums = Repo.SelectAllAlbums();
            return(View(av));
        }
Beispiel #2
0
        public ActionResult Edit(Guid albumId)
        {
            AlbumView av = new AlbumView();

            if (Repo.IsAlbumSpecial(albumId))
            {
                string userId      = User.Identity.GetUserId();
                var    userManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>();
                if (userManager.IsInRole(userId, "Admin"))
                {
                    av.Album = Repo.SelectAlbumByID(albumId);
                    return(PartialView(av));
                }
                else
                {
                    ModelState.AddModelError("error", "Error: Only admin can edit this album.");
                    return(new EmptyResult());
                }
            }
            else
            {
                av.Album = Repo.SelectAlbumByID(albumId);
                return(PartialView(av));
            }
        }
Beispiel #3
0
        private async Task <StackLayout> GetArtistAlbums()
        {
            var ArtistAlbums = await GetAlbumDetails.ByArtistId(ArtistId);

            var NumberOfAlbums = ArtistAlbums.Number_Of_Albums;
            var Artist         = ConvertJuxString.Decode(ArtistAlbums.Artist);
            var Albums         = ArtistAlbums.Albums;


            var stack = new StackLayout();
            await Task.Run(() =>
            {
                foreach (var Album in Albums)
                {
                    var albumView      = new AlbumView();
                    albumView.Artist   = Artist;
                    albumView.Album    = ConvertJuxString.Decode(Album.Title);
                    albumView.ImageUrl = Album.Album_Picture;
                    albumView.AlbumId  = Album.Id;
                    albumView.Year     = Album.Date;
                    stack.Children.Add(albumView);
                }
            });

            return(stack);
        }
Beispiel #4
0
        void bwCDList_DoWork(object sender, DoWorkEventArgs e)
        {
            SafeObservableCollection <AlbumItem> items = new SafeObservableCollection <AlbumItem>();

            int count = 0;

            Big3.Hitbase.DataBaseEngine.Condition searchCondition = Big3.Hitbase.DataBaseEngine.Condition.Combine(Condition, ConditionFromTree);

            using (DataBaseView view = AlbumView.CreateView(this.DataBase, this.CdListFields.GetFields(), new SortFieldCollection(), 0, searchCondition))
            {
                object[] values;

                while ((values = view.Read()) != null)
                {
                    AlbumItem newItem = new AlbumItem();
                    newItem.ID = (int)values[0];

                    newItem.Items = new object[values.Length - 1];
                    FillRowValues(newItem, values);
                    items.AddItemFromThread(newItem);

                    count++;
                }
            }

            e.Result = items;
        }
Beispiel #5
0
 public void SaveAlbum(AlbumView album, BitmapImage image)
 {
     if (Albums.FirstOrDefault(a => a.Equals(album)) is AlbumView albumView)
     {
         albumView.Thumbnail = image ?? MusicImage.DefaultImage;
     }
 }
Beispiel #6
0
        private void DropShadowControl_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
        {
            AlbumView album = sender.DataContext as AlbumView;

            if (album == null || album.DontLoad || !sender.IsPartiallyVisible(AlbumsGridView))
            {
                return;
            }
            LoadThumbnail(album);
        }
Beispiel #7
0
        private void DropShadowControl_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args)
        {
            AlbumView album = sender.DataContext as AlbumView;

            if (album == null || album.DontLoad || !ImageHelper.NeedsLoading(sender, args))
            {
                return;
            }
            LoadThumbnail(album);
        }
Beispiel #8
0
        private async Task <StackLayout> AlbumStackAsync()
        {
            StackLayout albumStack = new StackLayout();
            var         JuxResults = await ArtistOrAlbumSearchAsync();

            if (JuxResults != null)
            {
                var ResultCount = JuxResults.Results.Count;
                var CountMatch  = 0;

                string Artist = "";
                string Album  = "";
                string Url    = "";
                int    Id     = 0;

                await Task.Run(() =>
                {
                    for (int i = 0; i <= ResultCount - 1; i++)
                    {
                        albumView = new AlbumView();

                        Artist = ConvertJuxString.Decode(JuxResults.Results[i].Artist);
                        Album  = ConvertJuxString.Decode(JuxResults.Results[i].Album);
                        Url    = JuxResults.Results[i].Album_Picture;
                        Id     = JuxResults.Results[i].Id;

                        albumView.Artist        = Artist;
                        albumView.Album         = Album;
                        albumView.AlbumId       = Id;
                        albumView.ImageUrl      = Url;
                        albumView.DownloadCount = $" ";

                        if (Album.ToLower().Contains(SearchText.ToLower()))
                        {
                            CountMatch += 1;
                            albumStack.Children.Add(albumView);
                        }
                    }
                    if (CountMatch < 1)
                    {
                        albumStack.Children.Add(new Label
                        {
                            Text                    = $"Nothing was found for {SearchText}, try with another Title.",
                            FontSize                = 15,
                            TextColor               = Color.White,
                            LineBreakMode           = LineBreakMode.WordWrap,
                            HorizontalTextAlignment = TextAlignment.Center
                        });
                    }
                });
            }
            return(albumStack);
        }
Beispiel #9
0
        public ActionResult Carousel()
        {
            //宣告一個新頁面模型
            AlbumView Data = new AlbumView();

            //新增頁面模型中的分頁(只顯示第一頁)
            Data.Paging = new ForPaging(1);
            //從Service中取得頁面所需陣列資料
            Data.FileList = albumService.GetDataList(Data.Paging);
            //將頁面資料傳入View中
            return(View(Data));
        }
Beispiel #10
0
        private void UpdateAlbumItem(AlbumItem albumItem)
        {
            DataBaseView view = AlbumView.CreateView(DataBase, CdListFields.GetFields(), CdListSort, albumItem.ID);

            object[] values = view.Read();

            FillRowValues(albumItem, values);

            ListCollectionView lcv = this.dataGrid.ItemsSource as ListCollectionView;

            lcv.Refresh();
        }
Beispiel #11
0
        //一開始載入Action,並設定初始頁數為1
        public ActionResult List(int Page = 1)
        {
            //宣告一個新頁面模型
            AlbumView Data = new AlbumView();

            //新增頁面模型中的分頁
            Data.Paging = new ForPaging(Page);
            //從Service中取得頁面所需陣列資料
            Data.FileList = albumService.GetDataList(Data.Paging);
            //將頁面資料傳入View中
            return(PartialView(Data));
        }
Beispiel #12
0
        public AlbumDialog(AlbumDialogOption option, AlbumView album)
        {
            this.InitializeComponent();
            switch (option)
            {
            case AlbumDialogOption.Properties:
                break;

            case AlbumDialogOption.AlbumArt:
                break;
            }
            AlbumArtController.SetAlbumArt(album);
        }
Beispiel #13
0
        void ReleaseDesignerOutlets()
        {
            if (AlbumView != null)
            {
                AlbumView.Dispose();
                AlbumView = null;
            }

            if (SongTableView != null)
            {
                SongTableView.Dispose();
                SongTableView = null;
            }
        }
Beispiel #14
0
        private void GridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (AlbumsGridView.SelectionMode != ListViewSelectionMode.None)
            {
                return;
            }
            AlbumView album = (AlbumView)e.ClickedItem;

            if (album.Songs == null)
            {
                album.SetSongs(AlbumPage.SearchAlbumSongs(album.Name, album.Artist));
            }
            Frame.Navigate(typeof(AlbumPage), e.ClickedItem);
        }
Beispiel #15
0
        private async void LoadThumbnail(AlbumView album)
        {
            string before = album.ThumbnailSource;

            if (album.Songs == null)
            {
                album.SetSongs(AlbumPage.SearchAlbumSongs(album.Name, album.Artist));
            }
            await album.SetThumbnailAsync();

            if (album.ThumbnailSource != before && AlbumInfoList.FirstOrDefault(a => a.Equals(album)) is AlbumInfo albumInfo)
            {
                albumInfo.Thumbnail = album.ThumbnailSource;
            }
        }
Beispiel #16
0
        public static async void HandleCommand(string text)
        {
            string play = Helper.Localize("Play");

            if (text.StartsWith(play))
            {
                string keyword = text.Substring(play.Length);
                var    result  = await SearchHelper.Search(keyword);

                if (result.Result == null)
                {
                    Helper.ShowNotification("NoResults");
                    return;
                }
                switch (result.SearchType)
                {
                case SearchType.Artists:
                    Playlist artist = result.Result as Playlist;
                    MediaHelper.ShuffleAndPlay(artist.Songs);
                    Helper.ShowNotificationWithoutLocalization(Helper.LocalizeMessage("SearchResultArtist", artist.Name), 5000);
                    break;

                case SearchType.Albums:
                    AlbumView album = result.Result as AlbumView;
                    MediaHelper.ShuffleAndPlay(album.Songs);
                    Helper.ShowNotificationWithoutLocalization(Helper.LocalizeMessage("SearchResultAlbum", album.Name), 5000);
                    break;

                case SearchType.Playlists:
                    AlbumView playlist = result.Result as AlbumView;
                    MediaHelper.ShuffleAndPlay(playlist.Songs);
                    Helper.ShowNotificationWithoutLocalization(Helper.LocalizeMessage("SearchResultPlaylist", playlist.Name), 5000);
                    break;

                case SearchType.Folders:
                    GridFolderView folder = result.Result as GridFolderView;
                    MediaHelper.ShuffleAndPlay(folder.Songs);
                    Helper.ShowNotificationWithoutLocalization(Helper.LocalizeMessage("SearchResultFolder", folder.Name), 5000);
                    break;

                case SearchType.Songs:
                    Music music = result.Result as Music;
                    MediaHelper.SetMusicAndPlay(music);
                    Helper.ShowNotificationWithoutLocalization(Helper.LocalizeMessage("SearchResultMusic", music.Name), 5000);
                    break;
                }
            }
        }
Beispiel #17
0
        private void SearchPlaylistView_ItemClick(object sender, ItemClickEventArgs e)
        {
            AlbumView playlist = (AlbumView)e.ClickedItem;

            if (playlist.Name == MenuFlyoutHelper.NowPlaying)
            {
                Frame.Navigate(typeof(NowPlayingPage));
            }
            else if (playlist.Name == MenuFlyoutHelper.MyFavorites)
            {
                Frame.Navigate(typeof(MyFavoritesPage));
            }
            else
            {
                Frame.Navigate(typeof(PlaylistsPage), e.ClickedItem);
            }
        }
Beispiel #18
0
        public static int EvaluatePlaylist(AlbumView item, string keyword)
        {
            if (item == null)
            {
                return(0);
            }
            if (item.Name == keyword)
            {
                return(96);
            }
            if (item.Name.Contains(keyword))
            {
                return(86);
            }

            return(0);
        }
Beispiel #19
0
        public static void FindAlbum(string title)
        {
            string        selectString = @"SELECT a.title t, m.title FROM music m, album a WHERE a.title LIKE '%" + title + "%' AND m.id_album = a.id";
            SqlConnection connection   = new SqlConnection(ConnectionString);

            connection.Open();

            SqlCommand cmd = new SqlCommand(selectString, connection);
            var        rdr = cmd.ExecuteReader();

            // Appel de la vue pour les details d'un album
            var view = new AlbumView();

            view.showOneAlbum(rdr);

            connection.Close();
        }
Beispiel #20
0
        public async void SetAlbumArt(AlbumView album)
        {
            CurrentAlbum = album;
            RemoveAlbumArtWarningTextBlock.Text = Helper.LocalizeMessage("RemoveAlbumArt", string.IsNullOrEmpty(CurrentAlbum.Name) ? Helper.LocalizeMessage("UnknownAlbum") : CurrentAlbum.Name);
            foreach (var music in CurrentAlbum.Songs)
            {
                var thumbnail = await Helper.GetStorageItemThumbnailAsync(music, 1024);

                if (thumbnail.IsThumbnail())
                {
                    AlbumArt.Source     = thumbnail.ToBitmapImage();
                    AlbumArt.Visibility = Visibility.Visible;
                    return;
                }
            }
            AlbumArt.Visibility = Visibility.Collapsed;
        }
Beispiel #21
0
        public static void albumList()
        {
            string        selectString = @"SELECT a.title, a.artist, a.available, m.description FROM album a, musicGenre m WHERE a.id_genre = m.id";
            SqlConnection connection   = new SqlConnection(ConnectionString);

            connection.Open();

            SqlCommand cmd = new SqlCommand(selectString, connection);
            var        rdr = cmd.ExecuteReader();

            // Appel de la vue pour un album
            var view = new AlbumView();

            view.showAllAlbum(rdr);

            connection.Close();
        }
Beispiel #22
0
        public HttpResponseMessage IncreaseView([FromUri] int id)
        {
            using (var db = new OnlineMusicEntities())
            {
                var album = (from a in db.Albums
                             where a.Id == id
                             select a).FirstOrDefault();
                if (album == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Không tìm thấy album id=" + id));
                }
                else if (album.Songs.Count > 0)
                {
                    var views = (from v in db.AlbumViews where v.AlbumId == id select v).FirstOrDefault();
                    // Create new if song hasn't view yet
                    if (views == null)
                    {
                        views = new AlbumView()
                        {
                            Ip = "", AlbumId = id, Timestamp = DateTime.Now, Views = 0
                        };
                        db.AlbumViews.Add(views);
                    }
                    else
                    {
                        // Reset view hour
                        if (views.Timestamp.Date.CompareTo(DateTime.Now.Date) != 0 || views.Timestamp.Hour != DateTime.Now.Hour)
                        {
                            views.Ip        = "";
                            views.Timestamp = DateTime.Now;
                        }
                    }

                    string ip = HttpContext.Current.Request.UserHostAddress.Trim();
                    // If IP hasn't view yet then increase view of song
                    if (!views.Ip.Contains(ip))
                    {
                        views.Ip += " " + ip;
                        views.Views++;
                    }

                    db.SaveChanges();
                }
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
        }
Beispiel #23
0
 [HttpPost]  //設定此Action只接受頁面POST資料傳入
 //使用Bind的Inculde來定義只接受的欄位,用來避免傳入其他不相干值
 public ActionResult Upload([Bind(Include = "upload")] AlbumView File)
 {
     //檢查是否有上傳檔案
     if (File.upload != null)
     {
         //將檔案和伺服器上路徑合併
         string Url = Path.Combine(Server.MapPath("~/Upload/")
                                   , File.upload.FileName);
         //將檔案儲存於伺服器上
         File.upload.SaveAs(Url);
         //藉由Service將檔案資料存入資料庫
         albumService.UploadFile(File.upload.FileName, Url
                                 , File.upload.ContentLength
                                 , File.upload.ContentType, User.Identity.Name);
     }
     //重新導向頁面至開始頁面
     return(RedirectToAction("Index"));
 }
Beispiel #24
0
        public List <AlbumView> GetAlbumList(string userid)
        {
            List <AlbumView> albums = new List <AlbumView>();
            var pics = _db.Pictures.Where(t => t.Album.UserId == userid).GroupBy(t => t.Album.Name);

            foreach (var p in pics)
            {
                var       item  = p.OrderByDescending(t => t.UploadTime).FirstOrDefault();
                AlbumView album = new AlbumView
                {
                    Id      = item.AlbumId,
                    Name    = p.Key,
                    LastImg = PICURL + item.Url
                };
                albums.Add(album);
            }
            return(albums);
        }
        private AlbumView getAlbumViewModel(int albumId)
        {
            var queriedAlbumItem = _context.Albums.Where(a => a.id == albumId).First();
            var photoList        = _context.Photos.Where(s => s.album_id == queriedAlbumItem.id);
            var albumViewModel   = new AlbumView();

            albumViewModel.id        = queriedAlbumItem.id;
            albumViewModel.photoList = photoList;
            albumViewModel.name      = queriedAlbumItem.name;
            albumViewModel.owner_id  = queriedAlbumItem.owner_id;
            if (queriedAlbumItem.owner_id == User.FindFirst("emails").Value)
            {
                albumViewModel.permission_level = 2;
            }
            else
            {
                albumViewModel.permission_level = _context.Permissions.Where(s => s.album_id == albumId && s.user_id == User.FindFirst("emails").Value).First().permission_level;
            }
            return(albumViewModel);
        }
Beispiel #26
0
        private void PlaylistGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (PlaylistsGridView.SelectionMode != ListViewSelectionMode.None)
            {
                return;
            }
            AlbumView album = (AlbumView)e.ClickedItem;

            if (album.Name == MenuFlyoutHelper.NowPlaying)
            {
                Frame.Navigate(typeof(NowPlayingPage));
            }
            else if (album.Name == MenuFlyoutHelper.MyFavorites)
            {
                Frame.Navigate(typeof(MyFavoritesPage));
            }
            else
            {
                Frame.Navigate(typeof(AlbumPage), album);
            }
        }
Beispiel #27
0
        public static async Task <SearchResult> Search(string keyword)
        {
            List <SearchResult> results = new List <SearchResult>();

            Playlist artist = (await Task.Run(() => SearchArtists(MusicLibraryPage.AllSongs, keyword, SortBy.Artist)))?.FirstOrDefault();

            results.Add(new SearchResult(SearchType.Artists, artist, EvaluateArtist(artist, keyword)));
            Music music = (await Task.Run(() => SearchSongs(MusicLibraryPage.AllSongs, keyword, SortBy.Artist)))?.FirstOrDefault();

            results.Add(new SearchResult(SearchType.Artists, artist, EvaluateMusic(music, keyword)));
            AlbumView album = (await Task.Run(() => SearchAlbums(MusicLibraryPage.AllSongs, keyword, SortBy.Artist)))?.FirstOrDefault();

            results.Add(new SearchResult(SearchType.Artists, album, EvaluateAlbum(album, keyword)));
            GridFolderView folder = (await Task.Run(() => SearchFolders(Settings.settings.Tree, keyword, SortBy.Artist)))?.FirstOrDefault();

            results.Add(new SearchResult(SearchType.Folders, folder, EvaluateFolder(folder, keyword)));
            AlbumView playlist = (await Task.Run(() => SearchPlaylists(Settings.settings.Playlists, keyword, SortBy.Artist)))?.FirstOrDefault();

            results.Add(new SearchResult(SearchType.Playlists, playlist, EvaluatePlaylist(playlist, keyword)));

            results.Sort((r1, r2) => r2.Score - r1.Score);
            return(results[0]);
        }
Beispiel #28
0
        private async Task <StackLayout> GetAlbum()
        {
            var Results = await GetAlbumDetails.ById(AlbumId);

            var    Album  = Results.AlbumInformation;
            var    Title  = ConvertJuxString.Decode(Album.Album);
            var    Artist = ConvertJuxString.Decode(Album.Artist);
            string Year   = Convert.ToDateTime(ConvertJuxString.Decode(Album.Date)).Year.ToString();


            var stack = new StackLayout();
            await Task.Run(() =>
            {
                var albumView      = new AlbumView();
                albumView.Artist   = Artist;
                albumView.Album    = Title;
                albumView.ImageUrl = Album.High_Quality_Picture;
                albumView.AlbumId  = AlbumId;
                albumView.Year     = Year;
                stack.Children.Add(albumView);
            });

            return(stack);
        }
 public void DeletePhoto(AlbumView data)
 {
     _AlbumServices.DeletePhoto(data.p_Id);
 }
        private void Search()
        {
            Big3.Hitbase.DataBaseEngine.Condition sel = new Big3.Hitbase.DataBaseEngine.Condition();

            // Diese Sachen direkt speichern, wenn einmal gesucht wurde.
            Settings.SetValue("LinkSameNumber", checkBoxSameTrackCount.IsChecked == true ? (int)1 : (int)0);
            Settings.SetValue("LinkNotLinked", checkBoxNotAssigned.IsChecked == true ? (int)1 : (int)0);

            // Nur CDs.
            sel.Add(Field.AlbumType, Operator.Equal, 0);

            if (this.checkBoxNotAssigned.IsChecked == true)
            {
                sel.Add(Field.Identity, Operator.Empty, 0);
            }

            if (this.checkBoxSameTrackCount.IsChecked == true)
            {
                sel.Add(Field.NumberOfTracks, Operator.Equal, cdInDrive.NumberOfTracks);
            }

            if (textBoxArtist.Text != "")
            {
                sel.Add(Field.ArtistCDName, Operator.Contains, textBoxArtist.Text);
            }

            if (textBoxTitle.Text != "")
            {
                sel.Add(Field.Title, Operator.Contains, textBoxTitle.Text);
            }

            SortFieldCollection sortKeys = new SortFieldCollection();

            sortKeys.Add(Field.ArtistCDName);
            sortKeys.Add(Field.Title);

            FieldCollection fc = new FieldCollection();

            fc.Add(Field.ArtistCDName);
            fc.Add(Field.Title);
            fc.Add(Field.TotalLength);
            fc.Add(Field.NumberOfTracks);

            List <CDItemResult> items = new List <CDItemResult>();

            using (DataBaseView albumView = AlbumView.CreateView(dataBase, fc, sortKeys, 0, sel))
            {
                object[] values;

                while ((values = albumView.Read()) != null)
                {
                    CDItemResult newItem = new CDItemResult();
                    newItem.CDID           = (int)values[0];
                    newItem.Artist         = (string)values[1];
                    newItem.Title          = values[2] is DBNull ? "" : (string)values[2];
                    newItem.Length         = (int)values[3];
                    newItem.NumberOfTracks = (int)values[4];

                    items.Add(newItem);
                }
            }

            DataGridResult.ItemsSource = items;

            return;
        }
        public List<AlbumView> getAlbumList(string userid)
        {
            List<AlbumView> alist = new List<AlbumView>();

            string SQLStatement = "SELECT * FROM album WHERE user_id='"+ userid +"\'" ;

            // Create a SqlDataAdapter to get the results as DataTable
            SqlDataAdapter SQLDataAdapter = new SqlDataAdapter(SQLStatement, conn);

            // Create a new DataTable
            DataTable dtResult = new DataTable();

            // Fill the DataTable with the result of the SQL statement
            SQLDataAdapter.Fill(dtResult);

            foreach (DataRow drRow in dtResult.Rows)
            {
                AlbumView al = new AlbumView();
                al._id = Convert.ToInt32(drRow["_id"].ToString());
                al.user_id = drRow["user_id"].ToString();
                al.name = drRow["name"].ToString();
                al.face_addr = drRow["face_addr"].ToString();
                al.size = Convert.ToInt32(drRow["size"].ToString());
                al.file_path = drRow["file_path"].ToString();
                al.network_addr = drRow["network_addr"].ToString();
                al.descript = drRow["descript"].ToString();
                alist.Add(al);
            }
            return alist;
        }