Video | Andreano Lanusse | Technology and Software Development Where Andreano Lanusse talk about technology, software development, programming techniques, databases, games and more through articles, tutorials and videos Tue, 31 Jul 2012 20:20:15 +0000 en hourly 1 https://wordpress.org/?v=6.7.4 Android apps connected to Delphi DataSnap Server http://www.andreanolanusse.com/en/android-apps-connected-to-delphi-datasnap-server/ http://www.andreanolanusse.com/en/android-apps-connected-to-delphi-datasnap-server/#comments Wed, 11 Jan 2012 08:15:55 +0000 http://www.andreanolanusse.com/en/?p=771 On the following video I’m showing how you can create DataSnap REST Server in Delphi, expose server methods and call them from an Android application. The video shows all the steps to create the server and the Android application. This is a short recap of the video. In order to have other platforms connecting and […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
On the following video I’m showing how you can create DataSnap REST Server in Delphi, expose server methods and call them from an Android application. The video shows all the steps to create the server and the Android application.


This is a short recap of the video.

In order to have other platforms connecting and interacting with your DataSnap Server you need to enable the REST Interface, and for mobile platforms you can use the DataSnap Connectors that generate proxy classes for Android, BlackBerry, Windows Phone and iOS. In the video I’m showing how to create the Server, let’s take a look at the Server Method implementation.

The first server method called InsertCountry, connect on my InterBase database and add a new record to the Country table, see the implementation below:

function TServerMethods1.InsertCountry(Country, Currency: String;
  out Error: String): Boolean;
var
  Comm: TDBXCommand;
begin

  Result := False;

  DBConn.Open;
  Comm := DBConn.DBXConnection.CreateCommand;
  Comm.CommandType := TDBXCommandTypes.DbxSQL;
  Comm.Text :=
    Format('Insert Into Country (COUNTRY, CURRENCY) Values ( ''%s'', ''%s'')',
    [Country, Currency]);

  if not Comm.IsPrepared then
    Comm.Prepare;

  try
    Comm.ExecuteUpdate;
    Comm.Free;
    Result := True;
  except on E: Exception do
    Error := E.Message;
  end;

end;

The second server method is called GetCountries, and returns all the records I have in the COUNTRY table on my InterBase database. This method returns a DBXReader and DataSnap will convert this automatically to JSON at the moment the Android app calls this method, but since we will use the new DataSnap Connector to generate the proxy class, we won’t need to handle the JSON object and I will explain that after.

The following code represents the GetCountries implementation.

function TServerMethods1.GetCountries: TDBXReader;
var
  Comm: TDBXCommand;
begin

  DBConn.Open;
  Comm := DBConn.DBXConnection.CreateCommand;
  Comm.CommandType := TDBXCommandTypes.DbxSQL;
  Comm.Text := 'Select * from Country';

  if not Comm.IsPrepared then
    Comm.Prepare;

  Result := Comm.ExecuteQuery;

end;

The next step is to create the proxy class for Android using the DataSnap connectors, which is a new feature in Delphi XE2. The generation can be done through command line or via HTTP request on your DataSnap server, and in the video I’m showing how to do that.

The proxy generator generates only the DSProxy.java, all the other files part of the DataSnap Connectors are the representation of DataSnap Framework in Java, for example you won’t need to parse the DBXReader as JSON object in Java, just because we have the DBXReader class in Java and it parses the JSON object for you.

The first step to create a REST connection with your DataSnap Server, which will give me a instance of DSRESTConnection. If your DataSnap Server requires authentication you can use the methods SetUserName and SetPassword to define the credentials.

	private DSRESTConnection getConnection() {
		DSRESTConnection conn = new DSRESTConnection();
		conn.setHost("192.168.254.128");
		conn.setPort(8080);
		return conn;
	}

Now, let’s take a look and see how to execute the server methods, starting with the InsertCountry method as you can see in the following code.

After instantiation of the DSRESTConnection, we pass the REST connection object to the TServerMethods1’s instance, which is the client representation of TServerMethods1 on the server, and from there just call InsertCountry.

Since InsertCountry returns Boolean and also the Error message parameter is passed as reference, InsertCountry methods will return a InsertCountryReturns, which is a static class with two parameters: error that represent the error message and returnValue which represent the value return by InsertCountry.

