示例#1
0
        /// <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);
        }
示例#2
0
 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);
 }
示例#3
0
 /// <summary>
 /// explicitly delete all services first, then delete all service host on all portentities.
 /// </summary>
 public static void DeleteAllServiceHost()
 {
     //delete all services
     while (Services != null && Services.Count > 0)
     {
         DeleteService(Services[0].Port, Services[0].ServiceName);
     }
     if (PortEntities != null)
     {
         List <int> ports = PortEntities.Keys.ToList();
         for (int i = 0; i < ports.Count; i++)
         {
             PortEntities[ports[i]].ServiceProvider.Services.Clear();
             PortEntities[ports[i]].ServiceHost.Close();
             PortEntities.Remove(ports[i]);
         }
     }
 }
示例#4
0
        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);
        }