ObservableCollection <Grouping <string, ServerTransaction> > SetupList(IList <ServerTransaction> list)
        {
            List <ServerTransaction> l = new List <ServerTransaction>(list);

            l.OrderBy(x => BaseFunctions.GetDateTimeFull(x.transactionDate));
            list = l;
            var sorted = from child in list
                         group child by child.transactionType into _group
                         select new Grouping <string, ServerTransaction>(_group.Key, _group);

            var childGrouped = new ObservableCollection <Grouping <string, ServerTransaction> >(sorted);

            return(childGrouped);
        }
コード例 #2
0
 public async void SetCurrentEventReminder(object sender, EventArgs e)
 {
     if (CheckSelfPermission(Manifest.Permission.WriteCalendar.ToString()) == Android.Content.PM.Permission.Granted)
     {
         try
         {
             if (!isEventInCal(this, App.reminderEvent.eventName))
             {
                 ContentValues eventValues = new ContentValues();
                 eventValues.Put(CalendarContract.Events.InterfaceConsts.CalendarId, 1);
                 eventValues.Put(CalendarContract.Events.InterfaceConsts.Title, App.reminderEvent.eventName);
                 eventValues.Put(CalendarContract.Events.InterfaceConsts.Description, App.reminderEvent.eventDescription);
                 eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart, GetDateTimeMS(BaseFunctions.GetDateTimeFull(App.reminderEvent.eventStartDate + " " + App.reminderEvent.eventStartTime)));
                 eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend, GetDateTimeMS(BaseFunctions.GetDateTimeFull(App.reminderEvent.eventEndDate + " " + App.reminderEvent.eventEndTime)));
                 eventValues.Put(CalendarContract.Events.InterfaceConsts.AllDay, "0");
                 eventValues.Put(CalendarContract.Events.InterfaceConsts.EventLocation, App.reminderEvent.eventAddress);
                 eventValues.Put(CalendarContract.Events.InterfaceConsts.HasAlarm, "1");
                 eventValues.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, "UTC");
                 eventValues.Put(CalendarContract.Events.InterfaceConsts.EventEndTimezone, "UTC");
                 var           eventUri       = ContentResolver.Insert(CalendarContract.Events.ContentUri, eventValues);
                 long          eventID        = long.Parse(eventUri.LastPathSegment);
                 ContentValues reminderValues = new ContentValues();
                 reminderValues.Put(CalendarContract.Reminders.InterfaceConsts.Minutes, 30);
                 reminderValues.Put(CalendarContract.Reminders.InterfaceConsts.EventId, eventID);
                 reminderValues.Put(CalendarContract.Reminders.InterfaceConsts.Method, (int)RemindersMethod.Alert);
                 var reminderUri = ContentResolver.Insert(CalendarContract.Reminders.ContentUri, reminderValues);
                 await App.Current.MainPage.DisplayAlert("Alert", "This event is added to your calender", "Ok");
             }
             else
             {
                 await App.Current.MainPage.DisplayAlert("Alert", "This event is already added to your calender", "Ok");
             }
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine(ex.ToString());
         }
     }
     else
     {
         RequestPermissions(new string[] { Manifest.Permission.WriteCalendar.ToString() }, calenderRequestCode);
     }
 }
コード例 #3
0
        public async void AddEventToCalender(object sender, EventArgs e)
        {
            try
            {
                var store = new EKEventStore();
                if (EKEventStore.GetAuthorizationStatus(EKEntityType.Reminder) == EKAuthorizationStatus.Authorized)
                {
                    if (EKEventStore.GetAuthorizationStatus(EKEntityType.Event) == EKAuthorizationStatus.Authorized)
                    {
                        NSDate           startDate = ConvertDateTimeToNSDate(BaseFunctions.GetDateTimeFull(App.reminderEvent.eventStartDate + " " + App.reminderEvent.eventStartTime));
                        NSDate           endDate   = ConvertDateTimeToNSDate(BaseFunctions.GetDateTimeFull(App.reminderEvent.eventEndDate + " " + App.reminderEvent.eventEndTime));
                        NSPredicate      query     = store.PredicateForEvents(startDate, endDate, null);
                        EKCalendarItem[] events    = store.EventsMatching(query);
                        bool             exists    = false;
                        for (int i = 0; i < events.Length; i++)
                        {
                            if (events[i].Title == App.reminderEvent.eventName)
                            {
                                exists = true;
                            }
                        }
                        if (!exists)
                        {
                            EKEvent eEvent = EKEvent.FromStore(store);
                            eEvent.AddAlarm(EKAlarm.FromDate(ConvertDateTimeToNSDate(BaseFunctions.GetDateTimeFull(App.reminderEvent.eventStartDate + " " + App.reminderEvent.eventStartTime))));
                            eEvent.StartDate = startDate;
                            eEvent.EndDate   = endDate;
                            eEvent.Title     = App.reminderEvent.eventName;
                            eEvent.TimeZone  = new NSTimeZone("UTC");
                            eEvent.Location  = App.reminderEvent.eventAddress;
                            eEvent.Notes     = App.reminderEvent.eventDescription;
                            eEvent.Calendar  = store.DefaultCalendarForNewEvents;
                            NSError eventError;
                            store.SaveEvent(eEvent, EKSpan.ThisEvent, out eventError);

                            EKReminder reminder = EKReminder.Create(store);
                            reminder.Title = App.reminderEvent.eventName;
                            reminder.AddAlarm(EKAlarm.FromDate(ConvertDateTimeToNSDate(BaseFunctions.GetDateTimeFull(App.reminderEvent.eventStartDate + " " + App.reminderEvent.eventStartTime))));
                            reminder.TimeZone = new NSTimeZone("UTC");
                            reminder.Calendar = store.DefaultCalendarForNewEvents;
                            await App.Current.MainPage.DisplayAlert("Alert", "This event is added to your calender", "Ok");
                        }
                        else
                        {
                            await App.Current.MainPage.DisplayAlert("Alert", "This event is already added to your calender", "Ok");
                        }
                    }
                    else
                    {
                        store.RequestAccess(EKEntityType.Event, StoreAcceptRequest);
                    }
                }
                else
                {
                    store.RequestAccess(EKEntityType.Reminder, StoreAcceptRequest);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
        }