当前位置: 首页>>代码示例>>C#>>正文


C# Services.IsEntity方法代码示例

本文整理汇总了C#中Services.IsEntity方法的典型用法代码示例。如果您正苦于以下问题:C# Services.IsEntity方法的具体用法?C# Services.IsEntity怎么用?C# Services.IsEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Services的用法示例。


在下文中一共展示了Services.IsEntity方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Before

        public void Before(Services.tmp.EntityOperation operation, EntityOperationContext context)
        {
            if (operation.IsEntity(Payment.ENTITY) && operation is EntityUpdate)
            {
                var update = operation as EntityUpdate;
                if (update.IsCreate())
                {
                    List<int> usersToAttach = new List<int>();
                    foreach (var attach in update.RelationUpdates.Where(ru => ru.Operation == Services.tmp.RelationOperation.Attach))
                    {
                        var em = _domainService.Domain.Entities[attach.Entity];
                        var customerRel = em.Relations[em.Name, User.ENTITY, Payment.ROLE_CUSTOMER];
                        if (customerRel != null && customerRel.TypeFor(User.ENTITY) == RelationType.OneToMany)
                        {
                            var q = new EntityQuery2(User.ENTITY);
                            q.WhereRelated(new RelationQuery(em.Name, customerRel.Role, attach.Id.Value));
                            var cust = _repository.Read(q);
                            if (cust != null)
                                usersToAttach.Add(cust.Id);
                        }
                    }

                    foreach (var id in usersToAttach)
                    {
                        update.Attach(User.ENTITY, Payment.ROLE_CUSTOMER, id);
                    }
                }
            }
        }
开发者ID:kvuchkov,项目名称:nbulib,代码行数:29,代码来源:FinanceModule.cs

示例2: Before

        public void Before(Services.tmp.EntityOperation operation, EntityOperationContext context)
        {
            if (operation.IsEntity(NbuLibrary.Core.Domain.File.ENTITY) && operation is EntityUpdate)
            {
                var update = operation as EntityUpdate;
                if (update.IsCreate())
                {
                    var access = update.Attach(NbuLibrary.Core.Domain.User.ENTITY, Roles.Access, _securityService.CurrentUser.Id);
                    access.Set("Type", FileAccessType.Owner);
                }
                else
                {
                    var accessUpdates = update.GetMultipleRelationUpdates(User.ENTITY, Roles.Access);
                    if (accessUpdates != null)
                        foreach (var ac in accessUpdates)
                        {
                            if (ac.Operation == RelationOperation.Detach)
                                continue;

                            if (ac.ContainsProperty("Type") && ac.Get<FileAccessType>("Type") == FileAccessType.Token)
                                ac.Set("Token", Guid.NewGuid());//TODO: token based file access
                        }
                }
            }
            else if (operation.IsEntity(NbuLibrary.Core.Domain.File.ENTITY) && operation is EntityDelete)
            {
                var file = _fileService.GetFile(operation.Id.Value);
                context.Set<NbuLibrary.Core.Domain.File>(CTXKEY_FILEDELETION, file);
            }
        }
开发者ID:kvuchkov,项目名称:nbulib,代码行数:30,代码来源:FilesModule.cs

示例3: Inspect

        public InspectionResult Inspect(Services.tmp.EntityOperation operation)
        {
            if (operation.IsEntity(Payment.ENTITY) && operation is EntityUpdate)
            {
                var update = operation as EntityUpdate;
                if (update.IsCreate() && !update.ContainsProperty("Status"))
                    return InspectionResult.Allow; //TODO-Finance: Everyone is allowed to create payments
                else if (_securityService.HasModulePermission(_securityService.CurrentUser, FinanceModule.Id, Permissions.Approve))
                    return InspectionResult.Allow;

            }
            return InspectionResult.None;
        }
开发者ID:kvuchkov,项目名称:nbulib,代码行数:13,代码来源:FinanceModule.cs

示例4: After

 public void After(Services.tmp.EntityOperation operation, EntityOperationContext context, EntityOperationResult result)
 {
     if (operation.IsEntity(NbuLibrary.Core.Domain.File.ENTITY)
         && operation is EntityDelete
         && result.Success)
     {
         var file = context.Get<NbuLibrary.Core.Domain.File>(CTXKEY_FILEDELETION);
         if (file != null)
             _fileService.DeleteFileContent(Guid.Parse(file.ContentPath));
     }
 }
开发者ID:kvuchkov,项目名称:nbulib,代码行数:11,代码来源:FilesModule.cs


注:本文中的Services.IsEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。