public ActionResult ChangeTelemetryState(bool DisableTelemetry) { AsaTelemetry.SetOptOut(DisableTelemetry); return(Json(true)); }
private static int RunConfigCommand(ConfigCommandOptions opts) { DatabaseManager.Setup(opts.DatabaseFilename); CheckFirstRun(); AsaTelemetry.Setup(); if (opts.ResetDatabase) { DatabaseManager.CloseDatabase(); try { File.Delete(opts.DatabaseFilename); } catch (IOException e) { Log.Fatal(e, Strings.Get("FailedToDeleteDatabase"), opts.DatabaseFilename, e.GetType().ToString(), e.Message); Environment.Exit(-1); } Log.Information(Strings.Get("DeletedDatabaseAt"), opts.DatabaseFilename); } else { DatabaseManager.VerifySchemaVersion(); if (opts.ListRuns) { if (DatabaseManager.FirstRun) { Log.Warning(Strings.Get("FirstRunListRunsError"), opts.DatabaseFilename); } else { Log.Information(Strings.Get("DumpingDataFromDatabase"), opts.DatabaseFilename); List <string> CollectRuns = DatabaseManager.GetRuns("collect"); if (CollectRuns.Count > 0) { Log.Information(Strings.Get("Begin"), Strings.Get("EnumeratingCollectRunIds")); foreach (string runId in CollectRuns) { var run = DatabaseManager.GetRun(runId); Log.Information("RunId:{2} Timestamp:{0} AsaVersion:{1} ", run.Timestamp, run.Version, run.RunId); var resultTypesAndCounts = DatabaseManager.GetResultTypesAndCounts(run.RunId); foreach (var kvPair in resultTypesAndCounts) { Log.Information("{0} : {1}", kvPair.Key, kvPair.Value); } } } else { Log.Information(Strings.Get("NoCollectRuns")); } List <string> MonitorRuns = DatabaseManager.GetRuns("monitor"); if (MonitorRuns.Count > 0) { Log.Information(Strings.Get("Begin"), Strings.Get("EnumeratingMonitorRunIds")); foreach (string monitorRun in MonitorRuns) { var run = DatabaseManager.GetRun(monitorRun); if (run != null) { string output = $"{run.RunId} {run.Timestamp} {run.Version} {run.Type}"; Log.Information(output); Log.Information(string.Join(',', run.ResultTypes.Keys.Where(x => run.ResultTypes[x]))); } } } else { Log.Information(Strings.Get("NoMonitorRuns")); } } } if (opts.TelemetryOptOut != null) { AsaTelemetry.SetOptOut(bool.Parse(opts.TelemetryOptOut)); Log.Information(Strings.Get("TelemetryOptOut"), (bool.Parse(opts.TelemetryOptOut)) ? "Opted out" : "Opted in"); } if (opts.DeleteRunId != null) { DatabaseManager.DeleteRun(opts.DeleteRunId); } if (opts.TrimToLatest) { DatabaseManager.TrimToLatest(); } } return(0); }