internal static void UpdateTimeline(int eventId, DateTime startDate, DateTime finishDate, bool checkAccess) { if (checkAccess) { VerifyCanUpdate(eventId); } int TimeZoneId = Security.CurrentUser.TimeZoneId; startDate = DBCommon.GetUTCDate(TimeZoneId, startDate); finishDate = DBCommon.GetUTCDate(TimeZoneId, finishDate); int projectId = -1; bool hasRecurrence = false; using (IDataReader reader = CalendarEntry.GetEvent(eventId, false)) { if (reader.Read()) { if (reader["ProjectId"] != DBNull.Value) { projectId = (int)reader["ProjectId"]; } hasRecurrence = ((int)reader["HasRecurrence"] == 1); } } // O.R. [2009-12-18] Dates for recurrent events should be chnaged in recurrence editing. if (hasRecurrence) { return; } TimeSpan ts = finishDate.Subtract(startDate); int taskTime = (int)ts.TotalMinutes; using (DbTransaction tran = DbTransaction.Begin()) { int retVal = DbCalendarEntry2.UpdateTimeline(eventId, startDate, finishDate, taskTime); if (retVal > 0) { SystemEvents.AddSystemEvents(SystemEventTypes.CalendarEntry_Updated_Timeline, eventId); if (!hasRecurrence) { if (retVal == 1 || retVal == 3) { Schedule.UpdateDateTypeValue(DateTypes.CalendarEntry_StartDate, eventId, startDate); } if (retVal == 2 || retVal == 3) { Schedule.UpdateDateTypeValue(DateTypes.CalendarEntry_FinishDate, eventId, finishDate); } } else { // O.R.[2009-09-29]: Recalculate events dates for scheduling Schedule.DeleteDateTypeValue(DateTypes.CalendarEntry_StartDate, eventId); Schedule.DeleteDateTypeValue(DateTypes.CalendarEntry_FinishDate, eventId); int ReminderInterval; Hashtable ret = CalendarEntry.GetEventInstances(eventId, out ReminderInterval); foreach (DateTime dtStart in ret.Keys) { DateTime dtEnd = (DateTime)ret[dtStart]; if (dtStart > DateTime.UtcNow && dtEnd > DateTime.UtcNow) { DbSchedule2.AddNewDateTypeValue((int)DateTypes.CalendarEntry_StartDate, eventId, dtStart); DbSchedule2.AddNewDateTypeValue((int)DateTypes.CalendarEntry_FinishDate, eventId, dtEnd); } } } // O.R: Recalculating project TaskTime if (projectId > 0) { TimeTracking.RecalculateProjectTaskTime(projectId); } } CalendarEntry.RecalculateState(eventId); tran.Commit(); } }