Ejemplo n.º 1
0
        static SIPSqlite()
        {
            string path = AppDomain.CurrentDomain.BaseDirectory + "Config\\";

            m_storageType = (AppState.GetConfigSetting(m_storageTypeKey) != null) ? StorageTypesConverter.GetStorageType(AppState.GetConfigSetting(m_storageTypeKey)) : StorageTypes.Unknown;
            m_connStr     = AppState.GetConfigSetting(m_connStrKey);
            if (m_storageType == StorageTypes.SQLite)
            {
                m_connStr = string.Format(m_connStr, path);
            }
            if (m_storageType == StorageTypes.Unknown || m_connStr.IsNullOrBlank())
            {
                throw new ApplicationException("The SIP Registrar cannot start with no persistence settings.");
            }
        }
Ejemplo n.º 2
0
        // here init the gb28181.xml file setting from app.config
        static SipAccountStorage()
        {
            m_storageType = (AppState.GetConfigSetting(m_storageTypeKey) != null) ? StorageTypesConverter.GetStorageType(AppState.GetConfigSetting(m_storageTypeKey)) : StorageTypes.Unknown;

            var rootPath = AppDomain.CurrentDomain.BaseDirectory;

            m_connStr = Path.Combine(rootPath, AppState.GetConfigSetting(m_connStrKey));
            if (m_storageType == StorageTypes.SQLite)
            {
                m_connStr = string.Format(m_connStr, rootPath);
            }
            if (m_storageType == StorageTypes.Unknown || m_connStr.IsNullOrBlank())
            {
                throw new ApplicationException("The SIP Registrar cannot start with no persistence settings.");
            }
        }
