Open Menu

Synergex Blog


How “easy” can easy be – Google it!

By Richard Morris, Posted on May 24, 2017 at 4:45 am

The post conference workshop developed from the ground up a vinyl record collection catalogue system that allowed the management of your favourite records. The workshop stepped through the various aspects of the system including a desktop WPF maintenance program and remote management of your cloud based catalogue using the Synergy DBMS manager.

Having all your vinyl discs catalogued is great – but when I’m in the record shop browsing through all the latest available titles I often wonder – have I got this one? I’ve got a lot of vinyl’s and many more CD’s so remembering all the one’s I have can be difficult, and there is nothing worse than buying a duplicate.

So our OnVinyl app we built at the conference allows us to scan the barcode of the album in the store and check it against our catalogue – if we have it then the details are displayed and we don’t go and buy it again.

Getting all the album information into our catalogue would have been a long and rather boring job – especially having to trawl the web looking for the artwork to associate with each album we have. We need an easier solution – and so to Google we turn.

We all know how good Google is at searching for basically anything you can think of really, but did you know you can use this powerful searching capability from within your Synergy programs? Google provide a search API that allows you to simply and very easily perform any search you require. This is the facility we added into our OnVinyl Album Maintenance program – enter (or scan if you have a barcode scanner to hand) the barcode on the album and pass this through to the Google search API. Our implementation retrieved the album name, artist, cost and artwork so we are able to populate all the fields in the maintenance form – without any typing!

The Google search API provides a REST API that you can call directly from within your Synergy program. For full details visit https://developers.google.com/custom-search/json-api/v1/using_rest. To use the API you need a Google account. The first step is to create an “API key” which allows you access to various Google API’s and identifies you to those API’s. Visit the Google API Manager console to create an API Key. Once you have an API key then you can set up a custom “search engine” that allow you to customize how your searching is performed. You can limit the results to certain web sites for example. This is all configured using the Google control panel (https://cse.google.com/all). To begin you create a new “search engine” and name it. Once created it will be assigned a unique search engine ID – you’ll need this!

In your Synergy code define some constants;

The API is a REST implementation that has a defined URI;

And then make the required REST call to retrieve the search results;

And that’s the call to your custom search engine complete. The response from Google will be in the form of a JSON string which you need to parse and out and extract the individual elements you require. The code for that is available in the OnVinyl project.

And the results in your application;

Easy really is easy with Synergy and Google searching!

On a side note – I’ve been wondering where Jodah had got to, and then this appeared in my inbox;

I’m sure I recognise those eyes…. Have you seen or got a picture of Jodah’s identifying name tag?

 

 

 


Code Gremlins?

By Richard Morris, Posted on May 17, 2017 at 8:27 am

This year’s DevPartner conference was held in Atlanta, Georgia and was a blast. I guess I say “the best ever”” each year, so I won’t this time – but it was. The whole conference ran flawlessly, although throughout the week I did see a few strange things in the corner of my eye – but you know how it is. You think you are seeing things… But maybe not.

We had lots of new faces in the audience seeing what Synergy has to offer which is always great, and they got to see a few new faces presenting at the DevPartner conference for the first time.

Although Phil could be considered a veteran now – his third conference – he was joined on stage by first-timer Tate, a fellow support engineer. They presented a cool session on BOTS – not those things you sit on, the automated robots that answer whatever questions you have. There are loads of bots around and the duo showed us what it’s all about and how to build you own!

Another new face was Jacklin who presented all the ways to get fully up to speed with Synergy today including all the various media feeds and the cool YouTube channel we have that’s being loaded with great training videos – and of course you can always re-watch all the conference sessions.

At the beginning of March I blogged about “Physio My Way” which is an app to monitor a patients compliance to perform their prescribed upper limb exercises. Ashley presented the full Physio My Way story and received great feedback – if you get the time check out the Synergex YouTube channel in the coming days to see the full video! It’s a complete mobile solution written end to end in Synergy.

And so to my post-conference workshop. The goal was to write, from scratch, a complete application called “On Vinyl”. “On Vinyl” is a vinyl collection management and inquiry system. The system is written entirely in Synergy .Net and uses the Symphony Framework.

We started off by code generating the base data objects – the classes that expose the Synergy Repository structures as classes with full get/set properties for the fields. We also code generated classes to provide complete data management using Symphony Harmony.

Next we built a simple maintenance program to allow us to manage our collection of vinyl albums. To save typing we also implemented the ability to perform a Google search passing in the album barcode and returning/displaying all the album information, including the cover artwork. I’ll blog about just how easy it was to implement Google searching soon.

