Esempio n. 1
0
        public IList <DsdRole> GetAllDsdRoles()
        {
            var list = new List <DsdRole>();

            foreach (DataRow row in this["DsdRole"].Rows)
            {
                var item = new DsdRole
                {
                    Id       = (Guid)row["Id"],
                    RoleId   = (Guid)row["RoleId"],
                    DsdSetId = (Guid)row["DsdSetId"],
                    Etag     = (byte[])row["Etag"]
                };
                var entity = item as IEntityBase;
                entity.CreateBy       = row["CreateBy"] == DBNull.Value ? null : row["CreateBy"].ToString();
                entity.CreateOn       = row["CreateOn"] == DBNull.Value ? null : (DateTime?)row["CreateOn"];
                entity.CreateUserId   = row["CreateUserId"] == DBNull.Value ? null : (Guid?)row["CreateUserId"];
                entity.ModifiedBy     = row["ModifiedBy"] == DBNull.Value ? null : row["ModifiedBy"].ToString();
                entity.ModifiedOn     = row["ModifiedOn"] == DBNull.Value ? null : (DateTime?)row["ModifiedOn"];
                entity.ModifiedUserId = row["ModifiedUserId"] == DBNull.Value ? null : (Guid?)row["ModifiedUserId"];

                list.Add(item);
            }
            return(list);
        }
        public IList <DsdRole> GetAllDsdRoles()
        {
            var list = new List <DsdRole>();

            foreach (DataRow row in this["DsdRole"].Rows)
            {
                var item = new DsdRole((Guid)row["Id"])
                {
                    RoleId   = (Guid)row["RoleId"],
                    DsdSetId = (Guid)row["DsdSetId"],
                    ETag     = (byte[])row["ETag"]
                };
                var entity = (IEntityBase)item;
                PopulateEntity(entity, row);

                list.Add(item);
            }
            return(list);
        }
Esempio n. 3
0
            private void Handle(IAcSession acSession, IDsdRoleCreateIo input, bool isCommand)
            {
                var acDomain          = _set._acDomain;
                var dsdRoleBySet      = _set._dsdRoleBySet;
                var dsdRoleById       = _set._dsdRoleById;
                var dsdRoleRepository = acDomain.RetrieveRequiredService <IRepository <DsdRole> >();

                if (!input.Id.HasValue)
                {
                    throw new ValidationException("标识是必须的");
                }
                if (dsdRoleById.Any(a => a.Key == input.Id.Value || (a.Value.RoleId == input.RoleId && a.Value.DsdSetId == input.DsdSetId)))
                {
                    throw new ValidationException("重复的记录");
                }
                DsdSetState dsdSet;

                if (!acDomain.DsdSetSet.TryGetDsdSet(input.DsdSetId, out dsdSet))
                {
                    throw new ValidationException("意外的动态责任分离角色集标识" + input.DsdSetId);
                }

                var entity = DsdRole.Create(input);

                lock (Locker)
                {
                    if (dsdRoleById.Any(a => a.Key == input.Id.Value || (a.Value.RoleId == input.RoleId && a.Value.DsdSetId == input.DsdSetId)))
                    {
                        throw new ValidationException("重复的记录");
                    }
                    if (!acDomain.DsdSetSet.TryGetDsdSet(input.DsdSetId, out dsdSet))
                    {
                        throw new ValidationException("意外的动态责任分离角色集标识" + input.DsdSetId);
                    }
                    var state = DsdRoleState.Create(entity);
                    if (!dsdRoleById.ContainsKey(entity.Id))
                    {
                        dsdRoleById.Add(entity.Id, state);
                    }
                    if (!dsdRoleBySet.ContainsKey(dsdSet))
                    {
                        dsdRoleBySet.Add(dsdSet, new List <DsdRoleState>());
                    }
                    dsdRoleBySet[dsdSet].Add(state);
                    if (isCommand)
                    {
                        try
                        {
                            dsdRoleRepository.Add(entity);
                            dsdRoleRepository.Context.Commit();
                        }
                        catch
                        {
                            if (dsdRoleById.ContainsKey(entity.Id))
                            {
                                dsdRoleById.Remove(entity.Id);
                            }
                            dsdRoleBySet[dsdSet].Remove(state);
                            dsdRoleRepository.Context.Rollback();
                            throw;
                        }
                    }
                }
                if (isCommand)
                {
                    acDomain.MessageDispatcher.DispatchMessage(new DsdRoleAddedEvent(acSession, entity, input, isPrivate: true));
                }
            }
        public IList<DsdRole> GetAllDsdRoles()
        {
            var list = new List<DsdRole>();
            foreach (DataRow row in this["DsdRole"].Rows)
            {
                var item = new DsdRole
                {
                    Id = (Guid)row["Id"],
                    RoleId = (Guid)row["RoleId"],
                    DsdSetId = (Guid)row["DsdSetId"],
                    Etag = (byte[])row["Etag"]
                };
                var entity = item as IEntityBase;
                entity.CreateBy = row["CreateBy"] == DBNull.Value ? null : row["CreateBy"].ToString();
                entity.CreateOn = row["CreateOn"] == DBNull.Value ? null : (DateTime?)row["CreateOn"];
                entity.CreateUserId = row["CreateUserId"] == DBNull.Value ? null : (Guid?)row["CreateUserId"];
                entity.ModifiedBy = row["ModifiedBy"] == DBNull.Value ? null : row["ModifiedBy"].ToString();
                entity.ModifiedOn = row["ModifiedOn"] == DBNull.Value ? null : (DateTime?)row["ModifiedOn"];
                entity.ModifiedUserId = row["ModifiedUserId"] == DBNull.Value ? null : (Guid?)row["ModifiedUserId"];

                list.Add(item);
            }
            return list;
        }