Question OE .NET

gasomma

Member
Hi to all,

Could you pls suggest me which is better way for to use .NET with OE 11.7?
Follow the code that I need to run in OE.
Many thanks.
A.

Sample code enhanced with error and exception handling:

// Step #1: Create Connection object
oneSage.SDK.RD.Access.Connection lConnection =
new oneSage.SDK.RD.Access.Connection("SageStart",
@"@user=;@password=;" +
"@path=!Srv!Standard:myServerName/" +
"C:/Sage Data/Folders/Meine Firma/SageStart/Meine Firma.SgWwr",
"SageStart");
oneSage.SDK.RD.Validating.InfoList lInfoList = new oneSage.SDK.RD.Validating.InfoList();

if (lConnection.DoValidate((oneSage.SDK.RD.Validating.Interface.IInfoList)lInfoList) == true) {
try {
// Step #2: Create Adapter object
oneSage.SDK.RD.Access.Adapter lAdapter = new oneSage.SDK.RD.Access.Adapter(lConnection);

// Step #3: Create data set, tables, rows for data operations
// Create new and empty Sage Start data set
oneSage.SDK.RD.Data.SageStart lDataSet = new oneSage.SDK.RD.Data.SageStart();
oneSage.SDK.RD.Data.SageStart.AccountDataTable lTbl = lDataSet.Account;
oneSage.SDK.RD.Data.SageStart.AccountRow lRow = lTbl.NewAccountRow();

lRow.AccCode = "9999";
lRow.DescDe = lRow.DescFr = lRow.DescEn = lRow.DescIt = "My new account";
lTbl.AddAccountRow(lRow);

// Step #4: Execute SDK operation (Insert) and write all rows the database
lAdapter.Execute(oneSage.SDK.RD.Access.Operation.Insert, lDataSet, lTblName, lInfoList);
} catch (SystemException lExp) {
// Catch any exception thrown by the .NET data set (e.g. Primary Key, AllowDBNull, ReadOnly)
// Show error by re-using SDK's InfoList
lInfoList.Add(new oneSage.SDK.RD.Validating.Info(oneSage.SDK.RD.Validating.InfoTypes.Error,
DateTime.Now,
lExp.Message,
"MyApplication",
"Manipulating data set"));
}

// Show error messages if any
System.Text.StringBuilder lMessageBuilder = new StringBuilder();
foreach (oneSage.SDK.RD.Validating.Info lInfo in lInfoList) {
if ((int)lInfo.InfoType < (int)oneSage.SDK.RD.Validating.InfoTypes.CriticalError) {
lMessageBuilder.Append(lInfo.InfoType + " (" + lInfo.DateTime + "): " + lInfo.Method + "/"
lInfo.Message + "\r\n");
}
}

if (!string.IsNullOrEmpty(lMessageBuilder.ToString()))
MessageBox.Show(lMessageBuilder.ToString(), "Info List", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
 

Osborne

Active Member
I do not know what oneSage is but I presume it is a .NET component. If so, you first need to ensure it is added to assemblies.xml.

The following is a very rough translation of what the OpenEdge code could be. Bear in mind it is a very rough translation and parts of it may be totally incorrect as without the component I am purely guessing. Hopefully though it will at least point you in the right direction.
Code:
DEFINE VARIABLE lConnection AS oneSage.SDK.RD.Access.Connection NO-UNDO.
DEFINE VARIABLE lInfoList AS oneSage.SDK.RD.Validating.InfoList NO-UNDO.

lConnection = NEW oneSage.SDK.RD.Access.Connection("SageStart", ("@user=;@password=;" + ("@path=!Srv!Standard:myServerName/" + "C:/Sage Data/Folders/Meine Firma/SageStart/Meine Firma.SgWwr")), "SageStart").
lInfoList = NEW oneSage.SDK.RD.Validating.InfoList().

IF (lConnection:DoValidate(System.Convert:ChangeType(lInfoList,oneSage.SDK.RD.Validating.Interface.IInfoList)) = TRUE) THEN DO:
   DEFINE VARIABLE lAdapter AS oneSage.SDK.RD.Access.Adapter NO-UNDO.
   DEFINE VARIABLE lDataSet AS oneSage.SDK.RD.Data.SageStart NO-UNDO.
   DEFINE VARIABLE lTbl AS oneSage.SDK.RD.Data.SageStart.AccountDataTable NO-UNDO.
   DEFINE VARIABLE lRow AS oneSage.SDK.RD.Data.SageStart.AccountRow NO-UNDO.
   lAdapter = NEW oneSage.SDK.RD.Access.Adapter(lConnection).
   lDataSet = NEW oneSage.SDK.RD.Data.SageStart().
   lTbl = lDataSet:Account.
   lRow = lTbl:NewAccountRow.
   lRow:AccCode = "9999".
   lRow:DescIt = "My new account".
   lRow:DescEn = "My new account".
   lRow:DescFr = "My new account".
   lRow:DescDe = "My new account".
   lTbl:AddAccountRow(lRow).
   lAdapter:Execute(oneSage.SDK.RD.Access.Operation.Insert, lDataSet, lTblName, lInfoList).

   CATCH lExp AS System.Exception:
      lInfoList:Add(NEW oneSage.SDK.RD.Validating.Info(oneSage.SDK.RD.Validating.InfoTypes.Error, NOW, lExp:Message, "MyApplication", "Manipulating data set")).
   END CATCH.

   DEFINE VARIABLE lMessageBuilder AS System.Text.StringBuilder NO-UNDO.
   lMessageBuilder = NEW System.Text.StringBuilder().
   DEFINE VARIABLE lInfo AS oneSage.SDK.RD.Validating.Info NO-UNDO.
   DEFINE VARIABLE vCount AS INTEGER NO-UNDO.
   DEFINE VARIABLE vI AS INTEGER NO-UNDO.
   vCount = lInfoList:Count.
   DO vI = 0 TO vCount:
      lInfo = lInfoList:Item[vI].
      ...
   END.

   IF NOT System.String:IsNullOrEmpty(lMessageBuilder:ToString()) THEN
      MESSAGE lMessageBuilder:ToString() VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
END.
Also have a look at consultingwerk/ListsAndEnumSamples which contains some useful bits.
 

gasomma

Member
HI Osborne,
thanks for your email. As to honest I have no idea what I have to do in this case. I have to connect OE with a SAGE 50/STart software. They have developed onesage SDK (I enclosed the guide). If you can help/suggest me somethink I will appreciate. Many thanks. A.
 

Attachments

  • oneSageSDK_StartGuide.pdf
    777.9 KB · Views: 3

Osborne

Active Member
With the SDK there should be some .NET dll files, and before you can do anything Progress needs to see them. For a quick start try the following:
  1. Place the .dll files in the Progress/Project working directory - MESSAGE SESSION:TEMP-DIRECTORY VIEW-AS ALERT-BOX.
  2. As per this site - OpenEdge 11.7 Documentation - add all the .dll files via the "Local Assemblies" tab.
  3. Save the assemblies.xml in the same directory as the .dll files and quit Assembly References. You may need to restart the session so these will be picked up.
  4. Try writing a line of code such as DEFINE VARIABLE lConnection AS oneSage.SDK.RD.Access.Connection NO-UNDO. and then checking syntax. If you get this error it means Progress is not referencing the components:
Invalid datatype specified: oneSage.SDK.RD.Access.Connection. Specify a datatype such as 'character' or the name of a class. (5638)
** Could not understand line 1. (196)

This should hopefully get you started.
 

gasomma

Member
Hi Osborne,

IF "oneSage.SDK.RD.Access.Connection" is a DLL I cannot find. In Sage path there are a lot of DLL but not this one.
For example I can find DLL below. I add also developer reference. Maybe can help!
many thanks

1524688843072.png
 

Attachments

  • SData.Samples.zip
    3.3 MB · Views: 2
  • oneSage SDK Developer Reference.pdf
    153.1 KB · Views: 1

gasomma

Member
Hi Osborne,

start working. I have error this lines:
/*if (lConnection.DoValidate((oneSage.SDK.RD.Validating.Interface.IInfoList)lInfoList) = true) THEN DO:*/
/*IF (lConnection:DoValidate(System.Convert:ChangeType(lInfoList.oneSage.SDK.RD.Validating.Interface.IInfoList)) = TRUE) THEN DO:*/

IF I comment line above I error also for:

DEFINE VARIABLE lTbl AS oneSage.SDK.RD.Data.SageStart.AccountDataTable NO-UNDO.

Thx.
 

Osborne

Active Member
If you unzip the zip file and search for extension dll there will be a list of dll's and the oneSage.sdk one is there - see the 4th entry on the attached.

However, when I tried to add it to assemblies.xml I got the attached error. I do not know if this is due to the component not being compatible with Progress or the wrong .NET version for the Progress version.

Maybe an idea to contact Progress support to ask if oneSage can be used with Progress.
 

Attachments

  • Assembly Error.png
    Assembly Error.png
    22.4 KB · Views: 5
  • Sdata dlls.png
    Sdata dlls.png
    110.1 KB · Views: 5

gasomma

Member
Hi Osborne,
the DLL in the zip file are for VB and CS.
There is no other way for comunicate with SAGE?
 

Osborne

Active Member
Gasomma, even if the information says VB or C#, more often than not if the DLL is for the .NET framework it will work with Progress.

The only thing I can advise is contact the company and ask them for the correct oneSage.SDK.dll file. Maybe best if you get all possible versions available - .NET 3.5, .NET 4.0 or .NET 4.5 - and hopefully one of them will work.
 

Osborne

Active Member
For example. If I insert in the URL http://obsv:5493/sdata/SageStart/SageStart/OBS/Clients
Sage show an XML in the browse that contains data.
How I can execute the string "http://obsv:5493/sdata/SageStart/SageStart/OBS/Clients" and capture the XML in progress editor?
In this case I can read the datas. Also in order to insert data I can prepare a equal XML file and import to SAGE.
I am not sure about this, but think you may need to look at the Progress methods READ-XML and WRITE-XML. I have never used these but maybe someone who has can advise.
 

gasomma

Member
Thanks Osborne. Documentation wrote
System requirements
In order to install and use the oneSage SDK the following system requirements apply:
 Installed Sage Product5
 Sage 50: V-2009 or later (with the latest Auto-Update)
 Sage Start: V-2012 or later (with the latest Auto-Update)
 Windows XP/Vista/7 (32 or 64 Bit)
 .NET Framework 3.5
 

Osborne

Active Member
That could explain the problem, because I think .NET Framework 3.5 only works with Progress 10.2B whereas you are on 11.7 which uses .NET Framework 4.6:

Progress KB - Which .NET Framework Versions are supported with OpenEdge?
Progress KB - .NET Open Client runtime files do not work with the .NET 3.5 framework in OpenEdge 11
Progress KB - What version of the .NET framework does OpenEdge 10.2B use for the .NET UI?

Unless they have a later .NET Framework version you may not be able to use oneSage at all.

The only thing I can think of is contact Progress Support and ask if a .NET 3.5 component can be used with Progress 11.7 and if so how.
 

gasomma

Member
Thanks Obsorne. I also have 10.2b installed. I can try. But How I can add all the .dll files via the "Local Assemblies" tab? I have not OpenEdge Architect .
thanks in advance.
 

Osborne

Active Member
From the GUI client select Tools-Assembly References.

One thing I have just noticed is the oneSage DLL contained in the zip file you attached is actually called oneSage.SData.Adapter.Sage50.dll NOT oneSage.SDK.dll. Is the DLL stored somewhere else, because unless you can add the exact file called to oneSage.SDK.dll to assemblies it will not work.
 

gasomma

Member
I tried in 10.2b but I have same error of 11.7 in line:

IF (lConnection:DoValidate(System.Convert:ChangeType(lInfoList.oneSage.SDK.RD.Validating.Interface.IInfoList)) = TRUE) THEN DO:

1524835772494.png
 

Osborne

Active Member
Is that the first line that an error is first encountered and the previous ones are okay? If so, then some good news as you are interacting with oneSage okay.

As I said in post #2, the code is a very rough translation and you need to experiment to get it correct. As error 198 indicates the syntax is not correct:

"This is probably a syntax problem. Check this statement and the previous one for proper termination (a period followed by a space, or a colon followed by a space for block statements). Also, check for misplaced reserved keywords (AVAILABLE, INDEX, HEADER, etc.) and for constants (quoted strings, numerals, dates) where field, file and frame names should go, and vice versa".

Unfortunately, I do not know what the correct syntax is for that line.
 

gasomma

Member
In any case if I insert comment for this line, Progress shows another relevant error:
The road is very long..

1524855645415.png
 
Top