[mapguide-users] RE: Come get your Key IDs

Kori Maleski km at pat.ca
Thu Jun 29 14:58:09 EDT 2006


Hi Andrew,
 
It is indeed VB.NET - although I can switch it to C# easy enough.  
 
I don't think you can utilize VBScript server side for these operations (if anybody can correct me on this feel free).
You will have to pick up a book on .NET basics - VB since you are more comfortable with it.
 
You can get away with not purchasing Visual Studio by just coding in a text editor (you will lose the debugging ability).
 
Note: My code is only a snippet and won't run without a larger part of code above it.  
 
 
 
 
Cheers,
 
 
Kori Maleski  BSc. 
Senior Technical Consultant
 
Pacific Alliance Technologies
Suite 400 - 534 17 Ave. SW Calgary, AB CANADA T2S 0B1
TEL 403.770.1917 FAX 877.691.9149 TOL 877.691.9171 www.pat.ca <http://www.pat.ca/> 

________________________________

From: Andrew DeMerchant [mailto:andrew.demerchant at gemtec.ca]
Sent: Thu 29/06/2006 12:37 PM
To: users at mapguide.osgeo.org
Subject: Re: [mapguide-users] RE: Come get your Key IDs


Kori,

Is your code VB.Net? The server-side code that I use will need to be VBScript (not VB.Net)....I tried your code, but it doesn't run, which is why I suspect that it's .Net....I'm a 'programming type', but not when it comes to PHP, C# or .Net. I can read them to some extent, but don't know that languages very well. Since I don't know PHP or C#, I've found the documentation pretty hard to follow. I'd LOVE it if you could just specify a field to pass for each layer without any coding involved. That would be a great addition. In the meantime, any help that I can get would be greatly appreciated. What I really need is to see some example VBScript code (I learn best by example) that shows how to get data from the "$CurrentSelection$" variable that gets passed with InvokeURL.

Andrew

