public CsvExportercs(string folderPath, string what) { _folder = folderPath; _what = what; if (what == "Apps" || what == "All") { _total += AppServices.Gets().Count; } if (what == "Books" || what == "All") { _total += BookServices.Gets().Count; } if (what == "Games" || what == "All") { _total += GameServices.Gets().Count; } if (what == "Movies" || what == "All") { _total += MovieServices.Gets().Count; } if (what == "Music" || what == "All") { _total += MusicServices.Gets().Count; } if (what == "Nds" || what == "All") { _total += NdsServices.Gets().Count; } if (what == "Series" || what == "All") { _total += SerieServices.Gets().Count; } if (what == "XXX" || what == "All") { _total += XxxServices.Gets().Count; } }
public PdfExporter(string folderPath, string what) { _what = what; _folder = Path.Combine(folderPath, "myCollections_" + _what + ".pdf"); if (what == "Apps" || what == "All") { _total += AppServices.Gets().Count; } if (what == "Books" || what == "All") { _total += BookServices.Gets().Count; } if (what == "Games" || what == "All") { _total += GameServices.Gets().Count; } if (what == "Movies" || what == "All") { _total += MovieServices.Gets().Count; } if (what == "Music" || what == "All") { _total += MusicServices.Gets().Count; } if (what == "Nds" || what == "All") { _total += NdsServices.Gets().Count; } if (what == "Series" || what == "All") { _total += SerieServices.Gets().Count; } if (what == "XXX" || what == "All") { _total += XxxServices.Gets().Count; } }
public int GetCountExportItems(string item) { if (item == AppTitle || item == AllTitle) { _totalCount += AppServices.Gets().Count; } if (item == BookTitle || item == AllTitle) { _totalCount += BookServices.Gets().Count; } if (item == GameTitle || item == AllTitle) { _totalCount += GameServices.Gets().Count; } if (item == MovieTitle || item == AllTitle) { _totalCount += MovieServices.Gets().Count; } if (item == MusicTitle || item == AllTitle) { _totalCount += MusicServices.Gets().Count; } if (item == NdsTitle || item == AllTitle) { _totalCount += NdsServices.Gets().Count; } if (item == SeriesTitle || item == AllTitle) { _totalCount += SerieServices.Gets().Count; } if (item == XxxTitle || item == AllTitle) { _totalCount += XxxServices.Gets().Count; } return(_totalCount); }
private void AddMusic(string[] strTemp, string strTitle, string strFileName, string strFilePath) { bool isFolder = false; bool isEmptyFolder = false; FileInfo file = new FileInfo(Path.Combine(strFilePath, strFileName)); Hashtable tags = new Hashtable(); Media objMedia = MediaServices.Get(_strMediaName.Trim(), _mediaType, _path, _cleanTitle, _entityType, _patternType, _useSubFolder, _bGetImage, _bParseNfo, true); if (file.Exists == false && string.IsNullOrWhiteSpace(file.Extension)) { if (Directory.Exists(file.FullName)) { DirectoryInfo folder = new DirectoryInfo(file.FullName); FileInfo[] files = folder.GetFiles("*.mp3", SearchOption.TopDirectoryOnly); files = files.Concat(folder.GetFiles("*.flc", SearchOption.TopDirectoryOnly)).ToArray(); files = files.Concat(folder.GetFiles("*.flac", SearchOption.TopDirectoryOnly)).ToArray(); if (files.Any()) { file = files[0]; isFolder = true; } else { isEmptyFolder = true; } } } if (isEmptyFolder == false) { if (Dal.GetInstance.GetMusics(objMedia.Name, strFilePath, strFileName) == null) { switch (file.Extension) { case ".mp3": IID3v2 objMp3Tag = ID3v2Helper.CreateID3v2(file.FullName); tags.Add("Title", objMp3Tag.Title); if (string.IsNullOrWhiteSpace(objMp3Tag.Album) == false) { tags.Add("Album", objMp3Tag.Album); } if (isFolder == false && objMp3Tag.LengthMilliseconds != null) { tags.Add("Length", objMp3Tag.LengthMilliseconds); } if (objMp3Tag.PictureList.Count > 0) { tags.Add("Cover", objMp3Tag.PictureList[0].PictureData); } tags.Add("Genre", objMp3Tag.Genre); tags.Add("Artist", objMp3Tag.Artist); break; case ".flac": case ".flc": try { FlacTagger objFlacTag = new FlacTagger(file.FullName); tags.Add("Title", objFlacTag.Title); if (string.IsNullOrWhiteSpace(objFlacTag.Album) == false) { tags.Add("Album", objFlacTag.Album); } if (isFolder == false) { tags.Add("Length", objFlacTag.Length); } if (objFlacTag.Arts.Count > 0) { tags.Add("Cover", objFlacTag.Arts[0].PictureData); } tags.Add("Genre", objFlacTag.Genre); tags.Add("Artist", objFlacTag.Artist); break; } //FIX 2.8.9.0 catch (FileFormatException) { break; } } #region Title if (tags.ContainsKey("Title") == false) { if (string.IsNullOrEmpty(strTitle) == false) { strTitle = strTitle.Replace('_', ' '); strTitle = strTitle.Replace(".MP3", ""); strTitle = strTitle.Replace(".Mp3", ""); strTitle = strTitle.Replace(".flac", ""); strTitle = strTitle.Trim(); strTitle = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(strTitle); tags.Add("Title", strTitle); } } #endregion Music objMusic = new Music(); objMusic.Ressources = new List <Ressource>(); objMusic.Genres = new List <Genre>(); objMusic.Title = strTitle; objMusic.AddedDate = DateTime.Now; objMusic.FileName = strFileName; objMusic.FilePath = strFilePath; if (tags.ContainsKey("Album")) { objMusic.Album = tags["Album"].ToString(); if (isFolder == true && string.IsNullOrWhiteSpace(tags["Album"].ToString()) == false) { objMusic.Title = tags["Album"].ToString(); } } if (tags.ContainsKey("Length")) { objMusic.Runtime = tags["Length"] as int?; } objMusic.Media = objMedia; #region Cover if (_bGetImage == true) { RessourcesServices.AddImage(Util.GetLocalImage(objMusic.FilePath, objMusic.FileName, _bFile), objMusic, true); } else { RessourcesServices.AddImage(tags["Cover"] as byte[], objMusic, true); } #endregion bool bExist = false; if (Dal.GetInstance.GetMusics(objMusic.Media.Name, objMusic.FilePath, objMusic.FileName) != null) { bExist = true; } if (bExist == false) { #region ParseNfo if (_bParseNfo == true) { string errorMessage; MusicServices.ParseNfo(objMusic, out errorMessage); } #endregion #region Artist string strArtistFullName = string.Empty; if (tags.ContainsKey("Artist") == true) { if (tags["Artist"] == null) { if (_mapping != null) { strArtistFullName = Util.ConstructString(strTemp, (string[])_mapping["Artist"], _nbrBaseParsing); } } else { strArtistFullName = tags["Artist"] as string; } } #endregion Dal.GetInstance.AddMusic(objMusic); if (tags.ContainsKey("Genre")) { GenreServices.AddGenres(new[] { tags["Genre"] as string }, objMusic, true); } if (strArtistFullName != null && string.IsNullOrWhiteSpace(strArtistFullName.Trim()) == false) { ArtistServices.AddArtist(strArtistFullName, objMusic); } _intAddedItem++; } else { _intNotAddedItem++; } } } }
private void worker_DoWork_XML(object sender, DoWorkEventArgs e) { try { Total = _selectedNodes.Length; foreach (XElement node in _selectedNodes) { //exit if the user cancels if (_isCancelationPending == true) { return; } Music music = new Music(); music.Title = Util.GetElementValue(node, "Title"); music.Album = Util.GetElementValue(node, "Album"); music.BarCode = Util.GetElementValue(node, "BarCode"); music.Comments = Util.GetElementValue(node, "Comments"); music.FileName = Util.GetElementValue(node, "FileName"); music.FilePath = Util.GetElementValue(node, "FilePath"); #region DateTime DateTime dateValue; if (DateTime.TryParse(Util.GetElementValue(node, "AddedDate"), out dateValue) == true) { music.AddedDate = dateValue; } if (DateTime.TryParse(Util.GetElementValue(node, "ReleaseDate"), out dateValue) == true) { music.ReleaseDate = dateValue; } #endregion #region Bool bool boolValue; if (bool.TryParse(Util.GetElementValue(node, "IsComplete"), out boolValue) == true) { music.IsComplete = boolValue; } if (bool.TryParse(Util.GetElementValue(node, "IsDeleted"), out boolValue) == true) { music.IsDeleted = boolValue; } if (bool.TryParse(Util.GetElementValue(node, "IsHear"), out boolValue) == true) { music.Watched = boolValue; } if (bool.TryParse(Util.GetElementValue(node, "IsWhish"), out boolValue) == true) { music.IsWhish = boolValue; } if (bool.TryParse(Util.GetElementValue(node, "ToBeDeleted"), out boolValue) == true) { music.ToBeDeleted = boolValue; } #endregion #region int int intValue; if (int.TryParse(Util.GetElementValue(node, "BitRate"), out intValue) == true) { music.BitRate = intValue; } if (int.TryParse(Util.GetElementValue(node, "Length"), out intValue) == true) { music.Runtime = intValue; } if (int.TryParse(Util.GetElementValue(node, "Rating"), out intValue) == true) { music.MyRating = intValue; } #endregion #region Media var query = from item in node.Descendants("Media") select item; XElement[] musicNode = query.ToArray(); foreach (XElement media in musicNode) { Media newMedia = MediaServices.Get(Util.GetElementValue(media, "Name"), true); newMedia.Path = Util.GetElementValue(media, "Path"); music.Media = newMedia; } #endregion #region Studio query = from item in node.Descendants("Studio") select item; musicNode = query.ToArray(); foreach (XElement editor in musicNode) { bool isNew; music.Publisher = PublisherServices.GetPublisher(Util.GetElementValue(editor, "Name"), out isNew, "Music_Studio"); if (isNew == true) { Dal.GetInstance.AddPublisher("Music_Studio", music.Publisher); } } #endregion #region Track query = from item in node.Descendants("Track") select item; musicNode = query.ToArray(); foreach (XElement track in musicNode) { MusicServices.AddTracks(new [] { Util.GetElementValue(track, "Title") }, music); } #endregion #region Links query = from item in node.Descendants("Link") select item; musicNode = query.ToArray(); foreach (XElement link in musicNode) { LinksServices.AddLinks(Util.GetElementValue(link, "Path"), music, true); } #endregion #region Types query = from item in node.Descendants("Type") select item; musicNode = query.ToArray(); foreach (XElement type in musicNode) { GenreServices.AddGenres(new[] { Util.GetElementValue(type, "RealName") }, music, true); } #endregion #region Image query = from item in node.Descendants("Ressource") select item; musicNode = query.ToArray(); foreach (XElement images in musicNode) { if (Util.GetElementValue(images, "ResourcesType") == "Image") { bool isDefault = bool.Parse(Util.GetElementValue(images, "IsDefault")); byte[] cover = Convert.FromBase64String(Util.GetElementValue(images, "Value")); if (cover.Length > 0) { RessourcesServices.AddImage(cover, music, isDefault); } } if (Util.GetElementValue(images, "ResourcesType") == "Background") { byte[] cover = Convert.FromBase64String(Util.GetElementValue(images, "Value")); if (cover.Length > 0) { RessourcesServices.AddBackground(cover, music); } } } #endregion #region Artist query = from item in node.Descendants("Artist") select item; XElement[] artistNode = query.ToArray(); foreach (XElement artist in artistNode) { bool isNew; string fullname = Util.GetElementValue(artist, "FulleName"); Artist newArtist = ArtistServices.Get(fullname, out isNew); if (string.IsNullOrWhiteSpace(newArtist.Aka)) { newArtist.Aka = Util.GetElementValue(artist, "Aka"); } if (string.IsNullOrWhiteSpace(newArtist.Bio)) { newArtist.Bio = Util.GetElementValue(artist, "Bio"); } if (newArtist.BirthDay == null && DateTime.TryParse(Util.GetElementValue(artist, "BirthDay"), out dateValue) == true) { newArtist.BirthDay = dateValue; } if (string.IsNullOrWhiteSpace(newArtist.Breast)) { newArtist.Breast = Util.GetElementValue(artist, "Breast"); } if (string.IsNullOrWhiteSpace(newArtist.Ethnicity)) { newArtist.Ethnicity = Util.GetElementValue(artist, "Ethnicity"); } if (string.IsNullOrWhiteSpace(newArtist.FirstName)) { newArtist.FirstName = Util.GetElementValue(artist, "FirstName"); } if (string.IsNullOrWhiteSpace(newArtist.LastName)) { newArtist.LastName = Util.GetElementValue(artist, "LastName"); } if (newArtist.Picture == null) { newArtist.Picture = Convert.FromBase64String(Util.GetElementValue(artist, "Picture")); } if (string.IsNullOrWhiteSpace(newArtist.PlaceBirth)) { newArtist.PlaceBirth = Util.GetElementValue(artist, "PlaceBirth"); } if (string.IsNullOrWhiteSpace(newArtist.WebSite)) { newArtist.WebSite = Util.GetElementValue(artist, "WebSite"); } if (string.IsNullOrWhiteSpace(newArtist.YearsActive)) { newArtist.YearsActive = Util.GetElementValue(artist, "YearsActive"); } query = from item in artist.Descendants("Credit") select item; XElement[] creditsNode = query.ToArray(); foreach (XElement artistCredit in creditsNode) { ArtistCredits artistCredits = new ArtistCredits(); artistCredits.Title = Util.GetElementValue(artistCredit, "Title"); artistCredits.BuyLink = Util.GetElementValue(artistCredit, "BuyLink"); artistCredits.EntityType = EntityType.Movie; artistCredits.Notes = Util.GetElementValue(artistCredit, "Notes"); DateTime releaseDate; if (DateTime.TryParse(Util.GetElementValue(artistCredit, "ReleaseDate"), out releaseDate) == true) { artistCredits.ReleaseDate = releaseDate; } if (string.IsNullOrWhiteSpace(artistCredits.Title) == false && string.IsNullOrWhiteSpace(newArtist.FulleName) == false) { if (Dal.GetInstance.GetArtistCredit(artistCredits.Title, newArtist.FulleName) == null) { newArtist.ArtistCredits.Add(artistCredits); } } } ArtistServices.SaveArtist(newArtist, music); } #endregion Dal.GetInstance.AddMusic(music); _intAddedItem++; Current++; } } catch (Exception ex) { Util.LogException(ex); } }
private void worker_DoWork(object sender, DoWorkEventArgs e) { try { Total = _selectedItems.Count; foreach (string item in _selectedItems) { //exit if the user cancels if (_isCancelationPending == true) { return; } if (string.IsNullOrWhiteSpace(item) == false) { string[] attributes = item.Split(';'); if (string.IsNullOrWhiteSpace(attributes[1]) == false) { Music music = new Music(); music.Title = attributes[1]; music.Media = new Media(); music.Media.Id = _mediaId; music.AddedDate = DateTime.Now; ArtistServices.AddArtist(attributes[0], music); GenreServices.AddGenres(new List <string> { attributes[2] }, music, true); music.Comments = attributes[4]; List <string> tracks = new List <string>(); for (int i = 5; i < attributes.Length; i++) { if (string.IsNullOrWhiteSpace(attributes[i]) == false) { tracks.Add(attributes[i]); } } MusicServices.AddTracks(tracks, music); Music bExist = null; if (music.Artists != null && music.Artists.Count > 0) { bExist = Dal.GetInstance.GetMusics(_mediaName, music.Title, music.Artists.First().FirstName, music.Artists.First().LastName); } if (bExist == null) { Dal.GetInstance.AddMusic(music); _intAddedItem++; } else { _intNotAddedItem++; } } } Current++; } } catch (Exception ex) { Util.LogException(ex); } }
private void ExportMusics(string path, string separator, string newline) { try { IList items = MusicServices.Gets(); for (int i = 0; i < items.Count; i++) { Music entity = items[i] as Music; CommonServices.GetChild(entity); if (_isCancelationPending == true) { break; } StringBuilder row = new StringBuilder(); row.Append("Music" + separator); if (entity != null) { row.Append(entity.Title + separator); if (entity.Publisher != null) { row.Append(entity.Publisher.Name + separator); } else { row.Append(string.Empty + separator); } if (entity.ReleaseDate != null) { row.Append(entity.ReleaseDate.Value.ToShortDateString() + separator); } else { row.Append(string.Empty + separator); } if (entity.MyRating != null) { row.Append(entity.MyRating + separator); } else { row.Append(string.Empty + separator); } //FIX 2.8.9.0 string description = string.Empty; if (entity.Comments != null) { description = entity.Comments.Replace(separator, " "); } row.Append(description + separator); StringBuilder types = new StringBuilder(); foreach (Genre item in entity.Genres) { if (types.Length == 0) { types.Append(item.DisplayName); } else { types.Append("," + item.DisplayName); } } row.Append(types + separator); row.Append(entity.AddedDate.ToShortDateString() + separator); if (entity.Media != null) { row.Append(entity.Media.Name + separator); } else { row.Append(string.Empty + separator); } row.Append(entity.FilePath + separator); row.Append(entity.FileName + separator); types = new StringBuilder(); foreach (Artist item in entity.Artists) { if (types.Length == 0) { types.Append(item.FulleName); } else { types.Append("," + item.FulleName); } } row.Append(types + separator); } File.AppendAllText(path, row + newline, Encoding.UTF8); _intAddedItem++; Current++; items[i] = null; } } catch (Exception ex) { Util.LogException(ex); throw; } }
private void ExportMusics(Document doc) { try { WriteChapter(doc, "Musics"); IList items = MusicServices.Gets(); PdfPTable mainTable = new PdfPTable(1); for (int i = 0; i < items.Count; i++) { Music entity = items[i] as Music; CommonServices.GetChild(entity); if (_isCancelationPending == true) { break; } if (entity != null) { Ressource cover = entity.Ressources.FirstOrDefault(x => x.IsDefault == true); byte[] image = null; if (cover != null) { image = cover.Value; } PdfPTable table = WriteCover(image, entity.Title); StringBuilder types = new StringBuilder(); foreach (Artist item in entity.Artists) { if (types.Length == 0) { types.Append(item.FulleName); } else { types.Append("," + item.FulleName); } } string editorName = string.Empty; if (entity.Publisher != null) { editorName = entity.Publisher.Name; } PdfPTable text = WriteFirstRow(entity.Title, types.ToString(), editorName); DateTime releasedate = DateTime.MinValue; if (entity.ReleaseDate != null) { releasedate = (DateTime)entity.ReleaseDate; } int rating = 0; if (entity.MyRating != null) { rating = (int)entity.MyRating; } WriteSecondRow(releasedate, rating, text); WriteDescription(entity.Comments, text); types = new StringBuilder(); foreach (Genre item in entity.Genres) { if (types.Length == 0) { types.Append(item.DisplayName); } else { types.Append("," + item.DisplayName); } } WriteTypeRow(types.ToString(), entity.AddedDate.ToShortDateString(), text); string media = string.Empty; if (entity.Media != null) { media = entity.Media.Name; } WriteMediaInfo(media, entity.FilePath, entity.FileName, text); table.AddCell(text); //table.SplitRows = false; PdfPCell cell = new PdfPCell(table); cell.Border = 0; cell.BorderColor = iTextSharp.text.BaseColor.WHITE; mainTable.AddCell(cell); } _intAddedItem++; Current++; items[i] = null; } doc.Add(mainTable); doc.NewPage(); } catch (Exception ex) { Util.LogException(ex); throw; } }
private void UpdateItem(ThumbItem thumbItem) { try { if (thumbItem == null) { return; } bool?saved = false; switch (thumbItem.EType) { case EntityType.Apps: AppsUpdate objAppsDetails = new AppsUpdate(); objAppsDetails.ItemsId = thumbItem.Id; saved = objAppsDetails.ShowDialog(); if (saved == true) { Apps apps = new AppServices().Get(thumbItem.Id) as Apps; FileThumbItem(thumbItem, apps); } break; case EntityType.Artist: Task.Factory.StartNew(() => Util.NotifyEvent("ArtistDetail:" + thumbItem.Name)); ArtistDetail artistDetails = new ArtistDetail(thumbItem.Name, thumbItem.EType); saved = artistDetails.ShowDialog(); break; case EntityType.Books: BookUpdate objBookDetails = new BookUpdate(); objBookDetails.ItemsId = thumbItem.Id; saved = objBookDetails.ShowDialog(); if (saved == true) { Books books = new BookServices().Get(thumbItem.Id) as Books; FileThumbItem(thumbItem, books); } break; case EntityType.Games: GameUpdate objGameDetails = new GameUpdate(); objGameDetails.ItemsId = thumbItem.Id; saved = objGameDetails.ShowDialog(); if (saved == true) { Gamez games = new GameServices().Get(thumbItem.Id) as Gamez; FileThumbItem(thumbItem, games); } break; case EntityType.Movie: MovieUpdate objMovieDetails = new MovieUpdate(); objMovieDetails.ItemsId = thumbItem.Id; saved = objMovieDetails.ShowDialog(); if (saved == true) { Movie movie = new MovieServices().Get(thumbItem.Id) as Movie; FileThumbItem(thumbItem, movie); } break; case EntityType.Music: MusicUpdate objMusicDetails = new MusicUpdate(); objMusicDetails.ItemsId = thumbItem.Id; saved = objMusicDetails.ShowDialog(); if (saved == true) { Music music = new MusicServices().Get(thumbItem.Id) as Music; FileThumbItem(thumbItem, music); } break; case EntityType.Nds: NdsUpdate objNdsDetails = new NdsUpdate(); objNdsDetails.ItemsId = thumbItem.Id; saved = objNdsDetails.ShowDialog(); if (saved == true) { Nds nds = new NdsServices().Get(thumbItem.Id) as Nds; FileThumbItem(thumbItem, nds); } break; case EntityType.Series: Main main = Util.TryFindParent <Main>(this); main.NewSeasonAdded = false; SerieUpdate objSerieDetails = new SerieUpdate(); objSerieDetails.ItemsId = thumbItem.Id; saved = objSerieDetails.ShowDialog(); main.NewSeasonAdded = objSerieDetails.NewSeasonAdded; if (objSerieDetails.NewSeasonAdded == true) { saved = true; } if (saved == true) { SeriesSeason serie = new SerieServices().Get(thumbItem.Id) as SeriesSeason; FileThumbItem(thumbItem, serie); } break; case EntityType.XXX: XxxUpdate objXxxDetails = new XxxUpdate(); objXxxDetails.ItemsId = thumbItem.Id; saved = objXxxDetails.ShowDialog(); if (saved == true) { XXX xxx = new XxxServices().Get(thumbItem.Id) as XXX; FileThumbItem(thumbItem, xxx); } break; } _currentItem = thumbItem; if (saved == true) { RoutedEventArgs args = new RoutedEventArgs(UpdateEvent); RaiseEvent(args); Cursor = null; ShowVisibleItems(MainStack); } } catch (Exception ex) { CatchException(ex); } }