This commit is contained in:
2021-03-02 15:34:05 +00:00
parent 054f25efbe
commit c1cccba712
9 changed files with 58 additions and 18 deletions

View File

@@ -85,7 +85,7 @@ namespace AyaNova.Api.Controllers
ret.Add(new KeyValuePair<string, string>(StringUtil.TrimTypeName(typeof(NotifyEventType).ToString()), "Notification event types")); ret.Add(new KeyValuePair<string, string>(StringUtil.TrimTypeName(typeof(NotifyEventType).ToString()), "Notification event types"));
ret.Add(new KeyValuePair<string, string>(StringUtil.TrimTypeName(typeof(NotifyDeliveryMethod).ToString()), "Notification delivery methods")); ret.Add(new KeyValuePair<string, string>(StringUtil.TrimTypeName(typeof(NotifyDeliveryMethod).ToString()), "Notification delivery methods"));
ret.Add(new KeyValuePair<string, string>(StringUtil.TrimTypeName(typeof(NotifyMailSecurity).ToString()), "Notification SMTP mail server security method")); ret.Add(new KeyValuePair<string, string>(StringUtil.TrimTypeName(typeof(NotifyMailSecurity).ToString()), "Notification SMTP mail server security method"));
todo: add missing from below
return Ok(ApiOkResponse.Response(ret)); return Ok(ApiOkResponse.Response(ret));
} }

View File

