Skip to content

Commit 5a2eaed

Browse files
committed
Missing events added to mvc filter
1 parent c80ee81 commit 5a2eaed

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

src/JQDT.MVC/JQDataTableAttribute.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public override void OnActionExecuted(ActionExecutedContext filterContext)
3636
}
3737

3838
/// <summary>
39-
/// Called when [data processed].
39+
/// Called after all data processors execute.
4040
/// </summary>
4141
/// <param name="data">The data.</param>
4242
/// <param name="requestInfoModel">The request information model.</param>
@@ -45,6 +45,16 @@ public virtual void OnDataProcessed(ref object data, RequestInfoModel requestInf
4545
// No data processing logic by default;
4646
}
4747

48+
/// <summary>
49+
/// Called before all data processors execute.
50+
/// </summary>
51+
/// <param name="data">The data.</param>
52+
/// <param name="requestInfoModel">The request information model.</param>
53+
public virtual void OnDataProcessing(ref object data, RequestInfoModel requestInfoModel)
54+
{
55+
// No data processing logic by default;
56+
}
57+
4858
/// <summary>
4959
/// Called when [search data processing].
5060
/// </summary>
@@ -55,6 +65,16 @@ public virtual void OnSearchDataProcessing(ref object data, RequestInfoModel req
5565
// No data processing logic by default;
5666
}
5767

68+
/// <summary>
69+
/// Called when [search data processed].
70+
/// </summary>
71+
/// <param name="data">The data.</param>
72+
/// <param name="requestInfoModel">The request information model.</param>
73+
public virtual void OnSearchDataProcessed(ref object data, RequestInfoModel requestInfoModel)
74+
{
75+
// No data processing logic by default;
76+
}
77+
5878
/// <summary>
5979
/// Called when [custom filters data processing].
6080
/// </summary>
@@ -158,8 +178,11 @@ private void PerformOnActionExecuted(ActionExecutedContext filterContext)
158178

159179
private void SubscribeToEvents(IApplicationBase application)
160180
{
181+
application.OnDataProcessingEvent += this.OnDataProcessing;
161182
application.OnDataProcessedEvent += this.OnDataProcessed;
183+
162184
application.OnSearchDataProcessingEvent += this.OnSearchDataProcessing;
185+
application.OnSearchDataProcessedEvent += this.OnSearchDataProcessed;
163186

164187
application.OnCustomFiltersDataProcessingEvent += this.OnCustomFiltersDataProcessing;
165188
application.OnCustomFiltersDataProcessedEvent += this.OnCustomFiltersDataProcessed;

src/JQDT/Application/ApplicationBase.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public ApplicationBase(IDependencyResolver dependencyResolver)
2828
this.dependencyResolver = dependencyResolver;
2929
}
3030

31+
public event DataProcessorEventHandler OnDataProcessingEvent = delegate { };
32+
3133
/// <summary>
3234
/// Occurs when [on data processed].
3335
/// </summary>
@@ -100,9 +102,13 @@ public ResultModel Execute()
100102
var requestModel = modelBinder.BindModel(ajaxForm, data);
101103

102104
var dataProcessChain = this.GetDataProcessChain(requestModel.Helpers.DataCollectionType);
105+
106+
// Call events before the data is processed
107+
this.PerformDataProcessorEventHandler(ref data, requestModel);
108+
103109
var processedData = dataProcessChain.ProcessData(data, requestModel);
104110

105-
// Call on data processed event
111+
// Call events after the data is processed
106112
this.PerformDataProcessorEventHandler(ref processedData, requestModel);
107113

108114
result.Data = processedData.ToList().Select(x => (object)x).ToList();

src/JQDT/Application/IApplicationBase.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
/// </summary>
99
public interface IApplicationBase
1010
{
11+
/// <summary>
12+
/// Occurs when [on data processing event].
13+
/// </summary>
14+
event DataProcessorEventHandler OnDataProcessingEvent;
15+
1116
/// <summary>
1217
/// Occurs when [on data processed].
1318
/// </summary>
@@ -18,6 +23,11 @@ public interface IApplicationBase
1823
/// </summary>
1924
event DataProcessorEventHandler OnSearchDataProcessingEvent;
2025

26+
/// <summary>
27+
/// Occurs when [on search data processed event].
28+
/// </summary>
29+
event DataProcessorEventHandler OnSearchDataProcessedEvent;
30+
2131
/// <summary>
2232
/// Occurs when [on custom filters data processing event].
2333
/// </summary>

0 commit comments

Comments
 (0)