示例#1
0
文件: Main.cs 项目: emperorbyl/HMHY
        public static UserEventInfo addNewGoal(string titleA, string descriptionA, DateTime startTimeA, DateTime endTimeA, string phoneConnection)
        {
            //TODO
            //Figure out how to access the database on a phone. This will be used instead of hmhy-global.
            // Open the connection for the query.
            SQLiteDatabase db    = SQLiteDatabase.OpenDatabase(phoneConnection, null, DatabaseOpenFlags.OpenReadwrite);
            string         query = @"INSERT INTO Goal
            Values(id, @title, @description, @startTime, @endTime, reminderId)";

            // Add the values passed in to a Content Vales
            Android.Content.ContentValues values = new Android.Content.ContentValues(5);
            values.Put("0", "0");
            values.Put("1", titleA);
            values.Put("2", descriptionA);
            values.Put("3", startTimeA.ToString());
            values.Put("4", endTimeA.ToString());
            // Execute the query to inset into the phone database.
            db.Insert(query, "id, title, goalDescription, StartTime, EndTime", values);
            // Add the goal as an event to the calendar.
            AndroidCalendar userCalendar = new AndroidCalendar();

            userCalendar.AddEvent("0", titleA, startTimeA, endTimeA, descriptionA);
            UserEventInfo info = new UserEventInfo();

            info.Id        = "0";
            info.Title     = titleA;
            info.StartDate = startTimeA;
            info.EndDate   = endTimeA;

            return(info);
        }
示例#2
0
        /// <summary>
        /// Gets the cursor for user events.
        /// </summary>
        /// <param name="uri"> The uniform resource locator of the event. </param>
        /// <param name="info"> The event info. </param>
        /// <param name="calId"> The calendar id of where the event is located. </param>
        /// <returns></returns>
        public ICursor GetEventIcursor(Android.Net.Uri uri, UserEventInfo userInfo, int calId)
        {
            var milliseconds = userInfo.StartDate.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;

            string[] info =
            {
                userInfo.Id,
                userInfo.Title,
                milliseconds.ToString()
            };
            return(Application.Context.ContentResolver.Query(uri, info, String.Format("calendar_id={0}", calId), null, "dtstart ASC"));
        }
示例#3
0
        /// <summary>
        /// Gets the events from the users calendar.
        /// </summary>
        /// <param name="calId"></param>
        public UserEventInfo GetUserCalendarEvents()
        {
            var userEvents = new UserEventInfo();

            userEvents.Id    = CalendarContract.Events.InterfaceConsts.Id;
            userEvents.Title = CalendarContract.Events.InterfaceConsts.Title;
            DateTime startDate;

            if (DateTime.TryParse(CalendarContract.Events.InterfaceConsts.Dtstart, out startDate))
            {
                userEvents.StartDate = startDate;
            }

            DateTime endDate;

            if (DateTime.TryParse(CalendarContract.Events.InterfaceConsts.Dtend, out endDate))
            {
                userEvents.EndDate = endDate;
            }

            return(userEvents);
        }