本文整理匯總了Golang中github.com/cgrates/cgrates/engine.StoredCdr.AccId方法的典型用法代碼示例。如果您正苦於以下問題:Golang StoredCdr.AccId方法的具體用法?Golang StoredCdr.AccId怎麽用?Golang StoredCdr.AccId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cgrates/cgrates/engine.StoredCdr
的用法示例。
在下文中一共展示了StoredCdr.AccId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AsStoredCdr
func (kev KamEvent) AsStoredCdr(timezone string) *engine.StoredCdr {
storCdr := new(engine.StoredCdr)
storCdr.CgrId = kev.GetCgrId(timezone)
storCdr.TOR = utils.VOICE
storCdr.AccId = kev.GetUUID()
storCdr.CdrHost = kev.GetOriginatorIP(utils.META_DEFAULT)
storCdr.CdrSource = kev.GetCdrSource()
storCdr.ReqType = kev.GetReqType(utils.META_DEFAULT)
storCdr.Direction = kev.GetDirection(utils.META_DEFAULT)
storCdr.Tenant = kev.GetTenant(utils.META_DEFAULT)
storCdr.Category = kev.GetCategory(utils.META_DEFAULT)
storCdr.Account = kev.GetAccount(utils.META_DEFAULT)
storCdr.Subject = kev.GetSubject(utils.META_DEFAULT)
storCdr.Destination = kev.GetDestination(utils.META_DEFAULT)
storCdr.SetupTime, _ = kev.GetSetupTime(utils.META_DEFAULT, timezone)
storCdr.AnswerTime, _ = kev.GetAnswerTime(utils.META_DEFAULT, timezone)
storCdr.Usage, _ = kev.GetDuration(utils.META_DEFAULT)
storCdr.Pdd, _ = kev.GetPdd(utils.META_DEFAULT)
storCdr.Supplier = kev.GetSupplier(utils.META_DEFAULT)
storCdr.DisconnectCause = kev.GetDisconnectCause(utils.META_DEFAULT)
storCdr.ExtraFields = kev.GetExtraFields()
storCdr.Cost = -1
return storCdr
}
示例2: populateStoredCdrField
// Populates the
func populateStoredCdrField(cdr *engine.StoredCdr, fieldId, fieldVal, timezone string) error {
var err error
switch fieldId {
case utils.TOR:
cdr.TOR += fieldVal
case utils.ACCID:
cdr.AccId += fieldVal
case utils.REQTYPE:
cdr.ReqType += fieldVal
case utils.DIRECTION:
cdr.Direction += fieldVal
case utils.TENANT:
cdr.Tenant += fieldVal
case utils.CATEGORY:
cdr.Category += fieldVal
case utils.ACCOUNT:
cdr.Account += fieldVal
case utils.SUBJECT:
cdr.Subject += fieldVal
case utils.DESTINATION:
cdr.Destination += fieldVal
case utils.RATED_FLD:
cdr.Rated, _ = strconv.ParseBool(fieldVal)
case utils.SETUP_TIME:
if cdr.SetupTime, err = utils.ParseTimeDetectLayout(fieldVal, timezone); err != nil {
return fmt.Errorf("Cannot parse answer time field with value: %s, err: %s", fieldVal, err.Error())
}
case utils.PDD:
if cdr.Pdd, err = utils.ParseDurationWithSecs(fieldVal); err != nil {
return fmt.Errorf("Cannot parse answer time field with value: %s, err: %s", fieldVal, err.Error())
}
case utils.ANSWER_TIME:
if cdr.AnswerTime, err = utils.ParseTimeDetectLayout(fieldVal, timezone); err != nil {
return fmt.Errorf("Cannot parse answer time field with value: %s, err: %s", fieldVal, err.Error())
}
case utils.USAGE:
if cdr.Usage, err = utils.ParseDurationWithSecs(fieldVal); err != nil {
return fmt.Errorf("Cannot parse duration field with value: %s, err: %s", fieldVal, err.Error())
}
case utils.SUPPLIER:
cdr.Supplier += fieldVal
case utils.DISCONNECT_CAUSE:
cdr.DisconnectCause += fieldVal
case utils.COST:
if cdr.Cost, err = strconv.ParseFloat(fieldVal, 64); err != nil {
return fmt.Errorf("Cannot parse cost field with value: %s, err: %s", fieldVal, err.Error())
}
default: // Extra fields will not match predefined so they all show up here
cdr.ExtraFields[fieldId] += fieldVal
}
return nil
}