示例#1
0
        public void Test_DTO_CDR()
        {
            CdrDto[] _cdrs = CDRController.GetRetailAcctCDRs(200625000, 200625023, 0, 0);
            foreach (CdrDto _cdr in _cdrs)
            {
                string _xml = serializeCDR(_cdr);
                Debug.WriteLine(_xml.Length);

                CdrDto _xcdr = DeserializeCDR(_xml);
                Debug.WriteLine(_xcdr.ToString());
            }
        }
示例#2
0
 String serializeCDR(CdrDto pCDR)
 {
     try {
         String        _xmlizedString = null;
         MemoryStream  memoryStream   = new MemoryStream();
         XmlSerializer xs             = new XmlSerializer(typeof(CdrDto));
         XmlTextWriter xmlTextWriter  = new XmlTextWriter(memoryStream, Encoding.UTF8);
         xs.Serialize(xmlTextWriter, pCDR);
         memoryStream   = (MemoryStream)xmlTextWriter.BaseStream;
         _xmlizedString = UTF8ByteArrayToString(memoryStream.ToArray());
         return(_xmlizedString);
     }
     catch (Exception e) {
         Console.WriteLine(e);
         return(null);
     }
 }
示例#3
0
        private static CdrDto mapToCDRDto(CDRViewRow pCDRViewRow)
        {
            var _cdr = new CdrDto();

            _cdr.Guid                   = pCDRViewRow.Id;
            _cdr.ANI                    = pCDRViewRow.ANI;
            _cdr.CarrierAcctId          = pCDRViewRow.Carrier_acct_id;
            _cdr.CarrierAcctName        = pCDRViewRow.Carrier_acct_name;
            _cdr.CarrierRouteId         = pCDRViewRow.Carrier_route_id;
            _cdr.CarrierRouteName       = pCDRViewRow.Carrier_route_name;
            _cdr.CarrierDuration        = pCDRViewRow.Carrier_duration;
            _cdr.CarrierMinutes         = pCDRViewRow.Carrier_minutes;
            _cdr.Ccode                  = pCDRViewRow.Ccode;
            _cdr.CarrierCost            = pCDRViewRow.Cost;
            _cdr.CustomerAcctId         = pCDRViewRow.Customer_acct_id;
            _cdr.CustomerAcctName       = pCDRViewRow.Customer_acct_name;
            _cdr.CustomerDuration       = pCDRViewRow.Customer_duration;
            _cdr.CustomerMinutes        = pCDRViewRow.Minutes;      //customer minutes
            _cdr.CustomerRouteId        = pCDRViewRow.Customer_route_id;
            _cdr.CustomerRouteName      = pCDRViewRow.Customer_route_name;
            _cdr.DateLogged             = pCDRViewRow.Date_logged;
            _cdr.DialedNumber           = pCDRViewRow.Dialed_number;
            _cdr.DisconnectCauseNumber  = pCDRViewRow.Disconnect_cause;
            _cdr.DisconnectSourceNumber = pCDRViewRow.Disconnect_source;
            _cdr.DNIS                   = pCDRViewRow.DNIS;
            _cdr.InfoDigits             = pCDRViewRow.Info_digits;
            _cdr.Leg2Duration           = pCDRViewRow.Duration;
            _cdr.Leg1Duration           = (short)pCDRViewRow.Date_logged.Subtract(pCDRViewRow.Start).TotalSeconds;
            if (_cdr.Leg1Duration < 0)
            {
                TimokLogger.Instance.LogRbr(LogSeverity.Error, "", string.Format("Negative Leg1 Duration, callID: {0}", pCDRViewRow.Id));
                _cdr.Leg1Duration = (short)(_cdr.Leg2Duration + 2);
            }
            if (_cdr.Leg1Duration < _cdr.Leg2Duration)
            {
                TimokLogger.Instance.LogRbr(LogSeverity.Error, "", string.Format("Leg1 Duration < Leg2 Duration, callID: {0}", pCDRViewRow.Id));
                _cdr.Leg1Duration = (short)(_cdr.Leg2Duration + 3);
            }
            _cdr.EndUserPrice = pCDRViewRow.End_user_price;
            _cdr.LocalNumber  = pCDRViewRow.Local_number;
            _cdr.MappedDisconnectCauseNumber = pCDRViewRow.Mapped_disconnect_cause;
            _cdr.NodeId             = pCDRViewRow.Node_id;
            _cdr.NodeName           = pCDRViewRow.Node_name;
            _cdr.OrigAlias          = pCDRViewRow.Orig_alias;
            _cdr.OrigDotIPAddress   = pCDRViewRow.Orig_dot_IP_address;
            _cdr.OrigEndpointId     = pCDRViewRow.Orig_end_point_id;
            _cdr.OrigIPAddress      = pCDRViewRow.Orig_IP_address;
            _cdr.OrigPartnerId      = pCDRViewRow.Orig_partner_id;
            _cdr.OrigPartnerName    = pCDRViewRow.Orig_partner_name;
            _cdr.PrefixIn           = pCDRViewRow.Prefix_in;
            _cdr.PrefixOut          = pCDRViewRow.Prefix_out;
            _cdr.CustomerPrice      = pCDRViewRow.Price;
            _cdr.RbrResultNumber    = pCDRViewRow.Rbr_result;
            _cdr.RetailAcctId       = pCDRViewRow.Retail_acct_id;
            _cdr.RetailDuration     = pCDRViewRow.Retail_duration;
            _cdr.RetailMinutes      = pCDRViewRow.Retail_minutes;
            _cdr.SerialNumber       = pCDRViewRow.Serial_number;
            _cdr.Start              = pCDRViewRow.Start;
            _cdr.TermAlias          = pCDRViewRow.Term_alias;
            _cdr.TermEndpointId     = pCDRViewRow.Term_end_point_id;
            _cdr.TermIPAddressRange = pCDRViewRow.Term_ip_address_range;
            _cdr.TermPartnerId      = pCDRViewRow.Term_partner_id;
            _cdr.TermPartnerName    = pCDRViewRow.Term_partner_name;
            _cdr.TimokDate          = pCDRViewRow.Timok_date;
            _cdr.UsedBonusMinutes   = pCDRViewRow.Used_bonus_minutes;
            _cdr.ResellerPrice      = pCDRViewRow.Reseller_price;
            return(_cdr);
        }