コード例 #1
0
        public string PublishMapToServer(string sAgsConn, string sServiceName, string sMxd, string sOutputSdDir, string sPublishFolder, string sPythonScriptFile)
        {
            RunPython pRunPython = null;

            try
            {
                // Set Args for python
                string sArgs = "\"" + sPythonScriptFile + "\" \"" + sMxd + "\" \"" +
                               sOutputSdDir + "\" \"" + sAgsConn + "\" \"" +
                               sServiceName + "\" \"" + sPublishFolder + "\"";

                // Run PublishMxd python script
                bool bOk = false;
                pRunPython = new RunPython();
                bOk        = pRunPython.RunScript(sArgs);

                if (bOk)
                {
                    return(pRunPython.StdOutput);
                }
                else
                {
                    return("Error: " + pRunPython.ErrOutput);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        public bool CreateMxd(string sMxdTemplate,
                              string sPathToMXD,
                              string ArcGISServer,
                              string sMxdFile,
                              string sDBConn,
                              string sDataSet,
                              string sPythonScriptDir,
                              bool bSde)
        {
            if (sMxdTemplate.Length > 0) _sMxdTemplate = sMxdTemplate;

            _sPathToMXD = sPathToMXD;
            _ArcGISServer = ArcGISServer;
            RunPython pRunPython = null;

            try
            {
                // TODO:
                // Verify we have dataset, feature classes, and records
                // Set Args for python
                string sArgs = "\"" + Path.Combine(sPythonScriptDir, CHECKFORDATA_PY) + "\" \"" + sDBConn + "\" \"" + sDataSet + "\"";

                // Run CheckForData python script
                bool bOk = false;
                pRunPython = new RunPython();
                bOk = pRunPython.RunScript(sArgs);

                if (!(bOk)) throw new ApplicationException("Error: Data check failed for " + sMxdFile + Environment.NewLine + pRunPython.ErrOutput);

                // Check if Mxd already exists
                if (File.Exists(sMxdFile)) throw new ApplicationException("Error: " + sMxdFile + " already exists!");
                
                // Create a Mxd from Template
                if (!(PrivateCreateMxd(sMxdFile))) throw new ApplicationException("Error creating Mxd file from template");

                // Set Args for python
                sArgs = "\"" + Path.Combine(sPythonScriptDir, CHANGEDATASOURCE_PY) + "\" \"" + _sNewDocument + "\" \"" + sDBConn + "\" \"" + sDataSet + "\" " + bSde;

                // Run ChangeDatasource python script
                bOk = false;
                pRunPython = new RunPython();
                bOk = pRunPython.RunScript(sArgs);

                if (!(bOk)) throw new ApplicationException("Error changing datasources in " + sMxdFile + Environment.NewLine + pRunPython.ErrOutput);
                
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public void DeleteFeatureDataset(string sFeatureDataset, string sConnectionFile, string sPythonScriptDir)
        {
            RunPython pRunPython = null;

            // Set PythonScript
            string sDeleteDataPyScript = Path.Combine(sPythonScriptDir, "");

            // Set Args for python
            string sArgs = "\"" + sDeleteDataPyScript + "\" \"" + sConnectionFile + "\" \"" + sFeatureDataset + "\"";

            // Run DeleteData python script
            bool bOk = false;

            pRunPython = new RunPython();
            bOk        = pRunPython.RunScript(sArgs);

            if (!(bOk))
            {
                throw new ApplicationException("Error removing dataset " + sFeatureDataset + Environment.NewLine + pRunPython.ErrOutput);
            }
        }
コード例 #4
0
        public string UnPublish(string sServer, string sServerURL, string sServiceName, string sServiceFolder, string sAgsAdminUser, string sAgsAdminPwd, string sPythonScriptFile)
        {
            //Python Args: -u http://robertb:6080/arcgis -n arcgis -p arcgis -s EmergencyTempWork_1 -f
            RunPython pRunPython = null;

            try
            {
                // Check is service exists
                if (Exists(sServer, sServiceName, sServiceFolder))
                {
                    // Set Args for python
                    string sArgs = "\"" + sPythonScriptFile + "\" -u " + sServerURL + " " +
                                    "-n " + sAgsAdminUser + " -p " + sAgsAdminPwd + " " +
                                    "-s \"" + sServiceName + "\" -f \"" + sServiceFolder + "\"";

                    // Run UnPublish python script
                    bool bOk = false;
                    pRunPython = new RunPython();
                    bOk = pRunPython.RunScript(sArgs);

                    if (bOk)
                    {
                        return pRunPython.StdOutput;
                    }
                    else
                    {
                        return "Error: " + pRunPython.ErrOutput;
                    }
                }

                return "Service " + sServiceName + " does not exist!";
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
0
        public string UnPublish(string sServer, string sServerURL, string sServiceName, string sServiceFolder, string sAgsAdminUser, string sAgsAdminPwd, string sPythonScriptFile)
        {
            //Python Args: -u http://robertb:6080/arcgis -n arcgis -p arcgis -s EmergencyTempWork_1 -f
            RunPython pRunPython = null;

            try
            {
                // Check is service exists
                if (Exists(sServer, sServiceName, sServiceFolder))
                {
                    // Set Args for python
                    string sArgs = "\"" + sPythonScriptFile + "\" -u " + sServerURL + " " +
                                   "-n " + sAgsAdminUser + " -p " + sAgsAdminPwd + " " +
                                   "-s \"" + sServiceName + "\" -f \"" + sServiceFolder + "\"";

                    // Run UnPublish python script
                    bool bOk = false;
                    pRunPython = new RunPython();
                    bOk        = pRunPython.RunScript(sArgs);

                    if (bOk)
                    {
                        return(pRunPython.StdOutput);
                    }
                    else
                    {
                        return("Error: " + pRunPython.ErrOutput);
                    }
                }

                return("Service " + sServiceName + " does not exist!");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #6
0
        public string PublishMapToServer(string sAgsConn, string sServiceName, string sMxd, string sOutputSdDir, string sPublishFolder, string sPythonScriptFile)
        {
            RunPython pRunPython = null;

            try
            {
                // Set Args for python
                string sArgs = "\"" + sPythonScriptFile + "\" \"" + sMxd + "\" \"" +
                                sOutputSdDir + "\" \"" + sAgsConn + "\" \"" +
                                sServiceName + "\" \"" + sPublishFolder + "\"";

                // Run PublishMxd python script
                bool bOk = false;
                pRunPython = new RunPython();
                bOk = pRunPython.RunScript(sArgs);

                if (bOk)
                {
                    return pRunPython.StdOutput;
                }
                else
                {
                    return "Error: " + pRunPython.ErrOutput;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
コード例 #7
0
        public bool CreateMxd(string sMxdTemplate,
                              string sPathToMXD,
                              string ArcGISServer,
                              string sMxdFile,
                              string sDBConn,
                              string sDataSet,
                              string sPythonScriptDir,
                              bool bSde)
        {
            if (sMxdTemplate.Length > 0)
            {
                _sMxdTemplate = sMxdTemplate;
            }

            _sPathToMXD   = sPathToMXD;
            _ArcGISServer = ArcGISServer;
            RunPython pRunPython = null;

            try
            {
                // TODO:
                // Verify we have dataset, feature classes, and records
                // Set Args for python
                string sArgs = "\"" + Path.Combine(sPythonScriptDir, CHECKFORDATA_PY) + "\" \"" + sDBConn + "\" \"" + sDataSet + "\"";

                // Run CheckForData python script
                bool bOk = false;
                pRunPython = new RunPython();
                bOk        = pRunPython.RunScript(sArgs);

                if (!(bOk))
                {
                    throw new ApplicationException("Error: Data check failed for " + sMxdFile + Environment.NewLine + pRunPython.ErrOutput);
                }

                // Check if Mxd already exists
                if (File.Exists(sMxdFile))
                {
                    throw new ApplicationException("Error: " + sMxdFile + " already exists!");
                }

                // Create a Mxd from Template
                if (!(PrivateCreateMxd(sMxdFile)))
                {
                    throw new ApplicationException("Error creating Mxd file from template");
                }

                // Set Args for python
                sArgs = "\"" + Path.Combine(sPythonScriptDir, CHANGEDATASOURCE_PY) + "\" \"" + _sNewDocument + "\" \"" + sDBConn + "\" \"" + sDataSet + "\" " + bSde;

                // Run ChangeDatasource python script
                bOk        = false;
                pRunPython = new RunPython();
                bOk        = pRunPython.RunScript(sArgs);

                if (!(bOk))
                {
                    throw new ApplicationException("Error changing datasources in " + sMxdFile + Environment.NewLine + pRunPython.ErrOutput);
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #8
0
        public void DeleteFeatureDataset(string sFeatureDataset, string sConnectionFile, string sPythonScriptDir)
        {
            RunPython pRunPython = null;

            // Set PythonScript
            string sDeleteDataPyScript = Path.Combine(sPythonScriptDir, "");

            // Set Args for python
            string sArgs = "\"" + sDeleteDataPyScript + "\" \"" + sConnectionFile + "\" \"" + sFeatureDataset + "\"";

            // Run DeleteData python script
            bool bOk = false;
            pRunPython = new RunPython();
            bOk = pRunPython.RunScript(sArgs);

            if (!(bOk)) throw new ApplicationException("Error removing dataset " + sFeatureDataset + Environment.NewLine + pRunPython.ErrOutput);            
        }