/// <summary>
/// Set the Results after applying renderers and IS_SELECTED column of the graphics layer to true.
/// </summary>
/// <param name="dtResults">Contains the data of the graphics layer.</param>
/// <param name="sResourceName">Name of the resource to apply renderers.</param>
/// <param name="sLayerId">Name of the layer Id to apply renderers.</param>
/// <param name="bSetAsSelected">Whether to set IsSelected column of graphics layer to true.</param>
public void SetResults(ref DataTable dtResults, string sResourceName, string sLayerId, bool bSetAsSelected)
{
try
{
if (dtResults == null dtResults.Rows.Count == 0)
{
NoSelectionsTaskResult taskResult = new NoSelectionsTaskResult(this.Title);
Results = taskResult;
}
else
{
dtResults = LoadDomainValues(dtResults); //<- add this function
......
public DataTable LoadDomainValues(DataTable dt)
{
try
{
IDictionary<String, IDictionary<Int32, String>> dc = null;
MapResourceLocal mr = (MapResourceLocal)Map.PrimaryMapResourceInstance;
ESRI.ArcGIS.Carto.IMapServerObjects mso = (ESRI.ArcGIS.Carto.IMapServerObjects)mr.MapServer;
ESRI.ArcGIS.Carto.ILayer layer = null;
ESRI.ArcGIS.Carto.IMap map = mso.get_Map(mr.MapServer.DefaultMapName);
ESRI.ArcGIS.Carto.IEnumLayer enumLayer = map.get_Layers(null, true);
ESRI.ArcGIS.Carto.ILayer loopLayer = null;
while ((loopLayer = enumLayer.Next()) != null)
{
if (loopLayer.Name == dt.TableName)
{
layer = loopLayer;
break;
}
}
ESRI.ArcGIS.Carto.IFeatureLayer fl = (ESRI.ArcGIS.Carto.IFeatureLayer)layer;
ESRI.ArcGIS.Geodatabase.IFeatureClass fclass = fl.FeatureClass;
ESRI.ArcGIS.Geodatabase.IFields flds = fclass.Fields;
ESRI.ArcGIS.Geodatabase.IDomain d = null;
ESRI.ArcGIS.Geodatabase.ICodedValueDomain cvd = null;
dc = new Dictionary<String, IDictionary<Int32, String>>();
IDictionary<Int32, String> dm = null;
ESRI.ArcGIS.Geodatabase.IField f = null;
for (Int32 fi = 0; fi < flds.FieldCount; fi++)
{
f = flds.get_Field(fi);
d = f.Domain;
if (d == null)
dm = null;
else
{
cvd = (ESRI.ArcGIS.Geodatabase.ICodedValueDomain)d;
dm = new Dictionary<Int32, String>();
for (Int32 i = 0; i < cvd.CodeCount; i++)
dm.Add(Convert.ToInt32(cvd.get_Value(i)), cvd.get_Name(i));
}
dc.Add(f.Name, dm);
}
IDictionary<Int32, String> listDomain = null;
DataTable dtnew = dt.Clone();
foreach (DataColumn c in dtnew.Columns)
{
if (dc.ContainsKey(c.ColumnName))
{
listDomain = dc[c.ColumnName];
if (listDomain != null)
c.DataType = System.Type.GetType("System.String");
}
}
DataRow newRow;
foreach (DataRow r in dt.Rows)
{
newRow = dtnew.NewRow();
foreach (DataColumn c in dt.Columns)
{
if (dc.ContainsKey(c.ColumnName))
{
listDomain = dc[c.ColumnName];
if (listDomain == null)
newRow[c.ColumnName] = r[c.ColumnName];
else
{
if (!(r[c.ColumnName] is DBNull))
newRow[c.ColumnName] = listDomain[Convert.ToInt32(r[c.ColumnName])];
}
}
else
newRow[c.ColumnName] = r[c.ColumnName];
}
dtnew.Rows.Add(newRow);
}
return dtnew;
}
catch (Exception ex)
{
_log.Error("Error in LoadDomainValues", ex);
return dt;
}
}
Scarica qui il task Query Builder x MapViewer
Scarica qui il task Layout SOE x MapViewer (versione semplificata: solo PDF)
2 commenti:
Ciao Domenico ho una domanda da porti anche se non è decisamente il post giusto....
Per piccole realtà (comuni vicentino) utilizzo mapserver come render dei dati gis. Ora che ho un po di esperienza posso fare queste considerazioni:
1) creare simbologie costa un sacco in termini di tempo!! giorni e giorni quando con arcgis lo fai in minuti
2) quando creo un servizio tile con mapserver che pubblica delle feaure class con label, ho il problema che mapserver mi mette le label su ogni tile. Non riesce a capire dove posizionare la label.
Ora la domanda questi problemi 2) esistono anche con ArcGis Server?
ciao
Michele Fioretto
Ciao Michele prova a vedere in questo link:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0053000000p8000000.htm
Posta un commento