Esempio n. 1
0
        public DeviceReply GetDataDemography(string idOperator, string nikOperator, string idAuth, string nikAuth, int timeout)
        {
            DeviceReply dev = new DeviceReply();
            IntPtr      pAddressOfFunctionToCall = NativeMethods.GetProcAddress(this.pDll, "ektp_getDataDemography");

            if (pAddressOfFunctionToCall == IntPtr.Zero)
            {
                dev.Error_code  = -1;
                dev.Err_message = "Method Or Function Not Found";
                return(dev);
            }
            ektp_getDataDemography ektpgetDataDemography = (ektp_getDataDemography)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall, typeof(ektp_getDataDemography));

            byte[] error = new byte[20];
            //string error = "";
            //StringBuilder sb = new StringBuilder(1000);
            IntPtr pointers  = new IntPtr();
            int    theResult = ektpgetDataDemography(error, timeout, idOperator, nikOperator, idAuth, nikAuth, ref pointers);


            //string data = sb.ToString();
            string data = Marshal.PtrToStringAnsi(pointers);

            data = data.Replace("\"", "");
            string[]   array   = data.Split(',');
            Demography demo    = new Demography();
            var        options = new JsonSerializerOptions
            {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                WriteIndented        = true
            };

            demo.Nik     = array[0].ToString().Split("=")[1].ToString();
            demo.Name    = array[1].ToString().Split("=")[1].ToString();
            demo.Address = array[2].ToString().Split("=")[1].ToString();

            demo.PlaceOfBirth = array[3].ToString().Split("=")[1].ToString();
            demo.DateOfBirth  = array[4].ToString().Split("=")[1].ToString();
            demo.Gender       = array[5].ToString().Split("=")[1].ToString();

            demo.RT      = array[6].ToString().Split("=")[1].ToString();
            demo.RW      = array[7].ToString().Split("=")[1].ToString();
            demo.Village = array[8].ToString().Split("=")[1].ToString();

            demo.SubDistrict = array[9].ToString().Split("=")[1].ToString();
            demo.City        = array[10].ToString().Split("=")[1].ToString();
            demo.Province    = array[11].ToString().Split("=")[1].ToString();

            demo.BloodType     = array[12].ToString().Split("=")[1].ToString();
            demo.Religion      = array[13].ToString().Split("=")[1].ToString();
            demo.MaritalStatus = array[14].ToString().Split("=")[1].ToString();
            demo.Occupation    = array[15].ToString().Split("=")[1].ToString();
            demo.Nationality   = array[16].ToString().Split("=")[1].ToString();
            demo.PlaceOfIssue  = array[17].ToString().Split("=")[1].ToString();
            string err_msg = "";

            if (theResult == 0)
            {
                err_msg = JsonSerializer.Serialize(demo, options);
            }
            else
            {
                //err_msg = Encoding.ASCII.GetString(error);
                err_msg = "";//error;
            }
            dev.Error_code = theResult;

            dev.Err_message = err_msg;
            return(dev);
        }
