Example #1
0
        public static void Clean(Gamez objItem)
        {
            foreach (Genre genre in objItem.Genres)
            {
                genre.IsOld = true;
            }

            foreach (Links link in objItem.Links)
            {
                link.IsOld = true;
            }

            foreach (Ressource ressource in objItem.Ressources)
            {
                ressource.IsOld = true;
            }

            objItem.RemoveCover = true;
            objItem.Cover       = null;

            objItem.BarCode      = string.Empty;
            objItem.Comments     = string.Empty;
            objItem.Description  = string.Empty;
            objItem.Rated        = null;
            objItem.MyRating     = null;
            objItem.ReleaseDate  = null;
            objItem.Publisher    = null;
            objItem.Platform     = null;
            objItem.Language     = null;
            objItem.IsComplete   = false;
            objItem.PublicRating = null;
        }
        private static void FileThumbItem(ThumbItem thumbItem, Gamez item)
        {
            //Fix v2.5
            if (item == null)
            {
                return;
            }

            thumbItem.Added       = item.AddedDate;
            thumbItem.Cover       = item.Cover;
            thumbItem.Deleted     = item.IsDeleted;
            thumbItem.Description = item.Description;
            if (item.Cover != null)
            {
                thumbItem.HasCover = true;
            }
            else
            {
                thumbItem.Cover    = Util.CreateCover(item.Title);
                thumbItem.HasCover = false;
            }
            thumbItem.IsComplete  = item.IsComplete;
            thumbItem.Media       = item.Media.Name;
            thumbItem.Name        = item.Title;
            thumbItem.MyRating    = item.MyRating / 4;
            thumbItem.ReleaseDate = item.ReleaseDate;
            thumbItem.Seen        = item.Watched;
            thumbItem.ToBeDeleted = item.ToBeDeleted;
            thumbItem.ToBuy       = item.IsWhish;
            thumbItem.ToWatch     = item.ToWatch;
        }
 private void LoadItem()
 {
     _objItem = new GameServices().Get(Id) as Gamez;
     if (_objItem != null)
     {
         DataContext = _objItem;
         Bind();
     }
 }
