private byte[] OperazioneRestDownloadFeatureHandler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { responseProperties = null; #region Istanzio il JSON Result JsonObject result = new JsonObject(); result.AddBoolean("hasError", false); #endregion bool found = operationInput.TryGetArray("listaOID", out object[] paramListaOID); if (!found || paramListaOID == null) { throw new ArgumentNullException("listaOID"); } bool okParam2 = operationInput.TryGetString("URLServiceLayer", out string paramURL); if (!okParam2 || paramURL == String.Empty) { throw new ArgumentNullException("URLServiceLayer"); } IGeoProcessor2 gp = new GeoProcessor() as IGeoProcessor2; gp.OverwriteOutput = true; try { result.AddArray("interno", paramListaOID); // Ricavo Feature Class dietro al Service Layer IFeatureClass featureClass = MapServiceHelper_GiancaGIS.RicavaFCDaURLServiceLayer(this.serverObjectHelper, paramURL); IFeatureLayer fLayer = new FeatureLayerClass { FeatureClass = featureClass, Name = "Mio Layer", SpatialReference = ((IGeoDataset)featureClass).SpatialReference }; IFeatureSelection featureSelection = fLayer as IFeatureSelection; IQueryFilter2 queryFilter = new QueryFilterClass { WhereClause = "OBJECTID IN (" + String.Join(",", paramListaOID) + ")" }; featureSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultNew, false); this.CreaWorkSpaceOutput(out IWorkspaceName WorkspaceNameOUT, out string pathFGDB); IVariantArray parameters = new VarArrayClass(); parameters.Add(fLayer); parameters.Add(System.IO.Path.Combine(pathFGDB, "output")); gp.Execute("CopyFeatures_management", parameters, null); this.ZippaFGDB(System.IO.Path.GetDirectoryName(pathFGDB), out string pathZip); result.AddString("zip", pathZip); } catch (Exception errore) { object severity = null; string errGp = gp.GetMessages(ref severity); if (!string.IsNullOrEmpty(errGp)) { result.AddBoolean("GeoProcessingError", true); result.AddString("erroreGp", errGp); } result.AddString("errorDescription", errore.Message); result.AddBoolean("hasError", true); } return(Encoding.UTF8.GetBytes(result.ToJson())); }