protected void Insert() {

	DSRESTConnection conn = getConnection();

	TServerMethods1 sm = new TServerMethods1(conn);

	try {
		InsertCountryReturns ret;
		ret = sm.InsertCountry(editCountry.getText().toString(), editCurrency.getText().toString(), "");

		if ( ! ret.returnValue ) {
			System.out.println(ret.error);
		}

	} catch (DBXException e) {
		e.printStackTrace();
	}

	// Hide keyboard
	InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
	imm.hideSoftInputFromWindow(editCountry.getWindowToken(),0);

}

The next method is GetCountries. We start as before by getting the DSRESTConnection instance. The GetCountries method returns a DBXReader and the way we work with the DBXReader class in Java is very similar the way we work in Delphi, use the Next method to interact through the result, and getValue/GetAsXXXXX to get the column value. See the following code:

protected void Refresh() {

	DSRESTConnection conn = getConnection();

	TServerMethods1 sm = new TServerMethods1(conn);

	TDBXReader reader;
	try {
		reader = sm.GetCountries();

		ArrayList COUNTRIES = new ArrayList();

		while (reader.next()) {
			COUNTRIES.add(reader.getValue("COUNTRY").GetAsString());
		}

		// Add the COUNTRIES array in to the list view
		list.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, COUNTRIES));

	} catch (DBXException e) {
		e.printStackTrace();
	}

}

This is just a short tutorial explaining how to use DataSnap Connector with Android, take some time and watch the video where I’m going through more details.

The source code is available for download here and download the video from here.

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/android-apps-connected-to-delphi-datasnap-server/feed/ 23
Android apps connected to C++Builder DataSnap Server http://www.andreanolanusse.com/en/android-apps-connected-to-cbuilder-datasnap-server/ http://www.andreanolanusse.com/en/android-apps-connected-to-cbuilder-datasnap-server/#comments Thu, 22 Dec 2011 01:48:16 +0000 http://www.andreanolanusse.com/en/?p=747 As part of the 31 days of RAD Studio XE2 Tutorials, in today’s video I’m showing how you can create DataSnap REST Server in C++Builder, expose server methods and call them from an Android application. The video shows all the steps to create the server and the Android application. This is a short recap of […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
As part of the 31 days of RAD Studio XE2 Tutorials, in today’s video I’m showing how you can create DataSnap REST Server in C++Builder, expose server methods and call them from an Android application. The video shows all the steps to create the server and the Android application.

This is a short recap of the video.

In order to have other platforms connecting and interacting with your DataSnap Server you need to enable the REST Interface, and for mobile platforms you can use the DataSnap Connectors that generate proxy classes for Android, BlackBerry, Windows Phone and iOS. In the video I’m showing how to create the Server, let’s take a look at the Server Method implementation.

The first server method called InsertCountry, connect on my InterBase database and add a new record to the Country table, see the implementation below:

bool TServerMethods1::InsertCountry(String country, String currency,
	String &error) {
	TDBXCommand *comm;

	bool result = false;
	DbConn->Open();
	comm = DbConn->DBXConnection->CreateCommand();
	comm->CommandType = TDBXCommandTypes_DbxSQL;

	TVarRec vr[] = {country, currency};
	comm->Text =
		Format("Insert Into Country (COUNTRY, CURRENCY) Values ( '%s', '%s')", vr, 2);

	if (!comm->IsPrepared) {
		comm->Prepare();
	}

	try {
		comm->ExecuteUpdate();
		result = true;

	}
	catch (Exception* e) {
		error = e->Message;
	}
	delete comm;
	return result;

}

The second server method is called GetCountries, and returns all the records I have in the COUNTRY table on my InterBase database. This method returns a DBXReader and DataSnap will convert this automatically to JSON at the moment the Android app calls this method, but since we will use the new DataSnap Connector to generate the proxy class, we won’t need to handle the JSON object and I will explain that after.

The following code represents the GetCountries implementation.

TDBXReader* TServerMethods1::GetCountries() {

	TDBXCommand *comm;

	try {
		DbConn->Open();
		comm = DbConn->DBXConnection->CreateCommand();
		comm->CommandType = TDBXCommandTypes_DbxSQL;
		comm->Text = "Select * from Country";

		if (!comm->IsPrepared) {
			comm->Prepare();
		}
		return comm->ExecuteQuery();
	}
	catch (Exception* e) {
		return NULL;
	}
}

