private void RefreshMods(object param = null)
 {
     try
     {
         // Refresh only if last updated more than 30 seconds ago
         if (lastUpdated < DateTime.Now.AddSeconds(-30))
         {
             IsLoading = true;
             log.Info("Loading mods from Trovesaurus API");
             TrovesaurusApi.RefreshModList();
             TrovesaurusMods.Clear();
             foreach (TroveMod mod in TrovesaurusApi.ModList)
             {
                 TrovesaurusMods.Add(new TroveModViewModel(mod));
             }
             lastUpdated = DateTime.Now;
             log.Info("Loading mod list complete");
         }
         else
         {
             log.InfoFormat("Please wait {0} to refresh the mod list again", lastUpdated.AddSeconds(30).Subtract(DateTime.Now).Humanize());
         }
     }
     catch (Exception ex)
     {
         log.Error("Error refreshing mods", ex);
     }
     finally
     {
         IsLoading = false;
     }
 }
 private void LaunchTrovesaurus(object param = null)
 {
     try
     {
         TrovesaurusApi.LaunchTrovesaurus();
     }
     catch (Exception ex)
     {
         log.Error("Error launching Trovesaurus", ex);
     }
 }
Пример #3
0
        public void LoadData(object param = null)
        {
            // Load Trovesaurus data from API
            try
            {
                log.Info("Loading Trovesaurus news, calendar, and streams data");
                if (_StatusTimer == null)
                {
                    StartStatusTimer();
                }
                CheckStatus();

                TrovesaurusApi.RefreshNewsList();
                NewsItems.Clear();
                foreach (var item in TrovesaurusApi.NewsList)
                {
                    NewsItems.Add(item);
                }

                TrovesaurusApi.RefreshCalendarList();
                CalendarItems.Clear();
                foreach (var item in TrovesaurusApi.CalendarList)
                {
                    CalendarItems.Add(item);
                }

                TrovesaurusApi.RefreshStreamList();
                OnlineStreams.Clear();
                foreach (var item in TrovesaurusApi.StreamList)
                {
                    OnlineStreams.Add(item);
                }

                CalendarView.SortDescriptions.Clear();
                CalendarView.SortDescriptions.Add(new SortDescription("EndDateTime", ListSortDirection.Ascending));

                log.Info("Trovesaurus news, calendar, and streams data loaded successfully");
            }
            catch (Exception ex)
            {
                log.Error("Error loading Trovesaurus news, calendar or streams", ex);
            }
        }
Пример #4
0
 private void CheckMail()
 {
     try
     {
         int oldMailCount = MailCount;
         int?newMailCount = TrovesaurusApi.GetMailCount();
         if (newMailCount.HasValue)
         {
             MailCount = newMailCount.Value;
             string message = string.Format("{0} new Trovesaurus mail message{1}", MailCount, MailCount == 1 ? "" : "s");
             log.InfoFormat("Checked Trovesaurus mail: {0}", message);
             if (MailCount > oldMailCount)
             {
                 Action launchMail = () => LaunchTrovesaurusMailCommand.Execute(null);
                 MainWindowViewModel.Instance.ViewCommandManager.InvokeLoaded("ShowTrayTip", message, launchMail);
             }
         }
     }
     catch (Exception ex) { log.Error("Error checking Trovesaurus mail", ex); }
 }
Пример #5
0
        private void RefreshServerStatus()
        {
            try
            {
                if (statusLastUpdated < DateTime.Now.AddSeconds(-25))
                {
                    var oldStatus = _ServerStatus; // Check private variable for server status here to prevent a recursive issue
                    var newStatus = TrovesaurusApi.GetServerStatus();
                    statusLastUpdated = DateTime.Now;

                    if (newStatus != null)
                    {
                        ServerStatus = newStatus;
                        if (oldStatus != null)
                        {
                            StringBuilder status = new StringBuilder();
                            if (newStatus.Live.Online != oldStatus.Live.Online)
                            {
                                status.AppendFormat("Live Launcher is now {0}{1}", newStatus.Live.Online ? "online" : "offline", Environment.NewLine);
                            }
                            //if (newStatus.Server.Online != oldStatus.Server.Online) status.AppendFormat("Live Server is now {0}{1}", newStatus.Server.Online ? "online" : "offline", Environment.NewLine);
                            if (newStatus.PTS.Online != oldStatus.PTS.Online)
                            {
                                status.AppendFormat("Public Test Server is now {0}{1}", newStatus.PTS.Online ? "online" : "offline", Environment.NewLine);
                            }

                            if (status.Length > 0)
                            {
                                Action launchStatus = () => LaunchServerStatusCommand.Execute(null);
                                MainWindowViewModel.Instance.ViewCommandManager.InvokeLoaded("ShowTrayTip", status.ToString(), launchStatus);
                            }
                        }
                    }
                }
            }
            catch (Exception ex) { log.Error("Error refreshing server status", ex); }
        }
Пример #6
0
 private void LaunchTrovesaurus(string url = null)
 {
     try { TrovesaurusApi.LaunchTrovesaurus(url); }
     catch (Exception ex) { log.Error("Error launching Trovesaurus page", ex); }
 }
Пример #7
0
 private void LaunchTrovesaurusNewsTag(string tag)
 {
     try { TrovesaurusApi.LaunchTrovesaurusNewsTag(tag); }
     catch (Exception ex) { log.Error("Error launching Trovesaurus news tag page", ex); }
 }