IdGenerater.cs 364 B

123456789101112131415161718192021
  1. namespace ETModel
  2. {
  3. public static class IdGenerater
  4. {
  5. public static long AppId { private get; set; }
  6. private static ushort value;
  7. public static long GenerateId()
  8. {
  9. long time = TimeHelper.ClientNowSeconds();
  10. return (AppId << 48) + (time << 16) + ++value;
  11. }
  12. public static int GetAppIdFromId(long id)
  13. {
  14. return (int)(id >> 48);
  15. }
  16. }
  17. }