Esempio n. 1
0
        /// <summary>
        /// Updated the database with information from the AppInfo cache file.
        /// </summary>
        /// <param name="path">Path to the cache file</param>
        /// <returns>The number of entries integrated into the database.</returns>
        public int UpdateFromAppInfo(string path)
        {
            int updated = 0;

            Dictionary <int, AppInfo> appInfos = AppInfo.LoadApps(path);
            int timestamp = Utility.GetCurrentUTime();

            foreach (AppInfo aInf in appInfos.Values)
            {
                GameDBEntry entry;
                if (!Games.ContainsKey(aInf.Id))
                {
                    entry    = new GameDBEntry();
                    entry.Id = aInf.Id;
                    Games.Add(entry.Id, entry);
                }
                else
                {
                    entry = Games[aInf.Id];
                }

                entry.LastAppInfoUpdate = timestamp;
                entry.AppType           = aInf.AppType;
                entry.Name      = aInf.Name;
                entry.Platforms = aInf.Platforms;
                entry.ParentId  = aInf.Parent;
                updated++;
            }
            return(updated);
        }
Esempio n. 2
0
        public int UpdateFromAppInfo(string path)
        {
            int updated = 0;

            lock (Games)
            {
                Dictionary <int, AppInfo> appInfos = AppInfo.LoadApps(path);
                long currentUnixTime = Utility.CurrentUnixTime();

                foreach (AppInfo appInfo in appInfos.Values)
                {
                    try
                    {
                        DatabaseEntry entry;
                        if (!Contains(appInfo.AppId))
                        {
                            entry = new DatabaseEntry(appInfo.AppId);
                            AddOrUpdate(entry);
                        }
                        else
                        {
                            entry = Games[appInfo.AppId];
                        }

                        entry.LastAppInfoUpdate = currentUnixTime;
                        if (appInfo.AppType != AppType.Unknown)
                        {
                            entry.AppType = appInfo.AppType;
                        }

                        if (!string.IsNullOrWhiteSpace(appInfo.Name))
                        {
                            entry.Name = appInfo.Name;
                        }

                        if ((entry.Platforms == AppPlatforms.None) || ((entry.LastStoreScrape == 0) && (appInfo.Platforms > AppPlatforms.None)))
                        {
                            entry.Platforms = appInfo.Platforms;
                        }

                        if (appInfo.ParentId > 0)
                        {
                            entry.ParentId = appInfo.ParentId;
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }

                    updated++;
                }
            }

            return(updated);
        }
Esempio n. 3
0
        /// <summary>
        ///     Updated the database with information from the AppInfo cache file.
        /// </summary>
        /// <param name="path">Path to the cache file</param>
        /// <returns>The number of entries integrated into the database.</returns>
        public int UpdateFromAppInfo(string path)
        {
            int updated = 0;

            Dictionary <int, AppInfo> appInfos = AppInfo.LoadApps(path);
            int timestamp = Utility.GetCurrentUTime();

            foreach (AppInfo aInf in appInfos.Values)
            {
                DatabaseEntry entry;
                if (!Games.ContainsKey(aInf.Id))
                {
                    entry    = new DatabaseEntry();
                    entry.Id = aInf.Id;
                    Games.Add(entry.Id, entry);
                }
                else
                {
                    entry = Games[aInf.Id];
                }

                entry.LastAppInfoUpdate = timestamp;
                if (aInf.AppType != AppType.Unknown)
                {
                    entry.AppType = aInf.AppType;
                }

                if (!string.IsNullOrEmpty(aInf.Name))
                {
                    entry.Name = aInf.Name;
                }

                if (entry.Platforms == AppPlatforms.None || entry.LastStoreScrape == 0 && aInf.Platforms > AppPlatforms.None)
                {
                    entry.Platforms = aInf.Platforms;
                }

                if (aInf.Parent > 0)
                {
                    entry.ParentId = aInf.Parent;
                }

                updated++;
            }

            return(updated);
        }
Esempio n. 4
0
        /// <summary>
        ///     Updated the database with information from the AppInfo cache file.
        /// </summary>
        /// <param name="path">Path to the cache file</param>
        /// <returns>The number of entries integrated into the database.</returns>
        public int UpdateFromAppInfo(string path)
        {
            int updated = 0;

            Dictionary <int, AppInfo> appInfos = AppInfo.LoadApps(path);
            long timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();

            foreach (AppInfo aInf in appInfos.Values)
            {
                if (!Contains(aInf.Id, out DatabaseEntry entry))
                {
                    entry = new DatabaseEntry(aInf.Id);
                    Add(entry);
                }

                entry.LastAppInfoUpdate = timestamp;
                if (aInf.AppType != AppType.Unknown)
                {
                    entry.AppType = aInf.AppType;
                }

                if (!string.IsNullOrEmpty(aInf.Name))
                {
                    entry.Name = aInf.Name;
                }

                if (entry.Platforms == AppPlatforms.None || entry.LastStoreScrape == 0 && aInf.Platforms > AppPlatforms.None)
                {
                    entry.Platforms = aInf.Platforms;
                }

                if (aInf.Parent > 0)
                {
                    entry.ParentId = aInf.Parent;
                }

                updated++;
            }

            return(updated);
        }