Sam6522984
Posts: 0
Joined: Thu Dec 26, 2013 2:35 pm

Windows Phone project contains empty files

I tested your workaround and it solved this issue. Unfortunately I have now two other issues.

The first one affects the fileTransfer API. On start up the app downloads some logos, which fails randomly. Sometimes the download of the logos works and sometime it fails. When it fails I get the following output from Visual Studio:

ERROR: Exception in ProcessCommand :: Exception has been thrown by the target of an invocation.
ERROR: failed to InvokeMethodNamed :: download on Object :: FileTransfer

The error callback gets called and outputs the following:

Error while downloading logos: {"code":null,"source":null,"target":null,"http_status":null,"body":null}

The code which produces the error:

code
my.downloadLogos = function(filenames) {
logoDownloadError = false;
numberOfLogoDownloads = 0;
numberOfLogos = filenames.length;
requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) {
fs.root.getDirectory("BonusPlus/Logos", {
create: true,
exclusive: false
}, function(entry) {
localStorage.setItem('logoPaths', JSON.stringify(logoPaths));
for (var i = 0; i < filenames&#46;length; i++) {
var url = LogoURL + filenames&#46;Filename;
var path = fs&#46;root&#46;fullPath + "/BonusPlus/Logos/" + filenames&#46;LogoID;
var fileTransfer = new FileTransfer();
fileTransfer&#46;download(url, path, downloadSuccess, downloadError);
}
}, function(evt) {
console&#46;log("FileSystem failure: " + evt&#46;code);
});
}, function(evt) {
console&#46;log("FileSystem failure: " + evt&#46;code);
});
};
/code

The second issue I have, is that the onload method for each page is only called once, this is most likely the outcome of changing the app to the multi-page template. So is there an easy way to change the behavior or do I need to go through every page and change the code?

I have uploaded the project to Dropbox, so you don't need to add the database plugin. You can find the "fileTransfer-code" in the www/views/assets/js/DataCollector.js file.
https://www.dropbox.com/sh/bewlj4vkdc...

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Windows Phone project contains empty files

Hello Sam,

Sorry for delay.
1) Could you please clarify, on what event do you call you this code? Is device ready event already triggered to this point?
2) Yes. This is all because of the render in one HTML. The load is triggered only once. Every time you open the page Page show event will trigger.

Sam6522984
Posts: 0
Joined: Thu Dec 26, 2013 2:35 pm

Windows Phone project contains empty files

Hi Evgene

1) Yes, after the "device ready" event I get a list from the Appery backend with the names of the files and start downloading them. The "filenames" variable contains those urls.

2) Ok, so there is no other way than rewrite all the events? Would it be possible to write a Javascript which calls the "onLoad" event after the "page show" event was triggered? I tried to write such a script, but unfortunately the "onload" was called multiple times.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Windows Phone project contains empty files

Hello Sam,

1) Could you please detail, are there any steps to reproduce this with a guaranty or it just randomly sometimes works and sometimes not? And if you remove caching of the images from the event on which it hangs now and hang it for example on a click on the button? Will it work normally, or will randomly (from time to time) fail?
2) we do not use the load event of the page and actually the pagecreate event is used and it is hunged all the handlers. You can try to create a new js asset with this code
pre$(document)&#46;on("pagebeforeshow", "[data-role=page]", function(event) {
$&#46;mobile&#46;activePage&#46;on("pagebeforeshow", function() {
$&#46;mobile&#46;activePage&#46;off("pageshow pagebeforeshow");
$&#46;mobile&#46;activePage&#46;trigger("pagecreate");
});
});/pre
here we use pagebeforeshow event for the load event has been triggered as usual before the show event.

Sam6522984
Posts: 0
Joined: Thu Dec 26, 2013 2:35 pm

Windows Phone project contains empty files

Hi Evgene,

I tried your suggestions with a click event. The filetransfer still fails randomly, but only for the first time after start up. I need to further investigate the problem, so I will come back to the topic tomorrow.

Thank you for the Javascript, I will try it asap.

Cheers
Sam

Sam6522984
Posts: 0
Joined: Thu Dec 26, 2013 2:35 pm

Windows Phone project contains empty files

Hi Evgene,

I had now a deeper look into it, not every download fails, some of them work as expected, some throw an exception. I have now added 3 methods for the logo downloads.
The first one uses my javascript which is already in place. The second one uses hardcoded links and paths and starts all downloads at the same time, like in a for-loop. The last method synchronizes the downloads, so one by one.
First two fail randomly at the first time, after that the download works without a problem. The third method runs ok, without any trouble.

I also looked into the fileTransfer class, and there seems to be the problem. When the download fails, the InProcDownloads Dictionary throws a NullReferenceException while adding the state. Probably a threading problem?

I have added the project to the dropbox again, so you can have a look when needed. To change the different methods go to the CollectorScreen.js and search for the ScanButton of the collectorscreen, there you can set the test methode (test1, test2 or test3). The implementation of those test methods are in the DataCollector.
https://www.dropbox.com/s/uvd2oj4s4ds...

Thank you for your help.
Cheers
Sam

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Windows Phone project contains empty files

Hi Sam,

Please specify steps how we can reproduce this problem in your app.

Also if wee nee to see some data in DB please share your db with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a and tell us here it name.

Regards.

Sam6522984
Posts: 0
Joined: Thu Dec 26, 2013 2:35 pm

Windows Phone project contains empty files

Hi Yurii,

The steps to reproduce the issue are based on the app, which I uploaded to dropbox.
Once you start the app you need to generate a new card, if not already happened. For that you just need to press on "Create virtual card". After that you are on the startpage, you should see a qr-code and a button underneath called "Scan Code", this button starts the download, currently with the original javacript I wrote. You can change the javascript for the download in the click event of the "Scan Code"-button, there is a test2() and a test3() method. The description of the different methods are in my post above.

I have also shared the "AdditionalInfo" DB. The logos of the app are stored in the file collection and the names of the logos are in the FileNameMapping collection.

Cheers
Sam

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Windows Phone project contains empty files

Hi Sam,

By your link is not project backup.

So please give us your app public link. Or give us link to backup of your project with problem for we could restore your app from it.

Regards.

Sam6522984
Posts: 0
Joined: Thu Dec 26, 2013 2:35 pm

Windows Phone project contains empty files

Hi Yurii,

I uploaded the source of the windows phone app, because I use a local websql database, which needs to be installed first.
I have now changed the app, so you can use the public link (6c0709aa-a3ad-4f71-8497-4ed49aae6e09).
To test you only need to start the app and press on the "Scan Code"-button.

Cheers
Sam

Return to “Issues”