Exemplo n.º 1
0
        public EntityPostRequest ToUpdateRequest()
        {
            EntityPostRequest request;

            if (this.IsPersisted())
            {
                request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Update)
                {
                    Entity = this
                };
                request.AppendConditionMap(this.ID, () => this.ID);
            }
            else
            {
                request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Create)
                {
                    Entity = this
                };
                request.AppendFieldMap(this.ID, () => this.ID);
            }
            request.AppendFieldMap(this.UserID, () => this.UserID);
            request.AppendFieldMap(this.BindID, () => this.BindID);
            request.AppendFieldMap(this.BindProvider, () => this.BindProvider);
            return(request);
        }
Exemplo n.º 2
0
        public EntityPostRequest ToDeleteRequest()
        {
            EntityPostRequest post = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Delete)
            {
                Entity = this
            };

            post.AppendConditionMap(this.ID, () => this.ID);
            return(post);
        }
Exemplo n.º 3
0
        static EntityPostRequest BuilddeleteRoleRequest(string roleid)
        {
            TeamRole          role    = new TeamRole(roleid, string.Empty);
            EntityPostRequest request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Delete)
            {
                Entity = role
            };

            request.AppendConditionMap(role.ID, () => role.ID);
            return(request);
        }
Exemplo n.º 4
0
        public void Save()
        {
            EntityPostRequest request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Update)
            {
                Entity = this.Entity
            };

            request.AppendConditionMap(this.Entity.TemplateKey, () => this.Entity.TemplateKey);
            request.AppendFieldMap(this.Entity.Expression, () => this.Entity.Expression);
            request.AppendFieldMap(this.Entity.Value, () => this.Entity.Value);
            Actor.Public.BuildEntityProcessor(ConfigTemplateSource.Name).UpdateEntity(request);
        }
Exemplo n.º 5
0
 static EntityPostRequest BuilddeleteDroitRequest(string resourceid)
 {
     DroitResource oldResource = new DroitResource(Guid.NewGuid().ToString())
     {
         ResourceName = resourceid
     };
     EntityPostRequest oldPostRequest = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Delete)
     {
         Entity = oldResource
     };
     oldPostRequest.AppendConditionMap(oldResource.ResourceName, () => oldResource.ResourceName);
     return oldPostRequest;
 }
Exemplo n.º 6
0
        static EntityPostRequest BuildaddDroitRequest(string ResourceName, DroitResource resource)
        {
            EntityPostRequest postRequest = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Create)
            {
                Entity = resource
            };

            postRequest.AppendFieldMap(resource.ResourceID, () => resource.ResourceID);
            postRequest.AppendFieldMap(resource.ResourceName, () => resource.ResourceName);
            postRequest.AppendFieldMap(resource.RoleID, () => resource.RoleID);
            postRequest.AppendFieldMap(resource.RightValue, () => resource.RightValue);
            postRequest.AppendFieldMap(resource.State, () => resource.State);
            return(postRequest);
        }
Exemplo n.º 7
0
        static EntityPostRequest BuilddeleteDroitRequest(string resourceid)
        {
            DroitResource oldResource = new DroitResource(Guid.NewGuid().ToString())
            {
                ResourceName = resourceid
            };
            EntityPostRequest oldPostRequest = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Delete)
            {
                Entity = oldResource
            };

            oldPostRequest.AppendConditionMap(oldResource.ResourceName, () => oldResource.ResourceName);
            return(oldPostRequest);
        }
Exemplo n.º 8
0
        static EntityPostRequest BuilddeleteUserRoleRequest(string roleid)
        {
            UserRoleMap ur = new UserRoleMap()
            {
                RoleID = roleid
            };

            EntityPostRequest request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Delete)
            {
                Entity = ur
            };

            request.AppendConditionMap(ur.RoleID, () => ur.RoleID);
            return(request);
        }
Exemplo n.º 9
0
        static EntityPostRequest BuilddeleteRoleDroitsRequest(string roleid)
        {
            DroitResource dr = new DroitResource(string.Empty)
            {
                RoleID = roleid
            };

            EntityPostRequest request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Delete)
            {
                Entity = dr
            };

            request.AppendConditionMap(dr.RoleID, () => dr.RoleID);
            return(request);
        }
