Querying the segment by Characteristic(Location) through code
Hi Team,
I am using sitefinity 7.0 with personalization module in my project. I have created 4 user segment and added different characteristics(Location) in the each segment. I want to Querying the segment by Characteristic(Location) through code. Please send me some sample code. It is urgent.
Thanks & Regards,
Pravat Sharma
Hi Team,
Please help out to solve the above issue as soon as possible.
Thanks & Regards,
Pravat Sharma
Hi team,
Still I am waiting your reply. Please provide me the solution for above issue.
Hello,
To get all segments use:
var segments = PersonalizationService .GetActiveSegments();
var segments = PersonalizationService .GetActiveSegments()
// for each segment
foreach
(var segment
in
segments)
bool
isSegmentMatch =
true
;
// for each criteria group
foreach
(var criteriaGroup
in
segment.CriteriaGroups)
bool
isGroupMatch =
false
;
// for each criterion (remember, criteria is in the OR conditions)
foreach
(var criterion
in
criteriaGroup.Criteria)
if
(
this
.IsCriteriaMatch(criterion, testContext))
isGroupMatch =
true
;
break
;
// if a group was a match, return the segment
if
(!isGroupMatch)
isSegmentMatch =
false
;
break
;
if
(isSegmentMatch)
return
segment;