-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEMMSeedDataGenerator.cs
More file actions
110 lines (86 loc) · 3.93 KB
/
Copy pathEMMSeedDataGenerator.cs
File metadata and controls
110 lines (86 loc) · 3.93 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using BExIS.Dlm.Entities.Data;
using BExIS.Dlm.Entities.DataStructure;
using BExIS.Dlm.Entities.MetadataStructure;
using BExIS.Dlm.Services.Administration;
using BExIS.Dlm.Services.DataStructure;
using BExIS.Dlm.Services.MetadataStructure;
using BExIS.Emm.Entities.Event;
using BExIS.Emm.Services.Event;
using BExIS.Security.Entities.Objects;
using BExIS.Security.Services.Objects;
using BExIS.Xml.Helpers;
using BExIS.Xml.Helpers.Mapping;
using System;
using System.IO;
using System.Linq;
using System.Xml;
using Vaiona.Persistence.Api;
using Vaiona.Utils.Cfg;
using Vaiona.Web.Mvc.Modularity;
namespace BExIS.Modules.EMM.UI.Helpers
{
public class EMMSeedDataGenerator : IModuleSeedDataGenerator
{
public void GenerateSeedData()
{
EntityManager entityManager = new EntityManager();
try
{
#region create Entities
// Entities
Entity entity = entityManager.Entities.Where(e => e.Name.ToUpperInvariant() == "Event".ToUpperInvariant()).FirstOrDefault();
if (entity == null)
{
entity = new Entity();
entity.Name = "Event";
entity.EntityType = typeof(Event);
entity.EntityStoreType = typeof(EventStore);
entity.UseMetadata = true;
entity.Securable = true;
entityManager.Create(entity);
}
#endregion
#region SECURITY
OperationManager operationManager = new OperationManager();
FeatureManager featureManager = new FeatureManager();
try
{
Feature rootEventManagementFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Event Management"));
if (rootEventManagementFeature == null) rootEventManagementFeature = featureManager.Create("Event Management", "Event Management");
Feature eventRegistrationFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Event Registration"));
if (eventRegistrationFeature == null) eventRegistrationFeature = featureManager.Create("Event Registration", "Event Registration", rootEventManagementFeature);
Feature eventAdministrationFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Event Administration"));
if (eventAdministrationFeature == null) eventAdministrationFeature = featureManager.Create("Event Administration", "Event Administration", rootEventManagementFeature);
Feature eventRegistrationResultFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Event Registration Result"));
if (eventRegistrationResultFeature == null) eventRegistrationResultFeature = featureManager.Create("Event Registration Result", "Event Registration Result", rootEventManagementFeature);
operationManager.Create("EMM", "EventRegistration", "*", eventRegistrationFeature);
operationManager.Create("EMM", "Event", "*", eventAdministrationFeature);
operationManager.Create("EMM", "EventRegistrationResult", "*", eventRegistrationResultFeature);
}
catch (Exception ex)
{
throw ex;
}
finally
{
featureManager.Dispose();
operationManager.Dispose();
}
#endregion
}
catch (Exception ex)
{
throw ex;
}
finally
{
entityManager.Dispose();
}
}
public void Dispose()
{
// nothing to do for now...
}
}
}