コード例 #1
0
        /// <summary>
        /// Initializes the library.
        /// </summary>
        public static void Initialize()
        {
            if (!Signature.IsActivated)
            {
                return;
            }

            if (Files.Count != 0)
            {
                Log.Debug("Library data loaded; checking to see if files still exist.");

                foreach (var ep in Files)
                {
                    var files = ep.Value.ToList();

                    foreach (var file in files)
                    {
                        try
                        {
                            if (!File.Exists(file))
                            {
                                ep.Value.Remove(file);
                            }
                        }
                        catch { }
                    }
                }
            }

            _stmr = new Timer
            {
                AutoReset = false,
                Interval  = 3000
            };
            _stmr.Elapsed += (sender, args) =>
            {
                try
                {
                    SaveList();
                }
                catch (Exception ex)
                {
                    Log.Warn("Error while saving library.", ex);
                }

                if (UPnP.IsRunning)
                {
                    try
                    {
                        UPnP.RebuildList();
                    }
                    catch (Exception ex)
                    {
                        Log.Warn("Error while rebuilding UPnP/DLNA library.", ex);
                    }
                }
            };

            SearchForFiles();
        }
コード例 #2
0
        /// <summary>
        /// Propagates data changes.
        /// </summary>
        /// <param name="delaySave">if set to <c>true</c> the database commit will be delayed for 3 seconds.</param>
        private static void DataChanged(bool delaySave = true)
        {
            try
            {
                if (MainWindow.Active != null && MainWindow.Active.activeGuidesPage != null && MainWindow.Active.activeGuidesPage._activeShowID != 0)
                {
                    MainWindow.Active.Run(MainWindow.Active.activeGuidesPage.Refresh);
                }
            }
            catch { }

            if (delaySave)
            {
                if (_stmr.Enabled)
                {
                    _stmr.Stop();
                }

                _stmr.Start();
            }
            else
            {
                try
                {
                    SaveList();
                }
                catch (Exception ex)
                {
                    Log.Warn("Error while saving library.", ex);
                }

                if (UPnP.IsRunning)
                {
                    try
                    {
                        UPnP.RebuildList();
                    }
                    catch (Exception ex)
                    {
                        Log.Warn("Error while rebuilding UPnP/DLNA library.", ex);
                    }
                }
            }
        }