private void btnDisconnect_Click(object sender, EventArgs e) { deviceConnection.Close(); MessageBox.Show("Device has been disconnected", "System", MessageBoxButtons.OK, MessageBoxIcon.Stop); btnBiometricData.Enabled = false; btnDisconnect.Enabled = false; btnConnect.Enabled = true; }
private void btn_CloseDevice_Click(object sender, EventArgs e) { deviceConnection.Close(); btn_CloseDevice.Enabled = false; SetButtonEnabled(false); btn_OpenDevice.Enabled = true; device = null; deviceConnection = null; deviceEty = null; }
async void enterButton_Click(object sender, RoutedEventArgs e) { var text = result.Text; if (text.StartsWith(">")) { _comPort = text.Substring(1); _connection?.Close(); _connection = null; } result.SelectAll(); var connection = await GetDeviceAsync(); var stream = await _engine.SayText(text); TheMedia.SetSource(stream, stream.ContentType); var task = connection?.PlayAnimationSequenceAsync(stream.Markers); TheMedia.Play(); }
public JsonResult DownloadAttendence(int DN, string Model, int ConnectionModel, string IpAddress, int IpPort, string FrmDt, string ToDt) { int Result = 0; int Result1 = 0; int UsrKy = HTNSession.UsrKy; int CKy = HTNSession.CKy; //string EnvironmentName = HTNSession.Environment; string EnvironmentName = ""; try { if (WebConfigurationManager.AppSettings["AttendenceInsertEnvNm"] != null && WebConfigurationManager.AppSettings["AttendenceInsertEnvNm"] != "") { EnvironmentName = WebConfigurationManager.AppSettings["AttendenceInsertEnvNm"]; } else { EnvironmentName = HTNSession.Environment; } } catch (Exception) { } //string EnvironmentName = WebConfigurationManager.AppSettings["AttendenceInsertEnvNm"]; device = new Riss.Devices.Device(); device.CommunicationType = CommunicationType.Tcp; device.DN = DN; device.IpAddress = IpAddress; device.Model = Model; device.ConnectionModel = ConnectionModel; device.IpPort = IpPort; deviceConnection = DeviceConnection.CreateConnection(ref device); if (deviceConnection.Open() > 0) { Result1 = 1; deviceEty = new DeviceCommEty(); deviceEty.Device = device; deviceEty.DeviceConnection = deviceConnection; } else { return(Json(Result, JsonRequestBehavior.AllowGet)); } object extraProperty = new object(); object extraData = new object(); extraData = Global.DeviceBusy; if (Result1 == 1) { try { FrmDt = "01/01/2017"; ToDt = "31/12/2099"; List <DateTime> dtList = GetDateTimeList(FrmDt, ToDt); bool result = deviceConnection.SetProperty(DeviceProperty.Enable, extraProperty, device, extraData); extraProperty = false; extraData = dtList; result = deviceConnection.GetProperty(DeviceProperty.AttRecordsCount, extraProperty, ref device, ref extraData); if (false == result) { return(Json(Result, JsonRequestBehavior.AllowGet)); } int recordCount = (int)extraData; if (0 == recordCount) { return(Json(Result, JsonRequestBehavior.AllowGet)); } List <bool> boolList = new List <bool>(); boolList.Add(false); boolList.Add(false); extraProperty = boolList; extraData = dtList; result = deviceConnection.GetProperty(DeviceProperty.AttRecords, extraProperty, ref device, ref extraData); if (result) { List <Record> recordList = (List <Record>)extraData; List <AttendenceDownloadModel> AtnDownloadLst = new List <AttendenceDownloadModel>(); foreach (Record item in recordList) { AttendenceDownloadModel obj = new AttendenceDownloadModel(); obj.UsrKy = Convert.ToInt32(item.DIN); obj.ClkDt = item.Clock.ToString(); AtnDownloadLst.Add(obj); } var stringList = AtnDownloadLst.OfType <string>(); bool res = apiOpr.AtnClkDet_InsertWeb(CKy, UsrKy, AtnDownloadLst, EnvironmentName); if (res) { //bool clear = deviceConnection.SetProperty(DeviceProperty.Enable, extraProperty, device, extraData); bool clear = deviceConnection.SetProperty(DeviceProperty.AttRecords, extraProperty, device, extraData); if (clear) { //lvw_GLogList.Items.Clear(); Result = 1; } } } else { return(Json(Result, JsonRequestBehavior.AllowGet)); } } #pragma warning disable CS0168 // The variable 'ex' is declared but never used catch (Exception ex) #pragma warning restore CS0168 // The variable 'ex' is declared but never used { return(Json(Result, JsonRequestBehavior.AllowGet)); } finally { extraData = Global.DeviceIdle; deviceConnection.SetProperty(DeviceProperty.Enable, extraProperty, device, extraData); deviceConnection.Close(); device = null; deviceConnection = null; deviceEty = null; } } return(Json(Result, JsonRequestBehavior.AllowGet)); }