Question Accessing .net-array From Abl

Hi everybody

OE11.3 - Win8

I'm trying to read a property in a .NET-class and I'm not able to translate the C#-syntax to ABL-code.
I'm totally new to this kind of programming, so I would appreciate any code-example.

the class is called "DocuWare.Platform.ServerClient.ServiceConnection" and the property i want to read is "Organizations".

from the DocuWare-documentation:
ServiceConnection.Organizations Property - Gets the organizations.

C# - public Organization[] Organizations { get; }


the C#-example i have is:
this.connector = ServiceConnection.Create(new System.Uri(String.Format(urlFormatString, serverUrl)),
userName: userName,
password: userPassword,
organization: organizationName);

this.org = this.connector.Organizations[0];

my ABL-Code:

I have managed to translate the first statement and already get a connection:

DEF VAR sConn AS DocuWare.Platform.ServerClient.ServiceConnection.
sConn = ServiceConnection:Create (URI, "username", "pswd", "orgname").

but I dont know how to translate the second statement, to get the organisations:

this.org = this.connector.Organizations[0];

I also don't understand at all the documantation-line:
C# - public Organization[] Organizations { get; }
 

RealHeavyDude

Well-Known Member
Ymight want to have a look here ( OE 11.6 ):
OpenEdge 11.6 Documentation

There are also links on examples.

"this.org" must be an ABL variable defined as an Organization class.
Does the Connector object provide a method to get the Organization Array?
If yes, then you can use the System.Array as intermediate to take the output of the get method and then you can cast the individual objects in the array to an Organization object.

Coded in FireFox IDE:
Code:
define variable connector as class DocuWare.Platform.ServerClient.ServiceConnection  no-undo.
define variable oranizationArray  as class System.Array  no-undo.
define variable organization  as class DocuWare.????
define variable orgNumber  as integer   no-undo.

assing connector = ServiceConnection:Create (URI, "username", "pswd", "orgname").
assign oranizationArray = connector:GetOrganizations ( ) ????
do orgNumber = 1 to oranizationArray:Length:
  assign organization = cast ( oranizationArray:GetValue (orgNumber - 1 ), DocuWare.???? ). /* .Net starts with zero */
end.
Hope that helps, RealHeavyDude.
 

Osborne

Active Member
For help in the future regarding C# lines such as public Organization[] Organizations { get; }. This would translate into ABL something like this:
Code:
DEFINE PUBLIC PROPERTY Organization AS CLASS "DocuWare.Platform.ServerClient.ServiceConnection.Organizations[]" NO-UNDO GET.
If not using a class it would be:
Code:
DEFINE VARIABLE Organization AS CLASS "DocuWare.Platform.ServerClient.ServiceConnection.Organizations[]" NO-UNDO.
 
sorry guys to bother you again, but i'm stuck again. How would the following class be implemented in ABL ?


public IEnumerable<FileCabinet> GetAllFileCabinetsUserHasAccessTo()
{
return (from fileCabinet in this.org.GetFileCabinetsFromFilecabinetsRelation().FileCabinet
where fileCabinet.IsBasket == false
select fileCabinet);
}
 

Osborne

Active Member
I presume FileCabinet is part of the DocuWare .NET classes of which I know nothing about. It seems you have to read the values and return the value of the one that is false - fileCabinet:IsBasket = FALSE.

A very loose pseudo translation which although not correct will hopefully point you in the right direction:
Code:
FUNCTION GetAllFileCabinetsUserHasAccessTo RETURNS System.Collections.IEnumerable ():
   DEFINE VARIABLE vIEnumerable AS System.Collections.IEnumerable NO-UNDO.

   vIEnumerable = CAST(FileCabinet ???, System.Collections.IEnumerable):GetEnumerator().
   DO WHILE vIEnumerable:MoveNext():
      IF value false THEN RETURN vIEnumerable.
   END.
END FUNCTION.
 

RealHeavyDude

Well-Known Member
Just my 0.0001 Cent:

When using .Net objects in the ABL I prefer to use ABL classes instead of procedures:
  • For one I don't like having my mind to constantly switch between procedural and OO
  • Secondly, if you really want to use .Net classes you are in the OO world and you need OO thinking to be able to use them successfully. Therefore practicing OO in the ABL will help you in C# ( or Java ) and vice versa.
Therefore I would recommend you to use ABL classes or start using them if you are not already.

Nevertheless, depending on your version of OpenEdge, the support of types like collections and enumerations is either lacking in the ABL or not usable in the same way as you would use them in say Java or C#. Whenever you are dealing with collections and enumerations you need to stay in the .Net world until you have a single object that you can use in the ABL ( See above example with System.Array - the single organization object ).

Heavy Regards, RealHeavyDude.
 
Top