/// <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);
        }
示例#2
0
        public int GetCount(CalendarQuery query)
        {
            int count = -1;
            int error = Interop.Database.GetCountWithQuery(query._queryHandle, out count);

            if (CalendarError.None != (CalendarError)error)
            {
                Log.Error(Globals.LogTag, "GetCount Failed with error " + error);
                throw CalendarErrorFactory.GetException(error);
            }
            return(count);
        }
示例#3
0
        public CalendarList GetRecordsWithQuery(CalendarQuery query, int offset, int limit)
        {
            IntPtr handle;
            int    error = Interop.Database.GetRecords(query._queryHandle, offset, limit, out handle);

            if (CalendarError.None != (CalendarError)error)
            {
                Log.Error(Globals.LogTag, "GetAllWithQuery Failed with error " + error);
                throw CalendarErrorFactory.GetException(error);
            }
            return(new CalendarList(handle));
        }
        /// <summary>
        /// Get utc instance list.
        /// To get not-allday instance list, InstanceUtimeBook uri must be used.
        /// This does not include allday instances.
        /// 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 GetUtcInstances(DateTime dt)
        {
            TPC.CalendarList list;

            DateTime firstDate = new DateTime(dt.Year, dt.Month, dt.Day, 0, 0, 0, DateTimeKind.Local);

            TPC.CalendarTime from = new TPC.CalendarTime(firstDate.ToUniversalTime().Ticks);
            TPC.CalendarTime to   = new TPC.CalendarTime(from.UtcTime.AddDays(1).Ticks);

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

            return(list);
        }