IAbpSession.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using Abp.MultiTenancy;
  3. namespace Abp.Runtime.Session
  4. {
  5. /// <summary>
  6. /// Defines some session information that can be useful for applications.
  7. /// </summary>
  8. public interface IAbpSession
  9. {
  10. /// <summary>
  11. /// Gets current UserId or null.
  12. /// It can be null if no user logged in.
  13. /// </summary>
  14. long? UserId { get; }
  15. /// <summary>
  16. /// Gets current TenantId or null.
  17. /// This TenantId should be the TenantId of the <see cref="UserId"/>.
  18. /// It can be null if given <see cref="UserId"/> is a host user or no user logged in.
  19. /// </summary>
  20. int? TenantId { get; }
  21. /// <summary>
  22. /// Gets current multi-tenancy side.
  23. /// </summary>
  24. MultiTenancySides MultiTenancySide { get; }
  25. /// <summary>
  26. /// UserId of the impersonator.
  27. /// This is filled if a user is performing actions behalf of the <see cref="UserId"/>.
  28. /// </summary>
  29. long? ImpersonatorUserId { get; }
  30. /// <summary>
  31. /// TenantId of the impersonator.
  32. /// This is filled if a user with <see cref="ImpersonatorUserId"/> performing actions behalf of the <see cref="UserId"/>.
  33. /// </summary>
  34. int? ImpersonatorTenantId { get; }
  35. /// <summary>
  36. /// Used to change <see cref="TenantId"/> and <see cref="UserId"/> for a limited scope.
  37. /// </summary>
  38. /// <param name="tenantId"></param>
  39. /// <param name="userId"></param>
  40. /// <returns></returns>
  41. IDisposable Use(int? tenantId, long? userId);
  42. }
  43. }