Quantcast
Channel: Latest blog entries - Embarcadero Community
Viewing all 1683 articles
Browse latest View live

Video Tutorial #2/#3: CodeSite Express / Beyond Compare

$
0
0

Zwei weitere Videos aus meiner Video-Tipp-Reihe:


[YoutubeButton url='https://www.youtube.com/watch?v=EgZLt5l0mHM']

[YoutubeButton url='https://www.youtube.com/watch?v=QbkuOluQw2k']

Read More

Build iOS 11 ready apps with RAD Studio 10.2.1

$
0
0

Build iOS 11 ready apps with RAD Studio 10.2.1 and the newly released iOS 11 patch.

We have released a patch that adds support for building and debugging iOS 11 applications on supported devices, and building App Store, Ad Hoc or In-House Distribution ready apps. It also addresses a number of iOS 10 related issues.

This patch is available for any active Update Subscription customer and requires that you have RAD Studio 10.2.1 (Tokyo Release 1) installed.

Supported iOS SDK versions: iOS 10.3.x, iOS 11

Supported Xcode versions: Xcode 8.2.x, 8.3.2, 8.3.3 and 9.0

 

Note: iOS 11 Simulator deployment is currently not supported as it requires macOS 64-bit support. macOS 64-bit support is on our product roadmap. Targeting iOS 10 Simulator devices is supported. 

 

 


Read More

Cross Platform Business Stats Dashboard App For Delphi 10.2.1 Tokyo On Android And IOS

$
0
0

The Hospitality Survey Client project is part of the Hospitality Survey App template for Delphi 10.2.1 Tokyo that Embarcadero has released through their GetIt platform. The Hospitality Survey App consists of four different projects plus a Survey Question Editor. And now there is a sixth project I am releasing for the Hospitality Survey App which is a Hospitality Survey Admin Client built in Delphi 10.2 Tokyo. The original business stats dashboard included with the Hospitality Survey App is built in AngularJS but I wanted to also build this same dashboard in Delphi.

I based the Hospitality Survey Admin Client off of the Hospitality Survey Client source code and just modified it a bit. The original client only downloaded the survey questions and then uploaded the results. I modified the client so that it downloads the admin business stats, a CSV file of the email addresses for the users who filled out the survey, the list of completed surveys, and the details of each individual survey. I only needed to add 4 new REST API calls to do this.  The code to dynamically generate the client survey form was modified to display the survey results dynamically. The relevant new API calls in the Admin Client are listed below:

