public bool checkAPBOptionInAuthConfig(IntPtr sdkContext, UInt32 deviceID, byte networkFailAction) { BS2AuthConfig authConfig; BS2ErrorCode result = (BS2ErrorCode)API.BS2_GetAuthConfig(sdkContext, deviceID, out authConfig); if (result != BS2ErrorCode.BS_SDK_SUCCESS) { Console.WriteLine("Got error({0}).", result); return(false); } const byte On = 1; if (authConfig.useGlobalAPB != On) { authConfig.useGlobalAPB = On; authConfig.globalAPBFailAction = networkFailAction; result = (BS2ErrorCode)API.BS2_SetAuthConfig(sdkContext, deviceID, ref authConfig); if (result != BS2ErrorCode.BS_SDK_SUCCESS) { Console.WriteLine("Got error({0}).", result); return(false); } } return(true); }
public void changeAuthMode(IntPtr sdkContext, UInt32 deviceID, bool isMasterDevice, bool turnOn) { Console.WriteLine("Get slave device ID"); Console.Write(">>>> "); UInt32 slaveID = (UInt32)Util.GetInput(); BS2AuthConfig authConfig; Console.WriteLine("Getting auth config."); BS2ErrorCode result = (BS2ErrorCode)API.BS2_GetAuthConfig(sdkContext, slaveID, out authConfig); if (result != BS2ErrorCode.BS_SDK_SUCCESS) { Console.WriteLine("Got error({0}).", result); return; } Console.WriteLine("Select auth mode."); Console.WriteLine(" 0. Biometric Only"); Console.WriteLine(" 1. Biometric + PIN"); Console.WriteLine(" 2. Card Only"); Console.WriteLine(" 3. Card + Biometric"); Console.WriteLine(" 4. Card + PIN"); Console.WriteLine(" 5. Card + Biometric/PIN"); Console.WriteLine(" 6. Card + Biometric + PIN"); Console.WriteLine(" 7. ID + Biometric"); Console.WriteLine(" 8. ID + PIN"); Console.WriteLine(" 9. ID + Biometric/PIN"); Console.WriteLine(" 10. ID + Biometric + PIN"); Console.Write(">>>> "); UInt32 mode = (UInt32)Util.GetInput(); if (10 < mode) { Console.WriteLine("Invalid auth mode"); return; } else { authConfig.authSchedule[mode] = turnOn ? 1U : 0U; Console.WriteLine("Turn {0} auth mode.", turnOn ? "on" : "off"); result = (BS2ErrorCode)API.BS2_SetAuthConfig(sdkContext, slaveID, ref authConfig); if (result != BS2ErrorCode.BS_SDK_SUCCESS) { Console.WriteLine("Got error({0}).", result); return; } } BS2AuthConfig configResult; result = (BS2ErrorCode)API.BS2_GetAuthConfig(sdkContext, slaveID, out configResult); if (result != BS2ErrorCode.BS_SDK_SUCCESS) { Console.WriteLine("Got error({0}).", result); return; } print(configResult); }
//void slaveExControl(IntPtr sdkContext, List<BS2Rs485SlaveDeviceEX> slaveDeviceList) //{ // //TODO implement this section. // foreach (BS2Rs485SlaveDeviceEX slaveDevice in slaveDeviceList) // { // BS2AuthConfig authConfig; // Console.WriteLine("Getting auth config. reader[{0}]", slaveDevice.deviceID); // BS2ErrorCode result = (BS2ErrorCode)API.BS2_GetAuthConfig(sdkContext, slaveDevice.deviceID, out authConfig); // if (result != BS2ErrorCode.BS_SDK_SUCCESS) // { // Console.WriteLine("Get auth config. reader[{0}]-error[{1}].", slaveDevice.deviceID, result); // return; // } // Console.WriteLine("Get auth config. reader[{0}]-AuthMode[{1}].", slaveDevice.deviceID, getAuthInfo(authConfig)); // } //} public void getSlaveExAuthMode(IntPtr sdkContext, UInt32 slaveID) { BS2AuthConfig authConfig; Console.WriteLine("Getting auth config. reader[{0}]", slaveID); BS2ErrorCode result = (BS2ErrorCode)API.BS2_GetAuthConfig(sdkContext, slaveID, out authConfig); if (result != BS2ErrorCode.BS_SDK_SUCCESS) { Console.WriteLine("Get auth config. reader[{0}]-error[{1}].", slaveID, result); return; } Console.WriteLine("Get auth config. reader[{0}]-AuthMode[{1}].", slaveID, getAuthInfo(authConfig)); }
void slaveExControl(IntPtr sdkContext, List <BS2Rs485SlaveDeviceEX> slaveDeviceList) { //TODO implement this section. foreach (BS2Rs485SlaveDeviceEX slaveDevice in slaveDeviceList) { BS2AuthConfig authConfig; Console.WriteLine("Getting auth config. reader[{0}]", slaveDevice.deviceID); BS2ErrorCode result = (BS2ErrorCode)API.BS2_GetAuthConfig(sdkContext, slaveDevice.deviceID, out authConfig); if (result != BS2ErrorCode.BS_SDK_SUCCESS) { Console.WriteLine("Get auth config. reader[{0}]-error[{1}].", slaveDevice.deviceID, result); return; } Console.WriteLine("Get auth config. reader[{0}]-AuthMode[{1}].", slaveDevice.deviceID, getAuthInfo(authConfig)); } }
public void StartGlobalAPBZone(IntPtr sdkContext, UInt32 deviceID, bool isMasterDevice) { zoneManager = new GlobalAPBZoneManager(); UInt32[] connectedDeviceIDs = null; uint numDevice = 0; IntPtr deviceObjList = IntPtr.Zero; API.BS2_GetDevices(sdkContext, out deviceObjList, out numDevice); connectedDeviceIDs = new UInt32[numDevice]; for (int idx = 0; idx < numDevice; ++idx) { connectedDeviceIDs[idx] = Convert.ToUInt32(Marshal.ReadInt32(deviceObjList, (int)idx * sizeof(UInt32))); } API.BS2_ReleaseObject(deviceObjList); if (connectedDeviceIDs.Length < 2) { Console.WriteLine("Number of connected device is {0}. At least two terminals must be connected.", connectedDeviceIDs.Length); return; } Console.WriteLine("+----------------------------------------------------------------------------------------------------------+"); for (UInt32 idx = 0; idx < numDevice; ++idx) { Console.WriteLine("[{0:000}] ==> ID[{1, 10}]", idx, connectedDeviceIDs[idx]); } Console.WriteLine("+----------------------------------------------------------------------------------------------------------+"); char[] delimiterChars = { ' ', ',', '.', ':', '\t' }; Console.WriteLine("Enter index of the readers which are used as >>>>> IN <<<<< device of global apb zone: [0,1,2 ...]"); Console.Write(">>>> "); string[] readerIndexs = Console.ReadLine().Split(delimiterChars); for (int idx = 0; idx < readerIndexs.Length; ++idx) { UInt32 indexOfReader; if (UInt32.TryParse(readerIndexs[idx], out indexOfReader) && indexOfReader < numDevice) { if (BS2ErrorCode.BS_SDK_SUCCESS == (BS2ErrorCode)API.BS2_ConnectDevice(sdkContext, connectedDeviceIDs[indexOfReader])) { zoneManager.inDeviceIDs.Add(connectedDeviceIDs[indexOfReader]); } } else { Console.WriteLine("Got error(Invaild index({0})).", readerIndexs[idx]); return; } } Console.WriteLine("Enter index of the readers which are used as <<<<< OUT >>>>> device of global apb zone: [0,1,2 ...]"); Console.Write(">>>> "); readerIndexs = Console.ReadLine().Split(delimiterChars); for (int idx = 0; idx < readerIndexs.Length; ++idx) { UInt32 indexOfReader; if (UInt32.TryParse(readerIndexs[idx], out indexOfReader) && indexOfReader < numDevice) { if (BS2ErrorCode.BS_SDK_SUCCESS == (BS2ErrorCode)API.BS2_ConnectDevice(sdkContext, connectedDeviceIDs[indexOfReader])) { if (!zoneManager.inDeviceIDs.Contains(connectedDeviceIDs[indexOfReader])) { zoneManager.outDeviceIDs.Add(connectedDeviceIDs[indexOfReader]); } else { Console.WriteLine("Got error(index({0}) is IN device already.).", readerIndexs[idx]); return; } } } else { Console.WriteLine("Got error(Invaild index({0})).", readerIndexs[idx]); return; } } Console.WriteLine("Which type is this global apb zone? [{0} : {1}, {2} : {3}(default)]", (byte)BS2APBZoneTypeEnum.HARD, BS2APBZoneTypeEnum.HARD, (byte)BS2APBZoneTypeEnum.SOFT, BS2APBZoneTypeEnum.SOFT); Console.Write(">>>> "); zoneManager.APBZoneType = (BS2APBZoneTypeEnum)Util.GetInput((byte)BS2APBZoneTypeEnum.SOFT); BS2GlobalAPBFailActionTypeEnum networkFailAction = BS2GlobalAPBFailActionTypeEnum.NONE; Console.WriteLine("Which network fail action type is this global apb zone? [{0} : {1}(default), {2} : {3}, {4} : {5}]", (byte)BS2GlobalAPBFailActionTypeEnum.NONE, BS2GlobalAPBFailActionTypeEnum.NONE, (byte)BS2GlobalAPBFailActionTypeEnum.SOFT, BS2GlobalAPBFailActionTypeEnum.SOFT, (byte)BS2GlobalAPBFailActionTypeEnum.HARD, BS2GlobalAPBFailActionTypeEnum.HARD); Console.Write(">>>> "); networkFailAction = (BS2GlobalAPBFailActionTypeEnum)Util.GetInput((byte)BS2GlobalAPBFailActionTypeEnum.NONE); Console.WriteLine("Enter the ID for the zone which you want to set"); Console.Write(">>>> "); zoneManager.zoneID = (UInt32)Util.GetInput(); SortedSet <UInt32> zoneReaders = new SortedSet <UInt32>(); zoneReaders.UnionWith(zoneManager.inDeviceIDs); zoneReaders.UnionWith(zoneManager.outDeviceIDs); BS2ErrorCode result = 0; foreach (UInt32 zoneReaderID in zoneReaders) { BS2AuthConfig authConfig; Console.WriteLine("Getting auth config. reader[{0}]", zoneReaderID); result = (BS2ErrorCode)API.BS2_GetAuthConfig(sdkContext, zoneReaderID, out authConfig); if (result != BS2ErrorCode.BS_SDK_SUCCESS) { Console.WriteLine("Got error({0}).", result); return; } authConfig.useGlobalAPB = 1; authConfig.globalAPBFailAction = (byte)networkFailAction; Console.WriteLine("Setting auth config. reader[{0}]", zoneReaderID); result = (BS2ErrorCode)API.BS2_SetAuthConfig(sdkContext, zoneReaderID, ref authConfig); if (result != BS2ErrorCode.BS_SDK_SUCCESS) { Console.WriteLine("Got error({0}).", result); return; } } this.sdkContext = sdkContext; taskExecutor = new CheckGlobalAPBViolationTaskExecutor(); Console.WriteLine("Attaching a global apb zone handler."); cbCheckGlobalAPBViolation = new API.OnCheckGlobalAPBViolation(onCheckGlobalAPBViolation); result = (BS2ErrorCode)API.BS2_SetCheckGlobalAPBViolationHandler(sdkContext, cbCheckGlobalAPBViolation); if (result != BS2ErrorCode.BS_SDK_SUCCESS) { Console.WriteLine("Got error({0}).", result); return; } taskExecutor.start(); Console.WriteLine("Press ESC to stop global apb zone."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { Thread.Sleep(100); } taskExecutor.stop(); Console.WriteLine("Detaching a global apb zone handler."); result = (BS2ErrorCode)API.BS2_SetCheckGlobalAPBViolationHandler(sdkContext, null); if (result != BS2ErrorCode.BS_SDK_SUCCESS) { Console.WriteLine("Got error({0}).", result); return; } cbCheckGlobalAPBViolation = null; taskExecutor = null; zoneManager = null; }
public void setSlaveExAuthMode(IntPtr sdkContext, UInt32 slaveID) { BS2AuthConfig authConfig; Console.WriteLine("Getting auth config."); BS2ErrorCode result = (BS2ErrorCode)API.BS2_GetAuthConfig(sdkContext, slaveID, out authConfig); if (result != BS2ErrorCode.BS_SDK_SUCCESS) { Console.WriteLine("Get auth config. reader[{0}]-error[{1}].", slaveID, result); return; } bool stop = false; do { Console.WriteLine("Select auth mode."); Console.WriteLine(" 0. Biometric Only"); Console.WriteLine(" 1. Biometric + PIN"); Console.WriteLine(" 2. Card Only"); Console.WriteLine(" 3. Card + Biometric"); Console.WriteLine(" 4. Card + PIN"); Console.WriteLine(" 5. Card + Biometric/PIN"); Console.WriteLine(" 6. Card + Biometric + PIN"); Console.WriteLine(" 7. ID + Biometric"); Console.WriteLine(" 8. ID + PIN"); Console.WriteLine(" 9. ID + Biometric/PIN"); Console.WriteLine(" 10. ID + Biometric + PIN"); Console.WriteLine("999. No more changes."); Console.Write(">>>> "); UInt32 mode = (UInt32)Util.GetInput(); if (10 < mode && 999 != mode) { Console.WriteLine("Invalid auth mode"); return; } if (999 == mode) { stop = true; } else { Console.WriteLine("0. Off (No time)"); Console.WriteLine("1. On (Always)"); Console.Write(">>>> "); UInt32 onoff = (UInt32)Util.GetInput(); if (0 == onoff || 1 == onoff) { authConfig.authSchedule[mode] = onoff; } } } while (!stop); result = (BS2ErrorCode)API.BS2_SetAuthConfig(sdkContext, slaveID, ref authConfig); if (result != BS2ErrorCode.BS_SDK_SUCCESS) { Console.WriteLine("Got error({0}).", result); return; } BS2AuthConfig configResult; result = (BS2ErrorCode)API.BS2_GetAuthConfig(sdkContext, slaveID, out configResult); if (result != BS2ErrorCode.BS_SDK_SUCCESS) { Console.WriteLine("Got error({0}).", result); return; } print(configResult); }