當前位置: 首頁>>代碼示例>>Golang>>正文


Golang RSRField.IsStatic方法代碼示例

本文整理匯總了Golang中github.com/cgrates/cgrates/utils.RSRField.IsStatic方法的典型用法代碼示例。如果您正苦於以下問題:Golang RSRField.IsStatic方法的具體用法?Golang RSRField.IsStatic怎麽用?Golang RSRField.IsStatic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cgrates/cgrates/utils.RSRField的用法示例。


在下文中一共展示了RSRField.IsStatic方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: FieldAsString

// Used to retrieve fields as string, primary fields are const labeled
func (storedCdr *StoredCdr) FieldAsString(rsrFld *utils.RSRField) string {
	if rsrFld.IsStatic() { // Static values do not care about headers
		return rsrFld.ParseValue("")
	}
	switch rsrFld.Id {
	case utils.CGRID:
		return rsrFld.ParseValue(storedCdr.CgrId)
	case utils.ORDERID:
		return rsrFld.ParseValue(strconv.FormatInt(storedCdr.OrderId, 10))
	case utils.TOR:
		return rsrFld.ParseValue(storedCdr.TOR)
	case utils.ACCID:
		return rsrFld.ParseValue(storedCdr.AccId)
	case utils.CDRHOST:
		return rsrFld.ParseValue(storedCdr.CdrHost)
	case utils.CDRSOURCE:
		return rsrFld.ParseValue(storedCdr.CdrSource)
	case utils.REQTYPE:
		return rsrFld.ParseValue(storedCdr.ReqType)
	case utils.DIRECTION:
		return rsrFld.ParseValue(storedCdr.Direction)
	case utils.TENANT:
		return rsrFld.ParseValue(storedCdr.Tenant)
	case utils.CATEGORY:
		return rsrFld.ParseValue(storedCdr.Category)
	case utils.ACCOUNT:
		return rsrFld.ParseValue(storedCdr.Account)
	case utils.SUBJECT:
		return rsrFld.ParseValue(storedCdr.Subject)
	case utils.DESTINATION:
		return rsrFld.ParseValue(storedCdr.Destination)
	case utils.SETUP_TIME:
		return rsrFld.ParseValue(storedCdr.SetupTime.Format(time.RFC3339))
	case utils.PDD:
		return strconv.FormatFloat(storedCdr.Pdd.Seconds(), 'f', -1, 64)
	case utils.ANSWER_TIME:
		return rsrFld.ParseValue(storedCdr.AnswerTime.Format(time.RFC3339))
	case utils.USAGE:
		return strconv.FormatFloat(storedCdr.Usage.Seconds(), 'f', -1, 64)
	case utils.SUPPLIER:
		return rsrFld.ParseValue(storedCdr.Supplier)
	case utils.DISCONNECT_CAUSE:
		return rsrFld.ParseValue(storedCdr.DisconnectCause)
	case utils.MEDI_RUNID:
		return rsrFld.ParseValue(storedCdr.MediationRunId)
	case utils.RATED_ACCOUNT:
		return rsrFld.ParseValue(storedCdr.RatedAccount)
	case utils.RATED_SUBJECT:
		return rsrFld.ParseValue(storedCdr.RatedSubject)
	case utils.RATED_FLD:
		return rsrFld.ParseValue(strconv.FormatBool(storedCdr.Rated))
	case utils.COST:
		return rsrFld.ParseValue(strconv.FormatFloat(storedCdr.Cost, 'f', -1, 64)) // Recommended to use FormatCost
	case utils.COST_DETAILS:
		return rsrFld.ParseValue(storedCdr.CostDetailsJson())
	default:
		return rsrFld.ParseValue(storedCdr.ExtraFields[rsrFld.Id])
	}
}
開發者ID:henrylee2cn,項目名稱:cgrates,代碼行數:60,代碼來源:storedcdr.go

示例2: PassesFieldFilter

func (storedCdr *StoredCdr) PassesFieldFilter(fieldFilter *utils.RSRField) (bool, string) {
	if fieldFilter == nil {
		return true, ""
	}
	if fieldFilter.IsStatic() && storedCdr.FieldAsString(&utils.RSRField{Id: fieldFilter.Id}) == storedCdr.FieldAsString(fieldFilter) {
		return true, storedCdr.FieldAsString(&utils.RSRField{Id: fieldFilter.Id})
	}
	preparedFilter := &utils.RSRField{Id: fieldFilter.Id, RSRules: make([]*utils.ReSearchReplace, len(fieldFilter.RSRules))} // Reset rules so they do not point towards same structures as original fieldFilter
	for idx := range fieldFilter.RSRules {
		// Hardcode the template with maximum of 5 groups ordered
		preparedFilter.RSRules[idx] = &utils.ReSearchReplace{SearchRegexp: fieldFilter.RSRules[idx].SearchRegexp, ReplaceTemplate: utils.FILTER_REGEXP_TPL}
	}
	preparedVal := storedCdr.FieldAsString(preparedFilter)
	filteredValue := storedCdr.FieldAsString(fieldFilter)
	if preparedFilter.RegexpMatched() && (len(preparedVal) == 0 || preparedVal == filteredValue) {
		return true, filteredValue
	}
	return false, ""
}
開發者ID:henrylee2cn,項目名稱:cgrates,代碼行數:19,代碼來源:storedcdr.go

示例3: PassesFieldFilter

func (fsev FSEvent) PassesFieldFilter(fieldFilter *utils.RSRField) (bool, string) {
	// Keep in sync (or merge) with StoredCdr.PassesFieldFielter()
	if fieldFilter == nil {
		return true, ""
	}
	if fieldFilter.IsStatic() && fsev.ParseEventValue(&utils.RSRField{Id: fieldFilter.Id}, config.CgrConfig().DefaultTimezone) == fsev.ParseEventValue(fieldFilter, config.CgrConfig().DefaultTimezone) {
		return true, fsev.ParseEventValue(&utils.RSRField{Id: fieldFilter.Id}, config.CgrConfig().DefaultTimezone)
	}
	preparedFilter := &utils.RSRField{Id: fieldFilter.Id, RSRules: make([]*utils.ReSearchReplace, len(fieldFilter.RSRules))} // Reset rules so they do not point towards same structures as original fieldFilter
	for idx := range fieldFilter.RSRules {
		// Hardcode the template with maximum of 5 groups ordered
		preparedFilter.RSRules[idx] = &utils.ReSearchReplace{SearchRegexp: fieldFilter.RSRules[idx].SearchRegexp, ReplaceTemplate: utils.FILTER_REGEXP_TPL}
	}
	preparedVal := fsev.ParseEventValue(preparedFilter, config.CgrConfig().DefaultTimezone)
	filteredValue := fsev.ParseEventValue(fieldFilter, config.CgrConfig().DefaultTimezone)
	if preparedFilter.RegexpMatched() && (len(preparedVal) == 0 || preparedVal == filteredValue) {
		return true, filteredValue
	}
	return false, ""
}
開發者ID:kevinlovesing,項目名稱:cgrates,代碼行數:20,代碼來源:fsevent.go


注:本文中的github.com/cgrates/cgrates/utils.RSRField.IsStatic方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。