GET /survey/results/* - Download the survey results in a paged fashion in FireDAC JSON format. The page number is placed where the * is.
GET /survey/stats/all - Download various stats about the survey results in FireDAC JSON format.
GET /survey/details/* - Download the questions and answers from a specific survey ID in FireDAC JSON format. The survey ID is placed where the * is.
GET /survey/emails/csv - Download a list of all of the email addresses from completed surveys in CSV format.

The JSON that is returned is already in FireDAC JSON format (from RAD Server) so it can be easily loaded into a TFDMemTable. The stats dashboard itself uses various FireMonkey objects to display some of the stats and it also uses TeeChart Lite which comes with Delphi 10.2 Tokyo to display the 3 charts. I tried to achieve the same look and feel of the dashboard in the Admin Client as the original AngularJS admin client. Here is the code below to load up the stats into the business dashboard. As you can see TeeChart Lite is pretty easy to use and the charts work across Android, IOS, OSX, and Windows with a single codebase and single UI. What is not visible in the code for TeeChart Lite is that the first Series chart has to be created by right clicking the chart component and selecting Edit Chart... and then choosing the Add... button to create the first chart Series. Once you create the first chart and select the chart type you can then start adding data to the chart via code.

//
//
procedure TMainForm.LoadStats(Sender: TObject);
var
  FrameItem: TFrame;
  FieldType: String;
  FieldCategory: Integer;
  JSONArray: TJSONArray;
  I: Integer;
begin
  ExpValueText.Text := getavg_exp_rating().ToString;
  FoodValueText.Text := getavg_food_rating().ToString;
  ServiceValueText.Text := getavg_service_rating().ToString;
  AmbValueText.Text := getavg_ambiance_rating().ToString;

  BarChart.Series[0].Clear;
  BarChart.Series[0].Add(getAmbiancePercentage(),'Ambiance ('+getAmbiancePercentage().ToString+')');
  BarChart.Series[0].Add(getServicePercentage(),'Service ('+getServicePercentage().ToString+')');
  BarChart.Series[0].Add(getFoodPercentage(),'Food ('+getFoodPercentage().ToString+')');
  BarChart.Series[0].Add(getExperiencePercentage(),'Experience ('+getExperiencePercentage().ToString+')');

  FirstTimeChart.Series[0].Clear;
  FirstTimeChart.Series[0].Add(getfirsttime_yes(),'First Visit ('+getfirsttime_yes().ToString+')');
  FirstTimeChart.Series[0].Add(getfirsttime_no(),'Multiple Visits ('+getfirsttime_no().ToString+')');
  FirstTimeChart.Series[0].Add(getFirstTimeNoAnswer(),'No Answer ('+getFirstTimeNoAnswer().ToString+')');

  RecommendChart.Series[0].Clear;
  RecommendChart.Series[0].Add(getrecommendus_yes(),'Would' + #13#10 + 'Recommend Us ('+getrecommendus_yes().ToString+')');
  RecommendChart.Series[0].Add(getrecommendus_no(),'Would Not' + #13#10 + 'Recommend Us ('+getrecommendus_no().ToString+')');
  RecommendChart.Series[0].Add(getRecommendNoAnswer(),'No Answer ('+getRecommendNoAnswer().ToString+')');
end;

Delphi 10.2 Tokyo has a built in project statistics package which shows you where you are using your time in the IDE when you are developing a project. Below is a screenshot of the time it took to modify the Hospitality Survey Client and turn it into the Hospitality Survey Admin Client. There was some extra debugging time needed to work out some display issues with TeeChart Lite on Android but other than that it was a pretty fast build.

Here is a screenshot of the original AngularJS Hospitality Survey Admin dashboard. It is styled with Bootstrap and uses a Javascript chart library.

Finally, here is a screenshot (see below) of the Delphi 10.2 Tokyo Hospitality Survey Admin Client which uses FireMonkey styling and TeeChart Lite for the business stats dashboard.

Download the full cross platform source code of the Hospitality Survey Admin Client for Delphi 10.2 Tokyo.


Read More

CodeRage XII - Nov 7th - 9th - Call for Papers!

$
0
0

It is time for your favorite online developer conference: CodeRage. This year for CodeRage XII we are adding more platforms, more technology, and more learning. Join us for 3 full days November 7th through 9th. 

Now is the time to submit your sessions for CodeRage XII. Show off what you've been working on. Share best practices. Explore new platforms. And share your knowledge, skills, and excitement with the community!

[Submit your session]

 

Suggested TopicsCodeRage XII

  • Platforms:
    • Linux
    • Windows 10
    • Android
    • iOS
    • macOS 
    • Web
  • RAD Technologies:
    • FireDAC
    • FireMonkey
    • FireUI
    • VCL
    • DataSnap
    • RAD Server
    • REST Clients
    • InterBase
    • Enterprise Connectors
  • Best Practices:
    • Unit Testing
    • Writing SOLID Code
    • Dependency Injection
    • Clean Code
    • Exception Handling
    • Multithreading
    • Patterns and Practices
    • Refactoring
    • Tools and Tips
  • Languages:
    • Delphi / Object Pascal
    • C/C++
    • SQL
    • JavaScript
    • HTML / CSS
  • Emerging Technologies:
    • Working in the Cloud
    • REST Services
    • Microservices
    • Blockchain
    • Cryptography
    • Clustering
    • Artificial Intelligence / Neural Networks / Deep Learning
    • Internet of Things (IoT)
    • Single Board Computers (SBC)
    • Wearables
    • Embedded systems
    • Automation
    • Sensors
    • Robotics
  • Industry Trends and More:
    • Software as a Service
    • Working with Audio and Video
    • Business Side of Software
    • Technical Partners
    • Component Libraries
    • Latest Open Source 
    • MVP Projects
    • Cool Apps
    • Case Studies

Session Formats

We are continuing to evolve the format again this year. We will still have our standard session: 30-45 minutes with 10-15 minute Q&A (hour total tops). You can submit a double session in two parts, or twice as long for a really deep dive (100 minutes with a 20 minute Q&A). This year if you want to submit a shorter session without Q&A we will make space for that too. You can do lightning talks at  15 minutes, quick ideas in 10 minutes, or create a short clip for your favorite development tool, feature, component library, etc. And if "video" isn't your thing, then you can just submit non-video content like sides, code samples, or a paper.

  • Standard session: 45 + 15 minutes Q&A
  • Double Session: 100 + 20 minutes Q&A
  • Lightning Talk: 10 minutes, no Q&A
  • Quick Idea: 5 minutes, no Q&A
  • Clip or Custom: any length, no Q&A
  • Non-video content: code, library, slides, paper, etc.

All videos should ideally be 1920x1080 with audio, in English, but we can work with you if any of that is an issue. We just want to make sure your video looks and sounds great. Speakers can also upload papers, slides and source code to make it easy for attendees to follow along and get the most out of the sessions.

Important Dates

  • Call for Papers: Sept 28th to Oct 15th 
  • Updated descriptions due: Oct 22nd
  • Session materials due: Nov 3rd
  • CodeRage XII: Nov 7th to 8th
  • Premium Subscription Content: Nov 9th

[Submit your session]


Read More

「Delphi + FireDAC」を使ってmacOSからPostgreSQL接続[JAPAN]

$
0
0

Delphi 10.2 TokyoでデバイスターゲットがmacOSの場合ビルド環境は32bitです
なので、PostgreSQL接続に関しては32bitのlibpq.dylibが必要です
現在macOS版のPostgreSQLは64bitのみですので、32bitのlibpq.dylibを利用するには、下記URLの手順が必要です。

http://ht-deko.com/delphiforum/?vasthtmlaction=viewtopic&t=2013
http://a23.sblo.jp/article/181133248.html?1506651043

TFDConnection設定

TFDConnection設定はWindows環境でPostgreSQL接続ができている環境のままでOKです

TFDPhysPgDriverLink設定

TFDPhysPgDriverLinkTFDConnection配置と同じ場所に配置し、
VendorLibをlibpq.dylibの置いている場所に指定します。

  FDPhysPgDriverLink1.VendorLib := '/パス/libpq.dylib';

PostgreSQL接続テスト

下のような画面デザインします。TButton でPostgreSQL接続とクエリー問い合わせするボタンを配置
TMemoを配置しクエリーで抽出したデータを出力します。

「Connection PostgreSQL」ボタンの実装

procedure Tfm_main.Button1Click(Sender: TObject);
begin
  FDConnection1.Connected := True;
  ShowMessage('FDConnection1.Connected := True;');
end;

「start Query」ボタンの実装

procedure Tfm_main.Button2Click(Sender: TObject);
var
  query: TFDQuery;
begin
  query := TFDQuery.Create(Self);
  try
    query.Connection  := FDConnection1;
    query.SQL.Text    := Edit1.Text;
    try
      query.Active  := True;
      while not query.Eof do
      begin
        Memo1.Lines.Append(query.Fields[0].AsString);
        query.Next;
      end;

    except
      on e1: Exception do
        ShowMessage(e1.Message);
    end;
  finally
    query.DisposeOf;
  end;
end;

実行

Delphi FireDACを使って macOSからPostgreSQL接続の確認ができました。
2017_09_29_09_48.gif

 

 


Read More

Experimenting with Neural Networks – Part 2

iOS 11和UniGUI在线研讨会

$
0
0

英巴昨天公布了支持iOS 11:

https://community.embarcadero.com/blogs/entry/build-ios-11-ready-apps-with-rad-studio-10-2-1

 

最新支持平台的信息也公布在docwiki:

http://docwiki.embarcadero.com/PlatformStatus/en/Main_Page#cite_note-1

 

另外前一阵子Idera并购Sencha之后也连续的举办了数次UniGUI的在线研讨会:

https://community.embarcadero.com/blogs/entry/ext-js-kitto-and-unigui-oh-my

 

再对照Marco公布的最新RoadMap要支持Ext JS以及提供Web客户端开发工具, 看来和UniGUI有很大的想象空间:

https://community.embarcadero.com/article/16563-rad-studio-roadmap-september-2017

 

 

巧合的是最近IntraWeb也发展的很快, 似乎有意和UniGUI同台竞争的意思, 目前IntraWeb是附在RAD Studio之中, 未来UniGUIRAD Studio的发展会是如何实在令人好奇.


Read More

RAD Studio東京版支援iOS 11和UniGUI線上研討會

$
0
0

英巴昨天公佈了支援iOS 11:

https://community.embarcadero.com/blogs/entry/build-ios-11-ready-apps-with-rad-studio-10-2-1

 

最新支援平台的資訊也公佈在docwiki:

http://docwiki.embarcadero.com/PlatformStatus/en/Main_Page#cite_note-1

 

另外前一陣子IderaSencha之後也連續的舉辦了數次UniGUI的線上研討會:

https://community.embarcadero.com/blogs/entry/ext-js-kitto-and-unigui-oh-my

 

再對照Marco公佈的最新RoadMap要支援Ext JS以及提供Web客戶端開發工具, 看來和UniGUI有很大的想像空間:

https://community.embarcadero.com/article/16563-rad-studio-roadmap-september-2017

 

 

巧合的是最近IntraWeb也發展的很快, 似乎有意和UniGUI同台競爭的意思, 目前IntraWeb是附在RAD Studio之中, 未來UniGUIRAD Studio的發展會是如何實在令人好奇.


Read More

InterBase 2017 Update 1 and Delphi

$
0
0

A few months after the InterBase 2017 release, Embarcadero has just made available InterBase 2017 Update 1. If you are an existing InterBase user, this is a nice update the install, given it has some performance improvements, bug fixes, and new features, as explained in the announcement article I just publsihed at:

https://community.embarcadero.com/article/16575-interbase-2017-update-1-is-now-available

InterBase is a great embedded database, and the IBLite/IBToGo versions come included with RAD Studio for all supported platforms (desktop and mibile). The Windows developer edition of the full RDMBS (a fast, hassle free, fully powered SQL engine) is also included in RAD Studio and helps power the RAD Server database. Not only InterBase is on par with most competing (and often more expensive) solution, but it has unique features like ChangeViews that can be leveraged to greatly optimize the data traffic, something even more important in today's mobile and distributed world.

While RAD Studio Tokyo ships with the previous version, InterBase XE7, the InterBase 2017 versions of the developer server and IBLite/IBToGo are available in GetIt -- currently still the original release, Udpate 1 will be made available early next week. Read the linked article above for current download links and more information on this version of InterBase.

 


Read More

Delphi / C++Builder 10.2 Tokyo Release 1で iOS 11対応[JAPAN]

$
0
0

Delphi / C++Builder 10.2 Tokyo Release 1 用 iOS 11 patchをリリース

この記事は、Sarina DuPontによるBuild iOS 11 ready apps with RAD Studio 10.2.1の抄訳です。

 

iOS 11 アプリケーションをビルド / デバッグをサポートし、App Store、Ad Hoc、In-House 対応のアプリケーションをビルドするパッチをリリースしました。

ID: 30805, RAD Studio 10.2.1 iOS 11 Patch
https://cc.embarcadero.com/item/30805

iOS 11 対応patchは、iOS 10関連の問題にも対処しています。

更新プログラムは、サブスクリプションのお客様でご利用いただけます。
Delphi / C++Builder 10.2 Tokyo Release 1がインストールされている必要があります。

  バージョン
iOS SDK iOS 10.3.x、iOS 11
Xcode Xcode 8.2.x、8.3.2、8.3.3、9.0

※:iOS 11 Simulatorへのデプロイは現在サポートされていません。
 (これは、macOS 64ビットのサポートが必要なためです。 macOS 64ビットのサポートは、当社の製品ロードマップ上にございます。) 
 iOS 10 Simulatorに関しては、デバイスのターゲット設定がサポートされています。


Read More

How to Transfer Images via DataSnap REST Part 2

RAD Studio 10.2: Windows 10 VCL UWP/WinRT Support

$
0
0

Windows 10 VCL Universal Windows Platform (UWP)/WinRT Services and Components has been added to the Run Time Library (RTL).

For example, the Windows 10 Notifications Component and Windows 10 Sharing/Contract Component, for both Object Pascal and C++ is included in RAD Studio, Delphi and/or C++ Builder

Introduction/Background on WinRT

To implement Windows 8 and Windows 10 features like Notifications and Sharing Contract, there is no Win32 API available for this, so you need access to the WinRT (Windows Runtime).

What is the Windows Runtime (WinRT)?

Starting with Windows 8, WinRT is the default application programming interface.

To be clear, WinRT does NOT replace the Win32 API that has been running underneath all Windows applications but rather augments it.  Microsoft decided to add new APIs instead of adding into the Win32 layer, they think that’s it better to use their new WinRT.  Microsoft has its reasons like its object-oriented, and it’s at the same level as Win32.

The C++ object-oriented API sits at the same level as Win32 API, not a shell that sits under Win32.

This is NOT like the .NET framework that is managed code.  WinRT is NATIVE code and is focused on performance!  For us RAD Studio developers this is perfect to integrate with WinRT!

All the parts of the WinRT API are designed to be asynchronous.  Meaning, according to Microsoft, if a function takes more than 50 milliseconds, this function needs to be asynchronous.

The API definitions are in metadata format, which is the same as the one used for .NET (ECMA 335).  And we use this to generate the new Winapi.* units for WinRT support, that we’ll see later in this post. 

WinRT is not new technology, it’ just the old COM based interface (old friends of ours!), so it was easy to integrate and support WinRT into RAD Studio!

Important to note is NOT all the WinRT classes can be used from Win32 Desktop applications.  WinRT has some classes that can only be used for Metro Applications or used to build WinRT applications, so we translated the classes that can be used from Win32 Desktop applications.

What does the WinRT and Universal Windows Platform Integration mean in RAD Studio?

Using the WinRT API definitions metadata, we created a new set of UNITS, called Winapi.* units (about 40 units) from the metadata.

We created some Helper Classes to let you easily manage the hard part of the creation of the objects (such as avoid getting class factories, etc.).

We created a new TWindowString record to manage HString type.  This is a record helper, to help manage a new HString type that was introduced by Microsoft.

RAD Studio provides WinRT API mappings and Object Pascal interfaces, and this provides support for Services such as Win 10 Notifications and Win 10 Contracts (source only).  

We provide components for both Notifications and Contracts that you can use in your application in both VCL and FMX C++ and Object Pascal.  The Notifications come through the Win10 Standard Action Center.  The Contracts are similar to Intents on Android or ShareSheet on iOS.  The Contracts allow you to find what types of applications can consume the content of your application.  For example, you can select TEXT content in your app, and click SHARE, and then you can open it up with a Reading List Application or a Notes Application.

The sample  \Object Pascal\VCL\Windows 10 Calendar includes WinRT support by System.Win.Winrt and Winapi.winrt.

Using WinRT Classes

Let's takes a quick overview look at some of the WinRT units, and how to use them.

Using RAD Studio 10.2 Tokyo, from Windows Explorer, you can see all the WinAPI units (that Embarcadero has translated) using the APIs metadata, installed at C:\Program Files (x86)\Embarcadero\Studio\19.0\source\rtl\win\winrt

We have Units like UI.Notifications, Globalization, and some interesting ones like Devices.Bluetooth.

WinRTClasses

WinAPI.Devices.Bluetooth contains the new BT and BTLE classes.  (NOTE:  We did discover that Windows implementation of this unit was very poor, and lacked some of the needed BT and BTLE characteristics like Advertisement, but the good news is WinRT fixed all of this!)

Let's say we are interested in working with BluetoothLE Advertisement Manufacture Data.

Open unit Winapi.Devices.Bluetooth.Advertisement in RAD Studio and Search | Find | advertisement, and you will see interfaces for BT LE Advertisement:

BTLEAdvertisement

Let’s look at one more WinRT unit.  Let’s look at Winapi.UI.Notifications that we used for the new Windows 10 Notifications

From Windows Explorer, Drag and Drop Winapi.UI.Notifications.pas into the IDE.

 

WinAPI_Notifications

Looking at the source code for Winapi.UI.Notifications, we see, looking for the TToastManager (line 280), we have the ToastNotificationManagerStatics :

ToastMaster

 We have static methods of a class that you can use, for example, if you create:

1. File | New | VCL Forms App – Delphi.

2. Add Winapi.UI.Notifications to the uses.

WinAPI_UI_Uses

3. Then you can code: TToastNotificationManager.   

And you see Statics: IToastNotificationManagerStatics

 ToastStatics  ToastStaticsButton.jpg

And TToastNotificationManager.Statics.  gives the static methods of the class (functions we can use!).

 

Create a Windows 10 VCL Universal Windows Platform (UWP) application.

Let’s look at one more of the classes, the Calendar class and create a Windows 10 VCL Universal Windows Platform (UWP) application.

For example, using C# and Visual Studio, to create a calendar and display the current year, the code looks like this:

Using Windows.Globalization;

Using Windows.UI.Popups;

Calendar Cal = new Calendar();

String Year = Cal.YearAsString();

MessageDialog ToShow = new MessageDialog(Year);

ToShow.ShowAsync();

In Delphi, we do:

1. New | VCL Forms Application. 

2. Add a Button.  

3. Add to uses:  Winapi.Globalization, System.Win.WinRT;

(Note:  We use the same Globalization classes, and the WinRT is for the Helper classes).

4. For the Button’s onClick Event, we declare the Calendar:

procedure TForm2.Button1Click(Sender: TObject);

var

Cal: ICalendar;

begin

//create the Calendar

Cal := TCalendar.Create;

//get the Calendar Year as a String method (YearAsString),

//returns the new Type HSTRING

//

// So we need to convert it to a Delphi String, using the

//TWindowsString class, with the HStringToString method

//

// And then we can display the Year in a ShowMessage

ShowMessage(TWindowsString.HStringToString(Cal.YearAsString));

end;

5. We want to build this for our Windows 10 machine, Win32:

- Project Options | Delphi Compiler | Linking | Include remote debug symbols | TRUE

RemoteDebugSymbolsWin32

6. Build and Run the app. 

7. Click the Button. 

8. The ShowMessage displays the current year 2017:

Year2017

 So, as you can see, the code in Delphi is similar to the code in Microsoft C# Visual Studio to create a new Calendar. 

This is because if you look at the Winapi.Globalization.pas code from C:\Program Files (x86)\Embarcadero\Studio\19.0\source\rtl\win\winrt, (Drag and Drop the file into the IDE), search for TCalendar (line 1042):

 function GetCalendarSystem: HSTRING; safecall;

We see we have an ICalendarFactory (Search | Find Class):

ICalendarFactory

  // DualAPI Interface
  // Windows.Globalization.ICalendar
  [WinRTClassNameAttribute(SCalendar)]
  ICalendar = interface(IInspectable)
  ['{CA30221D-86D9-40FB-A26B-D44EB7CF08EA}']
  // Windows.Globalization.ICalendarFactory
  ICalendarFactory = interface;
  PICalendarFactory = ^ICalendarFactory;

In the IDE, place your cursor on the ICalendarFactory, | Find Declarations | gives us the Interfaces:

  // DualAPI Interface
  // Windows.Globalization.ICalendarFactory
  [WinRTClassNameAttribute(SCalendar)]
  ICalendarFactory = interface(IInspectable)
  ['{83F58412-E56B-4C75-A66E-0F63D57758A6}']
    function CreateCalendarDefaultCalendarAndClock(languages: IIterable_1__HSTRING): ICalendar; safecall;
    function CreateCalendar(languages: IIterable_1__HSTRING; calendar: HSTRING; clock: HSTRING): ICalendar; safecall;
  end;

We see we have a function CreateCalendar that we can use to create a Calendar.  So we can do a CREATE on the Calendar.  In other cases, you need to use the Factory.

In our sample Calendar app above, we used Cal := TCalendar.Create;

This post gave a quick overview of the Windows 10 VCL Universal Windows Platform (UWP)/WinRT Services and Components added to the RAD Studio, Delphi and C++ Builder Run Time Library (RTL).

[DownloadButton Product='RAD' Caption='Start Your RAD Studio FREE Trial Today to create your own UWP/WinRT applications']

 


Read More

Delphi + Enterprise Connectors + DataSnap = Salesforce native client for iOS and Android

$
0
0

Enterprise Connectors allows you to connect from Delphi and C++ Builder to 80+ enterprise data sources: https://www.embarcadero.com/products/enterprise-connectors.

Between these datasources, we have Salesforce, probably the #1 CRM in the world.

To demonstrate how easy is to use the Enterprise Connectors with FireDAC, I decided to build a native Salesforce mobile client for Android and iOS, using Delphi and Firemonkey on the client side, and DataSnap/FireDAC on the server side.

Solution overview

In summary, the idea is to allow the mobile application to display data from Salesforce cases, a kind of support case management that is part of their CRM solution.

To accomplish this task we’ll have an FireDAC Salesforce connection in the DataSnap server, which will allows us to validate the user credentials, as well to query the cases entries directly from the Salesforce in the clouds.

The cool thing from the Enterprise Connectors is that, you basically can issue standard SQL ANSI queries against any supported data source, easy as 1,2,3.

Server Implementation

Our server application is an standard Datasnap REST server application. Before starting, I have installed the Salesforce driver from the Enterprise Connectors collection that are available in the GetIt as a trial: https://community.embarcadero.com/blogs/entry/enterprise-connectors-are-now-live

 

As you can see in the image, it’s a standard FireDAC implementation, the only difference from connecting a regular database are the parameters. In this case, for Salesforce, you can create an developer account in https://developer.salesforce.com.

Our server has only two methods, one to authenticate the user, and another one to grab some Salesforce data:

function TServerMethods1.DoUserLogin(fUserName, fPassword: string): boolean; begin FDCnn.Params.UserName := fUserName; FDCnn.Params.Password := fPassword; try // open the connection to validate the user/pass FDCnn.Open; Result := True; // close the connection after the validation FDCnn.Close; except on E: Exception do raise Exception.Create('UserLogin: ' + E.Message); end; end; function TServerMethods1.GetSFCases(fUserName, fPassword: string) : TFDJSONDataSets; begin // active the connection FDCnn.Params.UserName := fUserName; FDCnn.Params.Password := fPassword; FDCnn.Open; // serialize the dataset CaseTable.Close; Result := TFDJSONDataSets.Create; TFDJSONDataSetsWriter.ListAdd(Result, CaseTable); end;

Again, it’s a standard DataSnap/FireDAC server, serializing and returning the JSON data to the client, in this case an multi device application with FMX.

Mobile Client Implementation

Our client application has a login form, a ListView using the Dynamic Appearance style to display the cases data, and an third tab that shows all the selected case details.

 

The data is de-serialized back to a TFDMemTable using the FireDAC reflection classes, as you can see in the excerpts below:

function TMainDM.UserLogin: boolean; begin Result := False; DSRestCnn.Host := fServerIP; if ServerMethods1Client.DoUserLogin(fUserName, fPassword) then begin SaveLoginData; Result := True; end; end; procedure TMainDM.LoadSFCases; var LDataSetList: TFDJSONDataSets; begin DSRestCnn.Host := FServerIP; LDataSetList := ServerMethods1Client.GetSFCases(fUserName, fPassword); CaseMemTable.Close; CaseMemTable.AppendData(TFDJSONDataSetsReader.GetListValue(LDataSetList, 0)); CaseMemTable.Open; end;

There are some other details in the client application, like saving the login information, the general app workflow, look&feel and etc., that you can review downloading the samples in the link by the end of this post.

 

All the source code from this sample is located here, in my personal GitHub: https://github.com/flrizzato/CDATA

And stay tuned, next week I’ll show how you can easily connect an real SAP/R3 implementation directly from an Delphi or C++ Builder, and display/modify some data from the ERP, with almost no code!

ps: in order to run the sample, you’ll need to create an Salesforce developer account and add the login information and security token in the FireDAC connection before trying to run.

 

 



Read More

How to enqueue TQueue from TTask with bcc32

$
0
0

When considering migration from old C++Builder 10.2 Tokyo bcc32 project.
You can use functions such as TThread::CreateAnonymousThread() and TTask to improve performance.
In addition to TCriticalSection, you can also use System.TMonitor which supports multiple devices.
I will show you how to program bcc32 project using the above method.

TQueue<String> is created in Delphi.

TQueue<T> is in System::Generics::Collections.
To use TQueue<String>, describe it in Delphi as follows.

uses
  System.Generics.Collections;
type
  TQueStr = class(TQueue<String>)
  end;

You can now use TQueue__1<System::UnicodeString>.

Create a class to run in the interior of the TTask.

//_proc is a struct to execute TTask::start().
struct _proc: TCppInterfacedObject<TProc>
{
    TQueue__1<System::UnicodeString>* f_queue_;
    TObject* f_mutex_;      //TObject behaves like a mutex.
    int f_number;

    _proc(int i, TObject* lmtx, TQueue__1<System::UnicodeString>* lq):TCppInterfacedObject<TProc>(){
        f_mutex_ = lmtx;
        f_queue_ = lq;
        f_number = i;       //This is the number where the Task is executed.
    }

    //Convert from int to string.
    std::string int_to_string(const int i)
    {
        std::ostringstream ss;
        ss << i;
        return ss.str();
    }

    //Executed in TTask.
    void __fastcall Invoke(){
        std::string s = "TTask" + int_to_string(f_number+1);
        //Lock with TMonitor.
        System::TMonitor::Enter(f_mutex_);
        try
        {
            //Add a character to the common TQueue<String>.
            f_queue_->Enqueue(s.c_str());
            //Sleep(100);
        }
        __finally
        {
            //UnLock with TMonitor.
            System::TMonitor::Exit(f_mutex_);
        }
    }
    inline __fastcall virtual ~_proc(void){
    }
};

Actually executed is void __fastcall Invoke(){}.
The internal in the task memory each other will use the System::TMonitor::Enter(f_mutex_); so as not to conflict.

It is a class that creates many TTasks.

We have created and stored many TTasks in std::vector<_di_ITask>.

struct _queue_task
{
    TQueue__1<System::UnicodeString>* f_queue;
    TObject* f_mutex;           //TObject behaves like a mutex.
    std::vector<_di_ITask> v1;  //_di_ITask is managed with std::vector.
    _queue_task(){
        f_queue = new TQueue__1<System::UnicodeString>();
        f_mutex = new TObject();
    }
    std::vector<_di_ITask>& start(const int icount)
    {
        // Only the number of purpose, to create a TTask.
        for (int li = 0; li < icount; li++)
        {
            //The TTask is _proc::Invoke() is executed.
            v1.push_back(TTask::Create(_di_TProc( new _proc(li, f_mutex, f_queue))));
        }
        for (std::vector<_di_ITask>::iterator tsk = v1.begin(); tsk != v1.end(); ++tsk)
        {
            //Start the TTask in the std::vector in order.
            (*tsk)->Start();
        }
        return v1;
    }
    virtual ~_queue_task()
    {
        //Destructor
        delete f_queue;
        delete f_mutex;
    }
};

Using TThread::CreateAnonymousThread() etc., the design method as shown below is also possible.

 


Read More

Why I Choose Delphi Summary

$
0
0

Over the summer, there has been a number of blog posts on the "Why I Choose Delphi?" topic. While providing personal ideas, they do have common themes and I think there are very interesting to read, for anyone who is using Delphi today (or used it in the past). Here is the list of the blogs I noted, and I migh have missed others, let me know:

David Harper: https://csvelocity.wordpress.com/2017/07/27/why-i-choose-delphi/

Andre Celestino: http://www.andrecelestino.com/why-i-choose-delphi/

Frank Lauter: http://delphiprofi.blogspot.it/2017/08/whyichoosedelphi.html

Ryan Potts: https://rpottsoh.github.io/Why-I-Choose-Delphi/

Jim McKeeth:  https://community.embarcadero.com/blogs/entry/why-i-keep-choosing-delphi and http://delphi.org/2017/08/why-i-keep-choosing-delphi/

Steffen Nyeland: https://fixedbycode.blogspot.it/2017/08/why-i-keep-preferring-delphi.html

Ray Konopka: https://delphibydesign.com/why-i-choose-delphi/

Jens Fudge: https://community.embarcadero.com/blogs/entry/why-i-choose-delphi

 Robert Calco: http://www.hitcompileandrun.com/2017/08/why-i-choose-delphi.html

"T Theobald":  http://borkedcode.com/wp/?p=1511


Read More

Wi-Fi management from applications using C++Builder

$
0
0

Using C++Builder 10.2 Tokyo, explain how to switch Wi-Fi on Android.

Manage Wi-Fi switching using JWifiManager

I use di_JWifiManager which wrapped WifiManager.
di_JWifiManager is the Delphi interface.
Set the variable. _di_JWifiManager f_WifiManager; use it like this.

Required headers

Header file for using WifiManager.

#include <Androidapi.JNI.Net.hpp>
#include <Androidapi.Helpers.hpp>
#include <Androidapi.JNI.GraphicsContentViewText.hpp>
#include <Androidapi.JNIBridge.hpp>

Display design

It is a design for displaying on Android.


TEditTSwitchTTimerTLabel, was placed.

 

When the main form creation

Create _di_JWifiManager using TJWifiManager.

//---------------------------------------------------------------------------
void __fastcall Tfm_main_wifistatus::FormCreate(TObject *Sender)
{
    //Form creation.Using TAndroidHelper, get the WIFI_SERVICE.
    _di_JObject obj = TAndroidHelper::Activity->getSystemService(TJContext::JavaClass->WIFI_SERVICE);
    if (obj != nullptr)
    {
        //Wrap to TJWifiManager.
        f_WifiManager = TJWifiManager::Wrap(_di_ILocalObject(obj)->GetObjectID());
        if (f_WifiManager != nullptr)
        {
            Timer1->Enabled = true;
        }
    }
}

Monitor Wi-Fi status at Timer1 event.

void __fastcall Tfm_main_wifistatus::Timer1Timer(TObject *Sender)
{
    //Use a timer event to monitor the Wi-Fi state.
    //Write state change to Edit1->Text. and It also reflects Switch1->IsChecked.
    Timer1->Enabled = false;
    if (f_WifiManager != nullptr)
    {
        Switch1->IsChecked = f_WifiManager->isWifiEnabled();
        UnicodeString wifistr;
        (Switch1->IsChecked)?wifistr = "true": wifistr = "false";
        Edit1->Text = "f_WifiManager->isWifiEnabled() = " + wifistr;
    }
    Timer1->Enabled = true;
}

When you tap the Switch1.

Change the Wi-Fi status when tapping the Switch1.
This uses the setWifiEnabled() function.

void __fastcall Tfm_main_wifistatus::Switch1Switch(TObject *Sender)
{
    //This is a Switch1 change event.
    Timer1->Enabled = false;
    //Set the value of Switch1->IsChecked to setWifiEnabled()
    f_WifiManager->setWifiEnabled(Switch1->IsChecked);
    TThread::CreateAnonymousThread([this]()
    {
        sleep(1);
        TThread::Synchronize(TThread::CurrentThread, [this]()
        {
            Timer1->Enabled = true;
        });
    })->Start();
}


Read More

Embarcadero Academy

$
0
0

One developer asked me recently on Embarcadero community chat where he could find any learning resources for Delphi. Then I have realized that maybe not everybody is aware that just recently "Embarcadero Academy" has launched!

It has been a big effort for a long time, but it is there and it is time to start using it!

At Embarcadero Academy you find online courses covering different technologies and programming languages run by well-known experts such as Delphi Product Manager Marco Cantu and many more.

There are different resources available such as:

  • Self-paced and live-lecture courses
  • Online developer bootcamps
  • Online developer conferences and replays
  • Developer skill certification exam

 Don't wait! There is always a good time to learn something new and become a better programmer!


Read More

My Courses on the New Embarcadero Academy

$
0
0

The online training site Embarcadero Academy, an independently-run but Embarcadero affiliated training web site, was launched a couple of weeks ago: http://www.businesswire.com/news/home/20170918005798/en/Embarcadero-Academy-Debuts-Online-Courses-Developers-Levels. The academy features classes on different topics, but a lot of them are focused on Delphi programming. You can see the list of Delphi classes here:

https://www.embarcaderoacademy.com/courses/category/Delphi

The site has paid online classes by several Delphi experts and it is going to be expanded rapidly with new content and options (live training, beside self-paced tutorials, subscriptions, etc). The classes are mostly video oriented and, in my case, they are slide free and focused on code.

I have currently 3 classes listed, two on interfaces (and there is a bundle to get both at once, as shown in the image) and one on generics. Another one on anonymous methods is in the works. As you can see my initial effort is to focus on the most recent and more complex features of the Object Pascal language, with content that matches my book but is presented in a different way. What I do, in fact, is building the example step by step, showing the feature but also reasoning on alternative coding options and ideas. I plan expanding my contribution completing the advanced area (RTTI, reflection, attributes), and add more core topics (properties and events, classes and objects, etc) and possibly even beginners Pascal material. Ideas are welcome. As an example, the bundle shown and linked here with the two classes on interfaces and my ebook, is currently priced at 29 US$. See https://www.embarcaderoacademy.com/p/interfaces-in-delphi-intro-to-advanced for more information.


Read More

New in 10.2.1: Debug visualisers for Delphi generics

$
0
0

Debug visualisers are a type of IDE plugin that allows you to change the display of a variable in the various debug windows (Local Variables, Watches, Inspector, and Evaluate/Modify.) For example, the TDateTime visualiser takes the double value that represents time and instead displays that time converted to a string. You register a debug visualiser for a type, so all variables of that type, and optionally descendants of that type, go through your visualiser.

In previous versions, this type was specified by a plain string, such as 'TComponent', and there was no way to handle a generic type. If you registered 'MyGeneric<T>', the visualiser would never be called, because the concrete instantiations of that type do not use T - they might be 'MyGeneric<Integer>', 'MyGeneric<TButton>', and so forth.

In 10.2.1, we have introduced support for registering a visualiser for a generic type. Your visualizer can implement IOTADebuggerVisualizer250 as well as the prior IOTADebuggerVisualizer, where the GetSupportedType method allows you to specify that the type string is a generic:

 

.
  IOTADebuggerVisualizer250 = interface(IOTADebuggerVisualizer)
    ['{DC0C8D82-B783-4205-B3F4-D325BA8B3EEB}']
    { Return the Index'd Type.  TypeName is the type.  AllDescendants indicates
      whether or not types descending from this type should use this visualizer
      as well. IsGeneric indicates whether this type is a generic type. }
    procedure GetSupportedType(Index: Integer; var TypeName: string;
      var AllDescendants: Boolean; var IsGeneric: Boolean); overload;
  end;

This means you can register for MyGeneric<T> and your visualiser will be called for all MyGeneric<>s. This is all generic types, ie interfaces as well as classes. 

One note is that we do not yet support registering for descendants of a generic type, meaning that if you have MyDesc<T> = class(MyGeneric<T>) or MyDesc = class(MyGeneric<T>), you need to register a visualiser for MyDesc separately. This is because of some complexities in the internal evaluator.

Generics are widely used, especially for collections like dictionaries and lists, and in third-party libraries like Spring4D. We hope you will find visualiser support for generics useful!


Read More

New "Delphi Memory Management" book is a hit!

$
0
0

Yesterday evening I have found an excellent Delphi book I have been always waiting for!

The full title of the book is "Delphi Memory Management for Classic and ARC Compilers"  and it is written by Dalija Prasnikar. The book is available in electronic form as a pdf file only.

The topic of memory management is probably the most important in becoming a competent Delphi developer. When you write code, you want to have a proper understanding what is happening under the hood and that is exciting about this book!

A must read for any serious Delphi programmer! Perfect reading for the upcoming weekend!


Read More
Viewing all 1683 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>