The next step is to create the proxy class for Android using the DataSnap connectors, which is a new feature in C++Builder XE2. The generation can be done through command line or via HTTP request on your DataSnap server, and in the video I’m showing how to do that.

The proxy generator generates only the DSProxy.java, all the other files part of the DataSnap Connectors are the representation of DataSnap Framework in Java, for example you won’t need to parse the DBXReader as JSON object in Java, just because we have the DBXReader class in Java and it parses the JSON object for you.

The first step to create a REST connection with your DataSnap Server, which will give me a instance of DSRESTConnection. If your DataSnap Server requires authentication you can use the methods SetUserName and SetPassword to define the credentials.

	private DSRESTConnection getConnection() {
		DSRESTConnection conn = new DSRESTConnection();
		conn.setHost("192.168.254.128");
		conn.setPort(8080);
		return conn;
	}

Now, let’s take a look and see how to execute the server methods, starting with the InsertCountry method as you can see in the following code.

After instantiation of the DSRESTConnection, we pass the REST connection object to the TServerMethods1’s instance, which is the client representation of TServerMethods1 on the server, and from there just call InsertCountry.

Since InsertCountry returns Boolean and also the Error message parameter is passed as reference, InsertCountry methods will return a InsertCountryReturns, which is a static class with two parameters: error that represent the error message and returnValue which represent the value return by InsertCountry.

protected void Insert() {

	DSRESTConnection conn = getConnection();

	TServerMethods1 sm = new TServerMethods1(conn);

	try {
		InsertCountryReturns ret;
		ret = sm.InsertCountry(editCountry.getText().toString(), editCurrency.getText().toString(), "");

		if ( ! ret.returnValue ) {
			System.out.println(ret.error);
		}

	} catch (DBXException e) {
		e.printStackTrace();
	}

	// Hide keyboard
	InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
	imm.hideSoftInputFromWindow(editCountry.getWindowToken(),0);

}

The next method is GetCountries. We start as before by getting the DSRESTConnection instance. The GetCountries method returns a DBXReader and the way we work with the DBXReader class in Java is very similar the way we work in C++, use the Next method to interact through the result, and getValue/GetAsXXXXX to get the column value. See the following code:

protected void Refresh() {

	DSRESTConnection conn = getConnection();

	TServerMethods1 sm = new TServerMethods1(conn);

	TDBXReader reader;
	try {
		reader = sm.GetCountries();

		ArrayList COUNTRIES = new ArrayList();

		while (reader.next()) {
			COUNTRIES.add(reader.getValue("COUNTRY").GetAsString());
		}

		// Add the COUNTRIES array in to the list view
		list.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, COUNTRIES));

	} catch (DBXException e) {
		e.printStackTrace();
	}

}

This is just a short tutorial explaining how to use DataSnap Connector with Android, take some time and watch the video where I’m going through more details.

The source code is available for download here and download the video from here.

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/android-apps-connected-to-cbuilder-datasnap-server/feed/ 8
Video: Delphi XE2 and FireMonkey app on Windows, Mac and iOS http://www.andreanolanusse.com/en/video-delphi-xe2-and-firemonkey-app-on-windows-mac-and-ios/ http://www.andreanolanusse.com/en/video-delphi-xe2-and-firemonkey-app-on-windows-mac-and-ios/#comments Fri, 05 Aug 2011 07:53:31 +0000 http://www.andreanolanusse.com/en/?p=681 After the RAD Studio XE2 World Tour first stop in New Zealand, you see all over internet great comments about Delphi XE2 and FireMonkey support for iOS, beyond Windows 64-bit and Mac. I know you are curious to see all of the great stuffs coming on RAD Studio XE2 and to give you an idea; […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
After the RAD Studio XE2 World Tour first stop in New Zealand, you see all over internet great comments about Delphi XE2 and FireMonkey support for iOS, beyond Windows 64-bit and Mac.

I know you are curious to see all of the great stuffs coming on RAD Studio XE2 and to give you an idea; I prepared a 5 minutes preview video. It shows a Delphi XE2 HD FireMonkey application running on Windows (64-bit), Mac and iOS, the use of 3D components and animations.

There are lot of possibilities with FireMonkey and all of the other new features in Rad Studio XE2, we are presenting all of them during the World Tour, reserve some time and register for the World Tour near you.

