示例#1
0
        public static List <Models.Nipps> ListNipps()
        {
            List <Models.Nipps> nippsList = new List <Models.Nipps>();

            NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();

            try
            {
                //get list of the service-hosts
                List <NippsParameter> nippsHosts = NippsSiteHelper.ListNippsHost();

                foreach (NippsParameter nippsHost in nippsHosts)
                {
                    foreach (string value in nippsHost.ParameterValue.Split('|'))
                    {
                        try
                        {
                            //get applications from the host
                            List <NippsSite> nippsSites = NippsSiteHelper.ListNippsSite(value);
                            foreach (NippsSite nippsSite in nippsSites)
                            {
                                foreach (NippsApplication nippsApplication in nippsSite.NippsApplications)
                                {
                                    //add only netas ip phone service application to the result list
                                    if (nippsApplication.Path.StartsWith("/Netas.Nipps.Service."))
                                    {
                                        Models.Nipps nipps = new Models.Nipps
                                        {
                                            HostName            = value,
                                            ApplicationName     = nippsApplication.Path,
                                            ApplicationPoolName = nippsApplication.ApplicationPoolName,
                                            SiteName            = nippsSite.Name,
                                            State        = nippsApplication.ApplicationPoolState,
                                            PhysicalPath = nippsApplication.PhysicalPath,
                                            Version      = nippsApplication.Version,
                                            ModuleId     = -1
                                        };
                                        nippsList.Add(nipps);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.Error("{0}: {1}", value, ex.ToString());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("{0}", ex.ToString());
            }

            return(nippsList);
        }
示例#2
0
        public static string ServiceBaseUrl(string hostName, string siteName, string appName)
        {
            //find site from given host
            NippsSite nippsSite = NippsSiteHelper.ListNippsSite(hostName)
                                  .Where(s => s.Name.Equals(siteName))
                                  .Single();

            //build url from site bindings
            string baseUrl = nippsSite.Protocol
                             + "://" + hostName
                             + ":" + nippsSite.Port + appName;

            return(baseUrl);
        }