quarta-feira, 23 de abril de 2014

Reports on demand using Smart Mobile + Datasnap

POST #032 =======================================================================
SmartMS has some basic controls,but there a lot of missing controls. So I have decided to implement an example using a weird approach: put controls by hand using HTML templates but code is done with pure pascal SmartMS, no visual designer is used in this example, I have just bind smart pascal to javascript in HTML templates. This mini-video is intended to demonstrate the use of a web service (is a REST DataSnap server) that provides reports on demand to mobile client applications created with Smart Mobile Studio.

Tags: Remote service with datasnap; reports on demand with datasnap; datasnap with smart mobile studio.
 
 


segunda-feira, 3 de março de 2014

Web service with MS Excel and Delphi

POST #031 =======================================================================
Hi everyone, welcome back, thanks for listening, if you like this video I'm warleyalex from the beautiful Seven lakes, Brazil. otherwise I don't know anything about it... Today I’m gonna talk web services with Microsoft Excel 2003. If you don’t know, Web Services are reusable applications that expose an interface that can be accessed over the internet. Web services generally use XML to provide a platform and language independent implementation of distributed application services and information.

Web services allow us to utilize the services provided by the other organizations. We can consume the web services not only from applications developed using various programming languages but also from Microsoft office tools like Access, Excel, and Word etc. In this mini-video we will explore how we can access a web service from Microsoft Excel using Delphi mORMot!

I was trying to write some VBA code in Excel 2003 that would consume a web service created with Delphi. So I would like to create in pure VBA (visual basic for application) without installing any plugins, neither opening up Visual Studio, nor other hacks.  Some fun features include strong authentication, URI signatures and JSON support (thanks to vba-json).

I’m using a REST server. REST is simple enough in practice that it doesn't really need a toolkit. All it requires is support for HTTP, which VBA offers through the MSXML2.XMLHTTP object. Using this object, you can create HTTP requests and process the responses.  There's no need to use the Microsoft Office Web Services Toolkit for this example; the VBA code for the button in alone is all you need.

It's working awesomely in my Excel 2003 (and most likely 2010), but does not work on Excel for Mac due to missing XMLHTTP libraries. I think it should work with pretty much any REST webservice. In my opinion Microsoft would like to have VBA dead and it is pushing dot net solutions for Office.

This example, includes a web service, which returns CEP (code postal) according to the address you request. Actually, user can find any Address here in Brazil, for instance, when a user types a street, avenue starting with letter B, web service will return all data address starting with B, in all over Brazil, this is really big result.  My database has more than 200 megabytes. Actually, this database contain more than 900 thousands records, 45,738 districts and 10,698 places.

My mormot_excel.xls sheet accesses the web service and displays the data provided by the webservice. Clicking on the clear button clears the data from the Excel sheet).

The REST HTTP version is both simpler and more portable, you can create this with Android platform and demands less code on the server side as well. Why wouldn't you use REST rather than SOAP throughout your work? If you control both ends of the transaction, this is a very appealing option, as it lets you use whatever web tools you like, not just tools specifically oriented toward SOAP web services. However, there are many services that are available only through SOAP, and a growing number of programmers who know how to work with SOAP. It's best to have both approaches in your toolbox. Now our little mORMot supports authentication using Delphi, javascript, java-android and visual basic for applications. This is very nice, isn’t it?

Tags: Remote service with Excel; webservice with Excel; CEP with Excel.
 


domingo, 23 de fevereiro de 2014

Android with Delphi for Javascript

POST #030 =======================================================================
Take the big picture: I want to access data over the web, using my android tablet thin client. But I would like to keep my server/service written in pascal. What I'm trying to do is write a small web application in Delphi which support REST protocol and JSON. I would like to share my customer table remotely through Android tablets, table has more than 10,000 customers. Of course, I need authentication, strong scheme to ensure that connection is secure. So, my server should send small data packets to client, and security is an issue, but I don't have the necessary muscules in my brain to do the client side in javascript. So I could try to convert Delphi to javascript, but I don't know if this is possible. Simple as...


Ok folks, I know that PHP, java could help me with this, but I would like I'm a GUI guy ;) Take a look at this video. I'm using Delphi as server side and Delphi for javascript as client side, and finally I've combined with Cordova to create an Android application. Everything using pascal, android .apk file size is 300kb!

