public static List <MODEL.Turnstile> GetAllDevices(DAL.Nodejs api) { var json = GetDevices.GetDevicesJSON(api.LoginToken); var dataset = api.GetDataSet(json); DataTable dt = dataset.Tables["datatable1"]; List <MODEL.Turnstile> list = new List <MODEL.Turnstile>(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { MODEL.Turnstile a = new MODEL.Turnstile(); a.ID = Convert.ToInt32(dt.Rows[i]["ID"]); a.NAME = dt.Rows[i]["NAME"].ToString(); a.IPNUMBER = dt.Rows[i]["IPNUMBER"].ToString(); a.PORTNUMBER = dt.Rows[i]["PORTNUMBER"].ToString(); try { a.ISENTRANCE = Convert.ToBoolean(dt.Rows[i]["ISENTRANCE"].ToString()); } catch (Exception) { a.ISENTRANCE = null; } try { a.HASOWNREADER = Convert.ToBoolean(dt.Rows[i]["HASOWNREADER"].ToString()); } catch (Exception) { a.HASOWNREADER = false; } a.READER_ENTRY_COMPORT = dt.Rows[i]["READER_ENTRY_COMPORT"].ToString(); a.READER_EXIT_COMPORT = dt.Rows[i]["READER_EXIT_COMPORT"].ToString(); list.Add(a); } } return(list); }
public static MODEL.Result CheckBarcodeForEntry(string barcode, DAL.Nodejs api) { MODEL.Result result = new MODEL.Result(); var json = CheckBarcode.CheckBarcodeJSON(barcode, api.LoginToken); var dataset = api.GetDataSet(json, "Execute"); DataTable dt = dataset.Tables["datatable1"]; if (dt.Rows.Count > 0) { result.Success = Convert.ToBoolean(dt.Rows[0]["SUCCESS"]); result.Message = dt.Rows[0]["MESSAGE"].ToString(); } else { result.Success = false; result.Message = "Procedure did not returned any message"; } return(result); }