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


Golang utils.TPAccountActions類代碼示例

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


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

示例1: LoadAccountActions

// Process dependencies and load a specific AccountActions profile from storDb into dataDb.
func (self *ApierV1) LoadAccountActions(attrs utils.TPAccountActions, reply *string) error {
	if len(attrs.TPid) == 0 {
		return utils.NewErrMandatoryIeMissing("TPid")
	}
	dbReader := engine.NewTpReader(self.RatingDb, self.AccountDb, self.StorDb, attrs.TPid, self.Config.DefaultTimezone, self.Config.LoadHistorySize)
	if _, err := engine.Guardian.Guard(func() (interface{}, error) {
		aas := engine.APItoModelAccountAction(&attrs)
		if err := dbReader.LoadAccountActionsFiltered(aas); err != nil {
			return 0, err
		}
		return 0, nil
	}, 0, attrs.KeyId()); err != nil {
		return utils.NewErrServerError(err)
	}
	// ToDo: Get the action keys loaded by dbReader so we reload only these in cache
	// Need to do it before scheduler otherwise actions to run will be unknown
	if err := self.RatingDb.CacheRatingPrefixes(utils.DERIVEDCHARGERS_PREFIX, utils.ACTION_PREFIX, utils.SHARED_GROUP_PREFIX); err != nil {
		return err
	}
	if self.Sched != nil {
		self.Sched.LoadActionPlans(self.RatingDb)
		self.Sched.Restart()
	}
	*reply = OK
	return nil
}
開發者ID:nikbyte,項目名稱:cgrates,代碼行數:27,代碼來源:apier.go

示例2: GetTPAccountActionsByLoadId

// Queries specific AccountActions profile on tariff plan
func (self *ApierV1) GetTPAccountActionsByLoadId(attrs utils.TPAccountActions, reply *[]*utils.TPAccountActions) error {
	mndtryFlds := []string{"TPid", "LoadId"}
	if len(attrs.Account) != 0 { // If account provided as filter, make all related fields mandatory
		mndtryFlds = append(mndtryFlds, "Tenant", "Account")
	}
	if missing := utils.MissingStructFields(&attrs, mndtryFlds); len(missing) != 0 { //Params missing
		return utils.NewErrMandatoryIeMissing(missing...)
	}
	aas := engine.APItoModelAccountAction(&attrs)
	if aa, err := self.StorDb.GetTpAccountActions(aas); err != nil {
		return utils.NewErrServerError(err)
	} else if len(aa) == 0 {
		return utils.ErrNotFound
	} else {

		tpAa, err := engine.TpAccountActions(aa).GetAccountActions()
		if err != nil {
			return err
		}
		var acts []*utils.TPAccountActions
		if len(attrs.Account) != 0 {
			acts = []*utils.TPAccountActions{tpAa[attrs.KeyId()]}
		} else {
			for _, actLst := range tpAa {
				acts = append(acts, actLst)
			}
		}
		*reply = acts
	}
	return nil
}
開發者ID:eloycoto,項目名稱:cgrates,代碼行數:32,代碼來源:tpaccountactions.go

示例3: GetTPAccountActions

// Queries specific DerivedCharge on tariff plan
func (self *ApierV1) GetTPAccountActions(attrs AttrGetTPAccountActions, reply *utils.TPAccountActions) error {
	if missing := utils.MissingStructFields(&attrs, []string{"TPid", "AccountActionsId"}); len(missing) != 0 { //Params missing
		return utils.NewErrMandatoryIeMissing(missing...)
	}
	tmpAa := &utils.TPAccountActions{TPid: attrs.TPid}
	if err := tmpAa.SetAccountActionsId(attrs.AccountActionsId); err != nil {
		return err
	}
	tmpAaa := engine.APItoModelAccountAction(tmpAa)
	if aas, err := self.StorDb.GetTpAccountActions(tmpAaa); err != nil {
		return utils.NewErrServerError(err)
	} else if len(aas) == 0 {
		return utils.ErrNotFound
	} else {
		tpAaa, err := engine.TpAccountActions(aas).GetAccountActions()
		if err != nil {
			return err
		}
		aa := tpAaa[tmpAa.KeyId()]
		tpdc := utils.TPAccountActions{
			TPid:             attrs.TPid,
			ActionPlanId:     aa.ActionPlanId,
			ActionTriggersId: aa.ActionTriggersId,
		}
		if err := tpdc.SetAccountActionsId(attrs.AccountActionsId); err != nil {
			return err
		}
		*reply = tpdc
	}
	return nil
}
開發者ID:eloycoto,項目名稱:cgrates,代碼行數:32,代碼來源:tpaccountactions.go

示例4: GetTPAccountActions

// Queries specific DerivedCharge on tariff plan
func (self *ApierV1) GetTPAccountActions(attrs AttrGetTPAccountActions, reply *utils.TPAccountActions) error {
	if missing := utils.MissingStructFields(&attrs, []string{"TPid", "AccountActionsId"}); len(missing) != 0 { //Params missing
		return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
	}
	tmpAa := &utils.TPAccountActions{TPid: attrs.TPid}
	if err := tmpAa.SetAccountActionsId(attrs.AccountActionsId); err != nil {
		return err
	}
	if aas, err := self.StorDb.GetTpAccountActions(tmpAa); err != nil {
		return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
	} else if len(aas) == 0 {
		return errors.New(utils.ERR_NOT_FOUND)
	} else {
		aa := aas[tmpAa.KeyId()]
		tpdc := utils.TPAccountActions{
			TPid:             attrs.TPid,
			ActionPlanId:     aa.ActionPlanId,
			ActionTriggersId: aa.ActionTriggersId,
		}
		if err := tpdc.SetAccountActionsId(attrs.AccountActionsId); err != nil {
			return err
		}
		*reply = tpdc
	}
	return nil
}
開發者ID:intralanman,項目名稱:cgrates,代碼行數:27,代碼來源:tpaccountactions.go

