private void CheckForUpdates(object state) { if (CurrentOS.IsWinTangraEndOfLife) { return; } try { m_LastUpdateTime = DateTime.Now; int serverConfigVersion; NewUpdateState updateState = NewUpdatesAvailable(out serverConfigVersion); if (updateState == NewUpdateState.TangraUpdate) { Trace.WriteLine("There is a new update.", "Update"); m_MainFrom.Invoke(new OnUpdateEventDelegate(OnUpdateEvent), MSG_ID_NEW_TANGRA3_UPDATE_AVAILABLE); } if (updateState == NewUpdateState.AddinModuleUpdate) { Trace.WriteLine("There is a new add-in update.", "Update"); m_MainFrom.Invoke(new OnUpdateEventDelegate(OnUpdateEvent), MSG_ID_NEW_TANGRA3_ADDIN_UPDATE_AVAILABLE); } else { Trace.WriteLine( string.Format("There are no new {0}updates.", TangraConfig.Settings.Generic.AcceptBetaUpdates ? "beta " : ""), "Update"); m_MainFrom.Invoke(new OnUpdateEventDelegate(OnUpdateEvent), MSG_ID_NO_TANGRA3_UPDATES_AVAILABLE); } Settings.Default.LastCheckedForUpdates = m_LastUpdateTime; Settings.Default.Save(); } catch (Exception ex) { Trace.WriteLine(ex, "Update"); } try { if (TangraConfig.Settings.Generic.SubmitUsageStats && Settings.Default.UsageStatsLastSent.AddDays(30) < DateTime.Now) { UsageStats.Instance.Save(); string usageStats = Settings.Default.UsageStatistics; WebRequest req = WebRequest.Create("http://www.occultwatcher.net/CGI-BIN/TangraUsageStats.ashx"); req.ContentType = "application/xml"; req.Method = "POST"; byte[] bytes = Encoding.UTF8.GetBytes(usageStats); req.ContentLength = bytes.Length; System.IO.Stream os = req.GetRequestStream(); os.Write(bytes, 0, bytes.Length); os.Close(); HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); if (resp.StatusCode == HttpStatusCode.OK) { UsageStats.ClearStats(); Settings.Default.UsageStatsLastSent = DateTime.Now; Settings.Default.Save(); } } } catch (Exception ex) { Trace.WriteLine(ex, "UsageStats"); } }