xsharp.eu • New to X# and need some direction - Page 4
Page 4 of 8

New to X# and need some direction

Posted: Tue Jun 26, 2018 11:47 am
by tom@dieselworks.com.au
Yes I have got that sorted in the meantime, the issue was that I have referenced v11 of Json and not v7
So that works, thaks to all. Now I have both VS C# and XIDE X# stopping at the same point - good and bad :-) Good that it looks like the sample is not correct. So now comes the new challenge :-)
XIDE X#:
error XS0103: The name 'companyFiles' does not exist in the current context 74,20 Form1.prg MYOB_Test1
VS with C#:
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'AccountService' could not be found (are you missing a using directive or an assembly reference?) WindowsFormsApp1 C:Usersintersoft.SBSsourcereposWindowsFormsApp1WindowsFormsApp1Program.cs 30 Active

Did you get this? If not

New to X# and need some direction

Posted: Tue Jun 26, 2018 11:48 am
by tom@dieselworks.com.au
using System.Windows.Forms
#using System.Drawing

#using MYOB.AccountRight.SDK
#using MYOB.AccountRight.SDK.Services
#using MYOB.AccountRight.SDK.Services.GeneralLedger
#using MYOB.AccountRight.SDK.Contracts


//USING MYOB.AccountRight.SDK
//USING MYOB.AccountRight.SDK.Services
//USING MYOB.AccountRight.SDK.Contracts

CLASS BasicForm INHERIT System.Windows.Forms.Form

PROTECT oTextBox AS System.Windows.Forms.TextBox
PROTECT oOKButton AS System.Windows.Forms.Button
// User code starts here (DO NOT remove this line) ##USER##

CONSTRUCTOR()

SUPER()
SELF:InitializeForm()

RETURN

METHOD InitializeForm() AS VOID

// IDE generated code (please DO NOT modify)

SELF:oTextBox := System.Windows.Forms.TextBox{}
SELF:oOKButton := System.Windows.Forms.Button{}

SELF:SuspendLayout()

SELF:ClientSize := System.Drawing.Size{392 , 264}
SELF:Location := System.Drawing.Point{100 , 100}
SELF:Name := "BasicForm"
SELF:Text := "Basic form application"

SELF:oTextBox:Location := System.Drawing.Point{8 , 48}
SELF:oTextBox:Name := "TextBox"
SELF:oTextBox:Size := System.Drawing.Size{341 , 20}
SELF:oTextBox:TabIndex := 1
SELF:Controls:Add(SELF:oTextBox)

SELF:oOKButton:Click += SELF:OKButtonClick
SELF:oOKButton:Location := System.Drawing.Point{280 , 232}
SELF:oOKButton:Name := "OKButton"
SELF:oOKButton:Size := System.Drawing.Size{104 , 24}
SELF:oOKButton:TabIndex := 0
SELF:oOKButton:Text := "&OK"
SELF:Controls:Add(SELF:oOKButton)

SELF:ResumeLayout()

RETURN

METHOD OKButtonClick(sender AS OBJECT , e AS System.EventArgs) AS VOID

//SELF:Close()
SELF:OKButtonClick2()
// SELF:oTextBox:Text := "Ok"
RETURN

METHOD OKButtonClick2() AS VOID

VAR configuration := ApiConfiguration{"http://localhost:8080/accountright"}
VAR cfService := CompanyFileService{configuration}
VAR comanyFiles := cfService.GetRange()

SELF:oTextBox:Text :="Company Files set"


VAR companyFile := companyFiles.FirstOrDefault({x => Version{x:ProductVersion} >= Version{"2013.3"}})


//VAR credentials := CompanyFileCredentials{"Administrator",""}


//VAR accountService := AccountService{configuration}
//VAR accounts := accountService.GetRange(companyFile,NULL,credentials)

RETURN

END CLASS

New to X# and need some direction

Posted: Tue Jun 26, 2018 11:53 am
by wriedmann
Hi Tom,

you need to add a reference to System.Core and a using System.LinQ to solve this error.

Wolfgang

New to X# and need some direction

Posted: Tue Jun 26, 2018 11:57 am
by tom@dieselworks.com.au
and where do I get them from? How to add them?

New to X# and need some direction

Posted: Tue Jun 26, 2018 11:59 am
by robert
You use the one that is also used in your VS project
Usually the latest version.

Robert

New to X# and need some direction

Posted: Tue Jun 26, 2018 12:03 pm
by wriedmann
Hi Tom,

System.Core is in the GAC - is part of the .NET Framework.

FirstOrDefault() is a extension method that comes from the System.Core assembly and uses the System.LinQ namespace:

msdn.microsoft.com/de-de/library/bb340482(v=vs.110).aspx

Wolfgang

New to X# and need some direction

Posted: Tue Jun 26, 2018 12:24 pm
by lumberjack
Hi Tom,
tom@dieselworks.com.au wrote: and where do I get them from? How to add them?
Add Reference (means add a DLL), so here you go to our application Projects tab on the right in XIDE. Right click references, select Add Reference. Then in the window that opens, select the GAC tab. Type System.Core and add from list.

Now you have the Assembly added to your application. In your form.prg you need to now tell it you want to use Linq from the System.Core assembly. You do that by #using System.Linq with your other #using statements.

HTH,

New to X# and need some direction

Posted: Tue Jun 26, 2018 12:26 pm
by tom@dieselworks.com.au
Thanks, got this sorted too. I have the test app running (except the last line) and it connects to MYOB, thaks again, really happy. I am not sure if this si a reference issue also?
error XS0120: An object reference is required for the non-static field, method, or property 'ReadableRangeService<Account>.GetRange(CompanyFile, string, ICompanyFileCredentials, string)' 85,19 Form1.prg MYOB_Test1

New to X# and need some direction

Posted: Tue Jun 26, 2018 12:30 pm
by tom@dieselworks.com.au
Thanks Johan, I have got that sorted, thanks again.

New to X# and need some direction

Posted: Tue Jun 26, 2018 12:31 pm
by tom@dieselworks.com.au
Thanks Robert, that is sorted, almost there, down to last error :-)