Exemplo n.º 1
0
        public async void ReadMyXML(string year, string month)
        {
            Albums = new Albums();

            Progress<int> progress = new Progress<int>((p) => { ProgressPercent = p; });

            BasicFileDownloader bidl = new BasicFileDownloader(ToAbsoluteUri("xmlalbums.aspx?ay=" + year + "&am=" + month));
            IRandomAccessStream s = await bidl.DownloadAsync(progress);

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ConformanceLevel = ConformanceLevel.Fragment;
            settings.IgnoreWhitespace = true;
            settings.IgnoreComments = true;
            settings.Async = true;
            XmlReader reader = XmlReader.Create(s.AsStream(), settings);
            reader.ReadStartElement("Model");
            reader.ReadStartElement("Albums");
            Count = 0;
            while (reader.IsStartElement())
            {
                string albumid = reader[0];
                string album = reader[2];
                string str = reader[1];
                str = str.Replace("_s.jpg", "");
                uint count = 0;
                if (uint.TryParse(reader[3], out count))
                {
                    Album m = new Album(albumid, album, str, count);
                    Albums.Add(m);
                    Count += m.Count;
                }
                await reader.ReadAsync();
            }
        }
Exemplo n.º 2
0
        private static void InitializeAlbums()
        {
            m_albums = new Albums();

            AlbumQuery albumQuery = new AlbumQuery();
            albumQuery.Uri = new Uri(PicasaQuery.CreatePicasaUri(ConfigurationManager.AppSettings.Get("PicasaWebUserId")));
            albumQuery.Access = PicasaQuery.AccessLevel.AccessPublic;

            PicasaFeed feed = PicasaService.Query(albumQuery);

            if (feed != null && feed.Entries.Count > 0)
            {
                foreach (PicasaEntry entry in feed.Entries)
                {
                    Album album = new Album();
                    album.Title = entry.Title.Text;
                    album.Summary = entry.Summary.Text.Replace("\r\n", "<br/>");
                    album.FeedUri = entry.FeedUri;
                    album.ThumbnailUrl = entry.Media.Thumbnails[0].Attributes["url"].ToString();
                    album.NumberOfPhotos = ((GPhotoNumPhotos)entry.ExtensionElements[5]).IntegerValue;

                    m_albums.Add(album);
                }
            }
        }
Exemplo n.º 3
0
 public void CreateAlbums(Albums albums)
 {
     using (SqlConnection connection = base.GetConnection())
     {
         SqlCommand command = new SqlCommand("_AlbumsUpdate", connection) {
             CommandType = CommandType.StoredProcedure
         };
         command.Parameters.AddWithValue("@Type", 0);
         command.Parameters.AddWithValue("@AlbumsID", 0);
         command.Parameters.AddWithValue("@AlbumsCateID", albums.AlbumsCateID);
         command.Parameters.AddWithValue("@Title", albums.Title);
         command.Parameters.AddWithValue("@Description", albums.Description);
         command.Parameters.AddWithValue("@ImageThumb", albums.ImageThumb);
         command.Parameters.AddWithValue("@ImageLarge", albums.ImageLarge);
         command.Parameters.AddWithValue("@Author", albums.Author);
         command.Parameters.AddWithValue("@PostDate", albums.PostDate);
         command.Parameters.AddWithValue("@Status", albums.Status);
         command.Parameters.AddWithValue("@Ishot", albums.Ishot);
         command.Parameters.AddWithValue("@Isview", albums.Isview);
         command.Parameters.AddWithValue("@Ishome", albums.Ishome);
         command.Parameters.AddWithValue("@IsComment", albums.IsComment);
         command.Parameters.AddWithValue("@ApprovalDate", albums.ApprovalDate);
         command.Parameters.AddWithValue("@ApprovalUserName", albums.ApprovalUserName);
         command.Parameters.AddWithValue("@IsApproval", albums.IsApproval);
         command.Parameters.AddWithValue("@CreatedUserName", albums.CreatedUserName);
         command.Parameters.AddWithValue("@CommentTotal", albums.CommentTotal);
         connection.Open();
         if (command.ExecuteNonQuery() <= 0)
         {
             throw new DataAccessException("Kh\x00f4ng thể th\x00eam mới tin");
         }
         command.Dispose();
     }
 }
 public List <Album> GetAlbums()
 {
     return(Albums.OrderBy(alb => alb.Title).ToList());
 }
Exemplo n.º 5
0
        public virtual bool IsOnAlbum(Album album)
        {
            ParamIs.NotNull(() => album);

            return(Albums.Any(a => a.Album.Equals(album)));
        }
        public Albums GetAlbums()
        {
            if (Albums == null)
            {
                Albums = new Albums()
                {
                    new Album()
                    {
                        Id          = 1,
                        Length      = "53:52",
                        AlbumArtUrl = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Images/Artist2.jpg")),
                            Name     = "Guns N Roses"
                        },
                        Price       = 18,
                        ReleaseYear = "1987",
                        Title       = "Appetite for Destruction",
                        Genre       = new Genre()
                        {
                            GenreId     = 1,
                            Description =
                                "Appetite for Destruction is the debut studio album by American hard rock band Guns N' Roses. It was released on July 21, 1987, by Geffen Records to massive commercial success.",
                            Name = "Heavy metal, Hard rock, Glam metal"
                        },
                        Songs = new List <Song>()
                        {
                            new Song {
                                Name = "Welcome to the Jungle", Id = 1, Duration = "4:34"
                            },
                            new Song {
                                Name = "It's So Easy", Id = 2, Duration = "3:21"
                            },
                            new Song {
                                Name = "Nightrain", Id = 3, Duration = "4:26"
                            },
                            new Song {
                                Name = "Out ta Get Me", Id = 4, Duration = "4:20"
                            },
                            new Song {
                                Name = "Mr. Brownstone", Id = 5, Duration = "3:46"
                            },
                            new Song {
                                Name = "Paradise City", Id = 6, Duration = "6:46"
                            },
                            new Song {
                                Name = "My Michelle", Id = 7, Duration = "3:39"
                            },
                            new Song {
                                Name = "Think About You", Id = 8, Duration = "3:50"
                            },
                            new Song {
                                Name = "Sweet Child o' Mine", Id = 9, Duration = "5:55"
                            },
                            new Song {
                                Name = "You're Crazy", Id = 10, Duration = "3:16"
                            },
                            new Song {
                                Name = "Anything Goes", Id = 11, Duration = "3:25"
                            },
                            new Song {
                                Name = "Rocket Queen", Id = 12, Duration = "6:13"
                            },
                        }
                    },

                    new Album()
                    {
                        Id          = 4,
                        Length      = "	01:00:01",
                        AlbumArtUrl = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Images/KennyG.jpg")),
                            Name     = "Kenny G"
                        },
                        Price       = 18,
                        ReleaseYear = "2015",
                        Title       = "Brazilian Nights",
                        Genre       = new Genre()
                        {
                            GenreId     = 1,
                            Description =
                                "Brazilian Nights is the fifteenth studio album by Kenny G, released on January 27, 2015, his second bossa nova album, following Rhythm & Romance released in 2008.",
                            Name = "Latin jazz, Smooth jazz"
                        },
                        Songs = new List <Song>()
                        {
                            new Song {
                                Name = "Bossa Antigua", Id = 1, Duration = "3:48"
                            },
                            new Song {
                                Name = "Corcovado (Quiet Nights Of Quiet Stars)", Id = 2, Duration = "7:30"
                            },
                            new Song {
                                Name = "Bossa Réal", Id = 3, Duration = "7:36"
                            },
                            new Song {
                                Name = "Brazilian Nights", Id = 4, Duration = "6:38"
                            },
                            new Song {
                                Name = "April Rain", Id = 5, Duration = "6:48"
                            },
                            new Song {
                                Name = "Menina Moca", Id = 6, Duration = "5:57"
                            },
                            new Song {
                                Name = "Bu Bossa", Id = 7, Duration = "4:25"
                            },
                            new Song {
                                Name = "Clouds", Id = 8, Duration = "5:37"
                            },
                            new Song {
                                Name = "Girl From Ipanema", Id = 9, Duration = "5:33"
                            },
                            new Song {
                                Name = "Summer Love", Id = 10, Duration = "6:15"
                            }
                        }
                    },

                    new Album()
                    {
                        Id          = 2,
                        Length      = "41:13",
                        AlbumArtUrl = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Images/Artist1.jpg")),
                            Name     = "David Bowie"
                        },
                        Price       = 18,
                        ReleaseYear = "2016",
                        Title       = "Blackstar",
                        Genre       = new Genre()
                        {
                            GenreId     = 1,
                            Description =
                                "is the twenty-fifth and final studio album by the English musician David Bowie, released worldwide through ISO, RCA, Columbia, and Sony on 8 January 2016, coinciding with Bowie's 69th birthday.",
                            Name = "Art rock, jazz, experimental rock"
                        },
                        Songs = new List <Song>()
                        {
                            new Song {
                                Name = "Blackstar", Id = 1, Duration = "9:57"
                            },
                            new Song {
                                Name = "Tis a Pity She Was a W***e", Id = 2, Duration = "4:52"
                            },
                            new Song {
                                Name = "Lazarus", Id = 3, Duration = "6:22"
                            },
                            new Song {
                                Name = "Sue (Or in a Season of Crime)", Id = 4, Duration = "4:40"
                            },
                            new Song {
                                Name = "Girl Loves Me", Id = 5, Duration = "4:51"
                            },
                            new Song {
                                Name = "Dollar Days", Id = 6, Duration = "6:46"
                            },
                            new Song {
                                Name = "My Michelle", Id = 7, Duration = "4:44"
                            },
                            new Song {
                                Name = "I Can't Give Everything Away", Id = 8, Duration = "5:47"
                            }
                        }
                    },

                    new Album()
                    {
                        Id          = 3,
                        Length      = "53:17",
                        AlbumArtUrl = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Images/Artist1.jpg")),
                            Name     = "David Bowie"
                        },
                        Price       = 18,
                        ReleaseYear = "2013",
                        Title       = "The Next Day",
                        Genre       = new Genre()
                        {
                            GenreId     = 1,
                            Description =
                                "The Next Day is the twenty-fourth studio album by musician David Bowie, released on 8 March 2013 on his ISO Records label, under exclusive licence to Columbia Records. The album was announced on Bowie's sixty-sixth birthday, 8 January 2013.",
                            Name = "Art rock"
                        },
                        Songs = new List <Song>()
                        {
                            new Song {
                                Name = "The Next Day", Id = 1, Duration = "3:27"
                            },
                            new Song {
                                Name = "Dirty Boys", Id = 2, Duration = "2:58"
                            },
                            new Song {
                                Name = "The Stars (Are Out Tonight)", Id = 3, Duration = "3:56"
                            },
                            new Song {
                                Name = "Love Is Lost", Id = 4, Duration = "3:57"
                            },
                            new Song {
                                Name = "Where Are We Now?", Id = 5, Duration = "4:08"
                            },
                            new Song {
                                Name = "Valentine's Day", Id = 6, Duration = "3:01"
                            },
                            new Song {
                                Name = "If You Can See Me", Id = 7, Duration = "3:15"
                            },
                            new Song {
                                Name = "I'd Rather Be High", Id = 8, Duration = "3:53"
                            },
                            new Song {
                                Name = "Boss of Me", Id = 9, Duration = "4:09"
                            },
                            new Song {
                                Name = "Dancing Out in Space", Id = 10, Duration = "3:24"
                            },
                            new Song {
                                Name = "How Does the Grass Grow?", Id = 11, Duration = "4:33"
                            },
                            new Song {
                                Name = "(You Will) Set the World On Fire", Id = 13, Duration = "3:30"
                            },
                            new Song {
                                Name = "You Feel So Lonely You Could Die", Id = 14, Duration = "4:37"
                            },
                            new Song {
                                Name = "Heat", Id = 12, Duration = "4:25"
                            },
                        }
                    }
                };
            }

            return(Albums);
        }
