Buildfire:Barcode Scanning Service working in Previewer app, but not in built app on android - buildfire

I am developing a Buildfire plugin that requires QR Code scanning.
I have used the code below and it works in the previewer app,
but fails to scan on the built app that is on the play store (only tested on Android).
function scan(){
buildfire.services.camera.barcodeScanner.scan(
{
preferFrontCamera : false,
showFlipCameraButton : true,
formats : "QR_CODE", // default: all but PDF_417 and RSS_EXPANDED
},
function (err, result) {
buildfire.notifications.alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
rcpt = result.text;
console.log(rcpt);
document.getElementById("recipient").value = rcpt;
}
);
}
Launch function with button.
Works in previewer.
Fails in built (android) app

You need to make sure you request the BarCodeScanner feature in your plugin.json see the Prerequisite portion of the API Doc https://github.com/BuildFire/sdk/wiki/Barcode-Scanning-Service
Note: Your app will require a hard build.
I hope this helps

Related

Using node.js and wcf.js in aws lambda to contact a wcf .net service not working

I got this completely working on my personal computer using powershell and node.js and when I submit via ask cli to aws lambda the proxy.send does nothing, no error, no sign of even attempting to function properly. I'm not sure how to find out what is wrong or where to go from here.
The idea is to send in two strings to the .net WCF service and the service will use them and spit back the text Alexa will eventually speak. I have put console.log all over this and it seems that everything plays out, but the console.log placed inside the proxy.send function never fires. I get no errors in the log.
Please note: Everything always works accept for the BasicHttpBinding and the proxy.send lines. I have no confirmation they are doing anything correctly as I get no error.
var parseString = require('xml2js').parseString;
var BasicHttpBinding = require('wcf.js').BasicHttpBinding
, Proxy = require('wcf.js').Proxy
, binding = new BasicHttpBinding()
, proxy = new Proxy(binding, "http://service.menofnoblegirth.com/service1.svc")
, message = "<Envelope xmlns='http://schemas.xmlsoap.org/soap/envelope/'>" +
"<Header />" +
"<Body>" +
"<GetData xmlns='http://tempuri.org/'>" +
"<value>test</value>" +
"<value2>test2</value2>" +
"</GetData>" +
"</Body>" +
"</Envelope>"
proxy.send(message, "http://tempuri.org/IService1/GetData", function (response, ctx) {
parseString(response, function(error, result) {
console.log(JSON.stringify(result));
var stringfun = JSON.stringify(result);
var objectValue = JSON.parse(stringfun);
console.log(objectValue["s:Envelope"]["s:Body"][0]["GetDataResponse"][0]["GetDataResult"][0]);
});
});
var parseString = require('xml2js').Parser();
var BasicHttpBinding = require('wcf.js').BasicHttpBinding
, Proxy = require('wcf.js').Proxy
, binding = new BasicHttpBinding()
, proxy = new Proxy(binding, "http://service.menofnoblegirth.com/service1.svc")
, message = "<Envelope xmlns='http://schemas.xmlsoap.org/soap/envelope/'>" +
"<Header />" +
"<Body>" +
"<GetData xmlns='http://tempuri.org/'>" +
"<value>test</value>" +
"<value2>test2</value2>" +
"</GetData>" +
"</Body>" +
"</Envelope>"
proxy.send(message, "http://tempuri.org/IService1/GetData", function (response, ctx) {
parseString.parseString(response, function(error, result) {
console.log(JSON.stringify(result));
var stringfun = JSON.stringify(result);
var objectValue = JSON.parse(stringfun);
console.log(objectValue["s:Envelope"]["s:Body"][0]["GetDataResponse"][0]["GetDataResult"][0]);
});
});
This code is functional but the 3 second time out by default on an Alexa skill needs to be increased to 4-14 seconds.
Two things happen. The "hosted" website that housed the WCF service goes to sleep and it takes up to 14 seconds for the service to wake and response on the first call. (1400 milliseconds)
The second thing that happens is a regular call once the service is awake can take 309 milliseconds which is 9 more milliseconds than the default timeout.

Google sign integration not working

I followed this guide to integrate google sign in: https://developers.google.com/identity/sign-in/web/
But when I click the sign in button a pop up comes and goes but doesn't provide any information of the user.
function onSignIn(googleUser) {
// Useful data for your client-side scripts:
var profile = googleUser.getBasicProfile();
console.log("ID: " + profile.getId()); // Don't send this directly to your server!
console.log('Full Name: ' + profile.getName());
console.log('Given Name: ' + profile.getGivenName());
console.log('Family Name: ' + profile.getFamilyName());
console.log("Image URL: " + profile.getImageUrl());
console.log("Email: " + profile.getEmail());
// The ID token you need to pass to your backend:
var id_token = googleUser.getAuthResponse().id_token;
console.log("ID Token: " + id_token);
};
In console I am not getting any information.
I fixed the problem by using right URL with the port number in Authorized JavaScript origins field in "Create a Project and Client ID" section.
And I also enabled Google+ Api for the project.

Calling into my own DLL when depolyed on Azure

