IdFactory.cs 825 B

1234567891011121314151617181920212223242526272829303132333435
  1. using SqlSugar.DistributedSystem.Snowflake;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace WCS.WorkEngineering.Model.WMS
  8. {
  9. public static class IdFactory
  10. {
  11. private static readonly object locker = new object();
  12. private static IdWorker _idworker;
  13. public static IdWorker GetInstance()
  14. {
  15. if (_idworker == null)
  16. {
  17. lock (locker)
  18. {
  19. if (_idworker == null)
  20. {
  21. _idworker = new IdWorker(1, 1);
  22. }
  23. }
  24. }
  25. return _idworker;
  26. }
  27. public static long NewId()
  28. {
  29. return GetInstance().NextId();
  30. }
  31. }
  32. }