Exemplo n.º 1
0
 /// <summary>
 /// Sets a value of the property to a record.
 /// </summary>
 /// <since_tizen> 4 </since_tizen>
 /// <param name="propertyId">The property ID</param>
 /// <param name="value">value</param>
 /// <feature>http://tizen.org/feature/calendar</feature>
 /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
 /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
 public void Set <T>(uint propertyId, T value)
 {
     if (typeof(T) == typeof(string))
     {
         string val   = Convert.ToString(value);
         int    error = Interop.Record.SetString(_recordHandle, propertyId, val);
         if (CalendarError.None != (CalendarError)error)
         {
             Log.Error(Globals.LogTag, "Set String Failed [" + error + "]" + String.Format("{0:X}", propertyId));
             throw CalendarErrorFactory.GetException(error);
         }
     }
     else if (typeof(T) == typeof(int))
     {
         int val   = Convert.ToInt32(value);
         int error = Interop.Record.SetInteger(_recordHandle, propertyId, val);
         if (CalendarError.None != (CalendarError)error)
         {
             Log.Error(Globals.LogTag, "Set Integer Failed [" + error + "]" + String.Format("{0:X}", propertyId));
             throw CalendarErrorFactory.GetException(error);
         }
     }
     else if (typeof(T) == typeof(long))
     {
         long val   = Convert.ToInt64(value);
         int  error = Interop.Record.SetLli(_recordHandle, propertyId, val);
         if (CalendarError.None != (CalendarError)error)
         {
             Log.Error(Globals.LogTag, "Set Long Failed [" + error + "]" + String.Format("{0:X}", propertyId));
             throw CalendarErrorFactory.GetException(error);
         }
     }
     else if (typeof(T) == typeof(double))
     {
         double val   = Convert.ToDouble(value);
         int    error = Interop.Record.SetDouble(_recordHandle, propertyId, val);
         if (CalendarError.None != (CalendarError)error)
         {
             Log.Error(Globals.LogTag, "Set Double Failed [" + error + "]" + String.Format("{0:X}", propertyId));
             throw CalendarErrorFactory.GetException(error);
         }
     }
     else if (typeof(T) == typeof(CalendarTime))
     {
         CalendarTime            time = (CalendarTime)Convert.ChangeType(value, typeof(CalendarTime));
         Interop.Record.DateTime val  = ConvertCalendarTimeToStruct(time);
         int error = Interop.Record.SetCalendarTime(_recordHandle, propertyId, val);
         if (CalendarError.None != (CalendarError)error)
         {
             Log.Error(Globals.LogTag, "Set CalendarTime Failed [" + error + "]" + String.Format("{0:X}", propertyId));
             throw CalendarErrorFactory.GetException(error);
         }
     }
     else
     {
         Log.Error(Globals.LogTag, "Not supported Data T/ype");
         throw CalendarErrorFactory.GetException((int)CalendarError.NotSupported);
     }
 }
Exemplo n.º 2
0
        internal static CalendarTime ConvertIntPtrToCalendarTime(Interop.Record.DateTime time)
        {
            CalendarTime value;

            if ((int)CalendarTime.Type.Utc == time.type)
            {
                DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0);
                value = new CalendarTime(time.utime * 10000000 + epoch.Ticks);
            }
            else
            {
                value = new CalendarTime(time.local.year, time.local.month, time.local.mday, time.local.hour, time.local.minute, time.local.second);
            }
            value._type = time.type;
            return(value);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a condition for the CalendarTime type.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <feature>http://tizen.org/feature/calendar</feature>
        /// <param name="logicalOperator">The operator type.</param>
        /// <param name="propertyId">The property ID to add a condition.</param>
        /// <param name="matchType">The match flag.</param>
        /// <param name="matchValue">The match value.</param>
        /// <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 void AddCondition(LogicalOperator logicalOperator, uint propertyId, IntegerMatchType matchType, CalendarTime matchValue)
        {
            int error = Interop.Filter.AddOperator(_filterHandle, logicalOperator);

            if (CalendarError.None != (CalendarError)error)
            {
                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
                throw CalendarErrorFactory.GetException(error);
            }

            Interop.Record.DateTime time = CalendarRecord.ConvertCalendarTimeToStruct(matchValue);
            error = Interop.Filter.AddCalendarTime(_filterHandle, propertyId, matchType, time);
            if (CalendarError.None != (CalendarError)error)
            {
                Log.Error(Globals.LogTag, "AddCondition Failed with error " + error);
                throw CalendarErrorFactory.GetException(error);
            }
        }
Exemplo n.º 4
0
        public CalendarFilter(string viewUri, uint propertyId, IntegerMatchType matchType, CalendarTime matchValue)
        {
            int error = 0;

            error = Interop.Filter.Create(viewUri, out _filterHandle);
            if (CalendarError.None != (CalendarError)error)
            {
                Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
                throw CalendarErrorFactory.GetException(error);
            }

            Interop.Record.DateTime time = CalendarRecord.ConvertCalendarTimeToStruct(matchValue);
            error = Interop.Filter.AddCalendarTime(_filterHandle, propertyId, matchType, time);
            if (CalendarError.None != (CalendarError)error)
            {
                Interop.Filter.Destroy(_filterHandle);
                Log.Error(Globals.LogTag, "CalendarFilter Failed with error " + error);
                throw CalendarErrorFactory.GetException(error);
            }
        }
Exemplo n.º 5
0
        internal static Interop.Record.DateTime ConvertCalendarTimeToStruct(CalendarTime value)
        {
            Interop.Record.DateTime time = new Interop.Record.DateTime();
            time.type = value._type;

            if ((int)CalendarTime.Type.Utc == value._type)
            {
                DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0);
                time.utime = (value.UtcTime.Ticks - epoch.Ticks) / 10000000;
            }
            else
            {
                time.local.year   = value.LocalTime.Year;
                time.local.month  = value.LocalTime.Month;
                time.local.mday   = value.LocalTime.Day;
                time.local.hour   = value.LocalTime.Hour;
                time.local.minute = value.LocalTime.Minute;
                time.local.second = value.LocalTime.Second;
            }
            return(time);
        }
Exemplo n.º 6
0
 internal static extern int AddCalendarTime(IntPtr filterHandle, uint propertyId, IntegerMatchType match, Interop.Record.DateTime value);