public GuestEdit(List <guestDetails> guestDetailsList, guestDetails Object) { //Passing values value on page load to fields and pickers InitializeComponent(); //Setting limits for datetime. DateTime date = new DateTime(1900, 1, 1); DateOfBirth.MaximumDate = DateTime.Today; DateOfBirth.MinimumDate = date; //setting guest details retrieved from guestifo page guestdetails = guestDetailsList; guestCodeFromSearch = Object.guestCode; Visitperhotel = Object.noOfVisitsHotel; Totalvisit = Object.noOfVisits; RevenueTotal = Object.revenueTotal; RevenueRoom = Object.revenueRoom; RevenueFnb = Object.reveneuFB; RevenueOther = Object.revenueOther; //countryFromSearch = Object.country; if (Object.passportIdNumber == "") { hideUntilSearched.IsVisible = false; viewUntilSearched.IsVisible = true; } else { hideUntilSearched.IsVisible = true; viewUntilSearched.IsVisible = false; } pageLoading(); guestDetailsAvailableOnLoad((Object.guestNumber).ToString(), Object.identificationMethod, Object.passportIdNumber, Object.salutation, Object.guestFirstName, Object.guestLastName, Object.gender, Object.email, Object.contactNumber, Object.houseNumber, Object.street, Object.city, Object.country, Object.nationality, Object.language, Object.guestCode, Object.dateOfBirth, Object.dateOfExpiry); //Getting results after passport successfully scanned MessagingCenter.Subscribe <Messages.BlinkIDResults>(this, Messages.BlinkIDResultsMessage, async(sender) => { pageLoading(); try { //Values from passport foreach (var result in sender.Results) { //Seperating values from array result.TryGetValue("SecondaryId", out fname); result.TryGetValue("PrimaryId", out lname); result.TryGetValue("Nationality", out nationality); result.TryGetValue("Sex", out gender); result.TryGetValue("DocumentNumber", out PassportNumber); result.TryGetValue("DateOfExpiry", out dateOfExpiry); result.TryGetValue("DateOfBirth", out dateOfBirthPass); PassportNumber = Regex.Replace(PassportNumber, "[^A-Za-z0-9 _]", ""); //List of identification methods from dictionary var nameToAlpha2FromAlpha3 = CountryDictionary.listAlpha3To(); //Getting Key Value from Dictoinary by passing the THREE Letter code nationality = nameToAlpha2FromAlpha3.FirstOrDefault(x => x.Key == nationality).Value; //string guestNumberPassport = guestNumber.Text; } new APILogger().Logger($"PP Scan Result : FName {fname},LName {lname},Nationality {nationality},Sex {gender},DocumentNumber {PassportNumber},DateOfExpiry {dateOfExpiry},DateOfBirth {dateOfBirthPass}"); await existingGuestDetailsFromDatabses(2, PassportNumber); Device.BeginInvokeOnMainThread(() => { GuestFisrtName.Text = fname; GuestLastName.Text = lname; guestIdentificationDetailsPicker("2"); guestNationalityDetailsPicker(nationality); guestContryDetailsPicker(nationality); guestLanguageDetailsPicker("E"); PassportExpiry.Date = FormatChanges.PassScanDateFormat(dateOfExpiry); guestGenderDetailsPicker(serviceDataValidation.guestEditGenderValidation(gender)); DateOfBirth.Date = FormatChanges.PassScanDateFormat(dateOfBirthPass); stopPageLoading(); }); } catch (Exception) { Device.BeginInvokeOnMainThread(() => { stopPageLoading(); guestEntryDetails(guestNumber.Text, PassportNumber, fname, lname, "", "", "", "", ""); guestIdentificationDetailsPicker("2"); guestNationalityDetailsPicker(nationality); guestContryDetailsPicker(nationality); guestLanguageDetailsPicker("E"); guestSalutationPicker(""); guestGenderDetailsPicker(serviceDataValidation.guestEditGenderValidation(gender)); PassportExpiry.Date = FormatChanges.PassScanDateFormat(dateOfExpiry); DateOfBirth.Date = FormatChanges.PassScanDateFormat(dateOfBirthPass); Visitperhotel = "00"; Totalvisit = "00"; RevenueTotal = "0.00"; RevenueRoom = "0.00"; RevenueFnb = "0.00"; RevenueOther = "0.00"; stopPageLoading(); DisplayAlert(Constants._headerMessage, Constants._noDetails, Constants._buttonOkay); }); } //MessagingCenter.Unsubscribe<Messages.BlinkIDResults>(this, Messages.BlinkIDResultsMessage); }); }
private void InitBlinkID() { // before obtaining any of the recognizer's implementations from DependencyService, it is required // to obtain instance of IMicroblinkScanner and set the license key. // Failure to do so will crash your app. var microblinkFactory = DependencyService.Get <IMicroblinkScannerFactory>(); // license keys are different for iOS and Android and depend on iOS bundleID/Android application ID // in your app, you may obtain the correct license key for your platform via DependencyService from // your Droid/iOS projects string licenseKey; // both these license keys are demo license keys for bundleID/applicationID com.microblink.xamarin.blinkid if (Device.R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zH9syNrE8Qfano3mAP8O4zxg0/c="; } // since DependencyService requires implementations to have default constructor, a factory is needed // to construct implementation of IMicroblinkScanner with given license key blinkID = microblinkFactory.CreateMicroblinkScanner(licenseKey); // subscribe to scanning done message MessagingCenter.Subscribe <ScanningDoneMessage>(this, ScanningDoneMessageId, async(sender) => { pageLoading(); try { ImageSource fullDocumentImageSource = null; ImageSource successFrameImageSource = null; string stringResult = "No valid results."; // if user cancelled scanning, sender.ScanningCancelled will be true if (sender.ScanningCancelled) { stringResult = "Scanning cancelled"; } else { // otherwise, one or more recognizers used in RecognizerCollection (see StartScan method below) // will contain result // if specific recognizer's result's state is Valid, then it contains data recognized from image if (mrtdRecognizer.Result.ResultState == RecognizerResultState.Valid) { var result = mrtdRecognizer.Result; lname = result.MrzResult.PrimaryId; fname = result.MrzResult.SecondaryId; nationality = result.MrzResult.Nationality; gender = result.MrzResult.Gender; PassportNumber = Regex.Replace(result.MrzResult.DocumentNumber, "[^A-Za-z0-9 _]", ""); dateOfExpiry = $"{result.MrzResult.DateOfExpiry.Day}-{result.MrzResult.DateOfExpiry.Month}-{result.MrzResult.DateOfExpiry.Year}"; dateOfBirthPass = $"{result.MrzResult.DateOfBirth.Day}-{result.MrzResult.DateOfBirth.Month}-{result.MrzResult.DateOfBirth.Year}"; //List of identification methods from dictionary var nameToAlpha2FromAlpha3 = CountryDictionary.listAlpha3To(); //Getting Key Value from Dictoinary by passing the THREE Letter code nationality = nameToAlpha2FromAlpha3.FirstOrDefault(x => x.Key == nationality).Value; //Extracting document Images fullDocumentImageSource = result.FullDocumentImage; successFrameImageSource = mrtdSuccessFrameGrabberRecognizer.Result.SuccessFrame; //Set Image to Globals Constants.PassportCopy = fullDocumentImageSource; await existingGuestDetailsFromDatabses(2, PassportNumber); Device.BeginInvokeOnMainThread(() => { GuestFisrtName.Text = fname; GuestLastName.Text = lname; guestIdentificationDetailsPicker("2"); guestNationalityDetailsPicker(nationality); guestContryDetailsPicker(nationality); guestLanguageDetailsPicker("E"); PassportExpiry.Date = DateTime.ParseExact(dateOfExpiry, "d-M-yyyy", CultureInfo.CurrentCulture); guestGenderDetailsPicker(serviceDataValidation.guestEditGenderValidation(gender)); DateOfBirth.Date = DateTime.ParseExact(dateOfBirthPass, "d-M-yyyy", CultureInfo.CurrentCulture); stopPageLoading(); }); } } } catch (Exception) { Device.BeginInvokeOnMainThread(() => { stopPageLoading(); guestEntryDetails(guestNumber.Text, PassportNumber, fname, lname, "", "", "", "", ""); guestIdentificationDetailsPicker("2"); guestNationalityDetailsPicker(nationality); guestContryDetailsPicker(nationality); guestLanguageDetailsPicker("E"); guestSalutationPicker(""); guestGenderDetailsPicker(serviceDataValidation.guestEditGenderValidation(gender)); PassportExpiry.Date = DateTime.ParseExact(dateOfExpiry, "d-M-yyyy", CultureInfo.CurrentCulture); DateOfBirth.Date = DateTime.ParseExact(dateOfBirthPass, "d-M-yyyy", CultureInfo.CurrentCulture); Visitperhotel = "00"; Totalvisit = "00"; RevenueTotal = "0.00"; RevenueRoom = "0.00"; RevenueFnb = "0.00"; RevenueOther = "0.00"; stopPageLoading(); DisplayAlert(Constants._headerMessage, Constants._noDetails, Constants._buttonOkay); }); } }); }