Ejemplo n.º 1
0
        public async Task GetAverageLyricCount_DoesNotCall_LyricApiService_NoSongs()
        {
            // Arrange
            var artist = new ArtistData
            {
                Name = "Hadouken",
                Id   = "8c9200b8-8e05-41d5-836e-44a37905560e"
            };

            _musicBrainzService.Setup(mb => mb.GetArtistData(It.IsAny <string>()))
            .Returns(artist);
            _musicBrainzService.Setup(mb => mb.GetArtistReleases(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new List <string>
            {
                "Every Weekend",
                "For The Masses"
            });
            _musicBrainzService.Setup(mb => mb.GetSongsByReleases(It.IsAny <string>(), It.IsAny <List <string> >()))
            .Returns(new List <string>());

            // Act
            var result = await _lyricApiLogic.GetAverageLyricCount("Hadouken");

            // Assert
            Assert.AreEqual(artist.Name, result.ArtistName);
            _lyricService.Verify(ls => ls.GetSongLyrics(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }
Ejemplo n.º 2
0
        public void Get()
        {
            IArtistData _artist = new ArtistData();
            ArtistBiz   person  = new ArtistBiz(_artist);

            Assert.AreEqual(true, person.Get(2).succeed);
        }
Ejemplo n.º 3
0
        public void GivenAnArtist_WhenComparedToAnArtistWithDifferentNameButSameCountry_ThenTheyAreNotEqual()
        {
            ArtistData ad1 = new ArtistData("artistName1", "country");
            ArtistData ad2 = new ArtistData("artistName2", "country");

            Assert.IsFalse(ad1.Equals(ad2));
        }
Ejemplo n.º 4
0
        public void GetAll()
        {
            IArtistData _artist = new ArtistData();
            ArtistBiz   person  = new ArtistBiz(_artist);

            Assert.AreEqual(5, person.GetAll().list.Count());
        }
Ejemplo n.º 5
0
        public void GivenAnArtist_WhenComparedToAnIdenticalArtist_ThenTheyAreEqual()
        {
            ArtistData ad1 = new ArtistData("artistName", "country");
            ArtistData ad2 = new ArtistData("artistName", "country");

            Assert.IsTrue(ad1.Equals(ad2));
        }
Ejemplo n.º 6
0
 static DataRepository()
 {
     Album   = new AlbumData();
     Artist  = new ArtistData();
     Track   = new TrackData();
     Invoice = new InvoiceData();
 }
        /// <summary>
        /// Tries to find an artist by their name and locale.
        /// </summary>
        /// <param name="artistName">The artist's name.</param>
        /// <param name="locale">The locale of the artist which is used to narrow the search.</param>
        /// <returns>ArtistData or null</returns>
        public async override Task <ArtistData> TryFindArtistAsync(string artistName, string locale = "JP")
        {
            ArtistData data = new ArtistData();

            var artistQuery = new Hqub.MusicBrainz.API.QueryParameters <Hqub.MusicBrainz.API.Entities.Artist>();

            //artistQuery.Add("inc", "url-rels");

            artistQuery.Add("artist", artistName);

            artistQuery.Add("alias", artistName);

            artistQuery.Add("country", locale);

            var artistResults = await Artist.SearchAsync(artistQuery);

            var artist = artistResults?.Items.FirstOrDefault();

            if (artist != null)
            {
                data.Name = artist.Name;

                data.Gender = artist.Gender;

                data.ArtistID = artist.Id;

                data.ArtistLinkUrl = "https://musicbrainz.org/artist/" + artist.Id;

                var browsingData = await Artist.GetAsync(artist.Id, "url-rels", "aliases");

                if (browsingData != null)
                {
                    if (browsingData.RelationLists != null)
                    {
                        var imageRel = browsingData.RelationLists.Items.FirstOrDefault(x => x.Type == "image");

                        if (imageRel != null)
                        {
                            if (!string.IsNullOrWhiteSpace(imageRel.Target))
                            {
                                var url = await ResolveImageUrlAsync(new Uri(imageRel.Target));

                                if (url != null)
                                {
                                    if (await CheckIfUrlIsWebAccessibleAsync(new Uri(url)))
                                    {
                                        data.ArtistImage = url;
                                    }
                                }
                            }
                        }
                    }
                }

                return(data);
            }

            return(null);
        }
Ejemplo n.º 8
0
        public void GivenUnparsedResponse_WhenParsingArtistDataOutOfHtml_ThenHtmlStrippedOffCorrectly()
        {
            var artistResponseHtml = "<a href=\"https://www.metal-archives.com/bands/%21T.O.O.H.%21/16265\" title=\"!T.O.O.H.! (CZ)\">!T.O.O.H.!</a>";

            var expected = new ArtistData("!T.O.O.H.!", "CZ");
            var actual   = _parser.GetArtistData(artistResponseHtml);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 9
0
        public void TestArtistNoSongs()
        {
            Song one = new Song("artist", "one two three four");

            ArtistData artist = new ArtistData("artist");

            artist.CalculateAverage();

            Assert.AreEqual(artist.Report(), "artist had no known songs");
        }
Ejemplo n.º 10
0
        public void TestArtistSingleSong()
        {
            Song one = new Song("artist", "one two three four");

            ArtistData artist = new ArtistData("artist");

            artist.AddSong(one);
            artist.CalculateAverage();

            Assert.AreEqual(artist.Report(), "artist has only one song found with word count of 4");
        }
Ejemplo n.º 11
0
        public void Update()
        {
            ArtistData updatePerson = new ArtistData();
            Artist     newPerson    = new Artist()
            {
                IdArtist = 5,
                FullName = "Juan"
            };

            Assert.AreEqual(true, updatePerson.Update(newPerson).succeed);
        }
Ejemplo n.º 12
0
		async void RetrieveArtistPicture (ArtistItemView view, ArtistData artist)
		{
			Bitmap bmp = null;
			if (cache.TryGet (artist.PictureUrl, out bmp)) {
				view.SetArtistImage (bmp, immediate: true);
				return;
			}
			var id = view.VersionID;
			bmp = await FetchBitmap (artist.PictureUrl);
			if (view.VersionID == id)
				view.SetArtistImage (bmp, immediate: false);
		}
        /// <summary>
        /// Gets an artist using a previously retrieved ID.
        /// </summary>
        /// <param name="artistID">The ID of the artist to retrieve.</param>
        /// <param name="locale">The locale of the artist which the ID corresponds to.</param>
        /// <returns>ArtistData or null</returns>
        public async override Task <ArtistData> GetArtistAsync(string artistID, string locale = "JP")
        {
            ArtistData data = new ArtistData();

            //Trys to grab an for artist on musicbrainz via their ID.
            var artistData = await Artist.GetAsync(artistID, "url-rels", "aliases", "artist-rels");

            if (artistData != null)
            {
                //If there is an artist with that ID, we start grabbing their data and putting it into an ArtistData object.
                data.Name          = artistData.Name;
                data.Gender        = artistData.Gender;
                data.ArtistID      = artistData.Id;
                data.Country       = artistData.Country;
                data.ArtistLinkUrl = "https://musicbrainz.org/artist/" + artistData.Id;


                //Next, we check to see if they have any external links listed on their page.
                if (artistData.RelationLists != null)
                {
                    //If they have an image listed, we can use this as their artist image.
                    var imageRel = artistData.RelationLists.Items?.FirstOrDefault(x => x.Type == "image");

                    if (imageRel != null)
                    {
                        //If there is an image, make sure the actual url isn't null.
                        if (!string.IsNullOrWhiteSpace(imageRel.Target))
                        {
                            var url = await ResolveImageUrlAsync(new Uri(imageRel.Target));

                            //Check if the URL is accessible.
                            if (await CheckIfUrlIsWebAccessibleAsync(new Uri(url)))
                            {
                                data.ArtistImage = url; //Its accessible, set the url as the artist image.
                            }
                        }
                    }

                    //Check if the artist has a wikipedia article referenced.
                    var wikipediaRel = artistData.RelationLists.Items?.FirstOrDefault(x => x.Type == "wikipedia");

                    if (wikipediaRel != null)
                    {
                        //Looks like they do have a wikipedia article. Set it as the WikipediaUrl.
                        data.WikipediaUrl = wikipediaRel.Target;
                    }
                }

                return(data); //Return the data we've found.
            }

            return(null);
        }
Ejemplo n.º 14
0
        public ActionResult Create([FromForm] ArtistData artist)
        {
            try
            {
                _repository.Add(artist);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 15
0
        public ActionResult Edit(int id, [FromForm] ArtistData artist)
        {
            try
            {
                _repository.Update(artist);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 16
0
        public void TestArtist()
        {
            Song one = new Song("artist", "one two three four");
            Song two = new Song("artist", "one two three four five six");

            ArtistData artist = new ArtistData("artist");

            artist.AddSong(one);
            artist.AddSong(two);
            artist.CalculateAverage();

            Assert.AreEqual(artist.Report(), "artist has 2 songs with an average word count of 5");
        }
Ejemplo n.º 17
0
        public ActionResult Delete(int id)
        {
            ArtistData artist = _repository.GetById(id);

            if (artist != null)
            {
                _repository.Remove(artist);

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(new BadRequestResult());
            }
        }
Ejemplo n.º 18
0
        public void Post()
        {
            ArtistData postPerson = new ArtistData();
            Artist     newPerson  = new Artist()
            {
                FullName    = "Juan Castelblanco",
                BirthDate   = Convert.ToDateTime("1991-06-11"),
                StartDate   = Convert.ToDateTime("2014-04-24"),
                PhoneNumber = "31787101069",
                Address     = "Diag 123",
                Email       = "*****@*****.**"
            };

            Assert.AreEqual(5.GetType(), postPerson.Post(newPerson).idElement.GetType());
        }
Ejemplo n.º 19
0
        public async Task GetAverageLyricCount_ReturnsAverageDetails()
        {
            // Arrange
            var artist = new ArtistData
            {
                Name = "Hadouken",
                Id   = "8c9200b8-8e05-41d5-836e-44a37905560e"
            };

            var averageDetails = new AverageDetails
            {
                Average  = 101.75,
                MaxCount = 132,
                MinCount = 75
            };

            _musicBrainzService.Setup(mb => mb.GetArtistData(It.IsAny <string>()))
            .Returns(artist);
            _musicBrainzService.Setup(mb => mb.GetArtistReleases(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new List <string>
            {
                "Every Weekend",
                "For The Masses"
            });
            _musicBrainzService.Setup(mb => mb.GetSongsByReleases(It.IsAny <string>(), It.IsAny <List <string> >()))
            .Returns(new List <string>
            {
                "The Vortex", "Oxygen", "Turn The Lights Out"
            });
            _lyricService.Setup(ls => ls.GetSongLyrics(It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(new SongLyrics {
                Lyrics = "Some lyrics to a song."
            });
            _lyricCalculator.Setup(lc => lc.GetLyricCount(It.IsAny <string>()))
            .Returns(57);
            _lyricCalculator.Setup(lc => lc.GetLyricCountAverageDetails(It.IsAny <List <int> >()))
            .Returns(averageDetails);

            // Act
            var result = await _lyricApiLogic.GetAverageLyricCount("Hadouken");

            // Assert
            Assert.AreEqual(artist.Name, result.ArtistName);
            Assert.AreEqual(averageDetails.Average, result.AverageDetails.Average);
            Assert.AreEqual(averageDetails.MaxCount, result.AverageDetails.MaxCount);
            Assert.AreEqual(averageDetails.MinCount, result.AverageDetails.MinCount);
        }
Ejemplo n.º 20
0
        private List <ArtistData> GetSuggestedArtistData(string[] extractedArtists)
        {
            var artists = new List <ArtistData>();

            foreach (var artist in extractedArtists)
            {
                var artistData = new ArtistData();
                artistData.Exists = false;
                artistData.Tag    = artist;

                string suggestedName, suggestedNickname, nameValue, bracketValue;
                suggestedName = suggestedNickname = nameValue = bracketValue = string.Empty;

                int openBracketIndex = artist.IndexOf('(');
                if (openBracketIndex != -1)
                {
                    int closeBracketIndex = artist.IndexOf(')');
                    int length            = closeBracketIndex - openBracketIndex - 1;
                    bracketValue = artist.Substring(openBracketIndex + 1, length);
                    nameValue    = artist.Substring(0, openBracketIndex - 1);
                }
                else
                {
                    nameValue = artist;
                }

                if (!string.IsNullOrEmpty(bracketValue))
                {
                    bracketValue = bracketValue.Capitalize();
                }

                suggestedName                = nameValue.Capitalize();
                suggestedNickname            = bracketValue;
                artistData.SuggestedName     = suggestedName;
                artistData.SuggestedNickname = suggestedNickname;
                artists.Add(artistData);
            }
            return(artists);
        }
Ejemplo n.º 21
0
        public List <ArtistDataSearch> SearchArtistsByName(string searchTerm)
        {
            List <ArtistDataSearch> listArtistDataSearch = new List <ArtistDataSearch>();

            var           client   = new RestClient(searchArtistUrl);
            var           request  = new RestRequest(Method.GET).AddParameter("searchTerm", searchTerm);
            IRestResponse response = client.Execute(request);

            dynamic data = JObject.Parse(response.Content);

            foreach (ArtistDataSearch item in data.artists.ToObject <List <ArtistDataSearch> >())
            {
                string        url = String.Format("{0}{1}", SearchArtistDataUrl, item.name);
                IRestResponse rsp = MakeRequest(url);

                ArtistData artistData = JsonConvert.DeserializeObject <ArtistData>(rsp.Content);

                item.artistData = artistData;

                listArtistDataSearch.Add(item);
            }
            return(listArtistDataSearch);
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Get Images for Artist
 /// </summary>
 /// <param name="mbId">Musicbrainz id for the artist</param>
 /// <param name="apiKey">Users api_key</param>
 public Artist(string mbId, string apiKey)
 {
     List = Info(mbId, apiKey, API.cKey);
 }
Ejemplo n.º 23
0
        public void Get()
        {
            ArtistData getPerson = new ArtistData();

            Assert.AreEqual(null, getPerson.Get(2).errorMessage);
        }
Ejemplo n.º 24
0
        public void Delete()
        {
            ArtistData delPerson = new ArtistData();

            Assert.AreEqual(true, delPerson.Delete(7).succeed);
        }
Ejemplo n.º 25
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            if (!fileUpload.HasFile)
            {
                mvImportMaster.AddError("ファイルを見つかりません・・・");
                return;
            }
            CsvReader csvRead = null;
            Hashtable artistKeyMap = new Hashtable();
            Hashtable labelKeyMap = new Hashtable();
            Hashtable albumKeyMap = new Hashtable();
            StringBuilder updSql = new StringBuilder();

            string[] excAlbumName = { "パッケージナシ",
                                        "パッケージなし",
                                        "パッケージ未発売",
                                        "パッケージ未発売のためなし",
                                        "先行配信",
                                        "配信シングル",
                                        "配信限定",
                                        "配信限定パッケージのためなし",
                                        "配信限定楽曲",
                                        "未定",
                                        "タイトル未定",
                                        "配信限定商品" };

            string[] excAlbumNameYomi = { "パッケージナシ",
                                        "ハッケージミハツバイ",
                                        "ハッケージミハツバイノタメナシ",
                                        "センコウハイシン",
                                        "ハイシンゲンテイシングル",
                                        "ハイシンゲンテイ",
                                        "ハイシンゲンテイパッケージノタメナシ",
                                        "ハイシンゲンテイガッキョク",
                                        "ミテイ",
                                        "タイトルミテイ",
                                        "ハイシンゲンテイショウヒン"};
            try
            {
                string[] array = fileUpload.FileName.Split('.');
                string ext = string.Empty;
                if (array.Length > 0)
                {
                    ext = array[array.Length - 1];
                }
                if (ext.Length == 0) return;

                ext = ext.ToUpper();

                if (!"csv".Equals(ext.ToLower()))
                {
                    mvImportMaster.AddError("CSVファイルを選択してください・・・");
                    return;
                }
                if (File.Exists(Server.MapPath("./") + fileUpload.FileName))
                {
                    File.Delete(Server.MapPath("./") + fileUpload.FileName);
                }
                fileUpload.SaveAs(Server.MapPath("./") + fileUpload.FileName);

                csvRead = new CsvReader(Server.MapPath("./") + fileUpload.FileName, true, ',');
                csvRead.IsCheckQuote = true;
                string sql = "DELETE FROM SongImport WHERE SessionId='" + Session.SessionID + "' and ImportType = '"+ importType +"'";
                DbHelper.ExecuteNonQuery(sql);
                sql = "DELETE FROM SongMediaTemp WHERE SessionId='" + Session.SessionID + "' and ImportType = '" + importType + "'";
                DbHelper.ExecuteNonQuery(sql);

                DataTable dt = new DataTable();
                DataTable dtTmp = new DataTable();
                dt.Load(csvRead);

                string[] header = csvRead.GetFieldHeaders();

                if (!validFormat(dt))
                {
                    return;
                }

                if (dt.Rows.Count > 0)
                {

                    //フォーマットチェック
                    for (int i = 0; i < Constants.ImportDataHeader.Length; i++)
                    {
                        if (!Constants.ImportDataHeader[i].Equals(header[i]))
                        {
                            mvImportMaster.AddError("CSVファイルのヘッダー部分が間違っています・・・");
                            return;
                        }
                    }

                    dt.Columns.Add("SessionId", Type.GetType("System.String"));
                    dt.Columns.Add("ImportType", Type.GetType("System.String"));
                    dt.Columns.Add("Status");

                    dt.Columns.Add("DelFlag", Type.GetType("System.String"));
                    dt.Columns.Add("Updated", Type.GetType("System.String"));
                    dt.Columns.Add("Updator", Type.GetType("System.String"));
                    dt.Columns.Add("Created", Type.GetType("System.String"));
                    dt.Columns.Add("Creator", Type.GetType("System.String"));

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        dt.Rows[i]["SessionId"] = Session.SessionID;
                        dt.Rows[i]["ImportType"] = importType;
                        dt.Rows[i]["DelFlag"] = "0";
                        dt.Rows[i]["Updated"] = DateTime.Now.ToString("yyyyMMddHHmmss");
                        dt.Rows[i]["Updator"] = Page.User.Identity.Name;
                        dt.Rows[i]["Created"] = DateTime.Now.ToString("yyyyMMddHHmmss");
                        dt.Rows[i]["Creator"] = Page.User.Identity.Name;
                    }

                    using (SqlBulkCopy copy = new SqlBulkCopy(Gnt.Configuration.ApplicationConfiguration.ConnectionString))
                    {
                        copy.DestinationTableName = "SongImport";
                        copy.BatchSize = 3000;
                        copy.BulkCopyTimeout = 99999;
                        for (int i = 0; i < Constants.ImportDataHeader.Length; i++)
                        {
                            copy.ColumnMappings.Add(i, Constants.ImportDataDbRef[i]);
                        }

                        copy.ColumnMappings.Add(dt.Columns.Count - 8, "SessionId");
                        copy.ColumnMappings.Add(dt.Columns.Count - 7, "ImportType");
                        copy.ColumnMappings.Add(dt.Columns.Count - 6, "Status");

                        copy.ColumnMappings.Add(dt.Columns.Count - 5, "DelFlag");
                        copy.ColumnMappings.Add(dt.Columns.Count - 4, "Updated");
                        copy.ColumnMappings.Add(dt.Columns.Count - 3, "Updator");
                        copy.ColumnMappings.Add(dt.Columns.Count - 2, "Created");
                        copy.ColumnMappings.Add(dt.Columns.Count - 1, "Creator");

                        copy.WriteToServer(dt);
                    }
                }

                DbHelper.ExecuteNonQuery("Update SongImport set Status = 1 where SessionId = '" + Session.SessionID + "' and ImportType = '"+ importType +"' and SongId in (Select SongMediaId from SongMedia where TypeId = '1')");

                sql = "Select * from SongImport where SessionId = '" + Session.SessionID + "' and ImportType = '" + importType + "'";
                SqlDatabase db = new SqlDatabase();
                DataSet ds = new DataSet();
                DataSet dsTmp = new DataSet();

                SqlCommand cm = db.CreateCommand(sql);
                SqlDataAdapter da = new SqlDataAdapter(cm);
                da.Fill(ds);
                dt = ds.Tables[0];

                string autoKeyArtist = "";
                string autoKeyLabel = "";
                string autoKeyAlbum = "";

                //record
                foreach (DataRow row in dt.Rows)
                {
                    //曲ID
                    string songId = row["SongId"].ToString().ToUpper();

                    //アーティスト名(半角)	ArtistName
                    string artistName = row["ArtistName"].ToString().Replace("'", "''").ToUpper();
                    //アーティスト名ヨミ(半角)	ArtistNameReadingFull
                    string artistNameReadingFull = row["ArtistNameReadingFull"].ToString().Replace("'", "''").ToUpper();

                    string artistId = row["ArtistId"].ToString().ToUpper();

                    if ("".Equals(artistId) || artistId == null)
                    {
                        if (!artistKeyMap.Contains(artistName) &&
                            !artistKeyMap.Contains(artistNameReadingFull) &&
                            !artistKeyMap.Contains(artistName + "_" + artistNameReadingFull))
                        {
                            ArtistData artistData = new ArtistData();
                            string sqlArtist01 = "UPPER(" + artistData.ObjectKeyTableName + artistData.ColName + ") = '" + artistName + "' and UPPER(" + artistData.ObjectKeyTableName + artistData.ColNameReadingFull + ") = '" + artistNameReadingFull + "'";
                            string sqlArtist02 = "UPPER(" + artistData.ObjectKeyTableName + artistData.ColName + ") = '" + artistName + "' ";
                            string sqlArtist03 = "UPPER(" + artistData.ObjectKeyTableName + artistData.ColNameReadingFull + ") = '" + artistNameReadingFull + "'";
                            string[] sqlWhereArtist = { sqlArtist01 };

                            artistId = GetKey(artistData, sqlWhereArtist);
                            if ("".Equals(artistId) || artistId == null)
                            {
                                string sqlTemp = "SELECT count(*) " + artistData.ObjectKeyColumnName + " FROM " + artistData.ObjectKeyTableName + " WHERE " + sqlArtist02;
                                int count1 = Func.ParseInt(DbHelper.GetScalar(sqlTemp));
                                sqlTemp = "SELECT count(*) FROM " + artistData.ObjectKeyTableName + " WHERE " + sqlArtist03;
                                int count2 = Func.ParseInt(DbHelper.GetScalar(sqlTemp));

                                if (count1 + count2 >= 1)
                                {
                                    artistId = "ERROR";
                                }
                                else
                                {
                                    if ("".Equals(autoKeyArtist) || autoKeyArtist == null)
                                    {
                                        artistId = CreateKey(artistData, artistData.ObjectType.Prefix);
                                    }
                                    else
                                    {
                                        string prefix = artistData.ObjectType.Prefix;
                                        int length = artistData.KeyAttributeData.MaxLength;
                                        string tmp = autoKeyArtist.Replace(prefix, "");
                                        int i = Func.ParseInt(tmp) + 1;
                                        artistId = prefix + Func.ParseString(i).PadLeft(length - prefix.Length, '0');
                                    }
                                    autoKeyArtist = artistId;
                                }
                            }

                            if (!artistKeyMap.Contains(artistName))
                            {
                                artistKeyMap.Add(artistName, artistId);
                            }
                            if (!artistKeyMap.Contains(artistNameReadingFull))
                            {
                                artistKeyMap.Add(artistNameReadingFull, artistId);
                            }
                            if (!artistKeyMap.Contains(artistName + "_" + artistNameReadingFull))
                            {
                                artistKeyMap.Add(artistName + "_" + artistNameReadingFull, artistId);
                            }
                        }
                        else
                        {
                            if (!"".Equals((string)artistKeyMap[artistName]))
                            {
                                artistId = (string)artistKeyMap[artistName];
                            }

                            if ("".Equals(artistId) || artistId == null)
                            {
                                if (!"".Equals((string)artistKeyMap[artistNameReadingFull]))
                                {
                                    artistId = (string)artistKeyMap[artistNameReadingFull];
                                }
                            }

                            if ("".Equals(artistId) || artistId == null)
                            {
                                if (!"".Equals((string)artistKeyMap[artistName + "_" + artistNameReadingFull]))
                                {
                                    artistId = (string)artistKeyMap[artistName + "_" + artistNameReadingFull];
                                }
                            }
                        }
                    }

                    //レーベル名(半角)	    LabelName
                    string labelName = row["LabelName"].ToString().Replace("'", "''").ToUpper();
                    string labelId = row["LabelId"].ToString().ToUpper();
                    if ("".Equals(labelId) || labelId == null)
                    {
                        if (!labelKeyMap.Contains(labelName))
                        {
                            LabelData labelData = new LabelData();
                            string labelSql01 = "UPPER(" + labelData.ObjectKeyTableName + labelData.ColName + ") = '" + labelName + "' ";
                            string[] sqlWhereLabel = { labelSql01 };
                            labelId = GetKey(labelData, sqlWhereLabel);
                            if ("".Equals(labelId) || labelId == null)
                            {
                                if ("".Equals(autoKeyLabel) || autoKeyLabel == null)
                                {
                                    labelId = CreateKey(labelData, labelData.ObjectType.Prefix);
                                }
                                else
                                {
                                    string prefix = labelData.ObjectType.Prefix;
                                    int length = labelData.KeyAttributeData.MaxLength;
                                    string tmp = autoKeyLabel.Replace(prefix, "");
                                    int i = Func.ParseInt(tmp) + 1;
                                    labelId = prefix + Func.ParseString(i).PadLeft(length - prefix.Length, '0');
                                }
                                autoKeyLabel = labelId;
                            }

                            labelKeyMap.Add(labelName, labelId);
                        }
                        else
                        {
                            labelId = (string)labelKeyMap[labelName];
                        }
                    }
                    string songTitleReading = row["SongTitleReading"].ToString();
                    string yomi = "";
                    if (!String.IsNullOrEmpty(songTitleReading))
                    {
                        yomi = songTitleReading.Substring(0, 1);
                        yomi = Strings.StrConv(Strings.StrConv(yomi, VbStrConv.Wide, 0x0411), VbStrConv.Hiragana, 0x0411);
                    }
                    updSql.AppendLine("Update SongImport set ArtistId = '" + artistId + "' , LabelId = '" + labelId + "', SongYomi = '" + yomi + "' where SongId = '" + songId + "' and SessionId = '" + Session.SessionID + "' and ImportType = '" + importType + "'");
                }

                DbHelper.ExecuteNonQuery(updSql.ToString());

                db = new SqlDatabase();
                ds = new DataSet();
                dsTmp = new DataSet();
                cm = db.CreateCommand(sql);
                da = new SqlDataAdapter(cm);

                updSql = new StringBuilder();
                sql = "Select * from SongImport where SessionId = '" + Session.SessionID + "' and ImportType = '" + importType + "'";
                cm = db.CreateCommand(sql);
                da = new SqlDataAdapter(cm);
                da.Fill(ds);

                dt = ds.Tables[0];
                foreach (DataRow row in dt.Rows)
                {
                    string contractorId = row["ContractorId"].ToString();
                    string hbunRitsu = "";
                    string uta_rate = "";
                    string video_rate = "";
                    if (!"".Equals(contractorId))
                    {
                        ContractorData data = new ContractorData();
                        ITransaction tran = factory.GetLoadObject(data, contractorId);
                        Execute(tran);
                        if (!HasError)
                        {

                            //編集の場合、DBに既存データを取得して設定する。
                            data = (ContractorData)tran.Result;
                            hbunRitsu = data.HbunRitsu;
                            uta_rate = data.uta_rate;
                            video_rate = data.video_rate;
                        }
                    }

                    //アーティストID
                    string artistId = row["ArtistId"].ToString().ToUpper();

                    ///////////
                    //アルバム名(半角)	",	"	AlbumTitle	",
                    string albumTitle = row["AlbumTitle"].ToString().Replace("'", "''").ToUpper();
                    //アルバム名ヨミ(半角)	",	"	AlbumTitleReadingFull	",
                    string albumTitleReadingFull = row["AlbumTitleReadingFull"].ToString().Replace("'", "''").ToUpper();
                    //CD品番	",	"	AlbumCdId	",
                    string albumCdId = row["AlbumCdId"].ToString().Replace("'", "''").ToUpper();

                    string albumId = row["AlbumId"].ToString().Replace("'", "''").ToUpper();

                    if ("".Equals(albumId) || albumId == null)
                    {
                        if (!albumKeyMap.Contains(albumTitle + "_" + albumTitleReadingFull + "_" + albumCdId))
                        {
                            if (excAlbumName.Contains(albumTitle) || excAlbumNameYomi.Contains(albumTitleReadingFull))
                            {
                                albumId = "ERROR";
                            }
                            else
                            {
                                AlbumData albumData = new AlbumData();

                                db = new SqlDatabase();
                                ds = new DataSet();
                                dsTmp = new DataSet();

                                string albumSql = "UPPER(" + albumData.ObjectKeyTableName + albumData.ColTitle + ") = '" + albumTitle + "' AND " +
                                                 "UPPER(" + albumData.ObjectKeyTableName + albumData.ColTitleReadingFull + ") = '" + albumTitleReadingFull + "' AND " +
                                                 "UPPER(" + albumData.ObjectKeyTableName + albumData.ColCdId + ") = '" + albumCdId + "' ";

                                string[] sqlWhereAlbum = { albumSql };
                                albumId = GetKey(albumData, sqlWhereAlbum);

                                albumSql = "Select count(*) from " + albumData.ObjectKeyTableName + " where " + albumSql;
                                int count = Func.ParseInt(DbHelper.GetScalar(albumSql));
                                if (count > 1)
                                {
                                    albumId = "ERROR";
                                }
                                else if (count == 1)
                                {
                                }
                                else
                                {
                                    db = new SqlDatabase();
                                    ds = new DataSet();
                                    dsTmp = new DataSet();

                                    string sqlGetArtist = "SELECT distinct Song.ArtistId, Album.AlbumId, Album.Title FROM Album INNER JOIN Song ON Album.AlbumId = Song.AlbumId WHERE (Album.Title = '" + albumTitle + "') OR (Album.TitleReadingFull = '" + albumTitleReadingFull + "')";
                                    cm = db.CreateCommand(sqlGetArtist);
                                    da = new SqlDataAdapter(cm);
                                    da.Fill(dsTmp);
                                    dtTmp = dsTmp.Tables[0];

                                    foreach (DataRow rowTmp in dtTmp.Rows)
                                    {
                                        string artistIdTmp = rowTmp["ArtistId"].ToString().ToUpper();
                                        string albumIdTmp = rowTmp["AlbumId"].ToString().ToUpper();

                                        if (artistId.Equals(artistIdTmp))
                                        {
                                            albumId = albumIdTmp;
                                        }
                                    }

                                    if ("".Equals(albumId) || albumId == null)
                                    {
                                        if ("".Equals(autoKeyAlbum) || autoKeyAlbum == null)
                                        {
                                            albumId = CreateKey(albumData, albumData.ObjectType.Prefix + "0");
                                        }
                                        else
                                        {
                                            string prefix = albumData.ObjectType.Prefix;
                                            int length = albumData.KeyAttributeData.MaxLength;
                                            string tmp = autoKeyAlbum.Replace(prefix, "");
                                            int i = Func.ParseInt(tmp) + 1;
                                            albumId = prefix + Func.ParseString(i).PadLeft(length - prefix.Length, '0');
                                        }
                                        autoKeyAlbum = albumId;
                                    }
                                }
                            }
                            albumKeyMap.Add(albumTitle + "_" + albumTitleReadingFull + "_" + albumCdId, albumId);
                        }
                        else
                        {
                            albumId = (string)albumKeyMap[albumTitle + "_" + albumTitleReadingFull + "_" + albumCdId];
                        }
                    }

                    string price = row["Price"].ToString();

                    string rate = hbunRitsu;
                    string priceNoTax = "";
                    string buyUnique = "";
                    string copyrightFeeUnique = "";
                    string KDDICommissionUnique = "";
                    string profitUnique = "";

                    if (!"".Equals(price) && !"".Equals(rate))
                    {
                        priceNoTax = Func.GetPriceNoTax(price);
                        buyUnique = Func.GetBuyUnique(priceNoTax, rate);
                        copyrightFeeUnique = Func.GetCopyrightFeeUnique(row["CopyrightContractId"].ToString(), priceNoTax, "1");
                        KDDICommissionUnique = Func.GetKDDICommissionUnique(priceNoTax);
                        profitUnique = Func.GetProfitUnique(priceNoTax, buyUnique, copyrightFeeUnique, KDDICommissionUnique);
                    }

                    string songId = row["SongId"].ToString();
                    updSql.AppendLine("Update SongImport set AlbumId = '" + albumId + "', hbunRitsu = '" + hbunRitsu + "', uta_rate = '" + uta_rate + "', video_rate = '" + video_rate + "' , PriceNoTax = '" + priceNoTax + "', BuyUnique = '" + buyUnique + "', CopyrightFeeUnique = '" + copyrightFeeUnique + "', KDDICommissionUnique = '" + KDDICommissionUnique + "', ProfitUnique = '" + profitUnique + "'where SongId = '" + songId + "' and SessionId = '" + Session.SessionID + "' and ImportType = '" + importType + "'");

                    ArrayList sqlAddSongMedia = GetSqlAddSongMediaKey(row,uta_rate,video_rate);
                    for (int i = 0; i < sqlAddSongMedia.Count; i++)
                    {
                        updSql.AppendLine(sqlAddSongMedia[i].ToString());
                    }
                }

                DbHelper.ExecuteNonQuery(updSql.ToString());

                //うた既存 => status=1
                DbHelper.ExecuteNonQuery("Update SongMediaTemp set Status = 1 where SessionId = '" + Session.SessionID + "' and SongMediaId in (Select SongMediaId from SongMedia where TypeId = '2') and ImportType = '" + importType + "'");

                //ビデオ既存 => status=1
                DbHelper.ExecuteNonQuery("Update SongMediaTemp set Status = 1 where SessionId = '" + Session.SessionID + "' and SongMediaId in (Select SongMediaId from SongMedia where TypeId = '3') and ImportType = '" + importType + "'");

                db.Close();
                ///////////
                Session["FolderPath"] = fileUpload.FileName;
                Response.Redirect("NewListMasterImport.aspx", false);
            }
            catch (Exception ex)
            {
                mvImportMaster.AddError("エラーが発生しました: " + ex.Message);
            }
            finally
            {
                if (csvRead != null)
                {
                    csvRead.Dispose();
                }
            }
        }
 public void Post([FromBody] ArtistData value)
 {
     _repository.Add(value);
 }
 public void Put(int id, [FromBody] ArtistData value)
 {
     value.Id = id;
     _repository.Update(value);
 }
 public ArtistToDistributor(ArtistData artist, DistributorData distributor)
 {
     Artist      = artist;
     Distributor = distributor;
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Get Images for Artist
 /// </summary>
 /// <param name="mbId">Musicbrainz id for the artist</param>
 public Artist(string mbId)
 {
     List = Info(mbId, API.Key, API.cKey);
 }
Ejemplo n.º 30
0
        private string GetBio(ArtistData value)
        {
            var localization = ServiceRegistration.Get <ILocalization>();
            var re           = localization.CurrentCulture.Name;

            if (re.Contains("en-") & value.BiographyEn != "")
            {
                return(value.BiographyEn);
            }
            if (re.Contains("de-") & value.BiographyDe != "")
            {
                return(value.BiographyDe);
            }
            if (re.Contains("fr-") & value.BiographyFr != "")
            {
                return(value.BiographyFr);
            }
            if (re.Contains("cn-") & value.BiographyCn != "")
            {
                return(value.BiographyCn);
            }
            if (re.Contains("it-") & value.BiographyIt != "")
            {
                return(value.BiographyIt);
            }
            if (re.Contains("jp-") & value.BiographyJp != "")
            {
                return(value.BiographyJp);
            }
            if (re.Contains("ru-") & value.BiographyRu != "")
            {
                return(value.BiographyRu);
            }
            if (re.Contains("es-") & value.BiographyEs != "")
            {
                return(value.BiographyEs);
            }
            if (re.Contains("pt-") & value.BiographyPt != "")
            {
                return(value.BiographyPt);
            }
            if (re.Contains("se-") & value.BiographySe != "")
            {
                return(value.BiographySe);
            }
            if (re.Contains("nl-") & value.BiographyNl != "")
            {
                return(value.BiographyNl);
            }
            if (re.Contains("hu-") & value.BiographyHu != "")
            {
                return(value.BiographyHu);
            }
            if (re.Contains("no-") & value.BiographyNo != "")
            {
                return(value.BiographyNo);
            }
            if (re.Contains("il-") & value.BiographyIl != "")
            {
                return(value.BiographyIl);
            }
            if (re.Contains("pl-") & value.BiographyPl != "")
            {
                return(value.BiographyPl);
            }

            return(value.BiographyEn);
        }
Ejemplo n.º 31
0
        public void GetAll()
        {
            ArtistData getAllPeople = new ArtistData();

            Assert.AreEqual(5, getAllPeople.GetAll().list.Count());
        }
Ejemplo n.º 32
0
 /// <summary>
 /// Get Images for Artist
 /// </summary>
 /// <param name="mbId">Musicbrainz id for the artist</param>
 /// <param name="apiKey">Users api_key</param>
 /// <param name="clientKey">Users client_key</param>
 public Artist(string mbId, string apiKey, string clientKey)
 {
     List = Info(mbId, apiKey, clientKey);
 }