Пример #1
0
        public static void DeleteSelectedListBoxItem(IList lstSelectedItems)
        {
            foreach (ListBoxItem item in lstSelectedItems)
            {
                IMyCollectionsData data = item.DataContext as IMyCollectionsData;

                if (data != null)
                {
                    switch (data.ObjectType)
                    {
                    case EntityType.Apps:
                        AppServices.Delete(data.Id);
                        break;

                    case EntityType.Artist:
                        ArtistServices.Delete(data.Id);
                        break;

                    case EntityType.Books:
                        BookServices.Delete(data.Id);
                        break;

                    case EntityType.Games:
                        GameServices.Delete(data.Id);
                        break;

                    case EntityType.Movie:
                        MovieServices.Delete(data.Id);
                        break;

                    case EntityType.Music:
                        MusicServices.Delete(data.Id);
                        break;

                    case EntityType.Nds:
                        NdsServices.Delete(data.Id);
                        break;

                    case EntityType.Series:
                        SerieServices.Delete(data.Id);
                        break;

                    case EntityType.XXX:
                        XxxServices.Delete(data.Id);
                        break;
                    }
                }
            }
        }
Пример #2
0
        public static void DeleteSelected(IList lstSelectedItems)
        {
            foreach (ThumbItem item in lstSelectedItems)
            {
                switch (item.EType)
                {
                case EntityType.Apps:
                    AppServices.Delete(item.Id);
                    break;

                case EntityType.Artist:
                    ArtistServices.Delete(item.Id);
                    break;

                case EntityType.Books:
                    BookServices.Delete(item.Id);
                    break;

                case EntityType.Games:
                    GameServices.Delete(item.Id);
                    break;

                case EntityType.Movie:
                    MovieServices.Delete(item.Id);
                    break;

                case EntityType.Music:
                    MusicServices.Delete(item.Id);
                    break;

                case EntityType.Nds:
                    NdsServices.Delete(item.Id);
                    break;

                case EntityType.Series:
                    SerieServices.Delete(item.Id);
                    break;

                case EntityType.XXX:
                    XxxServices.Delete(item.Id);
                    break;
                }
            }
        }
Пример #3
0
        private static void UpdateArtist(IMyCollectionsData entity, IEnumerable <string> artistName)
        {
            if (entity.Artists != null && entity.Artists.Any())
            {
                foreach (Artist artist in entity.Artists)
                {
                    Dal.GetInstance.UnlinkArtist(artist, entity);
                }
            }

            if (artistName != null)
            {
                ArtistServices.AddArtists(artistName, entity);
            }
            else if (entity.Artists != null)
            {
                foreach (Artist artist in entity.Artists)
                {
                    ArtistServices.SaveArtist(artist, entity);
                }
            }
        }
Пример #4
0
        public static void Update(IMyCollectionsData entity)
        {
            try
            {
                LinksServices.DeleteLinks(entity);
                #region Publisher

                if (entity.Publisher != null)
                {
                    if (String.IsNullOrWhiteSpace(entity.Publisher.Name) == false)
                    {
                        bool isNew;
                        switch (entity.ObjectType)
                        {
                        case EntityType.Nds:
                        case EntityType.Games:
                        case EntityType.Books:
                        case EntityType.Apps:
                            entity.Publisher = PublisherServices.GetPublisher(entity.Publisher.Name, out isNew, "App_Editor");
                            if (isNew == true)
                            {
                                Dal.GetInstance.AddPublisher("App_Editor", entity.Publisher);
                            }
                            break;

                        case EntityType.Series:
                        case EntityType.Movie:
                            entity.Publisher = PublisherServices.GetPublisher(entity.Publisher.Name, out isNew, "Movie_Studio");
                            if (isNew == true)
                            {
                                Dal.GetInstance.AddPublisher("Movie_Studio", entity.Publisher);
                            }
                            break;

                        case EntityType.Music:
                            entity.Publisher = PublisherServices.GetPublisher(entity.Publisher.Name, out isNew, "Music_Studio");
                            if (isNew == true)
                            {
                                Dal.GetInstance.AddPublisher("Music_Studio", entity.Publisher);
                            }
                            break;

                        case EntityType.XXX:
                            entity.Publisher = PublisherServices.GetPublisher(entity.Publisher.Name, out isNew, "XXX_Studio");
                            if (isNew == true)
                            {
                                Dal.GetInstance.AddPublisher("XXX_Studio", entity.Publisher);
                            }

                            break;
                        }
                    }
                }

                #endregion

                switch (entity.ObjectType)
                {
                case EntityType.Apps:
                    Dal.GetInstance.AddApps(entity as Apps);
                    break;

                case EntityType.Books:
                    Dal.GetInstance.AddBook(entity as Books);
                    break;

                case EntityType.Games:
                    Dal.GetInstance.AddGame(entity as Gamez);
                    break;

                case EntityType.Movie:
                    Dal.GetInstance.AddMovie(entity as Movie);
                    break;

                case EntityType.Music:
                    if (MySettings.AutoUpdateID3 == true)
                    {
                        Task.Factory.StartNew(() => MusicServices.UpdateId3(entity as Music));
                    }
                    Dal.GetInstance.AddMusic(entity as Music);
                    Dal.GetInstance.AddTracks(entity as Music);
                    break;

                case EntityType.Nds:
                    Dal.GetInstance.AddNds(entity as Nds);
                    break;

                case EntityType.Series:
                    Dal.GetInstance.AddSeriesSeason(entity as SeriesSeason);
                    break;

                case EntityType.XXX:
                    Dal.GetInstance.AddXxx(entity as XXX);
                    break;
                }

                #region Links
                LinksServices.AddLinks(entity.Links, entity, true);
                #endregion
                RessourcesServices.UpdateRessources(entity);
                #region Artist
                if (entity.Artists != null && entity.Artists.Any())
                {
                    foreach (Artist artist in entity.Artists)
                    {
                        Dal.GetInstance.UnlinkArtist(artist, entity);
                    }
                }

                if (entity.Artists != null)
                {
                    foreach (Artist artist in entity.Artists)
                    {
                        ArtistServices.SaveArtist(artist, entity);
                    }
                }
                #endregion
                #region Genres
                Dal.GetInstance.UnlinkGenre(entity);
                GenreServices.AddGenres(entity.Genres, entity, true);
                #endregion
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
                throw;
            }
        }
