TenantBase.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System.ComponentModel.DataAnnotations;
  2. using System.ComponentModel.DataAnnotations.Schema;
  3. using Abp.Domain.Entities;
  4. using Abp.Domain.Entities.Auditing;
  5. using Abp.MultiTenancy;
  6. using Abp.Runtime.Security;
  7. namespace IwbZero.MultiTenancy
  8. {
  9. /// <summary>
  10. /// Base class for tenants.
  11. /// </summary>
  12. [Table("Sys_Tenants")]
  13. [MultiTenancySide(MultiTenancySides.Host)]
  14. public abstract class TenantBase : FullAuditedEntity<int>, IPassivable
  15. {
  16. /// <summary>
  17. /// Max length of the <see cref="TenancyName"/> property.
  18. /// </summary>
  19. public const int MaxTenancyNameLength = 64;
  20. /// <summary>
  21. /// Max length of the <see cref="ConnectionString"/> property.
  22. /// </summary>
  23. public const int MaxConnectionStringLength = 1024;
  24. /// <summary>
  25. /// "Default".
  26. /// </summary>
  27. public const string DefaultTenantName = "Iwb";
  28. /// <summary>
  29. /// "^[a-zA-Z][a-zA-Z0-9_-]{1,}$".
  30. /// </summary>
  31. public const string TenancyNameRegex = "^[a-zA-Z][a-zA-Z0-9_-]{1,}$";
  32. /// <summary>
  33. /// Max length of the <see cref="Name"/> property.
  34. /// </summary>
  35. public const int MaxNameLength = 128;
  36. /// <summary>
  37. /// Tenancy name. This property is the UNIQUE name of this Tenant.
  38. /// It can be used as subdomain name in a web application.
  39. /// </summary>
  40. [Required]
  41. [StringLength(MaxTenancyNameLength)]
  42. public virtual string TenancyName { get; set; }
  43. /// <summary>
  44. /// Display name of the Tenant.
  45. /// </summary>
  46. [Required]
  47. [StringLength(MaxNameLength)]
  48. public virtual string Name { get; set; }
  49. /// <summary>
  50. /// ENCRYPTED connection string of the tenant database.
  51. /// Can be null if this tenant is stored in host database.
  52. /// Use <see cref="SimpleStringCipher"/> to encrypt/decrypt this.
  53. /// </summary>
  54. [StringLength(MaxConnectionStringLength)]
  55. public virtual string ConnectionString { get; set; }
  56. /// <summary>
  57. /// Is this tenant active?
  58. /// If as tenant is not active, no user of this tenant can use the application.
  59. /// </summary>
  60. public virtual bool IsActive { get; set; }
  61. }
  62. }