AnsweredAssumed Answered

how to use code(engine or arcobjects) to publish a server into a folder

Question asked by sd1036770 on May 4, 2015

below is my code,thanks

question.png

 

IServerObjectConfiguration2 pSOC = null;


                    try
                   {
                        pSOC = pSOA.GetConfiguration(fileName.Replace(sFileBack, ""), "MapServer") as IServerObjectConfiguration2;
                    }
                    catch
                    {
                        
                    }


                    if (pSOC != null)
                    {
                        //pSOA.DeleteConfiguration(fileName.Replace(sFileBack, ""), "MapServer");
                        continue;
                    }
                    pSOC = pSOA.CreateConfiguration() as IServerObjectConfiguration2;
                    pSOC.Name = fileName.Replace(sFileBack, "");
                    pSOC.TypeName = "MapServer";


                    IPropertySet pProperty = pSOC.Properties;
                    pProperty.SetProperty("FilePath", sNewMxdPath);
                    pProperty.SetProperty("OutputDir", @"F:\arcgisserver\arcgisoutput");
                    pSOC.IsolationLevel = esriServerIsolationLevel.esriServerIsolationHigh;
                    pSOC.IsPooled = true;
                    pSOC.MaxInstances = 2;
                    pSOC.MinInstances = 1;


                    IPropertySet pRecycleProperty = pSOC.RecycleProperties;
                    pRecycleProperty.SetProperty("StartTime", "00:00");
                    pRecycleProperty.SetProperty("Interval", "3600");


                    IPropertySet pInfoProperty = pSOC.Info;
                    pInfoProperty.SetProperty("WebEnabled", "true");
                    pInfoProperty.SetProperty("WebCapabilities", "Map,Query,Data");
                    //pInfoProperty.SetProperty("URL", string.Format("http://{0}/arcgis/services/{1}/{2}/MapServer", sServer, sServerFolder, fileName.Replace(sFileBack, "")));


                    pSOC.StartupType = esriStartupType.esriSTAutomatic;
                    pSOC.UsageTimeout = 120;
                    pSOC.WaitTimeout = 120;


                    //WMS
                    IPropertySet pWmsProperty = new PropertySetClass();
                    pWmsProperty.SetProperty("Name", "WMS");
                    pWmsProperty.SetProperty("Title", (sServerFolder == "" ? "" : sServerFolder + "_") + fileName.Replace(sFileBack, ""));
                    pWmsProperty.SetProperty("OnlineResource", string.Format("http://{0}/arcgis/services{1}/{2}/MapServer/WMSServer", sServer, (sServerFolder == "" ? "" : @"/" + sServerFolder), fileName.Replace(sFileBack, "")));
                    pSOC.set_ExtensionEnabled("WMSServer", true);
                    pSOC.set_ExtensionProperties("WMSServer", pWmsProperty);


                    //IPropertySet pWmsInfo = new PropertySetClass();
                    //pWmsInfo.SetProperty("URL", string.Format("http://{0}/arcgis/services/{1}/{2}/MapServer/WMSServer", sServer, sServerFolder, fileName.Replace(sFileBack, "")));
                    //pSOC.set_ExtensionInfo("WMSServer", pWmsInfo);


                    pSOA.AddConfiguration(pSOC);
                    pSOA.StartConfiguration(fileName.Replace(sFileBack, ""), "MapServer");

Outcomes