35 lines
817 B
C#
35 lines
817 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MyCode.Project.Infrastructure.Common
|
|
{
|
|
public sealed class IdHelper
|
|
{
|
|
private static long NextId = 0;
|
|
|
|
private static readonly object idLock = new object();
|
|
|
|
private static int IdLastNum = Convert.ToInt32(WebConfigUtils.GetAppSettingsInfo("IdLastNum"));
|
|
|
|
public static long GetNewId()
|
|
{
|
|
lock (idLock)
|
|
{
|
|
if (NextId == 0)
|
|
{
|
|
NextId = Convert.ToInt64(DateTime.Now.ToString("yyMMddHHmmssfff"));
|
|
}
|
|
|
|
NextId = NextId + 1;
|
|
|
|
return Convert.ToInt64(NextId.ToString() + IdLastNum);
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}
|