示例5: GetTPAccountActionsByLoadId

// Queries specific AccountActions profile on tariff plan
func (self *ApierV1) GetTPAccountActionsByLoadId(attrs utils.TPAccountActions, reply *[]*utils.TPAccountActions) error {
	mndtryFlds := []string{"TPid", "LoadId"}
	if len(attrs.Account) != 0 { // If account provided as filter, make all related fields mandatory
		mndtryFlds = append(mndtryFlds, "Tenant", "Account", "Direction")
	}
	if missing := utils.MissingStructFields(&attrs, mndtryFlds); len(missing) != 0 { //Params missing
		return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
	}
	if aa, err := self.StorDb.GetTpAccountActions(&attrs); err != nil {
		return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
	} else if len(aa) == 0 {
		return errors.New(utils.ERR_NOT_FOUND)
	} else {
		var acts []*utils.TPAccountActions
		if len(attrs.Account) != 0 {
			acts = []*utils.TPAccountActions{aa[attrs.KeyId()]}
		} else {
			for _, actLst := range aa {
				acts = append(acts, actLst)
			}
		}
		*reply = acts
	}
	return nil
}
開發者ID:intralanman,項目名稱:cgrates,代碼行數:26,代碼來源:tpaccountactions.go

示例6: LoadAccountActions

// Process dependencies and load a specific AccountActions profile from storDb into dataDb.
func (self *ApierV1) LoadAccountActions(attrs utils.TPAccountActions, reply *string) error {
	if len(attrs.TPid) == 0 {
		return utils.NewErrMandatoryIeMissing("TPid")
	}
	dbReader := engine.NewTpReader(self.RatingDb, self.AccountDb, self.StorDb, attrs.TPid, self.Config.DefaultTimezone)
	if _, err := engine.Guardian.Guard(func() (interface{}, error) {
		aas := engine.APItoModelAccountAction(&attrs)
		if err := dbReader.LoadAccountActionsFiltered(aas); err != nil {
			return 0, err
		}
		return 0, nil
	}, 0, attrs.KeyId()); err != nil {
		return utils.NewErrServerError(err)
	}
	// ToDo: Get the action keys loaded by dbReader so we reload only these in cache
	// Need to do it before scheduler otherwise actions to run will be unknown
	sched := self.ServManager.GetScheduler()
	if sched != nil {
		sched.Reload()
	}
	*reply = OK
	return nil
}
開發者ID:cgrates,項目名稱:cgrates,代碼行數:24,代碼來源:apier.go

示例7: LoadAccountActions

// Process dependencies and load a specific AccountActions profile from storDb into dataDb.
func (self *ApierV1) LoadAccountActions(attrs utils.TPAccountActions, reply *string) error {
	if missing := utils.MissingStructFields(&attrs, []string{"TPid", "LoadId", "Tenant", "Account", "Direction"}); len(missing) != 0 {
		return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
	}
	dbReader := engine.NewDbReader(self.StorDb, self.RatingDb, self.AccountDb, attrs.TPid)
	if attrs.LoadId == utils.EMPTY {
		attrs.LoadId = ""
	}
	if attrs.Tenant == utils.EMPTY {
		attrs.Tenant = ""
	}
	if attrs.Account == utils.EMPTY {
		attrs.Account = ""
	}
	if attrs.Direction == utils.EMPTY {
		attrs.Direction = ""
	}
	if _, err := engine.AccLock.Guard(attrs.KeyId(), func() (float64, error) {
		if err := dbReader.LoadAccountActionsFiltered(&attrs); err != nil {
			return 0, err
		}
		return 0, nil
	}); err != nil {
		return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
	}
	// ToDo: Get the action keys loaded by dbReader so we reload only these in cache
	// Need to do it before scheduler otherwise actions to run will be unknown
	if err := self.AccountDb.CacheAccounting(nil, nil, nil, []string{}); err != nil {
		return err
	}
	if self.Sched != nil {
		self.Sched.LoadActionTimings(self.AccountDb)
		self.Sched.Restart()
	}
	*reply = OK
	return nil
}
開發者ID:intralanman,項目名稱:cgrates,代碼行數:38,代碼來源:apier.go

示例8: SetTPAccountActions

// Creates a new AccountActions profile within a tariff plan
func (self *ApierV1) SetTPAccountActions(attrs utils.TPAccountActions, reply *string) error {
	if missing := utils.MissingStructFields(&attrs,
		[]string{"TPid", "LoadId", "Tenant", "Account", "Direction", "ActionPlanId", "ActionTriggersId"}); len(missing) != 0 {
		return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
	}
	if err := self.StorDb.SetTPAccountActions(attrs.TPid, map[string]*utils.TPAccountActions{attrs.KeyId(): &attrs}); err != nil {
		return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
	}
	*reply = "OK"
	return nil
}
開發者ID:intralanman,項目名稱:cgrates,代碼行數:12,代碼來源:tpaccountactions.go


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