Skip to content

Commit

Permalink
Correction for stats
Browse files Browse the repository at this point in the history
  • Loading branch information
p0358 committed Dec 30, 2017
1 parent 70ae347 commit 7c45728
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions CodeStats/CodeStatsPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class CodeStatsPackage
public static bool Stats;
public static string Guid;

public static bool _reportedStats = false;

//public static string currentLangName = ""; // N++ (ex. HTML, not compatible with Code::Stats names everywhere)
public static string currentLangDesc = ""; // N++ (ex. Hyper Text Markup Language)
public static string currentLanguage = ""; // Code::Stats
Expand Down Expand Up @@ -175,7 +177,7 @@ private static void InitializeAsync()

if (Stats)
{
StatsReport();
ReportStats();
}

Logger.Info(string.Format("Finished initializing Code::Stats v{0}", Constants.PluginVersion));
Expand Down Expand Up @@ -569,10 +571,11 @@ private static void SettingsPopup()
_settingsForm.ShowDialog();
}

private static void StatsReport()
public static void ReportStats()
{
var client = new WebClient { Proxy = CodeStatsPackage.GetProxy() };
string HtmlResult = client.DownloadString("https://p0358.cf/codestats/report.php?pluginver=" + Constants.PluginVersion + "&cid=" + CodeStatsPackage.Guid); // expected response: ok
if (HtmlResult.Contains("ok")) _reportedStats = true;
}

private static string ToUnixEpoch(DateTime date)
Expand Down
8 changes: 7 additions & 1 deletion CodeStats/Forms/SettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ private void btnOk_Click(object sender, EventArgs e)
_CodeStatsConfigFile.Debug = chkDebugMode.Checked;
_CodeStatsConfigFile.Stats = chkStats.Checked;
_CodeStatsConfigFile.Save();
OnConfigSaved();

if (chkStats.Checked && !CodeStatsPackage._reportedStats)
{
CodeStatsPackage.ReportStats();
}

OnConfigSaved();
}
else
{
Expand Down

0 comments on commit 7c45728

Please sign in to comment.