当前位置: 首页>>代码示例>>Golang>>正文


Golang CDR.PassesFieldFilter方法代码示例

本文整理汇总了Golang中github.com/cgrates/cgrates/engine.CDR.PassesFieldFilter方法的典型用法代码示例。如果您正苦于以下问题:Golang CDR.PassesFieldFilter方法的具体用法?Golang CDR.PassesFieldFilter怎么用?Golang CDR.PassesFieldFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cgrates/cgrates/engine.CDR的用法示例。


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

示例1: getDateTimeFieldVal

func (cdre *CdrExporter) getDateTimeFieldVal(cdr *engine.CDR, cfgCdrFld *config.CfgCdrField) (string, error) {
	if len(cfgCdrFld.Value) == 0 {
		return "", nil
	}
	for _, fltrRl := range cfgCdrFld.FieldFilter {
		if fltrPass, _ := cdr.PassesFieldFilter(fltrRl); !fltrPass {
			return "", fmt.Errorf("Field: %s not matching filter rule %v", fltrRl.Id, fltrRl)
		}
	}
	layout := cfgCdrFld.Layout
	if len(layout) == 0 {
		layout = time.RFC3339
	}
	if dtFld, err := utils.ParseTimeDetectLayout(cdr.FieldAsString(cfgCdrFld.Value[0]), cdre.timezone); err != nil { // Only one rule makes sense here
		return "", err
	} else {
		return dtFld.Format(layout), nil
	}
}
开发者ID:bhepp,项目名称:cgrates,代码行数:19,代码来源:cdrexporter.go

示例2: getCombimedCdrFieldVal

func (cdre *CdrExporter) getCombimedCdrFieldVal(processedCdr *engine.CDR, cfgCdrFld *config.CfgCdrField) (string, error) {
	var combinedVal string // Will result as combination of the field values, filters must match
	for _, filterRule := range cfgCdrFld.FieldFilter {
		fltrPass, ftrPassValue := processedCdr.PassesFieldFilter(filterRule)
		if !fltrPass {
			return "", nil
		}
		for _, cdr := range cdre.cdrs {
			if cdr.CGRID != processedCdr.CGRID {
				continue // We only care about cdrs with same primary cdr behind
			}
			if cdr.FieldAsString(&utils.RSRField{Id: filterRule.Id}) == ftrPassValue { // First CDR with filte
				for _, rsrRule := range cfgCdrFld.Value {
					combinedVal += cdr.FieldAsString(rsrRule)
				}
			}
		}
	}
	return combinedVal, nil
}
开发者ID:bhepp,项目名称:cgrates,代码行数:20,代码来源:cdrexporter.go

示例3: cdrFieldValue

// Extracts the value specified by cfgHdr out of cdr
func (cdre *CdrExporter) cdrFieldValue(cdr *engine.CDR, cfgCdrFld *config.CfgCdrField) (string, error) {
	for _, fltrRl := range cfgCdrFld.FieldFilter {
		if fltrPass, _ := cdr.PassesFieldFilter(fltrRl); !fltrPass {
			return "", fmt.Errorf("Field: %s not matching filter rule %v", fltrRl.Id, fltrRl)
		}
	}
	layout := cfgCdrFld.Layout
	if len(layout) == 0 {
		layout = time.RFC3339
	}
	var retVal string // Concatenate the resulting values
	for _, rsrFld := range cfgCdrFld.Value {
		var cdrVal string
		switch rsrFld.Id {
		case COST_DETAILS: // Special case when we need to further extract cost_details out of logDb
			if cdr.ExtraFields[COST_DETAILS], err = cdre.getCdrCostDetails(cdr.CGRID, cdr.RunID); err != nil {
				return "", err
			} else {
				cdrVal = cdr.FieldAsString(rsrFld)
			}
		case utils.COST:
			cdrVal = cdr.FormatCost(cdre.costShiftDigits, cdre.roundDecimals)
		case utils.USAGE:
			cdrVal = cdr.FormatUsage(layout)
		case utils.SETUP_TIME:
			cdrVal = cdr.SetupTime.Format(layout)
		case utils.ANSWER_TIME: // Format time based on layout
			cdrVal = cdr.AnswerTime.Format(layout)
		case utils.DESTINATION:
			cdrVal = cdr.FieldAsString(rsrFld)
			if cdre.maskLen != -1 && cdre.maskedDestination(cdrVal) {
				cdrVal = MaskDestination(cdrVal, cdre.maskLen)
			}
		default:
			cdrVal = cdr.FieldAsString(rsrFld)
		}
		retVal += cdrVal
	}
	return retVal, nil
}
开发者ID:bhepp,项目名称:cgrates,代码行数:41,代码来源:cdrexporter.go


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