Kori Maleski wrote: 

	Andy,
	 
	This code is part of a generic handler so I don't hardcode the column name and is reused in all the reporting functions.  I could have passed the name instead of the ordinal position.  I forget why I did that.  It must have been a Monday.
	 
	 
	 
	 
	Kori Maleski  BSc. 
	Senior Technical Consultant
	 
	Pacific Alliance Technologies
	Suite 400 - 534 17 Ave. SW Calgary, AB CANADA T2S 0B1
	TEL 403.770.1917 FAX 877.691.9149 TOL 877.691.9171 www.pat.ca <http://www.pat.ca/> <http://www.pat.ca/>  
	
	________________________________
	
	From: Andy Morsell [mailto:amorsell at spatialgis.com]
	Sent: Thu 29/06/2006 11:33 AM
	To: users at mapguide.osgeo.org
	Subject: [BULK] RE: [mapguide-users] RE: Come get your Key IDs
	
	
	Kori,
	I don't think you have to know the column order.  In my case I am getting to it directly by field name.  I am creating the filter, query options and feature reader the same way, though.  Also, my MgPropertyType is hardcoded here.  Your way of determining it from the field is better.
	 
	Here is part of the C# code for it:
	 
	//loop through the featureReader, get the ID field, and add it to an array   
	ArrayList objDBID = new ArrayList(0);
	while (featureReader.ReadNext())
	   {        
	        objDBID.Add(featureReader.GetString("ID")); //TO DO: un-hard code this.  Pick up the field name to be queried from a request parameter instead.
	   }
	 
	My biggest problem with these solutions is that the non-programmer types are not going to be able to easily do this.  We really need a way to easily pass ANY field in a given layer from a selection set client-side.
	 
	 
	Andy 
	
	________________________________
	
	From: Kori Maleski [mailto:km at pat.ca] 
	Sent: Thursday, June 29, 2006 10:15 AM
	To: users at mapguide.osgeo.org
	Subject: [mapguide-users] RE: Come get your Key IDs
	
	
	Andrew,
	
	The Selection Set contains the featureIDs for your datasource.
	You can get YOUR key IDs from the Selection set by querying the feature, then reading your preferred key Column (property).
	
	You have to know your key columns position in order to do this - hence my variable - l_iKeyColumnOrdinal.
	i.e. - if my key IDs are in column 4 then  l_iKeyColumnOrdinal = 4
	I utilize a lookup table that manages my key columns.  Not sure if this is the best way but it works.
	
	This returns MY key IDs in a column delimited string.
	
	 
	
	'query the features
	
	Dim l_oQuery As New MgFeatureQueryOptions()
	l_oQuery.SetFilter(l_sFilter) 'derived from selection set
	
	 
	
	Dim l_ofeatureSource As MgResourceIdentifier = New MgResourceIdentifier(l_oSelLayer.GetFeatureSourceId())
	Dim l_ofeatures As MgFeatureReader = l_oFeatureSrvc.SelectFeatures(l_ofeatureSource, l_sFeatureClassName, l_oQuery)
	
	 
	
	If l_ofeatures.ReadNext() Then
	Dim l_sProperty As String = l_ofeatures.GetPropertyName(l_iKeyColumnOrdinal)
	
	Do
	
	Dim pi As Integer
	'For pi = 0 To l_ofeatures.GetPropertyCount() - 1
	
	Dim l_iPropType As Integer = l_ofeatures.GetPropertyType(l_sProperty)
	Dim l_sPropertyValue As String = ""
	
	Select Case l_iPropType
	Case MgPropertyType.Boolean
	l_sPropertyValue = l_ofeatures.GetBoolean(l_sProperty).ToString()
	Case MgPropertyType.Single
	l_sPropertyValue = l_ofeatures.GetSingle(l_sProperty).ToString()
	Case MgPropertyType.Double
	l_sPropertyValue = l_ofeatures.GetDouble(l_sProperty).ToString()
	Case MgPropertyType.Int16
	l_sPropertyValue = l_ofeatures.GetInt16(l_sProperty).ToString()
	Case MgPropertyType.Int32
	l_sPropertyValue = l_ofeatures.GetInt32(l_sProperty).ToString()
	Case MgPropertyType.Int64
	l_sPropertyValue = l_ofeatures.GetInt64(l_sProperty).ToString()
	Case MgPropertyType.String
	l_sPropertyValue = l_ofeatures.GetString(l_sProperty)
	End Select
	
	If l_sSelectedLayerIDs = "" Then
	l_sSelectedLayerIDs = l_sPropertyValue
	Else
	l_sSelectedLayerIDs = l_sSelectedLayerIDs + "," + l_sPropertyValue
	End If
	
	'Next pi
	
	Loop While l_ofeatures.ReadNext()
	
	 
	 
	 
	 
	Obviously you have to do this server side...
	 
	 
	Cheers,
	 
	Kori Maleski  BSc. 
	Senior Technical Consultant
	 
	Pacific Alliance Technologies
	Suite 400 - 534 17 Ave. SW Calgary, AB CANADA T2S 0B1
	TEL 403.770.1917 FAX 877.691.9149 TOL 877.691.9171 www.pat.ca <http://www.pat.ca/> <http://www.pat.ca/>  
	
	________________________________
	
	From: Andrew DeMerchant [mailto:andrew.demerchant at gemtec.ca]
	Sent: Thu 29/06/2006 10:32 AM
	To: users at mapguide.osgeo.org
	Subject: Re: [mapguide-users] Andy - Question about your tooltips...
	
	
	 
	  
	
________________________________


	---------------------------------------------------------------------
	To unsubscribe, e-mail: users-unsubscribe at mapguide.osgeo.org
	For additional commands, e-mail: users-help at mapguide.osgeo.org


-- 

 
Andrew DeMerchant
Computer Technologist
ph.1-877-4GEMTEC x.163
fax 506-453-9470


GEMTEC Limited <http://www.gemtec.ca> 
191 Doak Road
Fredericton, NB, Canada
E3C 2E6

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 13368 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/mapguide_users/attachments/20060629/e5c07914/attachment.bin


More information about the Mapguide_users mailing list