using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Abp.Domain.Entities.Auditing;
using Abp.MultiTenancy;
namespace Abp.Notifications
{
///
/// Used to store a notification request.
/// This notification is distributed to tenants and users by .
///
[Serializable]
[Table("AbpNotifications")]
[MultiTenancySide(MultiTenancySides.Host)]
public class NotificationInfo : CreationAuditedEntity
{
///
/// Indicates all tenant ids for property.
/// Value: "0".
///
public const string AllTenantIds = "0";
///
/// Maximum length of property.
/// Value: 96.
///
public const int MaxNotificationNameLength = 96;
///
/// Maximum length of property.
/// Value: 1048576 (1 MB).
///
public const int MaxDataLength = 1024 * 1024;
///
/// Maximum length of property.
/// Value: 512.
///
public const int MaxDataTypeNameLength = 512;
///
/// Maximum length of property.
/// Value: 250.
///
public const int MaxEntityTypeNameLength = 250;
///
/// Maximum length of property.
/// Value: 512.
///
public const int MaxEntityTypeAssemblyQualifiedNameLength = 512;
///
/// Maximum length of property.
/// Value: 96.
///
public const int MaxEntityIdLength = 96;
///
/// Maximum length of property.
/// Value: 131072 (128 KB).
///
public const int MaxUserIdsLength = 128 * 1024;
///
/// Maximum length of property.
/// Value: 131072 (128 KB).
///
public const int MaxTenantIdsLength = 128 * 1024;
///
/// Unique notification name.
///
[Required]
[StringLength(MaxNotificationNameLength)]
public virtual string NotificationName { get; set; }
///
/// Notification data as JSON string.
///
[StringLength(MaxDataLength)]
public virtual string Data { get; set; }
///
/// Type of the JSON serialized .
/// It's AssemblyQualifiedName of the type.
///
[StringLength(MaxDataTypeNameLength)]
public virtual string DataTypeName { get; set; }
///
/// Gets/sets entity type name, if this is an entity level notification.
/// It's FullName of the entity type.
///
[StringLength(MaxEntityTypeNameLength)]
public virtual string EntityTypeName { get; set; }
///
/// AssemblyQualifiedName of the entity type.
///
[StringLength(MaxEntityTypeAssemblyQualifiedNameLength)]
public virtual string EntityTypeAssemblyQualifiedName { get; set; }
///
/// Gets/sets primary key of the entity, if this is an entity level notification.
///
[StringLength(MaxEntityIdLength)]
public virtual string EntityId { get; set; }
///
/// Notification severity.
///
public virtual NotificationSeverity Severity { get; set; }
///
/// Target users of the notification.
/// If this is set, it overrides subscribed users.
/// If this is null/empty, then notification is sent to all subscribed users.
///
[StringLength(MaxUserIdsLength)]
public virtual string UserIds { get; set; }
///
/// Excluded users.
/// This can be set to exclude some users while publishing notifications to subscribed users.
/// It's not normally used if is not null.
///
[StringLength(MaxUserIdsLength)]
public virtual string ExcludedUserIds { get; set; }
///
/// Target tenants of the notification.
/// Used to send notification to subscribed users of specific tenant(s).
/// This is valid only if UserIds is null.
/// If it's "0", then indicates to all tenants.
///
[StringLength(MaxTenantIdsLength)]
public virtual string TenantIds { get; set; }
public NotificationInfo()
{
}
///
/// Initializes a new instance of the class.
///
public NotificationInfo(Guid id)
{
Id = id;
Severity = NotificationSeverity.Info;
}
}
}