diff --git a/server/AyaNova/Controllers/WidgetController.cs b/server/AyaNova/Controllers/WidgetController.cs
index fa74ee8d..3ab92b34 100644
--- a/server/AyaNova/Controllers/WidgetController.cs
+++ b/server/AyaNova/Controllers/WidgetController.cs
@@ -345,6 +345,9 @@ namespace AyaNova.Api.Controllers
{
//save and success return
await ct.SaveChangesAsync();
+
+ //Only here process save event??
+ EventLogProcessor.AddEntry();
return CreatedAtAction("GetWidget", new { id = o.Id }, new ApiCreatedResponse(o));
}
}
diff --git a/server/AyaNova/biz/EventLogProcessor.cs b/server/AyaNova/biz/EventLogProcessor.cs
new file mode 100644
index 00000000..253f7e27
--- /dev/null
+++ b/server/AyaNova/biz/EventLogProcessor.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Collections.Generic;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Logging;
+using AyaNova.Models;
+using AyaNova.Util;
+
+
+namespace AyaNova.Biz
+{
+ internal static class EventLogProcessor
+ {
+ private static ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("EventLogProcessor");
+
+ ///
+ /// Add an entry to the log
+ ///
+ ///
+ ///
+ ///
+ internal static void AddEntry(Event newEvent, AyContext ct)
+ {
+ ct.Event.Add(newEvent);
+ ct.SaveChanges();
+ }
+
+
+ /////////////////////////////////////////////////////////////////////
+
+ }//eoc
+
+}//eons
+
diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs
index f973f694..e6a7a8e7 100644
--- a/server/AyaNova/biz/WidgetBiz.cs
+++ b/server/AyaNova/biz/WidgetBiz.cs
@@ -38,13 +38,44 @@ namespace AyaNova.Biz
return null;
else
{
- //do stuff with widget
- Widget outObj = inObj;
- outObj.OwnerId = userId;
- //SearchHelper(break down text fields, save to db)
- //TagHelper(collection of tags??)
- await ct.Widget.AddAsync(outObj);
- return outObj;
+
+
+ using (var trans = ct.Database.BeginTransaction())
+ {
+ // try
+ // {
+ //do stuff with widget
+ Widget outObj = inObj;
+ outObj.OwnerId = userId;
+ //SearchHelper(break down text fields, save to db)
+ //TagHelper(collection of tags??)
+ await ct.Widget.AddAsync(outObj);
+
+ //Log creation
+ Event ev = new Event();
+ ev.AyEvent = AyaEvent.Created;
+ ev.AyId = outObj.Id;
+ ev.AyType = AyaType.Widget;
+ ev.OwnerId = outObj.OwnerId;
+ await ct.Event.AddAsync(ev);
+
+
+ // Commit transaction if all commands succeed, transaction will auto-rollback
+ // when disposed if either commands fails
+ trans.Commit();
+
+ return outObj;
+ // }
+ // catch (Exception ex)
+ // {
+ // throw ex;
+ // }
+ }
+
+
+
+
+
}
}
diff --git a/server/AyaNova/models/AyContext.cs b/server/AyaNova/models/AyContext.cs
index a7a888c2..6cd5daa5 100644
--- a/server/AyaNova/models/AyContext.cs
+++ b/server/AyaNova/models/AyContext.cs
@@ -8,6 +8,7 @@ namespace AyaNova.Models
{
public partial class AyContext : DbContext
{
+ public virtual DbSet Event { get; set; }
public virtual DbSet User { get; set; }
public virtual DbSet License { get; set; }
public virtual DbSet Widget { get; set; }
@@ -77,7 +78,7 @@ namespace AyaNova.Models
//Relationships
modelBuilder.Entity()
.HasMany(c => c.LocaleItems)
- .WithOne(e => e.Locale)
+ .WithOne(e => e.Locale)
.IsRequired();//default delete behaviour is cascade when set to isrequired
diff --git a/server/AyaNova/models/Event.cs b/server/AyaNova/models/Event.cs
new file mode 100644
index 00000000..08f8820e
--- /dev/null
+++ b/server/AyaNova/models/Event.cs
@@ -0,0 +1,47 @@
+using System;
+using AyaNova.Biz;
+using System.ComponentModel.DataAnnotations;
+
+namespace AyaNova.Models
+{
+
+ ///
+ /// Event log entry
+ ///
+ public partial class Event
+ {
+ public long Id { get; set; }
+ public uint ConcurrencyToken { get; set; }
+ public DateTime Created { get; set; }
+ [Required]
+ public long OwnerId { get; set; }
+ //-----------------------------------------
+ [Required]
+ public long AyId { get; set; }
+ [Required]
+ public AyaType AyType { get; set; }
+ [Required]
+ public AyaEvent AyEvent { get; set; }
+ public string Textra { get; set; }
+
+
+ public Event()
+ {
+ Created = System.DateTime.UtcNow;
+ }
+
+ public Event(long ownerId, long ayId, AyaType ayType, AyaEvent ayEvent, string textra = null)
+ {
+ Created = System.DateTime.UtcNow;
+ OwnerId = ownerId;
+ AyId = ayId;
+ AyEvent = ayEvent;
+ if (textra != null)
+ {
+ Textra = textra;
+ }
+ }
+
+ }//eoc
+
+}//eons
diff --git a/server/AyaNova/util/AyaNovaVersion.cs b/server/AyaNova/util/AyaNovaVersion.cs
index 568fb9d9..39532e61 100644
--- a/server/AyaNova/util/AyaNovaVersion.cs
+++ b/server/AyaNova/util/AyaNovaVersion.cs
@@ -11,7 +11,7 @@ namespace AyaNova.Util
{
get
{
- return "8.0.0-alpha.2018.6.6";
+ return "8.0.0-alpha.2018.8.23";
}
}