private bool ProcessData(List <Record> recordList) { int no = 1; String time = String.Empty; foreach (Record record in recordList) { string type = ConvertObject.IOMode(record.Verify); string mode = ConvertObject.GLogType(record.Action); time = record.Clock.ToString("yyyy-MM-dd HH:mm:ss"); String text = no.ToString() + "|" + record.DN.ToString() + "|" + record.DIN.ToString() + "|" + type + "|" + mode + "|" + time; if (type.Equals("Check in")) { Logger.log(text); if (AddToDatabase(record)) { no++; UpdateLastEntryTime(time); } } } //Util.UpdateTime(time); return(true); }
private void listener_ReceiveHandler(object sender, ReceiveEventArg e) { Record record = e.record; string verify = ConvertObject.IOMode(record.Verify); string action = ConvertObject.GLogType(record.Action); ListViewItem lvi = new ListViewItem(new string[] { no.ToString(), record.DN.ToString(), record.DIN.ToString(), string.Empty, verify, action, record.Clock.ToString("yyyy-MM-dd HH:mm:ss") }); BeginInvoke(new AddRecord(AddRecordToListView), new object[] { lvi }); no++; }
private void AddRecordToListView(List <Record> recordList) { lvw_GLogList.Items.Clear(); int no = 1; foreach (Record record in recordList) { string type = ConvertObject.IOMode(record.Verify); string mode = ConvertObject.GLogType(record.Action); ListViewItem item = new ListViewItem(new string[] { no.ToString(), record.DN.ToString(), record.DIN.ToString(), type, mode, record.Clock.ToString("yyyy-MM-dd HH:mm:ss") }); lvw_GLogList.Items.Add(item); no++; } }
private void listener_ReceiveHandler(object sender, ReceiveEventArg e) { Record record = e.record; string verify = ConvertObject.IOMode(record.Verify); string action = ConvertObject.GLogType(record.Action); ListViewItem lvi = new ListViewItem(new string[] { no.ToString(), record.DN.ToString(), record.DIN.ToString(), string.Empty, verify, action, record.Clock.ToString("yyyy-MM-dd HH:mm:ss") }); string sql = "insert into dbo.DeviceOriginalData(UserID,DeviceID,DateTime,Verify,Action,Remark,MDIN,DoorStatus,JobCode,Antipassback) " + "values(@UserID,@DeviceID,@DateTime,@Verify,@Action,@Remark,@MDIN,@DoorStatus,@JobCode,@Antipassback)"; SqlConnection connection = new SqlConnection(conn); SqlCommand command = new SqlCommand(sql, connection); connection.Open(); command.Parameters.Add(new SqlParameter("@UserID", record.DIN.ToString())); command.Parameters.Add(new SqlParameter("@DeviceID", record.DN)); command.Parameters.Add(new SqlParameter("@DateTime", record.Clock.ToString("yyyy-MM-dd HH:mm:ss"))); command.Parameters.Add(new SqlParameter("@Verify", record.Verify)); command.Parameters.Add(new SqlParameter("@Action", record.Action)); command.Parameters.Add(new SqlParameter("@Remark", record.Remark)); command.Parameters.Add(new SqlParameter("@MDIN", record.MDIN.ToString())); command.Parameters.Add(new SqlParameter("@DoorStatus", record.DoorStatus)); command.Parameters.Add(new SqlParameter("@JobCode", record.JobCode)); command.Parameters.Add(new SqlParameter("@Antipassback", record.Antipassback)); command.ExecuteNonQuery(); connection.Close(); string sql1 = "select * from dbo.Staffs where PhysicalCardNumber='" + record.DIN.ToString() + "'";// + record.DIN.ToString(); // connection.Open(); SqlConnection connection1 = new SqlConnection(conn); connection1.Open(); SqlCommand command1 = new SqlCommand(sql1, connection1); SqlDataReader dataReader = command1.ExecuteReader(); string staffNumber = null; if (dataReader.Read()) { staffNumber = dataReader["StaffNumber"].ToString(); } else { return; } SqlConnection sdb = new SqlConnection("Data Source = 211.149.199.42,1433;Initial Catalog = BonsaiiSystem;User ID = sa;Password = admin123@;");//连接平台数据库 string conn1 = "Data Source = 211.149.199.42,1433;User ID = sa;Password = admin123@;Initial Catalog = Bonsaii0000000008;"; string sql2 = "select * from dbo.BindCodes where ConnectionString='" + conn1 + "' and StaffNumber='" + staffNumber + "'"; dataReader.Close(); connection1.Close(); sdb.Open(); SqlCommand command2 = new SqlCommand(sql2, sdb); SqlDataReader dataReader1 = command2.ExecuteReader(); if (dataReader1.Read()) { JPushClient client = new JPushClient(app_key, master_secret); // PushPayload payload = PushObject_all_alias_alert(dataReader1["Phone"].ToString(), record.Clock.ToString("yyyy-MM-dd HH:mm:ss"));//选择一种方式 PushPayload pushPayload = new PushPayload(); pushPayload.platform = Platform.android(); pushPayload.audience = Audience.s_alias(dataReader1["Phone"].ToString()); pushPayload.message = cn.jpush.api.push.mode.Message.content("hello").AddExtras("Tag", "2").AddExtras("ComapnyTag", "3"); pushPayload.notification = Notification.android("打卡完成!", "在" + record.Clock.ToString("yyyy-MM-dd HH:mm:ss")); try { var result = client.SendPush(pushPayload);//推送 } catch (APIRequestException eee) { Console.WriteLine("Error response from JPush server. Should review and fix it. "); Console.WriteLine("HTTP Status: " + eee.Status); Console.WriteLine("Error Code: " + eee.ErrorCode); Console.WriteLine("Error Message: " + eee.ErrorCode); } catch (APIConnectionException ee) { Console.WriteLine(ee.Message); } } dataReader1.Close(); sdb.Close(); //connection.Close(); BeginInvoke(new AddRecord(AddRecordToListView), new object[] { lvi }); no++; }
public ActionResult DownloadDataBiometric() { //List<DownloadDataViewModel> list = new List<DownloadDataViewModel>(); //------------------------------------------ BINUGO CODE device = new Device(); device.DN = 1; device.Model = "A-C030"; device.ConnectionModel = 5; device.IpAddress = "192.168.005.001"; device.IpPort = 123; device.CommunicationType = CommunicationType.Tcp; deviceConnection = DeviceConnection.CreateConnection(ref device); System.Diagnostics.Debug.WriteLine(deviceConnection.Open()); deviceEty = new DeviceComEty(); deviceEty.Device = device; deviceEty.DeviceConnection = deviceConnection; //----------------------------------------- object extraProperty = new object(); object extraData = new object(); extraData = Global.DeviceBusy; try { List <DateTime> dtList = new List <DateTime>(); bool result = deviceConnection.SetProperty(DeviceProperty.Enable, extraProperty, device, extraData); //------------------------------------------ BINUGO CODE dtList.Add(Convert.ToDateTime("08/01/2017")); dtList.Add(DateTime.Now); //----------------------------------------- //dtList.Add(model.TO.Date); //dtList.Add(model.TO.Date); extraProperty = false; extraData = dtList; result = deviceConnection.GetProperty(DeviceProperty.AttRecordsCount, extraProperty, ref device, ref extraData); if (false == result) { TempData["msg"] = "<script>alert('Download Failed');</script>"; } int recordCount = (int)extraData; if (0 == recordCount) {//为0时说明没有新日志记录 ListDownloadData.Clear(); } List <bool> boolList = new List <bool>(); //----------------------------------------- BINUGO CODE boolList.Add(false); //所有日志 boolList.Add(false); //清除新日志标记,false则不清除 //----------------------------------------- extraProperty = boolList; extraData = dtList; result = deviceConnection.GetProperty(DeviceProperty.AttRecords, extraProperty, ref device, ref extraData); if (result) { int i = 1; int y = 0; List <Record> recordList = (List <Record>)extraData; ListDownloadData.Clear(); foreach (Record record in recordList) { ListDownloadData.Add(new DownloadDataViewModel { SN = i.ToString(), DN = record.DN.ToString(), DIN = record.DIN.ToString(), Type = ConvertObject.GLogType(record.Verify), mode = ConvertObject.IOMode(record.Action), Clock = record.Clock.ToString("yyyy-MM-dd HH:mm:ss") }); i++; } Session["SessionName"] = ListDownloadData; } else { TempData["msg"] = "<script>alert('Download Failed');</script>"; } } catch (Exception) { TempData["msg"] = "<script>alert('Download Failed');</script>"; } return(View("ConnectBiometric", ListDownloadData)); }