Skip to content

Instantly share code, notes, and snippets.

@jimanx2
Created March 1, 2017 02:51
Show Gist options
  • Select an option

  • Save jimanx2/92a3c76fc6966623242bc52dff57fdd3 to your computer and use it in GitHub Desktop.

Select an option

Save jimanx2/92a3c76fc6966623242bc52dff57fdd3 to your computer and use it in GitHub Desktop.
var Persona = require('./lib/persona').Persona;
var unsub;
Persona(null, function(error, _unsub){
unsub = _unsub;
});
if (process.platform === "win32") {
var rl = require("readline").createInterface({
input: process.stdin,
output: process.stdout
});
rl.on("SIGINT", function () {
process.emit("SIGINT");
});
}
process.on("SIGINT", function () {
//graceful shutdown
unsub(null, function(err){
process.exit();
});
});
var edge = require('edge');
var Persona = edge.func({
references: ["DPFPDevNET.dll", "DPFPShrNET.dll"],
source: function(){/*
using System;
using System.Threading.Tasks;
public class Startup
{
internal class DigitalPersona : DPFP.Capture.EventHandler
{
private DPFP.Capture.Capture Capturer;
private dynamic eventHandlers { get; set; }
#region EventHandlers
public void OnComplete(object capture, string reader, DPFP.Sample sample)
{
Console.WriteLine("Complete");
}
public void OnFingerGone(object capture, string reader)
{
Console.WriteLine("Release");
}
public void OnFingerTouch(object capture, string reader)
{
Console.WriteLine("Touch");
}
public void OnReaderConnect(object capture, string reader)
{
Console.WriteLine("Conenct");
}
public void OnReaderDisconnect(object capture, string reader)
{
Console.WriteLine("Disconnect");
}
public void OnSampleQuality(object capture, string reader, DPFP.Capture.CaptureFeedback feedback)
{
Console.WriteLine("Sample");
}
#endregion
public DigitalPersona()
{
try
{
// Initializes DigitalPersona SDK Capturing Library
Capturer = new DPFP.Capture.Capture();
if (null != Capturer)
{
// Assign this class (DigitalPersona) as handler for events fired in the capturing libary
Capturer.EventHandler = this;
// Start the capture proccess
Capturer.StartCapture();
Console.WriteLine("Using the fingerprint reader, scan your fingerprint.");
}
else
{
// Failed to init capturing library
Console.WriteLine("Cannot init Capturer!");
}
}
catch (Exception ex)
{
Console.WriteLine("Error! " + ex.Message);
// Stop the capture process (just in case)
Capturer.StopCapture();
}
}
}
// Entrypoint for EdgeJS (it needs the Invoke async method by default)
public async Task<object> Invoke(dynamic input)
{
var ws = new DigitalPersona();
// Return a callable function from NodeJS
return (Func<object, Task<object>>)(async (dynamic data) =>
{
return null;
});
}
// Main entrypoint, to run in Visual Studio
public static void Main(string[] args)
{
var st = new Startup();
st.Invoke(null);
Console.Read();
}
}
*/}
});
module.exports = {
Persona: Persona
};
using System;
using System.Threading.Tasks;
using DPFP.Capture;
namespace DPFingerTest
{
using System;
using System.Threading.Tasks;
using DPFP.Capture;
using System;
using System.Threading.Tasks;
public class Startup
{
internal class DigitalPersona : DPFP.Capture.EventHandler
{
private DPFP.Capture.Capture Capturer;
private dynamic eventHandlers { get; set; }
#region EventHandlers
public void OnComplete(object capture, string reader, DPFP.Sample sample)
{
Console.WriteLine("Complete");
}
public void OnFingerGone(object capture, string reader)
{
Console.WriteLine("Release");
}
public void OnFingerTouch(object capture, string reader)
{
Console.WriteLine("Touch");
}
public void OnReaderConnect(object capture, string reader)
{
Console.WriteLine("Conenct");
}
public void OnReaderDisconnect(object capture, string reader)
{
Console.WriteLine("Disconnect");
}
public void OnSampleQuality(object capture, string reader, DPFP.Capture.CaptureFeedback feedback)
{
Console.WriteLine("Sample");
}
#endregion
public DigitalPersona()
{
try
{
// Initializes DigitalPersona SDK Capturing Library
Capturer = new DPFP.Capture.Capture();
if (null != Capturer)
{
// Assign this class (DigitalPersona) as handler for events fired in the capturing libary
Capturer.EventHandler = this;
// Start the capture proccess
Capturer.StartCapture();
Console.WriteLine("Using the fingerprint reader, scan your fingerprint.");
}
else
{
// Failed to init capturing library
Console.WriteLine("Cannot init Capturer!");
}
}
catch (Exception ex)
{
Console.WriteLine("Error! " + ex.Message);
// Stop the capture process (just in case)
Capturer.StopCapture();
}
}
}
// Entrypoint for EdgeJS (it needs the Invoke async method by default)
public async Task<object> Invoke(dynamic input)
{
var ws = new DigitalPersona();
// Return a callable function from NodeJS
return (Func<object, Task<object>>)(async (dynamic data) =>
{
return null;
});
}
// Main entrypoint, to run in Visual Studio
public static void Main(string[] args)
{
var st = new Startup();
st.Invoke(null);
Console.Read();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment