[mapguide-users] Field editor
Jamo
adam.jamison at portbris.com.au
Thu Mar 19 18:05:30 EDT 2009
Howdy
I'm working on a field editor for Mapguide, I woudl like to give certain
users the ability to edit the data through mapguide.
I have produced this code thus far I will work on making it more dynamic but
at the moment it is locked down to a certain feature type and certain
fields.
I seem to be having a problem with the selection XML and generating a
filter.... I'm sure there will be more problems but first things first
The selection XML seems to come across correctly.
<%@ Page Language="C#" ValidateRequest="false" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Collections.Specialized" %>
<%@ Import Namespace="System.Text" %>
<!-- #Include File="../../../mapviewernet/common.aspx -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script runat="server">
String mapName = "";
String sessionId = "";
String ID = "";
String ROW = "";
String TENANT = "";
String DOCUMENT = "";
String imgid = "";
String VESSEL = "";
String STATUS = "";
String LENGTH = "";
String mySelXML = "";
String layerName = "";
</script>
</head>
<%
Response.Charset = "utf-8";
InitializeWebTier();
GetRequestParameters();
MgUserInformation cred = new MgUserInformation(sessionId);
//connect to the site and get a feature service and a resource service
instances
MgSiteConnection site = new MgSiteConnection();
site.Open(cred);
MgResourceService resourceSrvc =
site.CreateService(MgServiceType.ResourceService) as MgResourceService;
MgFeatureService featureSrvc =
site.CreateService(MgServiceType.FeatureService) as MgFeatureService;
//Create a temporary map runtime object, locate the layer
MgMap map = new MgMap();
map.Open(resourceSrvc, mapName);
Response.Write(layerName);
MgLayerBase currentLayer = map.GetLayers().GetItem(layerName);
String currentClassName = currentLayer.GetClassName();
MgSelection newSel = new MgSelection(map);
newSel.FromXml(mySelXML);
String myFilter = new MgSelection(map,
mySelXML).GenerateFilter(currentLayer, currentClassName);
Response.Write(myFilter);
//String myFilter = mySel.GenerateFilter(myLayer, myLayer.GetClassName());
Response.Write("myFilter: " + EscapeForHtml(myFilter));
MgFeatureCommandCollection updateSelection = new
MgFeatureCommandCollection();
MgPropertyCollection properties = new MgPropertyCollection();
Response.Write(imgid);
//create loop to loop through each property and update where needed
properties.Add(new MgStringProperty("imgid", imgid));
MgUpdateFeatures updateCommand = new MgUpdateFeatures(currentClassName,
properties, myFilter);
updateSelection.Add(updateCommand);
//Response.Write(mapName);
//Response.Write(mySelXML);
//ReleaseReader(featureSrvc.UpdateFeatures(mySel.GetResourceId(),
updateSelection, false), updateSelection);
map.Save();
%>
<body>
</body>
</html>
<script runat=server>
void GetRequestParameters()
{
if (Request.HttpMethod == "GET")
{
GetParameters(Request.QueryString);
}
}
void GetParameters(NameValueCollection parameters)
{
mapName = GetParameter(parameters, "MAPNAME");
sessionId = GetParameter(parameters, "SESSIONID");
ID = GetParameter(parameters, "ID");
ROW = GetParameter(parameters, "ROW");
TENANT = GetParameter(parameters, "TENANT");
DOCUMENT = GetParameter(parameters, "DOCUMENT");
imgid = GetParameter(parameters, "imgid");
VESSEL = GetParameter(parameters, "VESSEL");
STATUS = GetParameter(parameters, "STATUS");
LENGTH = GetParameter(parameters, "LENGTH");
mySelXML = GetParameter(parameters, "SELXML");
layerName = GetParameter(parameters, "layerName");
}
void ReleaseReader(MgPropertyCollection res, MgFeatureCommandCollection
commands)
{
if(res == null)
return;
for(int i = 0; i < res.GetCount(); i++)
{
MgFeatureCommand cmd = commands.GetItem(i);
if(cmd.GetCommandType().Equals(MgFeatureCommandType.UpdateFeatures))
{
MgFeatureProperty resProp = (MgFeatureProperty)res.GetItem(i);
if(resProp != null)
{
MgFeatureReader reader =
(MgFeatureReader)resProp.GetValue();
if(reader == null)
return;
reader.Close();
}
}
}
}
</script>
--
View this message in context: http://n2.nabble.com/Field-editor-tp2505715p2505715.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list