Exemple #1
0
        public static string NextOrderCode(int workerId = 0)
        {
            if (workerId > 16)
            {
                throw new ArgumentOutOfRangeException("workerId must <=16");
            }
            IIdGen worker = null;
            string key    = "string-idGen-" + workerId;

            lock (GenDic)
            {
                if (GenDic.ContainsKey(key))
                {
                    worker = GenDic[key] as IIdGen;
                }
                else
                {
                    worker = new OrderCodeWorker(workerId);
                    GenDic.Add(key, worker);
                }
            }
            var id = worker.NextStringId();

            return(id);
        }
Exemple #2
0
        public static long NextImgId()
        {
            IIdGen worker = null;
            string key    = "long-idGen-7";

            lock (GenDic)
            {
                if (GenDic.ContainsKey(key))
                {
                    worker = GenDic[key] as IIdGen;
                }
                else
                {
                    worker = new IdWorker((long)7);
                    GenDic.Add(key, worker);
                }
            }
            long id = worker.NextId();

            return(id);
        }