public static double SumHistoryData(CTable dataSource, double date, int cycle, int field) { double sumValue = 0; double value = 0; int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0, ms = 0; CStrA.M130(date, ref year, ref month, ref day, ref hour, ref minute, ref second, ref ms); if (cycle == CYCLE_WEEK) { int dayOfWeek = DayOfWeek(year, month, day); if (dayOfWeek >= 5) { dayOfWeek = 4; } for (int i = 1; i <= dayOfWeek; i++) { double calcDate = CStrA.M129(year, month, day - i, 0, 0, 0, 0); value = dataSource.Get(calcDate, field); if (!double.IsNaN(value)) { sumValue += value; } } } else if (cycle == CYCLE_MONTH) { for (int i = 1; i < day; i++) { double calcDate = CStrA.M129(year, month, i, 0, 0, 0, 0); value = dataSource.Get(calcDate, field); if (!double.IsNaN(value)) { sumValue += value; } } } else if (cycle == 0) { int rowCount = dataSource.RowsCount; for (int i = 0; i < rowCount; i++) { value = dataSource.Get2(i, field); if (!double.IsNaN(value)) { sumValue += value; } } } return(sumValue); }