[button link=”http://www.embarcadero.com/world-tour” size=”large” style=”note” color=”red” border=”white” text=”light” window=”yes”]Register today for the RAD Studio XE2 World Tour[/button]

 

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/video-delphi-xe2-and-firemonkey-app-on-windows-mac-and-ios/feed/ 44
Video: Delphi Certification Webinar Replay http://www.andreanolanusse.com/en/video-delphi-certification-webinar-replay/ http://www.andreanolanusse.com/en/video-delphi-certification-webinar-replay/#comments Fri, 15 Jul 2011 05:34:24 +0000 http://www.andreanolanusse.com/en/?p=564 In case you missed the Delphi Certification webinar, below you can download the slides and watch the video replay. This presentation is a good start for who is looking in to became Delphi Developer Certified or Delphi Master Developer Certified. Presentation Slides Webinar Replay All the Certification Program information is available at the Certification Center, […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
In case you missed the Delphi Certification webinar, below you can download the slides and watch the video replay. This presentation is a good start for who is looking in to became Delphi Developer Certified or Delphi Master Developer Certified.

Presentation Slides

Webinar Replay


All the Certification Program information is available at the Certification Center, as well as the study guides and FAQ.

Good luck in the exam.

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/video-delphi-certification-webinar-replay/feed/ 1
Video: Delphi Conference 2010 Brazil Opening Keynote with David I http://www.andreanolanusse.com/en/video-delphi-conference-2010-brazil-opening-keynote-with-david-i/ http://www.andreanolanusse.com/en/video-delphi-conference-2010-brazil-opening-keynote-with-david-i/#comments Mon, 20 Dec 2010 20:27:58 +0000 http://www.andreanolanusse.com/en/?p=420 Most of you didn’t have a chance to attendee the Delphi Conference 2010 Brazil for many different reasons, for example the language, distance, etc., but this year we had the chance to record some sessions and two of them were presented in English, David I’s Keynote and Daniele Teti’s DataSnap and Android session. Let’s start […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
Most of you didn’t have a chance to attendee the Delphi Conference 2010 Brazil for many different reasons, for example the language, distance, etc., but this year we had the chance to record some sessions and two of them were presented in English, David I’s Keynote and Daniele Teti’s DataSnap and Android session.

Let’s start with David’s Keynote where he talks about Embarcadero products, RAD Studio RoadMap, shows a preview of Delphi for Mac, 64bit compiler and more. Tomorrow we will publish the Daniele Teti session.

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/video-delphi-conference-2010-brazil-opening-keynote-with-david-i/feed/ 3
Video: Building .NET based applications for Linux and iPhone with Mono and Monotouch http://www.andreanolanusse.com/en/video-building-net-based-applications-for-linux-and-iphone-with-mono-and-monotouch/ http://www.andreanolanusse.com/en/video-building-net-based-applications-for-linux-and-iphone-with-mono-and-monotouch/#comments Mon, 29 Nov 2010 19:25:25 +0000 http://www.andreanolanusse.com/en/?p=406 If you didn’t have a chance to watch my CodeRage 5 session “Building Managed Code Cross Platform Applications with Delphi Prism” the reply is available. During this presentation I introduce Mono and Monotouch frameworks and how you can use Delphi Prism integrated to Visual Studio 2010 to create .NET Web Services and ASP.NET applications and deploy […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
If you didn’t have a chance to watch my CodeRage 5 session Building Managed Code Cross Platform Applications with Delphi Prism” the reply is available. During this presentation I introduce Mono and Monotouch frameworks and how you can use Delphi Prism integrated to Visual Studio 2010 to create .NET Web Services and ASP.NET applications and deploy on Linux, as well the Mono IDE integrated with Delphi Prism on Mac to create iPhone/iPad applications.


The Web browser source code sample is available here

Watch more CodeRage replay videos

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/video-building-net-based-applications-for-linux-and-iphone-with-mono-and-monotouch/feed/ 7
Video: New dbExpress driver for Firebird in Delphi 2010 and C++Builder 2010 http://www.andreanolanusse.com/en/new-dbexpress-driver-for-firebird-in-delphi-2010-and-cbuilder-2010/ http://www.andreanolanusse.com/en/new-dbexpress-driver-for-firebird-in-delphi-2010-and-cbuilder-2010/#respond Tue, 18 Aug 2009 08:30:43 +0000 http://www.andreanolanusse.com/en/?p=35 Ok, the Firebird community asked for and now they have in RAD Studio 2010 a new dbExpress driver for Firebird, full support including the dbExpress framework, check this video out. For more information about RAD Studio 2010 click here Also I recommend you to watch the new sneak peek video about other new database features […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
dbExpress driver for FirebirdOk, the Firebird community asked for and now they have in RAD Studio 2010 a new dbExpress driver for Firebird, full support including the dbExpress framework, check this video out.

For more information about RAD Studio 2010 click here

Also I recommend you to watch the new sneak peek video about other new database features and DataSnap 2010.

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/new-dbexpress-driver-for-firebird-in-delphi-2010-and-cbuilder-2010/feed/ 0
Video: How to configure Delphi 2010 to look, work, and feel like Delphi 7 http://www.andreanolanusse.com/en/how-to-configure-delphi-2010-to-look-work-and-feel-like-delphi-7/ http://www.andreanolanusse.com/en/how-to-configure-delphi-2010-to-look-work-and-feel-like-delphi-7/#comments Mon, 10 Aug 2009 08:36:18 +0000 http://www.andreanolanusse.com/en/?p=33 During my Delphi 2010 IDE videos I presented the return of Delphi 7 Component Toolbar. I received some questions about how to change the IDE layout to work like Delphi 7, below a Delphi 2010 screen shot reproducing the same Delphi 7 layout. You get not only the same layout, but some of the other […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
During my Delphi 2010 IDE videos I presented the return of Delphi 7 Component Toolbar. I received some questions about how to change the IDE layout to work like Delphi 7, below a Delphi 2010 screen shot reproducing the same Delphi 7 layout.

Delphi 2010 look and feel like Delphi 7

You get not only the same layout, but some of the other new features like:

  • Search box for the component toolbar
  • Look at the structure panel window, you will see the Project Manager, Modeling and Data Explorer

Also, hundreds of new features since Delphi 7.

Here a video explaining how to configure your Delphi 2010 to look, work, and feel like Delphi 7

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/how-to-configure-delphi-2010-to-look-work-and-feel-like-delphi-7/feed/ 1
Video: The old Component Toolbar is back and better in RAD Studio 2010 http://www.andreanolanusse.com/en/the-old-component-toolbar-is-back-and-better-in-rad-studio-2010/ http://www.andreanolanusse.com/en/the-old-component-toolbar-is-back-and-better-in-rad-studio-2010/#comments Fri, 07 Aug 2009 05:50:29 +0000 http://www.andreanolanusse.com/en/?p=21 We hear a lot of developers like the old Component Toolbar from Delphi 7/C++Builder 6, and consider that one of reason not to move to the new release. In RAD Studio 2010 you can now use the old Component Toolbar and/or the new Tool Palette. To activate the Component Toolbar just right click on the […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
We hear a lot of developers like the old Component Toolbar from Delphi 7/C++Builder 6, and consider that one of reason not to move to the new release. In RAD Studio 2010 you can now use the old Component Toolbar and/or the new Tool Palette.

To activate the Component Toolbar just right click on the main toolbar and select Component. After that you can right click on the Component Toolbar to see the list of all categories available or just navigate through the tabs and chose one.

The configuration of the Tool Pallete and Component Toolbar are independent, for example you can reorder the categories, and the most cool feature is the search box for the components on the Component Toolbar.

NewOldComponentToolbar

Also, you have a new way to find components through the IDE Insight.

More to come, stay tuned.

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/the-old-component-toolbar-is-back-and-better-in-rad-studio-2010/feed/ 2
Video: Check this out some of the new IDE features in Delphi 2010 and C++Builder 2010 http://www.andreanolanusse.com/en/video-check-this-out-some-of-the-new-ide-features-in-delphi-2010-and-cbuilder-2010/ http://www.andreanolanusse.com/en/video-check-this-out-some-of-the-new-ide-features-in-delphi-2010-and-cbuilder-2010/#comments Fri, 07 Aug 2009 04:00:00 +0000 http://www.andreanolanusse.com/en/?p=13 Watch this video and learn some of the great new features implemented in Delphi 2010 and C++Builder 2010, both part of the RAD Studio 2010.

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
Watch this video and learn some of the great new features implemented in Delphi 2010 and C++Builder 2010, both part of the RAD Studio 2010.

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/video-check-this-out-some-of-the-new-ide-features-in-delphi-2010-and-cbuilder-2010/feed/ 1