We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

I could not add meeting on calendar

I tried this way to add meeting on calendar but was unable to see on screen.

 private void CreateCalendarEvents(ScheduleAppointmentCollection Meetings)
            {
                Meetings = new ScheduleAppointmentCollection();
                ScheduleAppointment meeting = new ScheduleAppointment();
                Calendar calendar = Calendar.Instance;
                Calendar startTimeCalendar = Calendar.Instance;
                foreach (var calendarEvent in remoteData)
                {
                    var DefaultHour = 9;                  
                    if (!string.IsNullOrEmpty(calendarEvent.start) && !string.IsNullOrEmpty(calendarEvent.end))
                    {
                        var startDate = GetDate(calendarEvent.start);
                        var startYear = startDate.Year;
                        var startMonth = startDate.Month;
                        var startDay = startDate.Day;
                        var startTime = GetDate(calendarEvent.start);
                      
                        var startHour = startTime.Hour == 0 ? DefaultHour : startTime.Hour;
                        var startMinute = startTime.Minute;
                        var endDate = GetDate(calendarEvent.end);
                        var endYear = endDate.Year;
                        var endMonth = endDate.Month;
                        var endDay = endDate.Day;
                        var endTime = GetDate(calendarEvent.end);
                        var endHour = endTime.Hour==0 ? DefaultHour : endTime.Hour;
                        var endMinute = endTime.Minute;
                      
                       // startTimeCalendar.Set(calendar.Get(CalendarField.Year), calendar.Get(CalendarField.Month), calendar.Get(CalendarField.Date), hour, 0);
                      
                        startTimeCalendar.Set(startYear, startMonth, calendar.Get(CalendarField.Date), startHour, startMinute, 0);
                        meeting.StartTime = startTimeCalendar;
                        Calendar endTimeCalendar = Calendar.Instance;
                        endTimeCalendar.Set(endYear, endMonth, calendar.Get(CalendarField.Date), endHour, endMinute, 0);
                        meeting.EndTime = endTimeCalendar;
                        meeting.Color = GetColor(calendarEvent.color);
                        meeting.Subject = calendarEvent.title ?? "";
                        meeting.IsAllDay = calendarEvent.allDay;
                        meeting.Notes = calendarEvent.title ?? "";
                        Meetings.Add(meeting);
                    }
                   
                }

            }  


  private int GetColor(string color)
            {
                var defaultColor = "#086A87";
                try
                {
                    if(!string.IsNullOrEmpty(color))
                    {
                        return Color.ParseColor(color);
                    }
                    return Color.ParseColor(defaultColor);
                }catch(Exception ex)
                {
                    Log.Debug(TAG, ex.StackTrace);
                    return Color.ParseColor(defaultColor);
                }
            }       
            private DateTimeOffset GetDate(string date)
            {
             
                try
                {
                   
                    if(!string.IsNullOrEmpty(date))
                    {
                        return DateTime.Parse(date);
                    }else
                    {
                        return DateTime.UtcNow.AddHours(5).AddMinutes(45);
                    }
                    
                }
                catch(Exception e)
                {
                    var dateTime = DateTimeOffset.Parse(date, System.Globalization.CultureInfo.InvariantCulture);
                    return dateTime;
                }
            }

1 Reply

NM Nijamudeen Mohamed Sulaiman Syncfusion Team September 1, 2017 07:19 AM UTC

Hi Ishwor,

Thanks for your interest in Syncfusion products.

Based on the given details we are unable to reproduce the mentioned issue with SfSchedule.Android. We have prepared a simple sample with the provided code. Please refer the sample in the below link.

If the provided solution does not meet your requirement, could you please provide us more details such as Syncfusion ES Version, ScheduleView, Android device, Android OS version etc. It will be helpful for us to analyze on your requirement and provide you a possible solution.


Regards,
Nijamudeen M.


Attachment: ScheduleAppointments_Android_3abe08d7.zip

Loader.
Up arrow icon