Exemplo n.º 1
0
        /// <summary>
        /// 生成打印 POS流水单号 等编号等
        /// </summary>
        /// <returns></returns>
        public static long ExtendGenerate(SerialType serialType)
        {
            TypePrefix typePrefix = SerialTypeHelper.GetSerialTypeAndPrefix(serialType);

            SerialCache gen = SerialCache.GetInstance();

            return(gen.CreateID(typePrefix.Type));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 生产指定长度的单号
        /// </summary>
        /// <param name="serialType"></param>
        /// <param name="pkLength">序列号总长度</param>
        /// <returns></returns>
        public static string Generate(SerialType serialType, int length)
        {
            TypePrefix typePrefix = SerialTypeHelper.GetSerialTypeAndPrefix(serialType);

            if (typePrefix.IsRandom)
            {
                return(RandomSerial.CreateID(length));
            }

            SerialCache cache = SerialCache.GetInstance();

            return(cache.CreateID(typePrefix.Type, length));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 生产单号
        /// </summary>
        /// <param name="serialType">默认长度10位</param>
        /// <returns></returns>
        public static string Generate(SerialType serialType)
        {
            TypePrefix typePrefix = SerialTypeHelper.GetSerialTypeAndPrefix(serialType);

            if (typePrefix.IsRandom)
            {
                return(RandomSerial.CreateID(DefualtLength));
            }

            SerialCache cache = SerialCache.GetInstance();

            //日期5位 编号5位
            return(cache.CreateID(typePrefix.Type, DefualtLength));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 根据业务类型枚举,获取实际的业务类型和相应前缀
        /// </summary>
        /// <param name="type">业务枚举</param>
        /// <returns></returns>
        public static TypePrefix GetSerialTypeAndPrefix(SerialType type)
        {
            var tp = new TypePrefix {
                Type = type.ToString().ToLower()
            };

            switch (type)
            {
            case SerialType.Normal:
                tp.IsRandom = true;
                return(tp);

            default:
                tp.IsRandom = true;
                return(tp);
            }
        }