Next we hosted all the server logic on a remote cloud server behind Symphony Bridge and showed how to manage the data remotely using the Synergy DBMS Manager (available on the download page at www.symphonyframework.net).

Next we moved to the client portion of the project – to build and deploy an app on the Android and iOS platforms to enable us to check if we have a particular vinyl in our collection. We built up the technology stack. First layer was the client data layer – code generated data objects built into a portable class library. Next we created the connection library which used commands to search for vinyl details using the barcode:

If we didn’t have the album in our collection we could call our stored procedure to perform the required Google search:

And if we chose to buy the album we could insert it into our collection directly from the device:

Our final portable library was the common UI code – using Xamarin Forms. This provides the ability to write the UI once and deploy to different target devices such as Android and iOS.

Up to this point, although there were a couple of “what was that…” moment’s things all built and ran just fine.

The final piece of the puzzle was to write the device specific code – and our first target was Android. We created the project, added the required resource (images, etc.) and after a couple of minor typo’s the project built. But something was not quite right and we could not get the program to successful deploy and run.

We’d hit the end of the day so aborted the attempt and regrouped to try to find out what had gone wrong.  Once we have the solution I’ll post the entire project to GitHub and blog about it!

Now I don’t really believe in code gremlins, ghosts or phantoms, but throughout the week there were some strange goings-on, and to be honest I was having flash-backs to conference time 2009! Surely he was not back to try to mess up my workshop again?

And where did Jodah get to……?


CodeGen 5.1.9 Released

By Steve Ives, Posted on May 12, 2017 at 8:45 am

I am pleased to announce that we have just released a new version of CodeGen (5.1.9) that contains some new features that were requested by customers. The changes in this release are as follows:

  • We added two new structure expansion tokens <FILE_ODBC_NAME> and <FILE_RPS_NAME> that expands to the repository ODBC table name or structure name of the first file definition that is assigned to the structure being processed.
  • We made a slight change to the way that the multiple structures command line option (-ms) is processed, allowing it to be used when only one repository structure is specified. This allows for templates that use the <STRUCTURE_LOOP> construct to be used when only one structure is being processed.
  • We also fixed an issue that was causing the <FIELD_SPEC> token to produce incorrect values for auto-sequence and auto-timestamp fields. Previously the value 8 would be inserted, now the correct value i8 is inserted.

This version of CodeGen was built with Synergy/DE 10.3.3c and requires a minimum Synergy runtime version of 10.1.1. You can download the new version directly from the CodeGen Github Repository.


I didn’t know you could do that!

By Richard Morris, Posted on March 23, 2017 at 2:34 pm

Working with the many customers we have is a great opportunity to advance the software we write. Some time ago I blogged about Symphony Bridge – a server based utility that allows you to expose Synergy data and logic through Symphony Harmony using an SQL-like syntax. In essence you can write queries on the client like “select * from part” and the bridge server will return a collection of part objects that are based on a structure you have created in your repository. You can then bind these to grids or input controls on you windows or mobile applications or display them in web pages. In fact you can use the data in any Synergy .Net or non-Synergy application.

Another aspect of Symphony Harmony/Symphony Bridge is the ability to call a remote procedure using the syntax “exec @MyNameSpace.MyClass.MyMethod”. You can pass in arguments and again a data object or a collection of data objects are returned.

During a recent visit with one of our customers who is currently utilizing symphony Harmony and Symphony Bridge to provide third-party access to their systems to allow enquiries on orders, etc. I was asked about “providing the ability to return a standard object that contains the call status AND the response data”. Simple, no problem: Create an RPS structure that defines your response details – call status, error codes, and error message for example. Code generate the required data object and then customize it by exposing a collection of <DataObjectBase> (the base class of all data objects!) As I said – simple.

But the customer was not overly impressed – and they had an idea! Oh dear me thinks – these are seasoned C# developers and I’m not convinced I’ll be able to implement their ideas in Synergy .Net! But how wrong I was…. and without any changes to the Symphony Framework. The basic requirement is to have a “response” class that they can extend with any serializable “type” – be that a single instance or a collection of “type” – without any restrictions.

The starting point was the same – create the required response structure in the repository and code-generate the “response” class. This is the resulting class definition;

public partial class Server_response_Data extends Symphony.Conductor.Model.DataObjectBase

The code generation process creates all the required properties and the logic to serialize the data into JSON or BSON.

The next step was to create a second class with the same name as the response class but this time it will accept a generic – generics are quite cool and allow you to defer the specification of a type until that type is instantiated. So our generic response class definition looks like this;

