Exemplo n.º 1
0
        /// <summary>
        /// Get allday instance list.
        /// To get allday instance list, InstanceLocaltimeBook uri must be used.
        /// Range is set from the first day of selected date to the last day of selected data.
        /// <param name="dt">The selected datetime</param>
        /// </summary>
        private TPC.CalendarList GetAlldayInstances(DateTime dt)
        {
            TPC.CalendarList list = null;

            TPC.CalendarTime from = new TPC.CalendarTime(dt.Year, dt.Month, dt.Day, 0, 0, 0);
            TPC.CalendarTime to   = new TPC.CalendarTime(dt.AddDays(1).Year, dt.AddDays(1).Month, dt.AddDays(1).Day, 0, 0, 0);

            TPC.CalendarQuery  query  = new TPC.CalendarQuery(InstanceLocaltimeBook.Uri);
            TPC.CalendarFilter filter = new TPC.CalendarFilter(InstanceLocaltimeBook.Uri,
                                                               InstanceLocaltimeBook.Start, TPC.CalendarFilter.IntegerMatchType.GreaterThanOrEqual, from);
            filter.AddCondition(TPC.CalendarFilter.LogicalOperator.And,
                                InstanceLocaltimeBook.Start, TPC.CalendarFilter.IntegerMatchType.LessThan, to);
            query.SetFilter(filter);
            try
            {
                list = manager.Database.GetRecordsWithQuery(query, 0, 0);
            }
            catch (Exception)
            {
            }
            filter.Dispose();
            query.Dispose();

            return(list);
        }
Exemplo n.º 2
0
        public void Replace(CalendarList list, int[] idArray)
        {
            int error = Interop.Database.ReplaceRecords(list._listHandle, idArray, idArray.Length);

            if (CalendarError.None != (CalendarError)error)
            {
                Log.Error(Globals.LogTag, "Replace Failed with error " + error);
                throw CalendarErrorFactory.GetException(error);
            }
        }
Exemplo n.º 3
0
        public void Update(CalendarList list)
        {
            int error = Interop.Database.UpdateRecords(list._listHandle);

            if (CalendarError.None != (CalendarError)error)
            {
                Log.Error(Globals.LogTag, "Update Failed with error " + error);
                throw CalendarErrorFactory.GetException(error);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Retrieves a vcalendar stream from a calendar list.
        /// </summary>
        /// <param name="list">The calendar list</param>
        /// <returns>
        /// The composed stream.
        /// </returns>
        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
        /// <since_tizen> 4 </since_tizen>
        public static string Compose(CalendarList list)
        {
            string stream;
            int    error = Interop.Vcalendar.Compose(list._listHandle, out stream);

            if (CalendarError.None != (CalendarError)error)
            {
                Log.Error(Globals.LogTag, "MakeVcalendar Failed with error " + error);
                throw CalendarErrorFactory.GetException(error);
            }
            return(stream);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Clones a child record list corresponding to property ID.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <param name="propertyId">The property ID.</param>
        /// <returns>
        /// The record list.
        /// </returns>
        /// <feature>http://tizen.org/feature/calendar</feature>
        /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid.</exception>
        public CalendarList CloneChildRecordList(uint propertyId)
        {
            IntPtr listHandle;
            int    error = Interop.Record.CloneChildRecordList(_recordHandle, propertyId, out listHandle);

            if (CalendarError.None != (CalendarError)error)
            {
                Log.Error(Globals.LogTag, "CloneChildRecordList Failed with [" + error + "]" + String.Format("{0:X}", propertyId));
                throw CalendarErrorFactory.GetException(error);
            }
            CalendarList list = new CalendarList(listHandle);

            return(list);
        }
Exemplo n.º 6
0
        /// <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);
        }
Exemplo n.º 7
0
        public int[] Insert(CalendarList list)
        {
            IntPtr ids;
            int    count;
            int    error = Interop.Database.InsertRecords(list._listHandle, out ids, out count);

            if (CalendarError.None != (CalendarError)error)
            {
                Log.Error(Globals.LogTag, "Insert Failed with error " + error);
                throw CalendarErrorFactory.GetException(error);
            }
            int[] idArr = new int[count];
            Marshal.Copy(ids, idArr, 0, count);

            return(idArr);
        }