本文整理汇总了C#中Core.IsEntity方法的典型用法代码示例。如果您正苦于以下问题:C# Core.IsEntity方法的具体用法?C# Core.IsEntity怎么用?C# Core.IsEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core
的用法示例。
在下文中一共展示了Core.IsEntity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Inspect
public InspectionResult Inspect(Core.Services.tmp.EntityOperation operation)
{
if ((operation.IsEntity(EntityConsts.BibliographicQuery)
|| operation.IsEntity(EntityConsts.Bibliography))
&& _securityService.HasModulePermission(_securityService.CurrentUser, BiblRefModule.Id, Permissions.Use))
{
if (_securityService.CurrentUser.UserType == UserTypes.Librarian)
return InspectionResult.Allow;
else if (operation is EntityUpdate)
{
var update = operation as EntityUpdate;
if (update.IsCreate())
return InspectionResult.Allow;
else if (update.IsEntity(EntityConsts.BibliographicQuery))
{
var q = new EntityQuery2(User.ENTITY, _securityService.CurrentUser.Id);
q.WhereRelated(new RelationQuery(EntityConsts.BibliographicQuery, Roles.Customer, update.Id.Value));
if (_repository.Read(q) != null)
return InspectionResult.Allow;
}
else if(update.IsEntity(EntityConsts.Bibliography))
{
var q = new EntityQuery2(EntityConsts.BibliographicQuery);
q.WhereIs("ForNew", true);
q.WhereRelated(new RelationQuery(EntityConsts.Bibliography, Roles.Query, update.Id.Value));
q.WhereRelated(new RelationQuery(User.ENTITY, Roles.Customer, _securityService.CurrentUser.Id));
q.Include(EntityConsts.Bibliography, Roles.Query);
if (_repository.Read(q) != null)
return InspectionResult.Allow;
}
}
}
return InspectionResult.None;
}
示例2: Before
public void Before(Core.Services.tmp.EntityOperation operation, EntityOperationContext context)
{
if (operation.IsEntity(EntityConsts.BibliographicListQuery))
{
if (operation is EntityUpdate)
{
var update = operation as EntityUpdate;
if (update.IsCreate() && _securityService.CurrentUser.UserType == UserTypes.Customer)
update.Attach(User.ENTITY, Roles.Customer, _securityService.CurrentUser.Id);
else if (_securityService.CurrentUser.UserType == UserTypes.Librarian)
{
bool attach = false;
int? fileId = null;
if (update.IsCreate())
attach = true;
else
{
var q = new EntityQuery2(EntityConsts.BibliographicListQuery, update.Id.Value);
q.Include(User.ENTITY, Roles.ProcessedBy);
q.Include(File.ENTITY, Roles.File);
var e = _repository.Read(q);
var user = e.GetSingleRelation(User.ENTITY, Roles.ProcessedBy);
if (user == null)
attach = true;
else if (user.Entity.Id != _securityService.CurrentUser.Id)
{
update.Detach(User.ENTITY, Roles.ProcessedBy, user.Id);
attach = true;
}
var file = e.GetSingleRelation(File.ENTITY, Roles.File);
if (file != null)
fileId = file.Entity.Id;
}
if (attach)
{
update.Attach(User.ENTITY, Roles.ProcessedBy, _securityService.CurrentUser.Id);
if (fileId.HasValue)
{
var librarian = _securityService.CurrentUser;
using (_securityService.BeginSystemContext())
{
_fileService.GrantAccess(fileId.Value, FileAccessType.Full, librarian);
}
}
}
}
}
}
}
示例3: Before
public void Before(Core.Services.tmp.EntityOperation operation, EntityOperationContext context)
{
if (operation.IsEntity(EntityConsts.BibliographicQuery))
{
if (operation is EntityUpdate)
{
var update = operation as EntityUpdate;
if (update.IsCreate() && _securityService.CurrentUser.UserType == UserTypes.Customer)
update.Attach(User.ENTITY, Roles.Customer, _securityService.CurrentUser.Id);
else if (_securityService.CurrentUser.UserType == UserTypes.Librarian)
{
bool attach = false;
if (update.IsCreate())
attach = true;
else
{
var q = new EntityQuery2(User.ENTITY);
q.WhereRelated(new RelationQuery(EntityConsts.BibliographicQuery, Roles.ProcessedBy, update.Id.Value));
var user = _repository.Read(q);
if (user == null)
attach = true;
else if (user.Id != _securityService.CurrentUser.Id)
{
update.Detach(User.ENTITY, Roles.ProcessedBy, user.Id);
attach = true;
}
}
if (attach)
update.Attach(User.ENTITY, Roles.ProcessedBy, _securityService.CurrentUser.Id);
}
}
}
}
示例4: After
public void After(Core.Services.tmp.EntityOperation operation, EntityOperationContext context, EntityOperationResult result)
{
if (!result.Success)
return;
var update = operation as EntityUpdate;
if (operation.IsEntity(EntityConsts.BibliographicListQuery) && update != null && update.ContainsProperty("Status") && update.Get<QueryStatus>("Status") == QueryStatus.Completed)
{
var q = new EntityQuery2(EntityConsts.BibliographicListQuery, update.Id.Value) { AllProperties = true };
q.Include(User.ENTITY, Roles.Customer);
var biblListQuery = _repository.Read(q);
var user = new User(biblListQuery.GetSingleRelation(User.ENTITY, Roles.Customer).Entity);
var template = _templateService.Get(new Guid(NotificationTemplates.QUERY_COMPLETED));
string subject = null, body = null;
Dictionary<string, Entity> templateContext = new Dictionary<string, Entity>(StringComparer.InvariantCultureIgnoreCase);
templateContext.Add("Customer", user);
templateContext.Add("Query", biblListQuery);
_templateService.Render(template, templateContext, out subject, out body);
var withEmail = biblListQuery.GetData<ReplyMethods>("ReplyMethod") == ReplyMethods.ByEmail;
_notificationService.SendNotification(withEmail, new User[] { user }, subject, body, null, new Relation[] { new Relation(Notification.ROLE, biblListQuery) });
}
else if (operation.IsEntity(Payment.ENTITY) && update != null && update.ContainsProperty("Status") && update.Get<PaymentStatus>("Status") == PaymentStatus.Paid)
{
var q = new EntityQuery2(EntityConsts.BibliographicListQuery);
q.AddProperties("Number");
q.WhereRelated(new RelationQuery(Payment.ENTITY, Roles.Payment, update.Id.Value));
q.Include(User.ENTITY, Roles.Customer);
q.Include(File.ENTITY, Roles.File);
var biblListQuery = _repository.Read(q);
if (biblListQuery != null)
{
var file = new File(biblListQuery.GetSingleRelation(File.ENTITY, Roles.File).Entity);
var user = new User(biblListQuery.GetSingleRelation(User.ENTITY, Roles.Customer).Entity);
var template = _templateService.Get(new Guid(NotificationTemplates.PAYMENT_COMPLETED));
string subject = null, body = null;
Dictionary<string, Entity> templateContext = new Dictionary<string, Entity>(StringComparer.InvariantCultureIgnoreCase);
templateContext.Add("Customer", user);
templateContext.Add("Query", biblListQuery);
_templateService.Render(template, templateContext, out subject, out body);
var withEmail = biblListQuery.GetData<ReplyMethods>("ReplyMethod") == ReplyMethods.ByEmail;
_notificationService.SendNotification(withEmail, new User[] { user }, subject, body, new File[] { file }, new Relation[] { new Relation(Notification.ROLE, biblListQuery) });
//_fileService.GrantAccess(file.Id, FileAccessType.Read, new User(biblQuery.GetSingleRelation(User.ENTITY, Roles.Customer).Entity));
}
}
}
示例5: Inspect
public InspectionResult Inspect(Core.Services.tmp.EntityOperation operation)
{
if (operation.IsEntity(EntityConsts.AnalysisQuery)
&& _securityService.HasModulePermission(_securityService.CurrentUser, RefAnalysisModule.Id, Permissions.Use))
{
if (_securityService.CurrentUser.UserType == UserTypes.Librarian)
return InspectionResult.Allow;
else if (operation is EntityUpdate)
{
var update = operation as EntityUpdate;
if (update.IsCreate())
return InspectionResult.Allow;
else if (update.IsEntity(EntityConsts.AnalysisQuery))
{
var q = new EntityQuery2(User.ENTITY, _securityService.CurrentUser.Id);
q.WhereRelated(new RelationQuery(EntityConsts.AnalysisQuery, Roles.Customer, update.Id.Value));
if (_repository.Read(q) != null)
return InspectionResult.Allow;
}
}
}
return InspectionResult.None;
}