Beispiel #1
0
        DateTime getTimeStamp()
        {
            var sec = BitConverter.ToInt32(new byte[4] {
                this.Value[3], this.Value[2], this.Value[1], this.Value[0],
            }, 0);

            return(IdBuilder.ToDateTime(sec));
        }
Beispiel #2
0
        public static byte[] Generate()
        {
            //4字节时间|2字节自增|4字节ip|2字节pid
            var oid = new byte[12];
            var sec = IdBuilder.TimeStampUTCBySec();

            Array.Copy(BitConverter.GetBytes(sec).Reverse().ToArray(), 0, oid, 0, 4);

            var counter = GenerateCounter(sec);

            Array.Copy(BitConverter.GetBytes(counter).Reverse().ToArray(), 2, oid, 4, 2);
            Array.Copy(_ip, 0, oid, 6, 4);
            Array.Copy(_processId, 2, oid, 10, 2);

            return(oid);
        }