public static AccountAttributeEntity ConvertAttribute(string encryptKey, AccountAttribute attribute) { AccountAttributeEntity tmpAttributeEntity = null; if (attribute != null) { tmpAttributeEntity = new AccountAttributeEntity(); tmpAttributeEntity.AttributeId = attribute.AttributeId; tmpAttributeEntity.Order = attribute.Order; tmpAttributeEntity.Name = attribute.Name; tmpAttributeEntity.AccountId = attribute.AccountId; tmpAttributeEntity.Encrypted = attribute.Encrypted; if (!tmpAttributeEntity.Encrypted) { tmpAttributeEntity.Value = attribute.Value; } else { tmpAttributeEntity.Value = EncryptorHelper.DESEncrypt(encryptKey, attribute.Value); } } return(tmpAttributeEntity); }
public static AccountAttribute ConvertAttribute(string encryptKey, AccountAttributeEntity entity) { AccountAttribute tmpAttribute = null; if (entity != null) { tmpAttribute = new AccountAttribute(); tmpAttribute.AttributeId = entity.AttributeId; tmpAttribute.Order = entity.Order; tmpAttribute.Name = entity.Name; tmpAttribute.AccountId = entity.AccountId; tmpAttribute.Encrypted = entity.Encrypted; if (!tmpAttribute.Encrypted) { tmpAttribute.Value = entity.Value; } else { tmpAttribute.Value = EncryptorHelper.DESDecrypt(encryptKey, entity.Value); } } return(tmpAttribute); }
private IList <AccountAttributeEntity> ReadAttributeEntities(IDataReader dataReader) { if (dataReader == null) { return(null); } var tmpAttributeEntities = new List <AccountAttributeEntity>(); while (dataReader.Read()) { var tmpAttributeEntity = new AccountAttributeEntity(); string tmpColumnName; for (int index = 0; index < dataReader.FieldCount; index++) { if (dataReader.IsDBNull(index)) { continue; } tmpColumnName = dataReader.GetName(index); switch (tmpColumnName.ToLower()) { case "attrid": tmpAttributeEntity.AttributeId = dataReader.GetInt32(index); break; case "accountid": tmpAttributeEntity.AccountId = dataReader.GetInt32(index); break; case "orderno": tmpAttributeEntity.Order = dataReader.GetInt16(index); break; case "encrypted": tmpAttributeEntity.Encrypted = dataReader.GetBoolean(index); break; case "attrname": tmpAttributeEntity.Name = dataReader.GetString(index); break; case "attrvalue": tmpAttributeEntity.Value = dataReader.GetString(index); break; default: break; } } tmpAttributeEntities.Add(tmpAttributeEntity); } return(tmpAttributeEntities); }