NotificationSubscriptionInfo.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. using Abp.Domain.Entities;
  5. using Abp.Domain.Entities.Auditing;
  6. using Abp.Json;
  7. namespace Abp.Notifications
  8. {
  9. /// <summary>
  10. /// Used to store a notification subscription.
  11. /// </summary>
  12. [Table("AbpNotificationSubscriptions")]
  13. public class NotificationSubscriptionInfo : CreationAuditedEntity<Guid>, IMayHaveTenant
  14. {
  15. /// <summary>
  16. /// Tenant id of the subscribed user.
  17. /// </summary>
  18. public virtual int? TenantId { get; set; }
  19. /// <summary>
  20. /// User Id.
  21. /// </summary>
  22. public virtual long UserId { get; set; }
  23. /// <summary>
  24. /// Notification unique name.
  25. /// </summary>
  26. [StringLength(NotificationInfo.MaxNotificationNameLength)]
  27. public virtual string NotificationName { get; set; }
  28. /// <summary>
  29. /// Gets/sets entity type name, if this is an entity level notification.
  30. /// It's FullName of the entity type.
  31. /// </summary>
  32. [StringLength(NotificationInfo.MaxEntityTypeNameLength)]
  33. public virtual string EntityTypeName { get; set; }
  34. /// <summary>
  35. /// AssemblyQualifiedName of the entity type.
  36. /// </summary>
  37. [StringLength(NotificationInfo.MaxEntityTypeAssemblyQualifiedNameLength)]
  38. public virtual string EntityTypeAssemblyQualifiedName { get; set; }
  39. /// <summary>
  40. /// Gets/sets primary key of the entity, if this is an entity level notification.
  41. /// </summary>
  42. [StringLength(NotificationInfo.MaxEntityIdLength)]
  43. public virtual string EntityId { get; set; }
  44. /// <summary>
  45. /// Initializes a new instance of the <see cref="NotificationSubscriptionInfo"/> class.
  46. /// </summary>
  47. public NotificationSubscriptionInfo()
  48. {
  49. }
  50. /// <summary>
  51. /// Initializes a new instance of the <see cref="NotificationSubscriptionInfo"/> class.
  52. /// </summary>
  53. public NotificationSubscriptionInfo(Guid id, int? tenantId, long userId, string notificationName, EntityIdentifier entityIdentifier = null)
  54. {
  55. Id = id;
  56. TenantId = tenantId;
  57. NotificationName = notificationName;
  58. UserId = userId;
  59. EntityTypeName = entityIdentifier == null ? null : entityIdentifier.Type.FullName;
  60. EntityTypeAssemblyQualifiedName = entityIdentifier == null ? null : entityIdentifier.Type.AssemblyQualifiedName;
  61. EntityId = entityIdentifier == null ? null : entityIdentifier.Id.ToJsonString();
  62. }
  63. }
  64. }