Exemplo n.º 10
0
        static EntityPostRequest BuildaddRoleRequest(string userid, string roleid)
        {
            UserRoleMap role = new UserRoleMap()
            {
                RoleID = roleid,
                UserID = userid
            };
            EntityPostRequest request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Create)
            {
                Entity = role
            };

            request.AppendFieldMap(role.UserID, () => role.UserID);
            request.AppendFieldMap(role.RoleID, () => role.RoleID);
            return(request);
        }
Exemplo n.º 11
0
        static EntityPostRequest BuilddeleteRoleRequest(string userid, string roleid)
        {
            UserRoleMap role = new UserRoleMap()
            {
                RoleID = roleid,
                UserID = userid
            };
            EntityPostRequest request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Delete)
            {
                Entity = role
            };

            request.AppendConditionMap(role.UserID, () => role.UserID);
            request.AppendConditionMap(role.RoleID, () => role.RoleID);
            return(request);
        }
Exemplo n.º 12
0
 /// <summary>
 /// 创建新角色,不允许角色名重复
 /// </summary>
 /// <param name="Public"></param>
 /// <param name="RoleName"></param>
 /// <param name="RoleDescription"></param>
 /// <returns></returns>
 public static TeamRole CreateRole(this Public Public, string RoleName, string RoleDescription)
 {
     if (Actor.Public.GetRoleByName(RoleName).IsNotNullAndEmpty())
     {
         return default(TeamRole);
     }
     TeamRole factor = new TeamRole(Actor.Public .AsUserManager ().GenerateRoleID(), RoleName) { RoleDescription = RoleDescription };
     EntityPostRequest createquest = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Create)
     {
         Entity = factor
     };
     createquest.AppendFieldMap(factor.ID, () => factor.ID);
     createquest.AppendFieldMap(factor.Name, () => factor.Name);
     createquest.AppendFieldMap(factor.RoleDescription, () => factor.RoleDescription);
     Actor.Public.BuildEntityProcessor("SecurityApp").UpdateEntity(createquest);
     return factor;
 }
Exemplo n.º 13
0
 static EntityPostRequest BuilderUserStateRequest(BzureUser user)
 {
     if (user.IsPersisted())
     {
         EntityPostRequest userStateRequest = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Update)
         {
             Entity = user
         };
         userStateRequest.AppendFieldMap(user.State, () => user.State);
         userStateRequest.AppendConditionMap(user.UserID, () => user.UserID);
         return(userStateRequest);
     }
     else
     {
         throw new Exception(string.Format("用户{0}还没有保存", user.UserName));
     }
 }
Exemplo n.º 14
0
        static void RegisterFactor_DeleteDroits(BizTransaction transaction, string RoleID)
        {
            IEntityRequestProcess deleteRoleDroitsProcessor = Actor.Public.BuildEntityProcessor("SecurityApp");
            TransactionFactor <IEntityRequestProcess, Action <IEntityRequestProcess, EntityPostRequest> > deleteRoleDroitsFactor = new TransactionFactor <IEntityRequestProcess, Action <IEntityRequestProcess, EntityPostRequest> >(deleteRoleDroitsProcessor);

            deleteRoleDroitsFactor.ActionBody = (IEntityRequestProcess contract, EntityPostRequest request) =>
            {
                contract.UpdateEntity(request);
            };

            deleteRoleDroitsFactor.Action = (Action <IEntityRequestProcess, EntityPostRequest> action) =>
            {
                EntityPostRequest deleteRoleDroitRequest = BuilddeleteRoleDroitsRequest(RoleID);
                action(deleteRoleDroitsProcessor, deleteRoleDroitRequest);
            };

            transaction.RegisterFactor(deleteRoleDroitsFactor);
        }
Exemplo n.º 15
0
        static void RegisterFactor_UserState(BizTransaction transaction, BzureUser user)
        {
            IEntityRequestProcess userStateProcessor = Actor.Public.BuildEntityProcessor("SecurityApp");
            TransactionFactor <IEntityRequestProcess, Action <IEntityRequestProcess, EntityPostRequest> > userStateFactor = new TransactionFactor <IEntityRequestProcess, Action <IEntityRequestProcess, EntityPostRequest> >(userStateProcessor);

            userStateFactor.ActionBody = (IEntityRequestProcess contract, EntityPostRequest request) =>
            {
                contract.UpdateEntity(request);
            };

            userStateFactor.Action = (Action <IEntityRequestProcess, EntityPostRequest> action) =>
            {
                EntityPostRequest OrderRequest = BuilderUserStateRequest(user);
                action(userStateProcessor, OrderRequest);
            };

            transaction.RegisterFactor(userStateFactor);
        }
