private void ItmAuthenticateRevoke_Click(object sender, EventArgs e) { try { //test authentication var testLogin = ArcLogin.TestLogin(); if (!testLogin) { UiMessages.Warning(@"Revocation failed: login not yet initiated"); } else if (Global.InitToken != null) { var logoutSuccess = Global.InitToken.Revoke(); if (logoutSuccess) { UpdateUIAuthenticate(); Global.InitToken = null; UiMessages.Info(@"Successfully logged user out"); } else { UiMessages.Warning(@"Revocation failed: logout was unsuccessful"); } } else { UiMessages.Warning(@"Revocation failed: login data not yet initiated"); } } catch (Exception ex) { UiMessages.Error(ex.ToString()); } }
private void ItmAuthenticateGrant_Click(object sender, EventArgs e) { try { //test authentication var testLogin = ArcLogin.TestLogin(); if (testLogin) { UiMessages.Warning(@"Authentication failed: user is already authenticated"); } else if (Global.InitToken == null) { var loginSuccess = LoginForm.ShowLogin(); if (loginSuccess) { UpdateUIAuthenticate(true); UiMessages.Info(@"Successfully authenticated user"); } else { UiMessages.Warning(@"Authentication failed: login was unsuccessful"); } } else { UiMessages.Warning(@"Authentication failed: login data already initialised"); } } catch (Exception ex) { UiMessages.Error(ex.ToString()); } }
private void DoJsonLoad() { try { //UI set AllTextReadOnly(true); //show open file dialog to locate a JSON file var jsonFile = FindJson(); //validation if (!string.IsNullOrWhiteSpace(jsonFile)) { //try deserialisation var jsonHandler = new CgiScriptFileService(jsonFile); var jsonObject = jsonHandler.ServiceAuthInfo; //validation if (jsonObject != null) { //fill UI FillValues(jsonObject); //clear script box browserMain.DocumentText = @""; //unlock fetch button btnFetchScript.Enabled = true; //assign globals FetchEnabled = true; ScriptService = jsonHandler; //report success UiMessages.Info(@"Successfully loaded JSON service information"); } else { UiMessages.Error(@"Deserialisation failed; service information was null"); } } //UI set AllTextReadOnly(false); } catch (Exception ex) { UiMessages.Error($"Error occurred whilst trying to load a JSON script information file:\n\n{ex}"); } }
public static void ExportThis(this DataTable table, ExportFormat format, string fileName, bool silent = false, bool waitWindow = true) { if (waitWindow) { ArcWaitWindow.ArcWaitWindow.Show(ExportThis, @"Exporting...", table, format, fileName, silent); } else { var success = true; switch (format) { case ExportFormat.Json: table.ToJson(fileName); break; case ExportFormat.Xml: table.ToXml(fileName); break; case ExportFormat.Csv: table.ToCsv(fileName); break; case ExportFormat.Cfg: table.ToCfg(fileName); break; case ExportFormat.Txt: table.ToTxt(fileName); break; default: if (!silent) { UiMessages.Error(@"Unrecognised export format"); success = false; } break; } if (!silent && success) { UiMessages.Info($"Successfully exported data to: {fileName}"); } } }
private void BillPrice() { try { //make sure there's an actual value to calculate if (lblTotalBilledTimeValue.Text != @"Unknown" && lblTotalBilledTimeValue.Text != @"00:00:00") { var guiHandler = new UserInteraction(); var r = guiHandler.showInputForm(@"Enter call charge per minute", @"Bill Price Prediction"); if (r.txt != @"!cancel=user") { if (decimal.TryParse(r.txt, out var callCharge)) { //convert existing label back to a time value var t = TimeSpan.Parse(lblTotalBilledTimeValue.Text); var m = Convert.ToDecimal(t.TotalMinutes); if (callCharge > 0) { var p = Math.Round(m * callCharge, 2); UiMessages.Info($"You're looking at around ${p} ({Math.Round(m, 2)} minutes) worth of outgoing calls"); } else { UiMessages.Info($"You're looking at $0.00 ({Math.Round(m, 2)} minutes) worth of outgoing calls"); } } else { UiMessages.Error(@"Your value wasn't valid; ensure it's a number and try again."); } } } } catch (Exception ex) { UiMessages.Error(ex.ToString()); } }
private void ItmTryDefault_Click(object sender, EventArgs e) { try { //test authentication var testLogin = ArcLogin.TestLogin(); if (testLogin) { UiMessages.Warning(@"Authentication failed: user is already authenticated"); } else if (Global.InitToken == null) { //LH1000 default is admin:Telstra var defaultLogin = new ArcCredential(@"admin", @"Telstra"); //login with default credentials var loginSuccess = ArcLogin.DoLogin(defaultLogin); if (loginSuccess) { UpdateUIAuthenticate(true); UiMessages.Info(@"Successfully authenticated user"); } else { UiMessages.Warning(@"Authentication failed: login was unsuccessful"); } } else { UiMessages.Warning(@"Authentication failed: login data already initialised"); } } catch (Exception ex) { UiMessages.Error(ex.ToString()); } }