Determining output parameter to entity integration

Determining output parameter to entity integration

  

Hi;


First of all, I'm using Personal Envirement.

I want to get data from MySQL server with .Net entegration. I connected my server and right now I can get some list in that data. But I want to determin my outputs to Entities. 

As you can see from the screenshots that I attached; I want to determine my "Ticket_No_A" output parameter to "Ticket_No_B" entity. But I can't do it successfully.

Thanks in advance.


Best Regards.


Hello Hasan,

A few questions.

I am not sure of what are you trying to accomplish and what is the problem...

1. Why you are not using the usual path that is import the tables from the database using the database connection defined in the Service Center? Did you tried and was not being able to do? What was the problem?

2. As far as I know, you can't "populate" an entity (if is that what you are trying to do), created in an extension, from an action. This entity would not work the same way, because both aggregates and queries will execute the query in the database, that in this case, you would prevent this from happen.

If the entities are being imported from the database and you want to expose as output from an action a list of a structure, where one of the fields is an Identifier for the entity imported, while I didn't this before, I think it should be possible without problems...

So, could you clarify (in different words) what are you trying to achieve?

Cheers,
Eduardo Jauch

Eduardo Jauch wrote:

Hello Hasan,

A few questions.

I am not sure of what are you trying to accomplish and what is the problem...

1. Why you are not using the usual path that is import the tables from the database using the database connection defined in the Service Center? Did you tried and was not being able to do? What was the problem?

2. As far as I know, you can't "populate" an entity (if is that what you are trying to do), created in an extension, from an action. This entity would not work the same way, because both aggregates and queries will execute the query in the database, that in this case, you would prevent this from happen.

If the entities are being imported from the database and you want to expose as output from an action a list of a structure, where one of the fields is an Identifier for the entity imported, while I didn't this before, I think it should be possible without problems...

So, could you clarify (in different words) what are you trying to achieve?

Cheers,
Eduardo Jauch

Hi Eduardo;


1. I want to do a MySQL connection wizard after that transfer data to my 'report' app. Not one time import data. 

2. When I get my extension (with manage dependencies) to Service Studio, I can see these entities, on "Data" under "Entities - Database - ..".  

    So that, if I get these entities easily that I can see, I thought that I could use it any screen. 

Even if my approach is nonsense, how can I use these entities (at Service Studio), from any report screen? 

My other solution that I though, transfer these data with JSON but it will be challenging than the other I guess.


I hope, I clarified my purpose :)


Thanks & Regards,





Hello Hasan,

Here is a tutorial on how to do what you want.

https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/Connect_to_an_External_Database

You just need to import the entities to your extension and use them in yout app. The extension will be like an "interface" to your tables in the external database, and you will be able to use them in your application as if they were outsystems entity, in aggregates, creating, updating and deleting records, etc.

Hope this will clarify how to easily use external databases in OutSystems.

Cheers,
Eduardo Jauch

Hi Eduardo;


I see that way to connect data before, but this is not what I want. I am not looking for one time data import so, I said that "I want to do a MySQL connection wizard after that transfer data to my 'report' app. Not one time import data".

The connection string should be dinamic. Becasue of that I have to use .Net (or JavaScript). 

I want to record all data access informations to a table in app. Then, I want to connect data and get select query results with these data connection informations. 

And then I want to insert/update the result to a table (local table).  Eventually I can show the selected informations at any screen on app.


Thanks & Regards,

Hasan,

This is NOT a "one time import".

When you "import" tables from external database, what you are doing is creating an INTERFACE to the external database. If some external app updates tables you imported, you will be able to see the new data in your OutSystems App when executing a Query.

Regarding "dynamic" connection string this is another subject.
You can, in runtime, change the connection string to connect to a different database, IF the database has the same scheme: https://www.outsystems.com/help/servicestudio/9.0/APIs/PlatformRuntime_API/PlatformRuntime_API.htm

Take a look at this topic: https://www.outsystems.com/forums/discussion/15993/servicecenter-database-connection-programmatically-switch-database-connection/

If you can't use this, I think the only other options is to use WebServices to reach the data in the external database, or create an extension the way you were doing, but returning data through the output parameters (probably a list of records) of your extension actions.

Cheers,
Eduardo Jauch 

Hi Eduardo,


Ok. My choice is ".Net integration". 

Could you say me, is there any way to use (assigning a value ) "Entities" which I shared the ss from visual studio? Or how can we use these Entities? Are these Entities just visual? 

Could you share with me any .Net integration example video?  


Thanks a lot.



I don't have any link to how to that. And I never did this before.

But here is a "working example", without the connection to database (that you are already doing). Just the interface, and using a structure (not an Entity).

And here a very rough implementation.

public class CssIntegrationTestExt: IssIntegrationTestExt {

