当前位置: 首页>>代码示例>>C#>>正文


C# Entities.SIPSorceryEntities类代码示例

本文整理汇总了C#中SIPSorcery.Entities.SIPSorceryEntities的典型用法代码示例。如果您正苦于以下问题:C# SIPSorceryEntities类的具体用法?C# SIPSorceryEntities怎么用?C# SIPSorceryEntities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SIPSorceryEntities类属于SIPSorcery.Entities命名空间,在下文中一共展示了SIPSorceryEntities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteQuery

 public static void ExecuteQuery(string query)
 {
     using (var sipSorceryEntities = new SIPSorceryEntities())
     {
         sipSorceryEntities.ExecuteStoreCommand(query, null);
     }
 }
开发者ID:sipsorcery,项目名称:sipsorcery,代码行数:7,代码来源:TestHelper.cs

示例2: GetLookups

 public List<SIPDialplanLookup> GetLookups(string dialplanName)
 {
     try
     {
         using (var ssEntities = new SIPSorceryEntities())
         {
             if (!dialplanName.IsNullOrBlank())
             {
                 return (from lookup in ssEntities.SIPDialplanLookups
                         join dialplan in ssEntities.SIPDialPlans on lookup.DialPlanID equals dialplan.ID
                         where lookup.Owner == m_owner && dialplan.DialPlanName.Contains(dialplanName)
                         select lookup).ToList();
             }
             else
             {
                 return (from lookup in ssEntities.SIPDialplanLookups
                         where lookup.Owner == m_owner
                         select lookup).ToList();
             }
         }
     }
     catch (Exception excp)
     {
         logger.Error("Exception GetLookups. " + excp.Message);
         return null;
     }
 }
开发者ID:TilmannBach,项目名称:sipsorcery-fork,代码行数:27,代码来源:DialPlanLookupFacade.cs

示例3: SIPProviderDeleted

        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);
            }
        }
开发者ID:sipsorcery,项目名称:sipsorcery,代码行数:35,代码来源:SIPProviderBindingSynchroniser.cs