public class Server_response_Data<T(new)> extends Server_response_Data

By extending the base code-generated class we get all the required Symphony capabilities. The “T” denotes the generic “type”. The (new) ensures that any type you provide must have a parameter-less constructor which ensures that this class can creates an instance of it. We can expose the property so it’s serializable;

{JsonProperty}
public property Result, T
       method get
       endmethod
       method set
       endmethod
endproperty

And in the constructor we can ensure there is an instance (to prevent null object exceptions);

public method Server_response_Data
       endparams
proc
       Result = new T()
endmethod

And that is about it. You can then write your server methods to create an instance of your response class, populate the generic “response.Result” with the required “type” and set the response properties accordingly. For example;

data response = new Server_response_Data<Part_Data>()

Will create a response class with the “Result” as a type of Part_Data data object. If you need to return a collection of Part_Data objects;

data response = new Server_response_Data<List<Part_Data>>()

It’s really as easy as that. On the client you simply make the remote EXEC call through Symphony Harmony;

result = DataExecute.RunDataExecute(connector,
       &      "exec @MyNameSpace.MyClass.MyMethod",
       &      new Server_response_Data<List<Part_Data>>()).Result

You can also await the call on a separate thread.

Big shout-out to Gareth for the idea and his persistence to make me get it working!

I’ll be using these techniques in my DevPartner 2017 post conference workshop as we build a mobile app from start to finish using Symphony Harmony/Symphony Bridge to access remote data and logic.


Let’s get Physical – at DevPartner 2017!

By Richard Morris, Posted on March 8, 2017 at 8:38 am

The DevPartner 2017 conference is rapidly approaching and so I thought I’d follow on from Steve’s recent blog about the conference and what a content packed agenda we have this year. As usual we have the hugely successful customer demonstrations – always great to see how developer are making the most from Synergy today. There are guest speakers taking about testing your software – and I thought if it compiled it was tested, so I’ll be glued to that one. We also have a student Physiotherapist guest speaker – not your usual topic for a Synergy software conference I must agree!

Way back in 1981 a certain blond bombshell by the name of Olivia Newton-John hit our screens in tight pink leggings telling us all to “get physical”. For many around my age she was the pin-up of our times. I’m sure I can recite all the lyrics today! Although we won’t be seeing Miss Newton-John at the conference (sorry) we will be “getting physical”!

As part of an undergraduate degree I’ve developed an interactive mobile app:

Exercise compliance is one of the most important parts in patient rehabilitation, and yet it is given minimal consideration. The Chartered Society of Physiotherapists (CSP) detail that the first step in rehabilitating a patient back to their pre-injury function lies with their Physiotherapist’s ability to educate and motivate their patient through a clear and concise home exercise program. Patients can regularly expect to receive a printed sheet of generic exercises laden with hand-written amendments which look to tailor the exercises to the patient’s needs. Given that more than 70% of adults in the U.K. own a smartphone, there has never been a better time to take the technological leap and focus of connecting with and engaging patients much more remotely. That’s where Physio My Way comes in.”

And so Physio My Way was born. Written entirely in Synergy .Net it’s a true mobile application that is designed to educate patients to perform the correct exercises and monitor their compliance with the exercise schedules defines by their therapist. In-app options include the ability to review the various assigned exercises and stream videos that show just how they should be performed. Guidance is provided through spoken instructions and monitoring patient compliance is recorded using the devices accelerometer.

Movement patterns and screen activity can provide a clear and detailed account of every single repetition that a patient completes. Their Physiotherapist will have secure access to all of their patients’ data through their own personal log in. Specifically, this means that all exercise progressions or regressions will now be based on objective outcome markers, rather than a patient’s subjective recollection of their exercise completion. This gives superior reliability of patient feedback and is based on key Physiotherapy findings such as severity, intensity and frequency of pain and rate of perceived exertion at every interval.”

Our guest student Physiotherapist , Ashley, will be presenting an interesting session on his design and the theory behind the Physio My Way app and the results from his studies – did it improve people’s compliance with their prescribed exercise plan? And I’ll be dissecting the technologies used to develop and deploy data in the cloud and the app to Google Play Store and the Apple App Store:

At the post conference workshop on 12th May I’ll be building, from the ground up, a cross-device mobile application through lecture and demonstration. The session will target both Android and iPhone devices. Using the latest Synergy tools, Xamarin forms and Visual Studio.  We will initially build and deploy a simple cloud based server. From here we will build a client connection module to communicate to our server and also implement the required code to manage Synergy device licensing. Next we will layer on the UI – XAML based cross device compliant forms. We’ll include some cool Xamarin components and finally build and deploy to both iPhone and Android. It’s a not-to-be-missed day if you are interested in expanding your Synergy applications capabilities onto the mobile device platforms.

