Exemple #1
0
        public bool AddRole(RoleInfo model, ref ValidationErrors errors)
        {
            try
            {
                ChannelRole entity = ChannelRoleRepository.GetRoleById(model.RoleId);
                if (entity != null)
                {
                    errors.Add(Suggestion.PrimaryRepeat);
                    return(false);
                }
                entity = new ChannelRole
                {
                    RoleId       = model.RoleId,
                    Name         = model.Name,
                    Description  = model.Description,
                    CreateTime   = model.CreateTime,
                    CreatePerson = model.CreatePerson
                };

                if (ChannelRoleRepository.AddRole(entity) == 1)
                {
                    // 分配给角色 存储过程
                    // 清理无用项 存储过程
                    return(true);
                }

                errors.Add(Suggestion.InsertFail);
                return(false);
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                return(false);
            }
        }
Exemple #2
0
        public bool EditRole(RoleInfo model, ref ValidationErrors errors)
        {
            try
            {
                ChannelRole entity = ChannelRoleRepository.GetRoleById(model.RoleId);
                if (entity == null)
                {
                    errors.Add(Suggestion.Disable);
                    return(false);
                }
                entity.RoleId       = model.RoleId;
                entity.Name         = model.Name;
                entity.Description  = model.Description;
                entity.CreateTime   = model.CreateTime;
                entity.CreatePerson = model.CreatePerson;

                if (ChannelRoleRepository.EditRole(entity) == 1)
                {
                    return(true);
                }

                errors.Add(Suggestion.EditFail);
                return(false);
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                return(false);
            }
        }
Exemple #3
0
        public Channel CreateNewChannel(ChannelRole role)
        {
            var channel = this.channelFixture.CreateChannel(role);

            this.channelFixture.ChannelsToDelete.Add(channel);
            return(channel);
        }
        public int AddRole(ChannelRole entity)
        {
            using (var db = new NationalUnionContext())
            {
                db.ChannelRoles.Add(entity);

                return(db.SaveChanges());
            }
        }
        public int EditRole(ChannelRole entity)
        {
            using (var db = new NationalUnionContext())
            {
                db.ChannelRoles.Attach(entity);
                db.Entry(entity).State = EntityState.Modified;

                return(db.SaveChanges());
            }
        }
Exemple #6
0
        public ChannelDraft GetChannelDraft(ChannelRole role)
        {
            ChannelDraft channelDraft = new ChannelDraft
            {
                Key   = TestingUtility.RandomString(10),
                Roles = new List <ChannelRole> {
                    role
                }
            };

            return(channelDraft);
        }
Exemple #7
0
        public RoleInfo GetRoleById(string roleId)
        {
            if (RoleExistsById(roleId))
            {
                ChannelRole entity = ChannelRoleRepository.GetRoleById(roleId);
                var         model  = new RoleInfo
                {
                    RoleId       = entity.RoleId,
                    Name         = entity.Name,
                    Description  = entity.Description,
                    CreateTime   = entity.CreateTime,
                    CreatePerson = entity.CreatePerson
                };

                return(model);
            }

            return(null);
        }
Exemple #8
0
 public async Task SetChannelRole(ChannelRole role, IChannel channel)
 {
     Context.server.GetMemory().GetData <ChannelSystem, ChannelServerData>().channelByRole[role] = channel.Id;
 }
Exemple #9
0
        public const int MaxPacketSize = (1024 * 1024) * 10; // 10 mb
        //------------------------------------------------------------------------------------------------------------------------
        #endregion


        #region Constructors
        //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        public CommonSocketChannel(Protocol[] Protocols, ChannelRole ChannelRole, ChannelSerializationMode SupportedChannelSerializationModes, ChannelSerializationMode PreferredChannelSerializationModes)
            : base(Protocols, ChannelRole, SupportedChannelSerializationModes, PreferredChannelSerializationModes, true)
        {
        }
 public bool TryGetChannelByRole(ChannelRole role, out SocketTextChannel channel) => (channel = GetChannelByRole(role)) != null;
 public SocketTextChannel GetChannelByRole(ChannelRole role) => channelByRole.TryGetValue(role, out ulong id) ? MopBot.client.GetChannel(id) as SocketTextChannel : null;
Exemple #12
0
 public Channel CreateChannel(ChannelRole role = ChannelRole.Primary)
 {
     return(this.CreateChannel(this.GetChannelDraft(role)));
 }
Exemple #13
0
        public const int MaxPacketSize = (1024 * 1024) * 10; // 10 mb
        //------------------------------------------------------------------------------------------------------------------------
        #endregion


        #region Constructors
        //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        public CommonSocketChannel(Protocol[] Protocols, ChannelRole ChannelRole, ChannelSerializationMode SupportedChannelSerializationModes, ChannelSerializationMode PreferredChannelSerializationModes, TimeSpan?keepAliveSpinDelay = null)
            : base(Protocols, ChannelRole, SupportedChannelSerializationModes, PreferredChannelSerializationModes, true, keepAliveSpinDelay)
        {
        }
Exemple #14
0
        public const int MaxPacketSize = (1024 * 1024) * 10; // 10 mb
        //------------------------------------------------------------------------------------------------------------------------
        #endregion


        #region Constructors
        //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        public CommonSocketChannel(Protocol[] Protocols, ChannelRole ChannelRole, ChannelSerializationMode SupportedChannelSerializationModes, ChannelSerializationMode PreferredChannelSerializationModes)
            : base(Protocols, ChannelRole, SupportedChannelSerializationModes, PreferredChannelSerializationModes, true)
        {
        }