Example #4
0
        private void AddGamez(string[] strTemp, string strTitle, string strFileName, string strFilePath)
        {
            Gamez objGames = new Gamez();

            objGames.Title      = strTitle;
            objGames.Ressources = new List <Ressource>();
            objGames.AddedDate  = DateTime.Now;
            #region File

            objGames.FileName = strFileName;
            objGames.FilePath = strFilePath;

            #endregion
            if (_mapping != null)
            {
                string strLanguage = Util.ConstructString(strTemp, (string[])_mapping["Language"], _nbrBaseParsing);
                objGames.Language = LanguageServices.GetLanguage(strLanguage, true);
            }

            objGames.Media = MediaServices.Get(_strMediaName.Trim(), _mediaType, _path,
                                               _cleanTitle, _entityType, _patternType, _useSubFolder, _bGetImage, _bParseNfo, true);
            #region Cover
            if (_bGetImage == true)
            {
                RessourcesServices.AddImage(Util.GetLocalImage(objGames.FilePath, objGames.FileName, _bFile), objGames, true);
            }
            #endregion
            if (string.IsNullOrEmpty(objGames.Title) == false)
            {
                bool bExist = false;
                if (Dal.GetInstance.GetGames(objGames.Media.Name, objGames.FilePath, objGames.FileName) != null)
                {
                    bExist = true;
                }


                if (bExist == false)
                {
                    #region ParseNfo

                    if (_bParseNfo == true)
                    {
                        string errorMessage;
                        GameServices.ParseNfo(objGames, out errorMessage);
                    }
                    #endregion
                    Dal.GetInstance.AddGame(objGames);

                    _intAddedItem++;
                }
                else
                {
                    _intNotAddedItem++;
                }
            }
        }
        public static void SetToBeDeleted(IList lstSelectedItems)
        {
            foreach (ThumbItem item in lstSelectedItems)
            {
                switch (item.EType)
                {
                case EntityType.Apps:
                    Apps objApps = Dal.GetInstance.GetApps(item.Id);
                    objApps.ToBeDeleted = true;
                    Dal.GetInstance.AddApps(objApps);
                    break;

                case EntityType.Books:
                    Books objBooks = Dal.GetInstance.GetBooks(item.Id);
                    objBooks.ToBeDeleted = true;
                    Dal.GetInstance.AddBook(objBooks);
                    break;

                case EntityType.Games:
                    Gamez objGamez = Dal.GetInstance.GetGames(item.Id);
                    objGamez.ToBeDeleted = true;
                    Dal.GetInstance.AddGame(objGamez);
                    break;

                case EntityType.Movie:
                    Movie objMovie = Dal.GetInstance.GetMovies(item.Id);
                    objMovie.ToBeDeleted = true;
                    Dal.GetInstance.AddMovie(objMovie);
                    break;

                case EntityType.Music:
                    Music objMusic = Dal.GetInstance.GetMusics(item.Id);
                    objMusic.ToBeDeleted = true;
                    Dal.GetInstance.AddMusic(objMusic);
                    break;

                case EntityType.Nds:
                    Nds objNds = Dal.GetInstance.GetNdss(item.Id);
                    objNds.ToBeDeleted = true;
                    Dal.GetInstance.AddNds(objNds);
                    break;

                case EntityType.Series:
                    SeriesSeason objSeriesSeason = Dal.GetInstance.GetSeries_Seasons(item.Id);
                    objSeriesSeason.ToBeDeleted = true;
                    Dal.GetInstance.AddSeriesSeason(objSeriesSeason);
                    break;

                case EntityType.XXX:
                    XXX objXxx = Dal.GetInstance.GetXxXs(item.Id);
                    objXxx.ToBeDeleted = true;
                    Dal.GetInstance.AddXxx(objXxx);
                    break;
                }
            }
        }
        public static void SetClean(IList lstSelectedItem)
        {
            foreach (ThumbItem item in lstSelectedItem)
            {
                switch (item.EType)
                {
                case EntityType.Apps:
                    Apps objApps = Dal.GetInstance.GetApps(item.Id);
                    AppServices.Clean(objApps);
                    Update(objApps);
                    break;

                case EntityType.Books:
                    Books objBooks = Dal.GetInstance.GetBooks(item.Id);
                    BookServices.Clean(objBooks);
                    Update(objBooks);
                    break;

                case EntityType.Games:
                    Gamez objGamez = Dal.GetInstance.GetGames(item.Id);
                    GameServices.Clean(objGamez);
                    Update(objGamez);
                    break;

                case EntityType.Movie:
                    Movie objMovie = Dal.GetInstance.GetMovies(item.Id);
                    MovieServices.Clean(objMovie);
                    Update(objMovie);
                    break;

                case EntityType.Music:
                    Music objMusic = Dal.GetInstance.GetMusics(item.Id);
                    MusicServices.Clean(objMusic);
                    Update(objMusic);
                    break;

                case EntityType.Nds:
                    Nds objNds = Dal.GetInstance.GetNdss(item.Id);
                    NdsServices.Clean(objNds);
                    Update(objNds);
                    break;

                case EntityType.Series:
                    SeriesSeason objSeriesSeason = Dal.GetInstance.GetSeries_Seasons(item.Id);
                    SerieServices.Clean(objSeriesSeason);
                    Update(objSeriesSeason);
                    break;

                case EntityType.XXX:
                    XXX objXxx = Dal.GetInstance.GetXxXs(item.Id);
                    XxxServices.Clean(objXxx);
                    Update(objXxx);
                    break;
                }
            }
        }
Example #7
0
 public TvixThemeManager(Gamez objItem, string strThemePath)
 {
     InitializeComponent();
     chkGames.IsChecked  = true;
     chkMovies.IsEnabled = false;
     chkMusic.IsEnabled  = false;
     chkSeries.IsEnabled = false;
     chkXXX.IsEnabled    = false;
     _strThemePath       = strThemePath;
     _objItem            = objItem;
     cmdGenerate.Content = Application.Current.FindResource("cmdGenerateFile");
     CommonLoad();
 }