示例4: SIPProviderAdded

        public static void SIPProviderAdded(SIPProvider sipProvider)
        {
            try
            {
                logger.Debug("SIPProviderBindingSynchroniser SIPProviderAdded for " + sipProvider.Owner + " and " + sipProvider.ProviderName + " (Provider ID=" + sipProvider.ID + ").");

                if (sipProvider.RegisterEnabled)
                {
                    using (SIPSorceryEntities sipSorceryEntities = new SIPSorceryEntities())
                    {
                        SIPProvider existingProvider = (from provider in sipSorceryEntities.SIPProviders
                                                        where provider.ID == sipProvider.ID
                                                        select provider).FirstOrDefault();

                        if (existingProvider != null)
                        {
                            AddNewBindingForProvider(sipSorceryEntities, existingProvider);
                        }
                        else
                        {
                            logger.Warn("The SIP provider entry was not in the database when attempting to add a provider binding.");
                        }
                    }
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPProviderBindingSynchroniser SIPProviderAdded. " + excp.Message);
            }
        }
开发者ID:sipsorcery,项目名称:sipsorcery,代码行数:30,代码来源:SIPProviderBindingSynchroniser.cs

示例5: Add

        /// <summary>
        /// Adds a new customer account.
        /// </summary>
        /// <param name="customerAccount">The customer account to add.</param>
        public void Add(CustomerAccount customerAccount)
        {
            using (var sipSorceryEntities = new SIPSorceryEntities())
            {
                customerAccount.AccountCode = Crypto.GetRandomString(ACCOUNT_CODE_RANDOM_STRING_PREFIX_LENGTH) + Crypto.GetRandomInt(ACCOUNT_CODE_RANDOM_NUMBER_SUFFIX_LENGTH).ToString();

                CheckUniqueFields(customerAccount);

                customerAccount.ID = Guid.NewGuid().ToString();
                customerAccount.Inserted = DateTimeOffset.UtcNow.ToString("o");

                sipSorceryEntities.CustomerAccounts.AddObject(customerAccount);
                sipSorceryEntities.SaveChanges();
            }
        }
开发者ID:TilmannBach,项目名称:sipsorcery-fork,代码行数:19,代码来源:CustomerAccountDataLayer.cs

示例6: GetForFTPPrefix

        /// <summary>
        /// Attempts to retrieve a customer record based on the FTP prefix.
        /// </summary>
        /// <param name="ftpPrefix">The FTP prefix to retrieve the customer for.</param>
        /// <returns>If found the matching Customer record otherwise null.</returns>
        public Customer GetForFTPPrefix(string ftpPrefix)
        {
            if (ftpPrefix.IsNullOrBlank())
            {
                return null;
            }

            using (var db = new SIPSorceryEntities())
            {
                string ftpPrefixLower = ftpPrefix.ToLower();

                return (from cu in db.Customers
                        where
                            cu.FTPPrefix.ToLower() == ftpPrefixLower
                        select cu).SingleOrDefault();
            }
        }
开发者ID:sipsorcery,项目名称:sipsorcery,代码行数:22,代码来源:CustomerDataLayer.cs

示例7: Add

        /// <summary>
        /// Adds a new rate.
        /// </summary>
        /// <param name="rate">The rate record to add.</param>
        public void Add(Rate rate)
        {
            using (var sipSorceryEntities = new SIPSorceryEntities())
            {
                if ((from rt in sipSorceryEntities.Rates where rt.Prefix == rate.Prefix select rt).Any())
                {
                    throw new ApplicationException("The rate prefix is already in use.");
                }
                else
                {
                    rate.ID = Guid.NewGuid().ToString();
                    rate.Inserted = DateTimeOffset.UtcNow.ToString("o");

                    sipSorceryEntities.Rates.AddObject(rate);
                    sipSorceryEntities.SaveChanges();
                }
            }
        }
开发者ID:TilmannBach,项目名称:sipsorcery-fork,代码行数:22,代码来源:RateDataLayer.cs

示例8: ChangeSIPDialPlanName

        public void ChangeSIPDialPlanName(string authUser, string sipDialPlanID, string name)
        {
            if (authUser.IsNullOrBlank())
            {
                throw new ArgumentException("An authenticated user is required for ChangeSIPDialPlanName.");
            }
            else if (name.IsNullOrBlank())
            {
                throw new ArgumentNullException("The new name cannot be empty in ChangeSIPDialPlanName.");
            }

            using (var sipSorceryEntities = new SIPSorceryEntities())
            {
                SIPDialPlan existingAccount = (from dp in sipSorceryEntities.SIPDialPlans where dp.ID == sipDialPlanID && dp.Owner.ToLower() == authUser.ToLower() select dp).FirstOrDefault();

                if (existingAccount == null)
                {
                    throw new ApplicationException("The SIP Dial Plan to change the name for could not be found.");
                }
                else if (existingAccount.Owner != authUser.ToLower())
                {
                    logger.Warn("User " + authUser + " was not authorised to change dial plan " + existingAccount.DialPlanName + " belonging to " + existingAccount.Owner + ".");
                    throw new ApplicationException("Not authorised to change the SIP Dial Plan name.");
                }
                else if (existingAccount.IsReadOnly)
                {
                    throw new ApplicationException("This Dial Plan is read-only. Please upgrade to a Premium service to enable it.");
                }

                logger.Debug("Changing the SIP dialplan " + existingAccount.DialPlanName + " for " + existingAccount.Owner + " to " + name + ".");

                if (sipSorceryEntities.SIPDialPlans.Any(x => x.DialPlanName.ToLower() == name.ToLower() && x.Owner.ToLower() == authUser.ToLower()))
                {
                    throw new ApplicationException("There is already a dialplan with the same name. Please choose something different.");
                }

                // Need to update any SIP accounts that are using the old dialplan name.
                UpdateSIPAccountsDialPlanName(sipSorceryEntities, authUser, existingAccount.DialPlanName, name);

                existingAccount.DialPlanName = name;

                sipSorceryEntities.SaveChanges();
            }
        }
开发者ID:Dawn2Yuan,项目名称:sipsorcery,代码行数:44,代码来源:SIPSorceryService.cs

示例9: CheckAccountCode

        /// <summary>
        /// Checks the account code is valid and if not will also check the account number.
        /// </summary>
        /// <param name="owner">The owner of the customer accounts to check.</param>
        /// <param name="accountNumber">The account code to check.</param>
        /// <returns>If a matching accountcode or number is found the account code will be returned otherwise null.</returns>
        public CustomerAccount CheckAccountCode(string owner, string accountCode)
        {
            using (var db = new SIPSorceryEntities())
            {
                var account = (from ca in db.CustomerAccounts
                        where
                            ca.Owner.ToLower() == owner.ToLower() &&
                           (ca.AccountCode.ToLower() == accountCode.ToLower() || ca.AccountNumber == accountCode)
                        select ca).SingleOrDefault();

                return (account != null) ? account : null;
            }
        }
开发者ID:sipsorcery,项目名称:sipsorcery,代码行数:19,代码来源:CustomerAccountDataLayer.cs

示例10: SetCDRIsHangingUp

        public void SetCDRIsHangingUp(string cdrID)
        {
            using (var db = new SIPSorceryEntities())
            {
                var callCDR = (from cdr in db.CDRs where cdr.ID == cdrID select cdr).SingleOrDefault();

                if (callCDR == null)
                {
                    logger.Debug("CDR could not be found for " + cdrID + " when attemping to set the IsHangingUp flag.");
                }
                else
                {
                    callCDR.IsHangingUp = true;
                    db.SaveChanges();
                }
            }
        }
开发者ID:TilmannBach,项目名称:sipsorcery-fork,代码行数:17,代码来源:CustomerAccountDataLayer.cs

示例11: Update

        /// <summary>
        /// Updates an existing customer account.
        /// </summary>
        /// <param name="customerAccount">The customer account to update.</param>
        public void Update(CustomerAccount customerAccount)
        {
            using (var db = new SIPSorceryEntities())
            {
                var existingAccount = (from ca in db.CustomerAccounts where ca.ID == customerAccount.ID select ca).SingleOrDefault();

                if (existingAccount == null)
                {
                    throw new ApplicationException("The customer account to update could not be found");
                }
                else if (existingAccount.Owner.ToLower() != customerAccount.Owner.ToLower())
                {
                    throw new ApplicationException("You are not authorised to update this customer account.");
                }
                else
                {
                    CheckUniqueFields(customerAccount);

                    logger.Debug("Updating customer account " + existingAccount.AccountName + " for " + existingAccount.Owner + ".");

                    existingAccount.AccountName = customerAccount.AccountName;
                    existingAccount.AccountNumber = customerAccount.AccountNumber;
                    existingAccount.Credit = customerAccount.Credit;
                    existingAccount.PIN = customerAccount.PIN;

                    db.SaveChanges();
                }
            }
        }
开发者ID:TilmannBach,项目名称:sipsorcery-fork,代码行数:33,代码来源:CustomerAccountDataLayer.cs

示例12: ReserveInitialCredit

        /// <summary>
        /// This method attempts to reserve a the initial amount of credit for a call.
        /// </summary>
        /// <param name="accountCode">The accountCode the credit should be reserved against.</param>
        /// <param name="amount">The amount of credit to reserve.</param>
        /// <param name="rate">The rate for the call destination and the values that will be used for subsequent credit reservations.</param>
        /// <param name="initialSeconds">IF the reservation is successful this parameter will hold the number of seconds that were reserved for the initial reservation.</param>
        /// <returns>True if there was enough credit for the reservation otherwise false.</returns>
        public decimal ReserveInitialCredit(string accountCode, decimal rate, out int initialSeconds)
        {
            logger.Debug("ReserveInitialCredit for " + accountCode + ", rate " + rate + ".");

            initialSeconds = 0;

            if (accountCode.IsNullOrBlank() || rate <= 0)
            {
                return Decimal.MinusOne;
            }

            using (var db = new SIPSorceryEntities())
            {
                using (var trans = new TransactionScope())
                {
                    var customerAccount = db.CustomerAccounts.Where(x => x.AccountCode == accountCode).SingleOrDefault();

                    if (customerAccount == null)
                    {
                        logger.Debug("The initial reservation for " + accountCode + " failed due to the no matching accountcode.");
                        return Decimal.MinusOne;
                    }

                    // Get the owning customer's RTCC billing increment.
                    int rtccIncrement = (from cust in db.Customers where cust.Name.ToLower() == customerAccount.Owner.ToLower() select cust.RTCCBillingIncrement).Single();

                    initialSeconds = (rtccIncrement > MINIMUM_INITIAL_RESERVATION_SECONDS) ? rtccIncrement : MINIMUM_INITIAL_RESERVATION_SECONDS;

                    decimal reservationCost = (decimal)initialSeconds / (decimal)60 * rate;

                    if (customerAccount.Credit < reservationCost)
                    {
                        logger.Debug("The initial reservation for " + accountCode + ", duration " + initialSeconds + "s and " + reservationCost.ToString("0.#####") + " failed due to lack of credit.");
                        return Decimal.MinusOne;
                    }
                    else
                    {
                        //var callCDR = (from cdr in db.CDRs where cdr.ID == cdrID select cdr).SingleOrDefault();

                        //if (callCDR == null)
                        //{
                        //    logger.Debug("The initial reservation for " + accountCode + " and " + reservationCost.ToString("0.#####") + " failed due to the no matching CDR for " + cdrID + ".");
                        //    return false;
                        //}
                        //else if (callCDR.HungupTime != null)
                        //{
                        //    logger.Debug("The initial reservation for " + accountCode + " and " + reservationCost.ToString("0.#####") + " failed due to the CDR already being hungup.");
                        //    return false;
                        //}

                        // The credit is available deduct it from the customer account balance and place it on the CDR.
                        customerAccount.Credit = customerAccount.Credit - reservationCost;

                        // Set the fields on the CDR.
                        //callCDR.Rate = rate;
                        //callCDR.SecondsReserved = seconds;
                        //callCDR.AccountCode = accountCode;
                        //callCDR.Cost = reservationCost;

                        db.SaveChanges();

                        trans.Complete();

                        logger.Debug("The initial reservation for " + accountCode + ", duration " + initialSeconds + "s and " + reservationCost.ToString("0.#####") + " was successful.");

                        return reservationCost;
                    }
                }
            }
        }
开发者ID:TilmannBach,项目名称:sipsorcery-fork,代码行数:78,代码来源:CustomerAccountDataLayer.cs

示例13: ReturnUnusedCredit

        /// <summary>
        /// This method should be called once a billable call has been completed. It will calcualte the final cost of the call and return
        /// any usused credit back to the customer account.
        /// </summary>
        /// <param name="cdrID">The ID of the CDR the credit is being returned for.</param>
        public void ReturnUnusedCredit(string cdrID)
        {
            logger.Debug("ReturnUnusedCredit for CDR ID " + cdrID + ".");

            if (cdrID.NotNullOrBlank())
            {
                using (var db = new SIPSorceryEntities())
                {
                    using (var trans = new TransactionScope())
                    {
                        var callCDR = (from cdr in db.CDRs where cdr.ID == cdrID select cdr).SingleOrDefault();

                        if (callCDR == null)
                        {
                            logger.Error("The unused credit could not be returned for " + cdrID + "  due to the no matching CDR.");
                        }
                        else
                        {
                            string reconciliationError = null;

                            if (callCDR.Duration == null)
                            {
                                reconciliationError = "Error, the call duration was null.";
                                logger.Warn("The unused credit could not be returned for " + cdrID + " the CDR has not been hungup.");
                            }
                            else if (callCDR.Cost == null)
                            {
                                reconciliationError = "Error, the call cost was null.";
                                logger.Warn("The unused credit could not be returned for " + cdrID + " the call cost was empty.");
                            }
                            else if (callCDR.AccountCode.IsNullOrBlank())
                            {
                                reconciliationError = "Error, the accountcode was null.";
                                logger.Warn("The unused credit could not be returned for " + cdrID + " due to the CDR having a blank accountcode.");
                            }
                            else if (callCDR.Rate <= 0)
                            {
                                reconciliationError = "Error, the rate was not set.";
                                logger.Warn("The unused credit could not be returned for " + cdrID + " due to the CDR having no rate.");
                            }

                            if (reconciliationError != null)
                            {
                                callCDR.ReconciliationResult = reconciliationError;
                                db.SaveChanges();
                            }
                            else
                            {
                                string accountCode = callCDR.AccountCode;
                                var customerAccount = db.CustomerAccounts.Where(x => x.AccountCode == accountCode).SingleOrDefault();

                                if (customerAccount == null)
                                {
                                    logger.Debug("The unused credit could not be returned for " + cdrID + " due to the no matching accountcode.");
                                    callCDR.ReconciliationResult = "Error, no matching customer for " + accountCode + ".";
                                    db.SaveChanges();
                                }
                                else
                                {
                                    // Get the owning customer's RTCC billing increment.
                                    int rtccIncrement = (from cust in db.Customers where cust.Name.ToLower() == callCDR.Owner.ToLower() select cust.RTCCBillingIncrement).Single();

                                    int billableDuration = (callCDR.Duration.Value % rtccIncrement == 0) ? callCDR.Duration.Value : (callCDR.Duration.Value / rtccIncrement + 1) * rtccIncrement;

                                    decimal actualCallCost = (Convert.ToDecimal(billableDuration) / SECONDS_FOR_RATE) * callCDR.Rate.Value;

                                    logger.Debug("RTCC billable duration " + billableDuration + " (increment " + rtccIncrement + "), actual call cost calculated at " + actualCallCost.ToString("0.#####") + " for call with cost of " + callCDR.Cost + ".");

                                    if (Math.Round(actualCallCost, 5) < Math.Round(callCDR.Cost.Value, 5))
                                    {
                                        decimal returnCredit = Math.Round(callCDR.Cost.Value, 5) - Math.Round(actualCallCost, 5);

                                        if (returnCredit > 0)
                                        {
                                            // There is some credit to return to the customer account.
                                            callCDR.Cost = callCDR.Cost.Value - returnCredit;
                                            callCDR.ReconciliationResult = "ok";
                                            callCDR.PostReconciliationBalance = customerAccount.Credit + returnCredit;
                                            customerAccount.Credit = customerAccount.Credit + returnCredit;
                                        }
                                        else
                                        {
                                            // An error has occurred and the credit reserved was less than the cost of the call.
                                            callCDR.ReconciliationResult = "Error: Actual call cost calculated as " + actualCallCost.ToString("0.#####");
                                            callCDR.PostReconciliationBalance = customerAccount.Credit + returnCredit;
                                            customerAccount.Credit = customerAccount.Credit + returnCredit;
                                        }

                                        db.SaveChanges();
                                    }
                                    else if (Math.Round(actualCallCost, 5) > Math.Round(callCDR.Cost.Value, 5) && Math.Abs(callCDR.Duration.Value - callCDR.SecondsReserved.Value) <= SECONDS_LENIENCY_FOR_RECONCILIATION)
                                    {
                                        logger.Debug("The billed call duration was in +/- " + SECONDS_LENIENCY_FOR_RECONCILIATION + " of actual call duration so a a bille call cost of " + callCDR.Cost.Value.ToString("0.#####") + " was accepted for an actual call cost of " + actualCallCost.ToString("0.#####") + ".");
                                        callCDR.ReconciliationResult = "ok";
                                        callCDR.PostReconciliationBalance = customerAccount.Credit;
//.........这里部分代码省略.........
开发者ID:TilmannBach,项目名称:sipsorcery-fork,代码行数:101,代码来源:CustomerAccountDataLayer.cs

示例14: UpdateRealTimeCallControlCDRID

        public void UpdateRealTimeCallControlCDRID(string oldCDRID, SIPCDR newCDR)
        {
            logger.Debug("UpdateRealTimeCallControlCDRID old CDR ID " + oldCDRID + ", new CDR ID " + newCDR.CDRId.ToString() + ".");

            using (var db = new SIPSorceryEntities())
            {
                using (var trans = new TransactionScope())
                {
                    var realTimeCallControl = (from rtcc in db.RTCCs1 where rtcc.CDRID == oldCDRID select rtcc).FirstOrDefault();

                    if (realTimeCallControl == null)
                    {
                        logger.Error("No RTCC record could be found for CDR ID " + oldCDRID + ".");
                    }
                    else
                    {
                        //db.CDRs.AddObject(newCDR);

                        realTimeCallControl.CDRID = newCDR.CDRId.ToString();

                        db.SaveChanges();

                        trans.Complete();
                    }
                }
            }
        }
开发者ID:sipsorcery,项目名称:sipsorcery,代码行数:27,代码来源:CustomerAccountDataLayer.cs

示例15: MonitorCDRs

        /// <summary>
        /// Monitors the CDRs table for records that are using real-time call control and are within the limit that requires them to 
        /// re-reserve credit.
        /// </summary>
        private void MonitorCDRs()
        {
            try
            {
                Thread.CurrentThread.Name = RTCC_THREAD_NAME;

                logger.Debug("RTCC Core Starting Monitor CDRs thread.");

                while (!m_exit)
                {
                    using (var db = new SIPSorceryEntities())
                    {
                        try
                        {
                            // Try and reserve credit on in progress calls.
                            DateTime reservationDue = DateTime.Now.AddSeconds(m_reserveDueSeconds);

                            var cdrsReservationDue = (from cdr in db.CDRs
                                                      where cdr.AccountCode != null && cdr.HungupTime == null && cdr.AnsweredAt != null && cdr.SecondsReserved != null && cdr.SecondsReserved > 0 &&
                                                            cdr.AnsweredStatus >= 200 && cdr.AnsweredStatus <= 299 && EntityFunctions.AddSeconds(cdr.AnsweredAt, cdr.SecondsReserved) <= reservationDue && cdr.ReservationError == null
                                                      orderby cdr.AnsweredAt
                                                      select cdr).Take(NUMBER_CDRS_PER_ROUNDTRIP);

                            while (cdrsReservationDue.Count() > 0)
                            {
                                foreach (CDR cdr in cdrsReservationDue)
                                {
                                    Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.RTCC, SIPMonitorEventTypesEnum.DialPlan, "Reserving credit for call " + cdr.Dst + ".", cdr.Owner));

                                    // Attempt to re-reserve the next chunk of credit for the call.
                                    m_customerAccountDataLayer.ReserveCredit(m_reservationAmountSeconds, cdr.ID);
                                }
                            }
                        }
                        //catch (ReflectionTypeLoadException ex)
                        //{
                        //    StringBuilder sb = new StringBuilder();
                        //    foreach (Exception exSub in ex.LoaderExceptions)
                        //    {
                        //        sb.AppendLine(exSub.Message);
                        //        if (exSub is FileNotFoundException)
                        //        {
                        //            FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
                        //            if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
                        //            {
                        //                sb.AppendLine("Fusion Log:");
                        //                sb.AppendLine(exFileNotFound.FusionLog);
                        //            }
                        //        }
                        //        sb.AppendLine();
                        //    }
                        //    string errorMessage = sb.ToString();
                        //    logger.Error(errorMessage);
                        //}
                        catch (Exception monitorExcp)
                        {
                            logger.Error("Exception MonitorCDRs Credit Reservation. " + monitorExcp);
                            logger.Error("InnerException MonitorCDRs Credit Reservation. " + monitorExcp.InnerException);
                        }

                        try
                        {
                            // Terminate any calls that have reached their time limit.
                            DateTime now = DateTime.Now;
                            var cdrsTerminationDue = (from cdr in db.CDRs
                                                      where !cdr.IsHangingUp && cdr.AccountCode != null && cdr.HungupTime == null && cdr.AnsweredAt != null && cdr.SecondsReserved != null &&
                                                              cdr.AnsweredStatus >= 200 && cdr.AnsweredStatus <= 299 && EntityFunctions.AddSeconds(cdr.AnsweredAt, cdr.SecondsReserved) <= now && !cdr.IsHangingUp
                                                      orderby cdr.AnsweredAt
                                                      select cdr).Take(NUMBER_CDRS_PER_ROUNDTRIP);

                            while (cdrsTerminationDue.Count() > 0)
                            {
                                foreach (CDR cdr in cdrsTerminationDue)
                                {
                                    Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.RTCC, SIPMonitorEventTypesEnum.DialPlan, "Terminating call due to reservation limit being reached " + cdr.Dst + ".", cdr.Owner));

                                    m_customerAccountDataLayer.SetCDRIsHangingUp(cdr.ID);

                                    var dialogue = m_sipDialoguePersistor.Get(x => x.CDRId == cdr.ID, null, 0, 1).FirstOrDefault();
                                    if (dialogue != null)
                                    {
                                        m_sipDialogueManager.CallHungup(dialogue.SIPDialogue, "RTCC time limit reached", true);
                                    }
                                    else
                                    {
                                        Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.RTCC, SIPMonitorEventTypesEnum.Warn, "A dialogue could not be found when terminating a call due to reservation limit being reached.", cdr.Owner));
                                    }
                                }
                            }
                        }
                        catch (Exception monitorExcp)
                        {
                            logger.Error("Exception RTCCCore MonitorCDRs Call Termination. " + monitorExcp.Message);
                        }
                    }

//.........这里部分代码省略.........
开发者ID:TilmannBach,项目名称:sipsorcery-fork,代码行数:101,代码来源:RTCCCore.cs


注:本文中的SIPSorcery.Entities.SIPSorceryEntities类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。