-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotificationService.cs
More file actions
103 lines (95 loc) · 3.67 KB
/
NotificationService.cs
File metadata and controls
103 lines (95 loc) · 3.67 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
namespace RexStudios.LanguageDependentNotification
{
using Microsoft.Xrm.Sdk;
using RexStudios.Extensions;
using System;
using System.Collections.Generic;
public abstract class NotificationService : INotificationService
{
private INotificationRepo _notificationrepo;
private INotificationTypeRepo _notificationTypeRepo;
private readonly ITracingService _tracingService;
public NotificationService(IOrganizationService organizationService, ITracingService tracingService)
{
_tracingService = tracingService;
_notificationrepo = new NotificationDL(organizationService, tracingService);
_notificationTypeRepo = new NotificationTypeDL(organizationService, tracingService);
}
/// <summary>
///
/// </summary>
/// <param name="entityName"></param>
/// <param name="commandText"></param>
/// <param name="languageCode"></param>
/// <returns></returns>
public string GetNotificationTexts(string entityName, string commandText, int languageCode)
{
try
{
Entity notificationText = _notificationrepo.GetNotificationTexts(entityName, commandText, languageCode);
if (notificationText != null)
{
return (string)notificationText.Attributes["rex_notificationtext"];
}
return string.Empty;
}
catch (InvalidPluginExecutionException ex)
{
_tracingService?.Trace($"Invalid Exception GetNotificationTexts: {ex.Message}");
throw ex;
}
catch (Exception ex)
{
_tracingService?.Trace($"Invalid Exception GetNotificationTexts: {ex.Message}");
throw ex;
}
}
/// <summary>
/// Gets all language notifications notifications
/// </summary>
/// <param name="CommandText"></param>
/// <param name="EntityLogicalName"></param>
/// <param name="NotificationType"></param>
/// <returns></returns>
public IEnumerable<Entity> GetNotificationTextByName(string CommandText, string EntityLogicalName, string NotificationType)
{
try
{
return _notificationrepo.GetNotificationTextByName(CommandText, EntityLogicalName, NotificationType);
}
catch (InvalidPluginExecutionException ex)
{
_tracingService?.Trace($"Invalid Exception GetNotificationTextByName: {ex.Message}");
throw ex;
}
catch (Exception ex)
{
_tracingService?.Trace($"Invalid Exception GetNotificationTextByName: {ex.Message}");
throw ex;
}
}
/// <summary>
///
/// </summary>
/// <param name="entityName"></param>
/// <param name="languagecode"></param>
/// <returns></returns>
public IEnumerable<Entity> GetNotificationTextsByEntityName(string entityName, int languagecode)
{
try
{
return _notificationrepo.GetNotificationTextByEntityName(entityName, languagecode);
}
catch (InvalidPluginExecutionException ex)
{
_tracingService?.Trace($"Invalid Exception GetNotificationTexts: {ex.Message}");
throw ex;
}
catch (Exception ex)
{
_tracingService?.Trace($"Invalid Exception GetNotificationTexts: {ex.Message}");
throw ex;
}
}
}
}