Friday, July 23, 2010

WP7 SqliteClient with transaction support

I've updated the preview and implemented the transaction-commit-rollback mechanism.
For 1050 rows the results are:

Without transaction: 13.088 sec
Using transaction: 0.474 sec

For more rows you will get even better results.

The link to the project is the one from the previous post

Enjoy the update


Tuesday, July 20, 2010

WP7 SqliteClient Preview

WP7 developer devices are already out in the US and I still hope I will qualify for one here in Italy. I would really love to test one. Brandon PLEASE don't forget me :)
As my proposal was a better port of the Sqlite engine I did some optimizing on the engine and also implemented/adapted a SqliteClient that is easier to use than normal sqlite3 commands.
At the "engine" part I use the journal file persistent this way the engine doesn't delete and create the journal at each command. I've also eliminated SQLITE_DEBUG from conditional compilation symbols spares some temporary file access.
For the client at the beginning I've wanted to compile the System.Data and Sqlite class from Monotouch, but after looking a little bit at the source code I've realized that there are tons of things that doesn't make sense on WP7. I wanted to keep it simple and searching I've found the SqliteClient.cs written by Frank Krueger for Monotouch. I've adapted the class to run with our library and got a pretty nice result.
I've also improved the test project and now you are able to set how many rows will be inserted, select the inserted rows and see the elapsed times for insert/select commands. For the insert I've tested two methods: the first with prepare, step, finalize and the second one with sqlite3_exec (which should be the same) and the insert time are more or less the same.

Anyway it's only a preview as it was not intensively tested and because it can be improved. If some of you find ways to optimize the library please let me know and I will post it for everybody. Also let me know what you think.

Here you have the link to the source code


Sunday, July 18, 2010

WP7 IsolatedStorage speed improvement

If you remember some time ago I did some tests on the IsolatedStorage and the speed was not very impressive (it was 127 slower than the FileStream). In the new beta version there is a TREMENDOUS improvement. I rerun the old test in the new emulator and these are the results:

Dividing the two values 0.0632/1.1866=0.0532 which is almost the same with FileStream. At this point it does make sense implementing/porting a database engine on IsolatedStorage. Well done WP 7 Team on this aspect.


Friday, July 16, 2010

Compact Framework Network Printing

As usual a lot of time without posting but I had no time. I am really excited about the beta tools of WP7 (2 days ago I felt asleep while installing the beta cause the only time I have is after 11 p.m.). I also did some improvements on the Sqlite port but I will post it as soon as it will be usable (I plan to compare the performance with Perst even if it's a different approach).
I am posting this because I lost almost two days and maybe someone that needs it will find it right away. My task was some labeling process using MC9090 devices and Zebra S4m printers. I decided to go for in-memory parameterized forms. The client application uses two method for connecting to the printer:
1) Some of the printers have ethernet port and it is quite simple to communicate with the printer as you will open a socket to 9100 port and send the commands to the printer. This is simple
2) Other printers are connected as shared printers from pc's. This one should also be simple but it gave me a lot of headaches and mainly from my fault. I have two approaches:

a. The classic one that you would also do on Windows applications is to invoke CreateFile with the UNC name of the shared printer. My mistake with this approach was that I set the main window as TopMost and when calling the CreateFile windows mobile it will pop up a networking window where you have to insert the user name and password to use for authentication (this even if Guest access is enabled on the shared printer). So this approach was working but as I did not see the pop up window I thought it doesn't work

b. The second one is a little bit more complex. I am invoking WNetAddConnection3 to map the printer as a local resource (when using this method you can also pass the username and the password) and than using CreateFile on the local resource. After sending everything to the printer I call WNetCancelConnection2 to remove the resource (not really optimized but works). The second one seems more stable

The only annoying thing in this moment is the POCKET PC networking pop-up that tells me that the job has finished printing. I want to disable it (I think that it's something to do with the registry) but didn't find the way yet.

I am attaching 2 files Print.cs and Networking.cs. Print.cs has two methods one with authentication and another without.

Hope someone will find it useful