This class maintains a list of domains that are being maintained by this process.
        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);
            }
        }
        public ProvisioningServiceInstanceProvider(
            SIPAssetPersistor<SIPAccount> sipAccountPersistor,
            SIPAssetPersistor<SIPDialPlan> sipDialPlanPersistor,
            SIPAssetPersistor<SIPProvider> sipProviderPersistor,
            SIPAssetPersistor<SIPProviderBinding> sipProviderBindingsPersistor,
            SIPAssetPersistor<SIPRegistrarBinding> sipRegistrarBindingsPersistor,
            SIPAssetPersistor<SIPDialogueAsset> sipDialoguePersistor,
            SIPAssetPersistor<SIPCDRAsset> sipCDRPersistor,
            CustomerSessionManager crmSessionManager,
            SIPDomainManager sipDomainManager,
            SIPMonitorLogDelegate log,
            int newCustomersAllowedLimit) {

            m_sipAccountPersistor = sipAccountPersistor;
            m_sipDialPlanPersistor = sipDialPlanPersistor;
            m_sipProviderPersistor = sipProviderPersistor;
            m_sipProviderBindingsPersistor = sipProviderBindingsPersistor;
            m_sipRegistrarBindingsPersistor = sipRegistrarBindingsPersistor;
            m_sipDialoguePersistor = sipDialoguePersistor;
            m_sipCDRPersistor = sipCDRPersistor;
            m_crmCustomerPersistor = crmSessionManager.CustomerPersistor;
            m_crmSessionManager = crmSessionManager;
            m_sipDomainManager = sipDomainManager;
            m_logDelegate = log;
            m_newCustomersAllowedLimit = newCustomersAllowedLimit;
        }
        public SIPSorceryPersistor(StorageTypes storageType, string storageConnectionStr)
        {
            if (storageType == StorageTypes.XML)
            {
                if (!storageConnectionStr.Contains(":"))
                {
                    // Relative path.
                    storageConnectionStr = AppDomain.CurrentDomain.BaseDirectory + storageConnectionStr;
                }

                if (!storageConnectionStr.EndsWith(@"\"))
                {
                    storageConnectionStr += @"\";
                }

                if (!Directory.Exists(storageConnectionStr))
                {
                    throw new ApplicationException("Directory " + storageConnectionStr + " does not exist for XML persistor.");
                }
            }

            m_sipAccountsPersistor = SIPAssetPersistorFactory<SIPAccount>.CreateSIPAssetPersistor(storageType, storageConnectionStr, m_sipAccountsXMLFilename);
            m_dialPlanPersistor = SIPAssetPersistorFactory<SIPDialPlan>.CreateSIPAssetPersistor(storageType, storageConnectionStr, m_sipDialplansXMLFilename);
            m_sipProvidersPersistor = SIPAssetPersistorFactory<SIPProvider>.CreateSIPAssetPersistor(storageType, storageConnectionStr, m_sipProvidersXMLFilename);
            m_sipProviderBindingsPersistor = SIPAssetPersistorFactory<SIPProviderBinding>.CreateSIPAssetPersistor(storageType, storageConnectionStr, m_sipProviderBindingsXMLFilename);
            m_sipDomainManager = new SIPDomainManager(storageType, storageConnectionStr);
            m_sipRegistrarBindingPersistor = SIPAssetPersistorFactory<SIPRegistrarBinding>.CreateSIPAssetPersistor(storageType, storageConnectionStr, m_sipRegistrarBindingsXMLFilename);
            m_sipDialoguePersistor = SIPAssetPersistorFactory<SIPDialogueAsset>.CreateSIPAssetPersistor(storageType, storageConnectionStr, m_sipDialoguesXMLFilename);
            m_sipCDRPersistor = SIPAssetPersistorFactory<SIPCDRAsset>.CreateSIPAssetPersistor(storageType, storageConnectionStr, m_sipCDRsXMLFilename);

            if (m_sipCDRPersistor != null)
            {
                ThreadPool.QueueUserWorkItem(delegate { WriteCDRs(); });
            }
        }
 public SIPProvisioningWebService(
     SIPAssetPersistor<SIPAccount> sipAccountPersistor,
     SIPAssetPersistor<SIPDialPlan> sipDialPlanPersistor,
     SIPAssetPersistor<SIPProvider> sipProviderPersistor,
     SIPAssetPersistor<SIPProviderBinding> sipProviderBindingsPersistor,
     SIPAssetPersistor<SIPRegistrarBinding> sipRegistrarBindingsPersistor,
     SIPAssetPersistor<SIPDialogueAsset> sipDialoguePersistor,
     SIPAssetPersistor<SIPCDRAsset> sipCDRPersistor,
     CustomerSessionManager crmSessionManager,
     SIPDomainManager sipDomainManager,
     SIPMonitorLogDelegate log,
     int newCustomersAllowedLimit)
 {
     SIPAccountPersistor = sipAccountPersistor;
     DialPlanPersistor = sipDialPlanPersistor;
     SIPProviderPersistor = sipProviderPersistor;
     SIPProviderBindingsPersistor = sipProviderBindingsPersistor;
     SIPRegistrarBindingsPersistor = sipRegistrarBindingsPersistor;
     SIPDialoguePersistor = sipDialoguePersistor;
     SIPCDRPersistor = sipCDRPersistor;
     CRMCustomerPersistor = crmSessionManager.CustomerPersistor;
     CRMSessionManager = crmSessionManager;
     SIPDomainManager = sipDomainManager;
     LogDelegate_External = log;
     m_newCustomersAllowedLimit = newCustomersAllowedLimit;
 }
 public SIPProvisioningWebService(
     SIPAssetPersistor<SIPAccount> sipAccountPersistor,
     SIPAssetPersistor<SIPDialPlan> sipDialPlanPersistor,
     SIPAssetPersistor<SIPProvider> sipProviderPersistor,
     SIPAssetPersistor<SIPProviderBinding> sipProviderBindingsPersistor,
     SIPAssetPersistor<SIPRegistrarBinding> sipRegistrarBindingsPersistor,
     SIPAssetPersistor<SIPDialogueAsset> sipDialoguePersistor,
     SIPAssetPersistor<SIPCDRAsset> sipCDRPersistor,
     CustomerSessionManager crmSessionManager,
     SIPDomainManager sipDomainManager,
     SIPMonitorLogDelegate log,
     int newCustomersAllowedLimit,
     bool inviteCodeRequired) :
     base(crmSessionManager)
 {
     SIPAccountPersistor = sipAccountPersistor;
     DialPlanPersistor = sipDialPlanPersistor;
     SIPProviderPersistor = sipProviderPersistor;
     SIPProviderBindingsPersistor = sipProviderBindingsPersistor;
     SIPRegistrarBindingsPersistor = sipRegistrarBindingsPersistor;
     SIPDialoguePersistor = sipDialoguePersistor;
     SIPCDRPersistor = sipCDRPersistor;
     SIPDomainManager = sipDomainManager;
     LogDelegate_External = log;
     m_newCustomersAllowedLimit = newCustomersAllowedLimit;
     m_inviteCodeRequired = inviteCodeRequired;
    
     if (!String.IsNullOrEmpty(m_providerRegistrationsDisabled))
     {
         Boolean.TryParse(m_providerRegistrationsDisabled, out m_providerRegDisabled);
     }
 }