This commit is contained in:
@@ -86,7 +86,16 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
DataListView outObj = new DataListView();
|
DataListView outObj = new DataListView();
|
||||||
CopyObject.Copy(dbObj, outObj);
|
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.Id = 0;
|
||||||
outObj.ConcurrencyToken = 0;
|
outObj.ConcurrencyToken = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace AyaNova.Util
|
|||||||
private const int DESIRED_SCHEMA_LEVEL = 9;
|
private const int DESIRED_SCHEMA_LEVEL = 9;
|
||||||
|
|
||||||
internal const long EXPECTED_COLUMN_COUNT = 98;
|
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!!!!
|
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ namespace AyaNova.Util
|
|||||||
|
|
||||||
|
|
||||||
//Add user table
|
//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), " +
|
"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, " +
|
"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)");
|
"headofficeid bigint, subvendorid bigint, customfields text, tags varchar(255) ARRAY)");
|
||||||
@@ -266,8 +266,8 @@ namespace AyaNova.Util
|
|||||||
{
|
{
|
||||||
LogUpdateMessage(log);
|
LogUpdateMessage(log);
|
||||||
|
|
||||||
await ExecQueryAsync("CREATE TABLE adatalistview (id BIGSERIAL PRIMARY KEY, userId bigint not null, name varchar(255) not null, public bool not null," +
|
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, UNIQUE(name))");
|
"listkey varchar(255) not null, listview text)");
|
||||||
|
|
||||||
await SetSchemaLevelAsync(++currentSchema);
|
await SetSchemaLevelAsync(++currentSchema);
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ namespace AyaNova.Util
|
|||||||
if (currentSchema < 8)
|
if (currentSchema < 8)
|
||||||
{
|
{
|
||||||
LogUpdateMessage(log);
|
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);
|
await SetSchemaLevelAsync(++currentSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,30 +90,30 @@ namespace AyaNova.Util
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// Make a unique but duplicate object name of desired length
|
// /// Make a unique but duplicate object name of desired length
|
||||||
/// (Used by Duplicate object function)
|
// /// (Used by Duplicate object function)
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="s"></param>
|
// /// <param name="s"></param>
|
||||||
/// <param name="maxLength"></param>
|
// /// <param name="maxLength"></param>
|
||||||
/// <returns></returns>
|
// /// <returns></returns>
|
||||||
public static string NameUniquify(string s, int maxLength)
|
// public static string NameUniquify(string s, int maxLength)
|
||||||
{
|
// {
|
||||||
//Unique string
|
// //Unique string
|
||||||
string unique = " - " + DateUtil.SortableShortCurrentDateTimeValue;
|
// string unique = " - " + DateUtil.SortableShortCurrentDateTimeValue;
|
||||||
string ret = s + unique;
|
// string ret = s + unique;
|
||||||
var diff = maxLength - ret.Length;
|
// var diff = maxLength - ret.Length;
|
||||||
if (diff < 0)
|
// if (diff < 0)
|
||||||
{
|
// {
|
||||||
if (unique.Length >= maxLength)
|
// if (unique.Length >= maxLength)
|
||||||
{
|
// {
|
||||||
throw new System.ArgumentOutOfRangeException("StringUtil::nameUniquify - maxlength> unique value, source field too short for this function?");
|
// throw new System.ArgumentOutOfRangeException("StringUtil::nameUniquify - maxlength> unique value, source field too short for this function?");
|
||||||
}
|
// }
|
||||||
ret = s.Substring(0, Math.Abs(diff)) + unique;
|
// 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
|
//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