I'm attempting to voting information to the context of a rule (RuleTriggerExecutionContext). I need to be able to get the date that a vote was cast in a poll. What type do I need to pass in order to be able to get that same info from the context in a token? If there's not a supporting type, is there a way to pass a single value (i.e. using the PollVoteEventArgs)?
//Rule public RuleTriggerExecutionContext GetExecutionContext(RuleTriggerData data) { var context = new RuleTriggerExecutionContext(); var userId = int.Parse(data["UserId"]); var threadContentId = Guid.Parse(data["ContentId"]); var voteId = int.Parse(data["VoteId"]); var voteDate = DateTime.Parse(data["VoteDate"]); context.Add(Apis.Get<Users>().ContentTypeId, Apis.Get<Users>().Get(new UsersGetOptions() { Id = userId })); context.Add(Apis.Get<IForumThreads>().ContentTypeId, Apis.Get<IForumThreads>().Get(threadContentId)); context.Add(Guid.Parse("41f4bfd9-c2eb-4638-9a47-aa7d471730aa"), Apis.Get<IForumReplyVotes>().Get(voteId)); context.Add(Guid.Parse("beea2e25 - a716 - 44c8 - aeaa - 2d2853f6af0f"), voteDate); return context; } public void SetController(IRuleController controller) { _ruleController = controller; } private void PollEvent_OnVote(PollVoteEventArgs vote) { var data = new Dictionary<string, string> { {"UserId", vote.VotingUserId.ToString() }, {"ContentId", vote.ContentId.ToString() }, {"VoteId", vote.Id.ToString() }, {"VoteDate", vote.CreatedDate.ToString() } }; _ruleController.ScheduleTrigger(data); }
// Token tokenController.Register(new TokenizedTemplateToken( "PollVoteDate", "PollVoteDateDescription", _controller, Guid.Parse("beea2e25-a716-44c8-aeaa-2d2853f6af0f"), dataTypeId, PrimitiveType.DateTime, context => // How to get the voteDate from the rule? ));