public void GetandSetAttendentsTest()
        {
            MeetingNode meeting0 = new MeetingNode(mTitle, mID, sTime, eTime, PID, "");
            MeetingNode meeting  = new MeetingNode(mTitle, mID, sTime, eTime, PID, Attendents);

            //test empty
            String actualAttend0 = meeting0.GetAttendents();

            Assert.AreEqual("", actualAttend0, "Actual Attendents are not empty");

            //test get
            String actualAttend1 = meeting.GetAttendents();

            Assert.AreEqual(Attendents, actualAttend1, "Actual attendents are not Steven, Eddie, Xiaoying");

            //test set
            meeting.SetAttendents("Harris, John");
            String actualAttend2 = meeting.GetAttendents();

            Assert.AreEqual("Harris, John", actualAttend2, "Actual attendents are not Harris, John");
        }
Пример #2
0
        public static void fetchFromGoogle(DateTime minTime)
        {
            Debug.Print("" + minTime);
            MeetingNode meeting = new MeetingNode();
            FileNode    file    = new FileNode();

            // Create Google Calendar API service.
            var service = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = ApplicationName,
            });

            // Define parameters of request.
            EventsResource.ListRequest request = service.Events.List("primary");
            request.TimeMin      = minTime;
            request.TimeMax      = DateTime.Now;
            request.ShowDeleted  = false;
            request.SingleEvents = true;


            // List events.
            try
            {
                Events events = request.Execute();
                if (events.Items != null && events.Items.Count > 0)
                {
                    foreach (var eventItem in events.Items)
                    {
                        meeting = new MeetingNode();
                        string attendee = "";
                        string when     = eventItem.Start.DateTime.ToString();
                        if (eventItem.Attendees != null)
                        {
                            EventAttendee[] attendeeData = new EventAttendee[eventItem.Attendees.Count];
                            eventItem.Attendees.CopyTo(attendeeData, 0);
                            List <String> attendeelist = new List <String>();
                            for (int i = 0; i < eventItem.Attendees.Count; i++)
                            {
                                if ((attendeeData[i].DisplayName != null) && (attendeeData[i].DisplayName != ""))
                                {
                                    attendeelist.Add(attendeeData[i].DisplayName);
                                }
                            }
                            if (attendeelist.Count >= 2)
                            {
                                for (int i = 0; i < attendeelist.Count; i++)
                                {
                                    attendee = attendee + attendeelist[i];
                                    if (i != attendeelist.Count - 1)
                                    {
                                        attendee = attendee + ";";
                                    }
                                }
                            }
                            else
                            {
                                attendee = "N/A";
                            }
                        }
                        else
                        {
                            attendee = "N/A";
                        }

                        meeting.SetAttendents(attendee);
                        meeting.SetMeetingID(eventItem.Id);
                        meeting.SetParentID(eventItem.ICalUID.ToString());
                        meeting.SetStartTime(when);
                        meeting.SetEndTime(eventItem.End.DateTime.ToString());
                        meeting.SetMeetingTitle(eventItem.Summary);
                        if (DateTime.Compare(meeting.GetEndTime(), DateTime.Now) <= 0)
                        {
                            meetingList.AddLast(meeting);
                        }
                        if (eventItem.Attachments != null)
                        {
                            for (int i = 0; i < eventItem.Attachments.Count; i++)
                            {
                                file = new FileNode();
                                file.SetModifiedTime(eventItem.Start.DateTime.ToString());
                                file.SetFileID(" ");
                                file.SetExtension("GoogleDrive");
                                file.SetFileName(eventItem.Attachments[i].Title);
                                file.SetFilePath(eventItem.Attachments[i].FileUrl);
                                file.AddMeetings(eventItem.Id);
                                file.SetMissing("No");
                                fileList.AddLast(file);
                            }
                        }
                    }
                }
            }catch (Exception e)
            {
                MessageBox.Show("Network connection lost");
            }
        }