Example #8
0
        public static void ParseNfo(Gamez 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))
                {
                    strFilePath = objEntity.FilePath + objEntity.FileName;
                }
                else
                {
                    strFilePath = objEntity.FilePath + @"\" + objEntity.FileName;
                }

                //FIX 2.82.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);
                        bool      allFind     = false;
                        Fill(objNfoValue, objEntity, ref allFind);
                    }
                    else
                    {
                        errorMessage = "Nfo File not found : " + strFilePath;
                    }
                }
                else
                {
                    errorMessage = "Nfo File not found : " + strFilePath;
                }
            }
        }
Example #9
0
        public static bool IsComplete(Gamez objEntity)
        {
            if (objEntity.Ressources.Any() == false)
            {
                return(false);
            }
            if (string.IsNullOrWhiteSpace(objEntity.Description))
            {
                return(false);
            }
            if (objEntity.ReleaseDate == null)
            {
                return(false);
            }
            if (objEntity.Genres.Any() == false)
            {
                return(false);
            }

            return(true);
        }
Example #10
0
        private void ExportGames(string path, string separator, string newline)
        {
            try
            {
                IList items = GameServices.Gets();

                for (int i = 0; i < items.Count; i++)
                {
                    Gamez entity = items[i] as Gamez;

                    CommonServices.GetChild(entity);
                    if (_isCancelationPending == true)
                    {
                        break;
                    }

                    StringBuilder row = new StringBuilder();
                    row.Append("Game" + 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.Description.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);
                        row.Append(separator);

                        if (entity.Platform != null)
                        {
                            row.Append(entity.Platform.Name + separator);
                        }
                        else
                        {
                            row.Append(string.Empty + separator);
                        }
                    }

                    File.AppendAllText(path, row + newline, Encoding.UTF8);

                    _intAddedItem++;
                    Current++;
                    items[i] = null;
                }
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
                throw;
            }
        }
Example #11
0
        private void ExportGames(Document doc)
        {
            try
            {
                WriteChapter(doc, "Games");
                IList items = GameServices.Gets();

                PdfPTable mainTable = new PdfPTable(1);

                for (int i = 0; i < items.Count; i++)
                {
                    Gamez entity = items[i] as Gamez;

                    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);

                        string editorName = string.Empty;
                        if (entity.Publisher != null)
                        {
                            editorName = entity.Publisher.Name;
                        }

                        string plateform = string.Empty;
                        if (entity.Platform != null)
                        {
                            plateform = entity.Platform.Name;
                        }

                        PdfPTable text = WriteFirstRow(entity.Title, plateform, 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.Description, text);

                        StringBuilder types = new StringBuilder();
                        foreach (Genre item in entity.Genres)
                        {
                            if (item != null)
                            {
                                if (types.Length == 0)
                                {
                                    types.Append(item.DisplayName);
                                }
                                else
                                {
                                    types.Append("," + item.DisplayName);
                                }
                            }
                        }

                        WriteTypeRow(types.ToString(), entity.AddedDate.ToShortDateString(), text);
                        WriteMediaInfo(entity.Media.Name, entity.FilePath, entity.FileName, text);
                        text.SplitRows = false;
                        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;
            }
        }
