Пример #1
0
        public static void SIPProviderDeleted(SIPProvider sipProvider)
        {
            try
            {
                logger.Debug("SIPProviderBindingSynchroniser SIPProviderDeleted for " + sipProvider.Owner + " and " + sipProvider.ProviderName + ".");

                using (SIPSorceryEntities sipSorceryEntities = new SIPSorceryEntities())
                {
                    SIPProviderBinding existingBinding = (from binding in sipSorceryEntities.SIPProviderBindings
                                                          where binding.ProviderID == sipProvider.ID
                                                          select binding).FirstOrDefault();

                    if (existingBinding != null)
                    {
                        if (existingBinding.IsRegistered)
                        {
                            // Let the registration agent know the existing binding should be expired.
                            existingBinding.BindingExpiry        = 0;
                            existingBinding.NextRegistrationTime = DateTime.UtcNow.ToString("o");
                            sipSorceryEntities.SaveChanges();
                        }
                        else
                        {
                            sipSorceryEntities.SIPProviderBindings.DeleteObject(existingBinding);
                            sipSorceryEntities.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPProviderBindingSynchroniser SIPProviderDeleted. " + excp.Message);
            }
        }
Пример #2
0
        private static void AddNewBindingForProvider(SIPSorceryEntities sipSorceryEntities, SIPProvider sipProvider)
        {
            try
            {
                logger.Debug("AddNewBindingForProvider provider ID=" + sipProvider.ID + ".");
                SIPProviderBinding newBinding = sipSorceryEntities.SIPProviderBindings.CreateObject();
                newBinding.SetProviderFields(sipProvider);
                newBinding.ID = Guid.NewGuid().ToString();
                newBinding.NextRegistrationTime = DateTimeOffset.UtcNow.ToString("o");
                newBinding.ProviderID           = sipProvider.ID;
                newBinding.Owner = sipProvider.Owner;

                sipSorceryEntities.SIPProviderBindings.AddObject(newBinding);
                sipSorceryEntities.SaveChanges();
            }
            catch (Exception excp)
            {
                logger.Error("Exception AddNewBindingForProvider. " + excp.Message);
                logger.Error(excp);
            }
        }
Пример #3
0
 /// <summary>
 /// Create a new SIPProviderBinding object.
 /// </summary>
 /// <param name="bindingExpiry">Initial value of the BindingExpiry property.</param>
 /// <param name="bindingURI">Initial value of the BindingURI property.</param>
 /// <param name="cSeq">Initial value of the CSeq property.</param>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="isRegistered">Initial value of the IsRegistered property.</param>
 /// <param name="nextRegistrationTime">Initial value of the NextRegistrationTime property.</param>
 /// <param name="owner">Initial value of the Owner property.</param>
 /// <param name="providerID">Initial value of the ProviderID property.</param>
 /// <param name="providerName">Initial value of the ProviderName property.</param>
 public static SIPProviderBinding CreateSIPProviderBinding(global::System.Int32 bindingExpiry, global::System.String bindingURI, global::System.Int32 cSeq, global::System.String id, global::System.Boolean isRegistered, global::System.String nextRegistrationTime, global::System.String owner, global::System.String providerID, global::System.String providerName)
 {
     SIPProviderBinding sIPProviderBinding = new SIPProviderBinding();
     sIPProviderBinding.BindingExpiry = bindingExpiry;
     sIPProviderBinding.BindingURI = bindingURI;
     sIPProviderBinding.CSeq = cSeq;
     sIPProviderBinding.ID = id;
     sIPProviderBinding.IsRegistered = isRegistered;
     sIPProviderBinding.NextRegistrationTime = nextRegistrationTime;
     sIPProviderBinding.Owner = owner;
     sIPProviderBinding.ProviderID = providerID;
     sIPProviderBinding.ProviderName = providerName;
     return sIPProviderBinding;
 }
Пример #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the SIPProviderBindings EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSIPProviderBindings(SIPProviderBinding sIPProviderBinding)
 {
     base.AddObject("SIPProviderBindings", sIPProviderBinding);
 }