This commit is contained in:
@@ -106,9 +106,9 @@ namespace AyaNova.Biz
|
||||
bool NotUnique = true;
|
||||
long l = 1;
|
||||
do
|
||||
{
|
||||
{
|
||||
newUniqueName = Util.StringUtil.UniqueNameBuilder(dbObj.Name, l++, 255);
|
||||
NotUnique = await ct.Widget.AnyAsync(m => m.Name == newUniqueName);
|
||||
NotUnique = await ct.Widget.AnyAsync(m => m.Name == newUniqueName);
|
||||
} while (NotUnique);
|
||||
|
||||
outObj.Name = newUniqueName;
|
||||
|
||||
@@ -119,6 +119,11 @@ namespace AyaNova.Util
|
||||
//Used to ensure a unique name generated by appending -nnn is within length requirements by splitting and chopping part of text to keep name
|
||||
public static string UniqueNameBuilder(string oldName, long appendValue, int maxLength)
|
||||
{
|
||||
//deadman switch
|
||||
if (appendValue > int.MaxValue)
|
||||
{
|
||||
throw new System.OverflowException($"UniqueNameBuilder: Unique name could not be generated for item \"{oldName}\" after {int.MaxValue.ToString()} attempts");
|
||||
}
|
||||
var appendString = "-" + appendValue.ToString();
|
||||
string ret = oldName + appendString;
|
||||
var diff = maxLength - ret.Length;
|
||||
|
||||
Reference in New Issue
Block a user