Пример #1
0
        public static int ImportFromBibTex(string filepath)
        {
            int          added         = 0;
            const string strBookFormat = "Unknown";
            FileFormat   objFormat     = GetFormat(strBookFormat, true);

            Media    objMedia = MediaServices.Get("None", string.Empty, string.Empty, false, EntityType.Books, string.Empty, false, false, false, true);
            XElement xmlData  = XElement.Load(filepath);

            var query = from item in xmlData.Descendants("{http://bibtexml.sf.net/}incollection")
                        select item;

            XElement[] nodes = query.ToArray();

            added += ImportsNodes(objFormat.Id, objMedia, nodes);

            query = from item in xmlData.Descendants("{http://bibtexml.sf.net/}article")
                    select item;

            nodes = query.ToArray();

            added += ImportsNodes(objFormat.Id, objMedia, nodes);

            query = from item in xmlData.Descendants("{http://bibtexml.sf.net/}book")
                    select item;

            nodes = query.ToArray();

            added += ImportsNodes(objFormat.Id, objMedia, nodes);

            return(added);
        }
Пример #2
0
        public static int ImportFromCsv(string filepath)
        {
            List <string> lines = new List <string>();

            Media objMedia = MediaServices.Get("None", string.Empty, string.Empty, false, EntityType.Music, string.Empty, false, false, false, true);

            using (StreamReader sr = new StreamReader(filepath, Util.GetFileEncoding(filepath)))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    if (string.IsNullOrWhiteSpace(line) == false)
                    {
                        lines.Add(line);
                    }
                }
            }

            int added = ImportsLines(objMedia, lines);

            return(added);
        }
Пример #3
0
        public static void Update(IMyCollectionsData entity, string strLanguage, string strMedia, string studio, IEnumerable <string> lstGenres, IEnumerable objLinks,
                                  IEnumerable <string> artistName, string fileFormat, string aspectRatio, string platform, IEnumerable <string> metaData)
        {
            try
            {
                LinksServices.DeleteLinks(entity);
                entity.Media    = MediaServices.Get(strMedia, true);
                entity.Language = LanguageServices.GetLanguage(strLanguage, true);

                #region Publisher

                if (String.IsNullOrWhiteSpace(studio) == false)
                {
                    bool isNew;
                    switch (entity.ObjectType)
                    {
                    case EntityType.Nds:
                    case EntityType.Games:
                    case EntityType.Books:
                    case EntityType.Apps:
                        entity.Publisher = PublisherServices.GetPublisher(studio, 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(studio, out isNew, "Movie_Studio");
                        if (isNew == true)
                        {
                            Dal.GetInstance.AddPublisher("Movie_Studio", entity.Publisher);
                        }
                        break;

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

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

                #endregion


                if (String.IsNullOrWhiteSpace(entity.FilePath))
                {
                    entity.FilePath = String.Empty;
                }

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

                case EntityType.Books:
                    #region FileFormat
                    if (entity.FileFormat == null)
                    {
                        entity.FileFormat = BookServices.GetFormat(fileFormat, true);
                    }
                    else if (entity.FileFormat.Name != fileFormat)
                    {
                        entity.FileFormat = BookServices.GetFormat(fileFormat, true);
                    }
                    #endregion
                    Dal.GetInstance.AddBook(entity as Books);
                    break;

                case EntityType.Games:
                    entity.Platform = GameServices.GetPlatform(platform, true);
                    Dal.GetInstance.AddGame(entity as Gamez);
                    break;

                case EntityType.Movie:
                    #region FileFormat
                    if (entity.FileFormat == null)
                    {
                        entity.FileFormat = MovieServices.GetFormat(fileFormat);
                    }
                    else if (entity.FileFormat.Name != fileFormat)
                    {
                        entity.FileFormat = MovieServices.GetFormat(fileFormat);
                    }
                    #endregion
                    #region AspectRatio
                    if (entity.AspectRatio == null)
                    {
                        entity.AspectRatio = MovieServices.GetAspectRatio(aspectRatio);
                    }
                    else if (entity.AspectRatio.Name != aspectRatio)
                    {
                        entity.AspectRatio = MovieServices.GetAspectRatio(aspectRatio);
                    }
                    #endregion
                    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 Genres
                Dal.GetInstance.UnlinkGenre(entity);

                GenreServices.AddGenres(lstGenres, entity, true);
                #endregion
                #region MetaData
                Dal.GetInstance.UnlinkMetaData(entity);
                MetaDataServices.Link(entity, metaData);
                #endregion

                LinksServices.AddLinks(objLinks.Cast <string>(), entity, true);
                RessourcesServices.UpdateRessources(entity);

                #region Artist

                if (entity.ObjectType != EntityType.Books && entity.ObjectType != EntityType.Music)
                {
                    Task.Factory.StartNew(() => UpdateArtist(entity, artistName));
                }
                else
                {
                    UpdateArtist(entity, artistName);
                }

                #endregion
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
                throw;
            }
        }