You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.0 KiB
C#

9 months ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace POSV.Utils
{
public class IdWorkerUtils
{
static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
private static object _lock = new object();
private static IdWorkerUtils _instance = null;
private static IdWorker _IdWorker = null;
public static IdWorkerUtils Instance
{
get
{
if (_instance == null)
{
lock (_lock)
{
_instance = new IdWorkerUtils();
_IdWorker = new IdWorker(1 , 1 , 0);
}
}
return _instance;
}
}
public string NextId()
{
try
{
return _IdWorker.NextId().ToString();
}
catch
{
return ObjectId.GenerateNewStringId();
}
}
}
}