/// <summary> /// Constructor for the form /// </summary> public BuildTools(Guid guid, Job job) { InitializeComponent(); _job = job; _googleAnalytics = new GoogleAnalytics(guid); _runner = new Runner(this, _job, _googleAnalytics); undoBT.Visible = false; progress.Visible = false; versionBox.SelectedIndex = 0; GetVersions(); // delegates _appendDelegate = AppendText; _appendRawDelegate = AppendRawText; _disableDelegate = Disable; _enableDelegate = Enable; _showProgressDelegate = ProgressShow; _hideProgressDelegate = ProgressHide; _indeterminateProgressDelegate = ProgressIndeterminate; _progressPercentDelegate = Progress; _updateVersionsDelegate = UpdateVersions; if (File.Exists(Program.CheckUpdate)) { string text = File.ReadAllText(Program.CheckUpdate); if (string.IsNullOrEmpty(text) || text.Trim().ToLower() == "false") { autoUpdateCB.Checked = false; } } Console.WriteLine(guid.ToString()); new Thread(delegate () { _googleAnalytics.SendEvent("Application", "Start"); }).Start(); }
// Run BuildTools Button Clicked private void runBT_Click(object sender, EventArgs e) { bool update = autoUpdateCB.Checked; string version; if (versionBox.SelectedIndex == 0) { version = "latest"; } else { version = _versions[versionBox.SelectedIndex - 1]; } _running = true; Thread thread = new Thread(delegate() { _googleAnalytics.SendEvent("BuildTools Run", "Version: " + version); _googleAnalytics.StartTimer("BuildTools Run Time"); _runner.RunBuildTools(update, version); Enable(); ProgressHide(); _googleAnalytics.EndTimer("BuildTools Run Time"); _running = false; }); Disable(); thread.Start(); }
/// <summary> /// Constructor for the form /// </summary> public BuildTools(Guid guid, Job job) { InitializeComponent(); _job = job; _googleAnalytics = new GoogleAnalytics(guid); _runner = new Runner(this, _job, _googleAnalytics); undoBT.Visible = false; progress.Visible = false; versionBox.SelectedIndex = 0; GetVersions(); // delegates _appendDelegate = AppendText; _appendRawDelegate = AppendRawText; _disableDelegate = Disable; _enableDelegate = Enable; _showProgressDelegate = ProgressShow; _hideProgressDelegate = ProgressHide; _indeterminateProgressDelegate = ProgressIndeterminate; _progressPercentDelegate = Progress; _updateVersionsDelegate = UpdateVersions; if (File.Exists(Program.CheckUpdate)) { string text = File.ReadAllText(Program.CheckUpdate); if (string.IsNullOrEmpty(text) || text.Trim().ToLower() == "false") { autoUpdateCB.Checked = false; } } Console.WriteLine(guid.ToString()); new Thread(delegate() { _googleAnalytics.SendEvent("Application", "Start"); }).Start(); }
/// <summary> /// Download a new copy of the BuildTools jar /// </summary> /// <returns>True if the update was successful</returns> public bool UpdateJar() { if (!Directory.Exists(Dir)) { Directory.CreateDirectory(Dir); } _form.AppendText("Checking for update"); _form.ProgressShow(); _form.ProgressIndeterminate(); bool bad; bool update = CheckUpdate(out bad); if (update) { _googleAnalytics.SendEvent("BuildTools Update", "Download"); _form.AppendText("Update needed for BuildTools"); if (!GetJson()) { return(false); } if (File.Exists(Dir + (string)_json["buildTools"]["name"])) { _form.AppendText("Deleting current BuildTools"); File.Delete(Dir + (string)_json["buildTools"]["name"]); } string baseUrl = (string)_api["url"]; string relativePath = (string)_api["artifacts"][0]["relativePath"]; string fullUrl = baseUrl + "artifact/" + relativePath; _form.AppendText("Downloading BuildTools"); if (!DownloadFile(fullUrl, Dir + (string)_json["buildTools"]["name"])) { _googleAnalytics.SendEvent("BuildTools Update", "Failed"); _form.AppendText("BuildTools failed to download"); return(false); } _form.AppendText("Download complete"); } else { if (!bad) { _form.AppendText("BuildTools is up to date, no need to update"); } else { return(false); } } return(true); }