public int editAlbum(AlbumData model) { int i = 0; ///Add Database connections string Data String connections = ("Server=;Port=;Database=;User Id=;Password="******"UPDATE public.mg_albumstore SET a_title=@a_title,a_price=@a_price,a_artist=@a_artist,quantity=@quantity WHERE a_id=@a_id"; connection.Open(); cmd = new NpgsqlCommand(query, connection); cmd.Parameters.AddWithValue("@a_title", model.a_title); cmd.Parameters.AddWithValue("@a_price", model.a_price); cmd.Parameters.AddWithValue("@a_id", model.a_id); cmd.Parameters.AddWithValue("@quantity", model.quantity); //cmd.Parameters.AddWithValue("@user_albumid", model.user_albumid); cmd.Parameters.AddWithValue("@a_artist", model.a_artist); try { i = cmd.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { connection.Close(); } return(i); }
public int AddAlbum(AlbumData model) { int i = 0; ///Add Database connections string Data String connections = ("Server=;Port=;Database=;User Id=;Password="******"INSERT INTO public.mg_albumstore(al_img, a_artist, a_title,quantity,a_price)VALUES(@al_img,@a_artist, @a_title,@quantity,@a_price)"; connection.ConnectionString = connections; connection.Open(); cmd = new NpgsqlCommand(query, connection); cmd.Parameters.Add(new NpgsqlParameter("@al_img", model.al_img)); cmd.Parameters.Add(new NpgsqlParameter("@a_artist", model.a_artist)); cmd.Parameters.Add(new NpgsqlParameter("@a_title", model.a_title)); cmd.Parameters.Add(new NpgsqlParameter("@quantity", model.quantity)); cmd.Parameters.Add(new NpgsqlParameter("@a_price", model.a_price)); try { i = cmd.ExecuteNonQuery(); } catch (Exception ex) { Console.Write(ex.Message); } finally { connection.Close(); } return(i); }
public CreateVinylCassette(ref VinylAlbum vinyl, int numDisc, bool edit = false) { InitializeComponent(); this.numDisc = numDisc; side = (char)('A' + (numDisc + (numDisc - 2))); album = vinyl.Album; editingVinyl = vinyl; creatingVinyl = vinyl; //If we're NOT editing if (numDisc > 1 && !edit) { labelAñoPublicacion.Hide(); comboBoxEstadoExterior.Hide(); labelEstadoExterior.Hide(); labelAñoPublicacion.Hide(); labelPaisPublicacion.Hide(); textBoxPais.Hide(); textBoxAño.Hide(); } else if (edit) { Log.Instance.PrintMessage("Editando CD", MessageType.Info); creatingVinyl = null; this.edit = true; comboBoxEstadoMedio.SelectedItem = vinyl.DiscList[numDisc - 1].MediaCondition; comboBoxEstadoExterior.SelectedItem = vinyl.SleeveCondition; numericUpDownNumSongsFront.Value = vinyl.DiscList[numDisc - 1].NumberOfSongs; textBoxAño.Text = editingVinyl.Year.ToString(); textBoxPais.Text = editingVinyl.Country; } SetMaxLength(); PutTexts(); }
public SpotifyResults(ref List <SimpleAlbum> l, bool edit, AlbumData album = null) { InitializeComponent(); EditarID = edit; AlbumAEditar = album; Text = Kernel.LocalTexts.GetString("resultado_busqueda"); labelAyuda.Text = Kernel.LocalTexts.GetString("ayudaAñadir"); labelResultado.Text = Kernel.LocalTexts.GetString("seHanEncontrado") + l.Count + " " + Kernel.LocalTexts.GetString("resultados"); listaBusqueda = l; listViewResultadoBusqueda.Columns[1].Text = Kernel.LocalTexts.GetString("artista"); listViewResultadoBusqueda.Columns[2].Text = Kernel.LocalTexts.GetString("titulo"); listViewResultadoBusqueda.Columns[3].Text = Kernel.LocalTexts.GetString("año"); listViewResultadoBusqueda.Columns[4].Text = Kernel.LocalTexts.GetString("numcanciones"); buttonCancelar.Text = Kernel.LocalTexts.GetString("cancelar"); buttonOK.Text = Kernel.LocalTexts.GetString("añadir"); int n = 1; foreach (SimpleAlbum a in listaBusqueda) { String[] parseFecha = a.ReleaseDate.Split('-'); String[] datos = { n.ToString(), a.Artists[0].Name, a.Name, parseFecha[0], a.TotalTracks.ToString() }; n++; ListViewItem i = new ListViewItem(datos); listViewResultadoBusqueda.Items.Add(i); } lvwColumnSorter = new ListViewItemComparer(); listViewResultadoBusqueda.ListViewItemSorter = lvwColumnSorter; listViewResultadoBusqueda.View = View.Details; Icon = Properties.Resources.spotifyico; }
public async Task <IActionResult> Create( Album album, [FromServices] IMemoryCache cache, CancellationToken requestAborted) { if (ModelState.IsValid) { album.Artist = await MusicStoreService.GetArtistAsync(album.ArtistId); album.Genre = await MusicStoreService.GetGenreAsync(album.GenreId); await MusicStoreService.AddAlbumAsync(album); var albumData = new AlbumData { Title = album.Title, Url = Url.Action("Details", "Store", new { id = album.AlbumId }) }; if (cache != null) { cache.Remove("latestAlbum"); } return(RedirectToAction("Index")); } var genres = await MusicStoreService.GetGenresAsync(); var artists = await MusicStoreService.GetAllArtistsAsync(); ViewBag.GenreId = new SelectList(genres, "GenreId", "Name", album.GenreId); ViewBag.ArtistId = new SelectList(artists, "ArtistId", "Name", album.ArtistId); return(View(album)); }
private void UpdateAlbumViewModel(int number, IList <AlbumData> albumDatas, ref AlbumViewModel albumViewModel) { if (albumDatas.Count >= number) { AlbumData data = albumDatas[number - 1]; if (albumViewModel == null || !albumViewModel.AlbumKey.Equals(data.AlbumKey)) { Task <AlbumArtwork> task = this.albumArtworkRepository.GetAlbumArtworkAsync(data.AlbumKey); AlbumArtwork albumArtwork = task.Result; albumViewModel = new AlbumViewModel(data, true) { ArtworkPath = this.cacheService.GetCachedArtworkPath(albumArtwork.ArtworkID) }; } } else { // Shows an empty tile albumViewModel = new AlbumViewModel(AlbumData.CreateDefault(), false) { ArtworkPath = string.Empty, Opacity = 0.8 - (number / 10.0) }; } RaisePropertyChanged("AlbumViewModel" + number.ToString()); System.Threading.Thread.Sleep(Constants.CloudLoadDelay); }
/// <summary> /// Get the AlbumId for the album containing the identified track /// </summary> /// <param name="trackId"></param> /// <returns></returns> public static string GetAlbumIdByTrackId( string trackId) { AlbumData album = albumByTrackId.ContainsKey(trackId) ? albumByTrackId[trackId] : null; return(album == null ? null : album.AlbumId); }
private async Task <AlbumData> GetAlbumDataAsync(ReleaseGroup album) { var albumData = new AlbumData { Title = album.Title, Id = album.Id.ToString() }; var url = $"http://coverartarchive.org/release-group/{album.Id}"; try { var response = await _httpClient.GetStringAsync(url); var coverArt = JsonConvert.DeserializeObject <CoverArtData>(response); foreach (var image in coverArt.images) { if (image.front) { albumData.Image = image.image; break; } } } catch (Exception ex) { // Some albums doesn´t have a image. Image will be null. } return(albumData); }
public AlbumViewer(ref VinylAlbum vinyl) { InitializeComponent(); ViewVinyl = vinyl; buttonPATH.Hide(); albumToVisualize = vinyl.Album; SetViewAlbumCover(); numDisco = 1; labelInfoAlbum.Text = Kernel.LocalTexts.GetString("artista") + ": " + vinyl.Album.Artist + Environment.NewLine + Kernel.LocalTexts.GetString("titulo") + ": " + vinyl.Album.Title + Environment.NewLine + Kernel.LocalTexts.GetString("año") + ": " + vinyl.Album.Year + Environment.NewLine + Kernel.LocalTexts.GetString("duracion") + ": " + vinyl.Album.Length.ToString() + Environment.NewLine + Kernel.LocalTexts.GetString("genero") + ": " + vinyl.Album.Genre.Name + Environment.NewLine + Kernel.LocalTexts.GetString("añoPublicacion") + ": " + vinyl.Year + Environment.NewLine + Kernel.LocalTexts.GetString("paisPublicacion") + ":" + vinyl.Country + Environment.NewLine + Kernel.LocalTexts.GetString("estado_exterior") + ": " + Kernel.LocalTexts.GetString(vinyl.SleeveCondition.ToString()) + Environment.NewLine; labelEstadoDisco.Text = Kernel.LocalTexts.GetString("estado_medio") + " " + numDisco + ": " + Kernel.LocalTexts.GetString(vinyl.DiscList[0].MediaCondition.ToString()) + Environment.NewLine; lvwColumnSorter = new ListViewItemComparer(); vistaCanciones.ListViewItemSorter = lvwColumnSorter; vistaCanciones.View = View.Details; vistaCanciones.MultiSelect = true; duracionSeleccionada.AutoSize = true; barraAbajo.Font = new Font("Segoe UI", 9); SetTexts(); LoadView(); }
public static void LoadLyrics() { Log.Instance.PrintMessage("Loading lyrics", MessageType.Info); Stopwatch crono = Stopwatch.StartNew(); using (StreamReader entrada = new FileInfo("lyrics.txt").OpenText()) { string linea = null; while (!entrada.EndOfStream) { linea = entrada.ReadLine(); string[] datos = linea.Split(';'); AlbumData albumData = Collection.SearchAlbum(datos[(int)CSV_PATHS_LYRICS.Album])[0]; Song song = albumData.GetSong(datos[(int)CSV_PATHS_LYRICS.SongTitle]); List <string> lyrics = new List <string>(); do { linea = entrada.ReadLine(); lyrics.Add(linea); } while (linea != "---"); lyrics.Remove("---"); song.Lyrics = lyrics.ToArray(); } } crono.Stop(); Log.Instance.PrintMessage("Lyrics loaded", MessageType.Correct, crono, TimeType.Milliseconds); }
static DataRepository() { Album = new AlbumData(); Artist = new ArtistData(); Track = new TrackData(); Invoice = new InvoiceData(); }
public void TrainingSetup(AlbumData _data, int albumID) { panCount = _data.imagePath.Count; Initializer(panCount); for (int i = 0; i < panCount; i++) { contentFiller = instPans[i].GetComponent <ContentFiller>(); if (contentFiller.nameText) { contentFiller.nameText.text = _data.imageName[i]; } if (albumID == 0 || albumID == 1) { // load from resources var texture = Resources.Load <Texture2D>("defaultalbum/" + _data.imagePath[i]); if (contentFiller.trainingImage) { contentFiller.trainingImage.texture = texture; } } else { //load from library } } contentRect.anchoredPosition = new Vector2(0f, 0f); init = true; }
/// <summary> /// Is the album a Classical album /// </summary> /// <param name="album"></param> /// <returns></returns> public static bool IsClassicalAlbum( AlbumData album) { var trackInfo = album.Track0.Info; return(trackInfo["Filename"].ToLower().Contains(@"\classical\")); }
private void CheckFile(AlbumData album, FileInfo file, SortedList<int, int> tracks, List<string> titles) { CheckHasTag(album, file); if (album.Result != ParseResult.Fine) return; Tag tag = TagUtils.ReadTag(file); Action<AlbumData, Tag>[] checkFuncs = { CheckRequiredTags, CheckArtist, CheckAlbum, CheckTitle, CheckReleaseYear, }; foreach (var func in checkFuncs) { func(album, tag); if (album.Result != ParseResult.Fine) return; } titles.Add(new TagEditor(tag).Title); CheckNumberOftrack(album, tag, tracks); if (album.Result != ParseResult.Fine) return; }
private void CheckTrackOrder(AlbumData album, SortedList<int, int> tracks) { if (TrackNumberRequired && !HasSortedTrackNumbers(tracks)) { album.Result = ParseResult.TrackIndexFailed; } }
public async Task <ActionResult> JsonAlbumDetails(int?albumId) { var album = await _commonService.GetAlbumWhere(newalbum => newalbum.AlbumId == albumId); if (album != null) { var albumData = new AlbumData(album); string result = "<strong>Artists: </strong>"; foreach (var artist in albumData.Artists) { result = result + artist.ArtistName; if (artist != albumData.Artists.Last()) { result = result + ", "; } } result = result + "<br /> <strong>Number of songs: </strong>" + album.Songs.Count; var response = new JsonResponseObject("ok", result); return(Json(response, JsonRequestBehavior.AllowGet)); } return(null); }
/// <summary> /// Get the collection of tracks which comprise an album /// </summary> /// <param name="albumId"></param> /// <returns></returns> public static TrackData[] GetTracksByAlbumId( string albumId) { AlbumData album = AlbumList.GetById(albumId); return(album == null ? null : album.Tracks); }
public async Task <Album> BuildAsync( Album album, CancellationToken cancellationToken) { IEnumerable <Guid> mediaIds = await _albumService.GetMediaIdsAsync( album, cancellationToken); if (!mediaIds.Any()) { return(album); } AlbumData data = await GetAlbumDataAsync(mediaIds, cancellationToken); album.Persons = GetPersons(data); album.Countries = GetCountries(data); album.ImageCount = data.Medias.Count(x => x.MediaType == MediaType.Image); album.VideoCount = data.Medias.Count(x => x.MediaType == MediaType.Video); album.StartDate = data.Medias.Min(x => x.DateTaken); album.EndDate = data.Medias.Max(x => x.DateTaken); if (album.CoverMediaId == null) { album.CoverMediaId = mediaIds.ToArray()[mediaIds.Count() / 2]; } return(album); }
public static Song GetRandomSong(AlbumData from) { Random random = new Random(); int index = random.Next(from.Songs.Count); return(from.Songs[index]); }
/// <summary> /// Recursively walk the JRMC tree of items and files to find all music tracks, music albums and photo albums /// </summary> /// <param name="itemiD"></param> /// <param name="albumList"></param> /// <param name="photoAlbumList"></param> static void FetchAllAlbums(string itemiD, AlbumCollection albumList, AlbumCollection photoAlbumList) { var childIds = GetChildren(itemiD); // If there are child items, recursively walk the tree if (childIds != null && childIds.Count != 0) { if (Convert.ToInt32(itemiD) >= 1000) { foreach (var childName in childIds.Keys) { var childId = childIds[childName]; FetchAllAlbums(childId, albumList, photoAlbumList); } } else { if (childIds.ContainsKey("Artist")) { FetchAllAlbums(childIds["Artist"], albumList, photoAlbumList); } if (childIds.ContainsKey("Album")) { FetchAllAlbums(childIds["Album"], albumList, photoAlbumList); } if (childIds.ContainsKey("Composer")) { FetchAllAlbums(childIds["Composer"], albumList, photoAlbumList); } } } else { // If there are NO child items, the files are music tracks or photos var tracks = GetTracks(itemiD); if (tracks != null && tracks.Length != 0) { string albumId = tracks[0].Info["Key"]; if (tracks[0].Info["Filename"].Contains(@"\Photos\")) { if (!photoAlbumList.Keys.Contains(albumId)) { var album = new AlbumData(albumId, tracks); photoAlbumList.Add(albumId, album); } } else { if (!albumList.Keys.Contains(albumId)) { var album = new AlbumData(albumId, tracks); albumList.Add(albumId, album); } } } } }
public AlbumControl(AlbumData albumData) : this() { this.lblTitle.Text = albumData.Title; this.lblMediaCount.Text = string.Format("{0} picture(s)", albumData.MediaItemsCount); this.pbxCover.Image = Utilities.GetBmpFromGoogleUrl(albumData.CoverPhotoBaseUrl + "=w220-h200-c"); this.albumControlId = albumData.Id; }
/// <summary> /// Get the collection of albums (containing at most one album) containing the identified track /// </summary> /// <param name="trackId"></param> /// <returns></returns> public static IEnumerable <AlbumData> GetAlbumsByTrackId( string trackId) { AlbumData album = albumByTrackId.ContainsKey(trackId) ? albumByTrackId[trackId] : null; return(album == null ? null : new List <AlbumData> { album }); }
public JsonResult EditPhoto(int id) { TempData["a_id"] = id; AlbumData model = new AlbumData(); //model = repo.AlbumDetailAdmin(id); model = repo.GetAlbumDetails(id); return(Json(model, JsonRequestBehavior.AllowGet)); }
private void BtnDelete_Click(object sender, EventArgs e) { AlbumData albumData = new AlbumData(); //Album album = albumData.GetByPK(10); //albumData.Delete(album); albumData.DeleteByPK(AlbumId); }
/// <summary> /// Sets global tracks filters. /// </summary> /// <param name="albumArtistFilter">Optionnal; <see cref="AlbumData.AlbumArtist"/> filter.</param> /// <param name="albumFilter">Optionnal; <see cref="TrackData.Album"/> filter.</param> /// <param name="genreFilter">Optionnal; <see cref="TrackData.Genres"/> filter.</param> /// <param name="performerFilter">Optionnal; <see cref="TrackData.Performers"/> filter.</param> /// <param name="yearFilter">Optionnal; <see cref="TrackData.Year"/> filter.</param> public void SetGlobalTracksFilters(AlbumArtistData albumArtistFilter = null, AlbumData albumFilter = null, GenreData genreFilter = null, PerformerData performerFilter = null, uint?yearFilter = null) { _albumArtistGlobalFilter = albumArtistFilter; _albumGlobalFilter = albumFilter; _genreGlobalFilter = genreFilter; _performerGlobalFilter = performerFilter; _yearGlobalFilter = yearFilter; }
private void BtnSearch_Click(object sender, EventArgs e) { int artistId = 10; string title = txtTitle.Text; AlbumData albumData = new AlbumData(); List <Album> albums = albumData.Search(artistId, title); bdsAlbum.DataSource = albums; }
private IEnumerable <AlbumCountry> GetCountries(AlbumData data) { IEnumerable <IGrouping <string, Media> > groupedCountry = data.Medias .Where(x => x.GeoLocation?.Address?.Country != null) .GroupBy(x => x.GeoLocation !.Address.Country); var albumCountries = new List <AlbumCountry>(); foreach (IGrouping <string, Media>?country in groupedCountry.Where( x => x.Key is { }))
private void CheckRequiredTags(AlbumData album, Tag tag) { if (HasAllRequiredTags(tag)) { album.Result = ParseResult.Fine; } else { album.Result = ParseResult.TagMissing; } }
private void CheckHasTag(AlbumData album, FileInfo file) { if (TagUtils.HasTag(file)) { album.Result = ParseResult.Fine; } else { album.Result = ParseResult.NoTagAtAll; } }
public AlbumViewModel(AlbumData albumData) { this.albumArtist = this.GetAlbumArtist(albumData); this.albumTitle = !string.IsNullOrEmpty(albumData.AlbumTitle) ? albumData.AlbumTitle : ResourceUtils.GetString("Language_Unknown_Album"); this.albumArtists = this.GetAlbumArtists(albumData); this.year = albumData.Year.HasValue && albumData.Year.Value > 0 ? albumData.Year.Value.ToString() : string.Empty; this.SortYear = albumData.Year.HasValue ? albumData.Year.Value : 0; this.AlbumKey = albumData.AlbumKey; this.DateAdded = albumData.DateAdded; this.DateFileCreated = albumData.DateFileCreated; }
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(); } } }