Exemplo n.º 7
0
        async Task <bool> ParseMediaFile(StorageFile item, bool isCameraRoll)
        {
            try
            {
                if (VLCFileExtensions.AudioExtensions.Contains(item.FileType.ToLower()))
                {
                    if (musicDatabase.ContainsTrack(item.Path))
                    {
                        return(true);
                    }

                    // Groove Music puts its cache into this folder in Music.
                    // If the file is in this folder or subfolder, don't add it to the collection,
                    // since we can't play it anyway because of the DRM.
                    if (item.Path.Contains("Music Cache") || item.Path.Contains("Podcast"))
                    {
                        return(false);
                    }

                    var media = await Locator.VLCService.GetMediaFromPath(item.Path);

                    var mP = await Locator.VLCService.GetMusicProperties(media);

                    if (mP == null || (string.IsNullOrEmpty(mP.Artist) && string.IsNullOrEmpty(mP.Album) && (string.IsNullOrEmpty(mP.Title) || mP.Title == item.Name)))
                    {
                        var props = await item.Properties.GetMusicPropertiesAsync();

                        mP = new MediaProperties()
                        {
                            Album       = props.Album,
                            AlbumArtist = props.AlbumArtist,
                            Artist      = props.Artist,
                            Title       = props.Title,
                            Tracknumber = props.TrackNumber,
                            Genre       = (props.Genre != null && props.Genre.Any()) ? props.Genre[0] : null,
                        };
                    }
                    if (mP != null)
                    {
                        var        artistName      = mP.Artist?.Trim();
                        var        albumArtistName = mP.AlbumArtist?.Trim();
                        ArtistItem artist          = LoadViaArtistName(string.IsNullOrEmpty(albumArtistName) ? artistName : albumArtistName);
                        if (artist == null)
                        {
                            artist           = new ArtistItem();
                            artist.Name      = string.IsNullOrEmpty(albumArtistName) ? artistName : albumArtistName;
                            artist.PlayCount = 0;
                            musicDatabase.Add(artist);
                            Artists.Add(artist);
                        }

                        var       albumName = mP.Album?.Trim();
                        var       albumYear = mP.Year;
                        AlbumItem album     = musicDatabase.LoadAlbumFromName(artist.Id, albumName);
                        if (album == null)
                        {
                            string albumSimplifiedUrl = null;
                            if (!string.IsNullOrEmpty(mP.AlbumArt) && mP.AlbumArt.StartsWith("file://"))
                            {
                                // The Uri will be like
                                // ms-appdata:///local/vlc/art/artistalbum/30 Seconds To Mars/B-sides & Rarities/art.jpg
                                var indexStart = mP.AlbumArt.IndexOf("vlc/art/artistalbum/", StringComparison.Ordinal);
                                if (indexStart != -1)
                                {
                                    albumSimplifiedUrl = mP.AlbumArt.Substring(indexStart, mP.AlbumArt.Length - indexStart);
                                    Debug.WriteLine("VLC : found album cover with TagLib - " + albumName);
                                }
                            }

                            album = new AlbumItem
                            {
                                Name          = string.IsNullOrEmpty(albumName) ? string.Empty : albumName,
                                AlbumArtist   = albumArtistName,
                                Artist        = string.IsNullOrEmpty(albumArtistName) ? artistName : albumArtistName,
                                ArtistId      = artist.Id,
                                Favorite      = false,
                                Year          = albumYear,
                                AlbumCoverUri = albumSimplifiedUrl
                            };
                            musicDatabase.Add(album);
                            Albums.Add(album);
                        }

                        TrackItem track = new TrackItem
                        {
                            AlbumId         = album.Id,
                            AlbumName       = album.Name,
                            ArtistId        = artist.Id,
                            ArtistName      = artistName,
                            CurrentPosition = 0,
                            Duration        = mP.Duration,
                            Favorite        = false,
                            Name            = string.IsNullOrEmpty(mP.Title) ? item.DisplayName : mP.Title,
                            Path            = item.Path,
                            Index           = mP.Tracknumber,
                            DiscNumber      = mP.DiscNumber,
                            Genre           = mP.Genre,
                            IsAvailable     = true,
                        };
                        musicDatabase.Add(track);
                        Tracks.Add(track);
                    }
                }
                else if (VLCFileExtensions.VideoExtensions.Contains(item.FileType.ToLower()))
                {
                    if (videoDatabase.DoesMediaExist(item.Path))
                    {
                        return(true);
                    }

                    var video = await MediaLibraryHelper.GetVideoItem(item);

                    if (video.IsTvShow)
                    {
                        await AddTvShow(video);
                    }
                    else if (isCameraRoll)
                    {
                        video.IsCameraRoll = true;
                        CameraRoll.Add(video);
                    }
                    else
                    {
                        Videos.Add(video);
                    }
                    videoDatabase.Insert(video);
                }
                else
                {
                    Debug.WriteLine($"{item.Path} is not a media file");
                    return(false);
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(true);
        }
Exemplo n.º 8
0
        private void Ins(HttpContext context, int NUM_LANG)
        {
            int    ret        = -1;
            String jSonString = "";

            try {
                long     a        = DateTime.Now.Ticks;
                TimeSpan Codespan = new TimeSpan(a);
                AlbumsBO albumsBO = new AlbumsBO();
                for (int i = 1; i <= NUM_LANG; i++)
                {
                    Albums aAlbums = new Albums();
                    aAlbums.Code   = Math.Floor(Codespan.TotalSeconds).ToString();
                    aAlbums.Status = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"])
                        ? Convert.ToInt32(context.Request.Form["cbbStatus"])
                        : 1;

                    aAlbums.Disable = !String.IsNullOrEmpty(context.Request.Form["cbbDisable"])
                        ? Convert.ToBoolean(context.Request.Form["cbbDisable"])
                        : false;

                    aAlbums.CreateDate = DateTime.Now;

                    aAlbums.CreateByIDUser = currentSystemUsers.ID;
                    aAlbums.Image          = !String.IsNullOrEmpty(context.Request.Form["txtImage_1"])
                        ? Convert.ToString(context.Request.Form["txtImage_1"])
                        : "";

                    aAlbums.Image1 = !String.IsNullOrEmpty(context.Request.Form["txtImage_2"])
                        ? Convert.ToString(context.Request.Form["txtImage_2"])
                        : "";
                    aAlbums.Image2 = !String.IsNullOrEmpty(context.Request.Form["txtImage_3"])
                        ? Convert.ToString(context.Request.Form["txtImage_3"])
                        : "";
                    aAlbums.Image3 = !String.IsNullOrEmpty(context.Request.Form["txtImage_4"])
                        ? Convert.ToString(context.Request.Form["txtImage_4"])
                        : "";

                    aAlbums.Type = !String.IsNullOrEmpty(context.Request.Form["cbbType"])
                        ? Convert.ToInt32(context.Request.Form["cbbType"])
                        : 0;

                    aAlbums.ViewCount = !String.IsNullOrEmpty(context.Request.Form["txtViewCount"])
                        ? Convert.ToInt64(context.Request.Form["txtViewCount"])
                        : 0;
                    aAlbums.DownloadCount = !String.IsNullOrEmpty(context.Request.Form["txtViewdowload"])
                        ? Convert.ToInt64(context.Request.Form["txtViewdowload"])
                        : 0;

                    aAlbums.IDLang = !String.IsNullOrEmpty(context.Request.Form["IDLang_" + i])
                        ? Convert.ToInt32(context.Request.Form["IDLang_" + i])
                        : 0;

                    aAlbums.Title = !String.IsNullOrEmpty(context.Request.Form["txtTitle_Lang" + i])
                        ? Convert.ToString(context.Request.Form["txtTitle_Lang" + i])
                        : "";

                    aAlbums.Info = !String.IsNullOrEmpty(context.Request.Form["txtInfo_Lang" + i])
                        ? Convert.ToString(HttpUtility.HtmlDecode(context.Request.Form["txtInfo_Lang" + i]))
                        : "";

                    aAlbums.Intro = !String.IsNullOrEmpty(context.Request.Form["txtIntro_Lang" + i])
                        ? Convert.ToString(context.Request.Form["txtIntro_Lang" + i])
                        : "";

                    ret = albumsBO.Ins(aAlbums);
                    if (ret == 0)
                    {
                        jSonString = "{\"status\":\"error|" + ret + "\"}";
                        break;
                    }
                }
                if (ret != 0)
                {
                    jSonString = "{\"status\": \"success\"}";
                }
            }
            catch (Exception ex) {
                jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message + "\"}";
            }
            finally {
                context.Response.Write(jSonString);
            }
        }
Exemplo n.º 9
0
        protected void btn_edit_Click(object sender, EventArgs e)
        {
            try
            {
                Albums album = new Albums();
                album = ReceiveHtml();


                AlbumsBSO albumBSO = new AlbumsBSO();
                albumBSO.UpdateAlbums(album);

                BindAlbumsCate(Convert.ToInt32(hddAlbumsCateID.Value));
                ViewAlbum(Convert.ToInt32(hddAlbumsCateID.Value));
                clientview.Text = String.Format(Resources.StringAdmin.AddNewsSuccessful);
            }
            catch (Exception ex)
            {
                clientview.Text = ex.Message.ToString();
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// There are no comments for Albums in the schema.
 /// </summary>
 public void AddToAlbums(Albums albums)
 {
     base.AddObject("Albums", albums);
 }
Exemplo n.º 11
0
 public void UpdateAlbums(Albums albums)
 {
     new AlbumsDAO().UpdateAlbums(albums);
 }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            Action line = () => Console.WriteLine("-----------------------------------------------------------");

            Init();

            //1 - how many Songs start with the letter 'a' (case insensitive)
            int counter          = 0;
            var songsWithLetterA = Songs.Select(x => x.Name.ToLower()).Where(x => x.StartsWith("a"));

            foreach (var item in songsWithLetterA)
            {
                counter++;
            }
            Console.WriteLine(counter + " songs start with letter 'a'");
            line();

            //2 - how many artists end with letter 'a' (case insensitive)
            int counter2             = 0;
            var songsEndsWithLetterA = Songs.Select(x => x.Name.ToLower()).Where(x => x.EndsWith("a"));

            foreach (var item in songsEndsWithLetterA)
            {
                counter2++;
            }
            Console.WriteLine(counter2 + " song ends with letter 'a'");
            line();

            //3 - whats the name of the song with longest duration
            var songsDuration           = Songs.Select(x => x.Duration);
            var longest                 = songsDuration.Max();
            var songWithLongestDuration = Songs.Where(x => x.Duration == longest);

            foreach (var item in songWithLongestDuration)
            {
                Console.WriteLine("Song with longest duration is: " + item.Name);
            }
            line();

            //4 - whats the total Duration of all Songs
            var totalDuration = songsDuration.Sum();

            Console.WriteLine("Total Duration of all Songs is : " + totalDuration);
            line();

            //5 - how many albums have Songs longer than 300 seconds
            var durationOfSongsLongerThan300 = Songs.Where(x => x.Duration >= 300);
            var albumsOfTheSongs             = durationOfSongsLongerThan300.Select(x => x.AlbumId).Distinct().Count();

            Console.WriteLine("There are " + string.Join(" ", albumsOfTheSongs) + " albums that have songs longer than 300 seconds");
            line();

            //6 - print the names of the artists(separated with "--"), that have more than one album of PopRock genre
            List <string> newList     = new List <string>();
            var           albumsGenre = Albums.Where(x => x.Genre == Genre.PopRock);

            foreach (var item in albumsGenre)
            {
                var artistPopRock = Artists.Where(x => x.Id == item.ArtistId);
                foreach (var item2 in artistPopRock)
                {
                    newList.Add(item2.FullName);
                }
            }
            Console.WriteLine("Artist that have more than one album of PopRock genre are :");
            var something0 = newList.GroupBy(x => x).Where((g => g.Count() > 1));

            foreach (var item in something0)
            {
                Console.WriteLine("--" + item.Key);
            }
            line();

            //7 - print the name of the album that has highest Average duration of a song
            var highestDuration = Albums.Select(x => new { _album = x.Name, _duration = x.Songs.Average(d => d.Duration) })
                                  .OrderByDescending(x => x._duration).First();

            Console.WriteLine($"The album with highest average duration of a song is : {highestDuration._album}");

            line();
            //8 - how many characters has the song that has the shortest Duration
            var shortestSong = Songs.OrderBy(x => x.Duration).First();

            char [] charArray = shortestSong.Name.ToString().ToCharArray();
            double  count     = 0;

            foreach (var c in charArray)
            {
                count++;
            }
            Console.WriteLine("The song with shortest duration has " + count + " characters");
            line();

            //9 - print the name and the genre of the album that has most songs
            var findId          = Songs.GroupBy(p => p.AlbumId).OrderByDescending(r => r.Count()).FirstOrDefault();
            var nameOftheAlbum1 = Albums.Where(x => x.Id == findId.Key).FirstOrDefault();

            Console.WriteLine("The name of the album is : " + nameOftheAlbum1.Name + " of genre " + nameOftheAlbum1.Genre);
            line();

            //10 - print the name of the artist that has most songs
            var artistMostSongs = Artists
                                  .Select(x => new { NameOfArtist = x.FullName, SongsOfArtist = x.Albums.Sum(y => y.Songs.Count) })
                                  .OrderByDescending(a => a.SongsOfArtist)
                                  .First();

            Console.WriteLine($"Artist: {artistMostSongs.NameOfArtist}, Songs Count: {artistMostSongs.SongsOfArtist}");


            line();
            //11 - print the type of the artist(SoloArtist/Band) that has most albums published before year 2000
            var before2000 = Albums.Where(x => x.Year < 2000).First();
            var theArtist  = Artists.Where(x => x.Id == before2000.Id);

            foreach (var item in theArtist)
            {
                Console.WriteLine(item.FullName);
            }
            line();

            //12 - print the average song duration, of the album that has most songs
            var findAlbumId     = Songs.GroupBy(p => p.AlbumId).OrderByDescending(r => r.Count()).FirstOrDefault();
            var averageDuration = Songs.Where(p => p.AlbumId == findAlbumId.Key).Average(x => x.Duration);

            Console.WriteLine("The average duration of the album with the most songs is : " + averageDuration);
            line();

            // Bonus:
            Console.WriteLine("Bonus:");
            line();

            //13 - print the longest song duration of the album that has least songs
            var albumWithLeastSong  = Songs.GroupBy(q => q.AlbumId).OrderBy(gp => gp.Count()).FirstOrDefault();
            var shortestSonginAlbum = albumWithLeastSong.OrderByDescending(x => x.Duration).FirstOrDefault();

            Console.WriteLine("The longest song of the album with least songs is " + shortestSonginAlbum.Name +
                              " with duration " + shortestSonginAlbum.Duration);
            line();

            //14 - print the name of the album that has most songs that contain letter 'a' in the name
            var containA = Albums.Select(x => new { _album = x.Name, _containA = x.Songs.Where(y => y.Name.Contains("a")).Count() })
                           .OrderByDescending(x => x._containA).FirstOrDefault();

            Console.WriteLine($"The name of the album that has most songs that contain letter 'a' is {containA._album}");

            line();

            //15 - print the name of the artist that has most songs that end with letter 'd'


            line();
            Console.ReadLine();
        }
Exemplo n.º 13
0
        public override void SaveChanges()
        {
            _context.Artists.AddOrUpdate(Artists.ToArray());
            _context.Albums.AddOrUpdate(Albums.ToArray());
            _context.Tracks.AddOrUpdate(Tracks.ToArray());

            RemoveEntities(_context.Artists, _context.Artists.AsEnumerable().Where(a => !Artists.Contains(a)));
            RemoveEntities(_context.Albums, _context.Albums.AsEnumerable().Where(a => !Albums.Contains(a)));
            RemoveEntities(_context.Tracks, _context.Tracks.AsEnumerable().Where(a => !Tracks.Contains(a)));

            _context.SaveChanges();
        }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            Init();// this method fills the arrays above with data

            // - print the mass of the earth on July 1895 XD

            /*
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░
             *  ░░███████░░░░░░░░░░███▒▒▒▒▒▒▒▒███░░░░░░
             *  ░░█▒▒▒▒▒▒█░░░░░░░███▒▒▒▒▒▒▒▒▒▒▒▒███░░░░
             *  ░░░█▒▒▒▒▒▒█░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░
             *  ░░░░█▒▒▒▒▒█░░░██▒▒▒▒▄██▄▒▒▒▒▄██▄▒▒▒███░
             *  ░░░░░█▒▒▒█░░░█▒▒▒▒▒▒████▒▒▒▒████▒▒▒▒▒██
             *  ░░░█████████████▒▒▒▒▀██▀▒▒▒▒▀██▀▒▒▒▒▒██
             *  ░░░█▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒██
             *  ░██▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒██▒▒▒▒▒▒▒▒▒██▒▒▒▒██
             *  ██▒▒▒███████████▒▒▒▒▒██▒▒▒▒▒▒▒██▒▒▒▒▒██
             *  █▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒███████▒▒▒▒▒▒▒██
             *  ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░
             *  ░█▒▒▒███████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░░
             *  ░██▒▒▒▒▒▒▒▒▒▒▒███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█░░░░░
             *  ░░████████████░░░████████████████░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░▄█████▄░▄███████▄░▄███████▄░██████▄░░
             *  ░░██▒▒▒▒█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░██▒▒▒▒▒░██▒▒▒▒▒██░██▒▒▒▒▒██░██▒▒▒██░░
             *  ░░██▒▒▒▀█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░▀█████▀░▀███████▀░▀███████▀░██████▀░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░▄█████░██▒▒▒▒██▀░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▀▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▒▒▒▒░█████▀░░░░░░░
             *  ░░░░██▒▒▒▒░██▄▒▄██░██▄▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░▀█████░▀█████▀░▀█████░██▒▒▒▒██▄░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             */

            // QUERIES!

            // - how many Songs start with the letter 'a' (case insensitive)

            List <Song> songsThatStartwitha = Songs.Where(song => song.Name.StartsWith('a')).ToList();
            List <Song> songsThatStartwithA = Songs.Where(song => song.Name.StartsWith('A')).ToList();

            Console.WriteLine($"There are {songsThatStartwitha.Count()} song names that start with 'a', and {songsThatStartwithA.Count()} song names that start with 'A'!");
            Console.WriteLine("_____________________________");

            // - how many artists end with letter 'a' (case insensitive)

            List <Artist> artistsEndingWitha = Artists.Where(artist => artist.FullName.EndsWith('a')).ToList();

            Console.WriteLine($"There are/is {artistsEndingWitha.Count()} artist(s) whose name(s) end(s) with 'a'!");
            Console.WriteLine("_____________________________");

            // - whats the name of the song with longest duration
            int longestSong     = Songs.Max(song => song.Duration);
            var longestSongName = Songs.Where(song => song.Duration == longestSong).Select(song => new { song.Name, song.Duration }).SingleOrDefault();

            Console.WriteLine($"Longest Song: Name: {longestSongName.Name} | Duration: {longestSongName.Duration} seconds");
            Console.WriteLine("_____________________________");

            // - whats the total Duration of all Songs

            var totalDuration = Songs.Sum(song => song.Duration);

            Console.WriteLine($"The total duration of all songs is {totalDuration} seconds!");
            Console.WriteLine("_____________________________");

            // - how many albums have Songs longer than 300 seconds

            List <int> albumsWithSongsLOngerThan300 = Songs.Where(song => song.Duration > 300).Select(song => song.AlbumId).ToList();
            List <int> numberOfAlbums = albumsWithSongsLOngerThan300.Distinct().ToList();

            Console.WriteLine($"There are {numberOfAlbums.Count()} albums with songs longer than 300 seconds!");
            Console.WriteLine("_____________________________");

            // - print the names of the artists(separated with "--"), that have more than one album of PopRock genre

            var           popRockArtistsIds = Albums.Where(album => album.Genre == Genre.PopRock).Select(id => id.ArtistId).ToList();
            var           returnDuplicates  = popRockArtistsIds.GroupBy(id => id).Where(id => id.Count() > 1).Select(id => id.Key).ToList();
            List <string> names             = new List <string>();

            foreach (var name in Artists)
            {
                foreach (var id in returnDuplicates)
                {
                    if (id == name.Id)
                    {
                        names.Add(name.FullName);
                    }
                }
            }
            List <string> artistWithPopRockAlbums = names.Distinct().ToList();

            Console.WriteLine($"The artists with more than one PopRock album are:");
            artistWithPopRockAlbums.ForEach(band => Console.Write($"{band} == "));
            Console.WriteLine("\n_____________________________");

            // - print the name of the album that has highest Average duration of a song

            Dictionary <string, double> nameAndDuration = new Dictionary <string, double>();

            foreach (var album in Albums)
            {
                double duration = album.Songs.Average(track => track.Duration);
                nameAndDuration.Add(album.Name, duration);
            }
            var printResult = nameAndDuration.OrderBy(duration => duration.Key).First();

            Console.WriteLine($"\nThe album { printResult.Key} has the highest average song duration with { printResult.Value} seconds!");
            Console.WriteLine("_____________________________");

            // - how many characters has the song that has the shortest Duration

            var    shortestSong     = Songs.Min(shortest => shortest.Duration);
            string songName         = "";
            var    shortestSongname = Songs.Where(shortest => shortest.Duration == shortestSong).Select(song => song.Name).ToList();

            shortestSongname.ForEach(name => songName = name);
            var shortestSongCharacters = Songs.Where(shortest => shortest.Duration == shortestSong).Select(song => song.Name.Length).ToList();

            shortestSongCharacters.ForEach(characters => Console.WriteLine($"The shortest song {songName} has {characters} characters!"));
            Console.WriteLine("_____________________________");

            // - print the name and the genre of the album that has most songs

            List <Album> allAlbums = new List <Album>();

            foreach (var album in Albums)
            {
                allAlbums.Add(album);
            }
            var albumWithMostSongs = allAlbums.OrderByDescending(count => count.Songs.Count()).Take(1);

            Console.WriteLine($"The album with the most songs is {albumWithMostSongs.First().Name}. Its genre is {albumWithMostSongs.First().Genre}");
            Console.WriteLine("_____________________________");

            // - print the name of the artist that has most songs

            List <int>    idsOfAllSongs             = Songs.Select(song => song.AlbumId).ToList();
            List <int>    idsOfAllAlbumsArtists     = new List <int>();
            List <string> nameOfArtistWithMostSongs = new List <string>();

            foreach (var album in Albums)
            {
                foreach (var id in idsOfAllSongs)
                {
                    if (id == album.Id)
                    {
                        idsOfAllAlbumsArtists.Add(album.ArtistId);
                    }
                }
            }
            var mostSongsByArtist = idsOfAllAlbumsArtists.GroupBy(i => i).OrderByDescending(group => group.Count()).Select(group => group.Key).First();

            foreach (var artist in Artists)
            {
                if (mostSongsByArtist == artist.Id)
                {
                    nameOfArtistWithMostSongs.Add(artist.FullName);
                }
            }
            nameOfArtistWithMostSongs.ForEach(name => Console.WriteLine($"The artist with most songs is {name}!"));
            Console.WriteLine("_____________________________");

            // - print the type of the artist(SoloArtist/Band) that has most albums published before year 2000

            List <int>    idsOfArtistWithAlbumsBefore2000 = Albums.Where(album => album.Year > 2000).Select(album => album.ArtistId).ToList();
            List <string> typeOfArtistWithAlbumsBefore200 = new List <string>();
            var           mostFrequentArtistId            = idsOfArtistWithAlbumsBefore2000.GroupBy(i => i).OrderByDescending(group => group.Count()).Select(group => group.Key).First();

            foreach (var artist in Artists)
            {
                if (mostFrequentArtistId == artist.Id)
                {
                    typeOfArtistWithAlbumsBefore200.Add(artist.ArtistType.ToString());
                }
            }
            typeOfArtistWithAlbumsBefore200.ForEach(type => Console.WriteLine($"The artist with most albums before 200 is a {type}!"));
            Console.WriteLine("_____________________________");

            // - print the average song duration, of the album that has most songs

            double averageSongDuration = 0;

            foreach (var song in albumWithMostSongs)
            {
                averageSongDuration = song.Songs.Average(track => track.Duration);
            }
            Console.WriteLine($"The average song duration of the album with most songs, {albumWithMostSongs.First().Name}, is {averageSongDuration} seconds!");
            Console.WriteLine("_____________________________");

            // Bonus:

            // - print the longest song duration of the album that has least songs

            List <Album> everyAlbum = new List <Album>();

            foreach (var album in Albums)
            {
                everyAlbum.Add(album);
            }
            var albumWithFewestSongs = everyAlbum.OrderBy(count => count.Songs.Count()).ToList().First();
            var longestSongs         = albumWithFewestSongs.Songs.OrderByDescending(song => song.Duration).ToList().First();

            Console.WriteLine($"The song with the longest duration is {longestSongs.Name} and it is {longestSongs.Duration} seconds long!");
            Console.WriteLine("_____________________________");

            // - print the name of the album that has most songs that contain letter 'a' in the name

            List <int>   idsOfSongsContainingA         = new List <int>();
            List <Album> albumWithMostSongsContainingA = new List <Album>();

            idsOfSongsContainingA = Songs.Where(song => song.Name.Contains('a')).Select(song => song.AlbumId).ToList();

            var mostFrequent = idsOfSongsContainingA.GroupBy(i => i).OrderByDescending(group => group.Count()).Select(group => group.Key).First();

            foreach (var album in Albums)
            {
                if (mostFrequent == album.Id)
                {
                    albumWithMostSongsContainingA.Add(album);
                }
            }
            Console.WriteLine($"The album with most songs containg 'a' is {albumWithMostSongsContainingA.First().Name}!");
            Console.WriteLine("_____________________________");

            // - print the name of the artist that has most songs that end with letter 'd'

            List <int>    idsOfAlbumsWhoseSongsEndWithD     = new List <int>();
            List <int>    idsofArtistsWhoseSongsEndWithD    = new List <int>();
            List <string> nameOfArtistWithMostSongsEndWithD = new List <string>();

            idsOfAlbumsWhoseSongsEndWithD = Songs.Where(song => song.Name.EndsWith('d')).Select(song => song.AlbumId).ToList();
            foreach (var album in Albums)
            {
                foreach (var id in idsOfAlbumsWhoseSongsEndWithD)
                {
                    if (id == album.Id)
                    {
                        idsofArtistsWhoseSongsEndWithD.Add(album.ArtistId);
                    }
                }
            }
            var mostFrequentArtistID = idsofArtistsWhoseSongsEndWithD.GroupBy(i => i).OrderByDescending(group => group.Count()).Select(group => group.Key).First();

            foreach (var artist in Artists)
            {
                if (mostFrequentArtistId == artist.Id)
                {
                    nameOfArtistWithMostSongsEndWithD.Add(artist.FullName);
                }
            }
            nameOfArtistWithMostSongsEndWithD.ForEach(name => Console.WriteLine($"The arist with most songs ending with 'd' is {name}!"));
            Console.WriteLine("_____________________________");



            // ************ Don't mind the structure, focus on the lists declared on the beginning of Program.cs ****************

            // 3, 2, 1.... GO! :)



            Console.ReadLine();
        }
Exemplo n.º 15
0
        private async Task LoadAlbumImages()
        {
            var images = album.Images ?? await Albums.GetImages(album.Id);

            AlbumImages = images.Select(i => new GalleryItem(i)).ToList();
        }
Exemplo n.º 16
0
        protected override void ShowPage()
        {
            pagetitle = "用户控制面板";

            if (userid == -1)
            {
                AddErrLine("你尚未登录");
                return;
            }
            user = Users.GetUserInfo(userid);

            if (config.Enablealbum != 1)
            {
                AddErrLine("相册功能已被关闭");
                return;
            }
            if (albumid < 1)
            {
                AddErrLine("指定的相册不存在");
                return;
            }
            AlbumInfo albuminfo = DTOProvider.GetAlbumInfo(albumid);

            if (this.userid != albuminfo.Userid)
            {
                AddErrLine("您无权限在该相册内添加照片");
                return;
            }

            enabletag     = config.Enabletag == 1;
            freephotosize = UserGroups.GetUserGroupInfo(usergroupid).Maxspacephotosize - Data.DbProvider.GetInstance().GetPhotoSizeByUserid(userid);
            albumname     = albuminfo.Title;

            if (DNTRequest.IsPost())
            {
                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                HttpFileCollection files = HttpContext.Current.Request.Files;
                int imgcount             = 0;

                for (int iFile = 0; iFile < files.Count; iFile++)
                {
                    HttpPostedFile postedFile = files[iFile];
                    if (postedFile == null || postedFile.FileName == "")
                    {
                        continue;
                    }
                    string fileName, fileExtension;
                    fileName      = Path.GetFileName(postedFile.FileName);
                    fileExtension = Path.GetExtension(fileName).ToLower();
                    if (fileExtension != ".jpg" && fileExtension != ".gif" && fileExtension != ".png" && fileExtension != ".jpeg")
                    {
                        continue;
                    }

                    //判断用户是否达到了照片最大上传数
                    int filesize = postedFile.ContentLength;
                    if (freephotosize < filesize)
                    {
                        AddErrLine("照片上传空间数已满,某些照片不能再上传!<br />如果想继续上传,请删除以前旧照片!");
                        return;
                    }
                    string    phototitle     = Utils.HtmlEncode(DNTRequest.GetFormString("phototitle" + (iFile + 1)));
                    PhotoInfo spacephotoinfo = new PhotoInfo();
                    spacephotoinfo.Title   = Utils.StrIsNullOrEmpty(phototitle) ? fileName.Remove(fileName.IndexOf("."), 1) : phototitle;
                    spacephotoinfo.Albumid = albumid;
                    spacephotoinfo.Userid  = userid;
                    string[] currentdate = DateTime.Now.ToString("yyyy-MM-dd").Split('-');
                    string   uploaddir   = "";

                    //当支持FTP上传远程照片
                    if (FTPs.GetAlbumAttachInfo.Allowupload == 1)
                    {
                        //当不保留本地附件模式时
                        if (FTPs.GetAlbumAttachInfo.Reservelocalattach == 0)
                        {
                            uploaddir = Utils.GetMapPath(BaseConfigs.GetForumPath + "space/upload/temp/");
                        }
                        else
                        {
                            uploaddir = Utils.GetMapPath(BaseConfigs.GetForumPath + "space/upload/" + currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/");
                        }

                        if (!Directory.Exists(uploaddir))
                        {
                            Utils.CreateDir(uploaddir);
                        }

                        string ftpfilename = Globals.UploadSpaceFile(postedFile, uploaddir, true);
                        spacephotoinfo.Filename = FTPs.GetAlbumAttachInfo.Remoteurl + "/" + currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/" + ftpfilename;

                        FTPs ftps = new FTPs();
                        ftps.UpLoadFile("/" + currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/",
                                        uploaddir + ftpfilename,
                                        FTPs.FTPUploadEnum.AlbumAttach);
                        ftps = new FTPs();
                        ftps.UpLoadFile("/" + currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/",
                                        uploaddir + Globals.GetThumbnailImage(ftpfilename),
                                        FTPs.FTPUploadEnum.AlbumAttach);
                        ftps = new FTPs();
                        ftps.UpLoadFile("/" + currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/",
                                        uploaddir + Globals.GetSquareImage(ftpfilename),
                                        FTPs.FTPUploadEnum.AlbumAttach);
                    }
                    else
                    {
                        uploaddir = Utils.GetMapPath(BaseConfigs.GetForumPath + "space/upload/" + currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/");
                        if (!Directory.Exists(uploaddir))
                        {
                            Utils.CreateDir(uploaddir);
                        }

                        spacephotoinfo.Filename = "space/upload/" + currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/" + Globals.UploadSpaceFile(postedFile, uploaddir, true);
                    }

                    spacephotoinfo.Attachment   = fileName;
                    spacephotoinfo.Description  = Utils.HtmlEncode(DNTRequest.GetFormString("description" + (iFile + 1)));
                    spacephotoinfo.Filesize     = filesize;
                    spacephotoinfo.Username     = username;
                    spacephotoinfo.IsAttachment = 0;
                    freephotosize -= filesize;
                    int      photoid   = Data.DbProvider.GetInstance().AddSpacePhoto(spacephotoinfo);
                    string   tags      = DNTRequest.GetHtmlEncodeString("phototag" + (iFile + 1)).Trim();
                    string[] tagsArray = null;
                    if (enabletag && tags != string.Empty)
                    {
                        tagsArray = Utils.SplitString(tags, " ", true, 10);
                        if (tagsArray.Length > 0)
                        {
                            Data.DbProvider.GetInstance().CreatePhotoTags(string.Join(" ", tagsArray), photoid, userid, Utils.GetDateTime());
                            AlbumTags.WritePhotoTagsCacheFile(photoid);
                        }
                    }
                    imgcount++;
                }
                if (imgcount != 0)
                {
                    AlbumInfo albumInfo = DTOProvider.GetAlbumInfo(albumid);
                    albumInfo.Imgcount = Data.DbProvider.GetInstance().GetSpacePhotoCountByAlbumId(albumid);
                    Data.DbProvider.GetInstance().SaveSpaceAlbum(albumInfo);
                }
                else
                {
                    AddErrLine("没有符合要求的图片,请上传jpg,jpeg,gif,png格式的图片");
                    return;
                }

                //生成json数据
                Albums.CreateAlbumJsonData(albumid);
                Albums.CreatePhotoImageByAlbum(albumid);

                SetUrl(string.Format("usercpspacemanagephoto.aspx?albumid={0}", albumid));
                SetMetaRefresh();
                SetShowBackLink(true);
                AddMsgLine("照片增加完毕");
            }
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            Init();// this method fills the arrays above with data

            /*
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░
             *  ░░███████░░░░░░░░░░███▒▒▒▒▒▒▒▒███░░░░░░
             *  ░░█▒▒▒▒▒▒█░░░░░░░███▒▒▒▒▒▒▒▒▒▒▒▒███░░░░
             *  ░░░█▒▒▒▒▒▒█░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░
             *  ░░░░█▒▒▒▒▒█░░░██▒▒▒▒▄██▄▒▒▒▒▄██▄▒▒▒███░
             *  ░░░░░█▒▒▒█░░░█▒▒▒▒▒▒████▒▒▒▒████▒▒▒▒▒██
             *  ░░░█████████████▒▒▒▒▀██▀▒▒▒▒▀██▀▒▒▒▒▒██
             *  ░░░█▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒██
             *  ░██▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒██▒▒▒▒▒▒▒▒▒██▒▒▒▒██
             *  ██▒▒▒███████████▒▒▒▒▒██▒▒▒▒▒▒▒██▒▒▒▒▒██
             *  █▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒███████▒▒▒▒▒▒▒██
             *  ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░
             *  ░█▒▒▒███████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░░
             *  ░██▒▒▒▒▒▒▒▒▒▒▒███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█░░░░░
             *  ░░████████████░░░████████████████░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░▄█████▄░▄███████▄░▄███████▄░██████▄░░
             *  ░░██▒▒▒▒█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░██▒▒▒▒▒░██▒▒▒▒▒██░██▒▒▒▒▒██░██▒▒▒██░░
             *  ░░██▒▒▒▀█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░▀█████▀░▀███████▀░▀███████▀░██████▀░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░▄█████░██▒▒▒▒██▀░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▀▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▒▒▒▒░█████▀░░░░░░░
             *  ░░░░██▒▒▒▒░██▄▒▄██░██▄▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░▀█████░▀█████▀░▀█████░██▒▒▒▒██▄░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             */

            //1 - how many Songs start with the letter 'a' (case insensitive)
            //var numberOfSongsLetterA = Songs.Where(x => x.Name[0] == 'a').ToList();

            int songs = Songs.Where(x => (x.Name.FirstOrDefault() == 'A') || (x.Name.FirstOrDefault() == 'a')).ToList().Count();

            //foreach (var item in songs)
            //{
            //    Console.WriteLine(item.Name);
            //}
            Console.WriteLine($"The namver of songs that name starts whit a is: {songs}");

            //2 - how many artists end with letter 'a' (case insensitive)

            var lastCharacter = Songs.Where(x => (x.Name.LastOrDefault() == 'A') || (x.Name.LastOrDefault() == 'a')).ToList().Count();

            Console.WriteLine($"The number of songs {lastCharacter}");
            //3 - whats the name of the song with longest duration
            var longestDuration = Songs.OrderByDescending(x => x.Duration).Select(x => x.Name).First();

            Console.WriteLine(longestDuration);

            //4 - whats the total Duration of all Songs

            var totalDuration = Songs.Aggregate(0, (acc, x) => acc + x.Duration);

            Console.WriteLine(totalDuration);
            //5 - how many albums have Songs longer than 300 seconds


            var SongsLongerThen300 = Songs.Where(x => x.Duration > 300).ToList().Count();

            Console.WriteLine(SongsLongerThen300);


            //6 - print the names of the artists(separated with "--"), that have more than one album of PopRock genre

            var atristWhitMoreAlbums = Artists.Where(x => x.Albums.Where(y => y.Genre.ToString() == "PopRock").Count() > 0).ToList();

            foreach (var item in atristWhitMoreAlbums)
            {
                Console.Write($"{item.FullName} --");
            }
            Console.WriteLine();
            //7 - print the name of the album that has highest Average duration of a song

            var highestAverigeDuration = Albums.OrderByDescending(x => x.Songs.Aggregate(0, (acc, y) => acc + y.Duration)).First();

            Console.WriteLine(highestAverigeDuration.Name);

            //8 - how many characters has the song that has the shortest Duration
            //9 - print the name and the genre of the album that has most songs
            //10 - print the name of the artist that has most songs
            //11 - print the type of the artist(SoloArtist/Band) that has most albums published before year 2000
            //12 - print the average song duration, of the album that has most songs

            // Bonus:
            //13 - print the longest song duration of the album that has least songs
            //14 - print the name of the album that has most songs that contain letter 'a' in the name
            //15 - print the name of the artist that has most songs that end with letter 'd'
        }
Exemplo n.º 18
0
 public void CreateAlbums(Albums albums)
 {
     new AlbumsDAO().CreateAlbums(albums);
 }
Exemplo n.º 19
0
    //public Storage(string[] Albumname)
    //{
    //    settingStore = new JsonStore<Settings>(dbPath: HttpRuntime.AppDomainAppPath);
    //    albumStore = new JsonStore<Albums>(dbPath: HttpRuntime.AppDomainAppPath);
    //    AlbumList.AddRange(Albumname);
    //}
    void Refresh()
    {
        var store = new BiggyList<Albums>(albumStore);
        List<Albums> albumContent = new List<Albums>();
        var drive = new GoogleDrive();

        if (AlbumList.Count > 0)
        {
            for (int i = 0; i < AlbumList.Count; i++)
            {
                string AlbumId = drive.GetFolderID(AlbumList[i]);
                var contents = drive.ListFolderContent(AlbumId);
                foreach (var image in contents)
                {
                    Albums album = new Albums();
                    album.Id = image.Id;
                    album.Title = image.Title;
                    album.AlbumName = AlbumList[i];
                    album.ThumbnailLink = image.ThumbnailLink;
                    album.DownloadURL = image.DownloadUrl;

                    albumContent.Add(album);
                }
            }
            store.Add(albumContent);
        }
    }
Exemplo n.º 20
0
        private Albums ReceiveHtml()
        {

            ConfigBSO configBSO = new ConfigBSO();
            Config config = configBSO.GetAllConfig(Language.language);
            commonBSO commonBSO = new commonBSO();


            int thumb_w = Convert.ToInt32(config.New_icon_w);
            int thumb_h = Convert.ToInt32(config.New_icon_h);
            string path_thumb = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/Albums/AlbumsImg/ImgThumb/";


            int large_w = Convert.ToInt32(config.New_large_w);
            int large_h = Convert.ToInt32(config.New_large_h);
            string path_large = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/Albums/AlbumsImg/ImgLarge/";

            string image_thumb = commonBSO.UploadImage(file_image_thumb, path_thumb, thumb_w, thumb_h);
            string image_large = commonBSO.UploadImage(file_image_large, path_large, large_w, large_h);


            Albums album = new Albums();
            //album.AlbumID = (hddAlbumID.Value != "") ? Convert.ToInt32(hddAlbumID.Value) : 0;
            //album.CateNewsID = (ddlCateNews.SelectedValue != "") ? Convert.ToInt32(ddlCateNews.SelectedValue) : 0;
            //album.ImageThumb = (image_thumb != "") ? image_thumb : hddImageThumb.Value;
            //album.ImageLarge = (image_large != "") ? image_large : hddImageLarge.Value;
            //album.IsHome = Convert.ToBoolean(rdbIsHome.SelectedValue);
            //album.Order = (hddOrder.Value != "") ? Convert.ToInt32(hddOrder.Value) : 0;

            album.AlbumsID = (hddAlbumID.Value != "") ? Convert.ToInt32(hddAlbumID.Value) : 0;
            album.AlbumsCateID = Convert.ToInt32(ddlAlbumsCate.SelectedValue);
            album.Title = txtTitle.Text;
            album.Description = txtRadShort.Html;
            album.ImageThumb = (image_thumb != "") ? image_thumb : hddImageThumb.Value;
            album.ImageLarge = (image_large != "") ? image_large : hddImageLarge.Value;
            album.Author = txtAuthor.Text;
            album.PostDate = txtRadDate.SelectedDate.Value;

            album.Status = Convert.ToBoolean(rdbStatus.SelectedItem.Value);
            album.Ishot = Convert.ToBoolean(rdbIshot.SelectedValue);
            album.Ishome = Convert.ToBoolean(rdbIshome.SelectedValue);

            album.Isview = (hddIsView.Value != "") ? Convert.ToInt32(hddIsView.Value) : 0;
            album.CommentTotal = (hddCommentTotal.Value != "") ? Convert.ToInt32(hddCommentTotal.Value) : 0;

            album.CreatedUserName = (hddCreateUserName.Value != "") ? hddCreateUserName.Value : Session["Admin_UserName"].ToString();
            album.ApprovalUserName = (hddApprovalUserName.Value != "") ? hddApprovalUserName.Value : Session["Admin_UserName"].ToString();

            album.IsComment = true;
            album.IsApproval = true;
            album.ApprovalDate = (hddApprovalDate.Value != "") ? Convert.ToDateTime(hddApprovalDate.Value) : DateTime.Now;



            return album;
        }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            Init();// this method fills the arrays above with data


            // QUERIES!

            // - 1) how many Songs start with the letter 'a' (case insensitive)
            // - 2) how many artists end with letter 'a' (case insensitive)
            // - 3) whats the name of the song with longest duration
            // - 4) whats the total Duration of all Songs
            // - 5) how many albums have Songs longer than 300 seconds
            // - 6) print the names of the artists(separated with "--"), that have more than one album of PopRock genre
            // - 7) print the name of the album that has highest Average duration of a song
            // - 8) how many characters has the song that has the shortest Duration
            // - 9) print the name and the genre of the album that has most songs
            // - 10) print the name of the artist that has most songs
            // - 11) print the type of the artist(SoloArtist/Band) that has most albums published before year 2000
            // - 12) print the average song duration, of the album that has most songs

            // Bonus:
            // - print the longest song duration of the album that has least songs
            // - print the name of the album that has most songs that contain letter 'a' in the name
            // - print the name of the artist that has most songs that end with letter 'd'



            // ************ Don't mind the structure, focus on the lists declared on the beginning of Program.cs ****************

            // 3, 2, 1.... GO! :)
            #region 1)
            IEnumerable <Song> SongsThatStartWithLowercaseA = from song in Songs
                                                              where song.Name.ToLower().StartsWith('a')
                                                              select song;
            int NumberOfSongsThatStartWithLowercaseA = SongsThatStartWithLowercaseA.Count();
            Console.WriteLine($"1)  The number of songs that start with the letter 'a' is {NumberOfSongsThatStartWithLowercaseA}.");
            #endregion
            #region 2)
            IEnumerable <Artist> ArtistWithNameEndingInA = from artist in Artists
                                                           where artist.FullName.ToLower().EndsWith('a')
                                                           select artist;
            int NumberOfArtistsWithNameEndingInA = ArtistWithNameEndingInA.Count();
            Console.WriteLine($"2)  The number of artists whose name ends with the letter 'a' is {NumberOfArtistsWithNameEndingInA}.");
            #endregion
            #region 3)
            Song LongestDurationSong = Songs.Aggregate((song1, song2) => song1.Duration > song2.Duration ? song1 : song2);
            Console.WriteLine($"3)  The song with the longest duration is {LongestDurationSong.Name}.");
            #endregion
            #region 4)
            var TotalDurationOfAllSongs = Songs.Select(song => song.Duration)
                                          .Aggregate((dur1, dur2) => dur1 + dur2);
            Console.WriteLine($"4)  The total duration of all songs is {TotalDurationOfAllSongs} seconds.");
            #endregion
            #region 5)
            IEnumerable <Album> AlbumsWithSongsLongerThan5min = from album in Albums
                                                                where album.Songs.Where(song => song.Duration > 300).ToList().Any()
                                                                select album;
            int NumOfAlbumsWithSongsLongerThan5min = AlbumsWithSongsLongerThan5min.Count();
            Console.WriteLine($"5)  There are {NumOfAlbumsWithSongsLongerThan5min} albums that contain at least a single song that lasts longer than 5 minutes.");
            #endregion
            #region 6)
            IEnumerable <Artist> ArtistsWithAtLeast2PopRockAlbums = from artist in Artists
                                                                    where artist.Albums.Where(alb => alb.Genre == Genre.PopRock).Count() > 1
                                                                    select artist;
            Artist LastArtistWithAtLeast2PopRockAlbums = ArtistsWithAtLeast2PopRockAlbums.Last();
            Console.Write("6)  Artists with 2 or more PopRock Albums: ");
            foreach (Artist artist in ArtistsWithAtLeast2PopRockAlbums)
            {
                if (artist.Equals(LastArtistWithAtLeast2PopRockAlbums))
                {
                    Console.Write($"{artist.FullName}.");
                    Console.WriteLine("");
                }
                else
                {
                    Console.Write($"{artist.FullName}--");
                }
            }

            #endregion
            #region 7)
            var HighestAverageDurationAlbum = Albums.Aggregate((alb1, alb2) =>
                                                               alb1.Songs.Select(song => song.Duration)
                                                               .Aggregate(0, (dur1, dur2) => dur1 + dur2, sum => sum / alb1.Songs.Count()) >
                                                               alb2.Songs.Select(song => song.Duration)
                                                               .Aggregate(0, (dur1, dur2) => dur1 + dur2, sum => sum / alb2.Songs.Count())
                                                                ? alb1 : alb2);
            Console.WriteLine($"7)  The album with the highest average duration of a song is {HighestAverageDurationAlbum.Name}.");


            #endregion
            #region 8)
            Song ShortestDurationSong           = Songs.Aggregate((song1, song2) => song1.Duration < song2.Duration ? song1 : song2);
            int  ShortestDurationSongNameLength = ShortestDurationSong.Name.Length;
            Console.WriteLine($"8)  The song with the shortest duration has {ShortestDurationSongNameLength} characters in its name.");
            #endregion
            #region 9)
            Album AlbumWithMostSongs = Albums.Aggregate((alb1, alb2) => alb1.Songs.Count() > alb2.Songs.Count() ? alb1 : alb2);
            Console.WriteLine($"9)  The album with most songs is the {AlbumWithMostSongs.Genre} album: {AlbumWithMostSongs.Name}");
            #endregion
            #region 10)
            Artist ArtistWithMostSongs = Artists.Aggregate((art1, art2) => art1.Albums.SelectMany(alb => alb.Songs).Count() > art2.Albums.SelectMany(alb => alb.Songs).Count() ? art1 : art2);
            Console.WriteLine($"10) The artist with the most songs is {ArtistWithMostSongs.FullName}.");
            #endregion
            #region 11)
            Artist TypeOfArtistWithMostAlbumsBeforeYear2000 = Artists.Aggregate((art1, art2) =>
                                                                                art1.Albums.Where(alb => alb.Year < 2000).Count() > art2.Albums.Where(alb => alb.Year < 2000).Count()
                                                              ? art1 : art2);
            Console.WriteLine($"11) The artist with the most albums released before the year 2000 is of type {TypeOfArtistWithMostAlbumsBeforeYear2000.ArtistType}.");
            #endregion
            #region 12)
            int AvgSongDurationOfAlbumWithMostSongs = AlbumWithMostSongs.Songs
                                                      .Select(song => song.Duration)
                                                      .Aggregate(0, (dur1, dur2) => (dur1 + dur2), dursum => dursum / AlbumWithMostSongs.Songs.Count());
            Console.WriteLine($"12) The average length of a song in the album with the most songs lasts {AvgSongDurationOfAlbumWithMostSongs} seconds.");
            #endregion
            Console.WriteLine("\n --------------------------------BONUS--------------------------------\n ");
            #region Bonus 1)
            Album AlbumWithLeastSongs = Albums.Aggregate((alb1, alb2) => alb1.Songs
                                                         .Select(song => song.Duration).Aggregate((dur1, dur2) => dur1 + dur2) <
                                                         alb2.Songs
                                                         .Select(song => song.Duration).Aggregate((dur1, dur2) => dur1 + dur2)
                                                                       ? alb1 : alb2);
            Song LongestSongFromAlbumWithLeastSongs = AlbumWithLeastSongs.Songs.Aggregate((song1, song2) =>
                                                                                          song1.Duration > song2.Duration
                                                                          ? song1 : song2);
            Console.WriteLine($"1)  The longest song in the album with least songs lasts {LongestSongFromAlbumWithLeastSongs.Duration} seconds.");
            #endregion
            #region Bonus 2)
            Album AlbumWithMostAs = Albums.Aggregate((alb1, alb2) =>
                                                     alb1.Songs.Select(song => song.Name.ToLower().Contains('a')).Count() >
                                                     alb2.Songs.Select(song => song.Name.ToLower().Contains('a')).Count()
                                            ? alb1 : alb2);
            Console.WriteLine($"2)  The album which has the most songs that contain the letter 'a' in its name is {AlbumWithMostAs.Name}.");
            #endregion
            #region Bonus 3)
            Artist ArtistWithMostSongsThatEndInD = Artists.Aggregate((art1, art2) =>
                                                                     art1.Albums.SelectMany(alb => alb.Songs)
                                                                     .Select(song => song.Name)
                                                                     .Where(name => name.ToLower().EndsWith('d')).Count() >
                                                                     art2.Albums.SelectMany(alb => alb.Songs)
                                                                     .Select(song => song.Name)
                                                                     .Where(name => name.ToLower().EndsWith('d')).Count()
                                                           ? art1 : art2);
            Console.WriteLine($"3)  The artist that has the most songs that end in 'd' is {ArtistWithMostSongsThatEndInD.FullName}.");
            #endregion


            Console.ReadKey();
        }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            Init();// this method fills the arrays above with data

            // - print the mass of the earth on July 1895 XD

            /*
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░
             *  ░░███████░░░░░░░░░░███▒▒▒▒▒▒▒▒███░░░░░░
             *  ░░█▒▒▒▒▒▒█░░░░░░░███▒▒▒▒▒▒▒▒▒▒▒▒███░░░░
             *  ░░░█▒▒▒▒▒▒█░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░
             *  ░░░░█▒▒▒▒▒█░░░██▒▒▒▒▄██▄▒▒▒▒▄██▄▒▒▒███░
             *  ░░░░░█▒▒▒█░░░█▒▒▒▒▒▒████▒▒▒▒████▒▒▒▒▒██
             *  ░░░█████████████▒▒▒▒▀██▀▒▒▒▒▀██▀▒▒▒▒▒██
             *  ░░░█▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒██
             *  ░██▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒██▒▒▒▒▒▒▒▒▒██▒▒▒▒██
             *  ██▒▒▒███████████▒▒▒▒▒██▒▒▒▒▒▒▒██▒▒▒▒▒██
             *  █▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒███████▒▒▒▒▒▒▒██
             *  ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░
             *  ░█▒▒▒███████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░░
             *  ░██▒▒▒▒▒▒▒▒▒▒▒███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█░░░░░
             *  ░░████████████░░░████████████████░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░▄█████▄░▄███████▄░▄███████▄░██████▄░░
             *  ░░██▒▒▒▒█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░██▒▒▒▒▒░██▒▒▒▒▒██░██▒▒▒▒▒██░██▒▒▒██░░
             *  ░░██▒▒▒▀█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░▀█████▀░▀███████▀░▀███████▀░██████▀░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░▄█████░██▒▒▒▒██▀░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▀▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▒▒▒▒░█████▀░░░░░░░
             *  ░░░░██▒▒▒▒░██▄▒▄██░██▄▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░▀█████░▀█████▀░▀█████░██▒▒▒▒██▄░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             */

            // QUERIES!

            // - how many Songs start with the letter 'a' (case insensitive)
            // - how many artists end with letter 'a' (case insensitive)
            // - whats the name of the song with longest duration
            // - whats the total Duration of all Songs
            // - how many albums have Songs longer than 300 seconds
            // - print the names of the artists(separated with "--"), that have more than one album of PopRock genre
            // - print the name of the album that has highest Average duration of a song
            // - how many characters has the song that has the shortest Duration
            // - print the name and the genre of the album that has most songs
            // - print the name of the artist that has most songs
            // - print the type of the artist(SoloArtist/Band) that has most albums published before year 2000
            // - print the average song duration, of the album that has most songs

            // Bonus:
            // - print the longest song duration of the album that has least songs
            // - print the name of the album that has most songs that contain letter 'a' in the name
            // - print the name of the artist that has most songs that end with letter 'd'



            // ************ Don't mind the structure, focus on the lists declared on the beginning of Program.cs ****************

            // 3, 2, 1.... GO! :)



            Console.ForegroundColor = ConsoleColor.Green;


            // 1. How many Songs start with the letter 'a' (case insensitive)

            int songsWithA = Songs.Where(song => song.Name.ToLower().StartsWith('a')).Count();

            Console.WriteLine($"{songsWithA} Songs start with the letter 'a'");



            Console.WriteLine(new string('-', 60));



            // 2. How many artists end with letter 'a'(case insensitive)
            List <Artist> artistsEndWithA = Artists.Where(artist => artist.FullName.EndsWith('a')).ToList();

            artistsEndWithA.ForEach(artist => Console.WriteLine($"{artist.FullName.Length} artists end with letter 'a'. "));



            Console.WriteLine(new string('-', 60));



            // 3. Whats the name of the song with longest duration
            double longestDurationOf = Songs.Max(x => x.Duration);

            var longestDurationSong = Songs
                                      .Where(song => song.Duration == longestDurationOf)
                                      .Select(x => new { x.Name, x.Duration })
                                      .FirstOrDefault();

            Console.WriteLine($"The name of song with longest duration is: {longestDurationSong.Name} - {longestDurationSong.Duration} duration");



            Console.WriteLine(new string('-', 60));



            // 4. Whats the total Duration of all Songs
            double totalDurationOf = Songs.Sum(x => x.Duration);

            Console.WriteLine($"Total duration of All songs is - {totalDurationOf}");



            Console.WriteLine(new string('-', 60));



            // 5. How many albums have Songs longer than 300 seconds
            var songsLongerThan = Albums.Where(x => x.Songs.Max(x => x.Duration > 300)).Select(x => x.Name).Count();

            Console.WriteLine($"{songsLongerThan} albums have Songs longer than 300 seconds.");



            Console.WriteLine(new string('-', 60));



            // 6. Print the names of the artists(separated with "--"), that have more than one album of PopRock genre
            List <Artist> popRockArtists = Artists.Where(x => x.Albums.Max(x => x.Genre.Equals(Genre.PopRock))).ToList();

            Console.WriteLine("Pop Rock Artists Name: \n");
            popRockArtists.ForEach(x => Console.Write($"-- {x.FullName} \n"));



            Console.WriteLine(new string('-', 60));



            //7. Print the name of the album that has highest Average duration of a song
            var printAlbum = Albums.OrderByDescending(x => x.Songs.Average(x => x.Duration)).First();

            Console.WriteLine($"The name of the album that has highest Average duration of a song is {printAlbum.Name}.");



            Console.WriteLine(new string('-', 60));



            // 8. How many characters has the song that has the shortest Duration
            double shortSong = Songs.Min(x => x.Duration);

            var shortestDuration = Songs
                                   .Where(song => song.Duration == shortSong)
                                   .Select(x => x.Name)
                                   .SingleOrDefault();

            Console.WriteLine($"The Song with shortest duration have {shortestDuration.Length} characters");



            Console.WriteLine(new string('-', 60));



            // 9. Print the name and the genre of the album that has most songs
            double mostSongs = Albums.Max(x => x.Songs.Count);

            var mostSongsAlbum = Albums.Where(album => album.Songs.Count == mostSongs)
                                 .Select(x => new { x.Name, x.Genre })
                                 .SingleOrDefault();

            Console.WriteLine($"Name and the genre of the album that has most songs is {mostSongsAlbum.Name} - {mostSongsAlbum.Genre} Genre");



            Console.WriteLine(new string('-', 60));



            //10. Print the name of the artist that has most songs
            var songs = Albums.Max(x => x.Songs.Count);

            var mostSongsArtist = Artists.Where(x => x.Albums.Max(x => x.Songs.Count == songs))
                                  .Select(x => x.FullName)
                                  .SingleOrDefault();


            Console.WriteLine($"The name of the artist that has most songs is {mostSongsArtist}");



            Console.WriteLine(new string('-', 60));



            // 11. Print the type of the artist(SoloArtist/Band) that has most albums published before year 2000
            var albumYear = Albums.Where(x => x.Year < 2000)
                            .Select(x => x.Year)
                            .ToList();

            var printArtist = Artists.Where(x => x.Albums.Max(x => x.Name)
                                            .Equals(albumYear))
                              .Select(x => x.ArtistType)
                              .SingleOrDefault();


            Console.WriteLine($"Type of the artist that has most albums published before year 2000 is ({printArtist})");



            Console.WriteLine(new string('-', 60));



            // 12. Print the average song duration, of the album that has most songs
            double averageSongDuration = Albums.Max(x => x.Songs.Average(x => x.Duration));

            Console.WriteLine($"Average song duration of the album that has most songs is - {averageSongDuration}");


            //var averageSongDuration = Albums.OrderByDescending(a => a.Songs.Count)
            //                          .Select(a => a.Songs.Average(s => s.Duration))
            //                          .FirstOrDefault();
            //Console.WriteLine(averageSongDuration);



            Console.WriteLine(new string('-', 60));



            // Bonus:

            //1. Print the longest song duration of the album that has least songs
            double leastSongsAlbum = Albums.Min(x => x.Songs.Count());


            var longestSongDuration = Albums.Where(x => x.Songs.Count == leastSongsAlbum).Select(x => x.Songs).Take(1).ToList();

            longestSongDuration.ForEach(x => Console.WriteLine($"Longest song duration of two albums with the {x.Count} songs that has least song is - {x.Max(x => x.Duration)} duration, but I taked the first album."));



            Console.WriteLine(new string('-', 60));



            //2. Print the name of the album that has most songs that contain letter 'a' in the name
            var mostSongsWithA = Albums.OrderByDescending(x => x.Songs.Sum(x => x.Name.Take('a').Count()))
                                 .Select(x => x.Name)
                                 .FirstOrDefault();

            Console.WriteLine($"The name of the album that has most songs that contain letter 'a' in the name is {mostSongsWithA}");



            Console.WriteLine(new string('-', 60));



            //3. - Print the name of the artist that has most songs that end with letter 'd'
            var mostSongsWithD = Artists.OrderByDescending(x => x.Albums.Count(x => x.Songs.Max(x => x.Name.EndsWith('d'))))
                                 .Select(x => x.FullName)
                                 .FirstOrDefault();

            Console.WriteLine($"The name of the artist that has most songs that end with letter 'd' is {mostSongsWithD}");



            Console.ReadLine();
        }
Exemplo n.º 23
0
        private void Upd_ByID(HttpContext context)
        {
            string jSonString = string.Empty;

            try {
                AlbumsBO albumsBO = new AlbumsBO();
                int      id       = Convert.ToInt32(context.Request.Form["txtID"]);
                Albums   albums   = albumsBO.Sel_ByID(id);

                albums.ID = albums.ID;

                albums.Title = !String.IsNullOrEmpty(context.Request.Form["txtTitle_Lang"])
                    ? Convert.ToString(context.Request.Form["txtTitle_Lang"])
                    : albums.Title;

                albums.Info = !String.IsNullOrEmpty(context.Request.Form["txtInfo_Lang"])
                    ? Convert.ToString(HttpUtility.HtmlDecode(context.Request.Form["txtInfo_Lang"]))
                    : albums.Info;

                albums.Intro = !String.IsNullOrEmpty(context.Request.Form["txtIntro_Lang"])
                    ? Convert.ToString(context.Request.Form["txtIntro_Lang"])
                    : albums.Intro;

                albums.Status = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"])
                    ? Convert.ToInt32(context.Request.Form["cbbStatus"])
                    : albums.Status;

                albums.Disable = !String.IsNullOrEmpty(context.Request.Form["cbbDisable"])
                    ? Convert.ToBoolean(context.Request.Form["txt_Disable"])
                    : albums.Disable;

                albums.CreateDate = !String.IsNullOrEmpty(context.Request.Form["dtpPublishDate"])
                    ? DateTime.ParseExact(context.Request.Form["dtpPublishDate"], "dd/MM/yyyy", _culture)
                    : albums.CreateDate;

                albums.CreateByIDUser = currentSystemUsers.ID;

                albums.Image = !String.IsNullOrEmpty(context.Request.Form["txtImage_1"])
                    ? Convert.ToString(context.Request.Form["txtImage_1"])
                    : albums.Image;

                albums.Image1 = !String.IsNullOrEmpty(context.Request.Form["txtImage_2"])
                    ? Convert.ToString(context.Request.Form["txtImage_2"])
                    : albums.Image1;
                albums.Image2 = !String.IsNullOrEmpty(context.Request.Form["txtImage_3"])
                    ? Convert.ToString(context.Request.Form["txtImage_3"])
                    : albums.Image2;
                albums.Image3 = !String.IsNullOrEmpty(context.Request.Form["txtImage_4"])
                    ? Convert.ToString(context.Request.Form["txtImage_4"])
                    : albums.Image3;

                albums.Type = !String.IsNullOrEmpty(context.Request.Form["cbbType"])
                    ? Convert.ToInt32(context.Request.Form["cbbType"])
                    : albums.Type;

                albums.IDLang = !String.IsNullOrEmpty(context.Request.Form["IDLang_"])
                    ? Convert.ToInt32(context.Request.Form["IDLang_"])
                    : albums.IDLang;
                albums.ViewCount = !String.IsNullOrEmpty(context.Request.Form["txtViewCount"])
                    ? Convert.ToInt64(context.Request.Form["txtViewCount"])
                    : albums.ViewCount;
                albums.DownloadCount = !String.IsNullOrEmpty(context.Request.Form["txtDownloadCount"])
                    ? Convert.ToInt64(context.Request.Form["txtDownloadCount"])
                    : albums.DownloadCount;

                var ret = albumsBO.Upd_Albums(albums);
                if (ret == 0)
                {
                    jSonString = "{\"status\":\"error|" + ret + "\"}";
                }
                else if (ret != 0)
                {
                    jSonString = "{\"status\": \"success\"}";
                }
            }
            catch (Exception ex) {
                jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message + "\"}";
            }
            finally {
                context.Response.Write(jSonString);
            }
        }
Exemplo n.º 24
0
        public ActionResult Add(CreateAlbumViewModel album, HttpPostedFileBase CoverImage)
        {
            album.Producers = new SelectList(db.Producers.ToList(), "Id", "Name");
            album.Artists   = new SelectList(db.Artists.ToList(), "Id", "Name");
            if (ModelState.IsValid)
            {
                List <int> artistIds = album.ArtistIds != null?album.ArtistIds.ToList() : new List <int>();

                List <int> producerIds = album.ProducerIds != null?album.ProducerIds.ToList() : new List <int>();

                if (String.IsNullOrEmpty(album.ArtistList[0].Name) && artistIds.Count() == 0)
                {
                    ModelState.AddModelError("", "No Artist Selected");
                    return(View(album));
                }

                if (String.IsNullOrEmpty(album.ProducerList[0].Name) && producerIds.Count() == 0)
                {
                    ModelState.AddModelError("", "No Producers Selected");
                    return(View(album));
                }

                foreach (var item in album.ArtistList)
                {
                    if (!String.IsNullOrEmpty(item.Name))
                    {
                        Artist artist = new Artist
                        {
                            BirthDate   = item.BirthDate,
                            Email       = item.Email,
                            Gender      = item.Gender,
                            Name        = item.Name,
                            PhoneNumber = item.PhoneNumber
                        };
                        if (!db.Artists.Any(m => m.Email == item.Email && m.Name == item.Name))
                        {
                            db.Artists.Add(artist);
                            db.SaveChanges();
                            artistIds.Add(artist.Id);
                        }
                        else
                        {
                            artist = db.Artists.FirstOrDefault(m => m.Email == item.Email && m.Name == item.Name);
                            artistIds.Add(artist.Id);
                        }
                    }
                }



                foreach (var item in album.ProducerList)
                {
                    if (!string.IsNullOrEmpty(item.Name))
                    {
                        Producer producer = new Producer
                        {
                            DateOfBirth = item.DateOfBirth,
                            Name        = item.Name,
                            Studio      = item.Studio
                        };
                        if (!db.Producers.Any(m => m.DateOfBirth == item.DateOfBirth && m.Name == item.Name && m.Studio == item.Studio))
                        {
                            db.Producers.Add(producer);
                            db.SaveChanges();
                            producerIds.Add(producer.Id);
                        }
                        else
                        {
                            producer = db.Producers.FirstOrDefault(m => m.DateOfBirth == item.DateOfBirth && m.Name == item.Name && m.Studio == item.Studio);
                            producerIds.Add(producer.Id);
                        }
                    }
                }


                if (producerIds.Count() == 0 || artistIds.Count() == 0)
                {
                    ModelState.AddModelError("", "No Artist or Producers");
                    return(View(album));
                }

                Albums albums = new Albums
                {
                    Producers      = db.Producers.Where(m => producerIds.Contains(m.Id)).ToList(),
                    Artists        = db.Artists.Where(m => artistIds.Contains(m.Id)).ToList(),
                    Length         = album.Length,
                    Name           = album.Name,
                    ReleaseDate    = album.ReleaseDate,
                    StudioName     = album.StudioName,
                    IsAgeBar       = album.IsAgeBar,
                    FinePerDay     = album.FinePerDay,
                    CopyNumber     = album.CopyNumber,
                    CoverImagePath = "~/Images/Albums/"
                };

                Albums prevAlbum = db.Albums.Include(m => m.Artists).Include(m => m.Producers)
                                   .FirstOrDefault(m => m.Name == albums.Name);

                bool Status = db.Albums.Include(m => m.Artists).Include(m => m.Producers)
                              .Any(m => m.Name == albums.Name);

                if (Status)
                {
                    if (albums.Producers.Intersect(prevAlbum.Producers) == null && albums.Artists.Intersect(prevAlbum.Artists) == null)
                    {
                        db.Albums.Add(albums);
                        db.SaveChanges();

                        if (!Directory.Exists(Server.MapPath("~/Images/Albums")))
                        {
                            Directory.CreateDirectory(Server.MapPath("~/Images/Albums"));
                        }

                        if (CoverImage.ContentLength > 0)
                        {
                            CoverImage.SaveAs(Server.MapPath("~/Images/Albums/" + albums.id + ".jpg"));
                        }
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Album Already Exists");
                        return(View(album));
                    }
                }
                else
                {
                    db.Albums.Add(albums);
                    db.SaveChanges();

                    if (!Directory.Exists(Server.MapPath("~/Images/Albums")))
                    {
                        Directory.CreateDirectory(Server.MapPath("~/Images/Albums"));
                    }

                    if (CoverImage.ContentLength > 0)
                    {
                        CoverImage.SaveAs(Server.MapPath("~/Images/Albums/" + albums.id + ".jpg"));
                    }
                    return(RedirectToAction("Index"));
                }
            }
            return(View(album));
        }
Exemplo n.º 25
0
        public void Load(string startingDirectory)
        {
            Albums.Clear();
            Songs.Clear();

            List <string> musicFiles = Directory.EnumerateFiles(startingDirectory, "*.mp3", SearchOption.AllDirectories).ToList();

            System.Console.WriteLine(String.Format("Loading {0} files", musicFiles.Count()));

            //Parallel.ForEach<string>(musicFiles, musicFile =>
            foreach (string musicFile in musicFiles)
            {
                TagLib.File fileInfo = null;
                try
                {
                    if (!System.IO.File.Exists(musicFile))
                    {
                        System.Console.WriteLine("File: " + musicFile + " does not exist");
                    }

                    fileInfo = TagLib.File.Create(musicFile);
                }
                catch (Exception exn) {
                    //System.Console.WriteLine("QWE:" + exn.Message.ToString());
                }

                if (fileInfo != null)
                {
                    Album album = new Album();
                    Song  track = new Song();

                    track.FileLocation = fileInfo.Name;
                    track.Name         = fileInfo.Tag.Title;
                    track.TrackNumber  = (int)fileInfo.Tag.Track;

                    string albumName    = fileInfo.Name;
                    string albumArtists = "";

                    if (fileInfo.Tag.Album != null)
                    {
                        albumName = fileInfo.Tag.Album;
                    }
                    if (fileInfo.Tag.AlbumArtists != null)
                    {
                        albumArtists = String.Join(",", fileInfo.Tag.AlbumArtists);
                    }

                    if (
                        (album = this.Albums.SingleOrDefault(
                             x => x.Title.ToLower().Equals(albumName.ToLower()) &&
                             x.Artist.ToLower().Equals(albumArtists.ToLower()))
                        ) == null)
                    {
                        album        = new Album();
                        album.Artist = albumArtists;
                        album.Title  = albumName;

                        //lock (albumLock)
                        //{
                        this.Albums.Add(album);
                        //}
                    }

                    track.Album = album;

                    //lock (album)
                    //{
                    if (album.Songs == null)
                    {
                        album.Songs = new ObservableCollection <Song>();
                    }

                    album.Songs.Add(track);
                    //}

                    //lock (songLock)
                    //{
                    this.Songs.Add(track);
                    //}
                }
                else
                {
                    //System.Console.WriteLine("Could not load metadata for file: " + musicFile);
                }
            }//);

            if (this.LibraryUpdated != null)
            {
                this.LibraryUpdated(this, new EventArgs());
            }
        }
Exemplo n.º 26
0
        private async Task LoadSelectedArtist()
        {
            if (SelectedArtist == null)
            {
                return;
            }

            OnTaskStarted("artists");

            try
            {
                if (Albums.IsNullOrEmpty())
                {
                    await LoadAlbums();
                }

                var albums = await ServiceLocator.LocalMusicService.GetArtistAlbums(SelectedArtist.Id);

                if (!albums.IsNullOrEmpty())
                {
                    foreach (var album in albums)
                    {
                        var tracks = await ServiceLocator.LocalMusicService.GetAlbumTracks(album.Id);

                        if (!tracks.IsNullOrEmpty())
                        {
                            album.Tracks = tracks.Cast <Audio>().ToList();
                        }
                    }
                }
                else
                {
                    albums = new List <AudioAlbum>();
                }

                if (SelectedArtist == null)
                {
                    return;
                }

                var unsortedTracks = await ServiceLocator.LocalMusicService.GetArtistUnsortedTracks(SelectedArtist.Id);

                if (!unsortedTracks.IsNullOrEmpty())
                {
                    var unsortedAlbum = new AudioAlbum()
                    {
                        Tracks = unsortedTracks.OfType <Audio>().ToList()
                    };
                    albums.Insert(0, unsortedAlbum);
                }

                SelectedArtistAlbums = albums;
                SelectedArtistTracks = albums.SelectMany(a => a.Tracks).Cast <LocalAudio>().ToList();
            }
            catch (Exception ex)
            {
                OnTaskError("artists", ErrorResources.LoadArtistsErrorCommon);

                LoggingService.Log(ex);
            }

            OnTaskFinished("artists");
        }
Exemplo n.º 27
0
        public void Task_Get_With_Relation_Return_NotNull()
        {
            var factory = new ConnectionFactory();
            var context = factory.CreateContextForSQLite();

            for (int i = 1; i < 4; i++)
            {
                var singers = new Singers()
                {
                    SingerId     = i,
                    SingerName   = "Category " + i,
                    SingerReview = "good one",
                    IsActive     = true,
                    CreatedDate  = DateTime.Now,
                    ModifiedDate = DateTime.Now,
                    CreatedBy    = 1,
                    ModifiedBy   = 1
                };
                context.Singers.Add(singers);
            }

            for (int i = 1; i < 4; i++)
            {
                var album = new Albums()
                {
                    AlbumId          = i,
                    AlbumName        = "Category " + i,
                    AlbumImagPath    = "../Test/Image.png",
                    AlbumPrice       = 1,
                    AlbumReleaseDate = DateTime.Now,
                    IsActive         = true,
                    CreatedDate      = DateTime.Now,
                    ModifiedDate     = DateTime.Now,
                    CreatedBy        = 1,
                    ModifiedBy       = 1
                };
                context.Albums.Add(album);
            }

            for (int i = 1; i < 4; i++)
            {
                var songs = new Songs()
                {
                    SongId         = i,
                    SingerId       = 2,
                    AlbumId        = 2,
                    SongDuration   = TimeSpan.Parse("00:04:00"),
                    SongName       = "Test Song" + i.ToString(),
                    SongPrice      = 3,
                    SongPopularity = 3,
                    IsActive       = true,
                    CreatedDate    = DateTime.Now,
                    ModifiedDate   = DateTime.Now,
                    CreatedBy      = 1,
                    ModifiedBy     = 1
                };
                context.Songs.Add(songs);
            }
            context.SaveChanges();

            var songRepo    = new SongsRepository(context);
            var songService = new SongService(songRepo);
            var result      = songService.GetSongList(2, 10, 0, string.Empty);

            Assert.NotNull(result);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     allAlbums = Albums.getAllAlbums();
 }
Exemplo n.º 29
0
 public async Task <int> Delete(Albums entityToDelete)
 {
     return(await _baseRepository.Delete(entityToDelete));
 }
Exemplo n.º 30
0
        public async Task ScanMusicFolder(string path)
        {
            var files = Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories);

            var albumDictionary = new Dictionary <int, Album>();

            using (var dbLock = await LockDatabaseAsync())
            {
                var db = Database;
                var artistsCollection = db.GetCollection <Artist>(Artist.CollectionName);
                var albumsCollection  = db.GetCollection <Album>(Album.CollectionName);
                var tracksCollection  = db.GetCollection <Track>(Track.CollectionName);

                foreach (var file in files.Select(x => new FileInfo(x).FullName))
                {
                    if (!SupportedFileExtensions.Any(x => $".{x}" == Path.GetExtension(file).ToLower()))
                    {
                        continue;
                    }

                    try
                    {
                        using (var tagFile = File.Create(file))
                        {
                            var tag = tagFile.Tag;

                            if (tag is null)
                            {
                                continue;
                            }

                            var artistName = tag.AlbumArtists.Concat(tag.Artists).FirstOrDefault();

                            if (artistName is null)
                            {
                                artistName = "Unknown Artist";
                            }

                            var albumName = tag.Album ?? "Unknown Album";

                            var trackName = tag.Title ?? "Unknown Track";

                            var trackNumber = tag.Track;

                            // TODO other what to do if we dont know anything about the track, ignore?

                            StatusChanged?.Invoke(this, $"Processing: {artistName}, {albumName}, {trackName}");

                            var existingArtist = artistsCollection.FindOne(x => x.Name == artistName.Trim());

                            if (existingArtist is null)
                            {
                                existingArtist = new Artist
                                {
                                    Name = artistName
                                };

                                artistsCollection.Insert(existingArtist);
                            }

                            var existingAlbum = albumsCollection.FindOne(x =>
                                                                         x.ArtistId == existingArtist.ArtistId && x.Title == tag.Album.Trim());

                            var albumAdded = false;

                            if (existingAlbum is null)
                            {
                                albumAdded = true;

                                existingAlbum = new Album
                                {
                                    Title    = albumName,
                                    ArtistId = existingArtist.ArtistId,
                                    Artist   = existingArtist
                                };

                                albumsCollection.Insert(existingAlbum);

                                existingArtist.Albums.Add(existingAlbum);

                                artistsCollection.Update(existingArtist);

                                albumDictionary.Add(existingAlbum.AlbumId, existingAlbum);

                                Albums.Add(existingAlbum);
                            }
                            else
                            {
                                if (albumDictionary.ContainsKey(existingAlbum.AlbumId))
                                {
                                    existingAlbum = albumDictionary[existingAlbum.AlbumId];
                                }
                                else
                                {
                                    albumDictionary[existingAlbum.AlbumId] = existingAlbum;
                                }
                            }

                            var existingTrack = tracksCollection.FindOne(x => x.Path == file);

                            if (existingTrack is null)
                            {
                                existingTrack = new Track
                                {
                                    Path        = new FileInfo(file).FullName,
                                    Title       = trackName,
                                    Album       = existingAlbum,
                                    TrackNumber = trackNumber
                                };

                                tracksCollection.Insert(existingTrack);

                                existingAlbum.Tracks.Add(existingTrack);

                                albumsCollection.Update(existingAlbum);
                            }
                            else
                            {
                                existingTrack.Album = existingAlbum;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
        }
Exemplo n.º 31
0
 public async Task <Albums> Insert(Albums entity)
 {
     return(await _baseRepository.Insert(entity));
 }
Exemplo n.º 32
0
        private void buildLocalMusicAlbumArtistModels()
        {
            foreach (var song in Service.Library.Musics)
            {
                var music = new LocalMusicModel
                {
                    Music = song,
                    Image = Service.Library.Thumbnails.Where(t => t.Id == song.ThumbnailId).FirstOrDefault().Image
                };
                Musics.Add(music);


                var privilegedArtist = "";
                if (song.AlbumArtist != UNKNOWN_ARTIST)
                {
                    privilegedArtist = song.AlbumArtist;
                }
                else if (song.Artist != UNKNOWN_ARTIST)
                {
                    privilegedArtist = song.Artist;
                }
                else
                {
                    privilegedArtist = UNKNOWN_ARTIST;
                }

                var album = Albums.Where(a => a.Title == song.AlbumTitle && a.AlbumArtist == privilegedArtist).FirstOrDefault();
                if (album == null)
                {
                    album = new LocalAlbumModel
                    {
                        Title       = song.AlbumTitle,
                        AlbumArtist = privilegedArtist,
                        Image       = Service.Library.Thumbnails.Where(t => t.Id == music.Music.ThumbnailId).FirstOrDefault().Image,
                        Year        = song.Year
                    };
                    album.Musics.Add(music);
                    Albums.Add(album);
                }
                else
                {
                    album.Musics.Add(music);
                }



                var artist = Artists.Where(a => a.Name == privilegedArtist).FirstOrDefault();
                if (artist == null)
                {
                    artist = new LocalArtistModel
                    {
                        Name = privilegedArtist
                    };
                    artist.Albums.Add(album);
                    artist.Musics.Add(music);
                    Artists.Add(artist);
                }
                else
                {
                    if (!artist.Albums.Contains(album))
                    {
                        artist.Albums.Add(album);
                        artist.Musics.Add(music);
                    }
                    else
                    {
                        artist.Musics.Add(music);
                    }
                }
            }
        }
Exemplo n.º 33
0
 public async Task <Albums> Update(Albums entityToUpdate)
 {
     return(await _baseRepository.Update(entityToUpdate));
 }
Exemplo n.º 34
0
        /// <summary>
        /// Gets the albums callback.
        /// </summary>
        /// <param name="requestState">State of the request.</param>
        private void GetAlbumsCallback(XRequestState requestState)
        {
            var albums = new Albums();//new List<Album>();

            JObject query = JObject.Parse(requestState.ResponseData);
            var result = (JObject)query["result"];

            albums.LoadFromJsonObject(result);

            if (requestState.UserCallback != null)
                requestState.UserCallback(albums);
        }
Exemplo n.º 35
0
        static void Main(string[] args)
        {
            Init();// this method fills the arrays above with data


            // - print the mass of the earth on July 1895 XD

            /*
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░
             *  ░░███████░░░░░░░░░░███▒▒▒▒▒▒▒▒███░░░░░░
             *  ░░█▒▒▒▒▒▒█░░░░░░░███▒▒▒▒▒▒▒▒▒▒▒▒███░░░░
             *  ░░░█▒▒▒▒▒▒█░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░
             *  ░░░░█▒▒▒▒▒█░░░██▒▒▒▒▄██▄▒▒▒▒▄██▄▒▒▒███░
             *  ░░░░░█▒▒▒█░░░█▒▒▒▒▒▒████▒▒▒▒████▒▒▒▒▒██
             *  ░░░█████████████▒▒▒▒▀██▀▒▒▒▒▀██▀▒▒▒▒▒██
             *  ░░░█▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒██
             *  ░██▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒██▒▒▒▒▒▒▒▒▒██▒▒▒▒██
             *  ██▒▒▒███████████▒▒▒▒▒██▒▒▒▒▒▒▒██▒▒▒▒▒██
             *  █▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒███████▒▒▒▒▒▒▒██
             *  ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░
             *  ░█▒▒▒███████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░░
             *  ░██▒▒▒▒▒▒▒▒▒▒▒███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█░░░░░
             *  ░░████████████░░░████████████████░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░▄█████▄░▄███████▄░▄███████▄░██████▄░░
             *  ░░██▒▒▒▒█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░██▒▒▒▒▒░██▒▒▒▒▒██░██▒▒▒▒▒██░██▒▒▒██░░
             *  ░░██▒▒▒▀█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░▀█████▀░▀███████▀░▀███████▀░██████▀░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░▄█████░██▒▒▒▒██▀░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▀▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▒▒▒▒░█████▀░░░░░░░
             *  ░░░░██▒▒▒▒░██▄▒▄██░██▄▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░▀█████░▀█████▀░▀█████░██▒▒▒▒██▄░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             */

            // QUERIES!
            foreach (Artist artist in Artists)
            {
                foreach (Album album in artist.Albums)
                {
                    Console.WriteLine($"{artist.FullName}, {artist.Albums.Count} {album.Name}");
                }
            }
            Console.WriteLine("---------------------------------");
            Albums.ForEach(album => Console.WriteLine($"{album.Name}, {album.Genre}, {album.Year}, {album.Songs.Count}"));
            Console.WriteLine("---------------------------------");
            foreach (Album album in Albums)
            {
                foreach (Song song in album.Songs)
                {
                    Console.WriteLine($"{album.Name}, {song.Name}, {song.Duration}");
                }
            }
            Console.WriteLine("---------------------------------");


            // - how many Songs start with the letter 'a' (case insensitive)

            var songsStartWithA = from song in Songs
                                  where song.Name.StartsWith('a') || song.Name.StartsWith('A')
                                  select song;

            Console.WriteLine($"{songsStartWithA.ToList().Count} songs start(s) with A");
            Console.WriteLine("---------------------------------");


            // - how many artists end with letter 'a' (case insensitive)

            var artistEndWithA = from artist in Artists
                                 where artist.FullName.EndsWith('a') || artist.FullName.EndsWith('A')
                                 select artist;

            Console.WriteLine($"{artistEndWithA.ToList().Count} artist end(s) with A");
            //artistEndWithA.ToList().ForEach(artist => Console.WriteLine(artist.FullName));
            Console.WriteLine("---------------------------------");


            // - whats the name of the song with longest duration

            var longestSong = from song in Songs
                              orderby song.Duration
                              select song.Name;

            Console.WriteLine($"The name of the longet song is {longestSong.LastOrDefault()}");
            Console.WriteLine("---------------------------------");


            // - whats the total Duration of all Songs

            var totalDuration = from song in Songs
                                select song.Duration;

            Console.WriteLine($"The total duration of all songs is {totalDuration.ToList().Sum()} seconds");
            Console.WriteLine("---------------------------------");


            // - how many albums have Songs longer than 300 seconds

            var albumsWithSongOver300 = from album in Albums
                                        from song in album.Songs
                                        where song.Duration > 300
                                        select album;

            Console.WriteLine($"{albumsWithSongOver300.Distinct().ToList().Count} album have(has) song(s) longer than 300 seconds");
            //albumsWithSongOver300.ToList().ForEach(album => Console.WriteLine(album.Name));
            Console.WriteLine("---------------------------------");


            // - print the names of the artists(separated with "--"), that have more than one album of PopRock genre

            var artistsWithPoprockAlbum = from artist in Artists
                                          from album in artist.Albums
                                          where album.Genre == Genre.PopRock
                                          select artist;

            var moreThenOne = from artist in artistsWithPoprockAlbum.Distinct().ToList()
                              where artist.Albums.Count > 1
                              select artist.FullName;

            Console.WriteLine("These artists have more than one album of PopRock genre:");
            moreThenOne.ToList().ForEach(Console.WriteLine);
            Console.WriteLine("---------------------------------");


            // - print the name of the album that has highest Average duration of a song

            var albumSongsHigherAverage = from album in Albums
                                          orderby album.Songs.ToList().Average(song => song.Duration)
                                          select album.Name;

            Console.WriteLine($"The name of the album that has highest Average duration of a song is {albumSongsHigherAverage.LastOrDefault()}");
            Console.WriteLine("---------------------------------");


            // - how many characters has the song that has the shortest Duration

            var shortestSongChars = from song in Songs
                                    orderby song.Duration
                                    select song;

            Console.WriteLine($"The shortest song has {shortestSongChars.ToList().FirstOrDefault().Name.Length} characters");
            Console.WriteLine("---------------------------------");


            // - print the name and the genre of the album that has most songs

            var albumWithMostSongs = from album in Albums
                                     orderby album.Songs.Count
                                     select album;

            Console.WriteLine($"The album that has most songs is {albumWithMostSongs.LastOrDefault().Name}," +
                              $" genre: {albumWithMostSongs.LastOrDefault().Genre}");
            Console.WriteLine("---------------------------------");


            // - print the name of the artist that has most songs

            var artistWithMostSongs = from artist in Artists
                                      from album in artist.Albums
                                      orderby artist.Albums.ToList().Sum(album => album.Songs.Count)
                                      select artist.FullName;

            Console.WriteLine($"{artistWithMostSongs.LastOrDefault()} has most songs");
            Console.WriteLine("---------------------------------");


            // - print the type of the artist(SoloArtist/Band) that has most albums published before year 2000

            var artistWithMostalbumsBefore2000 = from artist in Artists
                                                 from album in artist.Albums
                                                 where album.Year < 2000
                                                 orderby artist.Albums.Count
                                                 select artist;

            Console.WriteLine(artistWithMostalbumsBefore2000.ToList().LastOrDefault().ArtistType);
            Console.WriteLine("---------------------------------");


            // - print the average song duration, of the album that has most songs

            var albumFilterMost = from album in Albums
                                  orderby album.Songs.Count
                                  select album;
            var averageSongDuration = from song in albumFilterMost.LastOrDefault().Songs
                                      select song.Duration;

            Console.WriteLine($"The average song duration of album that has most songs is {averageSongDuration.Average()} seconds");
            Console.WriteLine("---------------------------------");


            // Bonus:
            // - print the longest song duration of the album that has least songs

            var albumFilterLess = from album in Albums
                                  orderby album.Songs.Count
                                  select album;

            int least          = albumFilterLess.ToList().FirstOrDefault().Songs.Count;
            var filteredAlbums = from album in albumFilterLess
                                 where album.Songs.Count == least
                                 select album;

            var longestSongDur = from album in filteredAlbums
                                 from song in album.Songs
                                 orderby song.Duration
                                 select song.Duration;

            Console.WriteLine($"The longest song duration in the album that has least songs is {longestSongDur.LastOrDefault()} seconds");
            Console.WriteLine("---------------------------------");


            // - print the name of the album that has most songs that contain letter 'a' in the name

            var mostSongsThatContainA = from album in Albums
                                        from song in album.Songs
                                        where song.Name.Contains('a')
                                        group album by album.Name;

            var albumName = from name in mostSongsThatContainA
                            orderby name.Count()
                            select name;

            Console.WriteLine($"The name of the album that has most songs that contain letter 'a' in the name is" +
                              $" {albumName.ToList().LastOrDefault().Key}");
            //albumName.ToList().ForEach(album => Console.WriteLine(album.Key));
            Console.WriteLine("---------------------------------");


            // - print the name of the artist that has most songs that end with letter 'd'

            var mostSongsThatEndWithD = from artist in Artists
                                        from album in artist.Albums
                                        from song in album.Songs
                                        where song.Name.EndsWith('d')
                                        group artist by artist.FullName;

            var artistName = from name in mostSongsThatEndWithD
                             orderby name.Count()
                             select name;

            Console.WriteLine($"The name of the artist that has most songs that end with letter 'd' is " +
                              $"{artistName.ToList().LastOrDefault().Key}");
            //artistName.ToList().ForEach(artist => Console.WriteLine(artist.Key));


            // ************ Don't mind the structure, focus on the lists declared on the beginning of Program.cs ****************

            // 3, 2, 1.... GO! :)



            Console.ReadLine();
        }
Exemplo n.º 36
0
 public void AddToAlbums(Album album)
 {
     Albums.Add(album);
 }
Exemplo n.º 37
0
        protected override void ShowPage()
        {
            pagetitle = "编辑图片信息";

            #region 验证
            if (userid == -1)
            {
                AddErrLine("请先登录");
                return;
            }
            user = Users.GetUserInfo(userid);
            if (config.Enablealbum != 1)
            {
                AddErrLine("相册功能已被关闭");
                return;
            }
            if (photoid < 1)
            {
                AddErrLine("不存在的图片Id");
                return;
            }
            photo = DTOProvider.GetPhotoInfo(photoid, 0, 0);
            if (photo == null)
            {
                AddErrLine("图片不存在");
                return;
            }
            if (photo.Userid != userid)
            {
                AddErrLine("您没有编辑此图片的权限");
                return;
            }
            #endregion

            if (!DNTRequest.IsPost())
            {
                photo.Filename = Globals.GetThumbnailImage(photo.Filename);
                commentstatus  = (int)photo.Commentstatus;
                tagstatus      = (int)photo.Tagstatus;
                tags           = AlbumTags.GetTagsByPhotoId(photoid);
            }
            else
            {
                photo.Title       = DNTRequest.GetString("title");
                photo.Description = DNTRequest.GetString("description");

                if (commentstatus < 0 || commentstatus > 2)
                {
                    commentstatus = 2;
                }

                photo.Commentstatus = (PhotoStatus)commentstatus;

                string   newtags   = DNTRequest.GetString("phototag").Trim();
                string[] tagsArray = null;
                if (config.Enabletag == 1 && newtags != string.Empty && newtags != tags)
                {
                    tagsArray = Utils.SplitString(newtags, " ", true, 10);
                    if (tagsArray.Length > 0 && string.Join(" ", tagsArray) != tags)
                    {
                        DbProvider.GetInstance().DeletePhotoTags(photoid);
                        DbProvider.GetInstance().CreatePhotoTags(string.Join(" ", tagsArray), photoid, userid, Utils.GetDateTime());
                        AlbumTags.WritePhotoTagsCacheFile(photoid);
                    }
                }

                DTOProvider.UpdatePhotoInfo(photo);

                //生成json数据
                Albums.CreateAlbumJsonData(photo.Albumid);
                //生成图片标题
                Albums.CreatePhotoTitleImage(photo.Photoid, photo.Title);
                //生成用户名图片
                Albums.CreateUserImage(photo.Userid, photo.Username);

                AddMsgLine("图片信息修改成功, 将返回图片列表");
                SetUrl("usercpspacemanagephoto.aspx?albumid=" + photo.Albumid);
                SetMetaRefresh();
            }
        }
Exemplo n.º 38
0
 public string GetKey()
 {
     return($"{Id}:{Albums.FirstOrDefault().Id}");
 }
Exemplo n.º 39
0
        public ActionResult AlbumUpdate(int uid)
        {
            var u = _repository._UserRepositories.GetUserByUID(new Users {
                UID = uid
            });

            if (u != null)
            {
                if (u.UserName != HttpContext.User.Identity.Name)
                {
                    return(null);
                }
                else
                {
                    try
                    {
                        int                albumid     = Convert.ToInt32(Request["albumid"]);
                        string             albumname   = Request["albumname"];
                        string             description = Request["description"];
                        HttpPostedFileBase file        = Request.Files["imgfile"];
                        if (file != null)
                        {
                            if (file.InputStream == null || file.InputStream.Length > 1024000)
                            {
                                return(Json(new { Result = "ERROR", Message = "上传单张图片最大为1M" }));
                            }
                            else
                            {
                                string FileType = file.FileName.Substring(file.FileName.LastIndexOf(".") + 1);
                                if (FileType == "gif" || FileType == "GIF" || FileType == "jpg" || FileType == "JPG" || FileType == "png" || FileType == "PNG")
                                {
                                    string savePath    = string.Format("/Content/Upload/{0}/{1}/", HttpContext.User.Identity.Name, albumid);
                                    string saveUrl     = "http://" + Request.Url.Authority + savePath;
                                    string dirPath     = Server.MapPath(savePath);
                                    string fileName    = file.FileName;
                                    string fileExt     = Path.GetExtension(fileName).ToLower();
                                    string newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + fileExt;
                                    string filePath    = dirPath + newFileName;
                                    file.SaveAs(filePath);
                                    string fileUrl   = saveUrl + newFileName;
                                    Albums album     = _repository._AlbumRepositories.GetAlbum(albumid);
                                    string coverpath = album.CoverPath;
                                    album.CoverPath   = fileUrl;
                                    album.AlbumName   = albumname;
                                    album.Description = description;
                                    AlbumValidation  albumValidation  = new AlbumValidation();
                                    ValidationResult validationResult = albumValidation.Validate(album);
                                    string           Msg = "";
                                    if (!validationResult.IsValid)
                                    {
                                        foreach (var failure in validationResult.Errors)
                                        {
                                            Msg += "Property " + failure.PropertyName + " failed validation. Error was: " + failure.ErrorMessage;
                                        }
                                        return(Json(new { Result = "Error", Message = Msg }));
                                    }
                                    Common.DirFile.DeleteFile(savePath + coverpath.Substring(coverpath.LastIndexOf('/') + 1));
                                    _repository._AlbumRepositories.UpdateAlbum(album);
                                    return(Json(new { Result = "OK", Message = new { AlbumID = album.AlbumID, CoverPath = album.CoverPath, AlbumName = album.AlbumName, Description = album.Description } }));
                                }
                                else
                                {
                                    return(Json(new { Result = "ERROR", Message = "上传图片格式错误" }));
                                }
                            }
                        }
                        else
                        {
                            Albums album = _repository._AlbumRepositories.GetAlbum(albumid);
                            album.AlbumName   = albumname;
                            album.Description = description;
                            AlbumValidation  albumValidation  = new AlbumValidation();
                            ValidationResult validationResult = albumValidation.Validate(album);
                            string           Msg = "";
                            if (!validationResult.IsValid)
                            {
                                foreach (var failure in validationResult.Errors)
                                {
                                    Msg += "Property " + failure.PropertyName + " failed validation. Error was: " + failure.ErrorMessage;
                                }
                                return(Json(new { Result = "Error", Message = Msg }));
                            }
                            _repository._AlbumRepositories.UpdateAlbum(album);
                            return(Json(new { Result = "OK", Message = new { AlbumID = album.AlbumID, CoverPath = album.CoverPath, AlbumName = album.AlbumName, Description = album.Description } }));
                        }
                    }
                    catch (Exception ex)
                    {
                        return(Json(new { Result = "Error", Message = ex.Message }));
                    }
                }
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 40
0
 /// <summary>
 /// Create a new Albums object.
 /// </summary>
 /// <param name="albumId">Initial value of albumId.</param>
 public static Albums CreateAlbums(int albumId)
 {
     Albums albums = new Albums();
     albums.albumId = albumId;
     return albums;
 }
Exemplo n.º 41
0
        private void updateAlbumsButton_Click(object sender, RoutedEventArgs e)
        {
            var curAlbum = albums.GetSelectedAlbum();
            KeyValuePair<string, string>[] selectedTracks = null;
            selectedTracks = albums.GetSelectedTracksForAlbum();
            bool isAlbumPlaying = curAlbum != null ? albums.GetSelectedAlbum().playlist == playlist : false;
            listAlbumBox.Items.Clear();
            tracksCountAlbumLabel.Content = "0 треків";

            albums = new Albums();

            albums.DownloadAlbums(new string[] { sett.UserId, sett.VKToken });

            FillAlbums(albums);

            if (curAlbum != null)
            {
                var index = Array.IndexOf(albums.GetAlbumsIds(), curAlbum.Id, 0);
                albumsCombobox.SelectedIndex = index;
                albumsCombobox_SelectionChanged(null, null);
                curAlbum = albums.GetSelectedAlbum();
                tracksCountAlbumLabel.Content = curAlbum.playlist.Count() + " треків";
            }
            else
                if (albums.Count() > 0)
                {
                    albumsCombobox.SelectedIndex = 0;
                    albumsCombobox_SelectionChanged(null, null);
                    curAlbum = albums.GetSelectedAlbum();
                    tracksCountAlbumLabel.Content = albums.GetSelectedAlbum().playlist.Count() + " треків";
                }
            if (selectedTracks != null)
                albums.SetSelectedTracksForAlbum(selectedTracks);


            if (curAlbum != null)
                FillListBox(albums.GetSelectedAlbum().playlist, listAlbumBox, false, true, false);
            else
                listAlbumBox.Items.Clear();

            if (curAlbum != null)
                listAlbumBox.SelectedIndex = albums.GetSelectedAlbum().playlist.SelTrack;

            if (isAlbumPlaying)
                playlist = albums.GetSelectedAlbum().playlist;
        }
Exemplo n.º 42
0
        protected void btn_add_Click(object sender, EventArgs e)
        {

            try
            {
                if (String.IsNullOrEmpty(file_image_thumb.FileName))
                {
                    BindAlbumsCate(Convert.ToInt32(hddAlbumsCateID.Value));
                    ViewAlbum(Convert.ToInt32(hddAlbumsCateID.Value));
                    clientview.Text = "Chưa có hình ảnh";

                }
                else
                {
                    Albums album = new Albums();
                    album = ReceiveHtml();


                    AlbumsBSO albumBSO = new AlbumsBSO();
                    albumBSO.CreateAlbums(album);

                    BindAlbumsCate(Convert.ToInt32(hddAlbumsCateID.Value));
                    ViewAlbum(Convert.ToInt32(hddAlbumsCateID.Value));
                    clientview.Text = String.Format(Resources.StringAdmin.AddNewsSuccessful);


                }


            }
            catch (Exception ex)
            {
                clientview.Text = ex.Message.ToString();
            }

        }
Exemplo n.º 43
0
        private async void logInButton_Click(object sender, RoutedEventArgs e)
        {
            GetAuth();
            if (sett.VKToken != "")
            {
                //albums
                albums = new Albums();
                await Task.Factory.StartNew(() => albums.DownloadAlbums(new string[] { sett.UserId, sett.VKToken }));
                FillAlbums(albums);

                //my tracks
                playlist = new PlayListVk();
                playlistAll = playlist;
                await Task.Factory.StartNew(() => playlist.DownloadTracks(new string[] { sett.UserId, sett.VKToken }));

                tracksCountLabel.Content = playlist.Count() + " треків";
                FillListBox((PlayListVk)playlist, listBox, false, true, true);


                //users
                loadFriendList();

                //search
                search = new Search(sett.VKToken);
                //recommeds
                recommendations = new Reccomendations(sett.VKToken);
                UpdateRecommendations();
            }
        }
Exemplo n.º 44
0
 public List<Album> Get(Albums request)
 {
     return Db.Select<Album>();
 }
Exemplo n.º 45
0
 private void FillAlbums(Albums albums)
 {
     albumsCombobox.Items.Clear();
     foreach (var alb in albums.GetAlbums())
     {
         albumsCombobox.Items.Add(alb);
     }
 }
Exemplo n.º 46
0
 private void textFilter_TextChanged(object sender, TextChangedEventArgs e)
 {
     Albums.Refresh();
 }
Exemplo n.º 47
0
    void preprocess(IosBuildConfig config)
    {
        oldLanguage = PropertiesSingleton.instance.language;
        PropertiesSingleton.instance.language = config.language;

        oldStampList = PropertiesSingleton.instance.guiStampList;
        PropertiesSingleton.instance.guiStampList = config.stampList;

        oldAlbums  = PropertiesSingleton.instance.albums;
        PropertiesSingleton.instance.albums = config.albums;

        oldBundleId = PlayerSettings.bundleIdentifier;
        PlayerSettings.bundleIdentifier = config.bundleId;
        tempDir = Directory.GetParent( Application.dataPath)+"/temp"+EditorApplication.timeSinceStartup.GetHashCode();
        Directory.CreateDirectory(tempDir);

        movedDirResources = new List<MovedResource>();
        movedFileResources = new List<MovedResource>();

        List<string> pictureNames = new List<string>();
        foreach(Album album in config.albums.album){
            if (album.sheetList!=null)
                foreach(SheetObject sheet in album.sheetList.sheetList)
                    pictureNames.Add(sheet.persistentBorderLayerPath);
        }
        foreach(string resourceDir in Directory.GetDirectories(Application.dataPath+"/"+ PICTURE_RESOURCE_DIR,"Resources", SearchOption.AllDirectories)){
            string[] filePaths = Directory.GetFiles(resourceDir,"*.border.*");
            if (filePaths.Length > 0){
                string borderName = Path.GetFileNameWithoutExtension(filePaths[0]);
                if (!pictureNames.Contains(borderName)){
                    movedDirResources.Add(new MovedResource( resourceDir        , tempDir + "/" + resourceDir.GetHashCode()));
                    movedFileResources.Add(new MovedResource( resourceDir+".meta", tempDir + "/" + resourceDir.GetHashCode()+"meta"));
                }
            }
        }

        List<string> stamps = new List<string>();
        foreach (GUIStamp stamp in config.stampList.stampList)
            stamps.Add(stamp.stampPath);

        foreach(string filePath in Directory.GetFiles(Application.dataPath + "/" + STAMP_RESOURCE_DIR, "*.icon")){
            if (filePath.EndsWith("meta"))
                continue;
            string fileName =Path.GetFileNameWithoutExtension(filePath);
            fileName = fileName.Replace(".icon","");
            if (!stamps.Contains(fileName)){
                movedFileResources.Add(new MovedResource(filePath        , tempDir + "/" + filePath.GetHashCode()+  ".icon"));
                movedFileResources.Add(new MovedResource(filePath+".meta", tempDir + "/" + filePath.GetHashCode()+  ".icon.meta"));
            }
        }

        foreach(string filePath in Directory.GetFiles(Application.dataPath + "/" + STAMP_RESOURCE_DIR+"/Resources")){
            if (filePath.EndsWith("meta"))
                continue;
            string fileName =Path.GetFileNameWithoutExtension(filePath);
            if (!stamps.Contains(fileName)){
                movedFileResources.Add(new MovedResource(filePath        , tempDir + "/" + filePath.GetHashCode()));
                movedFileResources.Add(new MovedResource(filePath+".meta", tempDir + "/" + filePath.GetHashCode()+".meta"));
            }
        }

        foreach(MovedResource mr in movedDirResources){
            Directory.Move(mr.from, mr.to);
        }

        foreach(MovedResource mr in movedFileResources)
            File.Move(mr.from, mr.to);

        AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);

        PropertiesSingleton.instance.language = config.language;
    }