/// <summary> /// Checks whether the appointment is different to the time entry /// </summary> /// <param name="item">The item</param> /// <param name="timeEntry">The time entry</param> /// <returns>True if the item is modified</returns> public static bool CheckItemIsModified(this AppointmentItem item, TimeEntryInfo timeEntry) { // create new calendar item var startTime = timeEntry.StartDateTime; var endTime = timeEntry.EndDateTime; if (!string.Equals(item.Subject, timeEntry.Name)) { return(true); } if (item.Start != startTime || item.End != endTime) { return(true); } var issueId = item.GetIssueId(); if (issueId != timeEntry.IssueInfo.Id) { return(true); } return(false); }
/// <summary> /// Method that checks the previous state of an appointment and tries to reset that state. /// </summary> /// <param name="item">The appointment for which to set the previous state.</param> public static void ResetPreviousState(this AppointmentItem item) { var previousState = item.GetAppointmentCustomId(Constants.FieldAppointmentPreviousState); if (!previousState.HasValue) { return; } var state = AppointmentState.AllStates.FirstOrDefault(s => s.Value == previousState.Value); if (state == null) { return; } if (state == AppointmentState.Synchronized) { Log.Warn(string.Format("Appointment state set to synchronized. #{0} Previus state: {1}", item.GetIssueId(), item.Categories)); } item.SetAppointmentState(state); item.Save(); }