/// <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)








