Inheritance: ISIPAsset
        private void WriteCDRs()
        {
            try
            {
                Thread.CurrentThread.Name = WRITE_CDRS_THREAD_NAME;

                while (!StopCDRWrites || m_pendingCDRs.Count > 0)
                {
                    try
                    {
                        if (m_pendingCDRs.Count > 0)
                        {

                            SIPCDRAsset cdrAsset = new SIPCDRAsset(m_pendingCDRs.Dequeue());
                            if (m_sipCDRPersistor.Count(c => c.Id == cdrAsset.Id) == 1)
                            {
                                m_sipCDRPersistor.Update(cdrAsset);
                            }
                            else
                            {
                                m_sipCDRPersistor.Add(cdrAsset);
                            }
                        }
                        else
                        {
                            Thread.Sleep(1000);
                        }
                    }
                    catch (Exception writeExcp)
                    {
                        logger.Error("Exception WriteCDRs writing CDR. " + writeExcp.Message);
                    }
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception WriteCDRs. " + excp.Message);
            }
        }
Ejemplo n.º 2
0
        public void WriteCDR(SIPCDR cdr)
        {
            try
            {
                //if (m_sipCDRPersistor != null && !StopCDRWrites && !m_pendingCDRs.Contains(cdr))
                //{
                //    m_pendingCDRs.Enqueue(cdr);
                //}

                SIPCDRAsset cdrAsset = new SIPCDRAsset(cdr);

                var existingCDR = m_sipCDRPersistor.Get(cdrAsset.Id);

                if (existingCDR == null)
                {
                    cdrAsset.Inserted = DateTimeOffset.UtcNow;
                    m_sipCDRPersistor.Add(cdrAsset);
                }
                else //if (existingCDR.ReconciliationResult == null)
                {
                    m_sipCDRPersistor.Update(cdrAsset);
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception QueueCDR. " + excp.Message);
            }
        }