This commit is contained in:
@@ -86,7 +86,16 @@ namespace AyaNova.Biz
|
||||
|
||||
DataListView outObj = new DataListView();
|
||||
CopyObject.Copy(dbObj, outObj);
|
||||
outObj.Name = Util.StringUtil.NameUniquify(outObj.Name, 255);
|
||||
//generate unique name
|
||||
string newUniqueName = string.Empty;
|
||||
bool NotUnique = true;
|
||||
long l = 1;
|
||||
do
|
||||
{
|
||||
newUniqueName = Util.StringUtil.UniqueNameBuilder(dbObj.Name, l++, 255);
|
||||
NotUnique = await ct.DataListView.AnyAsync(m => m.Name == newUniqueName);
|
||||
} while (NotUnique);
|
||||
outObj.Name = newUniqueName;
|
||||
outObj.Id = 0;
|
||||
outObj.ConcurrencyToken = 0;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace AyaNova.Util
|
||||
private const int DESIRED_SCHEMA_LEVEL = 9;
|
||||
|
||||
internal const long EXPECTED_COLUMN_COUNT = 98;
|
||||
internal const long EXPECTED_INDEX_COUNT = 25;
|
||||
internal const long EXPECTED_INDEX_COUNT = 26;
|
||||
|
||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace AyaNova.Util
|
||||
|
||||
|
||||
//Add user table
|
||||
await ExecQueryAsync("CREATE TABLE auser (id BIGSERIAL PRIMARY KEY, active bool not null, name varchar(255) not null, " +
|
||||
await ExecQueryAsync("CREATE TABLE auser (id BIGSERIAL PRIMARY KEY, active bool not null, name varchar(255) not null unique, " +
|
||||
"login text not null, password text not null, salt text not null, roles integer not null, localeid bigint not null REFERENCES alocale (id), " +
|
||||
"dlkey text, dlkeyexpire timestamp, usertype integer not null, employeenumber varchar(255), notes text, customerid bigint, " +
|
||||
"headofficeid bigint, subvendorid bigint, customfields text, tags varchar(255) ARRAY)");
|
||||
@@ -266,8 +266,8 @@ namespace AyaNova.Util
|
||||
{
|
||||
LogUpdateMessage(log);
|
||||
|
||||
await ExecQueryAsync("CREATE TABLE adatalistview (id BIGSERIAL PRIMARY KEY, userId bigint not null, name varchar(255) not null, public bool not null," +
|
||||
"listkey varchar(255) not null, listview text, UNIQUE(name))");
|
||||
await ExecQueryAsync("CREATE TABLE adatalistview (id BIGSERIAL PRIMARY KEY, userId bigint not null, name varchar(255) not null unique, public bool not null," +
|
||||
"listkey varchar(255) not null, listview text)");
|
||||
|
||||
await SetSchemaLevelAsync(++currentSchema);
|
||||
}
|
||||
@@ -278,7 +278,7 @@ namespace AyaNova.Util
|
||||
if (currentSchema < 8)
|
||||
{
|
||||
LogUpdateMessage(log);
|
||||
await ExecQueryAsync("CREATE TABLE atag (id BIGSERIAL PRIMARY KEY, name varchar(255) not null, refcount bigint not null, UNIQUE(name))");
|
||||
await ExecQueryAsync("CREATE TABLE atag (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, refcount bigint not null)");
|
||||
await SetSchemaLevelAsync(++currentSchema);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,30 +90,30 @@ namespace AyaNova.Util
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Make a unique but duplicate object name of desired length
|
||||
/// (Used by Duplicate object function)
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <param name="maxLength"></param>
|
||||
/// <returns></returns>
|
||||
public static string NameUniquify(string s, int maxLength)
|
||||
{
|
||||
//Unique string
|
||||
string unique = " - " + DateUtil.SortableShortCurrentDateTimeValue;
|
||||
string ret = s + unique;
|
||||
var diff = maxLength - ret.Length;
|
||||
if (diff < 0)
|
||||
{
|
||||
if (unique.Length >= maxLength)
|
||||
{
|
||||
throw new System.ArgumentOutOfRangeException("StringUtil::nameUniquify - maxlength> unique value, source field too short for this function?");
|
||||
}
|
||||
ret = s.Substring(0, Math.Abs(diff)) + unique;
|
||||
}
|
||||
// /// <summary>
|
||||
// /// Make a unique but duplicate object name of desired length
|
||||
// /// (Used by Duplicate object function)
|
||||
// /// </summary>
|
||||
// /// <param name="s"></param>
|
||||
// /// <param name="maxLength"></param>
|
||||
// /// <returns></returns>
|
||||
// public static string NameUniquify(string s, int maxLength)
|
||||
// {
|
||||
// //Unique string
|
||||
// string unique = " - " + DateUtil.SortableShortCurrentDateTimeValue;
|
||||
// string ret = s + unique;
|
||||
// var diff = maxLength - ret.Length;
|
||||
// if (diff < 0)
|
||||
// {
|
||||
// if (unique.Length >= maxLength)
|
||||
// {
|
||||
// throw new System.ArgumentOutOfRangeException("StringUtil::nameUniquify - maxlength> unique value, source field too short for this function?");
|
||||
// }
|
||||
// ret = s.Substring(0, Math.Abs(diff)) + unique;
|
||||
// }
|
||||
|
||||
return ret;
|
||||
}
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
|
||||
//Used to ensure a unique name generated by appending -nnn is within length requirements by splitting and chopping part of text to keep name
|
||||
|
||||
Reference in New Issue
Block a user