Esempio n. 1
0
        /// <summary>
        /// 获取12字节唯一ID:4字节时间戳+4字节主机MAC+2字节进程PID+2字节自增序列
        /// </summary>
        /// <param name="id">自增序列,只取2字节</param>
        /// <returns>12字节唯一ID</returns>
        public static long GetUniquenessID12(int id)
        {
            string  strMac = "";
            long    lngMac = Net.GetMac(out strMac);
            Process curPro = Process.GetCurrentProcess();
            string  s      = string.Format("{0:X8}{1:X8}{2:X4}{3:X4}", DateTimes.GetTimeStamp(), (int)(lngMac), (short)curPro.Id, ((short)id));
            long    n      = Convert.ToInt64(s, 16);

            return(n);
        }
Esempio n. 2
0
        /// <summary>
        /// 获取8字节唯一ID:4字节时间戳+3字节主机MAC+1字节自增序列
        /// </summary>
        /// <param name="id">自增序列,只取1字节</param>
        /// <returns>8字节唯一ID</returns>
        public static long GetUniquenessID8(int id)
        {
            string strMac = "";
            long   lngMac = Net.GetMac(out strMac);

            string s = string.Format("{0:X8}{1:X6}{2:X2}", DateTimes.GetTimeStamp(), ((int)(lngMac)) & 0x00FFFFFF, ((byte)id));
            long   n = Convert.ToInt64(s, 16);

            return(n);
        }