Modify aygetname postgres function to handle translation of items that do not have a name, also code to back it at server
This commit is contained in:
@@ -7,13 +7,13 @@ namespace AyaNova.Biz
|
||||
//Used by search and eventlog processor
|
||||
internal static class BizObjectNameFetcherDirect
|
||||
{
|
||||
internal static string Name(AyaType ayaType, long id, System.Data.Common.DbCommand cmd)
|
||||
internal static string Name(AyaType ayaType, long id, long translationid, System.Data.Common.DbCommand cmd)
|
||||
{
|
||||
try
|
||||
{
|
||||
string ret;
|
||||
|
||||
cmd.CommandText = $"select PUBLIC.AYGETNAME({id}, {(int)ayaType}) as m";
|
||||
cmd.CommandText = $"select PUBLIC.AYGETNAME({id}, {(int)ayaType}, {translationid}) as m";
|
||||
using (var dr = cmd.ExecuteReader())
|
||||
{
|
||||
if (dr.Read())
|
||||
@@ -40,12 +40,12 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
//warning: use the above in a loop, not this one
|
||||
internal static string Name(AyaType ayaType, long id, AyaNova.Models.AyContext ct)
|
||||
internal static string Name(AyaType ayaType, long id, long translationId, AyaNova.Models.AyContext ct)
|
||||
{
|
||||
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
||||
{
|
||||
ct.Database.OpenConnection();
|
||||
return Name(ayaType, id, command);
|
||||
return Name(ayaType, id,translationId, command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -495,7 +495,7 @@ namespace AyaNova.Biz
|
||||
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.CSRAccepted).ToListAsync();
|
||||
string SourceName = string.Empty;
|
||||
if (subs.Count > 0)
|
||||
SourceName = BizObjectNameFetcherDirect.Name(BizType, o.Id, ct);
|
||||
SourceName = BizObjectNameFetcherDirect.Name(BizType, o.Id, UserTranslationId, ct);
|
||||
foreach (var sub in subs)
|
||||
{
|
||||
//not for inactive users
|
||||
@@ -522,7 +522,7 @@ namespace AyaNova.Biz
|
||||
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.CSRRejected).ToListAsync();
|
||||
string SourceName = string.Empty;
|
||||
if (subs.Count > 0)
|
||||
SourceName = BizObjectNameFetcherDirect.Name(BizType, o.Id, ct);
|
||||
SourceName = BizObjectNameFetcherDirect.Name(BizType, o.Id, UserTranslationId, ct);
|
||||
foreach (var sub in subs)
|
||||
{
|
||||
//not for inactive users
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace AyaNova.Biz
|
||||
var ret = new DataListColumnView();
|
||||
ret.UserId = UserId;
|
||||
ret.ListKey = listKey;
|
||||
var dataList = DataListFactory.GetAyaDataList(listKey);
|
||||
var dataList = DataListFactory.GetAyaDataList(listKey, 0);
|
||||
ret.Columns = JsonConvert.SerializeObject(dataList.DefaultColumns);
|
||||
ret.Sort = JsonConvert.SerializeObject(dataList.DefaultSortBy);
|
||||
return await CreateAsync(ret);
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace AyaNova.Biz
|
||||
throw new System.ArgumentOutOfRangeException($"ListKey '{listKey}' is not a valid DataListKey");
|
||||
}
|
||||
|
||||
var dataList = DataListFactory.GetAyaDataList(listKey);
|
||||
var dataList = DataListFactory.GetAyaDataList(listKey,0);
|
||||
|
||||
DataListSavedFilter d = new DataListSavedFilter();
|
||||
d.ListKey = listKey;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace AyaNova.Biz
|
||||
/// Get the event log for a specified object
|
||||
/// Presentation is the client's responsibility (localization internationalization etc)
|
||||
/// </summary>
|
||||
internal static async Task<AyaNova.Api.Controllers.EventLogController.ObjectEventLog> GetLogForObjectAsync(AyaNova.Api.Controllers.EventLogController.EventLogOptions opt, AyContext ct)
|
||||
internal static async Task<AyaNova.Api.Controllers.EventLogController.ObjectEventLog> GetLogForObjectAsync(AyaNova.Api.Controllers.EventLogController.EventLogOptions opt, long translationId, AyContext ct)
|
||||
{
|
||||
AyaNova.Api.Controllers.EventLogController.ObjectEventLog ret = new Api.Controllers.EventLogController.ObjectEventLog();
|
||||
|
||||
@@ -72,10 +72,10 @@ namespace AyaNova.Biz
|
||||
UserId = z.UserId,
|
||||
Event = z.AyEvent,
|
||||
Textra = z.Textra,
|
||||
Name = BizObjectNameFetcherDirect.Name(AyaType.User, z.UserId, command)
|
||||
Name = BizObjectNameFetcherDirect.Name(AyaType.User, z.UserId, translationId, command)
|
||||
}).ToArray();
|
||||
|
||||
ret.Name = BizObjectNameFetcherDirect.Name(opt.AyaType, opt.AyId, command);
|
||||
ret.Name = BizObjectNameFetcherDirect.Name(opt.AyaType, opt.AyId, translationId, command);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ namespace AyaNova.Biz
|
||||
/// Get the event log for a specified User
|
||||
/// Presentation is the client's responsibility (localization internationalization etc)
|
||||
/// </summary>
|
||||
internal static async Task<AyaNova.Api.Controllers.EventLogController.UserEventLog> GetLogForUserAsync(AyaNova.Api.Controllers.EventLogController.UserEventLogOptions opt, AyContext ct)
|
||||
internal static async Task<AyaNova.Api.Controllers.EventLogController.UserEventLog> GetLogForUserAsync(AyaNova.Api.Controllers.EventLogController.UserEventLogOptions opt, long translationId, AyContext ct)
|
||||
{
|
||||
|
||||
AyaNova.Api.Controllers.EventLogController.UserEventLog ret = new Api.Controllers.EventLogController.UserEventLog();
|
||||
@@ -115,10 +115,10 @@ namespace AyaNova.Biz
|
||||
ObjectId = z.AyId,
|
||||
Event = z.AyEvent,
|
||||
Textra = z.Textra,
|
||||
Name = BizObjectNameFetcherDirect.Name(z.AyaType, z.AyId, command)
|
||||
Name = BizObjectNameFetcherDirect.Name(z.AyaType, z.AyId, translationId, command)
|
||||
|
||||
}).ToArray();
|
||||
ret.Name = BizObjectNameFetcherDirect.Name(AyaType.User, opt.UserId, command);
|
||||
ret.Name = BizObjectNameFetcherDirect.Name(AyaType.User, opt.UserId, translationId, command);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ namespace AyaNova.Biz
|
||||
if (o.SourceType != null)
|
||||
o.SourceTypeViz = ayaTypesEnumList.Where(x => x.Id == (long)o.SourceType).Select(x => x.Name).First();
|
||||
if (o.SourceType != null && o.SourceId != null)
|
||||
o.SourceViz = BizObjectNameFetcherDirect.Name((AyaType)o.SourceType, (long)o.SourceId, cmd);
|
||||
o.SourceViz = BizObjectNameFetcherDirect.Name((AyaType)o.SourceType, (long)o.SourceId, UserTranslationId, cmd);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ namespace AyaNova.Biz
|
||||
await ValidateCanDeleteAsync(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
{
|
||||
{
|
||||
var IDList = await ct.Review.AsNoTracking().Where(x => x.AType == AyaType.PurchaseOrder && x.ObjectId == id).Select(x => x.Id).ToListAsync();
|
||||
if (IDList.Count() > 0)
|
||||
{
|
||||
@@ -957,7 +957,7 @@ namespace AyaNova.Biz
|
||||
AyaType = AyaType.WorkOrderItemPartRequest,
|
||||
ObjectId = (long)proposedRequestItem.WorkOrderItemPartRequestId,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = BizObjectNameFetcherDirect.Name(AyaType.WorkOrderItemPartRequest, (long)proposedRequestItem.WorkOrderItemPartRequestId, ct)
|
||||
Name = BizObjectNameFetcherDirect.Name(AyaType.WorkOrderItemPartRequest, (long)proposedRequestItem.WorkOrderItemPartRequestId, UserTranslationId, ct)
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
return false;
|
||||
ct.Review.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
@@ -364,7 +364,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
o.UserViz = await ct.User.AsNoTracking().Where(x => x.Id == o.UserId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||
o.AssignedByUserViz = await ct.User.AsNoTracking().Where(x => x.Id == o.AssignedByUserId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||
o.ReviewObjectViz = BizObjectNameFetcherDirect.Name(o.AType, o.ObjectId, ct);
|
||||
o.ReviewObjectViz = BizObjectNameFetcherDirect.Name(o.AType, o.ObjectId, UserTranslationId, ct);
|
||||
if (o.ReviewObjectViz.StartsWith("LT:"))
|
||||
{
|
||||
o.ReviewObjectViz = await Translate(o.ReviewObjectViz);
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
SearchResult SR = new SearchResult();
|
||||
SR.Name = BizObjectNameFetcherDirect.Name(i.AType,
|
||||
i.ObjectId,
|
||||
i.ObjectId,translationId,
|
||||
command);
|
||||
SR.Id = i.ObjectId;
|
||||
SR.Type = i.AType;
|
||||
|
||||
Reference in New Issue
Block a user