public static ParameterConfig Create(IDictionary <string, object> dictionary) { GPParameterType type = GPParameterType.String; if (dictionary.ContainsKey("type")) { type = (GPParameterType)(Enum.Parse(typeof(GPParameterType), dictionary["type"] as string, true)); } ParameterConfig config = null; switch (type) { case GPParameterType.Boolean: case GPParameterType.Double: case GPParameterType.Long: case GPParameterType.String: case GPParameterType.Date: case GPParameterType.LinearUnit: case GPParameterType.RecordSet: case GPParameterType.DataFile: config = new ParameterConfig(); break; case GPParameterType.RasterData: case GPParameterType.RasterDataLayer: config = new RasterDataParameterConfig(); break; case GPParameterType.MultiValueString: config = new MultiValueStringConfig(); break; case GPParameterType.FeatureLayer: config = new FeatureLayerParameterConfig(); break; case GPParameterType.MapServiceLayer: config = new MapServiceLayerParameterConfig(); break; } if (config != null) { config.FromJsonDictionary(dictionary); } return(config); }
public static ParameterBase Create(ParameterConfig config, Map map) { switch (config.Type) { case GPParameterType.Boolean: return(new BooleanParameter() { Config = config, Value = config.DefaultValue as GPParameter }); case GPParameterType.Double: case GPParameterType.Long: case GPParameterType.String: case GPParameterType.RecordSet: case GPParameterType.DataFile: return(new SimpleParameter() { Config = config, Value = config.DefaultValue as GPParameter }); case GPParameterType.RasterData: case GPParameterType.RasterDataLayer: return(new RasterParameter() { Config = config, Value = config.DefaultValue as GPParameter }); case GPParameterType.Date: return(new DateParameter() { Config = config, Value = config.DefaultValue as GPParameter }); case GPParameterType.LinearUnit: return(new LinearUnitParameter() { Config = config, Value = config.DefaultValue as GPParameter }); case GPParameterType.MultiValueString: var m = new MultiValueStringParameter(); return(m.SetConfiguration(config as MultiValueStringConfig) ? m : null); case GPParameterType.FeatureLayer: FeatureLayerParameterConfig flConfig = config as FeatureLayerParameterConfig; switch (flConfig.Mode) { case FeatureLayerParameterConfig.InputMode.SketchLayer: return(new SketchLayerParameter() { Config = config, Value = config.DefaultValue as GPParameter, Map = map }); case FeatureLayerParameterConfig.InputMode.SelectExistingLayer: return(new SelectExistingLayerParameter() { Config = config, Value = config.DefaultValue as GPParameter, Map = map }); case FeatureLayerParameterConfig.InputMode.Url: return(new SimpleParameter() { Config = config, Value = config.DefaultValue as GPParameter }); case FeatureLayerParameterConfig.InputMode.CurrentExtent: return(new CurrentExtentLayerParameter() { Config = config, Value = config.DefaultValue as GPParameter, Map = map }); } break; } return(null); }
public void LoadConfiguration(GP.MetaData.GPMetaData serviceInfo, Uri taskEndPoint) { if (serviceInfo == null) { return; } TaskEndPoint = taskEndPoint; TaskName = Title = serviceInfo.DisplayName; HelpUrl = serviceInfo.HelpUrl; if (InputParameters == null) { InputParameters = new List <ParameterSupport.ParameterConfig>(); } else { InputParameters.Clear(); } if (OutputParameters == null) { OutputParameters = new List <ParameterSupport.ParameterConfig>(); } else { OutputParameters.Clear(); } if (LayerOrder == null) { LayerOrder = new ObservableCollection <string>(); } else { LayerOrder.Clear(); } Collection <LayerInformation> resultMapserviceLayerInfos = string.IsNullOrEmpty(serviceInfo.ResultMapServerName) || string.IsNullOrEmpty(serviceInfo.CurrentVersion) ? null : new Collection <LayerInformation>(); #region Get parameter configs if (serviceInfo.Parameters != null) { int layerId = 0; foreach (ESRI.ArcGIS.Mapping.GP.MetaData.GPParameter param in serviceInfo.Parameters) { ParameterConfig config = null; if (param.DataType == "GPFeatureRecordSetLayer") { if (!string.IsNullOrEmpty(serviceInfo.ResultMapServerName) && param.Direction != "esriGPParameterDirectionInput") { if (!string.IsNullOrEmpty(serviceInfo.CurrentVersion)) // A resultmapservice can only be accessed at http://.../<resultMapservice>/MapServer/jobs/<jobId> when server version can be determined. { resultMapserviceLayerInfos.Add(ToLayerInfo(param, layerId++)); } else { MapServiceLayerParameterConfig layerConfig = new MapServiceLayerParameterConfig { Name = param.Name, LayerName = param.DisplayName, Type = GPParameterType.MapServiceLayer, SupportsJobResource = false, Opacity = 1, }; OutputParameters.Add(layerConfig); LayerOrder.Add(layerConfig.Name); } } else { #region No result GP mapserver GP.ParameterSupport.FeatureLayerParameterConfig layerConfig = new ParameterSupport.FeatureLayerParameterConfig() { ShownAtRunTime = true }; layerConfig.Name = param.Name; layerConfig.Label = layerConfig.DisplayName = string.IsNullOrEmpty(param.DisplayName) ? param.Name : param.DisplayName; layerConfig.Mode = ParameterSupport.FeatureLayerParameterConfig.InputMode.SketchLayer; layerConfig.Type = GPParameterType.FeatureLayer; layerConfig.Required = param.ParameterType == "esriGPParameterTypeRequired"; ESRI.ArcGIS.Mapping.GP.MetaData.GPFeatureRecordSetLayer frs = param.DefaultValue as ESRI.ArcGIS.Mapping.GP.MetaData.GPFeatureRecordSetLayer; if (frs != null) { if (frs.GeometryType == "esriGeometryPolyline") { layerConfig.GeometryType = ESRI.ArcGIS.Mapping.Core.GeometryType.Polyline; layerConfig.HelpText = Resources.Strings.DrawLine; } else if (frs.GeometryType == "esriGeometryPolygon") { layerConfig.GeometryType = ESRI.ArcGIS.Mapping.Core.GeometryType.Polygon; layerConfig.HelpText = Resources.Strings.DrawPolygon; } else if (frs.GeometryType == "esriGeometryPoint") { layerConfig.GeometryType = ESRI.ArcGIS.Mapping.Core.GeometryType.Point; layerConfig.HelpText = Resources.Strings.DrawPoint; } else if (frs.GeometryType == "esriGeometryMultipoint") { layerConfig.GeometryType = ESRI.ArcGIS.Mapping.Core.GeometryType.MultiPoint; layerConfig.HelpText = Resources.Strings.DrawPoint; } #region Layer with field info, geometry type and renderer GraphicsLayer layer = new GraphicsLayer(); if (frs.Fields != null && frs.Fields.Length > 0) { Collection <ESRI.ArcGIS.Mapping.Core.FieldInfo> fields = new Collection <ESRI.ArcGIS.Mapping.Core.FieldInfo>(); List <string> doubleFields = new List <string>(); List <string> singleFields = new List <string>(); foreach (MetaData.Field field in frs.Fields) { #region Get Single and Double Fields string type = field.Type; if (type.StartsWith(GPConfiguration.esriFieldType, StringComparison.Ordinal)) { type = type.Substring(GPConfiguration.esriFieldType.Length); ESRI.ArcGIS.Client.Field.FieldType fieldType = (ESRI.ArcGIS.Client.Field.FieldType)Enum.Parse(typeof(ESRI.ArcGIS.Client.Field.FieldType), type, true); if (fieldType == ESRI.ArcGIS.Client.Field.FieldType.Double) { doubleFields.Add(field.Name); } else if (fieldType == Client.Field.FieldType.Single) { singleFields.Add(field.Name); } } #endregion #region Get FieldInfos if (field.Type == "esriGeometry") { continue; } fields.Add(new ESRI.ArcGIS.Mapping.Core.FieldInfo() { DisplayName = field.Alias, FieldType = mapFieldType(field.Type), Name = field.Name, VisibleInAttributeDisplay = true, VisibleOnMapTip = true, }); #endregion } ESRI.ArcGIS.Mapping.Core.LayerExtensions.SetFields(layer, fields); layerConfig.SingleFields = singleFields.ToArray(); layerConfig.DoubleFields = doubleFields.ToArray(); } ESRI.ArcGIS.Mapping.Core.LayerExtensions.SetGeometryType(layer, layerConfig.GeometryType); layer.Renderer = FeatureLayerParameterConfig.GetSimpleRenderer(layerConfig.GeometryType); // Disable pop-ups by default for input layers if (param.Direction == "esriGPParameterDirectionInput") { LayerProperties.SetIsPopupEnabled(layer, false); } layerConfig.Layer = layer; #endregion } else { layerConfig.GeometryType = ESRI.ArcGIS.Mapping.Core.GeometryType.Unknown; layerConfig.HelpText = Resources.Strings.UnknownGeometryType; } layerConfig.LayerName = layerConfig.Label; layerConfig.ToolTip = layerConfig.HelpText; layerConfig.Opacity = 1; config = layerConfig; LayerOrder.Add(layerConfig.Name); #endregion } } else if (param.DataType == "GPRasterDataLayer" || param.DataType == "GPRasterData") { if (string.IsNullOrEmpty(serviceInfo.ResultMapServerName) || param.Direction == "esriGPParameterDirectionInput") { config = new RasterDataParameterConfig() { Name = param.Name, ShownAtRunTime = true, FormatToolTip = "e.g. tif, jpg", Type = param.DataType == "GPRasterDataLayer" ? GPParameterType.RasterDataLayer : GPParameterType.RasterData, ToolTip = param.DataType == "GPRasterDataLayer" ? Resources.Strings.EnterUrlForRasterDataLayer : Resources.Strings.EnterUrlForRasterData, HelpText = param.DataType == "GPRasterDataLayer" ? Resources.Strings.EnterUrlForRasterDataLayer : Resources.Strings.EnterUrlForRasterData, Label = param.DisplayName, DisplayName = param.DisplayName, Required = param.ParameterType == "esriGPParameterTypeRequired", Input = param.Direction == "esriGPParameterDirectionInput" }; } else if (string.IsNullOrEmpty(serviceInfo.CurrentVersion)) { MapServiceLayerParameterConfig layerConfig = new MapServiceLayerParameterConfig { Name = param.Name, LayerName = param.DisplayName, Type = GPParameterType.MapServiceLayer, SupportsJobResource = false, Opacity = 1, }; OutputParameters.Add(layerConfig); LayerOrder.Add(layerConfig.Name); } else { resultMapserviceLayerInfos.Add(ToLayerInfo(param, layerId++)); } } else { #region other param types if (param.DataType == "GPMultiValue:GPString") { config = new MultiValueStringConfig() { ShownAtRunTime = true } } ; else { config = new ParameterConfig() { ShownAtRunTime = true } }; config.Name = param.Name; config.Label = config.DisplayName = param.DisplayName; config.Required = param.ParameterType == "esriGPParameterTypeRequired"; string defaultString = param.DefaultValue == null ? null : param.DefaultValue.ToString(); switch (param.DataType) { #region case "GPBoolean": config.Type = GPParameterType.Boolean; if (param.DefaultValue != null) { config.DefaultValue = new Client.Tasks.GPBoolean(param.Name, (bool)param.DefaultValue); } break; case "GPDouble": config.Type = GPParameterType.Double; if (!string.IsNullOrEmpty(defaultString)) { double val = 0; if (double.TryParse(defaultString, System.Globalization.NumberStyles.Any, CultureHelper.GetCurrentCulture(), out val)) { config.DefaultValue = new Client.Tasks.GPDouble(param.Name, val); } } break; case "GPLong": config.Type = GPParameterType.Long; if (!string.IsNullOrEmpty(defaultString)) { int val = 0; if (int.TryParse(defaultString, out val)) { config.DefaultValue = new ESRI.ArcGIS.Client.Tasks.GPLong(param.Name, val); } } break; case "GPDate": config.Type = GPParameterType.Date; if (!string.IsNullOrEmpty(defaultString)) { long ticks = 0; if (long.TryParse(defaultString, out ticks)) { config.DefaultValue = new ESRI.ArcGIS.Client.Tasks.GPDate(param.Name, Epoch.AddMilliseconds(ticks)); } } break; case "GPLinearUnit": config.Type = GPParameterType.LinearUnit; if (param.DefaultValue is ESRI.ArcGIS.Mapping.GP.MetaData.GPLinearUnit) { ESRI.ArcGIS.Mapping.GP.MetaData.GPLinearUnit value = (param.DefaultValue as ESRI.ArcGIS.Mapping.GP.MetaData.GPLinearUnit); config.DefaultValue = new ESRI.ArcGIS.Client.Tasks.GPLinearUnit(param.Name, (ESRI.ArcGIS.Client.Tasks.esriUnits)(Enum.Parse(typeof(ESRI.ArcGIS.Client.Tasks.esriUnits), value.Units, true)), value.Distance); } break; case "GPString": config.Type = GPParameterType.String; config.DefaultValue = new ESRI.ArcGIS.Client.Tasks.GPString(param.Name, defaultString); if (param.ChoiceList != null && param.ChoiceList.Length > 0) { config.ChoiceList = new List <Choice>(param.ChoiceList.Length); for (int i = 0; i < param.ChoiceList.Length; i++) { config.ChoiceList.Add(new Choice() { DisplayText = param.ChoiceList[i], Value = new ESRI.ArcGIS.Client.Tasks.GPString(param.Name, param.ChoiceList[i]) }); } } break; case "GPMultiValue:GPString": config.Type = GPParameterType.MultiValueString; object[] defaultStrings = param.DefaultValue as object[]; // the default value could be an array of strings if (defaultStrings != null && defaultStrings.Length > 0) { List <GPString> list = (from string s in defaultStrings select new GPString(param.Name, s)).ToList(); config.DefaultValue = new GPMultiValue <GPString>(param.Name, list); } if (param.ChoiceList != null && param.ChoiceList.Length > 0) { config.ChoiceList = new List <Choice>(param.ChoiceList.Length); foreach (string t in param.ChoiceList) { config.ChoiceList.Add(new Choice { DisplayText = t, Value = new GPString(param.Name, t) }); } } break; case "GPRecordSet": config.Type = GPParameterType.RecordSet; config.ToolTip = config.HelpText = Resources.Strings.EnterUrlForRecordset; break; case "GPDataFile": config.Type = GPParameterType.DataFile; config.ToolTip = config.HelpText = Resources.Strings.EnterUrlForFile; break; default: break; #endregion } #endregion } if (config != null) { if (param.Direction == "esriGPParameterDirectionInput") { config.Input = true; InputParameters.Add(config); } else { config.Input = false; OutputParameters.Add(config); } } } } if (!string.IsNullOrEmpty(serviceInfo.ResultMapServerName) && !string.IsNullOrEmpty(serviceInfo.CurrentVersion)) { MapServiceLayerParameterConfig layerConfig = new MapServiceLayerParameterConfig { Name = serviceInfo.ResultMapServerName, LayerName = serviceInfo.ResultMapServerName, Type = GPParameterType.MapServiceLayer, LayerInfos = resultMapserviceLayerInfos, SupportsJobResource = true, Opacity = 1, }; OutputParameters.Add(layerConfig); LayerOrder.Add(layerConfig.Name); } #endregion }
public static ParameterConfig Create(IDictionary<string, object> dictionary) { GPParameterType type = GPParameterType.String; if (dictionary.ContainsKey("type")) type = (GPParameterType)(Enum.Parse(typeof(GPParameterType), dictionary["type"] as string, true)); ParameterConfig config = null; switch (type) { case GPParameterType.Boolean: case GPParameterType.Double: case GPParameterType.Long: case GPParameterType.String: case GPParameterType.Date: case GPParameterType.LinearUnit: case GPParameterType.RecordSet: case GPParameterType.DataFile: config = new ParameterConfig(); break; case GPParameterType.RasterData: case GPParameterType.RasterDataLayer: config = new RasterDataParameterConfig(); break; case GPParameterType.MultiValueString: config = new MultiValueStringConfig(); break; case GPParameterType.FeatureLayer: config = new FeatureLayerParameterConfig(); break; case GPParameterType.MapServiceLayer: config = new MapServiceLayerParameterConfig(); break; } if (config != null) config.FromJsonDictionary(dictionary); return config; }
public void LoadConfiguration(GP.MetaData.GPMetaData serviceInfo, Uri taskEndPoint) { if (serviceInfo == null) return; TaskEndPoint = taskEndPoint; TaskName = Title = serviceInfo.DisplayName; HelpUrl = serviceInfo.HelpUrl; if (InputParameters == null) InputParameters = new List<ParameterSupport.ParameterConfig>(); else InputParameters.Clear(); if (OutputParameters == null) OutputParameters = new List<ParameterSupport.ParameterConfig>(); else OutputParameters.Clear(); if (LayerOrder == null) LayerOrder = new ObservableCollection<string>(); else LayerOrder.Clear(); Collection<LayerInformation> resultMapserviceLayerInfos = string.IsNullOrEmpty(serviceInfo.ResultMapServerName) || string.IsNullOrEmpty(serviceInfo.CurrentVersion) ? null : new Collection<LayerInformation>(); #region Get parameter configs if (serviceInfo.Parameters != null) { int layerId = 0; foreach (ESRI.ArcGIS.Mapping.GP.MetaData.GPParameter param in serviceInfo.Parameters) { ParameterConfig config = null; if (param.DataType == "GPFeatureRecordSetLayer") { if (!string.IsNullOrEmpty(serviceInfo.ResultMapServerName) && param.Direction != "esriGPParameterDirectionInput") { if (!string.IsNullOrEmpty(serviceInfo.CurrentVersion)) // A resultmapservice can only be accessed at http://.../<resultMapservice>/MapServer/jobs/<jobId> when server version can be determined. resultMapserviceLayerInfos.Add(ToLayerInfo(param, layerId++)); else { MapServiceLayerParameterConfig layerConfig = new MapServiceLayerParameterConfig { Name = param.Name, LayerName = param.DisplayName, Type = GPParameterType.MapServiceLayer, SupportsJobResource = false, Opacity = 1, }; OutputParameters.Add(layerConfig); LayerOrder.Add(layerConfig.Name); } } else { #region No result GP mapserver GP.ParameterSupport.FeatureLayerParameterConfig layerConfig = new ParameterSupport.FeatureLayerParameterConfig() { ShownAtRunTime = true }; layerConfig.Name = param.Name; layerConfig.Label = layerConfig.DisplayName = string.IsNullOrEmpty(param.DisplayName) ? param.Name : param.DisplayName; layerConfig.Mode = ParameterSupport.FeatureLayerParameterConfig.InputMode.SketchLayer; layerConfig.Type = GPParameterType.FeatureLayer; layerConfig.Required = param.ParameterType == "esriGPParameterTypeRequired"; ESRI.ArcGIS.Mapping.GP.MetaData.GPFeatureRecordSetLayer frs = param.DefaultValue as ESRI.ArcGIS.Mapping.GP.MetaData.GPFeatureRecordSetLayer; if (frs != null) { if (frs.GeometryType == "esriGeometryPolyline") { layerConfig.GeometryType = ESRI.ArcGIS.Mapping.Core.GeometryType.Polyline; layerConfig.HelpText = Resources.Strings.DrawLine; } else if (frs.GeometryType == "esriGeometryPolygon") { layerConfig.GeometryType = ESRI.ArcGIS.Mapping.Core.GeometryType.Polygon; layerConfig.HelpText = Resources.Strings.DrawPolygon; } else if (frs.GeometryType == "esriGeometryPoint") { layerConfig.GeometryType = ESRI.ArcGIS.Mapping.Core.GeometryType.Point; layerConfig.HelpText = Resources.Strings.DrawPoint; } else if (frs.GeometryType == "esriGeometryMultipoint") { layerConfig.GeometryType = ESRI.ArcGIS.Mapping.Core.GeometryType.MultiPoint; layerConfig.HelpText = Resources.Strings.DrawPoint; } #region Layer with field info, geometry type and renderer GraphicsLayer layer = new GraphicsLayer(); if (frs.Fields != null && frs.Fields.Length > 0) { Collection<ESRI.ArcGIS.Mapping.Core.FieldInfo> fields = new Collection<ESRI.ArcGIS.Mapping.Core.FieldInfo>(); List<string> doubleFields = new List<string>(); List<string> singleFields = new List<string>(); foreach (MetaData.Field field in frs.Fields) { #region Get Single and Double Fields string type = field.Type; if (type.StartsWith(GPConfiguration.esriFieldType, StringComparison.Ordinal)) { type = type.Substring(GPConfiguration.esriFieldType.Length); ESRI.ArcGIS.Client.Field.FieldType fieldType = (ESRI.ArcGIS.Client.Field.FieldType)Enum.Parse(typeof(ESRI.ArcGIS.Client.Field.FieldType), type, true); if (fieldType == ESRI.ArcGIS.Client.Field.FieldType.Double) doubleFields.Add(field.Name); else if (fieldType == Client.Field.FieldType.Single) singleFields.Add(field.Name); } #endregion #region Get FieldInfos if (field.Type == "esriGeometry") continue; fields.Add(new ESRI.ArcGIS.Mapping.Core.FieldInfo() { DisplayName = field.Alias, FieldType = mapFieldType(field.Type), Name = field.Name, VisibleInAttributeDisplay = true, VisibleOnMapTip = true, }); #endregion } ESRI.ArcGIS.Mapping.Core.LayerExtensions.SetFields(layer, fields); layerConfig.SingleFields = singleFields.ToArray(); layerConfig.DoubleFields = doubleFields.ToArray(); } ESRI.ArcGIS.Mapping.Core.LayerExtensions.SetGeometryType(layer, layerConfig.GeometryType); layer.Renderer = FeatureLayerParameterConfig.GetSimpleRenderer(layerConfig.GeometryType); // Disable pop-ups by default for input layers if (param.Direction == "esriGPParameterDirectionInput") LayerProperties.SetIsPopupEnabled(layer, false); layerConfig.Layer = layer; #endregion } else { layerConfig.GeometryType = ESRI.ArcGIS.Mapping.Core.GeometryType.Unknown; layerConfig.HelpText = Resources.Strings.UnknownGeometryType; } layerConfig.LayerName = layerConfig.Label; layerConfig.ToolTip = layerConfig.HelpText; layerConfig.Opacity = 1; config = layerConfig; LayerOrder.Add(layerConfig.Name); #endregion } } else if (param.DataType == "GPRasterDataLayer" || param.DataType == "GPRasterData") { if (string.IsNullOrEmpty(serviceInfo.ResultMapServerName) || param.Direction == "esriGPParameterDirectionInput") { config = new RasterDataParameterConfig() { Name = param.Name, ShownAtRunTime = true, FormatToolTip = "e.g. tif, jpg", Type = param.DataType == "GPRasterDataLayer" ? GPParameterType.RasterDataLayer : GPParameterType.RasterData, ToolTip = param.DataType == "GPRasterDataLayer" ? Resources.Strings.EnterUrlForRasterDataLayer : Resources.Strings.EnterUrlForRasterData, HelpText = param.DataType == "GPRasterDataLayer" ? Resources.Strings.EnterUrlForRasterDataLayer : Resources.Strings.EnterUrlForRasterData, Label = param.DisplayName, DisplayName = param.DisplayName, Required = param.ParameterType == "esriGPParameterTypeRequired", Input = param.Direction == "esriGPParameterDirectionInput" }; } else if (string.IsNullOrEmpty(serviceInfo.CurrentVersion)) { MapServiceLayerParameterConfig layerConfig = new MapServiceLayerParameterConfig { Name = param.Name, LayerName = param.DisplayName, Type = GPParameterType.MapServiceLayer, SupportsJobResource = false, Opacity = 1, }; OutputParameters.Add(layerConfig); LayerOrder.Add(layerConfig.Name); } else resultMapserviceLayerInfos.Add(ToLayerInfo(param, layerId++)); } else { #region other param types if (param.DataType == "GPMultiValue:GPString") config = new MultiValueStringConfig() { ShownAtRunTime = true }; else config = new ParameterConfig() { ShownAtRunTime = true }; config.Name = param.Name; config.Label = config.DisplayName = param.DisplayName; config.Required = param.ParameterType == "esriGPParameterTypeRequired"; string defaultString = param.DefaultValue == null ? null : param.DefaultValue.ToString(); switch (param.DataType) { #region case "GPBoolean": config.Type = GPParameterType.Boolean; if (param.DefaultValue != null) config.DefaultValue = new Client.Tasks.GPBoolean(param.Name, (bool)param.DefaultValue); break; case "GPDouble": config.Type = GPParameterType.Double; if (!string.IsNullOrEmpty(defaultString)) { double val = 0; if (double.TryParse(defaultString, System.Globalization.NumberStyles.Any, CultureHelper.GetCurrentCulture(), out val)) config.DefaultValue = new Client.Tasks.GPDouble(param.Name, val); } break; case "GPLong": config.Type = GPParameterType.Long; if (!string.IsNullOrEmpty(defaultString)) { int val = 0; if (int.TryParse(defaultString, out val)) config.DefaultValue = new ESRI.ArcGIS.Client.Tasks.GPLong(param.Name, val); } break; case "GPDate": config.Type = GPParameterType.Date; if (!string.IsNullOrEmpty(defaultString)) { long ticks = 0; if (long.TryParse(defaultString, out ticks)) config.DefaultValue = new ESRI.ArcGIS.Client.Tasks.GPDate(param.Name, Epoch.AddMilliseconds(ticks)); } break; case "GPLinearUnit": config.Type = GPParameterType.LinearUnit; if (param.DefaultValue is ESRI.ArcGIS.Mapping.GP.MetaData.GPLinearUnit) { ESRI.ArcGIS.Mapping.GP.MetaData.GPLinearUnit value = (param.DefaultValue as ESRI.ArcGIS.Mapping.GP.MetaData.GPLinearUnit); config.DefaultValue = new ESRI.ArcGIS.Client.Tasks.GPLinearUnit(param.Name, (ESRI.ArcGIS.Client.Tasks.esriUnits)(Enum.Parse(typeof(ESRI.ArcGIS.Client.Tasks.esriUnits), value.Units, true)), value.Distance); } break; case "GPString": config.Type = GPParameterType.String; config.DefaultValue = new ESRI.ArcGIS.Client.Tasks.GPString(param.Name, defaultString); if (param.ChoiceList != null && param.ChoiceList.Length > 0) { config.ChoiceList = new List<Choice>(param.ChoiceList.Length); for (int i = 0; i < param.ChoiceList.Length; i++) { config.ChoiceList.Add(new Choice() { DisplayText = param.ChoiceList[i], Value = new ESRI.ArcGIS.Client.Tasks.GPString(param.Name, param.ChoiceList[i]) }); } } break; case "GPMultiValue:GPString": config.Type = GPParameterType.MultiValueString; object[] defaultStrings = param.DefaultValue as object[]; // the default value could be an array of strings if (defaultStrings != null && defaultStrings.Length > 0) { List<GPString> list = (from string s in defaultStrings select new GPString(param.Name, s)).ToList(); config.DefaultValue = new GPMultiValue<GPString>(param.Name, list); } if (param.ChoiceList != null && param.ChoiceList.Length > 0) { config.ChoiceList = new List<Choice>(param.ChoiceList.Length); foreach (string t in param.ChoiceList) { config.ChoiceList.Add(new Choice { DisplayText = t, Value = new GPString(param.Name, t) }); } } break; case "GPRecordSet": config.Type = GPParameterType.RecordSet; config.ToolTip = config.HelpText = Resources.Strings.EnterUrlForRecordset; break; case "GPDataFile": config.Type = GPParameterType.DataFile; config.ToolTip = config.HelpText = Resources.Strings.EnterUrlForFile; break; default: break; #endregion } #endregion } if (config != null) { if (param.Direction == "esriGPParameterDirectionInput") { config.Input = true; InputParameters.Add(config); } else { config.Input = false; OutputParameters.Add(config); } } } } if (!string.IsNullOrEmpty(serviceInfo.ResultMapServerName) && !string.IsNullOrEmpty(serviceInfo.CurrentVersion)) { MapServiceLayerParameterConfig layerConfig = new MapServiceLayerParameterConfig { Name = serviceInfo.ResultMapServerName, LayerName = serviceInfo.ResultMapServerName, Type = GPParameterType.MapServiceLayer, LayerInfos = resultMapserviceLayerInfos, SupportsJobResource = true, Opacity = 1, }; OutputParameters.Add(layerConfig); LayerOrder.Add(layerConfig.Name); } #endregion }