• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang utils.ConvertIfaceToString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/cgrates/cgrates/utils.ConvertIfaceToString函数的典型用法代码示例。如果您正苦于以下问题:Golang ConvertIfaceToString函数的具体用法?Golang ConvertIfaceToString怎么用?Golang ConvertIfaceToString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ConvertIfaceToString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: AsLcrRequest

func (self SMGenericEvent) AsLcrRequest() *engine.LcrRequest {
	setupTimeStr, _ := utils.ConvertIfaceToString(self[utils.SETUP_TIME])
	usageStr, _ := utils.ConvertIfaceToString(self[utils.USAGE])
	return &engine.LcrRequest{
		Direction:   self.GetDirection(utils.META_DEFAULT),
		Tenant:      self.GetTenant(utils.META_DEFAULT),
		Category:    self.GetCategory(utils.META_DEFAULT),
		Account:     self.GetAccount(utils.META_DEFAULT),
		Subject:     self.GetSubject(utils.META_DEFAULT),
		Destination: self.GetDestination(utils.META_DEFAULT),
		SetupTime:   utils.FirstNonEmpty(setupTimeStr),
		Duration:    usageStr,
	}
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:14,代码来源:smg_event.go


示例2: GetAnswerTime

func (self SMGenericEvent) GetAnswerTime(fieldName, timezone string) (time.Time, error) {
	if fieldName == utils.META_DEFAULT {
		fieldName = utils.ANSWER_TIME
	}
	result, _ := utils.ConvertIfaceToString(self[fieldName])
	return utils.ParseTimeDetectLayout(result, timezone)
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:7,代码来源:smg_event.go


示例3: GetOriginatorIP

func (self SMGenericEvent) GetOriginatorIP(fieldName string) string {
	if fieldName == utils.META_DEFAULT {
		fieldName = utils.CDRHOST
	}
	result, _ := utils.ConvertIfaceToString(self[fieldName])
	return result
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:7,代码来源:smg_event.go


示例4: GetDestination

func (self SMGenericEvent) GetDestination(fieldName string) string {
	if fieldName == utils.META_DEFAULT {
		fieldName = utils.DESTINATION
	}
	result, _ := utils.ConvertIfaceToString(self[fieldName])
	return result
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:7,代码来源:smg_event.go


示例5: GetCategory

func (self SMGenericEvent) GetCategory(fieldName string) string {
	if fieldName == utils.META_DEFAULT {
		fieldName = utils.CATEGORY
	}
	result, _ := utils.ConvertIfaceToString(self[fieldName])
	return result
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:7,代码来源:smg_event.go


示例6: GetAccount

func (self SMGenericEvent) GetAccount(fieldName string) string {
	if fieldName == utils.META_DEFAULT {
		fieldName = utils.ACCOUNT
	}
	result, _ := utils.ConvertIfaceToString(self[fieldName])
	return result
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:7,代码来源:smg_event.go


示例7: GetSubject

func (self SMGenericEvent) GetSubject(fieldName string) string {
	if fieldName == utils.META_DEFAULT {
		fieldName = utils.SUBJECT
	}
	result, _ := utils.ConvertIfaceToString(self[fieldName])
	return result
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:7,代码来源:smg_event.go


示例8: GetDisconnectCause

func (self SMGenericEvent) GetDisconnectCause(fieldName string) string {
	if fieldName == utils.META_DEFAULT {
		fieldName = utils.DISCONNECT_CAUSE
	}
	result, _ := utils.ConvertIfaceToString(self[fieldName])
	return result
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:7,代码来源:smg_event.go


示例9: GetReqType

func (self SMGenericEvent) GetReqType(fieldName string) string {
	if fieldName == utils.META_DEFAULT {
		fieldName = utils.REQTYPE
	}
	result, _ := utils.ConvertIfaceToString(self[fieldName])
	return result
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:7,代码来源:smg_event.go


示例10: GetSupplier

func (self SMGenericEvent) GetSupplier(fieldName string) string {
	if fieldName == utils.META_DEFAULT {
		fieldName = utils.SUPPLIER
	}
	result, _ := utils.ConvertIfaceToString(self[fieldName])
	return result
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:7,代码来源:smg_event.go


示例11: GetPdd

func (self SMGenericEvent) GetPdd(fieldName string) (time.Duration, error) {
	if fieldName == utils.META_DEFAULT {
		fieldName = utils.PDD
	}
	result, _ := utils.ConvertIfaceToString(self[fieldName])
	return utils.ParseDurationWithSecs(result)
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:7,代码来源:smg_event.go


示例12: GetLastUsed

func (self SMGenericEvent) GetLastUsed(fieldName string) (time.Duration, error) {
	if fieldName == utils.META_DEFAULT {
		fieldName = utils.LastUsed
	}
	valStr, hasVal := self[fieldName]
	if !hasVal {
		return nilDuration, utils.ErrNotFound
	}
	result, _ := utils.ConvertIfaceToString(valStr)
	return utils.ParseDurationWithSecs(result)
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:11,代码来源:smg_event.go


示例13: GetFieldAsString

func (self SMGenericEvent) GetFieldAsString(fieldName string) (string, error) {
	valIf, hasVal := self[fieldName]
	if !hasVal {
		return "", utils.ErrNotFound
	}
	result, converted := utils.ConvertIfaceToString(valIf)
	if !converted {
		return "", utils.ErrNotConvertible
	}
	return result, nil
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:11,代码来源:smg_event.go


示例14: GetMaxUsage

func (self SMGenericEvent) GetMaxUsage(fieldName string, cfgMaxUsage time.Duration) (time.Duration, error) {
	if fieldName == utils.META_DEFAULT {
		fieldName = utils.USAGE
	}
	maxUsageStr, hasIt := self[fieldName]
	if !hasIt {
		return cfgMaxUsage, nil
	}
	result, _ := utils.ConvertIfaceToString(maxUsageStr)
	return utils.ParseDurationWithSecs(result)
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:11,代码来源:smg_event.go


示例15: ParseEventValue

func (self SMGenericEvent) ParseEventValue(rsrFld *utils.RSRField, timezone string) string {
	switch rsrFld.Id {
	case utils.CGRID:
		return rsrFld.ParseValue(self.GetCgrId(timezone))
	case utils.TOR:
		return rsrFld.ParseValue(utils.VOICE)
	case utils.ACCID:
		return rsrFld.ParseValue(self.GetUUID())
	case utils.CDRHOST:
		return rsrFld.ParseValue(self.GetOriginatorIP(utils.META_DEFAULT))
	case utils.CDRSOURCE:
		return rsrFld.ParseValue(self.GetName())
	case utils.REQTYPE:
		return rsrFld.ParseValue(self.GetReqType(utils.META_DEFAULT))
	case utils.DIRECTION:
		return rsrFld.ParseValue(self.GetDirection(utils.META_DEFAULT))
	case utils.TENANT:
		return rsrFld.ParseValue(self.GetTenant(utils.META_DEFAULT))
	case utils.CATEGORY:
		return rsrFld.ParseValue(self.GetCategory(utils.META_DEFAULT))
	case utils.ACCOUNT:
		return rsrFld.ParseValue(self.GetAccount(utils.META_DEFAULT))
	case utils.SUBJECT:
		return rsrFld.ParseValue(self.GetSubject(utils.META_DEFAULT))
	case utils.DESTINATION:
		return rsrFld.ParseValue(self.GetDestination(utils.META_DEFAULT))
	case utils.SETUP_TIME:
		st, _ := self.GetSetupTime(utils.META_DEFAULT, timezone)
		return rsrFld.ParseValue(st.String())
	case utils.ANSWER_TIME:
		at, _ := self.GetAnswerTime(utils.META_DEFAULT, timezone)
		return rsrFld.ParseValue(at.String())
	case utils.USAGE:
		dur, _ := self.GetUsage(utils.META_DEFAULT)
		return rsrFld.ParseValue(strconv.FormatInt(dur.Nanoseconds(), 10))
	case utils.PDD:
		pdd, _ := self.GetPdd(utils.META_DEFAULT)
		return rsrFld.ParseValue(strconv.FormatFloat(pdd.Seconds(), 'f', -1, 64))
	case utils.SUPPLIER:
		return rsrFld.ParseValue(self.GetSupplier(utils.META_DEFAULT))
	case utils.DISCONNECT_CAUSE:
		return rsrFld.ParseValue(self.GetDisconnectCause(utils.META_DEFAULT))
	case utils.MEDI_RUNID:
		return rsrFld.ParseValue(utils.META_DEFAULT)
	case utils.COST:
		return rsrFld.ParseValue(strconv.FormatFloat(-1, 'f', -1, 64)) // Recommended to use FormatCost
	default:
		strVal, _ := utils.ConvertIfaceToString(self[rsrFld.Id])
		val := rsrFld.ParseValue(strVal)
		return val
	}
	return ""
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:53,代码来源:smg_event.go


示例16: GetExtraFields

func (self SMGenericEvent) GetExtraFields() map[string]string {
	extraFields := make(map[string]string)
	for key, val := range self {
		primaryFields := append(utils.PrimaryCdrFields, utils.EVENT_NAME)
		if utils.IsSliceMember(primaryFields, key) {
			continue
		}
		result, _ := utils.ConvertIfaceToString(val)
		extraFields[key] = result
	}
	return extraFields
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:12,代码来源:smg_event.go


示例17: GetSessionTTL

// GetSessionTTL retrieves SessionTTL setting out of SMGenericEvent
func (self SMGenericEvent) GetSessionTTL() time.Duration {
	valIf, hasVal := self[utils.SessionTTL]
	if !hasVal {
		return time.Duration(0)
	}
	ttlStr, converted := utils.ConvertIfaceToString(valIf)
	if !converted {
		return time.Duration(0)
	}
	ttl, _ := utils.ParseDurationWithSecs(ttlStr)
	return ttl
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:13,代码来源:smg_event.go


示例18: GetSessionTTLUsage

// GetSessionTTLUsage retrieves SessionTTLUsage setting out of SMGenericEvent
func (self SMGenericEvent) GetSessionTTLUsage() *time.Duration {
	valIf, hasVal := self[utils.SessionTTLUsage]
	if !hasVal {
		return nil
	}
	ttlStr, converted := utils.ConvertIfaceToString(valIf)
	if !converted {
		return nil
	}
	if ttl, err := utils.ParseDurationWithSecs(ttlStr); err != nil {
		return nil
	} else {
		return &ttl
	}
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:16,代码来源:smg_event.go


示例19: GetUUID

func (self SMGenericEvent) GetUUID() string {
	result, _ := utils.ConvertIfaceToString(self[utils.ACCID])
	return result
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:4,代码来源:smg_event.go


示例20: GetName

func (self SMGenericEvent) GetName() string {
	result, _ := utils.ConvertIfaceToString(self[utils.EVENT_NAME])
	return result
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:4,代码来源:smg_event.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang utils.DerivedChargersKey函数代码示例发布时间:2022-05-23
下一篇:
Golang utils.ConcatenatedKey函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap