This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -53,7 +53,7 @@
|
||||
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
|
||||
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
|
||||
"AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles",
|
||||
"AYANOVA_SERVER_TEST_MODE": "true",
|
||||
"AYANOVA_SERVER_TEST_MODE": "false",
|
||||
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small",
|
||||
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7",
|
||||
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\"
|
||||
|
||||
@@ -11,11 +11,26 @@ namespace AyaNova.Biz
|
||||
{
|
||||
try
|
||||
{
|
||||
string ret;
|
||||
|
||||
cmd.CommandText = $"select PUBLIC.AYGETNAME({id}, {(int)ayaType}) as m";
|
||||
// cmd.CommandText = $"SELECT m.{COLUMN} FROM {TABLE} AS m WHERE m.id = {id} LIMIT 1";
|
||||
using (var dr = cmd.ExecuteReader())
|
||||
return dr.Read() ? dr.GetString(0) : "-";
|
||||
{
|
||||
if (dr.Read())
|
||||
{
|
||||
if (dr.IsDBNull(0))
|
||||
ret = $"?? type:{ayaType},id:{id}";
|
||||
else
|
||||
ret = dr.GetString(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = "-";
|
||||
}
|
||||
//return dr.Read() ? dr.GetString(0) : "-";
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -67,16 +67,7 @@ namespace AyaNova.Biz
|
||||
return null;
|
||||
}
|
||||
PurchaseOrder newObject = new PurchaseOrder();
|
||||
CopyObject.Copy(dbObject, newObject, "Wiki");
|
||||
string newUniqueName = string.Empty;
|
||||
bool NotUnique = true;
|
||||
long l = 1;
|
||||
do
|
||||
{
|
||||
newUniqueName = Util.StringUtil.UniqueNameBuilder(dbObject.Name, l++, 255);
|
||||
NotUnique = await ct.PurchaseOrder.AnyAsync(z => z.Name == newUniqueName);
|
||||
} while (NotUnique);
|
||||
newObject.Name = newUniqueName;
|
||||
CopyObject.Copy(dbObject, newObject, "Wiki,Serial");
|
||||
newObject.Id = 0;
|
||||
newObject.Concurrency = 0;
|
||||
await ct.PurchaseOrder.AddAsync(newObject);
|
||||
@@ -159,7 +150,7 @@ namespace AyaNova.Biz
|
||||
return false;
|
||||
ct.PurchaseOrder.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Serial.ToString(), ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
@@ -202,7 +193,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
if (obj != null)
|
||||
searchParams.AddText(obj.Notes)
|
||||
.AddText(obj.Name)
|
||||
.AddText(obj.Serial)
|
||||
.AddText(obj.Wiki)
|
||||
.AddText(obj.Tags)
|
||||
.AddCustomFields(obj.CustomFields);
|
||||
@@ -219,20 +210,6 @@ namespace AyaNova.Biz
|
||||
|
||||
bool isNew = currentObj == null;
|
||||
|
||||
//Name required
|
||||
if (string.IsNullOrWhiteSpace(proposedObj.Name))
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name");
|
||||
|
||||
|
||||
//If name is otherwise OK, check that name is unique
|
||||
if (!PropertyHasErrors("Name"))
|
||||
{
|
||||
//Use Any command is efficient way to check existance, it doesn't return the record, just a true or false
|
||||
if (await ct.PurchaseOrder.AnyAsync(z => z.Name == proposedObj.Name && z.Id != proposedObj.Id))
|
||||
{
|
||||
AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Name");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Any form customizations to validate?
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace AyaNova.Models
|
||||
public long Id { get; set; }
|
||||
public uint Concurrency { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
public long Serial { get; set; }
|
||||
public bool Active { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public string Wiki { get; set; }
|
||||
|
||||
@@ -62,15 +62,15 @@ todo: Consider adding latitude / longitude to wo, quote, pm objects
|
||||
public List<WorkOrderItem> Items { get; set; }
|
||||
|
||||
|
||||
[NotMapped, JsonIgnore]
|
||||
public string Name
|
||||
{
|
||||
//Used by notification processor
|
||||
get
|
||||
{
|
||||
return this.Serial.ToString();
|
||||
}
|
||||
}
|
||||
// [NotMapped, JsonIgnore]
|
||||
// public string Name
|
||||
// {
|
||||
// //Used by notification processor
|
||||
// get
|
||||
// {
|
||||
// return this.Serial.ToString();
|
||||
// }
|
||||
// }
|
||||
|
||||
[NotMapped, JsonIgnore]
|
||||
public AyaType AyaType { get => AyaType.WorkOrder; }
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace AyaNova.Util
|
||||
private const int DESIRED_SCHEMA_LEVEL = 15;
|
||||
|
||||
internal const long EXPECTED_COLUMN_COUNT = 620;
|
||||
internal const long EXPECTED_INDEX_COUNT = 175;
|
||||
internal const long EXPECTED_INDEX_COUNT = 174;
|
||||
|
||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
||||
|
||||
@@ -385,7 +385,7 @@ BEGIN
|
||||
when 56 then return 'LT:OpsNotificationSettings';
|
||||
when 57 then aytable = 'areport';
|
||||
when 58 then return 'LT:DashBoardView';
|
||||
when 59 then aytable = 'acustomernote';
|
||||
when 59 then aytable = 'acustomernote'; aynamecolumn = 'notedate';
|
||||
when 60 then aytable = 'amemo';
|
||||
when 61 then aytable = 'areview';
|
||||
when 62 then aytable = 'aservicerate';
|
||||
@@ -700,9 +700,9 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
|
||||
//PURCHASEORDER
|
||||
//Note don't forget to update name fetcher stored procedure when change this to serial from name
|
||||
await ExecQueryAsync("CREATE TABLE apurchaseorder (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text not null unique, active bool, " +
|
||||
await ExecQueryAsync("CREATE TABLE apurchaseorder (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial bigint generated by default as identity not null, active bool, " +
|
||||
"notes text, wiki text, customfields text, tags varchar(255) ARRAY )");
|
||||
await ExecQueryAsync("CREATE UNIQUE INDEX apurchaseorder_name_id_idx ON apurchaseorder (id, name);");
|
||||
await ExecQueryAsync("CREATE UNIQUE INDEX apurchaseorder_serial_id_idx ON apurchaseorder (id, serial);");
|
||||
await ExecQueryAsync("CREATE INDEX apurchaseorder_tags ON apurchaseorder using GIN(tags)");
|
||||
|
||||
//VENDOR
|
||||
|
||||
Reference in New Issue
Block a user