terça-feira, 30 de dezembro de 2014

Smart Mobile Studio - Lesson 1/2






quinta-feira, 23 de outubro de 2014

Delphi mORMot with LINUX

POST #038 =======================================================================
It would be really nice to have Delphi mORMot targeting various OS and hardware platforms, into the Windows Delphi IDE.
It seems like a dream! There's a project called CrossFPC that generates binaries natively:
# 32 Bit Windows
# 64 Bit Windows
# 32 Bit x86 Linux
# 64 Bit x86 Linux
# ARM Kirkwood / SheevaPlug / GuruPlug
# ARM Android

This week, a guy named Alfred (Alf from Consulab) created a patch to enhance compatibility to FPC. Now, mORMot - demoniac version is nearly 100% complete! Thanks Alfred and AB. Our little  mORMot, with the latest unstable FPC (Free Pascal Compiler) can be compiled under Linux using Lazarus or CodeTyphon. Basic Restful ORM run perfectly on Linux (i386 and ARM) and (somewhat) running on Raspebery Pi, but interface-based SOA needs RTTI for all methods.

Unfortunately, FPC 2.7.1 does not allow to write interface-based services yet, due to a awful limitation in its RTTI support. See at: http://bugs.freepascal.org/view.php?id=26774  Sadly, the FPC team does not seem willing to fix it soon. 

Delphi mORMot currently is not ready to use services (interface based services) in non-windows platform because the FPC RTTI issue, but Yes! method-based services do work! Delphi mORMot allows for datastorage in a very structured and portable manner and we compile services methods under Linux.


This is pretty crazy, isn't it?

warleyalex from Sete Lagoas, MG.

Tags: Delphi mORMot with Linux; mORMot, demoniac version; Restful ORM with Linux server.


quinta-feira, 18 de setembro de 2014

Delphi mORMot with AngularJS

POST #037 =======================================================================
This week, I met an old colleague street called Dick Vigarista (Caralho Velho). The nickname was inspired by the character Dick Dastardly (Vigarista) in the Wacky Races drawing (Corrida Maluca). The guy has the typical iconography of the stereotypical "villain" of the story: tall, thin, with a devilish grin and a thin mustache, always dressed in dark clothing. He is always accompanied by his friend Mutley (the guys called Rabugento).

Dick Vigarista, always trying to win the Wacky Races with cheating, but always ended up getting ill, and ending the race in last. Dick Vigarista countless times, leading the race after performing his pranks, had his car stopped just inches from the finish line, and soon after all the exceeded, leaving the last.

The name "Dick Dastardly" or "Dick Vigarista" is one of the nicknames of the Formula 1 driver Michael Schumacher. Inspired by Dick Dastardly. Talking about racing and Dick I've created a small web application, called wacky races with mORMot. This is a racing standings powered by mORMot with AngularJS. The idea was demonstrate Delphi mORMot authentication scheme with AngularJS.

That's all.
warleyalex from Sete Lagoas, MG.

Tags: wacky races with mORMot; delphi with AngularJS; mORMot authentication.


domingo, 31 de agosto de 2014

quarta-feira, 30 de julho de 2014

Convert .PAS to .JS

POST #035 =======================================================================
Object Pascal to Javascript? I've created a small Bank Account Simulator System application powered by the old Delphi 7 and use a command-line compiler to convert pascal code to pure javascript.

Tags: pascal to javascript; object pascal to javascript; smart mobile studio compiler command line.


segunda-feira, 30 de junho de 2014

Delphi with MongoDB

POST #034 =======================================================================
Bye, bye Chile.
After a tense match, Brazil breathes giant sight of relief and defeats Chile on penaulties and advanced to the quarter-finals of the World Cup 2014.

BTW, if you don't know, Chile is fortunate to have climate conditions that are ideal for good wine grapes. 

Guess what? I've created a small Wine Cellar application powered by Delphi mORMot with MongoDB! Take a look at Christophe Coenraets blog here: http://coenraets.org/blog/2011/12/restful-services-with-jquery-and-java-using-jax-rs-and-jersey/. This is a wine cellar management application, allows you to manage, add, retrieve, update and delete the wines in a wine cellar MongoDB database.

Brazil breathed again.

Tags: MongoDB with Delphi; mORMot with MongoDB; CRUD with MongoDB and Delphi.
 
 


sexta-feira, 23 de maio de 2014

Shopping cart with Delphi mORMot

POST #033 =======================================================================
I've created an experimental shopping cart with Delphi 7 which generates HTML. It is a single page application which will have multiple views. I'm using mORMot to render mustache templates. I defend that server-side rendering with mORMot will be always faster than on client side rendering.

When a dynamic page is executing on the server-side, browser is doing nothing but waiting for the HTML to come from the server-side. Here, mORMot code takes only 15ms to perform rendering of my SPA (single page application). By the time server finishes doing its work, server will just send the dynamic content and browser will be able to render it right away. Of course JS/CSS files are loaded only after the page is delivered to the browser.

I've been thinking if I could render a template without refresh the page. Yes, I can. Oh, I have a question: I’m using a external shared template, I’ve been wondering, if this page generated concurrently would become an issue. Are there possibility this become a messed up, a user see another rendered template, for example? Answer is: No, no, TSynMustache is thread-safe, per dedicated template.

Neither javascript framework required nor json on client side, just jquery and mustache templates on server side. 

Tags: shopping cart; jquery with delphi; mORMot web server.
 
 


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.