public string PublishMap10_1(string sServiceName, string sServer, string sMxd, string sMxdOutputDir, string sAgsConnFile, string sPythonScriptFile) { string sPubResults = string.Empty; if (sServer != null) { _ArcGISServer = sServer; } if (sMxd != null) { _sNewDocument = sMxd; } if (sServiceName != null) { _sTable = sServiceName; } try { MapService10_1 pService = new MapService10_1(); // Check if MapService already exists if (pService.Exists(_ArcGISServer, _sTable)) { return("Service " + _sTable + " already exists."); } // Publish Map sPubResults = pService.PublishMapToServer(sAgsConnFile, sServiceName, _sNewDocument, sMxdOutputDir, "", sPythonScriptFile); // If Not empty then return now if (!(string.IsNullOrEmpty(sPubResults))) { return(sPubResults); } // Return URL return("http://" + _ArcGISServer + ":6080/arcgis/rest/services/" + _sTable + "/FeatureServer"); } catch (Exception ex) { throw ex; } }
public void DeleteService(string sArcGisServer, string sAgsInstance, string sConfigID, string sFeatureDataset, string sServiceName, string sMxdOutput, string sSDEConnection, string sAgsUser, string sAgsPwd, string sPythonScriptDir) { // Check if service name starts with http:// if (sServiceName.IndexOf("http://") > 1) { throw new ApplicationException("Service name did not begin with the expected http://! ServiceName: " + sServiceName); } // Parse out service name if (sServiceName.Contains("/")) { sServiceName = sServiceName.Substring(0, (sServiceName.LastIndexOf("/"))); sServiceName = sServiceName.Substring(sServiceName.LastIndexOf("/") + 1); } // Set AgsURL string sAgsUrl = "http://" + sArcGisServer + ":6080/" + sAgsInstance; // Stop and Unpublish ServicePublisher.MXD.MapService10_1 mapService = null; mapService = new MXD.MapService10_1(); mapService.UnPublish(sArcGisServer, sAgsUrl, sServiceName, "", sAgsUser, sAgsPwd, System.IO.Path.Combine(sPythonScriptDir, UNPUBLISHSVC_PY)); // Make sure MXD is deleted ServicePublisher.MXD.MxdManager mxdManager = null; mxdManager = new MXD.MxdManager(); mxdManager.DeleteMxd(sMxdOutput, sServiceName); // Delete the DataSet from the connection as well mxdManager.DeleteFeatureDataset(sFeatureDataset, sSDEConnection, System.IO.Path.Combine(sPythonScriptDir, REMOVEDATA_PY)); }
public string PublishMap10_1(string sServiceName, string sServer, string sMxd, string sMxdOutputDir, string sAgsConnFile, string sPythonScriptFile) { string sPubResults = string.Empty; if (sServer != null) _ArcGISServer = sServer; if (sMxd != null) _sNewDocument = sMxd; if (sServiceName != null) _sTable = sServiceName; try { MapService10_1 pService = new MapService10_1(); // Check if MapService already exists if (pService.Exists(_ArcGISServer, _sTable)) { return "Service " + _sTable + " already exists."; } // Publish Map sPubResults = pService.PublishMapToServer(sAgsConnFile, sServiceName, _sNewDocument, sMxdOutputDir, "", sPythonScriptFile); // If Not empty then return now if (!(string.IsNullOrEmpty(sPubResults))) { return sPubResults; } // Return URL return "http://" + _ArcGISServer + ":6080/arcgis/rest/services/" + _sTable + "/FeatureServer"; } catch (Exception ex) { throw ex; } }