/// <summary> /// Deletes multiple records with related child records from the calendar database as a batch operation. /// </summary> /// <since_tizen> 4 </since_tizen> /// <param name="list">The record list</param> /// <privilege>http://tizen.org/privilege/calendar.write</privilege> /// <feature>http://tizen.org/feature/calendar</feature> /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception> /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception> /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception> /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception> public void Delete(CalendarList list) { CalendarRecord record = null; if (list.Count <= 0) { return; } int[] ids = new int[list.Count]; int i; uint propertyId = 0; list.MoveFirst(); for (i = 0; i < list.Count; i++) { record = list.GetCurrentRecord(); if (0 == propertyId) { if (0 == String.Compare(CalendarViews.Book.Uri, record.Uri)) { propertyId = CalendarViews.Book.Id; } else if (0 == String.Compare(CalendarViews.Event.Uri, record.Uri)) { propertyId = CalendarViews.Event.Id; } else if (0 == String.Compare(CalendarViews.Todo.Uri, record.Uri)) { propertyId = CalendarViews.Todo.Id; } else if (0 == String.Compare(CalendarViews.Timezone.Uri, record.Uri)) { propertyId = CalendarViews.Timezone.Id; } else if (0 == String.Compare(CalendarViews.Extended.Uri, record.Uri)) { propertyId = CalendarViews.Extended.Id; } else { Log.Error(Globals.LogTag, "Invalid uri [" + record.Uri + "]"); continue; } } ids[i] = record.Get <int>(propertyId); list.MoveNext(); } Delete(record.Uri, ids); }
/// <summary> /// Get item from record. /// <param name="record">The record</param> /// <param name="item">The item to be converted from record.</param> /// </summary> private void RecordToItem(TPC.CalendarRecord record, RecordItem item, TPC.CalendarTime start, TPC.CalendarTime end, bool isAllday) { item.Index = record.Get <int>(Event.Id); item.Summary = record.Get <string>(Event.Summary); item.Location = record.Get <string>(Event.Location); item.Description = record.Get <string>(Event.Description); item.Priority = getPriorityIndex(record.Get <int>(Event.Priority)); item.Sensitivity = getSensitivityIndex(record.Get <int>(Event.Sensitivity)); item.Status = getStatusIndex(record.Get <int>(Event.EventStatus)); item.StartTime = isAllday == true ? start.LocalTime : start.UtcTime; item.EndTime = isAllday == true ? end.LocalTime : end.UtcTime; item.IsAllday = isAllday; item.Recurrence = getRecurrenceIndex(record.Get <int>(Event.Freq)); item.DisplayTime = String.Format("{0} - {1}", item.IsAllday == true ? item.StartTime.ToLocalTime().ToString("yyyy/MM/dd") : item.StartTime.ToLocalTime().ToString("yyyy/MM/dd HH:mm"), item.IsAllday == true ? item.EndTime.ToLocalTime().ToString("yyyy/MM/dd") : item.EndTime.ToLocalTime().ToString("yyyy/MM/dd HH:mm")); if (item.Recurrence > 0) { switch (record.Get <int>(Event.RangeType)) { default: /// count case (int)TPC.CalendarTypes.RangeType.Count: item.UntilType = 0; item.UntilCount = record.Get <int>(Event.Count); break; /// until case (int)TPC.CalendarTypes.RangeType.Until: item.UntilType = 1; var until = record.Get <TPC.CalendarTime>(Event.Until); item.UntilTime = until.UtcTime; break; } } if (record.Get <int>(Event.HasAlarm) > 0) { var alarm = record.GetChildRecord(Event.Alarm, 0); item.Reminder = getReminderIndex(alarm.Get <int>(Alarm.Tick), alarm.Get <int>(Alarm.TickUnit)); } }