/// <summary> /// Create an array of PropertyBlocks from an array of Property /// instances, creating empty Property instances to make up any /// shortfall /// </summary> /// <param name="properties">the Property instances to be converted into PropertyBlocks, in a java List</param> /// <returns>the array of newly created PropertyBlock instances</returns> public static BlockWritable [] CreatePropertyBlockArray( IList properties) { int block_count = (properties.Count + _properties_per_block - 1) / _properties_per_block; Property[] to_be_written = new Property[block_count * _properties_per_block]; Property[] array = new Property[properties.Count]; properties.CopyTo(array, 0); System.Array.Copy(array, 0, to_be_written, 0, properties.Count); for (int j = properties.Count; j < to_be_written.Length; j++) { // create an instance of an anonymous inner class that // extends Property to_be_written[j] = new AnonymousProperty(); } BlockWritable[] rvalue = new BlockWritable[block_count]; for (int j = 0; j < block_count; j++) { rvalue[j] = new PropertyBlock(to_be_written, j * _properties_per_block); } return(rvalue); }
/// <summary> /// Create an array of PropertyBlocks from an array of Property /// instances, creating empty Property instances to make up any /// shortfall /// </summary> /// <param name="bigBlockSize"></param> /// <param name="properties">the Property instances to be converted into PropertyBlocks, in a java List</param> /// <returns>the array of newly created PropertyBlock instances</returns> public static BlockWritable[] CreatePropertyBlockArray(POIFSBigBlockSize bigBlockSize, List <Property> properties) { int _properties_per_block = bigBlockSize.GetPropertiesPerBlock(); int blockCount = (properties.Count + _properties_per_block - 1) / _properties_per_block; Property[] toBeWritten = new Property[blockCount * _properties_per_block]; System.Array.Copy(properties.ToArray(), 0, toBeWritten, 0, properties.Count); for (int i = properties.Count; i < toBeWritten.Length; i++) { toBeWritten[i] = new AnonymousProperty(); } BlockWritable[] rvalue = new BlockWritable[blockCount]; for (int i = 0; i < blockCount; i++) { rvalue[i] = new PropertyBlock(bigBlockSize, toBeWritten, i * _properties_per_block); } return(rvalue); }
public override List <AnonymousProperty> getAnonymousProperties(List <int> propertyIds) { List <AnonymousProperty> result = new List <AnonymousProperty>(); ///include property type & all children foreach (Property property in emdb.Properties.Include(p => p.PropertyType).Include(p => p.PropertyType.Walls) .Include(p => p.PropertyType.Heating) .Include(p => p.PropertyType.Building)) { AnonymousProperty anonProperty = new AnonymousProperty { Id = property.Id, Postcode = property.Postcode, AnnualCost = property.AnnualCost, AnnualkWh = property.AnnualkWh, AreaNormalisedAnnualkWh = property.AreaNormalisedAnnualkWh, FloorArea = property.FloorArea, NumbBedrooms = property.NumbBedrooms }; anonProperty.isUsers = propertyIds.Contains(property.Id); anonProperty.Walls = property.PropertyType.Walls.Description; anonProperty.Buiding = property.PropertyType.Building.Description; anonProperty.Heating = property.PropertyType.Heating.Description; result.Add(anonProperty); } return(result); }
/// <summary> /// Returns a list of anonymous properties with postcode and annual costs populated. /// </summary> /// <returns>List[AnonymousProperty] with postcode and annual cost for each property in the database</returns> internal static List <AnonymousProperty> getAllPropertyAnnualCosts() { EMMediator mediator = new EMMediator(); List <Property> allProperties = mediator.DataManager.getAllProperties(); List <AnonymousProperty> result = new List <AnonymousProperty>(); foreach (Property property in allProperties) { AnonymousProperty anonProperty = new AnonymousProperty(); anonProperty.Postcode = property.Postcode; anonProperty.AnnualCost = property.AnnualCost; anonProperty.Id = property.Id; result.Add(anonProperty); } return(result); }
public List <AnonymousProperty> getComparativeCostsForUser(int userId) { List <Property> usersProperties = mediator.DataManager.getProperties(userId); List <AnonymousProperty> anonProperties = new List <AnonymousProperty>(); List <AnonymousProperty> allProperties = EMDatabaseStats.getAllPropertyAnnualCosts(); List <AnonymousProperty> result = new List <AnonymousProperty>(); foreach (AnonymousProperty anonProperty in allProperties) { AnonymousProperty resultProperty = new AnonymousProperty(); resultProperty.Id = anonProperty.Id; resultProperty.Postcode = anonProperty.Postcode; resultProperty.AnnualCost = anonProperty.AnnualCost; resultProperty.isUsers = usersProperties.ToList().Exists(p => p.Id == anonProperty.Id); result.Add(resultProperty); } return(result); }
/// <summary> /// Create an array of PropertyBlocks from an array of Property /// instances, creating empty Property instances to make up any /// shortfall /// </summary> /// <param name="bigBlockSize"></param> /// <param name="properties">the Property instances to be converted into PropertyBlocks, in a java List</param> /// <returns>the array of newly created PropertyBlock instances</returns> public static BlockWritable [] CreatePropertyBlockArray( POIFSBigBlockSize bigBlockSize, List<Property> properties) { int _properties_per_block = bigBlockSize.GetPropertiesPerBlock(); int blockCount = (properties.Count + _properties_per_block - 1) / _properties_per_block; Property[] toBeWritten = new Property[blockCount * _properties_per_block]; System.Array.Copy(properties.ToArray(), 0, toBeWritten, 0, properties.Count); for (int i = properties.Count; i < toBeWritten.Length; i++) { toBeWritten[i] = new AnonymousProperty(); } BlockWritable[] rvalue = new BlockWritable[blockCount]; for (int i = 0; i < blockCount; i++) rvalue[i] = new PropertyBlock(bigBlockSize, toBeWritten, i * _properties_per_block); return rvalue; }
/// <summary> /// Create an array of PropertyBlocks from an array of Property /// instances, creating empty Property instances to make up any /// shortfall /// </summary> /// <param name="properties">the Property instances to be converted into PropertyBlocks, in a java List</param> /// <returns>the array of newly created PropertyBlock instances</returns> public static BlockWritable [] CreatePropertyBlockArray( IList properties) { int block_count = (properties.Count + _properties_per_block - 1) / _properties_per_block; Property[] to_be_written = new Property[ block_count * _properties_per_block ]; Property[] array = new Property[properties.Count]; properties.CopyTo(array, 0); System.Array.Copy(array, 0, to_be_written, 0, properties.Count); for (int j = properties.Count; j < to_be_written.Length; j++) { // create an instance of an anonymous inner class that // extends Property to_be_written[j] = new AnonymousProperty(); } BlockWritable[] rvalue = new BlockWritable[ block_count ]; for (int j = 0; j < block_count; j++) { rvalue[ j ] = new PropertyBlock(to_be_written, j * _properties_per_block); } return rvalue; }