0byt3m1n1
Path:
C:
/
BACKUPS
/
Biometric Backup
/
KELTRON
/
COSEC V14R4.1
/
Setup
/
API Samples
/
CSharp
/
Backup
/
[
Home
]
File: MainForm.cs
using System; using System.Data; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using System.Text; using System.Text.RegularExpressions; namespace CSharp { /// <summary> /// Description of MainForm. /// </summary> public partial class MainForm : Form { internal static MainForm Instance = null; public MainForm() { Instance = this; // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // } void MainForm_Load(object sender, EventArgs e) { tabControl1.Enabled = false; txtWebURL.Text = "http://localhost/cosec"; Cosec.apiHelper.HttpOperations += new Cosec.apiHelper.HttpOperationsHandler(apiHelper_HttpOperations); Cosec.apiHelper.BaseAddress = txtWebURL.Text + "/api.svc"; Cosec.apiHelper.LoginID = "sa"; Cosec.apiHelper.Password = "admin"; } private void txtWebURL_TextChanged(object sender, EventArgs e) { Cosec.apiHelper.BaseAddress = txtWebURL.Text + "/api.svc"; } void apiHelper_HttpOperations(Cosec.apiHelper.HTTPOperation operation, string data) { txtHTTPData.AppendText(operation.ToString().PadRight(10, ' ') + data + System.Environment.NewLine); if (operation != Cosec.apiHelper.HTTPOperation.Request) txtHTTPData.AppendText(System.Environment.NewLine); txtHTTPData.ScrollToCaret(); } #region Message Show/Hide internal void ClearMessage() { lblMsg.Visible = false; } internal void ShowMessage(string msg, bool isSuccess) { if (string.IsNullOrEmpty(msg) == true) ClearMessage(); else { if (isSuccess) lblMsg.ForeColor = Color.Green; else lblMsg.ForeColor = Color.Red; lblMsg.Text = msg; lblMsg.Visible = true; } Application.DoEvents(); } #endregion #region HTTP Tab private void btnClearHttp_Click(object sender, EventArgs e) { txtHTTPData.Clear(); } #endregion private void btnCheckService_Click(object sender, EventArgs e) { try { string errMsg = ""; pnlCheckingService.Visible = true; if (Cosec.apiHelper.Ping(out errMsg)) { txtWebURL.Enabled = false; btnCheckService.Visible = false; // Success userAddEditTab1.Load(); assignRevokeDeviceTab1.Load(); tabPage1.Text = Cosec.apiHelper.strUser + " Add/Edit"; tabControl1.Enabled = true; } else { // fail MessageBox.Show(errMsg); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { pnlCheckingService.Visible = false; } } } }