public bool TestConnection() { try { if (SDK.GetConnectState()) { return(true); } else { return(false); } } catch { return(false); } finally { SDK.sta_DisConnect(); } }
public TimeATT() { InitializeComponent(); #region Main_Load Cursor = Cursors.WaitCursor; skdHelper.sta_SetRTLogListBox(RealTimeEventListBox); Cursor = Cursors.Default; skdHelper.PergjigjePajisja += OnPergjigjePajisja; #endregion #region lidhu NET if (!chkCfg.GjejNetConfigFile()) { btnLidhu.Text = "Krijo Profil"; logHandler.PMLog(lbPMLog, "Per tu lidhur me pajisjen plotesoni NET"); } else { string[] vlerat = chkCfg.LexoNetCfg(); tbIp.Text = vlerat[0]; tbPort.Text = vlerat[1]; tbCommKey.Text = vlerat[2]; if (!chkCfg.VleresoIPv4(vlerat[0])) { logHandler.PMLog(lbPMLog, "Error *Kontrollo IP."); } else if (vlerat[1] == "" || Convert.ToInt32(vlerat[1]) <= 0 || Convert.ToInt32(vlerat[1]) > 65535) { logHandler.PMLog(lbPMLog, "Error *Porta e parregullt!"); } else if (vlerat[2] == "" || Convert.ToInt32(vlerat[2]) < 0 || Convert.ToInt32(vlerat[2]) > 999999) { logHandler.PMLog(lbPMLog, "Error *CommKey i parregullt!"); } else { int ret = skdHelper.sta_ConnectTCP(lbPMLog, tbIp.Text.Trim(), tbPort.Text.Trim(), tbCommKey.Text.Trim()); if (skdHelper.GetConnectState()) { skdHelper.sta_getBiometricType(); } if (ret == 1) { this.tbIp.ReadOnly = true; this.tbPort.ReadOnly = true; this.tbCommKey.ReadOnly = true; GetCapacityInfo(); GetDeviceInfo(); btnLidhu.Text = "Shkëput lidhjen"; btnLidhu.Refresh(); } else if (ret == -2) { btnLidhu.Text = "Lidhu"; btnLidhu.Refresh(); this.tbIp.ReadOnly = false; this.tbPort.ReadOnly = false; this.tbCommKey.ReadOnly = false; } } Cursor = Cursors.Default; } #endregion #region lidhu TCP if (chkCfg.GjejTCPConfigFile()) { string[] vlerat = chkCfg.LexoTCPCfg(); tbHost.Text = vlerat[0]; tbTCPPort.Text = vlerat[1]; tbHost.Enabled = false; tbTCPPort.Enabled = false; btnLidhuTCP.Enabled = false; tcpKlient = new TCPKlient(IPAddress.Parse(vlerat[0]), int.Parse(vlerat[1])); tcpKlient.Connect(); tcpKlient.DataReceived += new TCPKlient.delDataReceived(Klient_DataReceived); tcpKlient.ConnectionStatusChanged += new TCPKlient.delConnectionStatusChanged(Klient_ConnectionStatusNdyshoi); } //Initialize the events #endregion }