IdGenerater.cs 709 B

123456789101112131415161718192021222324
  1. namespace Fort23.Core
  2. {
  3. public static class IdGenerater
  4. {
  5. private static long _increase;
  6. private static int _increaseInt;
  7. public static long GenerateId()
  8. {
  9. _increase++;
  10. return _increase;
  11. }
  12. /// <summary>
  13. /// 这里每次跳跃1000是为了给XNode的guid留足够多的ID点,尽量保证不重复,导出的表格中做了相关处理的,重复了也不会影响内容
  14. /// </summary>
  15. /// <returns></returns>
  16. public static int GenerateIdInt()
  17. {
  18. _increaseInt += 1000;
  19. return (int)(TimeHelper.ClientNowSeconds() % 1000000000 + _increaseInt);
  20. }
  21. }
  22. }