예제 #1
0
        public void ProcessTest()
        {
            File.Delete("Settings.xml");
            File.Delete("meetings.xml");
            File.Delete("files.xml");
            MeetingNode node = new MeetingNode();

            node.SetStartTime("2017/01/01 12:00:00");
            node.SetEndTime("2017/12/12 12:00:00");
            node.SetMeetingID("12345");
            node.SetMeetingTitle("Hello");
            FileNode file1 = new FileNode();
            FileNode file2 = new FileNode();

            file1.SetCreatedTime("2017/03/03 12:00:00");
            file1.SetFileName("test1");
            file2.SetCreatedTime("2016/03/03 12:00:00");
            file1.SetFileName("test2");
            LinkedList <FileNode> fn = new LinkedList <FileNode>();

            fn.AddLast(file1);
            fn.AddLast(file2);
            XMLProcessor processor = new XMLProcessor();

            processor.FirstUse();
            processor.SetFileList(fn);
            processor.ProcessFileWithMeetingNode(node);
            processor.Write();
        }
        public void GetandSetEndTimeTest()
        {
            MeetingNode meeting0 = new MeetingNode(mTitle, mID, sTime, "0001/01/01 00:00:00", PID, Attendents);
            MeetingNode meeting  = new MeetingNode(mTitle, mID, sTime, eTime, PID, Attendents);

            //test empty
            String actualsTime0 = meeting0.GetEndTimeS();

            Assert.AreEqual("", actualsTime0, "Actual meeting end time does not equal to empty, Actual:" + actualsTime0);

            //test get
            String actualsTime1 = meeting.GetEndTimeS();

            Assert.AreEqual(eTime, actualsTime1, "Expected: " + eTime + "Actual: " + actualsTime1);

            //test set
            meeting.SetEndTime("2017/04/02 18:00:30");
            String actualsTime2 = meeting.GetEndTimeS();

            Assert.AreEqual("2017/04/02 18:00:30", actualsTime2, "Actual meeting end time does not equal to 2017/04/02 18:00:30");
        }
예제 #3
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");
            }
        }