This commit is contained in:
2020-05-14 15:18:45 +00:00
parent 0333db82f2
commit 8f6e9cdc42
8 changed files with 42 additions and 14 deletions

View File

@@ -37,6 +37,7 @@ todo: api / server landing page is shitty on a mobile
todo: Should server show uptime somewhere?
todo: Log configuration into server log at startup? https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3523
log all config settings into server log on boot
todo:aycontext clean up old block of weird definitions
todo: Is there a log that records past jobs, how long can they be viewed?
todo: Rename the link to AyaNova App on the server page to just "AyaNova"
todo: translation cjkindex, no way to set this value currently

View File

@@ -24,7 +24,8 @@ namespace AyaNova.Biz
ServerStateChange=9,
SeedDatabase=10,
AttachmentModified=11,
EraseAllData=12
EraseAllData=12,
ResetSerial=13
//NEW ITEMS REQUIRE translation KEYS and update CLIENT ay-history.vue code in eventypes list and translation fetcher

View File

@@ -43,7 +43,7 @@ namespace AyaNova.Biz
return null;
else
{
// newObject.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext();
// newObject.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext();
newObject.Tags = TagUtil.NormalizeTags(newObject.Tags);
newObject.CustomFields = JsonUtil.CompactJson(newObject.CustomFields);
await ct.Widget.AddAsync(newObject);
@@ -98,7 +98,7 @@ namespace AyaNova.Biz
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct);
return ret;
}
////////////////////////////////////////////////////////////////////////////////////////////////
//UPDATE
//
@@ -172,16 +172,31 @@ namespace AyaNova.Biz
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
//RESET SERIAL
//
internal async Task<bool> ResetSerial(long newSerial)
{
await ct.SaveChangesAsync();
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.ResetSerial,newSerial.ToString()), ct);
/*
ALTER TABLE table_name
ALTER COLUMN column_name
{ SET GENERATED { ALWAYS| BY DEFAULT } |
SET sequence_option | RESTART [ [ WITH ] restart ] }
*/
using (var command = ct.Database.GetDbConnection().CreateCommand())
{
command.CommandText = $"alter table awidget alter column serial restart with {newSerial}";
await ct.Database.OpenConnectionAsync();
await command.ExecuteNonQueryAsync();
await ct.Database.CloseConnectionAsync();
}
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, 0, BizType, AyaEvent.ResetSerial, newSerial.ToString()), ct);
return true;
}

View File

@@ -115,6 +115,16 @@ namespace AyaNova.Models
}
}
///////////////////////////////
//SERIALIZED OBJECTS
//
modelBuilder.Entity<Widget>().Property(z => z.Serial).UseIdentityByDefaultColumn();
///////////////////////////////////////////////////////////////////////
//TODO: this entire block is almost certainly wrong or not required
//Indexes must be specified through fluent api unfortunately
modelBuilder.Entity<FileAttachment>().HasIndex(p => p.StoredFileName);
@@ -136,14 +146,11 @@ namespace AyaNova.Models
.WithOne(i => i.User)
.HasForeignKey<Widget>(b => b.UserId)
.OnDelete(DeleteBehavior.NoAction);
//////////////////////////////////////////////////////////////
modelBuilder.Entity<Widget>().Property(z => z.Serial).UseIdentityByDefaultColumn();
// //Workorder
// modelBuilder.Entity<WorkOrderItem>()
// .HasOne(p => p.WorkOrder)
// .WithMany(b => b.WorkorderItems);
//-----------

View File

@@ -1646,6 +1646,7 @@
"EventLicenseTrialRequest": "Testlizenz angefordert",
"EventServerStateChange": "Serverstatus geändert",
"EventSeedDatabase": "Datenbank mit Beispieldaten erstellt",
"EventResetSerial":"Seriennummer zurückgesetzt",
"NoType": "Kein Typ",
"License": "Lizenz",
"LogFile": "Logdatei",

View File

@@ -1646,6 +1646,7 @@
"EventLicenseTrialRequest": "Trial license requested",
"EventServerStateChange": "Server state changed",
"EventSeedDatabase": "Database seeded with trial data",
"EventResetSerial":"Serial number reset",
"NoType": "No type",
"License": "License",
"LogFile": "Log file",

View File

@@ -1646,6 +1646,7 @@
"EventLicenseTrialRequest": "Licencia de prueba solicitada",
"EventServerStateChange": "Estado del servidor cambiado",
"EventSeedDatabase": "Base de datos creada con datos de muestra",
"EventResetSerial":"Restablecimiento de número de serie",
"NoType": "Sin tipo",
"License": "Licencia",
"LogFile": "Archivo de registro",

View File

@@ -1646,6 +1646,7 @@
"EventLicenseTrialRequest": "Licence d'essai demandée",
"EventServerStateChange": "L'état du serveur a changé",
"EventSeedDatabase": "Base de données créée avec des exemples de données",
"EventResetSerial":"Réinitialisation du numéro de série",
"NoType": "Aucun type",
"License": "Licence",
"LogFile": "Fichier journal",