Example #12
0
        public void GetInfoFromWeb(IMyCollectionsData item)
        {
            Gamez objEntity = item as Gamez;

            if (objEntity == null)
            {
                return;
            }

            bool bFind = false;

            if (objEntity.IsComplete == false)
            {
                string strSearch = objEntity.Title;

                if (MySettings.CleanTitle == true)
                {
                    strSearch = Util.CleanExtensions(strSearch);
                }

                string search = strSearch;
                Task.Factory.StartNew(() => Util.NotifyEvent("getInfoFromWeb: Games : " + search));

                Hashtable objResults = null;
                #region TheGamesDB
                if (MySettings.EnableGamesDBGames == true)
                {
                    Collection <PartialMatche> results = TheGamesDbServices.Search(strSearch, GamesPlateform.All);

                    if (results != null && results.Any())
                    {
                        objResults = TheGamesDbServices.Parse(results[0].Link);
                    }

                    if (objResults != null)
                    {
                        objEntity = Fill(objResults, objEntity, ref bFind);
                    }
                }
                #endregion
                #region JeuxVideo
                if (bFind == false && MySettings.EnableJeuxVideoGamez == true)
                {
                    Collection <PartialMatche> results = JeuxVideoComServices.Search(strSearch, string.Empty);

                    if (results != null && results.Any())
                    {
                        objResults = JeuxVideoComServices.Parse(results[0].Link, strSearch);
                    }

                    if (objResults != null)
                    {
                        objEntity = Fill(objResults, objEntity, ref bFind);
                    }
                }
                #endregion
                #region Amazon US
                if (bFind == false && MySettings.EnableAmazonGamez == true)
                {
                    Collection <PartialMatche> results = AmazonServices.Search(strSearch, string.Empty, AmazonIndex.VideoGames, AmazonCountry.com, AmazonBrowserNode.None);

                    if (results != null && results.Any())
                    {
                        objResults = AmazonServices.Parse(results[0].Link, AmazonCountry.com, !string.IsNullOrWhiteSpace(objEntity.BarCode), AmazonIndex.VideoGames, string.Empty);
                    }

                    if (objResults != null)
                    {
                        objEntity = Fill(objResults, objEntity, ref bFind);
                    }
                }
                #endregion
                #region Amazon FR
                if (bFind == false && MySettings.EnableAmazonFrGamez == true)
                {
                    Collection <PartialMatche> results = AmazonServices.Search(strSearch, string.Empty, AmazonIndex.VideoGames, AmazonCountry.fr, AmazonBrowserNode.None);

                    if (results != null && results.Any())
                    {
                        objResults = AmazonServices.Parse(results[0].Link, AmazonCountry.fr, !string.IsNullOrWhiteSpace(objEntity.BarCode), AmazonIndex.VideoGames, string.Empty);
                    }

                    if (objResults != null)
                    {
                        objEntity = Fill(objResults, objEntity, ref bFind);
                    }
                }
                #endregion
                #region Amazon DE
                if (bFind == false && MySettings.EnableAmazonDeGamez == true)
                {
                    Collection <PartialMatche> results = AmazonServices.Search(strSearch, string.Empty, AmazonIndex.VideoGames, AmazonCountry.de, AmazonBrowserNode.None);

                    if (results != null && results.Any())
                    {
                        objResults = AmazonServices.Parse(results[0].Link, AmazonCountry.de, !string.IsNullOrWhiteSpace(objEntity.BarCode), AmazonIndex.VideoGames, string.Empty);
                    }

                    if (objResults != null)
                    {
                        objEntity = Fill(objResults, objEntity, ref bFind);
                    }
                }
                #endregion
                #region Amazon IT
                if (bFind == false && MySettings.EnableAmazonItGamez == true)
                {
                    Collection <PartialMatche> results = AmazonServices.Search(strSearch, string.Empty, AmazonIndex.VideoGames, AmazonCountry.it, AmazonBrowserNode.None);

                    if (results != null && results.Any())
                    {
                        objResults = AmazonServices.Parse(results[0].Link, AmazonCountry.it, !string.IsNullOrWhiteSpace(objEntity.BarCode), AmazonIndex.VideoGames, string.Empty);
                    }

                    if (objResults != null)
                    {
                        objEntity = Fill(objResults, objEntity, ref bFind);
                    }
                }
                #endregion
                #region Amazon CN
                if (bFind == false && MySettings.EnableAmazonCnGamez == true)
                {
                    Collection <PartialMatche> results = AmazonServices.Search(strSearch, string.Empty, AmazonIndex.VideoGames, AmazonCountry.cn, AmazonBrowserNode.None);

                    if (results != null && results.Any())
                    {
                        objResults = AmazonServices.Parse(results[0].Link, AmazonCountry.cn, !string.IsNullOrWhiteSpace(objEntity.BarCode), AmazonIndex.VideoGames, string.Empty);
                    }

                    if (objResults != null)
                    {
                        objEntity = Fill(objResults, objEntity, ref bFind);
                    }
                }
                #endregion
                #region Amazon ES
                if (bFind == false && MySettings.EnableAmazonSpGamez == true)
                {
                    Collection <PartialMatche> results = AmazonServices.Search(strSearch, string.Empty, AmazonIndex.VideoGames, AmazonCountry.es, AmazonBrowserNode.None);

                    if (results != null && results.Any())
                    {
                        objResults = AmazonServices.Parse(results[0].Link, AmazonCountry.es, !string.IsNullOrWhiteSpace(objEntity.BarCode), AmazonIndex.VideoGames, string.Empty);
                    }

                    if (objResults != null)
                    {
                        Fill(objResults, objEntity, ref bFind);
                    }
                }
                #endregion

                CommonServices.Update(objEntity);
            }
        }