Ejemplo n.º 3
0
        private void Initialize()
        {
            _deviceList = new List <string>();
            m_sipRegistrarStorageType = (AppState.GetConfigSetting(m_storageTypeKey) != null) ?
                                        StorageTypesConverter.GetStorageType(AppState.GetConfigSetting(m_storageTypeKey)) :
                                        StorageTypes.Unknown;
            m_sipRegistrarStorageConnStr = AppState.GetConfigSetting(m_connStrKey);

            if (m_sipRegistrarStorageType == StorageTypes.Unknown || m_sipRegistrarStorageConnStr.IsNullOrBlank())
            {
                throw new ApplicationException("The SIP Registrar cannot start with no persistence settings.");
            }

            lBoxDevice.Items.Add("34020000001320000077");
            lBoxDevice.Items.Add("34020000001320000088");
            lBoxDevice.SelectedIndex = 0;
            _deviceList = lBoxDevice.Items.Cast <string>().ToList();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            try
            {
                logger.Debug("SIP Notifier starting");

                m_sipNotifierStorageType    = (AppState.GetConfigSetting(m_storageTypeKey) != null) ? StorageTypesConverter.GetStorageType(AppState.GetConfigSetting(m_storageTypeKey)) : StorageTypes.Unknown;;
                m_sipNotifierStorageConnStr = AppState.GetConfigSetting(m_connStrKey);

                if (m_sipNotifierStorageType == StorageTypes.Unknown || m_sipNotifierStorageConnStr.IsNullOrBlank())
                {
                    throw new ApplicationException("The SIP Notifier cannot start with no persistence settings.");
                }

                if (m_sipNotifierStorageType == StorageTypes.XML && !Directory.Exists(m_sipNotifierStorageConnStr))
                {
                    throw new ApplicationException("Directory " + m_sipNotifierStorageConnStr + " does not exist for XML persistor.");
                }

                SIPAssetPersistor <Customer> customerPersistor = SIPAssetPersistorFactory <Customer> .CreateSIPAssetPersistor(m_sipNotifierStorageType, m_sipNotifierStorageConnStr, m_customersXMLFilename);

                SIPAssetPersistor <SIPAccount> sipAccountsPersistor = SIPAssetPersistorFactory <SIPAccount> .CreateSIPAssetPersistor(m_sipNotifierStorageType, m_sipNotifierStorageConnStr, m_sipAccountsXMLFilename);

                SIPAssetPersistor <SIPRegistrarBinding> sipRegistrarBindingsPersistor = SIPAssetPersistorFactory <SIPRegistrarBinding> .CreateSIPAssetPersistor(m_sipNotifierStorageType, m_sipNotifierStorageConnStr, m_registrarBindingsXMLFilename);

                SIPAssetPersistor <SIPDialogueAsset> sipDialoguePersistor = SIPAssetPersistorFactory <SIPDialogueAsset> .CreateSIPAssetPersistor(m_sipNotifierStorageType, m_sipNotifierStorageConnStr, m_sipDialoguesXMLFilename);

                SIPDomainManager sipDomainManager = new SIPDomainManager(m_sipNotifierStorageType, m_sipNotifierStorageConnStr);

                SIPNotifierDaemon daemon = new SIPNotifierDaemon(
                    customerPersistor.Get,
                    sipDialoguePersistor.Get,
                    sipDialoguePersistor.Get,
                    sipDomainManager.GetDomain,
                    sipAccountsPersistor,
                    sipRegistrarBindingsPersistor.Get,
                    sipAccountsPersistor.Get,
                    sipRegistrarBindingsPersistor.Count,
                    SIPRequestAuthenticator.AuthenticateSIPRequest,
                    null);

                if (args != null && args.Length == 1 && args[0].StartsWith("-c"))
                {
                    Thread daemonThread = new Thread(daemon.Start);
                    daemonThread.Start();
                    m_notifierUp.WaitOne();
                }
                else
                {
                    System.ServiceProcess.ServiceBase[] ServicesToRun;
                    ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service(daemon) };
                    System.ServiceProcess.ServiceBase.Run(ServicesToRun);
                }
            }
            catch (Exception excp)
            {
                Console.WriteLine("Exception Main. " + excp.Message);
                logger.Error("Exception Main. " + excp.Message);
            }
        }
        protected override object CreateBehavior()
        {
            try {
                m_serverStorageType    = (ConfigurationManager.AppSettings[m_storageTypeKey] != null) ? StorageTypesConverter.GetStorageType(ConfigurationManager.AppSettings[m_storageTypeKey]) : StorageTypes.Unknown;
                m_serverStorageConnStr = ConfigurationManager.AppSettings[m_connStrKey];
                Int32.TryParse(ConfigurationManager.AppSettings[NEW_CUSTOMERS_ALLOWED_LIMIT_KEY], out m_newCustomersAllowedLimit);
                Boolean.TryParse(ConfigurationManager.AppSettings[INVITE_CODE_REQUIRED_KEY], out m_inviteCodeRequired);

                if (m_serverStorageType == StorageTypes.Unknown || m_serverStorageConnStr.IsNullOrBlank())
                {
                    throw new ApplicationException("The Provisioning Web Service cannot start with no persistence settings specified.");
                }

                // Prevent users from creaing loopback or other crazy providers.
                m_disabledProviderServerPattern = ConfigurationManager.AppSettings[DISABLED_PROVIDER_SERVERS_PATTERN];
                if (!m_disabledProviderServerPattern.IsNullOrBlank())
                {
                    SIPProvider.DisallowedServerPatterns = m_disabledProviderServerPattern;
                }

                // The Registration Agent wants to know about any changes to SIP Provider entries in order to update any SIP
                // Provider bindings it is maintaining or needs to add or remove.
                SIPAssetPersistor <SIPProvider> sipProviderPersistor = SIPAssetPersistorFactory <SIPProvider> .CreateSIPAssetPersistor(m_serverStorageType, m_serverStorageConnStr, m_providersStorageFileName);

                SIPAssetPersistor <SIPProviderBinding> sipProviderBindingsPersistor = SIPAssetPersistorFactory <SIPProviderBinding> .CreateSIPAssetPersistor(m_serverStorageType, m_serverStorageConnStr, m_providerBindingsStorageFileName);

                SIPProviderBindingSynchroniser sipProviderBindingSynchroniser = new SIPProviderBindingSynchroniser(sipProviderBindingsPersistor);

                sipProviderPersistor.Added   += sipProviderBindingSynchroniser.SIPProviderAdded;
                sipProviderPersistor.Updated += sipProviderBindingSynchroniser.SIPProviderUpdated;
                sipProviderPersistor.Deleted += sipProviderBindingSynchroniser.SIPProviderDeleted;

                return(new ProvisioningServiceInstanceProvider(
                           SIPAssetPersistorFactory <SIPAccount> .CreateSIPAssetPersistor(m_serverStorageType, m_serverStorageConnStr, m_sipAccountsStorageFileName),
                           SIPAssetPersistorFactory <SIPDialPlan> .CreateSIPAssetPersistor(m_serverStorageType, m_serverStorageConnStr, m_dialplansStorageFileName),
                           sipProviderPersistor,
                           sipProviderBindingsPersistor,
                           SIPAssetPersistorFactory <SIPRegistrarBinding> .CreateSIPAssetPersistor(m_serverStorageType, m_serverStorageConnStr, m_registrarBindingsStorageFileName),
                           SIPAssetPersistorFactory <SIPDialogueAsset> .CreateSIPAssetPersistor(m_serverStorageType, m_serverStorageConnStr, m_dialoguesStorageFileName),
                           SIPAssetPersistorFactory <SIPCDRAsset> .CreateSIPAssetPersistor(m_serverStorageType, m_serverStorageConnStr, m_cdrsStorageFileName),
                           new CustomerSessionManager(m_serverStorageType, m_serverStorageConnStr),
                           new SIPDomainManager(m_serverStorageType, m_serverStorageConnStr),
                           (e) => { logger.Debug(e.Message); },
                           m_newCustomersAllowedLimit,
                           m_inviteCodeRequired));
            }
            catch (Exception excp) {
                logger.Error("Exception InstanceProviderExtensionElement CreateBehavior. " + excp.Message);
                throw;
            }
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            bool isConsole = false;

            try
            {
                // Get DateTime.ToString() to use a format ot ToString("o") instead of ToString("G").
                CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
                culture.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd";
                culture.DateTimeFormat.LongTimePattern  = "THH:mm:ss.fffffffzzz";
                Thread.CurrentThread.CurrentCulture     = culture;

                m_serverStorageType    = (AppState.GetConfigSetting(m_storageTypeKey) != null) ? StorageTypesConverter.GetStorageType(AppState.GetConfigSetting(m_storageTypeKey)) : StorageTypes.Unknown;
                m_serverStorageConnStr = AppState.GetConfigSetting(m_connStrKey);
                bool monitorCalls = true;

                if (m_serverStorageType == StorageTypes.Unknown || m_serverStorageConnStr.IsNullOrBlank())
                {
                    throw new ApplicationException("The SIP Application Service cannot start with no persistence settings specified.");
                }

                SIPAllInOneDaemon daemon = null;

                if (args != null && args.Length == 1 && args[0] == "-i")
                {
                    try
                    {
                        using (AssemblyInstaller inst = new AssemblyInstaller(typeof(MainConsole).Assembly, args))
                        {
                            IDictionary state = new Hashtable();
                            inst.UseNewContext = true;
                            try
                            {
                                //if (undo)
                                //{
                                //    inst.Uninstall(state);
                                //}
                                //else
                                //{
                                inst.Install(state);
                                inst.Commit(state);
                                //}
                            }
                            catch
                            {
                                try
                                {
                                    inst.Rollback(state);
                                }
                                catch { }
                                throw;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.Error.WriteLine(ex.Message);
                    }
                }
                else if (args != null && args.Length == 1 && args[0] == "-u")
                {
                    try
                    {
                        using (AssemblyInstaller inst = new AssemblyInstaller(typeof(MainConsole).Assembly, args))
                        {
                            IDictionary state = new Hashtable();
                            inst.UseNewContext = true;
                            try
                            {
                                inst.Uninstall(state);
                            }
                            catch
                            {
                                try
                                {
                                    inst.Rollback(state);
                                }
                                catch { }
                                throw;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.Error.WriteLine(ex.Message);
                    }
                }
                else if (args != null && args.Length == 1 && args[0].StartsWith("-c") || System.Environment.UserInteractive == true)
                {
                    isConsole = true;
                    Console.WriteLine("SIP App Server starting");
                    logger.Debug("SIP App Server Console starting...");

                    string sipSocket             = null;
                    string callManagerSvcAddress = null;

                    if (args != null && args.Length > 0)
                    {
                        foreach (string arg in args)
                        {
                            if (arg.StartsWith("-sip:"))
                            {
                                sipSocket = arg.Substring(5);
                            }
                            else if (arg.StartsWith("-cms:"))
                            {
                                callManagerSvcAddress = arg.Substring(5);
                            }
                            else if (arg.StartsWith("-hangupcalls:"))
                            {
                                monitorCalls = Convert.ToBoolean(arg.Substring(13));
                            }
                        }
                    }

                    if (sipSocket.IsNullOrBlank() || callManagerSvcAddress.IsNullOrBlank())
                    {
                        daemon = new SIPAllInOneDaemon(m_serverStorageType, m_serverStorageConnStr);
                    }
                    else
                    {
                        daemon = new SIPAllInOneDaemon(m_serverStorageType, m_serverStorageConnStr, SIPEndPoint.ParseSIPEndPoint(sipSocket), callManagerSvcAddress, monitorCalls);
                    }

                    Thread daemonThread = new Thread(new ThreadStart(daemon.Start));
                    daemonThread.Start();

                    m_proxyUp.WaitOne();
                }
                else
                {
                    logger.Debug("SIP App Server Windows Service Starting...");
                    System.ServiceProcess.ServiceBase[] ServicesToRun;
                    daemon        = new SIPAllInOneDaemon(m_serverStorageType, m_serverStorageConnStr);
                    ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service(daemon) };
                    System.ServiceProcess.ServiceBase.Run(ServicesToRun);
                }
            }
            catch (Exception excp)
            {
                Console.WriteLine("Exception SIP App Server Main. " + excp.Message);

                if (isConsole)
                {
                    Console.WriteLine("press any key to exit...");
                    Console.ReadLine();
                }
            }
        }
        static void Main(string[] args)
        {
            try
            {
                logger.Debug("SIP Registration Agent starting");

                m_sipRegAgentStorageType    = (AppState.GetConfigSetting(m_storageTypeKey) != null) ? StorageTypesConverter.GetStorageType(AppState.GetConfigSetting(m_storageTypeKey)) : StorageTypes.Unknown;
                m_sipRegAgentStorageConnStr = AppState.GetConfigSetting(m_connStrKey);

                if (m_sipRegAgentStorageType == StorageTypes.Unknown || m_sipRegAgentStorageConnStr.IsNullOrBlank())
                {
                    throw new ApplicationException("The SIP Registration Agent cannot start with no persistence settings.");
                }

                if (m_sipRegAgentStorageType == StorageTypes.XML && !Directory.Exists(m_sipRegAgentStorageConnStr))
                {
                    throw new ApplicationException("Directory " + m_sipRegAgentStorageConnStr + " does not exist for XML persistor.");
                }

                int minWorker, minIOC;
                ThreadPool.GetMinThreads(out minWorker, out minIOC);
                ThreadPool.SetMinThreads(MIN_THREADPOOL_WORKERS, minIOC);
                logger.Debug("ThreadPool minimum idle thread adusted from " + minWorker + " to " + MIN_THREADPOOL_WORKERS + ".");

                SIPAssetPersistor <SIPProvider> sipProvidersPersistor = SIPAssetPersistorFactory <SIPProvider> .CreateSIPAssetPersistor(m_sipRegAgentStorageType, m_sipRegAgentStorageConnStr, m_sipProvidersXMLFilename);

                SIPAssetPersistor <SIPProviderBinding> sipProviderBindingsPersistor = SIPAssetPersistorFactory <SIPProviderBinding> .CreateSIPAssetPersistor(m_sipRegAgentStorageType, m_sipRegAgentStorageConnStr, m_sipProviderBindingsXMLFilename);

                SIPRegAgentDaemon daemon = new SIPRegAgentDaemon(sipProvidersPersistor, sipProviderBindingsPersistor);
                SIPDNSManager.SIPMonitorLogEvent = daemon.FireSIPMonitorEvent;

                if (args != null && args.Length == 1 && args[0].StartsWith("-c"))
                {
                    Thread daemonThread = new Thread(daemon.Start);
                    daemonThread.Start();
                    m_regAgentUp.WaitOne();
                }
                else
                {
                    System.ServiceProcess.ServiceBase[] ServicesToRun;
                    ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service(daemon) };
                    System.ServiceProcess.ServiceBase.Run(ServicesToRun);
                }
            }
            catch (Exception excp)
            {
                Console.WriteLine("Exception Main. " + excp.Message);
                logger.Error("Exception Main. " + excp.Message);
            }
        }
Ejemplo n.º 8
0
 public static void ClassInitialize(TestContext context)
 {
     _serverStorageType    = (AppState.GetConfigSetting(m_storageTypeKey) != null) ? StorageTypesConverter.GetStorageType(AppState.GetConfigSetting(m_storageTypeKey)) : StorageTypes.Unknown;
     _serverStorageConnStr = AppState.GetConfigSetting(m_connStrKey);
 }
Ejemplo n.º 9
0
        static WebState()
        {
            try {
                #region Configure logging.

                try {
                    log4net.Config.XmlConfigurator.Configure();
                    logger = log4net.LogManager.GetLogger(LOGGER_NAME);
                }
                catch (Exception logExcp) {
                    Console.WriteLine("Exception SIPProxyState Configure Logging. " + logExcp.Message);
                }

                #endregion

                CRMStorageType    = (ConfigurationManager.AppSettings[m_storageTypeKey] != null) ? StorageTypesConverter.GetStorageType(ConfigurationManager.AppSettings[m_storageTypeKey]) : StorageTypes.Unknown;
                CRMStorageConnStr = ConfigurationManager.AppSettings[m_connStrKey];

                if (CRMStorageType == StorageTypes.Unknown || CRMStorageConnStr.IsNullOrBlank())
                {
                    logger.Error("The SIPSorcery.CRM.Web does not have any persistence settings configured.");
                }

                XmlNode validationRulesNode = (XmlNode)ConfigurationManager.GetSection(CUSTOMER_VALIDATION_RULES);
                if (validationRulesNode != null)
                {
                    foreach (XmlNode validationNode in validationRulesNode)
                    {
                        ValidationRules.Add(validationNode.SelectSingleNode("field").InnerText, validationNode.SelectSingleNode("rule").InnerText);
                    }
                }
            }
            catch (Exception excp) {
                logger.Error("Exception WebState. " + excp.Message);
            }
        }
        static void Main(string[] args)
        {
            try
            {
                m_storageType = (AppState.GetConfigSetting(m_storageTypeKey) != null) ? StorageTypesConverter.GetStorageType(AppState.GetConfigSetting(m_storageTypeKey)) : StorageTypes.Unknown;
                m_connStr     = AppState.GetConfigSetting(m_connStrKey);

                CustomerSessionManager customerSessionManager = new CustomerSessionManager(m_storageType, m_connStr);
                SSHServerDaemon        daemon = new SSHServerDaemon(customerSessionManager);

                if (args != null && args.Length == 1 && args[0].StartsWith("-c"))
                {
                    Console.WriteLine("SSH Server starting");

                    Thread daemonThread = new Thread(daemon.Start);
                    daemonThread.Start();

                    m_serverUp.WaitOne();
                }
                else
                {
                    System.ServiceProcess.ServiceBase[] ServicesToRun;
                    ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service(daemon) };
                    System.ServiceProcess.ServiceBase.Run(ServicesToRun);
                }
            }
            catch (Exception excp)
            {
                Console.WriteLine("Exception Main. " + excp.Message);
            }
        }
        static void Main(string[] args)
        {
            bool isConsole = false;

            try
            {
                // Get DateTime.ToString() to use a format ot ToString("o") instead of ToString("G").
                CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
                culture.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd";
                culture.DateTimeFormat.LongTimePattern  = "THH:mm:ss.fffffffzzz";
                Thread.CurrentThread.CurrentCulture     = culture;

                m_serverStorageType    = (AppState.GetConfigSetting(m_storageTypeKey) != null) ? StorageTypesConverter.GetStorageType(AppState.GetConfigSetting(m_storageTypeKey)) : StorageTypes.Unknown;
                m_serverStorageConnStr = AppState.GetConfigSetting(m_connStrKey);
                bool monitorCalls = true;

                if (m_serverStorageType == StorageTypes.Unknown || m_serverStorageConnStr.IsNullOrBlank())
                {
                    throw new ApplicationException("The SIP Application Service cannot start with no persistence settings specified.");
                }

                // Need to force the System.Data.Entity assembly to load before a dialplan instantiation. The assembly will fail to load if
                // requested from the Dynamic Language Runtime which is what happens if the first time it's requested is in an IronRuby dialplan.
                using (SIPSorceryEntities appEntities = new SIPSorceryEntities())
                {
                    logger.Debug("Lookups count=" + (from lookup in appEntities.SIPDialplanLookups select lookup).Count() + ", forcing entity framework assemblies to load.");
                }

                //if (args != null && args.Length > 0)
                //{
                isConsole = true;
                Console.WriteLine("SIP App Server starting");
                logger.Debug("SIP App Server Console starting...");

                string sipSocket             = null;
                string callManagerSvcAddress = null;

                foreach (string arg in args)
                {
                    if (arg.StartsWith("-sip:"))
                    {
                        sipSocket = arg.Substring(5);
                    }
                    else if (arg.StartsWith("-cms:"))
                    {
                        callManagerSvcAddress = arg.Substring(5);
                    }
                    else if (arg.StartsWith("-hangupcalls:"))
                    {
                        monitorCalls = Convert.ToBoolean(arg.Substring(13));
                    }
                }

                SIPAppServerDaemon daemon = null;

                if (sipSocket.IsNullOrBlank() || callManagerSvcAddress.IsNullOrBlank())
                {
                    daemon = new SIPAppServerDaemon(m_serverStorageType, m_serverStorageConnStr);
                }
                else
                {
                    daemon = new SIPAppServerDaemon(m_serverStorageType, m_serverStorageConnStr, SIPEndPoint.ParseSIPEndPoint(sipSocket), callManagerSvcAddress, monitorCalls);
                }

                Thread daemonThread = new Thread(new ThreadStart(daemon.Start));
                daemonThread.Start();

                m_proxyUp.WaitOne();
                //}
                //else
                //{
                //    logger.Debug("SIP App Server Windows Service Starting...");
                //    System.ServiceProcess.ServiceBase[] ServicesToRun;
                //    SIPAppServerDaemon daemon = new SIPAppServerDaemon(m_serverStorageType, m_serverStorageConnStr);
                //    ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service(daemon) };
                //    System.ServiceProcess.ServiceBase.Run(ServicesToRun);
                //}
            }
            catch (Exception excp)
            {
                Console.WriteLine("Exception SIP App Server Main. " + excp.Message);

                if (isConsole)
                {
                    Console.WriteLine("press any key to exit...");
                    Console.ReadLine();
                }
            }
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            try
            {
                logger.Debug("RTCC Server starting");

                m_rtccStorageType    = (AppState.GetConfigSetting(m_storageTypeKey) != null) ? StorageTypesConverter.GetStorageType(AppState.GetConfigSetting(m_storageTypeKey)) : StorageTypes.Unknown;;
                m_rtccStorageConnStr = AppState.GetConfigSetting(m_connStrKey);

                if (m_rtccStorageType == StorageTypes.Unknown || m_rtccStorageConnStr.IsNullOrBlank())
                {
                    throw new ApplicationException("The RTCC Server cannot start with no persistence settings.");
                }

                var        sipSorceryPersistor = new SIPSorceryPersistor(m_rtccStorageType, m_rtccStorageConnStr);
                RTCCDaemon daemon = new RTCCDaemon(sipSorceryPersistor);

                if (args != null && args.Length == 1 && args[0].StartsWith("-c"))
                {
                    Thread daemonThread = new Thread(daemon.Start);
                    daemonThread.Start();
                    m_rtccUp.WaitOne();
                }
                else
                {
                    System.ServiceProcess.ServiceBase[] ServicesToRun;
                    ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service(daemon) };
                    System.ServiceProcess.ServiceBase.Run(ServicesToRun);
                }
            }
            catch (Exception excp)
            {
                Console.WriteLine("Exception Main. " + excp.Message);
                logger.Error("Exception Main. " + excp.Message);
            }
        }