NotificationInfo.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. using Abp.Domain.Entities.Auditing;
  5. using Abp.MultiTenancy;
  6. namespace Abp.Notifications
  7. {
  8. /// <summary>
  9. /// Used to store a notification request.
  10. /// This notification is distributed to tenants and users by <see cref="INotificationDistributer"/>.
  11. /// </summary>
  12. [Serializable]
  13. [Table("AbpNotifications")]
  14. [MultiTenancySide(MultiTenancySides.Host)]
  15. public class NotificationInfo : CreationAuditedEntity<Guid>
  16. {
  17. /// <summary>
  18. /// Indicates all tenant ids for <see cref="TenantIds"/> property.
  19. /// Value: "0".
  20. /// </summary>
  21. public const string AllTenantIds = "0";
  22. /// <summary>
  23. /// Maximum length of <see cref="NotificationName"/> property.
  24. /// Value: 96.
  25. /// </summary>
  26. public const int MaxNotificationNameLength = 96;
  27. /// <summary>
  28. /// Maximum length of <see cref="Data"/> property.
  29. /// Value: 1048576 (1 MB).
  30. /// </summary>
  31. public const int MaxDataLength = 1024 * 1024;
  32. /// <summary>
  33. /// Maximum length of <see cref="DataTypeName"/> property.
  34. /// Value: 512.
  35. /// </summary>
  36. public const int MaxDataTypeNameLength = 512;
  37. /// <summary>
  38. /// Maximum length of <see cref="EntityTypeName"/> property.
  39. /// Value: 250.
  40. /// </summary>
  41. public const int MaxEntityTypeNameLength = 250;
  42. /// <summary>
  43. /// Maximum length of <see cref="EntityTypeAssemblyQualifiedName"/> property.
  44. /// Value: 512.
  45. /// </summary>
  46. public const int MaxEntityTypeAssemblyQualifiedNameLength = 512;
  47. /// <summary>
  48. /// Maximum length of <see cref="EntityId"/> property.
  49. /// Value: 96.
  50. /// </summary>
  51. public const int MaxEntityIdLength = 96;
  52. /// <summary>
  53. /// Maximum length of <see cref="UserIds"/> property.
  54. /// Value: 131072 (128 KB).
  55. /// </summary>
  56. public const int MaxUserIdsLength = 128 * 1024;
  57. /// <summary>
  58. /// Maximum length of <see cref="TenantIds"/> property.
  59. /// Value: 131072 (128 KB).
  60. /// </summary>
  61. public const int MaxTenantIdsLength = 128 * 1024;
  62. /// <summary>
  63. /// Unique notification name.
  64. /// </summary>
  65. [Required]
  66. [StringLength(MaxNotificationNameLength)]
  67. public virtual string NotificationName { get; set; }
  68. /// <summary>
  69. /// Notification data as JSON string.
  70. /// </summary>
  71. [StringLength(MaxDataLength)]
  72. public virtual string Data { get; set; }
  73. /// <summary>
  74. /// Type of the JSON serialized <see cref="Data"/>.
  75. /// It's AssemblyQualifiedName of the type.
  76. /// </summary>
  77. [StringLength(MaxDataTypeNameLength)]
  78. public virtual string DataTypeName { get; set; }
  79. /// <summary>
  80. /// Gets/sets entity type name, if this is an entity level notification.
  81. /// It's FullName of the entity type.
  82. /// </summary>
  83. [StringLength(MaxEntityTypeNameLength)]
  84. public virtual string EntityTypeName { get; set; }
  85. /// <summary>
  86. /// AssemblyQualifiedName of the entity type.
  87. /// </summary>
  88. [StringLength(MaxEntityTypeAssemblyQualifiedNameLength)]
  89. public virtual string EntityTypeAssemblyQualifiedName { get; set; }
  90. /// <summary>
  91. /// Gets/sets primary key of the entity, if this is an entity level notification.
  92. /// </summary>
  93. [StringLength(MaxEntityIdLength)]
  94. public virtual string EntityId { get; set; }
  95. /// <summary>
  96. /// Notification severity.
  97. /// </summary>
  98. public virtual NotificationSeverity Severity { get; set; }
  99. /// <summary>
  100. /// Target users of the notification.
  101. /// If this is set, it overrides subscribed users.
  102. /// If this is null/empty, then notification is sent to all subscribed users.
  103. /// </summary>
  104. [StringLength(MaxUserIdsLength)]
  105. public virtual string UserIds { get; set; }
  106. /// <summary>
  107. /// Excluded users.
  108. /// This can be set to exclude some users while publishing notifications to subscribed users.
  109. /// It's not normally used if <see cref="UserIds"/> is not null.
  110. /// </summary>
  111. [StringLength(MaxUserIdsLength)]
  112. public virtual string ExcludedUserIds { get; set; }
  113. /// <summary>
  114. /// Target tenants of the notification.
  115. /// Used to send notification to subscribed users of specific tenant(s).
  116. /// This is valid only if UserIds is null.
  117. /// If it's "0", then indicates to all tenants.
  118. /// </summary>
  119. [StringLength(MaxTenantIdsLength)]
  120. public virtual string TenantIds { get; set; }
  121. public NotificationInfo()
  122. {
  123. }
  124. /// <summary>
  125. /// Initializes a new instance of the <see cref="NotificationInfo"/> class.
  126. /// </summary>
  127. public NotificationInfo(Guid id)
  128. {
  129. Id = id;
  130. Severity = NotificationSeverity.Info;
  131. }
  132. }
  133. }