    /// <summary>
    /// 
    /// </summary>
    /// <param name="ssParameter1"></param>
    public void MssGetData(out RLMyDataRecordList ssParameter1) {
	ssParameter1 = new RLMyDataRecordList();
        //Get your data here

        //Than fill the list

        var r1 = new RCMyDataRecord();
        r1.ssSTMyData.ssId = 1;
        r1.ssSTMyData.ssAge = 35;
        r1.ssSTMyData.ssName = "João";

        ssParameter1.Add(r1);

        var r2 = new RCMyDataRecord();
        r2.ssSTMyData.ssId = 2;
        r2.ssSTMyData.ssAge = 40;
        r2.ssSTMyData.ssName = "Maria";

        ssParameter1.Add(r2);

        // TODO: Write implementation for action
    } // MssGetData
} // CssIntegrationTestExt

And here I am using the action in the preparation of a page to fetch the data to to show the data in a table records:

You can see the page here: https://eduardojauch.outsystemscloud.com/IntegrationTest/Home.aspx?_ts=636508455590348633

But I'll advise AGAINST doing it.

You will have performance issues unless you use connection pools and will include a layer of complexity in your application that is probably not necessary. In the long run, this will end in bad results, with an application that do not escale well with performance problems and a nightmare to maintain...

Cheers,
Eduardo Jauch

Actually I have a one question:

When I did this app and puplished it, then somebody download the app from store, how can he/she configure the app with his/her database?

Is it possible without environment management console configure? how can he/she create an account to enter it?

Actually I have a one question:

When I did this app and puplished it, then somebody download the app from store, how can he/she configure the app with his/her database?

Well, this is a matter for you to decide. If you are doing the connection inside the extension when fetching data, I assume that you will pass any relevant information to make the connection through input parameters in the action. 

Is it possible without environment management console configure? how can he/she create an account to enter it?

This I don't figured what you're talking about.
What do you mean about "account"?

The way your app is used depend on how you define it. If you are doing an application to be used "anonimously", where any user can reach it, you will not do any kind of authentication.

If you want to create users, you will have to provide a way to register users (by some users that can do it), or through some kind of self registering mechanism. 

Just remember that the number of authenticate users is limited depending on your license (100 for a Personal environment), and the number of active users that can access your application in total, will depend on your infrastructure.

This means that an app that make use of external databases will relay heavely on the server, creating a performance problem depending on your infrastructure. 

Can I ask what type of app is that you are doing that enables the user to use its own "external" database?

Cheers,
Eduardo Jauch


I will give a little more detail about the application I'm trying to do

I am trying to make an application that will allow a report to be pulled from a commonly used label application. So I will do a tag reporting application.
People who use the tag application use their own databases, and their databases are on their own servers.

In order to be able to report the information entered by the application, I should not make them a magician who can provide access to their databases. Because each user will have different database information to connect to. To do this, I do a "connection string" on ".net" and pulling the relevant "input parameters" from the fields I have in app.
That is, the users enter the connection information they have entered in the application I'm trying to make through the application, and I'll get that information and connect them to their database via ".net".
I want to extract the results of the queries in the templates I have specified from their data and show them on the application.
So I will show them the information they have in the label system.

In summary, everyone has their own tag system and external data that they follow their tag systems. The common notes will be the app. I'm trying to make.


I hope it has become clearer :)






Yes, it is clear.

Just a question. The database of the user, will have the same structure, tables, fields, etc?

If not, how do you pretend to  deal with this issue?

You probably will want to store the connection string information server side, in a table associated with the user/company/whatever. An extension. 

Beware with this, because storing personal information is becoming a problem, lately (ethical and legal reasons).

But as the app will need to be online to work, it is safer.

This will require users registered in the system, so they can login and use their own connection.

The rest of my previous observations remain.

Cheers, 

Eduardo Jauch

Eduardo Jauch wrote:

Just a question. The database of the user, will have the same structure, tables, fields, etc?

If not, how do you pretend to  deal with this issue?

You probably will want to store the connection string information server side, in a table associated with the user/company/whatever. An extension. 

Beware with this, because storing personal information is becoming a problem, lately (ethical and legal reasons).


For this reason, I would like to do this by using the database login information, which is stored in the users' "local storage" database login information.So users download the application, enter the database information and they will press the "connect" button. During this time, the connection information they entered will be registered in the local database. I will also do the locally stored login information via ".net" (with connection string).  Then I'll get the select result and show it on any screen from the application.


Actually, I did this.

So e new user can download the program from scratch, enter the database informatin, pull the information from his own label system and list it in the application.

But for now, only 1 column can be brought.

In order to more, I thought I could use the data fields under the heading "Entities" on the "Visual Studio" screen quickly.


So I could do it if "Integration Studio" could enable me to use the date entered in the "Entitites" field according to the values entered in the code ( with .Net).


Orherwise, and as far as I understand it, I'll have to first convert it to JSON and deserialize it in "Service Studio" again.



hasan karagoz wrote:

For this reason, I would like to do this by using the database login information, which is stored in the users' "local storage" database login information.So users download the application, enter the database information and they will press the "connect" button. During this time, the connection information they entered will be registered in the local database. I will also do the locally stored login information via ".net" (with connection string).  Then I'll get the select result and show it on any screen from the application.

Here there is a wrong assumption: "I will also do the locally stored login information via ".net" (with connection string)".

See, the extension do not run "locally" in the device. It will run in the server. So, lets say you have 50 users connected at the same time, all of them fetching data at the same time. 