Make sure to sign up and bring your exercise gear as we “get physical” at DevPartner 2017!


Build RESTful Web APIs at the DevPartner Conference

By Steve Ives, Posted on February 23, 2017 at 10:23 pm

Today we published the agenda for the 2017 DevPartner Conference which will take place in Atlanta, GA the week of Monday May 8th; we hope you can join us. The main conference will be a three-day event from Tuesday May 9th through Thursday May 11th. And similar to other recent conferences we will be offering both pre- and post-conference workshops on Monday 8th and Friday 12th respectively. I will be hosting the pre-conference workshop entitled “Building RESTful Web Services with Synergy .NET and ASP.NET Web API”. My colleague Richard Morris will be presenting the post-conference seminar entitled “Building Platform-Independent Mobile Apps with Xamarin Forms”. Of course we hope you can join us for both workshops, but for the remainder of this article I will be focusing on providing information about the pre-conference RESTful web services workshop.

Building and implementing web service APIs isn’t exactly new, but there are definitely some new and exciting technologies in play that can make building, deploying and interacting with web services faster, easier and more powerful than ever. With the relentless increase in demand for mobile applications and solutions the requirement to expose web service APIs is greater than ever. Not that web service API’s are only used to support mobile applications, that is certainly is not the case. In fact almost any new application developed today is likely to either require the use of a web service API, or it will just make sense to architect the application that way for increased flexibility and future-proofing.

I’m developing the content for my workshop right now and I wanted to give you some information about the audience that I am targeting, which is very broad. To be honest, unless you are already implementing RESTful web service APIs then this workshop is for you! And even if you ARE already implementing RESTful web services APIs, but with some technology other than ASP.NET Web API, then this workshop is also for you! In my opinion it is really important that every developer have at least a good understanding of what a RESTful web service APIs are and how they can be used, and it sure doesn’t hurt to know how to build them either! This workshop will teach you all of those things, and more.

We will start with the basics and will not assume any previous knowledge of web services. After an introductory presentation there will be lots of code, so you will need to be comfortable with that. I don’t want to just show you how to build a RESTful web service API, I want you to really understand what it is and how it works. So as well as covering ASP.NET Web API we will also be talking about the basic principles of REST, as well as various underlying technologies like HTTP, JSON and XML. If it all works out as planned it should be an action packed and interesting day.

This year both of the full-day workshops will be lecture and demonstration based; there won’t be any hands-on component. Unfortunately the hardware and software requirements of the underlying technologies that we will be using, particularly in the post-conference workshop, make it virtually impossible for us to offer a hands-on experience this time around. But rest assured that you will have access to all of the code that is developed and demonstrated, and we’ll make sure that you know exactly what hardware and software you will need if you want to work with that code, or perform your own similar development projects.

Time is ticking away and DevPartner 2017 is only about 10 weeks away. We’re all looking forward to seeing you again, or meeting you for the first time, and if you haven’t done so already then it’s time to register. See you there!


CodeGen 5.1.7 Released

By Steve Ives, Posted on February 7, 2017 at 10:25 am

We are pleased to announce that Professional Services has just released CodeGen 5.1.7. The main feature of the release is the addition of experimental support for generating code for the MySQL and PostgreSQL relational databases. Developers can use a new command line option -database to specify their database of choice. This causes the SQL-compatible data types that are injected by the field loop expansion token <FIELD_SQLTYPE> to be customized based on the chosen database. The default database continues to be Microsoft SQL Server.

Before we consider support for these new databases to be final we would appreciate any feedback from developers working with MySQL or PostgreSQL to confirm whether we have chosen appropriate data type mappings. Additional information can be found in the CodeGen documentation.

 


CodeGen 5.1.6 Released

By Steve Ives, Posted on November 7, 2016 at 4:31 pm