Пример #5
0
        public static bool Fill(Hashtable objResults, Movie objEntity)
        {
            try
            {
                bool bAllfind = true;

                if (objResults != null)
                {
                    #region Actors

                    if (objResults.ContainsKey("Actors"))
                    {
                        ArtistServices.AddArtist((List <Artist>)objResults["Actors"], objEntity);
                    }
                    if (objEntity.Artists.Count == 0)
                    {
                        bAllfind = false;
                    }

                    #endregion
                    #region Audios

                    if (objResults.ContainsKey("Audios"))
                    {
                        AudioServices.Add((List <Audio>)objResults["Audios"], objEntity);
                    }

                    #endregion
                    #region Background

                    if (objResults.ContainsKey("Background"))
                    {
                        if (objResults["Background"] != null)
                        {
                            RessourcesServices.AddBackground(Util.GetImage(objResults["Background"].ToString()), objEntity);
                        }
                    }

                    #endregion
                    #region BarCode

                    if (objResults.ContainsKey("BarCode"))
                    {
                        if (string.IsNullOrEmpty(objEntity.BarCode) == true)
                        {
                            objEntity.BarCode = objResults["BarCode"].ToString().Trim();
                        }
                    }

                    #endregion
                    #region Comments

                    if (objResults.ContainsKey("Comments"))
                    {
                        if (string.IsNullOrEmpty(objEntity.Tagline) == true)
                        {
                            objEntity.Tagline = objResults["Comments"].ToString().Trim();
                        }
                    }

                    #endregion
                    #region Country

                    if (objResults.ContainsKey("Country"))
                    {
                        if (string.IsNullOrEmpty(objEntity.Country) == true)
                        {
                            if (objResults["Country"] != null)
                            {
                                objEntity.Country = objResults["Country"].ToString().Trim();
                            }
                        }
                    }

                    #endregion
                    #region Description

                    if (objResults.ContainsKey("Description"))
                    {
                        if (string.IsNullOrEmpty(objEntity.Description) == true)
                        {
                            objEntity.Description = objResults["Description"].ToString().Trim();
                        }
                    }
                    if (string.IsNullOrEmpty(objEntity.Description))
                    {
                        bAllfind = false;
                    }

                    #endregion
                    #region Director

                    if (objResults.ContainsKey("Director") && objResults["Director"] != null)
                    {
                        if (objResults["Director"].GetType() == typeof(List <Artist>))
                        {
                            ArtistServices.AddDirector((List <Artist>)objResults["Director"], objEntity);
                        }
                    }

                    #endregion
                    #region Format

                    if (objResults.ContainsKey("Format"))
                    {
                        if (objEntity.FileFormat == null)
                        {
                            objEntity.FileFormat = objResults["Format"] as FileFormat;
                        }
                    }

                    #endregion
                    #region DisplayAspectRatio

                    if (objResults.ContainsKey("DisplayAspectRatio"))
                    {
                        if (objEntity.AspectRatio == null || objEntity.AspectRatio.IsOld == true || string.IsNullOrEmpty(objEntity.AspectRatio.Name))
                        {
                            objEntity.AspectRatio = objResults["DisplayAspectRatio"] as AspectRatio;
                        }
                    }

                    #endregion
                    #region Genres

                    if (objResults.ContainsKey("Types"))
                    {
                        GenreServices.AddGenres((List <string>)objResults["Types"], objEntity, false);
                    }
                    if (objEntity.Genres.Count == 0)
                    {
                        bAllfind = false;
                    }

                    #endregion
                    #region Image

                    int index;
                    if (objResults.ContainsKey("Image"))
                    {
                        if (objResults["Image"] != null)
                        {
                            if (!string.IsNullOrWhiteSpace(objResults["Image"].ToString()))
                            {
                                byte[] objImage     = Util.GetImage(objResults["Image"].ToString());
                                byte[] defaultCover = RessourcesServices.GetDefaultCover(objEntity, out index);
                                if (objImage != null)
                                {
                                    if (defaultCover == null || objEntity.RemoveCover == true ||
                                        defaultCover.LongLength < objImage.LongLength)
                                    {
                                        if (objResults["Image"] != null)
                                        {
                                            RessourcesServices.AddImage(Util.GetImage(objResults["Image"].ToString()), objEntity, true);
                                            objEntity.RemoveCover = false;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (RessourcesServices.GetDefaultCover(objEntity, out index) == null)
                    {
                        bAllfind = false;
                    }

                    #endregion
                    #region Links

                    if (objResults.ContainsKey("Links"))
                    {
                        LinksServices.AddLinks(objResults["Links"].ToString(), objEntity, false);
                    }
                    if (objEntity.Links.Count == 0)
                    {
                        bAllfind = false;
                    }

                    #endregion
                    #region OriginalTitle

                    if (objResults.ContainsKey("OriginalTitle"))
                    {
                        if (string.IsNullOrEmpty(objEntity.OriginalTitle) == true)
                        {
                            objEntity.OriginalTitle = objResults["OriginalTitle"].ToString().Trim();
                        }
                    }

                    #endregion
                    #region Rated

                    if (objResults.ContainsKey("Rated"))
                    {
                        if (string.IsNullOrEmpty(objEntity.Rated))
                        {
                            switch (objResults["Rated"].ToString().Trim())
                            {
                            case "R":
                                objEntity.Rated = 16.ToString(CultureInfo.InvariantCulture);
                                break;

                            case "NC_17":
                            case "NC-17":
                                objEntity.Rated = 18.ToString(CultureInfo.InvariantCulture);
                                break;

                            case "PG_13":
                            case "PG-13":
                                objEntity.Rated = 13.ToString(CultureInfo.InvariantCulture);
                                break;

                            case "PG":
                                objEntity.Rated = 8.ToString(CultureInfo.InvariantCulture);
                                break;

                            case "G":
                                objEntity.Rated = 0.ToString(CultureInfo.InvariantCulture);
                                break;
                            }
                        }
                    }

                    #endregion
                    #region PublicRating
                    //FIX 2.8.4.0
                    if (objResults.ContainsKey("Rating") && objResults["Rating"] != null)
                    {
                        objEntity.Imdb = objResults["Rating"].ToString().Trim();
                    }

                    if (objResults.ContainsKey("AlloCine"))
                    {
                        objEntity.AlloCine = objResults["AlloCine"].ToString().Trim();
                    }
                    objEntity.PublicRating = CalculateMovieRating(objEntity);

                    if (objEntity.PublicRating == null)
                    {
                        bAllfind = false;
                    }

                    #endregion
                    #region ReleaseDate

                    if (objResults.ContainsKey("Released"))
                    {
                        if (objEntity.ReleaseDate == null)
                        {
                            objEntity.ReleaseDate = objResults["Released"] as DateTime?;
                        }
                    }

                    if (objEntity.ReleaseDate == null)
                    {
                        bAllfind = false;
                    }

                    #endregion
                    #region RunTime

                    if (objResults.ContainsKey("Runtime"))
                    {
                        if (objEntity.Runtime == null || objEntity.Runtime == 0)
                        {
                            objEntity.Runtime = objResults["Runtime"] as int?;
                        }
                    }
                    if (objEntity.Runtime == null || objEntity.Runtime == 0)
                    {
                        bAllfind = false;
                    }

                    #endregion
                    #region Publisher

                    if (objResults.ContainsKey("Studio"))
                    {
                        bool isNew;
                        if (objEntity.Publisher == null)
                        {
                            objEntity.Publisher = PublisherServices.GetPublisher(objResults["Studio"].ToString().Trim(), out isNew, "Movie_Studio");
                        }
                    }

                    #endregion
                    #region Subs

                    if (objResults.ContainsKey("Subs"))
                    {
                        SubTitleServices.Add((List <string>)objResults["Subs"], objEntity);
                    }

                    #endregion
                    #region Title

                    if (objResults.ContainsKey("Title") &&
                        (string.IsNullOrWhiteSpace(objEntity.Title) || MySettings.RenameFile == true))
                    {
                        objEntity.Title = objResults["Title"].ToString();
                        if (MySettings.RenameFile == true &&
                            string.IsNullOrWhiteSpace(objEntity.FileName) == false)
                        {
                            objEntity.FileName = Util.RenameFile(objEntity.Title, objEntity.FileName, objEntity.FilePath);
                        }
                    }
                    if (string.IsNullOrWhiteSpace(objEntity.Title))
                    {
                        bAllfind = false;
                    }

                    #endregion
                }
                else
                {
                    bAllfind = false;
                }

                objEntity.IsComplete = bAllfind;
                return(bAllfind);
            }
            catch (Exception ex)
            {
                if (string.IsNullOrWhiteSpace(objEntity.Title) == false)
                {
                    Util.LogException(ex, objEntity.Title);
                }
                else
                {
                    Util.LogException(ex);
                }
                return(false);
            }
        }
Пример #6
0
        public static Books Fill(Hashtable objResults, Books objEntity, ref bool bAllfind)
        {
            try
            {
                bAllfind = true;
                if (objResults != null)
                {
                    #region Author

                    if (objResults.ContainsKey("Author"))
                    {
                        Artist artist = (Artist)objResults["Author"];

                        if (objEntity.Artists == null)
                        {
                            objEntity.Artists = new List <Artist>();
                        }

                        if (objEntity.Artists.Count == 0 || objEntity.Artists.Any(x => x.IsOld == false) == false)
                        {
                            if (artist != null)
                            {
                                if (artist.Job == null)
                                {
                                    artist.Job = ArtistServices.GetJob("Author");
                                }

                                objEntity.Artists.Add(artist);
                            }
                        }
                    }

                    if (objEntity.Artists.Count == 0)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Background
                    if (objResults.ContainsKey("Background"))
                    {
                        if (objResults["Background"] != null)
                        {
                            RessourcesServices.AddBackground(Util.GetImage(objResults["Background"].ToString()), objEntity);
                        }
                    }
                    #endregion
                    #region BarCode
                    if (objResults.ContainsKey("BarCode"))
                    {
                        if (string.IsNullOrEmpty(objEntity.BarCode) == true)
                        {
                            objEntity.BarCode = objResults["BarCode"].ToString().Trim();
                        }
                    }
                    else if (string.IsNullOrEmpty(objEntity.BarCode) == true)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Comments

                    if (objResults.ContainsKey("Comments"))
                    {
                        if (string.IsNullOrEmpty(objEntity.Comments) == true)
                        {
                            objEntity.Comments = objResults["Comments"].ToString().Trim();
                        }
                    }
                    else if (string.IsNullOrEmpty(objEntity.Comments) == true)
                    {
                        bAllfind = false;
                    }

                    #endregion
                    #region Description
                    if (objResults.ContainsKey("Description"))
                    {
                        if (string.IsNullOrEmpty(objEntity.Description) == true)
                        {
                            objEntity.Description = objResults["Description"].ToString().Trim();
                        }
                    }
                    else if (string.IsNullOrEmpty(objEntity.Description) == true)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Format
                    if (objResults.ContainsKey("Format"))
                    {
                        if (objEntity.FileFormat == null)
                        {
                            objEntity.FileFormat = GetFormat(objResults["Format"].ToString().Trim(), false);
                        }
                    }
                    #endregion
                    #region Publisher
                    if (objResults.ContainsKey("Editor"))
                    {
                        bool isNew;
                        if (objEntity.Publisher == null)
                        {
                            objEntity.Publisher = PublisherServices.GetPublisher(objResults["Editor"].ToString().Trim(), out isNew, "App_Editor");
                        }
                    }
                    #endregion
                    #region Image
                    int index;
                    if (objResults.ContainsKey("Image"))
                    {
                        if (objResults["Image"] != null)
                        {
                            if (!string.IsNullOrWhiteSpace(objResults["Image"].ToString()))
                            {
                                byte[] objImage     = Util.GetImage(objResults["Image"].ToString());
                                byte[] defaultCover = RessourcesServices.GetDefaultCover(objEntity, out index);
                                if (objImage != null)
                                {
                                    if (defaultCover == null || objEntity.RemoveCover == true || defaultCover.LongLength < objImage.LongLength)
                                    {
                                        if (objResults["Image"] != null)
                                        {
                                            RessourcesServices.AddImage(Util.GetImage(objResults["Image"].ToString()), objEntity, true);
                                            objEntity.RemoveCover = false;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (RessourcesServices.GetDefaultCover(objEntity, out index) == null)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region ISBN
                    if (objResults.ContainsKey("ISBN"))
                    {
                        if (string.IsNullOrEmpty(objEntity.Isbn) == true)
                        {
                            objEntity.Isbn = objResults["ISBN"].ToString().Trim();
                        }
                    }
                    else if (string.IsNullOrEmpty(objEntity.Isbn) == true)
                    {
                        bAllfind = false;
                    }

                    #endregion
                    #region Language
                    if (objResults.ContainsKey("Language"))
                    {
                        if (objEntity.Language == null)
                        {
                            objEntity.Language = LanguageServices.GetLanguage(objResults["Language"].ToString().Trim(), false);
                        }
                    }
                    #endregion
                    #region Links
                    if (objResults.ContainsKey("Links"))
                    {
                        LinksServices.AddLinks(objResults["Links"].ToString().Trim(), objEntity, false);
                    }
                    else if (objEntity.Genres.Count == 0)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Pages
                    if (objResults.ContainsKey("Pages"))
                    {
                        if (objEntity.NbrPages == 0)
                        {
                            int intNbrPages;
                            if (int.TryParse(objResults["Pages"].ToString(), out intNbrPages) == true)
                            {
                                objEntity.NbrPages = intNbrPages;
                            }
                        }
                    }
                    #endregion
                    #region ReleaseDate
                    if (objResults.ContainsKey("Released"))
                    {
                        if (objEntity.ReleaseDate == null &&
                            objResults["Released"].ToString().Trim().IndexOf("inconnue",
                                                                             StringComparison.OrdinalIgnoreCase) == -1)
                        {
                            string strDate = objResults["Released"].ToString().Trim();
                            if (strDate.Length < 10)
                            {
                                if (strDate.Length == 4)
                                {
                                    DateTime objTemp =
                                        new DateTime(Convert.ToInt32(strDate, CultureInfo.InvariantCulture), 1, 1);
                                    objEntity.ReleaseDate = objTemp;
                                }
                                else
                                {
                                    DateTime objTmp;
                                    if (DateTime.TryParse(objResults["Released"].ToString(), out objTmp) == true)
                                    {
                                        objEntity.ReleaseDate = objTmp;
                                    }
                                }
                            }
                            else
                            {
                                DateTime objTmp;
                                if (DateTime.TryParse(objResults["Released"].ToString(), out objTmp) == true)
                                {
                                    objEntity.ReleaseDate = objTmp;
                                }
                            }
                        }
                    }
                    else if (objEntity.ReleaseDate == null)
                    {
                        bAllfind = false;
                    }

                    #endregion
                    #region Rating

                    if (objResults.ContainsKey("Rating"))
                    {
                        if (objEntity.PublicRating == null)
                        {
                            double intRating;
                            if (double.TryParse(objResults["Rating"].ToString(), out intRating) == true)
                            {
                                objEntity.PublicRating = intRating;
                            }
                        }
                    }
                    if (objEntity.PublicRating == null)
                    {
                        bAllfind = false;
                    }

                    #endregion
                    #region Title
                    if (objResults.ContainsKey("Title") && (string.IsNullOrWhiteSpace(objEntity.Title) || MySettings.RenameFile == true))
                    {
                        objEntity.Title = objResults["Title"].ToString();
                        if (MySettings.RenameFile == true && string.IsNullOrWhiteSpace(objEntity.FileName) == false)
                        {
                            objEntity.FileName = Util.RenameFile(objEntity.Title, objEntity.FileName, objEntity.FilePath);
                        }
                    }
                    if (string.IsNullOrWhiteSpace(objEntity.Title))
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Types
                    if (objResults.ContainsKey("Types"))
                    {
                        GenreServices.AddGenres((IList <string>)objResults["Types"], objEntity, false);
                    }
                    if (objEntity.Genres.Count == 0)
                    {
                        bAllfind = false;
                    }
                    #endregion
                }
                else
                {
                    bAllfind = false;
                }

                objEntity.IsComplete = bAllfind;
                return(objEntity);
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
                return(objEntity);
            }
        }
Пример #7
0
        public static bool Fill(Hashtable objResults, XXX objEntity)
        {
            try
            {
                bool bAllfind = true;
                if (objResults != null)
                {
                    if (objResults.Count > 0)
                    {
                        #region Actors
                        if (objResults.ContainsKey("Actors"))
                        {
                            ArtistServices.AddArtist((List <Artist>)objResults["Actors"], objEntity);
                        }

                        if (objEntity.Artists.Count == 0)
                        {
                            bAllfind = false;
                        }
                        #endregion
                        #region Audios

                        if (objResults.ContainsKey("Audios"))
                        {
                            AudioServices.Add((List <Audio>)objResults["Audios"], objEntity);
                        }

                        #endregion
                        #region Background
                        if (objResults.ContainsKey("Background"))
                        {
                            if (objResults["Background"] != null)
                            {
                                RessourcesServices.AddBackground(Util.GetImage(objResults["Background"].ToString(), objResults["Links"].ToString().Trim()), objEntity);
                            }
                        }
                        #endregion
                        #region Comments
                        if (objResults.ContainsKey("Comments"))
                        {
                            if (string.IsNullOrEmpty(objEntity.Comments) == true)
                            {
                                objEntity.Description = objResults["Comments"].ToString().Trim();
                            }
                        }
                        #endregion
                        #region Country
                        if (objResults.ContainsKey("Country"))
                        {
                            objEntity.Country = (string)objResults["Country"];
                        }
                        #endregion
                        #region Description
                        if (objResults.ContainsKey("Description"))
                        {
                            if (string.IsNullOrEmpty(objEntity.Description) == true)
                            {
                                objEntity.Description = objResults["Description"].ToString().Trim();
                            }
                        }
                        if (string.IsNullOrEmpty(objEntity.Description) == true)
                        {
                            bAllfind = false;
                        }
                        #endregion
                        #region DisplayAspectRatio

                        if (objResults.ContainsKey("DisplayAspectRatio"))
                        {
                            if (objEntity.AspectRatio == null || objEntity.AspectRatio.IsOld == true || string.IsNullOrEmpty(objEntity.AspectRatio.Name))
                            {
                                objEntity.AspectRatio = objResults["DisplayAspectRatio"] as AspectRatio;
                            }
                        }

                        #endregion
                        #region Format

                        if (objResults.ContainsKey("Format"))
                        {
                            if (objEntity.FileFormat == null)
                            {
                                objEntity.FileFormat = objResults["Format"] as FileFormat;
                            }
                        }

                        #endregion
                        #region Image
                        int index;
                        if (objResults.ContainsKey("Image"))
                        {
                            if (objResults["Image"] != null)
                            {
                                if (!string.IsNullOrWhiteSpace(objResults["Image"].ToString()))
                                {
                                    byte[] objImage;

                                    if (objResults.ContainsKey("Links"))
                                    {
                                        objImage = Util.GetImage(objResults["Image"].ToString(), objResults["Links"].ToString().Trim());
                                    }
                                    else
                                    {
                                        objImage = Util.GetImage(objResults["Image"].ToString());
                                    }

                                    byte[] defaultCover = RessourcesServices.GetDefaultCover(objEntity, out index);
                                    if (objImage != null)
                                    {
                                        if (defaultCover == null || objEntity.RemoveCover == true || defaultCover.LongLength < objImage.LongLength)
                                        {
                                            RessourcesServices.AddImage(objImage, objEntity, true);
                                            objEntity.RemoveCover = false;
                                        }
                                    }
                                }
                            }
                        }
                        if (RessourcesServices.GetDefaultCover(objEntity, out index) == null)
                        {
                            bAllfind = false;
                        }
                        #endregion
                        #region RunTime

                        if (objResults.ContainsKey("Runtime"))
                        {
                            if (objEntity.Runtime == null || objEntity.Runtime == 0)
                            {
                                if (objResults["Runtime"] is double)
                                {
                                    objEntity.Runtime = (int)((double)objResults["Runtime"]);
                                }
                                else
                                {
                                    objEntity.Runtime = Util.ParseRunTime(objResults["Runtime"].ToString().Trim());
                                }
                            }
                        }

                        if (objEntity.Runtime == null || objEntity.Runtime == 0)
                        {
                            bAllfind = false;
                        }

                        #endregion
                        #region Genre
                        if (objResults.ContainsKey("Genre"))
                        {
                            GenreServices.AddGenres((List <string>)objResults["Genre"], objEntity, false);
                        }
                        if (objEntity.Genres.Count == 0)
                        {
                            bAllfind = false;
                        }
                        #endregion
                        #region Directed
                        if (objResults.ContainsKey("Directed"))
                        {
                            Console.WriteLine(objResults["Directed"].ToString().Trim());
                        }
                        #endregion
                        #region Links
                        if (objResults.ContainsKey("Links"))
                        {
                            LinksServices.AddLinks(objResults["Links"].ToString().Trim(), objEntity, false);
                        }
                        #endregion
                        #region Rating
                        if (objResults.ContainsKey("Rating"))
                        {
                            if (objEntity.PublicRating == null)
                            {
                                objEntity.PublicRating = (double?)objResults["Rating"];
                            }
                        }
                        #endregion
                        #region Released
                        if (objResults.ContainsKey("Released"))
                        {
                            if (objEntity.ReleaseDate == null &&
                                objResults["Released"].ToString().Trim().IndexOf("inconnue", StringComparison.Ordinal) == -1)
                            {
                                string   strDate = objResults["Released"].ToString().Trim();
                                DateTime objTemp;
                                if (DateTime.TryParse(strDate, out objTemp) == true)
                                {
                                    objEntity.ReleaseDate = objTemp;
                                }
                                else
                                {
                                    if (strDate.Length < 10)
                                    {
                                        if (strDate.Length == 4)
                                        {
                                            objTemp =
                                                new DateTime(Convert.ToInt32(strDate, CultureInfo.InvariantCulture), 1, 1);
                                            objEntity.ReleaseDate = objTemp;
                                        }
                                        else
                                        {
                                            DateTime objTmp;
                                            if (DateTime.TryParse(objResults["Released"].ToString(), out objTmp) == true)
                                            {
                                                objEntity.ReleaseDate = objTmp;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        DateTime objTmp;
                                        if (DateTime.TryParse(objResults["Released"].ToString(), out objTmp) == true)
                                        {
                                            objEntity.ReleaseDate = objTmp;
                                        }
                                    }
                                }
                            }
                        }
                        if (objEntity.ReleaseDate == null)
                        {
                            bAllfind = false;
                        }
                        #endregion
                        #region Publisher
                        if (objResults.ContainsKey("Studio"))
                        {
                            bool isNew;
                            if (objEntity.Publisher == null)
                            {
                                objEntity.Publisher = PublisherServices.GetPublisher((string)objResults["Studio"], out isNew, "XXX_Studio");
                            }
                        }
                        #endregion
                        #region Subs

                        if (objResults.ContainsKey("Subs"))
                        {
                            SubTitleServices.Add((List <string>)objResults["Subs"], objEntity);
                        }

                        #endregion

                        #region Title
                        if (objResults.ContainsKey("Title") && (string.IsNullOrWhiteSpace(objEntity.Title) || MySettings.RenameFile == true))
                        {
                            objEntity.Title = objResults["Title"].ToString();
                            if (MySettings.RenameFile == true && string.IsNullOrWhiteSpace(objEntity.FileName) == false)
                            {
                                objEntity.FileName = Util.RenameFile(objEntity.Title, objEntity.FileName, objEntity.FilePath);
                            }
                        }
                        if (string.IsNullOrWhiteSpace(objEntity.Title))
                        {
                            bAllfind = false;
                        }
                        #endregion
                    }
                    else
                    {
                        bAllfind = false;
                    }
                }

                objEntity.IsComplete = bAllfind;

                return(bAllfind);
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
                return(false);
            }
        }
Пример #8
0
        public static void ParseNfo(Music objEntity, out string errorMessage)
        {
            errorMessage = string.Empty;

            if (string.IsNullOrWhiteSpace(objEntity.FilePath))
            {
                errorMessage = "Nfo File not found";
            }
            else
            {
                string strFilePath;
                if (objEntity.FilePath.EndsWith(@"\", StringComparison.OrdinalIgnoreCase) == true)
                {
                    strFilePath = objEntity.FilePath + objEntity.FileName;
                }
                else
                {
                    strFilePath = objEntity.FilePath + @"\" + objEntity.FileName;
                }

                //FIX 2.8.2.0
                if (Directory.Exists(strFilePath))
                {
                    DirectoryInfo objFolder = new DirectoryInfo(strFilePath);
                    FileInfo[]    lstFile   = objFolder.GetFiles("*.nfo", SearchOption.AllDirectories);

                    if (lstFile.Any())
                    {
                        Hashtable objNfoValue = Dal.ParseNfo(lstFile[0].FullName);
                        #region Artist
                        //FIX 2.8.9.0
                        if (objEntity.Artists == null || objEntity.Artists.Count == 0)
                        {
                            if (objNfoValue.ContainsKey("Artist") == true)
                            {
                                ArtistServices.AddArtist(objNfoValue["Artist"].ToString().Trim(), objEntity);
                            }
                        }

                        #endregion
                        #region Publisher

                        if (objEntity.Publisher == null)
                        {
                            if (objNfoValue.ContainsKey("Editor") == true)
                            {
                                Publisher objEditor = Dal.GetInstance.GetPublisher(objNfoValue["Editor"].ToString().Trim(), "Music_Studio", "Name");
                                if (objEditor == null)
                                {
                                    objEditor      = new Publisher();
                                    objEditor.Name = objNfoValue["Editor"].ToString().Trim();
                                }
                                objEntity.Publisher = objEditor;
                            }
                        }

                        #endregion
                        #region Genres

                        if (objEntity.Genres == null || objEntity.Genres.Count == 0)
                        {
                            if (objNfoValue.ContainsKey("Type") == true)
                            {
                                Genre objType = Dal.GetInstance.GetGenre(objNfoValue["Type"].ToString().Trim(), "Music_Genre");
                                if (objType == null)
                                {
                                    objType = new Genre(objNfoValue["Type"].ToString().Trim(), objNfoValue["Type"].ToString().Trim());
                                }

                                if (objEntity.Genres == null)
                                {
                                    objEntity.Genres = new List <Genre>();
                                }

                                objEntity.Genres.Add(objType);
                            }
                        }


                        #endregion
                        #region Links

                        if (objNfoValue.ContainsKey("Links") == true)
                        {
                            LinksServices.AddLinks(objNfoValue["Links"].ToString().Trim(), objEntity, false);
                        }


                        #endregion
                        #region Released

                        if (objEntity.ReleaseDate == null)
                        {
                            if (objNfoValue.ContainsKey("Released") == true)
                            {
                                DateTime objConverted;
                                if (DateTime.TryParse(objNfoValue["Released"].ToString().Trim(), out objConverted) == true)
                                {
                                    objEntity.ReleaseDate = objConverted;
                                }
                            }
                        }

                        #endregion
                    }
                    else
                    {
                        errorMessage = "Nfo File not found : " + strFilePath;
                    }
                }
                else
                {
                    errorMessage = "Nfo File not found : " + strFilePath;
                }
            }
        }
Пример #9
0
        public static bool Fill(Hashtable objResults, Music objEntity)
        {
            try
            {
                bool bAllfind = true;
                if (objResults != null)
                {
                    #region Artist

                    if (objResults.ContainsKey("Artist"))
                    {
                        Artist artist = (Artist)objResults["Artist"];

                        if (objEntity.Artists == null)
                        {
                            objEntity.Artists = new List <Artist>();
                        }

                        if (objEntity.Artists.Count == 0 || objEntity.Artists.Any(x => x.IsOld == false) == false)
                        {
                            if (artist != null)
                            {
                                if (artist.Job == null)
                                {
                                    artist.Job = ArtistServices.GetJob("Singer");
                                }

                                objEntity.Artists.Add(artist);
                            }
                        }
                    }

                    if (objEntity.Artists.Count == 0)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Album
                    if (objResults.ContainsKey("Album"))
                    {
                        if (string.IsNullOrWhiteSpace(objEntity.Album))
                        {
                            objEntity.Album = objResults["Album"].ToString();
                        }
                    }
                    #endregion
                    #region Background
                    if (objResults.ContainsKey("Background"))
                    {
                        if (objResults["Background"] != null)
                        {
                            RessourcesServices.AddBackground(Util.GetImage(objResults["Background"].ToString()), objEntity);
                        }
                    }
                    #endregion
                    #region BarCode
                    if (objResults.ContainsKey("BarCode"))
                    {
                        if (string.IsNullOrEmpty(objEntity.BarCode) == true)
                        {
                            objEntity.BarCode = objResults["BarCode"].ToString().Trim();
                        }
                    }
                    #endregion
                    #region Cdart
                    if (objResults.ContainsKey("Cdart"))
                    {
                        if (objResults["Cdart"] != null)
                        {
                            RessourcesServices.AddImage(Util.GetImage(objResults["Cdart"].ToString()), objEntity, false);
                        }
                    }
                    #endregion
                    #region Description
                    if (objResults.ContainsKey("Description"))
                    {
                        if (string.IsNullOrWhiteSpace(objEntity.Comments))
                        {
                            objEntity.Comments = Util.PurgeHtml(objResults["Description"].ToString());
                        }
                    }
                    #endregion
                    #region Publisher
                    if (objResults.ContainsKey("Editor"))
                    {
                        bool isNew;
                        if (objEntity.Publisher == null)
                        {
                            objEntity.Publisher = PublisherServices.GetPublisher((string)objResults["Editor"], out isNew, "Music_Studio");
                        }
                    }
                    #endregion
                    #region Image
                    int index;
                    if (objResults.ContainsKey("Image"))
                    {
                        if (objResults["Image"] != null)
                        {
                            if (!string.IsNullOrWhiteSpace(objResults["Image"].ToString()))
                            {
                                byte[] objImage     = Util.GetImage(objResults["Image"].ToString());
                                byte[] defaultCover = RessourcesServices.GetDefaultCover(objEntity, out index);
                                if (objImage != null)
                                {
                                    if (defaultCover == null || objEntity.RemoveCover == true || defaultCover.LongLength < objImage.LongLength)
                                    {
                                        if (objResults["Image"] != null)
                                        {
                                            RessourcesServices.AddImage(Util.GetImage(objResults["Image"].ToString()), objEntity, true);
                                            objEntity.RemoveCover = false;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (RessourcesServices.GetDefaultCover(objEntity, out index) == null)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Links
                    if (objResults.ContainsKey("Links"))
                    {
                        if (objResults["Links"].GetType() == typeof(List <string>))
                        {
                            LinksServices.AddLinks((List <string>)objResults["Links"], objEntity, false);
                        }
                        else
                        {
                            LinksServices.AddLinks(objResults["Links"].ToString().Trim(), objEntity, false);
                        }
                    }
                    #endregion
                    #region Rating
                    if (objResults.ContainsKey("Rating"))
                    {
                        if (objEntity.PublicRating == null)
                        {
                            objEntity.PublicRating = Convert.ToDouble(objResults["Rating"], CultureInfo.InvariantCulture);
                        }
                    }

                    #endregion
                    #region Released
                    if (objResults.ContainsKey("Released"))
                    {
                        if (objEntity.ReleaseDate == null && objResults["Released"] != null &&
                            objResults["Released"].ToString().Trim().IndexOf("inconnue", StringComparison.OrdinalIgnoreCase) == -1)
                        {
                            string strDate = objResults["Released"].ToString().Trim();
                            if (strDate.Length < 10)
                            {
                                if (strDate.Length == 4)
                                {
                                    DateTime objTemp =
                                        new DateTime(Convert.ToInt32(strDate, CultureInfo.InvariantCulture), 1, 1);
                                    objEntity.ReleaseDate = objTemp;
                                }
                                else
                                {
                                    DateTime objTemp;
                                    if (DateTime.TryParse(objResults["Released"].ToString(), out objTemp) == true)
                                    {
                                        objEntity.ReleaseDate = objTemp;
                                    }
                                }
                            }
                            else if (objResults["Released"] is DateTime)
                            {
                                objEntity.ReleaseDate = objResults["Released"] as DateTime?;
                            }
                            else
                            {
                                DateTime objTemp;
                                if (DateTime.TryParse(objResults["Released"].ToString(), out objTemp) == true)
                                {
                                    objEntity.ReleaseDate = objTemp;
                                }
                            }
                        }
                    }
                    if (objEntity.ReleaseDate == null)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Runtime
                    if (objResults.ContainsKey("Runtime"))
                    {
                        if (objEntity.Runtime == null)
                        {
                            objEntity.Runtime = Convert.ToInt32(objResults["Runtime"]);
                        }
                    }
                    #endregion
                    #region Title
                    if (objResults.ContainsKey("Title") && string.IsNullOrWhiteSpace(objEntity.Title))
                    {
                        objEntity.Title = objResults["Title"].ToString();
                    }
                    if (string.IsNullOrWhiteSpace(objEntity.Title))
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Tracks
                    if (objResults.ContainsKey("Tracks"))
                    {
                        if (objEntity.Tracks.Count == 0)
                        {
                            AddTracks((List <string>)objResults["Tracks"], objEntity);
                        }
                    }
                    if (objEntity.Tracks.Count == 0)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Types
                    if (objResults.ContainsKey("Types"))
                    {
                        GenreServices.AddGenres((List <string>)objResults["Types"], objEntity, false);
                    }
                    if (objEntity.Genres.Count == 0)
                    {
                        bAllfind = false;
                    }
                    #endregion
                }
                else
                {
                    bAllfind = false;
                }

                objEntity.IsComplete = bAllfind;
                return(bAllfind);
            }
            catch (Exception ex)
            {
                Util.LogException(ex, objEntity.Title);
                return(false);
            }
        }
Пример #10
0
        public static bool Fill(Hashtable objResults, SeriesSeason objEntity)
        {
            bool bAllfind = true;

            if (objResults != null)
            {
                #region Actors
                if (objResults.ContainsKey("Actors"))
                {
                    ArtistServices.AddArtist((List <Artist>)objResults["Actors"], objEntity);
                }
                #endregion
                #region Audios

                if (objResults.ContainsKey("Audios"))
                {
                    AudioServices.Add((List <Audio>)objResults["Audios"], objEntity);
                }

                #endregion
                #region Background
                if (objResults.ContainsKey("Background"))
                {
                    if (objResults["Background"] != null)
                    {
                        RessourcesServices.AddBackground(Util.GetImage(objResults["Background"].ToString()), objEntity);
                    }
                }
                #endregion
                #region Episodes
                if (objResults.ContainsKey("Episodes"))
                {
                    if (objEntity.TotalEpisodes == null)
                    {
                        objEntity.TotalEpisodes = Convert.ToInt32(objResults["Episodes"]);
                    }
                }
                #endregion
                #region Image
                int index;
                if (objResults.ContainsKey("Image"))
                {
                    if (objResults["Image"] != null)
                    {
                        if (!string.IsNullOrWhiteSpace(objResults["Image"].ToString()))
                        {
                            byte[] objImage     = Util.GetImage(objResults["Image"].ToString());
                            byte[] defaultCover = RessourcesServices.GetDefaultCover(objEntity, out index);
                            if (objImage != null)
                            {
                                if (defaultCover == null || objEntity.RemoveCover == true || defaultCover.LongLength < objImage.LongLength)
                                {
                                    if (objResults["Image"] != null)
                                    {
                                        RessourcesServices.AddImage(Util.GetImage(objResults["Image"].ToString()), objEntity, true);
                                        objEntity.RemoveCover = false;
                                    }
                                }
                            }
                        }
                    }
                }
                if (RessourcesServices.GetDefaultCover(objEntity, out index) == null)
                {
                    bAllfind = false;
                }
                #endregion
                #region Publisher

                if (objResults.ContainsKey("Editor"))
                {
                    bool isNew;
                    if (objEntity.Publisher == null)
                    {
                        objEntity.Publisher = PublisherServices.GetPublisher((string)objResults["Editor"], out isNew, "Movie_Studio");
                    }
                }

                #endregion
                #region Comments

                if (objResults.ContainsKey("Comments"))
                {
                    if (string.IsNullOrEmpty(objEntity.Comments) == true)
                    {
                        objEntity.Comments = objResults["Comments"].ToString().Trim();
                    }
                }

                #endregion
                #region Description

                if (objResults.ContainsKey("Description"))
                {
                    if (string.IsNullOrEmpty(objEntity.Description) == true)
                    {
                        objEntity.Description = objResults["Description"].ToString().Trim();
                    }
                }
                if (string.IsNullOrEmpty(objEntity.Description) == true)
                {
                    bAllfind = false;
                }

                #endregion
                #region Format

                if (objResults.ContainsKey("Format"))
                {
                    if (objEntity.FileFormat == null)
                    {
                        objEntity.FileFormat = objResults["Format"] as FileFormat;
                    }
                }

                #endregion
                #region DisplayAspectRatio

                if (objResults.ContainsKey("DisplayAspectRatio"))
                {
                    if (objEntity.AspectRatio == null || objEntity.AspectRatio.IsOld == true || string.IsNullOrEmpty(objEntity.AspectRatio.Name))
                    {
                        objEntity.AspectRatio = objResults["DisplayAspectRatio"] as AspectRatio;
                    }
                }

                #endregion

                #region Genres
                if (objResults.ContainsKey("Types"))
                {
                    GenreServices.AddGenres((List <string>)objResults["Types"], objEntity, false);
                }
                if (objEntity.Genres.Count == 0)
                {
                    bAllfind = false;
                }

                #endregion
                #region Links
                if (objResults.ContainsKey("Links"))
                {
                    LinksServices.AddLinks(objResults["Links"].ToString().Trim(), objEntity, false);
                }
                #region EditorLinks

                if (objResults.ContainsKey("EditorLinks"))
                {
                    LinksServices.AddLinks(objResults["EditorLinks"].ToString().Trim(), objEntity, false);
                }

                #endregion
                #endregion
                #region Released Date

                if (objEntity.ReleaseDate == null)
                {
                    if (objResults.ContainsKey("Released") == true)
                    {
                        DateTime objConverted;
                        if (DateTime.TryParse(objResults["Released"].ToString().Trim(), out objConverted) == true)
                        {
                            objEntity.ReleaseDate = objConverted;
                        }
                    }
                }

                #endregion
                #region RunTime

                if (objResults.ContainsKey("Runtime"))
                {
                    if (objEntity.Runtime == null)
                    {
                        objEntity.Runtime = Util.ParseRunTime(objResults["Runtime"].ToString());
                    }
                }

                if (objEntity.Runtime == null)
                {
                    bAllfind = false;
                }

                #endregion
                #region Rating

                if (objResults.ContainsKey("Rating"))
                {
                    if (objEntity.PublicRating == null)
                    {
                        float fltTemp;
                        if (float.TryParse(objResults["Rating"].ToString().Trim(), out fltTemp))
                        {
                            objEntity.PublicRating = Math.Round(fltTemp, 2);
                        }
                        else
                        {
                            string strTemp = objResults["Rating"].ToString().Trim().Replace('.', ',');
                            if (float.TryParse(strTemp, out fltTemp))
                            {
                                objEntity.PublicRating = Math.Round(fltTemp, 2);
                            }
                        }
                    }
                }
                else if (objResults.ContainsKey("AlloCine"))
                {
                    if (objEntity.PublicRating == null)
                    {
                        string[] strTemp = objResults["AlloCine"].ToString().Trim().Split("_".ToCharArray());
                        int      lngTmp;
                        if (strTemp.Count() >= 2)
                        {
                            if (int.TryParse(objResults["AlloCine"].ToString().Trim().Split("_".ToCharArray())[1], out lngTmp) == true)
                            {
                                objEntity.PublicRating = lngTmp * 5;
                            }
                        }
                        else
                        {
                            if (int.TryParse(objResults["AlloCine"].ToString().Trim(), out lngTmp))
                            {
                                objEntity.PublicRating = lngTmp * 5;
                            }
                            else if (objResults["AlloCine"].ToString().Trim().IndexOf(",", StringComparison.Ordinal) > -1)
                            {
                                string strNote = objResults["AlloCine"].ToString().Trim().Replace(',', '.');
                                if (int.TryParse(strNote, out lngTmp))
                                {
                                    objEntity.PublicRating = lngTmp * 5;
                                }
                            }
                        }
                    }
                }
                if (objEntity.PublicRating == null)
                {
                    bAllfind = false;
                }
                #endregion
                #region Subs

                if (objResults.ContainsKey("Subs"))
                {
                    SubTitleServices.Add((List <string>)objResults["Subs"], objEntity);
                }

                #endregion
                #region Title
                if (objResults.ContainsKey("Title") && string.IsNullOrWhiteSpace(objEntity.Title))
                {
                    objEntity.Title = objResults["Title"].ToString();
                }
                if (string.IsNullOrWhiteSpace(objEntity.Title))
                {
                    bAllfind = false;
                }
                #endregion
            }
            else
            {
                bAllfind = false;
            }

            objEntity.IsComplete = bAllfind;
            return(bAllfind);
        }