public IList <SsdSet> GetAllSsdSets() { var list = new List <SsdSet>(); foreach (DataRow row in this["SsdSet"].Rows) { var item = new SsdSet { Id = (Guid)row["Id"], Name = row["Name"] == DBNull.Value ? null : row["Name"].ToString(), Etag = (byte[])row["Etag"], IsEnabled = (int)row["IsEnabled"], SsdCard = (int)row["SsdCard"], Description = row["Description"] == DBNull.Value ? null : row["Description"].ToString() }; 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); }
private void Handle(IAcSession acSession, ISsdSetCreateIo input, bool isCommand) { var acDomain = _set._acDomain; var ssdSetDic = _set._ssdSetDic; var ssdSetRepository = acDomain.RetrieveRequiredService <IRepository <SsdSet, Guid> >(); if (!input.Id.HasValue) { throw new ValidationException("标识是必须的"); } if (acDomain.SsdSetSet.Any(a => a.Id == input.Id.Value)) { throw new GeneralException("重复的SsdSet标识" + input.Id); } if (acDomain.SsdSetSet.Any(a => a.Name.Equals(input.Name, StringComparison.OrdinalIgnoreCase))) { throw new ValidationException("重复的静态责任分离角色集名称"); } var entity = SsdSet.Create(input); lock (Locker) { SsdSetState ssdSet; if (acDomain.SsdSetSet.TryGetSsdSet(entity.Id, out ssdSet)) { throw new GeneralException("意外的重复标识"); } if (!ssdSetDic.ContainsKey(entity.Id)) { ssdSetDic.Add(entity.Id, SsdSetState.Create(entity)); } if (isCommand) { try { ssdSetRepository.Add(entity); ssdSetRepository.Context.Commit(); } catch { if (ssdSetDic.ContainsKey(entity.Id)) { ssdSetDic.Remove(entity.Id); } ssdSetRepository.Context.Rollback(); throw; } } } if (isCommand) { acDomain.MessageDispatcher.DispatchMessage(new SsdSetAddedEvent(acSession, entity, input, isPrivate: true)); } }
public IList <SsdSet> GetAllSsdSets() { var list = new List <SsdSet>(); foreach (DataRow row in this["SsdSet"].Rows) { var item = new SsdSet((Guid)row["Id"]) { Name = row["Name"] == DBNull.Value ? null : row["Name"].ToString(), ETag = (byte[])row["ETag"], IsEnabled = (int)row["IsEnabled"], SsdCard = (int)row["SsdCard"], Description = row["Description"] == DBNull.Value ? null : row["Description"].ToString() }; var entity = (IEntityBase)item; PopulateEntity(entity, row); list.Add(item); } return(list); }
public IList<SsdSet> GetAllSsdSets() { var list = new List<SsdSet>(); foreach (DataRow row in this["SsdSet"].Rows) { var item = new SsdSet { Id = (Guid)row["Id"], Name = row["Name"] == DBNull.Value ? null : row["Name"].ToString(), Etag = (byte[])row["Etag"], IsEnabled = (int)row["IsEnabled"], SsdCard = (int)row["SsdCard"], Description = row["Description"] == DBNull.Value ? null : row["Description"].ToString() }; 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; }