Beispiel #1
0
        private static string[] GetBaseAddresses(ServiceDeploymentConfiguration item)
        {
            var host = new HostElement();

            host.DeserializeElement(item.HostXML);
            return(WcfServiceHelper.GetBaseAddressesFromHostElement(host));
        }
Beispiel #2
0
        private string GetServiceDeployPath(ServiceDeploymentConfiguration item)
        {
            string address = null;

            if (!string.IsNullOrEmpty(item.ListenUri))
            {
                if (item.ListenUri.Contains("://")) //is absolute url
                {
                    address = item.ListenUri;
                }
                else // is relative url to baseAddress
                {
                    if (!string.IsNullOrEmpty(item.HostXML))
                    {
                        var baseAddresses = GetBaseAddresses(item);
                        if (baseAddresses.Length > 0)
                        {
                            address = baseAddresses[0].TrimEnd('/') + "/" + item.ListenUri;
                        }
                    }
                }
            }
            else //use first baseAddress directly
            {
                var baseAddresses = GetBaseAddresses(item);
                if (baseAddresses.Length > 0)
                {
                    address = baseAddresses[0];
                }
            }

            var deployPath = GetDeployPathFromAddress(address);

            return(deployPath);
        }
Beispiel #3
0
        /// <summary>
        /// Gets the service deployment configuration.
        /// </summary>
        /// <param name="appCode">The app code.</param>
        /// <returns></returns>
        public IList <ServiceDeploymentConfiguration> GetServiceDeploymentConfiguration(string appCode)
        {
            var list = new List <ServiceDeploymentConfiguration>();

            using (var conn = new SqlConnection(WcfServiceHelper.GetConfigurationConnectionString()))
            {
                conn.Open();

                var context = new StoredProceduresDataContext(conn);
                var results = context.sp_GetServiceDeploymentConfiguration(
                    Environment.MachineName.ToLowerInvariant(), appCode);

                foreach (var result in results)
                {
                    var serviceDeployment = new ServiceDeploymentConfiguration
                    {
                        ServiceName     = result.ServiceName,
                        HostXML         = result.HostXML,
                        EndpointAddress = result.EndpointAddress,
                        ListenUri       = result.ListenUri
                    };

                    list.Add(serviceDeployment);
                }

                conn.Close();
                conn.Dispose();
            }

            return(list);
        }