Exemplo n.º 16
0
        static EntityPostRequest BuilderUserStateRequest(BzureUser user)
        {
            if (user.IsPersisted())
            {
                EntityPostRequest userStateRequest = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Update)
                {
                    Entity = user
                };
                userStateRequest.AppendFieldMap(user.State, () => user.State);
                userStateRequest.AppendConditionMap(user.UserID, () => user.UserID);
                return userStateRequest;
            }
            else
            {
                throw new Exception(string.Format("用户{0}还没有保存", user.UserName));
            }

        }
Exemplo n.º 17
0
        static void RegisterFactor_DeleteRoles(BizTransaction transaction, BzureUser user, string[] oldRoles)
        {
            IEntityRequestProcess deleteRolesProcessor = Actor.Public.BuildEntityProcessor("SecurityApp");
            TransactionFactor <IEntityRequestProcess, Action <IEntityRequestProcess, EntityPostRequest> > deleteRolesFactor = new TransactionFactor <IEntityRequestProcess, Action <IEntityRequestProcess, EntityPostRequest> >(deleteRolesProcessor);

            deleteRolesFactor.ActionBody = (IEntityRequestProcess contract, EntityPostRequest request) =>
            {
                contract.UpdateEntity(request);
            };

            deleteRolesFactor.Action = (Action <IEntityRequestProcess, EntityPostRequest> action) =>
            {
                foreach (string roleid in oldRoles)
                {
                    EntityPostRequest deleteRoleRequest = BuilddeleteRoleRequest(user.UserID.ToString(), roleid);
                    action(deleteRolesProcessor, deleteRoleRequest);
                }
            };

            transaction.RegisterFactor(deleteRolesFactor);
        }
Exemplo n.º 18
0
        static void RegisterFactor_AddNewDroits(BizTransaction transaction, string ResourceName, DroitResource[] droits)
        {
            IEntityRequestProcess addDroitsProcessor = Actor.Public.BuildEntityProcessor("SecurityApp");
            TransactionFactor <IEntityRequestProcess, Action <IEntityRequestProcess, EntityPostRequest> > addDroitsFactor = new TransactionFactor <IEntityRequestProcess, Action <IEntityRequestProcess, EntityPostRequest> >(addDroitsProcessor);

            addDroitsFactor.ActionBody = (IEntityRequestProcess contract, EntityPostRequest request) =>
            {
                contract.UpdateEntity(request);
            };

            addDroitsFactor.Action = (Action <IEntityRequestProcess, EntityPostRequest> action) =>
            {
                foreach (DroitResource droit in droits)
                {
                    EntityPostRequest addDroitRequest = BuildaddDroitRequest(ResourceName, droit);
                    action(addDroitsProcessor, addDroitRequest);
                }
            };

            transaction.RegisterFactor(addDroitsFactor);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 创建新角色,不允许角色名重复
        /// </summary>
        /// <param name="Public"></param>
        /// <param name="RoleName"></param>
        /// <param name="RoleDescription"></param>
        /// <returns></returns>
        public static TeamRole CreateRole(this Public Public, string RoleName, string RoleDescription)
        {
            if (Actor.Public.GetRoleByName(RoleName).IsNotNullAndEmpty())
            {
                return(default(TeamRole));
            }
            TeamRole factor = new TeamRole(Actor.Public.AsUserManager().GenerateRoleID(), RoleName)
            {
                RoleDescription = RoleDescription
            };
            EntityPostRequest createquest = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Create)
            {
                Entity = factor
            };

            createquest.AppendFieldMap(factor.ID, () => factor.ID);
            createquest.AppendFieldMap(factor.Name, () => factor.Name);
            createquest.AppendFieldMap(factor.RoleDescription, () => factor.RoleDescription);
            Actor.Public.BuildEntityProcessor("SecurityApp").UpdateEntity(createquest);
            return(factor);
        }
