Esempio n. 1
0
        public static void testEvent()
        {
            GService g = new GService();
            // these always need to be changed before testing
            string uuid         = "UUIDTESTefefERezfzesefeKE12&";
            string uuid2        = "efeefefe";
            string uuid3        = "efefefefefef";
            string calendarName = "test12345634567VIJF";
            Person testPerson   = makePerson("testName2", "TestLastName", "*****@*****.**");

            Attendee.InewAttendee(testPerson, uuid, "1");
            IList <EventAttendee> attendees = new List <EventAttendee>();
            EventAttendee         test      = new EventAttendee()
            {
                //Email = "testname2",
                DisplayName = "*****@*****.**"
            };

            IList <string> UUIDS = new List <string>();

            UUIDS.Add(testPerson.UserDefined[0].Value);

            Console.WriteLine("attendee created");
            Console.ReadKey();

            //create event
            //create calendar
            var testCalendar = Calendarss.InewCalendar(makeCalendar(calendarName), uuid3, "1");

            DateTime start = new DateTime(2019, 5, 7, 14, 30, 0);
            DateTime end   = new DateTime(2019, 5, 7, 15, 30, 0);

            Google.Apis.Calendar.v3.Data.Event ev = makeEvent("1223432123HG23F2V32H2", "tesstlocation", "testDisc", start, end, convertPersonToAttendee(UUIDS));
            Eventss.InewEvent(ev, uuid3, uuid2, "1");
            Console.WriteLine("event created");
            Console.ReadKey();

            //update event
            ev.Summary = "newTestsSummery";

            Eventss.IupdateEventById(ev, uuid3, uuid2, "2");
            Console.WriteLine("event updated");
            Console.ReadKey();

            //delete event
            Eventss.IDeleteEventById(uuid2, uuid3);
            Calendarss.IdeleteCalendarById(uuid3);
            Console.WriteLine("event deleted");
            Console.ReadKey();
        }
Esempio n. 2
0
        // Create an event on an existing calendar using PlanningLibrary (layered code on google calendar)
        public void createEvent(XmlDocument doc)
        {
            // Parsing data from XmlDocument
            XmlNodeList titel      = doc.GetElementsByTagName("titel");
            XmlNodeList lokaal     = doc.GetElementsByTagName("lokaal");
            XmlNodeList desc       = doc.GetElementsByTagName("desc");
            XmlNodeList start      = doc.GetElementsByTagName("start");
            XmlNodeList end        = doc.GetElementsByTagName("end");
            XmlNodeList CalendarID = doc.GetElementsByTagName("event_UUID");// event_UUID is the field to retrieve a CALENDAR id and NOT event
            XmlNodeList eventID    = doc.GetElementsByTagName("session_UUID");
            XmlNodeList xmlVersion = doc.GetElementsByTagName("version");

            // Logging parsed data
            Console.WriteLine(titel[0].InnerText);
            Console.WriteLine(lokaal[0].InnerText);
            Console.WriteLine(desc[0].InnerText);
            Console.WriteLine(start[0].InnerText);
            Console.WriteLine(end[0].InnerText);
            Console.WriteLine(CalendarID[0].InnerText);
            Console.WriteLine(eventID[0].InnerText);
            Console.WriteLine(xmlVersion[0].InnerText);

            // Reformatting time to google api time
            // Null iformatprovider argument as string is time represenation
            DateTime event_begin = DateTime.ParseExact(start[0].InnerText, "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);
            DateTime event_end   = DateTime.ParseExact(end[0].InnerText, "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);

            // Logging parsed data which has been reformatted
            Console.WriteLine(event_begin);
            Console.WriteLine(event_end);

            // Create a new <google.api> event, fields filled in with parsed data from XmlDocument
            Event e = new Event();

            e.Summary     = titel[0].InnerText;
            e.Location    = lokaal[0].InnerText;
            e.Description = desc[0].InnerText;
            e.Start       = new EventDateTime {
                DateTime = event_begin
            };                                                      //conversie <System Datetime> to <Google Apis Calendar V3 Data EventDateTime>
            e.End = new EventDateTime {
                DateTime = event_end
            };                                                  //conversie <System Datetime> to <Google Apis Calendar V3 Data EventDateTime>

            // List which will contain every user (attendee or employee) that was in the XmlDocument
            List <string> people = new List <string>();

            // Iterate every user into the List
            foreach (XmlNode speaker in doc.SelectNodes("//users/UUID"))
            {
                var person = speaker.InnerText;

                Console.WriteLine(person);

                people.Add(person);
            }

            // Using PlanningLibrary method which awaits a List of users and convert it to Attendees (attendees are added to an event and must be existing in google contacts)
            e.Attendees = PlanningLibrary.Program.convertPersonToAttendee(people);


            // Creates a new event in a specified calendar(no value, default primary calendar), filled with parsed data from XmlDocument and finally sent with PlanningLibrary method.
            // Expects a <google.api> event, calendar UUID, event UUID, version
            Eventss.InewEvent(e, CalendarID[0].InnerText, eventID[0].InnerText, xmlVersion[0].InnerText);

            Console.WriteLine("Session successfully created");
            ControlRoom.SendConfirmationMessage("Planning: Session successfully created");
        }