Dear Eeveryone.
i need you help to convert .net c# code to RDML.
thank you..
c# .net code.
var url = String.Format("http://maps.google.com/maps/api/geocode ... address={0}", address);
string result = String.Empty;
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
using (var response = request.GetResponse())
using (StreamReader sr = new StreamReader(response.GetResponseStream()))
{
//Json格式: 請參考http://code.google.com/intl/zh-TW/apis/maps/documentation/geocoding/
result = sr.ReadToEnd();
}
Please Help me convert .NET from C# to RDML.
Re: Please Help me convert .NET from C# to RDML.
It looks like you are trying to get the geocode from Google Maps.
The concept is similar to how it is done in .NET. Format the request, execute it and handle the response.
The first thing you need to do is format the Request. If you are on a web component, you can use #PRIM_WEB.HttpRequest. If you are on a server component, you are going to have to use Integrator.
Assuming you are on a web component, define the request as such
Then you can format the address and url and execute it
Then when you handle the request, you need to parse out the JSON response (ignore the widget timer, the important bit is the UpdateMap call)
Then you can do what you need to with the data (a #PRIM_WEB.JSONElement). Here I am updating the GoogleMapWidget with the response data.
Hope this helps,
Joe
The concept is similar to how it is done in .NET. Format the request, execute it and handle the response.
The first thing you need to do is format the Request. If you are on a web component, you can use #PRIM_WEB.HttpRequest. If you are on a server component, you are going to have to use Integrator.
Assuming you are on a web component, define the request as such
Code: Select all
define_com class(#PRIM_WEB.HttpRequest) name(#Request)
Code: Select all
mthroutine name(Load)
define_map for(*INPUT) class(#STD_STRNG) name(#caption)
define_map for(*INPUT) class(#STD_STRNG) name(#line1)
define_map for(*INPUT) class(#STD_STRNG) name(#city)
define_map for(*INPUT) class(#STD_STRNG) name(#state)
define_map for(*INPUT) class(#STD_STRNG) name(#postCode)
define_map for(*INPUT) class(#STD_STRNG) name(#country)
#AddressCaption := #caption
#Address := ("&1,&2,&3,&4,&5").Substitute( #line1 #city #state #postCode #country )
#Address := #Address.ReplaceAll( " " "+" )
if (#Address = *BLANKS)
return
endif
#SYS_APPLN.TraceMessageText( "Executing GeoCode" )
#Request.Url := "https://maps.googleapis.com/maps/api/geocode/json?address=" + #Address + "&key=" + #ApiKey
#Request.ExecuteAsync
endroutine
Code: Select all
evtroutine handling(#Request.Completed)
#SYS_APPLN.TraceMessageText( "GeoCode Completed" )
if ((#Request.Response *IsNot *NULL) *And (#Request.Response.StatusCode = 200))
#Json := #Request.Response.Content
if (#WidgetInitialized)
#COM_OWNER.UpdateMap( #Json.RootItem<"results">.ItemAt<1> )
else
#SYS_APPLN.TraceMessageText( "Widget not initialized. Starting Timer" )
#WidgetTimer.Start
endif
else
#SYS_APPLN.TraceMessageText( "NULL Response from GeoCoding API" )
endif
endroutine
Code: Select all
mthroutine name(UpdateMap) access(*PRIVATE)
define_map for(*INPUT) class(#PRIM_WEB.JsonElement) name(#data) pass(*BY_REFERENCE)
define_com class(#PRIM_WEB.JsonElement) name(#location) reference(*DYNAMIC)
#SYS_APPLN.TraceMessageText( "Updating Map" )
if (#data *IsNot *NULL)
#location <= #data<"geometry">.Item<"location">
#wk_Longitude := #location<"lng">.AsNumber
#wk_Latitude := #location<"lat">.AsNumber
#SYS_APPLN.TraceMessageText( ("Latitude: &1 Longitude:&2").Substitute( #wk_Latitude.AsString #wk_Longitude.AsString ) )
#GoogleMapWidget.AddMarker caption(#AddressCaption) longitude(#wk_Longitude) latitude(#wk_Latitude) data(#Address)
#GoogleMapWidget.Center latitude(#wk_Latitude) longitude(#wk_Longitude)
signal event(MapUpdated)
else
#SYS_APPLN.TraceMessageText( "Map data is null" )
signal event(MissingData)
endif
endroutine
Joe
Re: Please Help me convert .NET from C# to RDML.
Thank you for your reply..
but now ,i want to coding Visual Lansa Windows form.
How can i doing?
Thank you..
but now ,i want to coding Visual Lansa Windows form.
How can i doing?
Thank you..
Re: Please Help me convert .NET from C# to RDML.
Unfortunately PRIM_WEB.HttpRequest is only available on web components.
If you are trying to do this on a Server or Windows client, then you may be able to use Integrator's HttpService. http://docs.lansa.com/14/EN/lansa093/in ... 7_0115.htm
I don't work with Windows Forms so I don't know if you can use Integrator like that but it may be worth a try.
If you are trying to do this on a Server or Windows client, then you may be able to use Integrator's HttpService. http://docs.lansa.com/14/EN/lansa093/in ... 7_0115.htm
I don't work with Windows Forms so I don't know if you can use Integrator like that but it may be worth a try.
Re: Please Help me convert .NET from C# to RDML.
Thanks so much...
nice day to you.
nice day to you.
-
tsupartono
Re: Please Help me convert .NET from C# to RDML.
You may also want to wait for the next EPC (scheduled to come out in a few days).
This EPC lets you easily consume web services natively from your RDMLX code.
This EPC lets you easily consume web services natively from your RDMLX code.
Re: Please Help me convert .NET from C# to RDML.
*
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientheight(487) Clientwidth(784) Height(526) Left(565) Top(170) Visualstyle(#VS_NORM) Width(800) Windowstate(Maximized)
Define_Com Class(#ZSYS.System.Uri) Name(#uri) Reference(*DYNAMIC)
Define_Com Class(#zsys.System.Net.WebRequest) Name(#request) Reference(*DYNAMIC)
Define_Com Class(#zsys.System.Net.WebResponse) Name(#response) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.XDocument) Name(#Doc) Reference(*DYNAMIC)
* Define_Com Class(#zsys.System.Xml.XmlDocument) Name(#Doc) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.XElement) Name(#locationElement) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.XElement) Name(#lat) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.XElement) Name(#lng) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.Xname) Name(#GeocodeResponse) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.Xname) Name(#result) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.Xname) Name(#geometry) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.Xname) Name(#location) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.Xname) Name(#zlat) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.Xname) Name(#zlng) Reference(*DYNAMIC)
Define_Com Class(#VSAADDR.Visual) Name(#VSAADDR) Displayposition(1) Left(76) Parent(#COM_OWNER) Tabposition(1) Top(73) Height(24)
Define_Com Class(#VSALGTD.Visual) Name(#VSALGTD) Displayposition(2) Left(73) Parent(#COM_OWNER) Tabposition(2) Top(135)
Define_Com Class(#VSALTTD.Visual) Name(#VSALTTD) Displayposition(3) Left(72) Parent(#COM_OWNER) Tabposition(3) Top(175)
Define_Com Class(#PRIM_PHBN) Name(#Button1) Displayposition(4) Left(203) Parent(#COM_OWNER) Tabposition(4) Top(296) Width(158) Caption('GET')
Define Field(#address) Type(*string) Length(256)
*
*
Define Field(#requestUri) Type(*string) Length(1024)
Define Field(#latitude) Type(*string) Length(50)
Define Field(#longitude) Type(*string) Length(50)
Evtroutine Handling(#com_owner.Initialize)
Set Com(#com_owner) Caption(*component_desc)
Endroutine
Subroutine Name(SUBGET)
#address := #VSAADDR.AsNativeString
#requestUri := "http://maps.googleapis.com/maps/api/geo ... nsor=false"
#requestUri := #requestUri.Substitute( #uri.EscapeUriString( #address ) )
#request <= #request.Create( #requestUri )
#response <= #request.GetResponse()
#Doc <= #Doc.Load#2( #response.GetResponseStream() )
#GeocodeResponse <= #GeocodeResponse.Get( 'GeocodeResponse' )
#result <= #result.Get( 'result' )
#geometry <= #geometry.get( 'geometry' )
#location <= #location.get( 'location' )
#zlat <= #zlat.get( 'lat' )
#zlng <= #zlng.get( 'lng' )
#lat <= #Doc.Element( #GeocodeResponse ).Element( #result ).Element( #geometry ).Element( #location ).Element( #zlat )
#lng <= #Doc.Element( #GeocodeResponse ).Element( #result ).Element( #geometry ).Element( #location ).Element( #zlng )
#VSALTTD := #lat.ToString.ReplaceAll( '<lat>' '' ).ReplaceAll( '</lat>' '' ).AsNumber
#VSALGTD := #lng.ToString.ReplaceAll( '<lng>' '' ).ReplaceAll( '</lng>' '' ).AsNumber
#Doc <= *null
Endroutine
Evtroutine Handling(#Button1.Click)
Execute Subroutine(SUBGET)
Endroutine
End_Com
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientheight(487) Clientwidth(784) Height(526) Left(565) Top(170) Visualstyle(#VS_NORM) Width(800) Windowstate(Maximized)
Define_Com Class(#ZSYS.System.Uri) Name(#uri) Reference(*DYNAMIC)
Define_Com Class(#zsys.System.Net.WebRequest) Name(#request) Reference(*DYNAMIC)
Define_Com Class(#zsys.System.Net.WebResponse) Name(#response) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.XDocument) Name(#Doc) Reference(*DYNAMIC)
* Define_Com Class(#zsys.System.Xml.XmlDocument) Name(#Doc) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.XElement) Name(#locationElement) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.XElement) Name(#lat) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.XElement) Name(#lng) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.Xname) Name(#GeocodeResponse) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.Xname) Name(#result) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.Xname) Name(#geometry) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.Xname) Name(#location) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.Xname) Name(#zlat) Reference(*DYNAMIC)
Define_Com Class(#LINQ.System.XML.Linq.Xname) Name(#zlng) Reference(*DYNAMIC)
Define_Com Class(#VSAADDR.Visual) Name(#VSAADDR) Displayposition(1) Left(76) Parent(#COM_OWNER) Tabposition(1) Top(73) Height(24)
Define_Com Class(#VSALGTD.Visual) Name(#VSALGTD) Displayposition(2) Left(73) Parent(#COM_OWNER) Tabposition(2) Top(135)
Define_Com Class(#VSALTTD.Visual) Name(#VSALTTD) Displayposition(3) Left(72) Parent(#COM_OWNER) Tabposition(3) Top(175)
Define_Com Class(#PRIM_PHBN) Name(#Button1) Displayposition(4) Left(203) Parent(#COM_OWNER) Tabposition(4) Top(296) Width(158) Caption('GET')
Define Field(#address) Type(*string) Length(256)
*
*
Define Field(#requestUri) Type(*string) Length(1024)
Define Field(#latitude) Type(*string) Length(50)
Define Field(#longitude) Type(*string) Length(50)
Evtroutine Handling(#com_owner.Initialize)
Set Com(#com_owner) Caption(*component_desc)
Endroutine
Subroutine Name(SUBGET)
#address := #VSAADDR.AsNativeString
#requestUri := "http://maps.googleapis.com/maps/api/geo ... nsor=false"
#requestUri := #requestUri.Substitute( #uri.EscapeUriString( #address ) )
#request <= #request.Create( #requestUri )
#response <= #request.GetResponse()
#Doc <= #Doc.Load#2( #response.GetResponseStream() )
#GeocodeResponse <= #GeocodeResponse.Get( 'GeocodeResponse' )
#result <= #result.Get( 'result' )
#geometry <= #geometry.get( 'geometry' )
#location <= #location.get( 'location' )
#zlat <= #zlat.get( 'lat' )
#zlng <= #zlng.get( 'lng' )
#lat <= #Doc.Element( #GeocodeResponse ).Element( #result ).Element( #geometry ).Element( #location ).Element( #zlat )
#lng <= #Doc.Element( #GeocodeResponse ).Element( #result ).Element( #geometry ).Element( #location ).Element( #zlng )
#VSALTTD := #lat.ToString.ReplaceAll( '<lat>' '' ).ReplaceAll( '</lat>' '' ).AsNumber
#VSALGTD := #lng.ToString.ReplaceAll( '<lng>' '' ).ReplaceAll( '</lng>' '' ).AsNumber
#Doc <= *null
Endroutine
Evtroutine Handling(#Button1.Click)
Execute Subroutine(SUBGET)
Endroutine
End_Com