Every time a user tries to fetch data, you will have to execute the action in your extension (that will be executed in the server, not in the device), that will have to connect to the user external database, get data, and return data to the device. 

Also, storing login information in the device is a very dangerous, as the user can lost his device or had it stolen. It is always more safe to store in the server.

Actually, I did this.

So e new user can download the program from scratch, enter the database informatin, pull the information from his own label system and list it in the application.

But for now, only 1 column can be brought.

In order to more, I thought I could use the data fields under the heading "Entities" on the "Visual Studio" screen quickly.


So I could do it if "Integration Studio" could enable me to use the date entered in the "Entitites" field according to the values entered in the code ( with .Net).


Orherwise, and as far as I understand it, I'll have to first convert it to JSON and deserialize it in "Service Studio" again.

Here I am probably letting something slip away, because what you are saying does not amke sense to me.

When you "import" tables from an external database, using the wizard in an extension, the system automatically create the entities for you and you are able to query those entities in your OutSystems code, because the system knows to where send que queries.

You can do this once, for a database, and later change the connection string, but the database tables names and structure MUST be the same on ALL the external databases you want to connect.

If this is the case, why bother doing any .net code? Just use the enities and do the queries

If each of your uses have a DIFFERENT database, with different tables, different table names or different fields, this will not work. And you will have to import the tables for EACH of the users database, and prepare the code for each one of them.

In this case, even if your code can cope with this, and find the correct tables and fields, you will still have to normalize the information to send it back to the OutSystems app.

As you will be creating a LIST (like in the example I gave before), it is better to use a structure, not an entity, because this list is just a list, it is not information in the database, and trying to do SQL queries on it (if you use the entities, that you would have to create manually), would cause runtime errors. Conceptually does not make sense to your data be of type "entity record" anymore.

But you don't need to do any JSON, as the method I procided will return a list that can be used directly, without requiring serialization and deserialization.

But in any case, you will still have severe performance issues.

Eduardo Jauch wrote:

hasan karagoz wrote:

For this reason, I would like to do this by using the database login information, which is stored in the users' "local storage" database login information.So users download the application, enter the database information and they will press the "connect" button. During this time, the connection information they entered will be registered in the local database. I will also do the locally stored login information via ".net" (with connection string).  Then I'll get the select result and show it on any screen from the application.

Here there is a wrong assumption: "I will also do the locally stored login information via ".net" (with connection string)".

See, the extension do not run "locally" in the device. It will run in the server. So, lets say you have 50 users connected at the same time, all of them fetching data at the same time. 

Every time a user tries to fetch data, you will have to execute the action in your extension (that will be executed in the server, not in the device), that will have to connect to the user external database, get data, and return data to the device. 

Also, storing login information in the device is a very dangerous, as the user can lost his device or had it stolen. It is always more safe to store in the server.

Actually, I did this.

So e new user can download the program from scratch, enter the database informatin, pull the information from his own label system and list it in the application.

But for now, only 1 column can be brought.

In order to more, I thought I could use the data fields under the heading "Entities" on the "Visual Studio" screen quickly.


So I could do it if "Integration Studio" could enable me to use the date entered in the "Entitites" field according to the values entered in the code ( with .Net).


Orherwise, and as far as I understand it, I'll have to first convert it to JSON and deserialize it in "Service Studio" again.

Here I am probably letting something slip away, because what you are saying does not amke sense to me.

When you "import" tables from an external database, using the wizard in an extension, the system automatically create the entities for you and you are able to query those entities in your OutSystems code, because the system knows to where send que queries.

You can do this once, for a database, and later change the connection string, but the database tables names and structure MUST be the same on ALL the external databases you want to connect.

If this is the case, why bother doing any .net code? Just use the enities and do the queries

If each of your uses have a DIFFERENT database, with different tables, different table names or different fields, this will not work. And you will have to import the tables for EACH of the users database, and prepare the code for each one of them.

In this case, even if your code can cope with this, and find the correct tables and fields, you will still have to normalize the information to send it back to the OutSystems app.

As you will be creating a LIST (like in the example I gave before), it is better to use a structure, not an entity, because this list is just a list, it is not information in the database, and trying to do SQL queries on it (if you use the entities, that you would have to create manually), would cause runtime errors. Conceptually does not make sense to your data be of type "entity record" anymore.

But you don't need to do any JSON, as the method I procided will return a list that can be used directly, without requiring serialization and deserialization.

But in any case, you will still have severe performance issues.


"I will also do the locally stored login information via" .net "(with connection string)". I wanted to say that I will use the information I received from local.
I'm talking about local data being run on the server via .Net.


That is to say, in order:

1- the user registers MYSQL login information in the application.

2- the entered information is recorded on the user's machine. 

3- when the user requests the connection, the local database information is taken and executed on the server via .net

4- the returned result is displayed on the user's report screen.


On the other hand, the user will enter the user and password information for entering the program on his machine. Therefore, even if the machine is stolen, the application will not be able to launch without the input information of the reporting application. 

Also, although the program is logged in, the connection information will not be displayed.