protected override void OnSelecting(DataSelectContextBase context) { base.OnSelecting(context); //设置结果过滤器 context.ResultFilter = this.OnResultFilter; }
private bool OnResultFilter(DataSelectContextBase context, ref object data) { var dictionary = DataDictionary.GetDictionary <Models.Post>(data); if (dictionary.TryGetValue(p => p.Approved, out var approved) && !approved && (!context.Principal.Identity.IsAuthenticated || context.Principal.Identity.Credential.User.UserId != dictionary.GetValue(p => p.CreatorId, 0U))) { dictionary.TrySetValue(p => p.Content, string.Empty); } else if (dictionary.TryGetValue(p => p.Content, out var content) && dictionary.TryGetValue(p => p.ContentType, out var contentType)) { if (!Utility.IsContentEmbedded(contentType)) { dictionary.SetValue(p => p.Content, Utility.ReadTextFile(content)); } } return(true); }
private bool OnResultFilter(DataSelectContextBase context, ref object data) { var dictionary = DataDictionary.GetDictionary <Models.Thread>(data); if (!dictionary.TryGetValue(p => p.Post, out var post) || post == null) { return(true); } if (dictionary.TryGetValue(p => p.Approved, out var approved) && !approved && (!context.Principal.Identity.IsAuthenticated || context.Principal.Identity.Credential.User.UserId != dictionary.GetValue(p => p.CreatorId, 0U))) { post.Content = string.Empty; } else if (!string.IsNullOrEmpty(post.Content) && !string.IsNullOrEmpty(post.ContentType)) { if (!Utility.IsContentEmbedded(post.ContentType)) { post.Content = Utility.ReadTextFile(post.Content); } } return(true); }
protected virtual void OnSelected(DataSelectContextBase context) { }
protected override void OnSelect(DataSelectContextBase context) { this.Provider.Execute((IDataAccessContext)context); }
public DataGettingEventArgs(DataSelectContextBase context) : base(context) { _cancel = false; }
public DataGettedEventArgs(DataSelectContextBase context) : base(context) { }