This commit is contained in:
2020-07-16 17:58:23 +00:00
parent 35bf96e5c0
commit 9f0944d37b
10 changed files with 50 additions and 54 deletions

View File

@@ -37,12 +37,10 @@ namespace AyaNova.DataList
dlistView.Add(cm);
cm = new JObject();
cm.fld = "intags";
cm.fld = "tags";
dlistView.Add(cm);
cm = new JObject();
cm.fld = "outtags";
dlistView.Add(cm);
DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None);
@@ -104,16 +102,11 @@ namespace AyaNova.DataList
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "InTags",
FieldKey = "intags",
FieldKey = "tags",
UiFieldDataType = (int)UiFieldDataType.Tags
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "OutTags",
FieldKey = "outtags",
UiFieldDataType = (int)UiFieldDataType.Tags
});
}

View File

@@ -37,22 +37,30 @@ namespace AyaNova.Biz
await AddEvent(new NotifyEvent() { EventType = NotifyEventType.ServerOperationsProblem, Message = message });
}
public static async Task AddEvent(NotifyEvent ev)
//Add event if there are subscribers
public static async Task AddEvent(NotifyEvent ev, List<string> inTags = null)
{
log.LogTrace($"AddEvent processing: [{ev.ToString()}]");
try
{
log.LogTrace("Notify set to RUNNING state and starting now");
List<NotifySubscription> subs = new List<NotifySubscription>();
using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext)
{
//iterate subs, figure out who gets this event
//add to table for any that do
var subs=await ct.NotifySubscription.AsNoTracking().Where(z=>z.EventType==ev.EventType &&)
if (inTags == null || inTags.Count==0)
{
//No tags
subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == ev.EventType && z.AyaType == ev.AyaType).ToListAsync();
}
else
{
//In tags
}
}
}

View File

@@ -47,14 +47,12 @@ namespace AyaNova.Biz
return null;
else
{
newObject.InTags = TagBiz.NormalizeTags(newObject.InTags);
newObject.OutTags = TagBiz.NormalizeTags(newObject.OutTags);
newObject.Tags = TagBiz.NormalizeTags(newObject.Tags);
await ct.NotifySubscription.AddAsync(newObject);
await ct.SaveChangesAsync();
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.InTags, null);
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.OutTags, null);
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
return newObject;
}
}
@@ -80,8 +78,7 @@ namespace AyaNova.Biz
await ct.SaveChangesAsync();
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
//await SearchIndexAsync(newObject, true);
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.InTags, null);
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.OutTags, null);
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
return newObject;
}
@@ -112,8 +109,7 @@ namespace AyaNova.Biz
NotifySubscription SnapshotOfOriginalDBObj = new NotifySubscription();
CopyObject.Copy(dbObject, SnapshotOfOriginalDBObj);
CopyObject.Copy(putObject, dbObject, "Id");//can update serial
dbObject.InTags = TagBiz.NormalizeTags(dbObject.InTags);
dbObject.OutTags = TagBiz.NormalizeTags(dbObject.OutTags);
dbObject.Tags = TagBiz.NormalizeTags(dbObject.Tags);
ct.Entry(dbObject).OriginalValues["Concurrency"] = putObject.Concurrency;
await ValidateAsync(dbObject);
@@ -131,8 +127,7 @@ namespace AyaNova.Biz
return null;
}
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct);
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.InTags, SnapshotOfOriginalDBObj.InTags);
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.OutTags, SnapshotOfOriginalDBObj.OutTags);
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
return dbObject;
}
@@ -159,8 +154,7 @@ namespace AyaNova.Biz
//Log event
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.EventType.ToString(), ct);
// await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.InTags);
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.OutTags);
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
//await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
//TODO: DELETE RELATED RECORDS HERE
//all good do the commit

View File

