/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="port"></param> /// <param name="strType">DataSourceType enum + custom online maps</param> /// <param name="dataSorucePath"></param> /// <param name="disableClientCache"></param> /// <param name="displayNoDataTile"></param> /// <param name="style"></param> /// <param name="tilingSchemePath">Set this parameter only when type is ArcGISDynamicMapService and do not use Google Maps's tiling scheme</param> /// <returns>errors or warnings. string.empty if nothing wrong.</returns> public static string CreateService(string name, int port, string strType, string dataSorucePath, bool allowMemoryCache, bool disableClientCache, bool displayNoDataTile, VisualStyle style, string tilingSchemePath = null) { PBSServiceProvider serviceProvider = null; string str; if (!PortEntities.ContainsKey(port)) { str = StartServiceHost(port); if (str != string.Empty) { return(str); } } serviceProvider = PortEntities[port].ServiceProvider; if (serviceProvider.Services.ContainsKey(name)) { return("Servicename already exists!"); } PBSService service; try { service = new PBSService(name, dataSorucePath, port, strType, allowMemoryCache, disableClientCache, displayNoDataTile, style, tilingSchemePath); } catch (Exception e)//in case of reading conf.xml or conf.cdi file error|| reading a sqlite db error { Utility.Log(LogLevel.Error, null, "Creating New Service(" + name + ") Error!\r\nData Source: " + dataSorucePath + "\r\n\r\n" + e.Message); return("Creating New Service(" + name + ") Error!\r\nData Source: " + dataSorucePath + "\r\n\r\n" + e.Message); } serviceProvider.Services.Add(name, service); //for process http request Services.Add(service); //for ui binding return(string.Empty); }
public static string DeleteService(int port, string name) { if (!PortEntities.ContainsKey(port)) { return("Port " + port + " is not started yet."); } if (!PortEntities[port].ServiceProvider.Services.ContainsKey(name)) { return("Service " + name + "does not exists on port " + port + "."); } Services.Remove(PortEntities[port].ServiceProvider.Services[name]); PortEntities[port].ServiceProvider.Services[name].Dispose(); PortEntities[port].ServiceProvider.Services.Remove(name); return(string.Empty); }
public static string StartServiceHost(int port) { if (Services == null) { Services = new MTObservableCollection <PBSService>(); } //create one webservicehost to corresponding port number first if (!PortEntities.ContainsKey(port)) { //Self Hosted WCF REST Service or Hosting WCF REST Service in Console Application //http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/1407/ try { //WebServiceHost host = new WebServiceHost(serviceProvider, new Uri("http://*****:*****@" + port + " already exist!"); } return(string.Empty); }