Skip to content

Commit e08ca07

Browse files
authored
Merge pull request #29 from microting/master
Updates
2 parents 0b07a88 + 6a872c4 commit e08ca07

File tree

12 files changed

+553
-152
lines changed

12 files changed

+553
-152
lines changed

eFormAPI/Installation/CustomActions/CustomAction.cs

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -273,51 +273,61 @@ private static void BackupPluginSettings(Session session, string installFolder)
273273
Directory.CreateDirectory(tmpConfigs);
274274
Directory.CreateDirectory(Path.Combine(tmpConfigs, "plugin_modules"));
275275

276-
// plugins.routing.ts
277-
var src = Path.Combine(installFolder, "src\\app\\plugins\\plugins.routing.ts");
278-
session.Log("BackupPluginSettings src is : " + src.ToString());
279-
File.Copy(src, Path.Combine(tmpConfigs, "plugins.routing.ts"), true);
276+
// This try catch is only for upgrading preplugin versions.
277+
try
278+
{
279+
// plugins.routing.ts
280+
var src = Path.Combine(installFolder, "src\\app\\plugins\\plugins.routing.ts");
281+
session.Log("BackupPluginSettings src is : " + src.ToString());
282+
File.Copy(src, Path.Combine(tmpConfigs, "plugins.routing.ts"), true);
280283

281-
string[] dirs = Directory.GetDirectories(Path.Combine(installFolder, "src\\app\\plugins\\modules\\"));
284+
string[] dirs = Directory.GetDirectories(Path.Combine(installFolder, "src\\app\\plugins\\modules\\"));
282285

283-
foreach (string dir in dirs)
284-
{
285-
string folder = dir.Split(Path.DirectorySeparatorChar).Last();
286-
if (folder != "example-pn" && folder != "shared")
286+
foreach (string dir in dirs)
287287
{
288-
DirectoryCopy(dir, Path.Combine(tmpConfigs, "plugin_modules", folder), true);
289-
}
290-
}
288+
string folder = dir.Split(Path.DirectorySeparatorChar).Last();
289+
if (folder != "example-pn" && folder != "shared")
290+
{
291+
DirectoryCopy(dir, Path.Combine(tmpConfigs, "plugin_modules", folder), true);
292+
}
293+
}
291294

292-
// navigation.component.ts
293-
src = Path.Combine(installFolder, "src\\app\\components\\navigation\\navigation.component.ts");
294-
session.Log("BackupPluginSettings src is : " + src.ToString());
295-
File.Copy(src, Path.Combine(tmpConfigs, "navigation.component.ts"), true);
295+
// navigation.component.ts
296+
src = Path.Combine(installFolder, "src\\app\\components\\navigation\\navigation.component.ts");
297+
session.Log("BackupPluginSettings src is : " + src.ToString());
298+
File.Copy(src, Path.Combine(tmpConfigs, "navigation.component.ts"), true);
299+
}
300+
catch { }
296301

297302
}
298303

299304
private static void RestorePluginSettings(Session session, string installFolder)
300305
{
301306
var tmpConfigs = Path.Combine("c:\\", "MicrotingTemp");
302307

303-
// plugins.routing.ts
304-
var dst = Path.Combine(installFolder, "src\\app\\plugins\\plugins.routing.ts");
305-
session.Log("RestorePluginSettings src is : " + dst.ToString());
306-
File.Copy(Path.Combine(tmpConfigs, "plugins.routing.ts"), dst, true);
308+
// This try catch is only for upgrading preplugin versions.
309+
try
310+
{
311+
// plugins.routing.ts
312+
var dst = Path.Combine(installFolder, "src\\app\\plugins\\plugins.routing.ts");
313+
session.Log("RestorePluginSettings src is : " + dst.ToString());
314+
File.Copy(Path.Combine(tmpConfigs, "plugins.routing.ts"), dst, true);
307315

308316

309-
string[] dirs = Directory.GetDirectories(Path.Combine(tmpConfigs, "plugin_modules"));
317+
string[] dirs = Directory.GetDirectories(Path.Combine(tmpConfigs, "plugin_modules"));
310318

311-
foreach (string dir in dirs)
312-
{
313-
string folder = dir.Split(Path.DirectorySeparatorChar).Last();
314-
DirectoryCopy(dir, Path.Combine(installFolder, "src\\app\\plugins\\modules\\", folder), true);
315-
}
319+
foreach (string dir in dirs)
320+
{
321+
string folder = dir.Split(Path.DirectorySeparatorChar).Last();
322+
DirectoryCopy(dir, Path.Combine(installFolder, "src\\app\\plugins\\modules\\", folder), true);
323+
}
316324

317-
// navigation.component.ts
318-
dst = Path.Combine(installFolder, "src\\app\\components\\navigation\\navigation.component.ts");
319-
session.Log("RestorePluginSettings src is : " + dst.ToString());
320-
File.Copy(Path.Combine(tmpConfigs, "navigation.component.ts"), dst, true);
325+
// navigation.component.ts
326+
dst = Path.Combine(installFolder, "src\\app\\components\\navigation\\navigation.component.ts");
327+
session.Log("RestorePluginSettings src is : " + dst.ToString());
328+
File.Copy(Path.Combine(tmpConfigs, "navigation.component.ts"), dst, true);
329+
}
330+
catch { }
321331
}
322332