So there you have it, two possibly great frameworks combined! Whether they really are that great.

Thanks for listening, if you like this video I'm warleyalex from the beautiful Seven lakes, Brazil. otherwise I don't know anything about it...


Tags: Remote paging datagrid; Smart Mobile Studio; Android with Delphi for Javascript; OP4JS.
 


quinta-feira, 30 de janeiro de 2014

Database Reverse engineering with Delphi mORMot

POST #029 =======================================================================
I would like to map DB to class dynamically depending on the database. Now, I just have to select some tables and my little mORMot can generate the class on the fly to be used in models. Something like this:

TSQLSampleDB = Class(TSQLRecord  
public    
  fAuthUser       : TSQLAuthUser; 
  fLogonName      : RawUTF8; 
  fPasswordPlain  : RawUTF8; 
  fPrice          : currency; 
  fDisplayName    : RawUTF8; 
  fGroupRights    : RawUTF8; 
  fData           : TSQLRawBlob; 

published 
  property AuthUser: TSQLAuthUser read fAuthUser write fAuthUser; 
  property LogonName: RawUTF8 index 20 read fLogonName write fLogonName; 
  property PasswordPlain: RawUTF8 index 10 read fPasswordPlain write fPasswordPlain; 
  property Price: currency read fPrice write fPrice; 
  property DisplayName: RawUTF8 index 50 read fDisplayName write fDisplayName; 
  property GroupRights: RawUTF8 index 15 read fGroupRights write fGroupRights; 
  property Data: TSQLRawBlob read fData write fData; 
end; 

It's a good practice to put all data definition into a stand-alone unit called model. This unit will be shared between client and server.

This is not a real class but something quite similar, it just has to inherits from TSQLRecord, and the published properties will be used for the Delphi mORMot framework, in ORM side, ready to use in client/server environment. Very handy, isn't it?

Tags: Convert table to class; DB reverse engineering; mORMot framework.
 


quarta-feira, 4 de dezembro de 2013

Smart Mobile Studio - DBGrid with some curves

POST #028 =======================================================================
Like it or not, Delphi is the best development tool for Win32/Win64 but Embarcadero seems to ignore the fact. Someone could say that the baby is being thrown out with the bathwater and after all, when they realize the error will be too late.

The fate of Delphi is increasingly linked to the acclaimed FireMonkey technology. Concerns about FireMonkey are concerns about Delphi. Embarcadero beyond thinking who owns the Pascal, persists in pushing your fancy half-assed multi-platform write-once run-anywhere, in reality, is that you can write once and then run it in any platforms each "supported". For example, you develop for Android "some " Androids.

This is my space for outburst. Now, talking about SMS. Smart Mobile Studio was created with Delphi. The tool lets you instantly convert Pascal "Delphi-like" javascript code to native code. The interesting part is that the generated code (pure javascript) is ready to run on smart phones. In order to demonstrate the functionality of this greate tool, I've created a DBGrid with pictures in SmartMS. Nice photos, ehm. doncha think?

Noteworthy is that you can call javascript event handlers using object pascal . Thus, you could make a sort of binding between components of a javascript library and the native components SmartMS thus being able to create more sophisticated apps. This is warleyalex from Seven Lakes, Brazil. Stay tuned on upcoming videos about SmartMS.

Tags: OP4JS; Smart Mobile Studio; SmartMS with DBGrid.
 


sábado, 30 de novembro de 2013

Smart Mobile Studio - DBGrid component

POST #027 =======================================================================
Smart Mobile Studio (aka Delphi for Javascript) instantly converts pascal Delphi-like code into high-speed javascript. The interesting part is that JS code generated is ready to run on smart phone or any HTML5 web-kit empowered device.

I would like to create a testapp more sophisticated with SmartMS, I realized that I could write a Pascal wrapper classes to mimic the structure of the JS library, with the intent of using it to call events from pascal. In this mini video, I'll demonstrate a DBGrid with SmartMS. Thank you very much, I'm warleyalex, and you take care. Stay tuned on upcoming videos about SMS.

Tags: OP4JS; Smart Mobile Studio; SmartMS with DBGrid.