@@ -15,10 +15,7 @@ namespace AyaNova.Models
public uint Concurrency { get; set; }
[Required]
public long UserId { get; set; }
public AyaType? AyaType { get; set; }//Note: could be Global meaning any corebiz object would be included if relevant (e.g. ObjectCreated)
[Required]
public NotifyEventType EventType { get; set; }
public long UserId { get; set; }
public TimeSpan? AdvanceNotice { get; set; } //Note: I've been doing nullable wrong sort of: https://stackoverflow.com/a/29149207/8939
public long? IdValue { get; set; }
public decimal? DecValue { get; set; }
@@ -27,13 +24,18 @@ namespace AyaNova.Models
public NotifyDeliveryMethod DeliveryMethod { get; set; }
public string DeliveryAddress { get; set; }
public long? AttachReportId { get; set; }
public List<string> InTags { get; set; }
public List<string> OutTags { get; set; }
//CONDITIONS - Following fields are all conditions set on whether to notify or not
public AyaType AyaType { get; set; }//Note: must be specific object, not global for any object related stuff to avoid many role issues and also potential overload
[Required]
public NotifyEventType EventType { get; set; }
public List<string> Tags { get; set; }//Tags to filter an event, object *must* have these tags to generate event related to it (AT TIME OF UPDATE)
public NotifySubscription()
{
InTags = new List<string>();
OutTags = new List<string>();
Tags = new List<string>();
AyaType= AyaType.NoType;
}
}//eoc

View File

@@ -1857,7 +1857,6 @@
"NotifyEventType": "Benachrichtigungsereignis",
"NotifyDeliveryAddress": "An Adresse liefern",
"InTags": "Filtern Sie in diesen Tags",
"OutTags": "Filtern Sie diese Tags heraus",
"NotifyEventObjectDeleted": "Objekt gelöscht",
"NotifyEventObjectCreated": "Objekt erstellt",
"NotifyEventObjectModified": "Objekt geändert",

View File

@@ -1857,7 +1857,6 @@
"NotifyEventType": "Notification event",
"NotifyDeliveryAddress": "Deliver to address",
"InTags": "Filter include tags",
"OutTags": "Filter exclude tags",
"NotifyEventObjectDeleted": "Object deleted",
"NotifyEventObjectCreated": "Object created",
"NotifyEventObjectModified": "Object changed",

View File

@@ -1857,7 +1857,6 @@
"NotifyEventType": "Evento de notificación",
"NotifyDeliveryAddress": "Entregar a la dirección de correo electrónico",
"InTags": "Filtrar incluir etiquetas",
"OutTags": "Filtrar etiquetas excluidas",
"NotifyEventObjectDeleted": "Objeto eliminado",
"NotifyEventObjectCreated": "Objeto creado",
"NotifyEventObjectModified": "Objeto cambiado",

View File

@@ -1857,7 +1857,6 @@
"NotifyEventType": "Événement de notification",
"NotifyDeliveryAddress": "Livrer à l'adresse",
"InTags": "Filtrer les balises inclusives",
"OutTags": "Filtrer les tags exclusifs",
"NotifyEventObjectDeleted": "Objet supprimé",
"NotifyEventObjectCreated": "Objet créé",
"NotifyEventObjectModified": "Objet changé",

View File

@@ -684,8 +684,8 @@ $BODY$;
LogUpdateMessage(log);
await ExecQueryAsync("CREATE TABLE anotifysubscription (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, " +
"userid bigint not null, ayatype integer, eventtype integer not null, advancenotice interval, " +
"idvalue bigint, decvalue decimal(19,4), agevalue interval, deliverymethod integer not null, deliveryaddress text, attachreportid bigint, intags varchar(255) ARRAY, outtags varchar(255) ARRAY)");
"userid bigint not null, ayatype integer not null, eventtype integer not null, advancenotice interval, " +
"idvalue bigint, decvalue decimal(19,4), agevalue interval, deliverymethod integer not null, deliveryaddress text, attachreportid bigint, tags varchar(255) ARRAY)");
await ExecQueryAsync("CREATE TABLE anotifyevent (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created timestamp not null, " +
"ayatype integer, objectid bigint, eventtype integer not null, subscriptionid bigint not null, idvalue bigint, decvalue decimal(19,4), eventdate timestamp, deliverdate timestamp, message text)");