@@ -330,8 +330,16 @@ namespace AyaNova.Biz
var batchResults = await ct.CustomerServiceRequest.AsNoTracking().Where(z => batch.Contains(z.Id)).ToArrayAsync(); var batchResults = await ct.CustomerServiceRequest.AsNoTracking().Where(z => batch.Contains(z.Id)).ToArrayAsync();
//order the results back into original //order the results back into original
var orderedList = from id in batch join z in batchResults on id equals z.Id select z; var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
//cache frequent viz data
//usertypes
var CustomerServiceRequestStatusEnumList = await AyaNova.Api.Controllers.EnumListController.GetEnumList(StringUtil.TrimTypeName(typeof(CustomerServiceRequestStatus).ToString()), UserTranslationId);
var CustomerServiceRequestPriorityEnumList = await AyaNova.Api.Controllers.EnumListController.GetEnumList(StringUtil.TrimTypeName(typeof(CustomerServiceRequestPriority).ToString()), UserTranslationId);
foreach (CustomerServiceRequest w in orderedList) foreach (CustomerServiceRequest w in orderedList)
{ {
await PopulateVizFields(w, CustomerServiceRequestStatusEnumList, CustomerServiceRequestPriorityEnumList);
var jo = JObject.FromObject(w); var jo = JObject.FromObject(w);
if (!JsonUtil.JTokenIsNullOrEmpty(jo["CustomFields"])) if (!JsonUtil.JTokenIsNullOrEmpty(jo["CustomFields"]))
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]); jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
@@ -341,12 +349,26 @@ namespace AyaNova.Biz
return ReportData; return ReportData;
} }
//populate viz fields from provided object
private async Task PopulateVizFields(CustomerServiceRequest o, List<NameIdItem> customerServiceRequestStatusEnumList, List<NameIdItem> customerServiceRequestPriorityEnumList)
{
if (o.UnitId != null)
o.UnitViz = await ct.Unit.AsNoTracking().Where(x => x.Id == o.UnitId).Select(x => x.Serial).FirstOrDefaultAsync();
o.CustomerViz = await ct.Customer.AsNoTracking().Where(x => x.Id == o.CustomerId).Select(x => x.Name).FirstOrDefaultAsync();
//MIGRATE_OUTSTANDING routine to get wo id from the WorkorderItemId
// if (o.WorkorderItemId != null)
// o.WorkorderItemViz = await ct.WorkorderItem.AsNoTracking().Where(x=>x.Id==o.WorkorderItemId).Select(x => x.Name).FirstOrDefaultAsync();
o.RequestedByUserViz = await ct.User.AsNoTracking().Where(x => x.Id == o.RequestedByUserId).Select(x => x.Name).FirstOrDefaultAsync();
o.StatusViz = customerServiceRequestStatusEnumList.Where(x => x.Id == (long)o.Status).Select(x => x.Name).First();
o.PriorityViz = customerServiceRequestPriorityEnumList.Where(x => x.Id == (long)o.Priority).Select(x => x.Name).First();
}
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
// IMPORT EXPORT // IMPORT EXPORT
// //
public async Task<JArray> GetExportData(long[] idList) public async Task<JArray> GetExportData(long[] idList)
{ {
//for now just re-use the report data code //for now just re-use the report data code
@@ -354,9 +376,6 @@ namespace AyaNova.Biz
return await GetReportData(idList); return await GetReportData(idList);
} }
public async Task<List<string>> ImportData(JArray ja) public async Task<List<string>> ImportData(JArray ja)
{ {
List<string> ImportResult = new List<string>(); List<string> ImportResult = new List<string>();

View File

@@ -149,9 +149,9 @@ namespace AyaNova.Biz
if (po.DropShipToCustomerId != null) if (po.DropShipToCustomerId != null)
po.DropShipToCustomerViz = await ct.Customer.AsNoTracking().Where(x => x.Id == po.DropShipToCustomerId).Select(x => x.Name).FirstOrDefaultAsync(); po.DropShipToCustomerViz = await ct.Customer.AsNoTracking().Where(x => x.Id == po.DropShipToCustomerId).Select(x => x.Name).FirstOrDefaultAsync();
po.VendorViz = await ct.Contract.AsNoTracking().Where(x => x.Id == po.VendorId).Select(x => x.Name).FirstOrDefaultAsync(); po.VendorViz = await ct.Vendor.AsNoTracking().Where(x => x.Id == po.VendorId).Select(x => x.Name).FirstOrDefaultAsync();
if (po.ProjectId != null) if (po.ProjectId != null)
po.ProjectViz = await ct.Contract.AsNoTracking().Where(x => x.Id == po.ProjectId).Select(x => x.Name).FirstOrDefaultAsync(); po.ProjectViz = await ct.Project.AsNoTracking().Where(x => x.Id == po.ProjectId).Select(x => x.Name).FirstOrDefaultAsync();
foreach (PurchaseOrderItem item in po.Items) foreach (PurchaseOrderItem item in po.Items)
{ {

View File

@@ -278,6 +278,7 @@ namespace AyaNova.Biz
var orderedList = from id in batch join z in batchResults on id equals z.Id select z; var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
foreach (Reminder w in orderedList) foreach (Reminder w in orderedList)
{ {
await PopulateVizFields(w);
var jo = JObject.FromObject(w); var jo = JObject.FromObject(w);
if (!JsonUtil.JTokenIsNullOrEmpty(jo["CustomFields"])) if (!JsonUtil.JTokenIsNullOrEmpty(jo["CustomFields"]))
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]); jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
@@ -287,12 +288,16 @@ namespace AyaNova.Biz
return ReportData; return ReportData;
} }
//populate viz fields from provided object
private async Task PopulateVizFields(Reminder o)
{
o.UserViz = await ct.User.AsNoTracking().Where(x => x.Id == o.UserId).Select(x => x.Name).FirstOrDefaultAsync();
}
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
// IMPORT EXPORT // IMPORT EXPORT
// //
public async Task<JArray> GetExportData(long[] idList) public async Task<JArray> GetExportData(long[] idList)
{ {
//for now just re-use the report data code //for now just re-use the report data code
@@ -300,9 +305,6 @@ namespace AyaNova.Biz
return await GetReportData(idList); return await GetReportData(idList);
} }
public async Task<List<string>> ImportData(JArray ja) public async Task<List<string>> ImportData(JArray ja)
{ {
List<string> ImportResult = new List<string>(); List<string> ImportResult = new List<string>();

View File

@@ -300,6 +300,7 @@ namespace AyaNova.Biz
var orderedList = from id in batch join z in batchResults on id equals z.Id select z; var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
foreach (UnitModel w in orderedList) foreach (UnitModel w in orderedList)
{ {
await PopulateVizFields(w);
var jo = JObject.FromObject(w); var jo = JObject.FromObject(w);
if (!JsonUtil.JTokenIsNullOrEmpty(jo["CustomFields"])) if (!JsonUtil.JTokenIsNullOrEmpty(jo["CustomFields"]))
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]); jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
@@ -309,12 +310,17 @@ namespace AyaNova.Biz
return ReportData; return ReportData;
} }
//populate viz fields from provided object
private async Task PopulateVizFields(UnitModel o)
{
if (o.VendorId != null)
o.VendorViz = await ct.Vendor.AsNoTracking().Where(x => x.Id == o.VendorId).Select(x => x.Name).FirstOrDefaultAsync();
}
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
// IMPORT EXPORT // IMPORT EXPORT
// //
public async Task<JArray> GetExportData(long[] idList) public async Task<JArray> GetExportData(long[] idList)
{ {
//for now just re-use the report data code //for now just re-use the report data code
@@ -322,9 +328,6 @@ namespace AyaNova.Biz
return await GetReportData(idList); return await GetReportData(idList);
} }
public async Task<List<string>> ImportData(JArray ja) public async Task<List<string>> ImportData(JArray ja)
{ {
List<string> ImportResult = new List<string>(); List<string> ImportResult = new List<string>();

View File

@@ -910,7 +910,7 @@ namespace AyaNova.Biz
o.HeadOfficeViz = await ct.HeadOffice.AsNoTracking().Where(x => x.Id == o.HeadOfficeId).Select(x => x.Name).FirstOrDefaultAsync(); o.HeadOfficeViz = await ct.HeadOffice.AsNoTracking().Where(x => x.Id == o.HeadOfficeId).Select(x => x.Name).FirstOrDefaultAsync();
if (o.VendorId != null) if (o.VendorId != null)
o.VendorViz = await ct.Customer.AsNoTracking().Where(x => x.Id == o.VendorId).Select(x => x.Name).FirstOrDefaultAsync(); o.VendorViz = await ct.Vendor.AsNoTracking().Where(x => x.Id == o.VendorId).Select(x => x.Name).FirstOrDefaultAsync();
o.UserTypeViz = userTypesEnumList.Where(x => x.Id == (long)o.UserType).Select(x => x.Name).First(); o.UserTypeViz = userTypesEnumList.Where(x => x.Id == (long)o.UserType).Select(x => x.Name).First();
} }

View File

@@ -17,7 +17,7 @@ namespace AyaNova.Models
[Required] [Required]
public string Name { get; set; } public string Name { get; set; }
public string Notes { get; set; } public string Notes { get; set; }
public string Wiki { get; set; } public string Wiki { get; set; }
public string CustomFields { get; set; } public string CustomFields { get; set; }
@@ -26,15 +26,27 @@ namespace AyaNova.Models
public DateTime DateRequested { get; set; } public DateTime DateRequested { get; set; }
[Required] [Required]
public long CustomerId { get; set; } public long CustomerId { get; set; }
[NotMapped]
public string CustomerViz { get; set; }
public long? UnitId { get; set; } public long? UnitId { get; set; }
[NotMapped]
public string UnitViz { get; set; }
public long? WorkorderItemId { get; set; } public long? WorkorderItemId { get; set; }
[NotMapped]
public string WorkorderItemViz { get; set; }
[Required] [Required]
public long RequestedByUserId { get; set; } public long RequestedByUserId { get; set; }
[NotMapped]
public string RequestedByUserViz { get; set; }
public string CustomerReferenceNumber { get; set; } public string CustomerReferenceNumber { get; set; }
[Required] [Required]
public CustomerServiceRequestStatus Status { get; set; } public CustomerServiceRequestStatus Status { get; set; }
[NotMapped]
public string StatusViz { get; set; }
[Required] [Required]
public CustomerServiceRequestPriority Priority { get; set; } public CustomerServiceRequestPriority Priority { get; set; }
[NotMapped]
public string PriorityViz { get; set; }
public CustomerServiceRequest() public CustomerServiceRequest()
{ {

View File

@@ -29,6 +29,8 @@ namespace AyaNova.Models
public DateTime StopDate { get; set; } public DateTime StopDate { get; set; }
[Required] [Required]
public long UserId { get; set; } public long UserId { get; set; }
[NotMapped]
public string UserViz { get; set; }
/* /*
Hexadecimal notation: #RGB[A] Hexadecimal notation: #RGB[A]
R (red), G (green), B (blue), and A (alpha) are hexadecimal characters (09, AF). A is optional. The three-digit notation (#RGB) is a shorter version of the six-digit form (#RRGGBB). For example, #f09 is the same color as #ff0099. Likewise, the four-digit RGB notation (#RGBA) is a shorter version of the eight-digit form (#RRGGBBAA). For example, #0f38 is the same color as #00ff3388. R (red), G (green), B (blue), and A (alpha) are hexadecimal characters (09, AF). A is optional. The three-digit notation (#RGB) is a shorter version of the six-digit form (#RRGGBB). For example, #f09 is the same color as #ff0099. Likewise, the four-digit RGB notation (#RGBA) is a shorter version of the eight-digit form (#RRGGBBAA). For example, #0f38 is the same color as #00ff3388.

View File

@@ -26,6 +26,8 @@ namespace AyaNova.Models
[Required] [Required]
public string Number { get; set; } public string Number { get; set; }
public long? VendorId { get; set; } public long? VendorId { get; set; }
[NotMapped]
public string VendorViz { get; set; }
public string UPC { get; set; } public string UPC { get; set; }
public bool LifeTimeWarranty { get; set; } public bool LifeTimeWarranty { get; set; }
public DateTime? IntroducedDate { get; set; } public DateTime? IntroducedDate { get; set; }
@@ -36,7 +38,7 @@ namespace AyaNova.Models
public UnitModel() public UnitModel()
{ {
Tags = new List<string>(); Tags = new List<string>();
} }
[NotMapped, JsonIgnore] [NotMapped, JsonIgnore]