예제 #1
0
        public void GetandAddMeetingListTest()
        {
            FileNode file0 = new FileNode(fileName, fileID, modifiedTime, createdTime, executeTime, extension, filePath);
            FileNode file = new FileNode(fileName, fileID, modifiedTime, createdTime, executeTime, extension, filePath);

            //test get empty list
            String actualmeetingList0 = file0.GetMeetingListS();
            Assert.AreEqual("", actualmeetingList0, "The actual meeting list is not empty");

            //test add string value
            file0.AddMeetings("01");
            String actualmeetingList2 = file0.GetMeetingListS();
            Assert.AreEqual("01", actualmeetingList2, "The string value 01 was not added into the list successfully");

            //test add int value
            file.AddMeetings(2);
            String actualmeetingList3 = file.GetMeetingListS();
            Assert.AreEqual("2", actualmeetingList3, "The int value 2 was not added into the list successfully");

            //test add multiple values
            file.AddMeetings("3");
            file.AddMeetings("4");
            LinkedList<String> actualmeetingList4 = file.GetMeetingList();
            LinkedList<String> expectedmeetingList4 = new LinkedList<String>();
            expectedmeetingList4.AddLast("2");
            expectedmeetingList4.AddLast("3");
            expectedmeetingList4.AddLast("4");
            for (int n = 0; n < actualmeetingList4.Count; n++)
            {
                if (n == 0)
                {
                    Assert.AreEqual(expectedmeetingList4.First.Value, actualmeetingList4.First.Value, "1st element in two lists are not equal");
                }
                if (n == 1)
                {
                    Assert.AreEqual(expectedmeetingList4.First.Next.Value, actualmeetingList4.First.Next.Value, "2nd element in two lists are not equal");
                }
                if (n == 2)
                {
                    Assert.AreEqual(expectedmeetingList4.First.Next.Next.Value, actualmeetingList4.First.Next.Next.Value, "3rd element in two lists are not equal");
                }
            }
        }
예제 #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");
            }
        }