Exemplo n.º 20
0
 public EntityPostRequest ToUpdateRequest()
 {
     EntityPostRequest request;
     if (this.IsPersisted())
     {
         request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Update)
         {
             Entity = this
         };
         request.AppendConditionMap(this.ID, () => this.ID);
     }
     else
     {
         request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Create)
         {
             Entity = this
         };
         request.AppendFieldMap(this.ID, () => this.ID);
     }
     request.AppendFieldMap(this.UserID, () => this.UserID);
     request.AppendFieldMap(this.BindID, () => this.BindID);
     request.AppendFieldMap(this.BindProvider, () => this.BindProvider);
     return request;
 }
Exemplo n.º 21
0
        static EntityPostRequest BuilddeleteUserRoleRequest(string roleid)
        {
            UserRoleMap ur = new UserRoleMap()
            {
                RoleID = roleid
            };

            EntityPostRequest request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Delete)
            {
                Entity = ur
            };
            request.AppendConditionMap(ur.RoleID, () => ur.RoleID);
            return request;
        }
Exemplo n.º 22
0
        static EntityPostRequest BuilddeleteRoleDroitsRequest(string roleid)
        {
            DroitResource dr = new DroitResource(string.Empty)
            {
                RoleID = roleid
            };

            EntityPostRequest request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Delete)
            {
                Entity = dr
            };
            request.AppendConditionMap(dr.RoleID, () => dr.RoleID);
            return request;
        }
Exemplo n.º 23
0
 static EntityPostRequest BuildaddRoleRequest(string userid, string roleid)
 {
     UserRoleMap role = new UserRoleMap()
     {
         RoleID = roleid,
         UserID = userid
     };
     EntityPostRequest request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Create)
     {
         Entity = role
     };
     request.AppendFieldMap(role.UserID, () => role.UserID);
     request.AppendFieldMap(role.RoleID, () => role.RoleID);
     return request;
 }
Exemplo n.º 24
0
 static EntityPostRequest BuilddeleteRoleRequest(string userid, string roleid)
 {
     UserRoleMap role = new UserRoleMap()
     {
         RoleID = roleid,
         UserID = userid
     };
     EntityPostRequest request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Delete)
     {
         Entity = role
     };
     request.AppendConditionMap(role.UserID, () => role.UserID);
     request.AppendConditionMap(role.RoleID, () => role.RoleID);
     return request;
 }
Exemplo n.º 25
0
 public void Save()
 {
     EntityPostRequest request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Update)
     {
         Entity = this.Entity
     };
     request.AppendConditionMap(this.Entity.TemplateKey, () => this.Entity.TemplateKey);
     request.AppendFieldMap(this.Entity.Expression, () => this.Entity.Expression);
     request.AppendFieldMap(this.Entity.Value, () => this.Entity.Value);
     Actor.Public.BuildEntityProcessor(ConfigTemplateSource.Name).UpdateEntity(request);
 }
Exemplo n.º 26
0
 static EntityPostRequest BuilddeleteRoleRequest(string roleid)
 {
     TeamRole role = new TeamRole(roleid, string.Empty);
     EntityPostRequest request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Delete)
     {
         Entity = role
     };
     request.AppendConditionMap(role.ID, () => role.ID);
     return request;
 }
Exemplo n.º 27
0
 static EntityPostRequest BuildaddDroitRequest(string ResourceName, DroitResource resource)
 {
     EntityPostRequest postRequest = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Create)
     {
         Entity = resource
     };
     postRequest.AppendFieldMap(resource.ResourceID, () => resource.ResourceID);
     postRequest.AppendFieldMap(resource.ResourceName, () => resource.ResourceName);
     postRequest.AppendFieldMap(resource.RoleID, () => resource.RoleID);
     postRequest.AppendFieldMap(resource.RightValue, () => resource.RightValue);
     postRequest.AppendFieldMap(resource.State, () => resource.State);
     return postRequest;
 }
Exemplo n.º 28
0
 public EntityPostRequest ToDeleteRequest()
 {
     EntityPostRequest post = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Delete)
     {
         Entity = this
     };
     post.AppendConditionMap(this.ID, () => this.ID);
     return post;
 }