Esempio n. 2
0
        static void RunUtils(string userDomain, string ip, string operation, string fingerTemplate, string nik, string wsid, string cardNumber, string hashIso)
        {
            // Load configuration
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));


            var dataOutParam = new OutParam();

            dataOutParam.userDomain = userDomain;
            dataOutParam.ip         = ip;
            dataOutParam.operation  = operation;
            Utils ut = new Utils(operation);

            log.Info("Check Type of Operation");
            if (operation == "1")
            {
                log.Info("Operation Type 1: Login Finger Print");

                var ektpDeviceStatus = ut.DeviceOpen();
                var ektpDevice       = ut.EktpDevice(fingerTemplate, nik, wsid, hashIso);

                dataOutParam.errCode    = "0";//ektpDevice.Error_code.ToString();
                dataOutParam.errMessage = ektpDevice.Err_message;

                // call signalR method
                log.Info("Invoke Websocket method ReceiveFromAgent");
                log.Info("To Deliver Data to Angular Client");
                ut.DeviceClose();
                connection.InvokeAsync("ReceiveFromAgent", dataOutParam);
            }
            else if (operation == "12")
            {
                var ektpDevice = ut.DeviceOpen();

                dataOutParam.errCode    = "0";// ektpDevice.Error_code.ToString();//"0";
                dataOutParam.errMessage = ektpDevice.Err_message;

                ut.DeviceClose();
                // call signalR method
                connection.InvokeAsync("InfoConnDevice", dataOutParam);
            }
            else if (operation == "13")
            {
                var ektpDeviceStatus = ut.DeviceOpen();
                var putEktp          = ut.PutEKTP();
                dataOutParam.errCode    = "0";//putEktp.Error_code.ToString();//"0";
                dataOutParam.errMessage = putEktp.Err_message;
                ut.DeviceClose();
                // call signalR method
                connection.InvokeAsync("SendResultPutEktp", dataOutParam);
            }
            else if (operation == "14")
            {
                var ektpDeviceStatus = ut.DeviceOpen();
                var getDataDemo      = ut.GetDataDemography(wsid, nik, "idAuth", "nikAuth", 20);
                dataOutParam.errCode    = getDataDemo.Error_code.ToString();
                dataOutParam.errMessage = getDataDemo.Err_message;
                ut.DeviceClose();
                // call signalR method
                connection.InvokeAsync("SendResultDataDemography", dataOutParam);
            }
            else if (operation == "15")
            {
                var ektpDeviceStatus = ut.DeviceOpen();

                var verifyFingerNasabah = ut.VerifyFinger("2R", userDomain, nik);
                dataOutParam.errCode = "0"; // verifyFingerNasabah.Error_code.ToString();//"0";
                                            //dataOutParam.errMessage = verifyFingerNasabah.Err_message;

                /*if (verifyFingerNasabah.Error_code == 0)
                 * {
                 *  var getDataDemo = ut.GetDataDemography(wsid, nik, "idAuth", "nikAuth", 20);
                 *  dataOutParam.errCode = getDataDemo.Error_code.ToString();
                 *  dataOutParam.errMessage = getDataDemo.Err_message;
                 * } */
                Demography demo    = new Demography();
                var        options = new JsonSerializerOptions
                {
                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                    WriteIndented        = true
                };
                demo.Nik     = "1234567890";
                demo.Name    = "Nama Dummy";
                demo.Address = "Alamat Dummy";

                demo.PlaceOfBirth = "";
                demo.DateOfBirth  = "";
                demo.Gender       = "";

                demo.RT      = "";
                demo.RW      = "";
                demo.Village = "";

                demo.SubDistrict = "";
                demo.City        = "";
                demo.Province    = "";

                demo.BloodType          = "";
                demo.Religion           = "";
                demo.MaritalStatus      = "";
                demo.Occupation         = "";
                demo.Nationality        = "";
                demo.PlaceOfIssue       = "";
                dataOutParam.errMessage = JsonSerializer.Serialize(demo, options);
                Console.WriteLine(dataOutParam.errMessage);
                ut.DeviceClose();
                // call signalR method
                connection.InvokeAsync("SendResultVerifyNasabah", dataOutParam);
            }
            else if (operation == "2")
            {
                var ektpDeviceStatus = ut.PinpadOpen();
                // EDC Swipe Card
                var cardSwipeResult = ut.SwipeCard("Please swipe card");
                dataOutParam.errCode    = "0";                         //cardSwipeResult.Error_code.ToString();//"0";
                dataOutParam.errMessage = cardSwipeResult.Err_message; //"1234567890";

                ut.closeLibraryPinpad();
                // nanti call signalR method
                connection.InvokeAsync("SendResultSwapCard", dataOutParam);
            }
            else if (operation == "21")
            {
                var ektpDeviceStatus = ut.PinpadOpen();
                // EDC Verify Pin
                var verifyPinResult = ut.GetPin("Input Pin:", cardNumber);
                dataOutParam.errCode    = "0"; verifyPinResult.Error_code.ToString();//"0";
                dataOutParam.errMessage = verifyPinResult.Err_message;
                ut.closeLibraryPinpad();
                // nanti call signalR method
                connection.InvokeAsync("SendResultInputPin", dataOutParam);
            }
        }