Skip to content

Instantly share code, notes, and snippets.

@noakesey
Last active February 13, 2019 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noakesey/834dae1b06ef1b310a415242878e332e to your computer and use it in GitHub Desktop.
Save noakesey/834dae1b06ef1b310a415242878e332e to your computer and use it in GitHub Desktop.
private static str lastUniqueReference;
/// <summary>
/// Get a unique numerical reference
/// </summary>
/// <returns>Unique numerical reference</returns>
public static str getUniqueReference()
{
str nextUniqueReference;
int retryCount = 0;
do
{
System.DateTime d = System.DateTime::UtcNow;
int64 t = d.Ticks;
nextUniqueReference = strFmt('%1', t);
retryCount++;
}
while ((nextUniqueReference == lastUniqueReference) && (retryCount < 5));
if (retryCount >= 5)
{
warning ('Retry count exceeded in LNTestDataHelper::getUniqueReference');
}
lastUniqueReference = nextUniqueReference;
return nextUniqueReference;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment