public void Read() { SIPAssetPersistor <SIPAccount> account = SIPAssetPersistorFactory <SIPAccount> .CreateSIPAssetPersistor(m_storageType, m_connStr, m_XMLFilename); _sipAccount = account; _accounts = account.Get(); }
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 void Read() { SipAccountDataStorage = SIPAssetPersistorFactory <SIPAccount> .CreateSIPAssetPersistor(m_storageType, m_connStr, m_XMLFilename); SipAccountDataStorage.Added += Account_Added; _sipAccountsCache = SipAccountDataStorage.Get(); }
public void GetNonExistentSIPAccountAssetTestMethod() { var sipAccountPersistor = SIPAssetPersistorFactory <SIPAccountAsset> .CreateSIPAssetPersistor(_serverStorageType, _serverStorageConnStr, null); var result = sipAccountPersistor.Get(Guid.Empty); Assert.IsNull(result); }
public CustomerSessionManager(SIPSorceryConfiguration sipSorceryConfig) { StorageTypes storageType = sipSorceryConfig.PersistenceStorageType; string connectionString = sipSorceryConfig.PersistenceConnStr; m_customerPersistor = SIPAssetPersistorFactory <Customer> .CreateSIPAssetPersistor(storageType, connectionString, CUSTOMERS_XML_FILENAME); m_customerSessionPersistor = SIPAssetPersistorFactory <CustomerSession> .CreateSIPAssetPersistor(storageType, connectionString, CUSTOMER_SESSIONS_XML_FILENAME); }
//public SIPDomainManager() //{ } public SIPDomainManager(StorageTypes storageType, string storageConnectionStr) { m_sipDomainPersistor = SIPAssetPersistorFactory <SIPDomain> .CreateSIPAssetPersistor(storageType, storageConnectionStr, m_storageFileName); //m_sipDomainPersistor.Added += new SIPAssetDelegate<SIPDomain>(d => { LoadSIPDomains(); }); //m_sipDomainPersistor.Deleted += new SIPAssetDelegate<SIPDomain>(d => { LoadSIPDomains(); }); //m_sipDomainPersistor.Updated += new SIPAssetDelegate<SIPDomain>(d => { LoadSIPDomains(); }); //m_sipDomainPersistor.Modified += new SIPAssetsModifiedDelegate(() => { LoadSIPDomains(); }); LoadSIPDomains(); }
protected void Page_Load(object sender, EventArgs e) { try { logger.Debug("CustomerEmailConfirmation request from " + this.Context.Request.UserHostAddress + " for " + this.Request.QueryString["id"] + "."); string id = this.Request.QueryString["id"]; if (!id.IsNullOrBlank()) { Guid customerId = new Guid(id); m_crmPersistor = SIPAssetPersistorFactory <Customer> .CreateSIPAssetPersistor(m_crmStorageType, m_crmStorageConnStr, null); Customer customer = m_crmPersistor.Get(customerId); if (customer != null) { if (!customer.EmailAddressConfirmed) { customer.CreatedFromIPAddress = this.Context.Request.UserHostAddress; customer.EmailAddressConfirmed = true; if (IsValidCustomer(m_validationRules, customer)) { m_crmPersistor.Update(customer); m_confirmed = true; m_confirmMessage.Text = "Thank you, your account has now been activated."; } else { customer.Suspended = true; m_crmPersistor.Update(customer); m_confirmed = false; m_confirmMessage.Text = "Your account has been confirmed but not approved. You will receive an email within 48 hours if it is approved."; } } else { m_confirmed = false; m_confirmMessage.Text = "Your account has already been confirmed."; } } else { m_confirmMessage.Text = "No matching customer record could be found. Please check that you entered the confirmation URL correctly."; } } else { m_confirmMessage.Text = "Your account could not be confirmed. Please check that you entered the confirmation URL correctly."; } } catch (Exception excp) { logger.Error("Exception CustomerEmailConfirmation. " + excp.Message); m_confirmMessage.Text = "There was an error confirming your account. Please check that you entered the confirmation URL correctly."; } }
public static SIPProvisioningWebService CreateProvisioningService() { 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 SIPProvisioningWebService( SIPAssetPersistorFactory <SIPAccountAsset> .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 CreateProvisioningServicee. " + excp.Message); throw; } }
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); } }
public void GetSIPAccountAssetTestMethod() { try { TestHelper.ExecuteNonQuery(_serverStorageConnStr, "insert into sipaccounts (id, sipusername, sippassword, owner, sipdomain, inserted) values (uuid(), 'test', 'password', 'aaron', 'sipsorcery.com', now())"); var sipAccountPersistor = SIPAssetPersistorFactory <SIPAccountAsset> .CreateSIPAssetPersistor(_serverStorageType, _serverStorageConnStr, null); SIPAccountAsset result = sipAccountPersistor.Get(x => x.SIPUsername == "test"); Assert.IsNotNull(result); } finally { TestHelper.ExecuteNonQuery(_serverStorageConnStr, "delete from sipaccounts where sipusername = '******'"); } }
private void btnStart_Click(object sender, EventArgs e) { SIPAssetPersistor <SIPAccount> sipAccountsPersistor = SIPAssetPersistorFactory <SIPAccount> .CreateSIPAssetPersistor(m_sipRegistrarStorageType, m_sipRegistrarStorageConnStr, m_sipAccountsXMLFilename); SIPDomainManager sipDomainManager = new SIPDomainManager(m_sipRegistrarStorageType, m_sipRegistrarStorageConnStr); daemon = new SIPRegistrarDaemon(sipDomainManager.GetDomain, sipAccountsPersistor.Get, SIPRequestAuthenticator.AuthenticateSIPRequest, _deviceList); lblInit.Text = "sip服务已启动,等待初始化。。。"; lblInit.ForeColor = Color.Blue; Thread daemonThread = new Thread(daemon.Start); daemonThread.Start(); daemon.m_registrarCore.CatalogHandler += daemon_CatalogHandler; foreach (KeyValuePair <string, SipMonitorCore> monitorCore in daemon.m_registrarCore.MonitorItems) { monitorCore.Value.SipStatusHandler += monitorCore_SipStatusHandler; } }
/// <summary> /// 加载设备信息 /// </summary> public void Read() { SIPAssetPersistor <NvrItem> nvrItem = SIPAssetPersistorFactory <NvrItem> .CreateSIPAssetPersistor(m_storageType, m_connStr, m_XMLFilename); SIPAssetPersistor <ChannelItem> nvrChannel = SIPAssetPersistorFactory <ChannelItem> .CreateSIPAssetPersistor(m_storageType, m_connStr, m_XMLFilename); NvrItems = nvrItem; ChannelItems = nvrChannel; _nvrItems = nvrItem.Get(); var nvrChannelItems = nvrChannel.Get(); foreach (var item in _nvrItems) { foreach (var channel in nvrChannelItems) { if (item.NvrID == channel.NvrID) { item.Add(channel); } } } }
public CustomerSessionManager(StorageTypes storageType, string connectionString) { m_customerPersistor = SIPAssetPersistorFactory <Customer> .CreateSIPAssetPersistor(storageType, connectionString, CUSTOMERS_XML_FILENAME); m_customerSessionPersistor = SIPAssetPersistorFactory <CustomerSession> .CreateSIPAssetPersistor(storageType, connectionString, CUSTOMER_SESSIONS_XML_FILENAME); }