-
Notifications
You must be signed in to change notification settings - Fork 21
/
FeatureDefinitionActor.cs
79 lines (68 loc) · 2.63 KB
/
FeatureDefinitionActor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using Akka.Actor;
using Akka.Event;
using FeatureAdmin.Core.Messages.Request;
using FeatureAdmin.Core.Services;
using FeatureAdmin.Messages;
namespace FeatureAdmin.Actors
{
/// <summary>
/// class to convert a SharePoint location and its children to SPLocation objects
/// </summary>
public class FeatureDefinitionActor : BaseActor
{
private readonly IDataService dataService;
private readonly ILoggingAdapter _log = Logging.GetLogger(Context);
public FeatureDefinitionActor(IDataService dataService)
{
this.dataService = dataService;
Receive<LoadFeatureDefinitionQuery>(message => LoadFarmFeatures(message));
}
private void LoadFarmFeatures(LoadFeatureDefinitionQuery message)
{
_log.Debug("Entered LoadFarmFeatures");
if (!TaskCanceled)
{
try
{
var farmFeatureDefinitions = dataService.LoadFarmFeatureDefinitions();
if (farmFeatureDefinitions == null)
{
_log.Error("Farm Feature Definitions not found!");
}
Sender.Tell(new Core.Messages.Completed.FarmFeatureDefinitionsLoaded(
message.TaskId,
farmFeatureDefinitions));
//TODO: maybe check, if feature definitions from here have more data, than from activated features ...
}
catch (Exception ex)
{
var cancelationMsg = new CancelMessage(
message.TaskId,
"Error loading feature definitions.",
true,
ex
);
Sender.Tell(cancelationMsg);
}
}
}
/// <summary>
/// Props provider
/// </summary>
/// <param name="dataService">SharePoint data service</param>
/// <returns></returns>
/// <remarks>
/// see also https://getakka.net/articles/actors/receive-actor-api.html
/// </remarks>
public static Props Props(IDataService dataService)
{
return Akka.Actor.Props.Create(() => new FeatureDefinitionActor(
dataService));
}
protected override void ReceiveCancelMessage(CancelMessage message)
{
CancelationMessage = message.CancelationMessage;
}
}
}