I have a simple Windows Azure cloud service that does random number generation running on my local machine. I have then published this to azure
public string GetNumber()
{
Random number = new Random();
return "number = " + number.Next(1, 100).ToString() + " number ";
}
When I call this method from my client everything works fine.
ie
ServiceReference1.RandomNumbersClient client = new ServiceReference1.RandomNumbersClient();
Console.WriteLine("Starting .... ");
Console.WriteLine(client.GetNumber());
Now, the next step is I have added some code that requires "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Speech.dll" to be available in the project. This is easy on my local server as I just add the reference to the dll in my VS project.
New method ....
public string GetNumberAsString()
{
Random number = new Random();
SpeechSynthesizer synth = new SpeechSynthesizer();
synth.SetOutputToDefaultAudioDevice();
synth.Speak("This example demonstrates a basic use of Speech Synthesizer");
return "number = " + number.Next(1, 100).ToString() + " number ";
}
Problem now is when I publish to Azure. How do I make the DLL available to my app running in Azure?
When I call the GetNumber() method it works fine but any call to GetNumberAsString() fails because of the additional code.
ServiceReference1.RandomNumbersClient client = new ServiceReference1.RandomNumbersClient();
Console.WriteLine("Starting .... ");
Console.WriteLine(client.GetNumberAsString());
How do I actually inspect the logs for the Webservice running on Azure so I can make a start at finding out what the problem is.

Why won't my ASP.NET application export CSV when hosted as an Azure Web app?

MY application exports CSV's fine when I test it from Visual Studio, but when I deploy it to an Azure as a Web app, instead of exporting a CSV I get a Error code: ERR_INVALID_RESPONSE.
Below is the method I use :
public void ExportEmpReport(int? er_id)
{
var er_hdr = db.expense_report_hdr.Include(w => w.employeeExpUser).Where(x => x.ID == er_id).FirstOrDefault();
StringWriter sw = new StringWriter();
sw.WriteLine("Employee Name: " + er_hdr.employeeExpUser.fullname + ", Period: " + er_hdr.period + ", Expense Report ID: " + er_id);
sw.WriteLine("Date of Expense , Expense Class , Detail , Cust/Conv , Notes , Amount , GL Code , Project Code");
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment;filename=ExpenseReport_" + er_id + ".csv");
Response.ContentType = "text/csv";
var lines = db.expense_report_line.Where(y => y.er_id == er_id);
foreach (var line in lines)
{
string exp_class = line.expenseType.expense.ToString().Replace(",", "");
string detail = (line.expense_detail != null) ? line.expense_detail.Replace(",", "") : "";
string cust_conv = (line.cust_conv != null) ? line.cust_conv.Replace(",", "") : "";
string notes = (line.notes != null) ? line.notes.Replace(",", "") : "";
sw.WriteLine(string.Format("{0},{1},{2},{3},{4},{5},{6},{7}", line.expense_date, exp_class, detail, cust_conv, notes, line.amount, line.gl_code.GL_code, line.project_code));
}
Response.Write(sw.ToString());
Response.End();
}
Here are some suggestions you may use to try and troubleshoot it:
A. Debug the web app locally, while connected to the DB on Azure. Are the tables being read correctly?
If the code fails to read the data from the database, make sure that the database is updated to the latest schema.
B. If it reads the data correctly, debug it step by step, and watch exactly where it fails.
If it fails at a particular line, remove/replace some lines of code until the local web app is running correctly against the DB on Azure. You may be able to identify the offending line(s) of code, and then report back here to allow others to help you troubleshoot further.
C. Once you get it working with the local app against the DB on Azure, deploy the updated project code to the Web App on Azure to see if it still runs correctly.
If it still doesn't work, maybe there's a setting on your Web App that is preventing it from running the code successfully.
D. Check the version of the .NET Framework on the Web App in Azure. The choices should be v3.5 or v4.6 (for non-Core 1.0 applications).
If it has the wrong version selected, make sure you select the correct version.
E. Enable Remote Debugging of the Web App running on Azure.
There's a Remote Debugging feature that you can toggle on/off in the Application Settings blade, where you can also select the VS version (2012, 2013, 2015). Turn it on to pinpoint which line of code it's failing at.

Cassia method works fine in console app but error in asp.net app

I am running this code.
server.Open();
//Console.WriteLine("----------------------------------------------------");
//Console.WriteLine("Active users on {0}", machineName);
foreach (ITerminalServicesSession session in server.GetSessions())
{
System.Security.Principal.NTAccount account = session.UserAccount;
if (account != null)
{
if (session.ConnectionState == Cassia.ConnectionState.Active)
{
((TextBox)Page.FindControl("txt" + machineName.Substring(7))).Text += session.UserName + " idle " + session.IdleTime.TotalMinutes + " minutes" + "\r\n";
}
}
}
It runs fine in console application but gives "No more data is available " error in asp.net page.
I created a new Application Pool in IIS 7 and set its identity as my personal username instead of the default AppIdenitity. Then I assigned this new Application Pool to my ASP.NET web application in IIS. Issue fixed.

Resources