Example #13
0
        public static Gamez Fill(Hashtable objResults, Gamez objEntity, ref bool bAllfind)
        {
            try
            {
                bAllfind = true;

                if (objResults != null)
                {
                    #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.IsNullOrWhiteSpace(objEntity.BarCode) == true)
                        {
                            objEntity.BarCode = objResults["BarCode"].ToString().Trim();
                        }
                    }
                    #endregion
                    #region Comments
                    if (objResults.ContainsKey("Comments"))
                    {
                        if (string.IsNullOrWhiteSpace(objEntity.Comments))
                        {
                            objEntity.Comments = objResults["Comments"].ToString().Trim();
                        }
                    }
                    #endregion
                    #region Description
                    if (objResults.ContainsKey("Description"))
                    {
                        if (string.IsNullOrWhiteSpace(objEntity.Description) == true)
                        {
                            objEntity.Description = objResults["Description"].ToString().Trim();
                        }
                    }
                    if (string.IsNullOrWhiteSpace(objEntity.Description) == true)
                    {
                        bAllfind = 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 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);
                    }
                    if (objEntity.Links.Count == 0)
                    {
                        bAllfind = false;
                    }
                    #endregion
                    #region Platform
                    if (objResults.ContainsKey("Platform"))
                    {
                        if (objEntity.Platform == null)
                        {
                            objEntity.Platform = GetPlatform(objResults["Platform"].ToString().Trim(), false);
                        }
                    }
                    if (objEntity.Platform == null)
                    {
                        bAllfind = 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)
                        {
                            if (objResults["Released"] is DateTime?)
                            {
                                objEntity.ReleaseDate = objResults["Released"] as DateTime?;
                            }
                            else if (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;
                                    }
                                }
                            }
                        }
                    }
                    if (objEntity.ReleaseDate == 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 Genre
                    if (objResults.ContainsKey("Types"))
                    {
                        if (objResults["Types"].GetType() == typeof(List <string>))
                        {
                            GenreServices.AddGenres((IList <string>)objResults["Types"], objEntity, false);
                        }
                        else
                        {
                            GenreServices.AddGenres((IList <Genre>)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);
            }
        }
Example #14
0
        public static void Delete(string id)
        {
            Gamez item = Dal.GetInstance.GetGames(id);

            Dal.GetInstance.PurgeGames(item);
        }
Example #15
0
        private void worker_DoWork_XML(object sender, DoWorkEventArgs e)
        {
            try
            {
                Total = _selectedItems.Length;

                foreach (XElement node in _selectedItems)
                {
                    Gamez games = new Gamez();
                    games.Title       = Util.GetElementValue(node, "Title");
                    games.BarCode     = Util.GetElementValue(node, "BarCode");
                    games.Comments    = Util.GetElementValue(node, "Comments");
                    games.Description = Util.GetElementValue(node, "Description");
                    games.FileName    = Util.GetElementValue(node, "FileName");
                    games.FilePath    = Util.GetElementValue(node, "FilePath");

                    DateTime dateValue;

                    if (DateTime.TryParse(Util.GetElementValue(node, "AddedDate"), out dateValue) == true)
                    {
                        games.AddedDate = dateValue;
                    }

                    if (DateTime.TryParse(Util.GetElementValue(node, "ReleaseDate"), out dateValue) == true)
                    {
                        games.ReleaseDate = dateValue;
                    }

                    #region Bool
                    bool boolValue;

                    if (bool.TryParse(Util.GetElementValue(node, "IsComplete"), out boolValue) == true)
                    {
                        games.IsComplete = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "IsDeleted"), out boolValue) == true)
                    {
                        games.IsDeleted = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "IsTested"), out boolValue) == true)
                    {
                        games.Watched = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "IsWhish"), out boolValue) == true)
                    {
                        games.IsWhish = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "ToBeDeleted"), out boolValue) == true)
                    {
                        games.ToBeDeleted = boolValue;
                    }

                    #endregion
                    #region Long
                    int longValue;

                    if (int.TryParse(Util.GetElementValue(node, "Price"), out longValue) == true)
                    {
                        games.Price = longValue;
                    }

                    if (int.TryParse(Util.GetElementValue(node, "Rated"), out longValue) == true)
                    {
                        games.Rated = longValue.ToString(CultureInfo.InvariantCulture);
                    }

                    #endregion
                    #region int
                    int intValue;

                    if (int.TryParse(Util.GetElementValue(node, "Rating"), out intValue) == true)
                    {
                        games.MyRating = intValue;
                    }
                    #endregion
                    #region Media
                    var query = from item in node.Descendants("Media")
                                select item;

                    XElement[] mediaNode = query.ToArray();

                    foreach (XElement media in mediaNode)
                    {
                        Media newMedia = MediaServices.Get(Util.GetElementValue(media, "Name"), true);
                        newMedia.Path = Util.GetElementValue(media, "Path");
                        games.Media   = newMedia;
                    }
                    #endregion
                    #region Links
                    query = from item in node.Descendants("Link")
                            select item;

                    XElement[] linksNode = query.ToArray();

                    foreach (XElement link in linksNode)
                    {
                        LinksServices.AddLinks(Util.GetElementValue(link, "Path"), games, true);
                    }
                    #endregion
                    #region Types
                    query = from item in node.Descendants("Type")
                            select item;

                    XElement[] typekNode = query.ToArray();

                    foreach (XElement type in typekNode)
                    {
                        GenreServices.AddGenres(new[] { Util.GetElementValue(type, "RealName") }, games, true);
                    }
                    #endregion
                    #region Platform
                    query = from item in node.Descendants("Platform")
                            select item;

                    XElement[] platformNode = query.ToArray();

                    foreach (XElement type in platformNode)
                    {
                        games.Platform = GameServices.GetPlatform(Util.GetElementValue(type, "Name"), true);
                    }
                    #endregion
                    #region Image
                    query = from item in node.Descendants("Ressource")
                            select item;

                    XElement[] imagesNode = query.ToArray();

                    foreach (XElement images in imagesNode)
                    {
                        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, games, isDefault);
                            }
                        }
                        if (Util.GetElementValue(images, "ResourcesType") == "Background")
                        {
                            byte[] cover = Convert.FromBase64String(Util.GetElementValue(images, "Value"));

                            if (cover.Length > 0)
                            {
                                RessourcesServices.AddBackground(cover, games);
                            }
                        }
                    }
                    #endregion
                    #region Publisher
                    query = from item in node.Descendants("Editor")
                            select item;

                    XElement[] editorNode = query.ToArray();

                    foreach (XElement editor in editorNode)
                    {
                        bool isNew;
                        games.Publisher = PublisherServices.GetPublisher(Util.GetElementValue(editor, "Name"), out isNew, "App_Editor");
                        if (isNew == true)
                        {
                            Dal.GetInstance.AddPublisher("App_Editor", games.Publisher);
                        }
                    }
                    #endregion
                    #region Language
                    query = from item in node.Descendants("Language")
                            select item;

                    XElement[] languageNode = query.ToArray();

                    foreach (XElement languages in languageNode)
                    {
                        games.Language = LanguageServices.GetLanguage(Util.GetElementValue(languages, "DisplayName"), true);
                    }
                    #endregion
                    Dal.GetInstance.AddGame(games);
                    _intAddedItem++;

                    Current++;
                }
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
            }
        }