I am pleased to announce that we have just released a new version of CodeGen with the following enhancements:

  • We modified the way that key loops are processed so that if a repository structure has a mixture of access keys and foreign keys defined, the foreign keys are ignored when processing key loops.
  • We added a new key loop expression <IF FIRST_SEG_NOCASE>.
  • We added four new field loop expressions <IF AUTO_SEQUENCE>, <IF AUTO_TIMESTAMP>, <IF AUTO_TIMESTAMP_CREATED> and <IF AUTO_TIMESTAMP_UPDATED> which can be used to determine if fields are defined as auto sequence or auto time-stamp fields.
  • We added two new key loop expressions <IF AUTO_TIMESTAMP_CREATED> and <IF AUTO_TIMESTAMP_UPDATED>.
  • We added two new key segment loop expressions <IF SEG_AUTO_TIMESTAMP_CREATED> and <IF SEG_AUTO_TIMESTAMP_UPDATED>.
  • We changed the behavior of the field loop expansion token <FIELD_TYPE_NAME> when used in conjunction with auto-sequence and auto-time-stamp fields.

This version of CodeGen is built with Synergy/DE 10.3.3a, requires a minimum Synergy runtime version of 10.1.1, and can be downloaded from here.


Wheel, Scroll, Oops.

By Richard Morris, Posted on October 14, 2016 at 6:45 am

If you answer “yes” to the following questions, then please read on: Do you have a Synergy UI Toolkit application? Do you use standard (not ActiveX) list processing with a load method? Do you run your software on Microsoft Windows 10?

Windows 10 offers a new feature that allows you to mouse over a list and use the mouse wheel to scroll the list, without the list actually getting focus. It’s a great feature, but if you have a standard list displayed in your UI Toolkit application which uses a load method – then that mouse-over scroll operation will attempt to “process” the list and cause the list load method to execute. Does not sound too bad – but if you have method data being passed through from the l_select() or l_input() routines then this data will not be passed to your load method, because you are not actually in l_select() or l_input(). Also, because the list has not gained focus you have potentially not been through your “my list is gaining focus so set up the load parameters” logic, which again means when your load method executes it’s in an unknown state.

When your load method executes in this “unknown” state and you try to access method data or your uninitialized load data then a segmentation fault may occur. The user uses the Wheel, the list attempts to Scroll and Oops your application crashes.

Thankfully, the Synergex team have found the issue and resolved it – and the fix will be in the upcoming 10.3.3b patch. If you are experiencing this issue today and need a resolution now, you can contact support who can provide you with a hotfix.


Examining and modifying Synergy data

By Richard Morris, Posted on September 5, 2016 at 11:41 pm

