rename all variants of naming that hold an AyaType value to "aType" (parameter) / "AType" (not parameter) everywhere front and back; "ayType", "objectType", "oType" all are used in various areas
This commit is contained in:
@@ -90,7 +90,7 @@ namespace AyaNova.Biz
|
||||
var FullPathName = FileUtil.GetPermanentAttachmentFilePath(i.StoredFileName);
|
||||
AllDBFileFullPath.Add(FullPathName);
|
||||
var FileExistsInReality = AllAttachmentFilesOnDisk.Contains(FullPathName);
|
||||
var ParentBizObjectExistsInReality = await BizObjectExistsInDatabase.ExistsAsync(i.AttachToObjectType, i.AttachToObjectId, ct);
|
||||
var ParentBizObjectExistsInReality = await BizObjectExistsInDatabase.ExistsAsync(i.AttachToAType, i.AttachToObjectId, ct);
|
||||
//does the db record reflect the same status as reality?
|
||||
if (FileExistsInReality != i.Exists || !ParentBizObjectExistsInReality)
|
||||
{
|
||||
@@ -101,7 +101,7 @@ namespace AyaNova.Biz
|
||||
if (!ParentBizObjectExistsInReality)
|
||||
{
|
||||
//switch it to notype
|
||||
f.AttachToObjectType = AyaType.NoType;
|
||||
f.AttachToAType = AyaType.NoType;
|
||||
f.AttachToObjectId = 0;
|
||||
}
|
||||
await ct.SaveChangesAsync();
|
||||
@@ -121,10 +121,10 @@ namespace AyaNova.Biz
|
||||
// //also, potentiallly
|
||||
// //iterate orphaned file attachments to NOTHING type, if found to be attached to any other object remove the orphaned object attachment record in db
|
||||
// //but keeping the physical file since it's attached to something else
|
||||
// var AllOrphansInDb = await ct.FileAttachment.Where(z => z.AttachToObjectType == AyaType.NoType).ToListAsync();
|
||||
// var AllOrphansInDb = await ct.FileAttachment.Where(z => z.AttachToAType == AyaType.NoType).ToListAsync();
|
||||
// foreach (FileAttachment OrphanInDb in AllOrphansInDb)
|
||||
// {
|
||||
// if (await ct.FileAttachment.AnyAsync(z => z.StoredFileName==OrphanInDb.StoredFileName && z.AttachToObjectType != AyaType.NoType))
|
||||
// if (await ct.FileAttachment.AnyAsync(z => z.StoredFileName==OrphanInDb.StoredFileName && z.AttachToAType != AyaType.NoType))
|
||||
// {
|
||||
// //It is also attached to something else so remove it from the nothing type
|
||||
// ct.FileAttachment.Remove(OrphanInDb);
|
||||
@@ -158,7 +158,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
FileAttachment fa = new FileAttachment();
|
||||
fa.AttachToObjectId = 0;
|
||||
fa.AttachToObjectType = AyaType.NoType;
|
||||
fa.AttachToAType = AyaType.NoType;
|
||||
fa.ContentType = "application/octet-stream";//most generic type, we don't know what it is
|
||||
fa.DisplayFileName = "FOUND" + FileUtil.GetSafeDateFileName();
|
||||
fa.LastModified = DateTime.UtcNow;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
public AyaType ObjectType
|
||||
public AyaType AType
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -25,7 +25,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
public int ObjectTypeAsInt
|
||||
public int ATypeAsInt
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -33,20 +33,20 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
public AyaTypeId(AyaType ObjectType, long Id)
|
||||
public AyaTypeId(AyaType aType, long Id)
|
||||
{
|
||||
_id = Id;
|
||||
_ayaType = ObjectType;
|
||||
_ayaType = aType;
|
||||
}
|
||||
|
||||
public AyaTypeId(string sObjectTypeNumeral, string sId)
|
||||
public AyaTypeId(string sATypeNumeral, string sId)
|
||||
{
|
||||
_id = long.Parse(sId);
|
||||
int nType = int.Parse(sObjectTypeNumeral);
|
||||
int nType = int.Parse(sATypeNumeral);
|
||||
if (!AyaTypeExists(nType))
|
||||
_ayaType = AyaType.NoType;
|
||||
else
|
||||
_ayaType = (AyaType)Enum.Parse(typeof(AyaType), sObjectTypeNumeral);
|
||||
_ayaType = (AyaType)Enum.Parse(typeof(AyaType), sATypeNumeral);
|
||||
}
|
||||
|
||||
public bool Equals(AyaTypeId x, AyaTypeId y)
|
||||
@@ -60,7 +60,7 @@ namespace AyaNova.Biz
|
||||
return false;
|
||||
|
||||
//Check whether the products' properties are equal.
|
||||
return x.ObjectId == y.ObjectId && x.ObjectType == y.ObjectType;
|
||||
return x.ObjectId == y.ObjectId && x.AType == y.AType;
|
||||
}
|
||||
|
||||
public bool IsEmpty
|
||||
@@ -95,7 +95,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute));
|
||||
return this.AType.HasAttribute(typeof(CoreBizObjectAttribute));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,11 @@ namespace AyaNova.Biz
|
||||
|
||||
//Returns existance status of object type and id specified in database
|
||||
|
||||
internal static async Task<bool> ExistsAsync(AyaType objectType, long id, AyContext ct)
|
||||
internal static async Task<bool> ExistsAsync(AyaType aType, long id, AyContext ct)
|
||||
{
|
||||
//new up a context??
|
||||
|
||||
switch (objectType)
|
||||
switch (aType)
|
||||
{
|
||||
//CoreBizObject add here
|
||||
case AyaType.NoType://no type always exists and this is used by orphaned attachments
|
||||
@@ -123,7 +123,7 @@ namespace AyaNova.Biz
|
||||
case AyaType.CustomerServiceRequest:
|
||||
return await ct.CustomerServiceRequest.AnyAsync(z => z.Id == id);
|
||||
default:
|
||||
throw new System.NotSupportedException($"AyaNova.Biz.BizObjectExistsInDatabase::ExistsAsync type {objectType.ToString()} is not supported");
|
||||
throw new System.NotSupportedException($"AyaNova.Biz.BizObjectExistsInDatabase::ExistsAsync type {aType.ToString()} is not supported");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
|
||||
Date = z.Created,
|
||||
ObjectType = z.AyaType,
|
||||
AType = z.AyaType,
|
||||
ObjectId = z.AyId,
|
||||
Event = z.AyEvent,
|
||||
Textra = z.Textra,
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace AyaNova.Biz
|
||||
case JobType.BatchCoreObjectOperation:
|
||||
//batch op, hand off to biz object to deal with
|
||||
//note, convention is that there is an idList in job.jobinfo json if preselected else it's all objects of type
|
||||
o = (IJobObject)BizObjectFactory.GetBizObject(job.ObjectType, ct);
|
||||
o = (IJobObject)BizObjectFactory.GetBizObject(job.AType, ct);
|
||||
break;
|
||||
default:
|
||||
throw new System.NotSupportedException($"ProcessJobAsync type {job.JobType.ToString()} is not supported");
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace AyaNova.Biz
|
||||
// newObject.JsHelpers = (string)o["JsHelpers"];
|
||||
// newObject.JsPrerender = (string)o["JsPrerender"];
|
||||
// newObject.Notes = (string)o["Notes"];
|
||||
// newObject.ObjectType = (AyaType)(int)o["ObjectType"];
|
||||
// newObject.AType = (AyaType)(int)o["AType"];
|
||||
// newObject.RenderType = (ReportRenderType)(int)o["RenderType"];
|
||||
// newObject.Roles = (AuthorizationRoles)(int)o["Roles"];
|
||||
// newObject.Style = (string)o["Style"];
|
||||
@@ -239,9 +239,9 @@ namespace AyaNova.Biz
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//GET LIST
|
||||
//
|
||||
internal async Task<List<NameIdItem>> GetReportListAsync(AyaType ayType)
|
||||
internal async Task<List<NameIdItem>> GetReportListAsync(AyaType aType)
|
||||
{
|
||||
var rpts = await ct.Report.AsNoTracking().Where(z => z.ObjectType == ayType && z.Active == true).Select(z => new { id = z.Id, name = z.Name, roles = z.Roles }).ToListAsync();
|
||||
var rpts = await ct.Report.AsNoTracking().Where(z => z.AType == aType && z.Active == true).Select(z => new { id = z.Id, name = z.Name, roles = z.Roles }).ToListAsync();
|
||||
var ret = new List<NameIdItem>();
|
||||
foreach (var item in rpts)
|
||||
{
|
||||
@@ -341,15 +341,15 @@ namespace AyaNova.Biz
|
||||
var log = AyaNova.Util.ApplicationLogging.CreateLogger("ReportBiz::GetReportData");
|
||||
AuthorizationRoles effectiveRoles = CurrentUserRoles;
|
||||
|
||||
if (selectedRequest.ObjectType == AyaType.NoType)
|
||||
if (selectedRequest.AType == AyaType.NoType)
|
||||
{
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, null, $"ObjectType is required");
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, null, $"AType is required");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(effectiveRoles, selectedRequest.ObjectType))
|
||||
if (!AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(effectiveRoles, selectedRequest.AType))
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_AUTHORIZED, null, $"User not authorized for {selectedRequest.ObjectType} type object");
|
||||
AddError(ApiErrorCode.NOT_AUTHORIZED, null, $"User not authorized for {selectedRequest.AType} type object");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -358,9 +358,9 @@ namespace AyaNova.Biz
|
||||
selectedRequest.SelectedRowIds = await DataListSelectedProcessingOptions.RehydrateIdList(selectedRequest, ct, effectiveRoles, log, UserId, UserTranslationId);
|
||||
|
||||
|
||||
log.LogDebug($"Instantiating biz object handler for {selectedRequest.ObjectType}");
|
||||
var biz = BizObjectFactory.GetBizObject(selectedRequest.ObjectType, ct, UserId, CurrentUserRoles, UserTranslationId);
|
||||
log.LogDebug($"Fetching data for {selectedRequest.SelectedRowIds.Length} {selectedRequest.ObjectType} items");
|
||||
log.LogDebug($"Instantiating biz object handler for {selectedRequest.AType}");
|
||||
var biz = BizObjectFactory.GetBizObject(selectedRequest.AType, ct, UserId, CurrentUserRoles, UserTranslationId);
|
||||
log.LogDebug($"Fetching data for {selectedRequest.SelectedRowIds.Length} {selectedRequest.AType} items");
|
||||
return await ((IReportAbleObject)biz).GetReportData(selectedRequest.SelectedRowIds);
|
||||
}
|
||||
|
||||
@@ -383,17 +383,17 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
//If we get here via the /viewreport url in the client then there is no object type set so we need to set it here from the report
|
||||
if(reportRequest.ObjectType==AyaType.NoType){
|
||||
reportRequest.ObjectType=report.ObjectType;
|
||||
if(reportRequest.AType==AyaType.NoType){
|
||||
reportRequest.AType=report.AType;
|
||||
}
|
||||
|
||||
|
||||
AuthorizationRoles effectiveRoles = CurrentUserRoles;
|
||||
|
||||
|
||||
if (!AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(effectiveRoles, report.ObjectType))
|
||||
if (!AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(effectiveRoles, report.AType))
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_AUTHORIZED, null, $"User not authorized for {report.ObjectType} type object");
|
||||
AddError(ApiErrorCode.NOT_AUTHORIZED, null, $"User not authorized for {report.AType} type object");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -559,14 +559,14 @@ namespace AyaNova.Biz
|
||||
|
||||
//Custom fields definition for report usage
|
||||
string CustomFieldsTemplate = "null";
|
||||
var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == report.ObjectType.ToString());
|
||||
var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == report.AType.ToString());
|
||||
if (FormCustomization != null)
|
||||
{
|
||||
CustomFieldsTemplate = FormCustomization.Template;
|
||||
}
|
||||
|
||||
//Report meta data
|
||||
var reportMeta = $"{{Id:{report.Id},Name:`{report.Name}`,Notes:`{report.Notes}`,ObjectType:`{report.ObjectType}`,CustomFieldsDefinition:{CustomFieldsTemplate},DataListKey:`{reportRequest.DataListKey}`,SelectedRowIds: `{string.Join(",", reportRequest.SelectedRowIds)}`}}";
|
||||
var reportMeta = $"{{Id:{report.Id},Name:`{report.Name}`,Notes:`{report.Notes}`,AType:`{report.AType}`,CustomFieldsDefinition:{CustomFieldsTemplate},DataListKey:`{reportRequest.DataListKey}`,SelectedRowIds: `{string.Join(",", reportRequest.SelectedRowIds)}`}}";
|
||||
|
||||
|
||||
//duplicate meta data in report page wide variable for use by our internal functions
|
||||
|
||||
@@ -276,17 +276,17 @@ namespace AyaNova.Biz
|
||||
AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "ObjectId");
|
||||
return;
|
||||
}
|
||||
if (proposedObj.ObjectType != currentObj.ObjectType)
|
||||
if (proposedObj.AType != currentObj.AType)
|
||||
{
|
||||
AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "ObjectType");
|
||||
AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "AType");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Does the object of this Review actually exist?
|
||||
if (!await BizObjectExistsInDatabase.ExistsAsync(proposedObj.ObjectType, proposedObj.ObjectId, ct))
|
||||
if (!await BizObjectExistsInDatabase.ExistsAsync(proposedObj.AType, proposedObj.ObjectId, ct))
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND, "generalerror", $"LT:ErrorAPI2010 LT:{proposedObj.ObjectType} id {proposedObj.ObjectId}");
|
||||
AddError(ApiErrorCode.NOT_FOUND, "generalerror", $"LT:ErrorAPI2010 LT:{proposedObj.AType} id {proposedObj.ObjectId}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,11 +152,11 @@ namespace AyaNova.Biz
|
||||
|
||||
//Of type?
|
||||
if (searchParameters.TypeOnly != AyaType.NoType)
|
||||
q = q.Where(z => z.ObjectType == searchParameters.TypeOnly);
|
||||
q = q.Where(z => z.AType == searchParameters.TypeOnly);
|
||||
|
||||
|
||||
//Find the records that have the search terms in searchkey
|
||||
var SearchMatches = q.GroupBy(z => new { z.ObjectType, z.ObjectId }).Select(z => new { ObjectId = z.Key.ObjectId, ObjectType = z.Key.ObjectType, ObjectCount = z.LongCount() });
|
||||
var SearchMatches = q.GroupBy(z => new { z.AType, z.ObjectId }).Select(z => new { ObjectId = z.Key.ObjectId, AType = z.Key.AType, ObjectCount = z.LongCount() });
|
||||
|
||||
|
||||
//PUT THE RESULTS INTO MATCHING OBJECTS LIST
|
||||
@@ -164,7 +164,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
//keep any object that matches *all* the search terms
|
||||
if (SearchMatch.ObjectCount == TotalSearchTermsToMatch)
|
||||
MatchingObjects.Add(new AyaTypeId(SearchMatch.ObjectType, SearchMatch.ObjectId));
|
||||
MatchingObjects.Add(new AyaTypeId(SearchMatch.AType, SearchMatch.ObjectId));
|
||||
}
|
||||
|
||||
|
||||
@@ -173,19 +173,19 @@ namespace AyaNova.Biz
|
||||
List<AyaTypeId> CanReadMatchingObjects = new List<AyaTypeId>();
|
||||
foreach (AyaTypeId t in MatchingObjects)
|
||||
{
|
||||
if (t.ObjectType == AyaType.FileAttachment)
|
||||
if (t.AType == AyaType.FileAttachment)
|
||||
{
|
||||
//have to look up the actual underlying object type and id here
|
||||
//check if it's readable for user
|
||||
//then add the PARENT object type and id to the CanREadMatchingObjects list
|
||||
//this means user will not see it return as an attachment, just as the object
|
||||
FileAttachment f = await ct.FileAttachment.AsNoTracking().FirstOrDefaultAsync(z => z.Id == t.ObjectId);
|
||||
if (AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(currentUserRoles, f.AttachToObjectType))
|
||||
if (AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(currentUserRoles, f.AttachToAType))
|
||||
{
|
||||
CanReadMatchingObjects.Add(new AyaTypeId(f.AttachToObjectType, f.AttachToObjectId));
|
||||
CanReadMatchingObjects.Add(new AyaTypeId(f.AttachToAType, f.AttachToObjectId));
|
||||
}
|
||||
}
|
||||
else if (t.ObjectType == AyaType.Memo)
|
||||
else if (t.AType == AyaType.Memo)
|
||||
{
|
||||
//Users are only permitted to search their own memo's
|
||||
if (await ct.Memo.AsNoTracking().AnyAsync(z => z.Id == t.ObjectId && z.ToId == currentUserId))
|
||||
@@ -193,7 +193,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(currentUserRoles, t.ObjectType))
|
||||
if (AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(currentUserRoles, t.AType))
|
||||
{
|
||||
CanReadMatchingObjects.Add(t);
|
||||
}
|
||||
@@ -217,7 +217,7 @@ namespace AyaNova.Biz
|
||||
|
||||
//Sort and group the matching objects list in return order
|
||||
//zCzustomer.OrderBy(z => z.LastName).ThenBy(z => z.FirstName)
|
||||
var OrderedMatchingObjects = MatchingObjects.OrderBy(z => z.ObjectType).ThenByDescending(z => z.ObjectId);
|
||||
var OrderedMatchingObjects = MatchingObjects.OrderBy(z => z.AType).ThenByDescending(z => z.ObjectId);
|
||||
|
||||
|
||||
|
||||
@@ -233,11 +233,11 @@ namespace AyaNova.Biz
|
||||
foreach (AyaTypeId i in OrderedMatchingObjects)
|
||||
{
|
||||
SearchResult SR = new SearchResult();
|
||||
SR.Name = BizObjectNameFetcherDirect.Name(i.ObjectType,
|
||||
SR.Name = BizObjectNameFetcherDirect.Name(i.AType,
|
||||
i.ObjectId,
|
||||
command);
|
||||
SR.Id = i.ObjectId;
|
||||
SR.Type = i.ObjectType;
|
||||
SR.Type = i.AType;
|
||||
ReturnObject.SearchResults.Add(SR);
|
||||
}
|
||||
}
|
||||
@@ -581,16 +581,16 @@ namespace AyaNova.Biz
|
||||
{
|
||||
public long TranslationId { get; set; }
|
||||
public long ObjectId { get; set; }
|
||||
public AyaType ObjectType { get; set; }
|
||||
public AyaType AType { get; set; }
|
||||
public List<string> Words { get; set; }
|
||||
|
||||
|
||||
public SearchIndexProcessObjectParameters(long translationId, long objectID, AyaType objectType)
|
||||
public SearchIndexProcessObjectParameters(long translationId, long objectID, AyaType aType)
|
||||
{
|
||||
Words = new List<string>();
|
||||
TranslationId = translationId;
|
||||
ObjectId = objectID;
|
||||
ObjectType = objectType;
|
||||
AType = aType;
|
||||
}
|
||||
|
||||
//format used for getsummmary by biz objects
|
||||
@@ -599,7 +599,7 @@ namespace AyaNova.Biz
|
||||
Words = new List<string>();
|
||||
TranslationId = 0;
|
||||
ObjectId = 0;
|
||||
ObjectType = 0;
|
||||
AType = 0;
|
||||
}
|
||||
|
||||
public SearchIndexProcessObjectParameters AddText(string s)
|
||||
@@ -663,11 +663,11 @@ namespace AyaNova.Biz
|
||||
await ProcessKeywordsAsync(searchIndexObjectParameters, false);
|
||||
}
|
||||
|
||||
public static async Task ProcessDeletedObjectKeywordsAsync(long objectID, AyaType objectType, AyContext ct)
|
||||
public static async Task ProcessDeletedObjectKeywordsAsync(long objectID, AyaType aType, AyContext ct)
|
||||
{
|
||||
//Be careful in future, if you put ToString at the end of each object in the string interpolation
|
||||
//npgsql driver will assume it's a string and put quotes around it triggering an error that a string can't be compared to an int
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from asearchkey where objectid={objectID} and objecttype={(int)objectType}");
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from asearchkey where objectid={objectID} and aType={(int)aType}");
|
||||
//nothing to save here, it's a direct command already executed
|
||||
}
|
||||
|
||||
@@ -678,15 +678,15 @@ namespace AyaNova.Biz
|
||||
private static async Task ProcessKeywordsAsync(SearchIndexProcessObjectParameters p, bool newRecord)
|
||||
{
|
||||
// #if (DEBUG)
|
||||
// if (!p.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute)))
|
||||
// throw new System.NotSupportedException($"Search::ProcessKeywords - Invalid type presented {p.ObjectType}");
|
||||
// if (!p.AType.HasAttribute(typeof(CoreBizObjectAttribute)))
|
||||
// throw new System.NotSupportedException($"Search::ProcessKeywords - Invalid type presented {p.AType}");
|
||||
// #endif
|
||||
List<string> KeyWordList = await BreakAsync(p.TranslationId, p.Words);
|
||||
|
||||
if (KeyWordList.Count == 0) return;
|
||||
//call stored procedure to do the work right at the server (fastest method by far)
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"call aydosearchindex({KeyWordList},{p.ObjectId},{p.ObjectType},{!newRecord})");
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"call aydosearchindex({KeyWordList},{p.ObjectId},{p.AType},{!newRecord})");
|
||||
return;
|
||||
}//eoc
|
||||
#endregion
|
||||
|
||||
@@ -45,12 +45,12 @@ namespace AyaNova.Biz
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
//get the last record
|
||||
var LastEntry = await ct.ServiceBank.OrderByDescending(m => m.EntryDate).FirstOrDefaultAsync(m => m.ObjectId == newDtObject.ObjectId && m.ObjectType == newDtObject.ObjectType);
|
||||
var LastEntry = await ct.ServiceBank.OrderByDescending(m => m.EntryDate).FirstOrDefaultAsync(m => m.ObjectId == newDtObject.ObjectId && m.AType == newDtObject.AType);
|
||||
ServiceBank newObject = new ServiceBank();
|
||||
newObject.Name = newDtObject.Name;
|
||||
newObject.EntryDate = DateTime.UtcNow;
|
||||
newObject.ObjectId = newDtObject.ObjectId;
|
||||
newObject.ObjectType = newDtObject.ObjectType;
|
||||
newObject.AType = newDtObject.AType;
|
||||
newObject.SourceId = newDtObject.SourceId;
|
||||
newObject.SourceType = newDtObject.SourceType;
|
||||
newObject.Incidents = newDtObject.Incidents;
|
||||
@@ -126,10 +126,10 @@ namespace AyaNova.Biz
|
||||
// ////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// //GET LAST
|
||||
// //
|
||||
// internal async Task<ServiceBank> GetLastForObjectAsync(AyaType objectType, long objectId)
|
||||
// internal async Task<ServiceBank> GetLastForObjectAsync(AyaType aType, long objectId)
|
||||
// {
|
||||
|
||||
// var ret = await ct.ServiceBank.OrderByDescending(m => m.EntryDate).SingleOrDefaultAsync(m => m.ObjectId == objectId && m.ObjectType == objectType);
|
||||
// var ret = await ct.ServiceBank.OrderByDescending(m => m.EntryDate).SingleOrDefaultAsync(m => m.ObjectId == objectId && m.AType == aType);
|
||||
|
||||
// return ret;
|
||||
// }
|
||||
@@ -179,15 +179,15 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
//Object exists?
|
||||
if (!await BizObjectExistsInDatabase.ExistsAsync(proposedObj.ObjectType, proposedObj.ObjectId, ct))
|
||||
if (!await BizObjectExistsInDatabase.ExistsAsync(proposedObj.AType, proposedObj.ObjectId, ct))
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND, "generalerror", $"Bankable source object specified doesn't exist [type:{proposedObj.ObjectType}, id:{proposedObj.ObjectId}]");
|
||||
AddError(ApiErrorCode.NOT_FOUND, "generalerror", $"Bankable source object specified doesn't exist [type:{proposedObj.AType}, id:{proposedObj.ObjectId}]");
|
||||
return;
|
||||
}
|
||||
/*
|
||||
"CONSTRAINT UNQ_ServiceBank UNIQUE (entrydate, objectid, objecttype, incidentsbalance, hoursbalance, currencybalance), " +
|
||||
"CONSTRAINT UNQ_ServiceBank_Previous_values UNIQUE (lastentrydate, objectid, objecttype, lastincidentsbalance, lasthoursbalance, lastcurrencybalance), " +
|
||||
"CONSTRAINT fk_ServiceBank_self FOREIGN KEY (lastentrydate, objectid, objecttype, lastincidentsbalance, lasthoursbalance, lastcurrencybalance) references aservicebank(entrydate, objectid, objecttype, incidentsbalance, hoursbalance, currencybalance), " +
|
||||
"CONSTRAINT UNQ_ServiceBank UNIQUE (entrydate, objectid, aType, incidentsbalance, hoursbalance, currencybalance), " +
|
||||
"CONSTRAINT UNQ_ServiceBank_Previous_values UNIQUE (lastentrydate, objectid, aType, lastincidentsbalance, lasthoursbalance, lastcurrencybalance), " +
|
||||
"CONSTRAINT fk_ServiceBank_self FOREIGN KEY (lastentrydate, objectid, aType, lastincidentsbalance, lasthoursbalance, lastcurrencybalance) references aservicebank(entrydate, objectid, aType, incidentsbalance, hoursbalance, currencybalance), " +
|
||||
"CONSTRAINT CHK_Servicebank_Valid_IncidentBalance CHECK(incidentsbalance = COALESCE(lastincidentsbalance, 0) + incidents), " +
|
||||
"CONSTRAINT CHK_Servicebank_Valid_CurrencyBalance CHECK(currencybalance = COALESCE(lastcurrencybalance, 0) + currency), " +
|
||||
"CONSTRAINT CHK_Servicebank_Valid_HoursBalance CHECK(hoursbalance = COALESCE(lasthoursbalance, 0) + hours), " +
|
||||
@@ -323,7 +323,7 @@ namespace AyaNova.Biz
|
||||
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ServiceBankDepleted).ToListAsync();
|
||||
string SourceName = string.Empty;
|
||||
if (subs.Count > 0)
|
||||
SourceName = BizObjectNameFetcherDirect.Name(o.ObjectType, o.ObjectId, ct);
|
||||
SourceName = BizObjectNameFetcherDirect.Name(o.AType, o.ObjectId, ct);
|
||||
|
||||
foreach (var sub in subs)
|
||||
{
|
||||
@@ -343,7 +343,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
EventType = NotifyEventType.ServiceBankDepleted,
|
||||
UserId = sub.UserId,
|
||||
AyaType = o.ObjectType,
|
||||
AyaType = o.AType,
|
||||
ObjectId = o.ObjectId,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = SourceName
|
||||
|
||||
@@ -2575,7 +2575,7 @@ namespace AyaNova.Biz
|
||||
ICoreBizObjectModel o = null;
|
||||
//save a fetch if it's a delete
|
||||
if (job.SubType != JobSubType.Delete)
|
||||
o = await GetWorkOrderGraphItem(job.ObjectType, id);
|
||||
o = await GetWorkOrderGraphItem(job.AType, id);
|
||||
switch (job.SubType)
|
||||
{
|
||||
case JobSubType.TagAddAny:
|
||||
@@ -2587,7 +2587,7 @@ namespace AyaNova.Biz
|
||||
SaveIt = TagBiz.ProcessBatchTagOperation(o.Tags, (string)jobData["tag"], jobData.ContainsKey("toTag") ? (string)jobData["toTag"] : null, job.SubType);
|
||||
break;
|
||||
case JobSubType.Delete:
|
||||
if (!await DeleteWorkOrderGraphItem(job.ObjectType, id))
|
||||
if (!await DeleteWorkOrderGraphItem(job.AType, id))
|
||||
{
|
||||
await JobsBiz.LogJobAsync(job.GId, $"LT:Errors {GetErrorsAsString()} id {id}");
|
||||
FailedObjectCount++;
|
||||
@@ -2598,7 +2598,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
if (SaveIt)
|
||||
{
|
||||
o = await PutWorkOrderGraphItem(job.ObjectType, o);
|
||||
o = await PutWorkOrderGraphItem(job.AType, o);
|
||||
if (o == null)
|
||||
{
|
||||
await JobsBiz.LogJobAsync(job.GId, $"LT:Errors {GetErrorsAsString()} id {id}");
|
||||
|
||||
Reference in New Issue
Block a user