323333
private static void HandlePreviousConfigs(Session session, string installFolder)

eFormAPI/eFormAPI/App_Start/WebApiConfig.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Net.Http.Headers;
55
using System.Reflection;
66
using System.Web.Http;
7+
using System.Web.Http.Cors;
78
using System.Web.Http.Dispatcher;
89
using Autofac.Integration.WebApi;
910
using eFormAPI.Web.Infrastructure.Helpers;
@@ -20,6 +21,8 @@ public static void Register(HttpConfiguration config)
2021
{
2122
// Web API configuration and services
2223
// Configure Web API to use only bearer token authentication.
24+
var corsAttr = new EnableCorsAttribute("*", "content-type", "GET");
25+
config.EnableCors(corsAttr);
2326
config.SuppressDefaultHostAuthentication();
2427
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
2528
config.Filters.Add(new HostAuthenticationFilter(CookieAuthenticationDefaults.AuthenticationType));

eFormAPI/eFormAPI/Controllers/EntitySearchController.cs

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public OperationDataResult<EntityGroupList> GetEntityGroupList(
2424
{
2525
try
2626
{
27-
var core = _coreHelper.GetCore();
28-
var model = core.Advanced_EntityGroupAll(requestModel.Sort, requestModel.NameFilter,
27+
eFormCore.Core core = _coreHelper.GetCore();
28+
EntityGroupList model = core.Advanced_EntityGroupAll(requestModel.Sort, requestModel.NameFilter,
2929
requestModel.PageIndex, requestModel.PageSize, Constants.FieldTypes.EntitySearch,
3030
requestModel.IsSortDsc,
3131
Constants.WorkflowStates.NotRemoved);
@@ -44,13 +44,13 @@ public OperationResult CreateEntityGroup(AdvEntitySearchableGroupEditModel editM
4444
{
4545
try
4646
{
47-
var core = _coreHelper.GetCore();
48-
var groupCreate = core.EntityGroupCreate(Constants.FieldTypes.EntitySearch, editModel.Name);
47+
eFormCore.Core core = _coreHelper.GetCore();
48+
EntityGroup groupCreate = core.EntityGroupCreate(Constants.FieldTypes.EntitySearch, editModel.Name);
4949
if (editModel.AdvEntitySearchableItemModels.Any())
5050
{
51-
var entityGroup = core.EntityGroupRead(groupCreate.MicrotingUUID);
52-
var nextItemUid = entityGroup.EntityGroupItemLst.Count;
53-
foreach (var entityItem in editModel.AdvEntitySearchableItemModels)
51+
EntityGroup entityGroup = core.EntityGroupRead(groupCreate.MicrotingUUID);
52+
int nextItemUid = entityGroup.EntityGroupItemLst.Count;
53+
foreach (EntityItem entityItem in editModel.AdvEntitySearchableItemModels)
5454
{
5555
core.EntitySearchItemCreate(entityGroup.Id, entityItem.Name, entityItem.Description,
5656
nextItemUid.ToString());
@@ -78,10 +78,10 @@ public OperationResult UpdateEntityGroup(AdvEntitySearchableGroupEditModel editM
7878
{
7979
try
8080
{
81-
var core = _coreHelper.GetCore();
82-
var entityGroup = core.EntityGroupRead(editModel.GroupUid);
81+
eFormCore.Core core = _coreHelper.GetCore();
82+
EntityGroup entityGroup = core.EntityGroupRead(editModel.GroupUid);
8383

84-
var nextItemUid = entityGroup.EntityGroupItemLst.Count;
84+
int nextItemUid = entityGroup.EntityGroupItemLst.Count;
8585
List<int> currentIds = new List<int>();
8686

8787
foreach (var entityItem in editModel.AdvEntitySearchableItemModels)
@@ -125,9 +125,9 @@ public OperationDataResult<EntityGroup> GetEntityGroup(string entityGroupUid)
125125
{
126126
try
127127
{
128-
var core = _coreHelper.GetCore();
128+
eFormCore.Core core = _coreHelper.GetCore();
129129

130-
var entityGroup = core.EntityGroupRead(entityGroupUid);
130+
EntityGroup entityGroup = core.EntityGroupRead(entityGroupUid);
131131

132132
return new OperationDataResult<EntityGroup>(true, entityGroup);
133133
}
@@ -145,17 +145,17 @@ public OperationDataResult<List<CommonDictionaryTextModel>> GetEntityGroupDictio
145145
{
146146
try
147147
{
148-
var core = _coreHelper.GetCore();
148+
eFormCore.Core core = _coreHelper.GetCore();
149149

150-
var entityGroup = core.EntityGroupRead(entityGroupUid, null, searchString);
150+
EntityGroup entityGroup = core.EntityGroupRead(entityGroupUid, null, searchString);
151151

152-
var mappedEntityGroupDict = new List<CommonDictionaryTextModel>();
152+
List<CommonDictionaryTextModel> mappedEntityGroupDict = new List<CommonDictionaryTextModel>();
153153

154-
foreach (var entityGroupItem in entityGroup.EntityGroupItemLst)
154+
foreach (EntityItem entityGroupItem in entityGroup.EntityGroupItemLst)
155155
{
156156
mappedEntityGroupDict.Add(new CommonDictionaryTextModel()
157157
{
158-
Id = entityGroupItem.MicrotingUUID,
158+
Id = entityGroupItem.Id.ToString(),
159159
Text = entityGroupItem.Name
160160
});
161161
}
@@ -175,8 +175,7 @@ public OperationResult DeleteEntityGroup(string entityGroupUid)
175175
{
176176
try
177177
{
178-
var core = _coreHelper.GetCore();
179-
178+
eFormCore.Core core = _coreHelper.GetCore();
180179

181180
return core.EntityGroupDelete(entityGroupUid)
182181
? new OperationResult(true, LocaleHelper.GetString("ParamDeletedSuccessfully", entityGroupUid))
@@ -195,8 +194,7 @@ public OperationResult SendSearchableGroup(string entityGroupUid)
195194
{
196195
try
197196
{
198-
var core = _coreHelper.GetCore();
199-
197+
eFormCore.Core core = _coreHelper.GetCore();
200198

201199
return new OperationResult(true, LocaleHelper.GetString("ParamDeletedSuccessfully", entityGroupUid));
202200
}

eFormAPI/eFormAPI/Controllers/EntitySelectController.cs

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
using eFormApi.BasePn.Infrastructure;
1010
using eFormApi.BasePn.Infrastructure.Helpers;
1111
using eFormApi.BasePn.Infrastructure.Models.API;
12+
using eFormAPI.Web.Infrastructure.Helpers.ExchangeTokenValidation;
13+
using System.Web.Http.Cors;
1214

1315
namespace eFormAPI.Web.Controllers
1416
{
@@ -24,8 +26,8 @@ public OperationDataResult<EntityGroupList> GetEntityGroupList(
2426
{
2527
try
2628
{
27-
var core = _coreHelper.GetCore();
28-
var model = core.Advanced_EntityGroupAll(requestModel.Sort, requestModel.NameFilter,
29+
eFormCore.Core core = _coreHelper.GetCore();
30+
EntityGroupList model = core.Advanced_EntityGroupAll(requestModel.Sort, requestModel.NameFilter,
2931
requestModel.PageIndex, requestModel.PageSize, Constants.FieldTypes.EntitySelect,
3032
requestModel.IsSortDsc,
3133
Constants.WorkflowStates.NotRemoved);
@@ -43,8 +45,8 @@ public OperationResult CreateEntityGroup(AdvEntitySelectableGroupEditModel editM
4345
{
4446
try
4547
{
46-
var core = _coreHelper.GetCore();
47-
var groupCreate = core.EntityGroupCreate(Constants.FieldTypes.EntitySelect, editModel.Name);
48+
eFormCore.Core core = _coreHelper.GetCore();
49+
EntityGroup groupCreate = core.EntityGroupCreate(Constants.FieldTypes.EntitySelect, editModel.Name);
4850
if (editModel.AdvEntitySelectableItemModels.Any())
4951
{
5052
var entityGroup = core.EntityGroupRead(groupCreate.MicrotingUUID);
@@ -72,8 +74,8 @@ public OperationResult UpdateEntityGroup(AdvEntitySelectableGroupEditModel editM
7274
{
7375
try
7476
{
75-
var core = _coreHelper.GetCore();
76-
var entityGroup = core.EntityGroupRead(editModel.GroupUid);
77+
eFormCore.Core core = _coreHelper.GetCore();
78+
EntityGroup entityGroup = core.EntityGroupRead(editModel.GroupUid);
7779

7880
if (editModel.AdvEntitySelectableItemModels.Any())
7981
{
@@ -115,9 +117,9 @@ public OperationDataResult<EntityGroup> GetEntityGroup(string entityGroupUid)
115117
{
116118
try
117119
{
118-
var core = _coreHelper.GetCore();
120+
eFormCore.Core core = _coreHelper.GetCore();
119121

120-
var entityGroup = core.EntityGroupRead(entityGroupUid);
122+
EntityGroup entityGroup = core.EntityGroupRead(entityGroupUid);
121123

122124
return new OperationDataResult<EntityGroup>(true, entityGroup);
123125
}
@@ -127,23 +129,55 @@ public OperationDataResult<EntityGroup> GetEntityGroup(string entityGroupUid)
127129
}
128130
}
129131

132+
[HttpGet]
133+
[AllowAnonymous]
134+
[Route("api/selectable-groups/get/exchange/{entityGroupUid}")]
135+
[EnableCors(origins: "*", headers: "content-type", methods: "GET")]
136+
public OperationDataResult<EntityGroup> GetEntityGroupExternally(string entityGroupUid, string token, string callerURL)
137+
{
138+
// Do some validation of the token. For now token is not valid
139+
//bool tokenIsValid = false;
140+
ExchangeIdToken idToken = new ExchangeIdToken(token);
141+
IdTokenValidationResult result = idToken.Validate(callerURL);
142+
if (result.IsValid)
143+
{
144+
try
145+
{
146+
eFormCore.Core core = _coreHelper.GetCore();
147+
148+
EntityGroup entityGroup = core.EntityGroupRead(entityGroupUid);
149+
150+
return new OperationDataResult<EntityGroup>(true, entityGroup);
151+
}
152+
catch (Exception)
153+
{
154+
return new OperationDataResult<EntityGroup>(false,
155+
LocaleHelper.GetString("ErrorWhileObtainSelectableList"));
156+
}
157+
} else
158+
{
159+
return new OperationDataResult<EntityGroup>(false,
160+
LocaleHelper.GetString("ErrorWhileObtainSelectableList"));
161+
}
162+
}
163+
130164
[HttpGet]
131165
[Route("api/selectable-groups/dict/{entityGroupUid}")]
132166
public OperationDataResult<List<CommonDictionaryTextModel>> GetEntityGroupDictionary(string entityGroupUid)
133167
{
134168
try
135169
{
136-
var core = _coreHelper.GetCore();
170+
eFormCore.Core core = _coreHelper.GetCore();
137171

138-
var entityGroup = core.EntityGroupRead(entityGroupUid);
172+
EntityGroup entityGroup = core.EntityGroupRead(entityGroupUid);
139173

140-
var mappedEntityGroupDict = new List<CommonDictionaryTextModel>();
174+
List<CommonDictionaryTextModel> mappedEntityGroupDict = new List<CommonDictionaryTextModel>();
141175

142-
foreach (var entityGroupItem in entityGroup.EntityGroupItemLst)
176+
foreach (EntityItem entityGroupItem in entityGroup.EntityGroupItemLst)
143177
{
144178
mappedEntityGroupDict.Add(new CommonDictionaryTextModel()
145179
{
146-
Id = entityGroupItem.MicrotingUUID,
180+
Id = entityGroupItem.Id.ToString(),
147181
Text = entityGroupItem.Name
148182
});
149183
}
@@ -163,8 +197,7 @@ public OperationResult DeleteEntityGroup(string entityGroupUid)
163197
{
164198
try
165199
{
166-
var core = _coreHelper.GetCore();
167-
200+
eFormCore.Core core = _coreHelper.GetCore();
168201

169202
return core.EntityGroupDelete(entityGroupUid)
170203
? new OperationResult(true, LocaleHelper.GetString("ParamDeletedSuccessfully", entityGroupUid))
@@ -183,8 +216,7 @@ public OperationResult SendSearchableGroup(string entityGroupUid)
183216
{
184217
try
185218
{
186-
var core = _coreHelper.GetCore();
187-
219+
eFormCore.Core core = _coreHelper.GetCore();
188220

189221
return new OperationResult(true, LocaleHelper.GetString("ParamDeletedSuccessfully", entityGroupUid));
190222
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Newtonsoft.Json;
2+
3+
namespace eFormAPI.Web.Infrastructure.Helpers.ExchangeTokenValidation
4+
{
5+
/// <summary>
6+
/// Representation of the appctx claim in an Exchange user identity token.
7+
/// </summary>
8+
public class ExchangeAppContext
9+
{
10+
/// <summary>
11+
/// The Exchange identifier for the user
12+
/// </summary>
13+
[JsonProperty("msexchuid")]
14+
public string ExchangeUid { get; set; }
15+
16+
/// <summary>
17+
/// The token version
18+
/// </summary>
19+
public string Version { get; set; }
20+
21+
/// <summary>
22+
/// The URL to download authentication metadata
23+
/// </summary>
24+
[JsonProperty("amurl")]
25+
public string MetadataUrl { get; set; }
26+
}
27+
}

0 commit comments

Comments
 (0)