private SIPRegistrarBinding GetNextExpiredBinding(DateTimeOffset expiryTime) { using (var trans = new TransactionScope()) { SIPRegistrarBinding binding = m_bindingsPersistor.Get(b => b.ExpiryTime < expiryTime); if (binding != null) { if (binding.ExpiryTime < DateTimeOffset.UtcNow.AddSeconds(BINDING_EXPIRY_GRACE_PERIOD * -1)) { m_bindingsPersistor.Delete(binding); } else { logger.Warn("A binding returned from the database as expired wasn't. " + binding.SIPAccountName + " and " + binding.MangledContactURI + ", last register " + binding.LastUpdate.ToString("HH:mm:ss") + ", expiry " + binding.Expiry + ", expiry time " + binding.ExpiryTime.ToString("HH:mm:ss") + ", checkedtime " + expiryTime.ToString("HH:mm:ss") + ", now " + DateTimeOffset.UtcNow.ToString("HH:mm:ss") + "."); binding = null; } } trans.Complete(); return(binding); } }
public void SIPProviderUpdated(SIPProvider sipProvider) { try { Logger.Logger.Debug("SIPProviderBindingSynchroniser SIPProviderUpdated for " + sipProvider.Owner + " and " + sipProvider.ProviderName + "."); SIPProviderBinding existingBinding = m_bindingPersistor.Get(b => b.ProviderId == sipProvider.Id); if (sipProvider.RegisterEnabled) { if (existingBinding == null) { SIPProviderBinding newBinding = new SIPProviderBinding(sipProvider); m_bindingPersistor.Add(newBinding); } else { existingBinding.SetProviderFields(sipProvider); existingBinding.NextRegistrationTime = DateTime.UtcNow; m_bindingPersistor.Update(existingBinding); } } else { if (existingBinding != null) { if (existingBinding.IsRegistered) { // Let the registration agent know the existing binding should be expired. existingBinding.BindingExpiry = 0; existingBinding.NextRegistrationTime = DateTime.UtcNow; m_bindingPersistor.Update(existingBinding); } else { m_bindingPersistor.Delete(existingBinding); } } } } catch (Exception excp) { Logger.Logger.Error("Exception SIPProviderBindingSynchroniser SIPProviderUpdated. ->" + excp.Message); } }
public SIPDialPlan DeleteDialPlan(SIPDialPlan dialPlan) { Customer customer = AuthoriseRequest(); if (customer.AdminId != Customer.TOPLEVEL_ADMIN_ID && dialPlan.Owner != customer.CustomerUsername) { throw new ApplicationException("You are not authorised to delete the Dial Plan."); } DialPlanPersistor.Delete(dialPlan); // Enables the caller to see which dialplan has been deleted. return(dialPlan); }
public SIPAccount DeleteSIPAccount(SIPAccount sipAccount) { Customer customer = AuthoriseRequest(); if (customer.AdminId != Customer.TOPLEVEL_ADMIN_ID && sipAccount.Owner != customer.CustomerUsername) { throw new ApplicationException("You are not authorised to delete the SIP Account."); } SIPAccountPersistor.Delete(sipAccount); // Enables the caller to see which SIP account has been deleted. return(sipAccount); }
public SIPProvider DeleteSIPProvider(SIPProvider sipProvider) { Customer customer = AuthoriseRequest(); if (customer.AdminId != Customer.TOPLEVEL_ADMIN_ID && sipProvider.Owner != customer.CustomerUsername) { throw new ApplicationException("You are not authorised to delete the SIP Provider."); } //logger.Debug("DeleteSIPProvider, owner=" + sipProvider.Owner + ", providername=" + sipProvider.ProviderName + "."); SIPProviderPersistor.Delete(sipProvider); // Enables the caller to see which SIP Provider has been deleted. return(sipProvider); }
public void DeleteCustomer(string customerUsername) { try { Customer customer = AuthoriseRequest(); if (customer != null && customer.CustomerUsername == customerUsername) { CRMCustomerPersistor.Delete(customer); logger.Debug("Customer account " + customer.CustomerUsername + " successfully deleted."); } else { logger.Warn("Unauthorised attempt to delete customer " + customerUsername + "."); } } catch (Exception excp) { logger.Error("Exception DeleteCustomer. " + excp.Message); } }