//income processing protected override IEnumerable <DayIncomeObject> ConvertRawData(RawIncomeManager incomeManager) { var lastIncome = 0.0; var incomes = new List <DayIncomeObject>(); var startTime = UnixTimeHelper.GetCurrentDay(); while (true) { var rawIncome = incomeManager.GetRow(startTime); var income = new DayIncomeObject(rawIncome.time, rawIncome.value); if (income.time == 0) { break; } if (lastIncome > 0) { income.value = lastIncome - income.value; incomes.Add(income); lastIncome -= income.value; } else { lastIncome = income.value; } startTime -= 86400; } incomes.Reverse(); return(incomes.ToArray()); }
public IEnumerable <DayIncomeObject> GetIncomes() { var incomes = new List <DayIncomeObject>(); using (var fs = new FileStream("./Data/incomes.idat", FileMode.OpenOrCreate)) { if (fs.Length > 0) { var br = new BinaryReader(fs); var count = br.ReadInt32(); for (var i = 0; i < count; i++) { var income = new DayIncomeObject(); income.time = br.ReadInt64(); income.value = br.ReadDouble(); incomes.Add(income); } } } return(incomes.ToArray()); }