The Symphony Framework provides the ability to expose Synergy data as “Data Objects”. A “Data Object” or DO for short, is a class that exposes the fields of your repository structure as properties that can be accessed using Get and Set methods. These DO’s also provide access to the “raw” synergy record data through a property called SynergyRecord. The SynergyRecord property is the basic way to put record data into or get record data out of your DO. There are a lot of additional properties associated with DO’s, like its validity based on repository and custom validation rules, but those are for another blog. By exposing the individual field elements as Get/Set properties this allows us to bind to them from code (Synergy or C#/VB.Net) and in the WPF world the UI layer in XAML.

The Symphony Harmony framework allows you to select data from a Synergy DBMS file using standard SQL style syntax. Under the hood it uses the powerful SynergyDE.Select capabilities to access data in a file after parsing the SQL like query string. The data is returned as a collection of DO’s.  A simple example could be;

Select * from group

Where “group” is the name of a structure/file relationship in your repository. The Symphony Harmony returns all the located records in the form of DO’s. This means we can bind to the individual properties exposed by the DO.

Harmony can accept more complicated requests, for example;

SELECT Id ,Description ,Quantity ,Cost_price FROM part WHERE cost_price BETWEEN 10 AND 20

Is a valid query that will return only the DO’s that match the where clause.

To show the capabilities of the Symphony Data Object and Symphony Harmony I’ve put together a simple “Synergy DBMS Manager” program that allows you to interrogate and manage data in a Synergy ISAM data file. You can select data using SQL like syntax and display the results to the screen. You can also update, insert and delete records again using SQL like syntax. To show the query above using the Synergy DBMS Manager;

SDBMS1

The fields within the query can be typed in longhand or selected from the field list (retrieved dynamically from the DO). When the query is executed, the results grid is dynamically built to include only those fields selected.

As mentioned you can also modify the data in the file using an UPDATE command and you can insert new records using an INSERT command. To complete the capabilities you can also delete records using the DELETE command, but make sure you use a where clause or the whole file will be cleared.

The Synergy DBMS Manager application can be downloaded from SymphonyFramework.Net. You can also access full documentation on the same page or here. You will need a minimum of Synergy 10.3.1 runtime environment to run the Synergy DBMS Manager program. You will also need to create and build a library of Synergy Data Objects that represent your repository structure. This library is totally code-generated and full instructions are included in the documentation.

If you would like to take a look at the Synergy DBMS Manager but don’t have the time to build your library of data objects upload your repository files (zipped please) at: SymphonyFramework.Net and we’ll build it for you!

Why not take a quick look at the documentation to see how easy it is to use the Synergy DBMS Manager?

 


CodeGen 5.1.4 Released

By Steve Ives, Posted on July 29, 2016 at 10:42 am

We are pleased to announce that we have just released CodeGen V5.1.4. The main change in this version is an alteration to the way that CodeGen maps Synergy time fields, i.e. TM4 (HHMM) and TM6 (HHMMSS) fields, to corresponding SQL data types via the <FIELD_SQLTYPE> field loop expansion token. Previously these fields would be mapped to DECIMAL(4) and DECIMAL(6) fields, resulting in time fields being exposed as simple integer values in an underlying database. With this change it is now possible to correctly export time data to relational databases.

We also made a small change to the CodeGen installation so that the changes that it makes to the system PATH environment variable occur immediately after the installation completes, meaning that it is no longer necessary to reboot the system after installing CodeGen on a system for the first time.

This version of CodeGen is built with Synergy/DE 10.3.3a and requires a minimum Synergy runtime version of 10.1.1.


Replicating Data to SQL Server – Made Easy

By Steve Ives, Posted on July 28, 2016 at 5:29 pm

For some time now we have published various examples of how to replicate ISAM data to a relational database such as SQL Server in near to real time. Until now however, all of these examples have required that the ISAM files that were to be replicated needed be modified by the addition of a new “replication key” field and the addition of a corresponding key in the file. Generally this new field and key would be populated with a timestamp value that was unique to each record in the file. While this technique guarantees that every ISAM file can be replicated, it also made it hard work to do so because the record layout and key configuration of each ISAM file needed to be changed.

However, almost all ISAM files already have at least one unique key, and when that is the case one of those existing those keys could be used to achieve replication without requiring changes to the original record layouts or files. When this technique is combined with the capabilities of I/O hooks it is now possible to achieve data replication with only minimal effort, often with no changes to the ISAM files being replicated, and with only minimal modification of the original application code.

I am pleased to announce that I have just published a new example of doing exactly that. You can find the example code on GitHub at https://github.com/SteveIves/SqlReplicationIoHooks. Of course if you are interested in implementing data replication to a relational database but need some assistance in doing so, then we’re here to help; just contact your Synergex account manager for further information.


Symphony Framework Update 3.2.6 – File Management Capabilities

By Richard Morris, Posted on July 22, 2016 at 6:24 am

As I wrote about in my last blog the Symphony Harmony namespace provides the ability to execute select queries and stored procedure style method execution using SQL style syntax. The queries and procedures can be executed in-process or via the Symphony Bridge on a remote server via industry standard HTTP/HTTPS/TCP protocols as well as via a Service Bus Relay protocol. In the 3.2.6 release we have added the ability to fully manage the data in the SDBMS files via SQL this style syntax.

Accessing or selecting data through the Symphony Harmony namespace is simple. First you need to define your “connection” to the database. To do this you create an instance of the DBConnector class. For example;

data connector = new DBConnector(“SymLocal:user/password!SimpleHarmonyTestLibrary.TableMapper.MapTableToFile”)

The connection string defines how you want to access the data: SymLocal indicates that it’s in-process and specifying SymRemote indicates it’s via Symphony Bridge. If you are using Symphony Bridge you must include the “server” you wish to connect to – I’ll include an example shortly. The username and password allow you to provide authentication but that’s for another blog. The “SimpleHarmonyTestLibrary.TableMapper.MapTableToFile” is the named method that Symphony Harmony uses to translate the table name to a physical SDBMS filename, and it’s something you can code generate.

Here is an example of a remote access connection;

data connector = new DBConnector(“SymRemote:user/password@localhost:8081!SimpleHarmonyTestLibrary.TableMapper.MapTableToFile”)

Notice the server name and the port the Symphony Bridge server is listening on. Other than the connection string the usage of Symphony Harmony is identical regardless if it’s local or remote data access. Although here we are talking about local and remote data access – we are referring to where the code to perform the query is being executed, either locally in-process or via Symphony Bridge. We are not referring to the physical location of the SDBMS data files which may be local or remote and accessed via xfServer. Both local (in-process) and remote connections via Symphony Bridge can access data locally or via xfServer.

To select records from a file you use the SQL style SELECT syntax and call the DataSelect.RunDataSelect method. You need to instance the Symphony Data Object that will define the response data structure. For example;

data partItem = new Part_Data()

foreach partItem in DataSelect.RunDataSelect(connector, “SELECT * FROM part”, partItem).Result

begin

                Console.WriteLine(“Created ID = ” + partItem.Id + “, ” + partItem.Description + ” Qty = ” + %string(partItem.Quantity) + ” Cost = ” + %string(partItem.Cost_price))

end

Note here that the case of the command is not important however the case of string values within a where clause is. You can limit the fields returned, filter the data and order the results as you require. All of these are valid;

DataSelect.RunDataSelect(connector, “SELECT id, description, quantity FROM part WHERE quantity > 10”, partItem).Result

DataSelect.RunDataSelect(connector, “SELECT description, id FROM part WHERE description like ‘BRAKE’”, partItem).Result

DataSelect.RunDataSelect(connector, “SELECT cost_price, id, description FROM part WHERE cost_price < 1.99 ORDER BY cost_price “, partItem).Result

The order of the fields list is not important. You also don’t have to hard-wire the filter values as you can pass positional arguments. For example;

Data qtyValue   ,int         ,10

DataSelect.RunDataSelect(connector, “SELECT id, quantity, description FROM part WHERE quantity > :1”, partItem, qtyValue).Result

data descValue ,string   ,”BRAKE”

DataSelect.RunDataSelect(connector, “SELECT id, description FROM part WHERE description like :1″, partItem, descValue).Result

Data qtyValue   ,int                         ,10

Data costValue  ,decimal               ,1.99

DataSelect.RunDataSelect(connector, “SELECT id, description, cost_price FROM part WHERE cost_price < :1 AND quantity > :2 ORDER BY cost_price “, partItem, costValue, qtyValue).Result

All of the above will return a collection of data objects of type Part_Data().

As I mentioned above you can now maintain the data in your SDBMS files through Symphony Harmony. We have added the ability to insert data into an SDBMS file using Symphony Harmony. The DataInsert.RunDataInsert() method accepts an INSERT command and a data object and stores the passed-in data object data to the appropriate file. For example;

data partItem = new Part_Data()

partItem.Id = “ID1”

partItem.Description = “this is the description for part 1”

partItem.Technical_info = “lots of additional information for part 1”

partItem.Quantity = 5

partItem.Cost_price = 12.34

DataInsert.RunDataInsert(connector, “INSERT INTO part”, partItem).Wait()

The data in the partItem data object is extracted, placed into a Synergy record and stored into the SDBMS file. Any errors, like duplicate key, will be thrown on the client.

We have also added the ability to update the data in an SDBMS file using Symphony Harmony. The DataUpdate.RunDataUpdate() method accepts an UPDATE command, which should include a WHERE clause, and a data object, and updates the file with the passed data object data. You can optionally pass a list of fields that restrict the data to be updated. So for example if you application wants to simply update a field for a given record;

data numUpdated          ,long

partItem.Cost_price = 999.99

numUpdated = DataUpdate.RunDataUpdate(connector, “UPDATE part SET cost_price where QUANTITY = 13”, partItem).Result

Will update ALL records that have a quantity value of 13 with the updated cost_price value of 999.99. The resulting numUpdated field will contain the number of records that were updated in the file.

The field list is optional, but it’s recommended! If you don’t specify the field list then the whole record is updated, so you must ensure that the data object contains all the required information otherwise you may get exceptions if key values that are defined none-modifiable are changed. You may also inadvertently overwrite changes made by other processes.

And to provide the fully SDBMS data management capabilities we have added the ability to delete data from an SDBMS file using Symphony Harmony. The DataDelete.RunDataDelete() method accepts a DELETE command, which should include a WHERE clause, and a data object and deletes the matching records from the file.

data numDeleted            ,long

numDeleted = DataDelete.RunDataDelete(connector, “DELETE FROM part WHERE id = :1”, partItem, “ID1”).Result

Removes the required records from the file. There is no need to first select or lock them. The numDeleted field will contain the number of records that were deleted from the file. The where clause is optional so the following is valid;

numDeleted = DataDelete.RunDataDelete(connector, “DELETE FROM part”, partItem).Result

And will result in clearing the entire file – you have been warned!!

All this capability is now available in version 3.2.6 of the Symphony Framework, Symphony Harmony and Symphony Harmony Unplugged packages on Nuget.


Merging Data and Forms with the PSG PDF API

By Steve Ives, Posted on July 6, 2016 at 9:53 pm

When I introduced the PSG PDF API during the recent DevPartner Conference in Washington DC I received several questions about whether it was possible to define the layout of something like a standard form using one PDF file, and then simply merge in data in order to create another PDF file. I also received some suggestions about how this might be done, and I am pleased to report that one of those suggestions panned out into a workable solution, at least on the Windows platform.

The solution involves the use of a third-party product named PDFtk Pro. The bad news is that this one isn’t open source and neither is it free. But the good news is it only costs US$ 3.99, which I figured wouldn’t be a problem if you need the functionality that it provides.

Once you have PDFtk Pro installed and in your PATH you can then call the new SetBackgroundFile method on your PdfFile object, specifying the name of the existing PDF file to use as the page background for the pages in the PDF file that you are currently creating. All that actually happens is when you subsequently save your PDF file, by calling one of the Print, Preview or Save methods, the code executes a PDFtk Pro command that merges your PDF file with the background file that you specified earlier. Here’s an example of what the code looks like:

;;Create an instance of the PdfFile class
pdf = new PdfFile()

;;Name the other PDF file that defines page background content
if (!pdf.SetBackgroundFile(“FORMS:DeliveryTicketForm.pdf”,errorMessage)
    throw new Exception(errorMessage)

;;Other code to define the content of the PDF file

 

;;Show the results
pdf.Preview()

There are several possible benefits of using this approach, not least of which is the potential for a significant reduction in processing overhead when creating complex forms. Another tangible benefit will be the ability to create background forms and other documents using any Windows application that can create print output; Microsoft Word or Excel for example. Remember that in Windows 10 Microsoft has included the “Print to PDF” option, so now any Windows application that can create print output can be used to create PDF background documents.

I have re-worked the existing Delivery Ticket example that is distributed with the PDF API so that it first creates a “form” in one PDF file, then creates a second PDF file containing an actual delivery ticket with data, using the form created earlier as a page background.

I have just checked the code changes into the GitHub repository so this new feature is available for use right away, and I am looking forward to receiving any feedback that you may have. I will of course continue to research possible ways of doing this on the other platforms (Unix, Linux and OpenVMS) but for now at least we have a solution for the Windows platform that most of us are using.


Symphony takes a REST

By Richard Morris, Posted on at 3:08 am

The Symphony Harmony namespace allows access to data and logic through an SQL like syntax. For example you can select records from a file using a query such as “SELECT ID, DESCRIPTION FROM PART WHERE QUANTITY > 12 ORDER BY QUANTITY”. All matching records are returned from the query in the form of Symphony Data Objects. The data can be local or accessed via Synergy xfServer. The Symphony Bridge utility allows you to expose your query-able database via a standard Windows Communication Foundation (WCF) web service. So far so good.

Steve Ives and I recently had the opportunity to spend a week working together in the UK to “bang” heads together. Steve has always been an exponent of providing RESTful services to access logic and data which can be consumed by just about anything. So we set about using CodeGen to build a standard Restful service that will utilize the Symphony Framework to enable dynamic access to data and ultimately logic.

We soon had the basic service up and running. Out first implementation handled the standard GET verb – and returned all the records in the file. No filtering, no selection, just all the records retuned as a JSON collection. This is the standard API;

rest_1

Now remember that Symphony Harmony allows you to filter the data you are requesting, so we next implemented the ability to provide the “where” clause to the query. So for example;

rest_2

And using ARC (Advanced Rest Client which is a Google Chrome plug-in) we can test and query the service;

rest_3

And we get back just the selected customer details – all those customers where CUSTST has value of CA.

As well as being able to filter the data we can also limit the results returned by Harmony to just the fields we need; this has the benefit of reducing the data being brought across the wire. But how can our REST server build the required data objects to just include the fields we select? By doing runtime code generation! Within our code generated data objects we added the ability to dynamically build the response data object to only include those fields requested by the client. The calling syntax, as provided by the API, is;

rest_4

And again using ARC to test our server we can issue a command like;

rest_5

This is requesting all records from CUSMAS where the CUSNM2 field contains the word “LAWN” and limiting the response data object to just three fields. The response JSON looks like;

rest_6

Two perfectly formed data object that are limited by the fields in the selection list. If your Symphony Harmony connection to your data is via xfServer then only those selected fields will have been loaded from the file, again improving performance.

We also added the ability to limit the amount of data retuned by adding a “maxrows” option;

rest_7

We have already added the ability to the Symphony Harmony namespace to perform inserts, updates and deletes using standard SQL syntax and we’ll be adding these capabilities to the appropriate rest verbs POST, PUT and DELETE. Watch this blog feed for more information.


Page 1 of 1212345...10...Last »
RSS

Subscribe to the RSS Feed!

Recent Posts Categories Tag Cloud Archives