init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,34 @@
|
|||
using Kreta.Core.MessageBroker.Contract.MobileNotification;
|
||||
using Kreta.MessageBroker.ClientFactory;
|
||||
using Kreta.MessageBroker.Configuration;
|
||||
using Kreta.MessageBroker.TraceLog;
|
||||
|
||||
namespace Kreta.MessageBroker.Client.MobileNotification
|
||||
{
|
||||
/// <summary>
|
||||
/// Mobile notification client
|
||||
/// </summary>
|
||||
class MobileNotificationMessageClient : MessageClient<MobileNotificationMessage>
|
||||
{
|
||||
#region [Constructor(s)]
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="jsonMessageClientFactory">Json message client factory of mobile notification message</param>
|
||||
/// <param name="configuration">Configuration</param>
|
||||
public MobileNotificationMessageClient(
|
||||
IJsonMessageClientFactory<MobileNotificationMessage> jsonMessageClientFactory,
|
||||
IMessageBrokerConfiguration configuration,
|
||||
ITraceMessageClient traceMessageClient,
|
||||
ISerilogTraceLogger serilogTraceLogger) : base(Constants.MobileNotificationMessageClient.Name,
|
||||
jsonMessageClientFactory,
|
||||
configuration,
|
||||
traceMessageClient,
|
||||
serilogTraceLogger,
|
||||
Constants.MobileNotificationMessageClient.LoggerName)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
using System.Threading.Tasks;
|
||||
using Kreta.Core.MessageBroker.Contract.MobileNotification;
|
||||
using Kreta.Core.MessageBroker.Contract.MobileNotification.Enum;
|
||||
|
||||
namespace Kreta.MessageBroker.Client.MobileNotification
|
||||
{
|
||||
/// <summary>
|
||||
/// Mobile notification message helper
|
||||
/// </summary>
|
||||
public class MobileNotificationMessageHelper
|
||||
{
|
||||
#region [Public Methods]
|
||||
|
||||
/// <summary>
|
||||
/// Create
|
||||
/// </summary>
|
||||
/// <param name="instituteCode">Institute code</param>
|
||||
/// <param name="instituteUserId">Institute user id</param>
|
||||
/// <param name="itemId">Item id</param>
|
||||
/// <param name="message">Message</param>
|
||||
/// <param name="notificationType">Notification type</param>
|
||||
public static MobileNotificationMessage CreateMessage(string instituteCode, int instituteUserId, MobileNotificationMessageType notificationType, int itemId, string message)
|
||||
{
|
||||
return new MobileNotificationMessage(instituteCode, instituteUserId, MobileNotificationMessageRole.Student | MobileNotificationMessageRole.Tutelary, notificationType, MobileNotificationMessageSource.Kreta, MobileNotificationMessageDestination.RoleGroup, itemId, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create
|
||||
/// </summary>
|
||||
/// <param name="instituteCode">Institute code</param>
|
||||
/// <param name="instituteUserId">Institute user id</param>
|
||||
/// <param name="notificationType">Notification type</param>
|
||||
/// <param name="itemId">Item id</param>
|
||||
/// <param name="message">Message</param>
|
||||
/// <param name="title">Need for message address</param>
|
||||
/// <param name="data">Can hold any data</param>
|
||||
public static MobileNotificationMessage CreateMessage(string instituteCode, int instituteUserId, MobileNotificationMessageType notificationType, int itemId, string message, string title = "", string data = "")
|
||||
{
|
||||
return new MobileNotificationMessage(instituteCode, instituteUserId, MobileNotificationMessageRole.Student | MobileNotificationMessageRole.Tutelary, notificationType, MobileNotificationMessageSource.Kreta, MobileNotificationMessageDestination.RoleGroup, itemId, message, title, data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send message asynchronously
|
||||
/// </summary>
|
||||
/// <param name="instituteCode">Institute code</param>
|
||||
/// <param name="instituteUserId">Institute user id</param>
|
||||
/// <param name="itemId">Item id</param>
|
||||
/// <param name="message">Message</param>
|
||||
/// <param name="notificationType">Notification type</param>
|
||||
public static async Task PostStudentNotificationAsync(string instituteCode, int instituteUserId, MobileNotificationMessageType notificationType, int itemId, string message)
|
||||
{
|
||||
await DependencyContainer.Instance.GetInstance<MobileNotificationMessageClient>().PostAsync(new MobileNotificationMessage(instituteCode, instituteUserId, MobileNotificationMessageRole.Student | MobileNotificationMessageRole.Tutelary, notificationType, MobileNotificationMessageSource.Kreta, MobileNotificationMessageDestination.RoleGroup, itemId, message));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulk send messages asynchronously
|
||||
/// </summary>
|
||||
/// <param name="messages">Üzenetek</param>
|
||||
public static async Task PostStudentNotificationAsync(MobileNotificationMessage[] messages)
|
||||
{
|
||||
await DependencyContainer.Instance.GetInstance<MobileNotificationMessageClient>().PostAsync(messages);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send message
|
||||
/// </summary>
|
||||
/// <param name="instituteCode">Institute code</param>
|
||||
/// <param name="instituteUserId">Institute user id</param>
|
||||
/// <param name="itemId">Item id</param>
|
||||
/// <param name="message">Message</param>
|
||||
/// <param name="notificationType">Notification type</param>
|
||||
/// <remarks>We wrap calls into a task to avoid callbacks to current http syncronization context (because hosting thread may be destructed)</remarks>
|
||||
public static void PostStudentNotification(string instituteCode, int instituteUserId, MobileNotificationMessageType notificationType, int itemId, string message)
|
||||
{
|
||||
DependencyContainer.Instance.GetInstance<MobileNotificationMessageClient>().Post(new MobileNotificationMessage(instituteCode, instituteUserId, MobileNotificationMessageRole.Student | MobileNotificationMessageRole.Tutelary, notificationType, MobileNotificationMessageSource.Kreta, MobileNotificationMessageDestination.RoleGroup, itemId, message));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send message
|
||||
/// </summary>
|
||||
/// <param name="instituteCode">Institute code</param>
|
||||
/// <param name="instituteUserId">Institute user id</param>
|
||||
/// <param name="itemId">Item id</param>
|
||||
/// <param name="message">Message</param>
|
||||
/// <param name="notificationType">Notification type
|
||||
/// <list type="bullet">
|
||||
/// <item>
|
||||
/// <term>2</term>
|
||||
/// <description>Evaluation</description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>4</term>
|
||||
/// <description>Absence</description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>8</term>
|
||||
/// <description>Note</description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>16</term>
|
||||
/// <description>Message</description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>32</term>
|
||||
/// <description>Homework</description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>64</term>
|
||||
/// <description>Exam</description>
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// </param>
|
||||
/// <remarks>We wrap calls into a task to avoid callbacks to current http syncronization context (because hosting thread may be destructed)</remarks>
|
||||
public static void PostStudentTestNotification(string instituteCode, int instituteUserId, int notificationType, int itemId, string message)
|
||||
{
|
||||
DependencyContainer.Instance.GetInstance<MobileNotificationMessageClient>().Post(new MobileNotificationMessage(instituteCode, instituteUserId, MobileNotificationMessageRole.Student | MobileNotificationMessageRole.Tutelary, (MobileNotificationMessageType)notificationType, MobileNotificationMessageSource.Kreta, MobileNotificationMessageDestination.RoleGroup, itemId, message));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulk send messages
|
||||
/// </summary>
|
||||
/// <param name="messages">Üzenetek</param>
|
||||
public static void PostStudentNotification(MobileNotificationMessage[] messages)
|
||||
{
|
||||
DependencyContainer.Instance.GetInstance<MobileNotificationMessageClient>().Post(messages);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue