public async Task CreateNewMeeting()
        {
            try
            {
                Microsoft.Graph.Event evt = new Microsoft.Graph.Event();

                Location location = new Location();
                location.DisplayName = tbLocation.Text;

                ItemBody body = new ItemBody();
                body.Content = tbBody.Text;
                body.ContentType = BodyType.Html;

                List<Attendee> attendees = new List<Attendee>();
                Attendee attendee = new Attendee();
                EmailAddress email = new EmailAddress();
                email.Address = tbToRecipients.Text;
                attendee.EmailAddress = email;
                attendee.Type = AttendeeType.Required;
                attendees.Add(attendee);

                evt.Subject = tbSubject.Text;
                evt.Body = body;
                evt.Location = location;
                evt.Attendees = attendees;

                DateTimeTimeZone dtStart = new DateTimeTimeZone();
                dtStart.TimeZone = TimeZoneInfo.Local.Id;
                DateTime dts = dtpStartDate.Value.Date + dtpStartTime.Value.TimeOfDay;
                dtStart.DateTime = dts.ToString();
                
                DateTimeTimeZone dtEnd = new DateTimeTimeZone();
                dtEnd.TimeZone = TimeZoneInfo.Local.Id;
                DateTime dte = dtpEndDate.Value.Date + dtpEndTime.Value.TimeOfDay;
                dtEnd.DateTime = dte.ToString();

                evt.Start = dtStart;
                evt.End = dtEnd;
                
                // log the request info
                sdklogger.Log(graphClient.Me.Events.Request().GetHttpRequestMessage().Headers.ToString());
                sdklogger.Log(graphClient.Me.Events.Request().GetHttpRequestMessage().RequestUri.ToString());

                // send the new message
                var createdEvent = await graphClient.Me.Events.Request().AddAsync(evt);

                // log the send and associated id
                sdklogger.Log("Meeting Sent : Id = " + createdEvent.Id);
            }
            catch (Exception ex)
            {
                sdklogger.Log("NewMeetingSend Failed: " + ex.Message);
                sdklogger.Log(ex.Message);
            }
            finally
            {
                // close the form
                Close();
            }
        }
        public async Task <Graph.Event> CreateGroupRepairEventAsync(GraphService graphService, ScheduleRepairModel model)
        {
            var incident = await GetIncidentByIdAsync(model.IncidentId);

            var    property            = incident.sl_propertyID;
            var    unifiedGroupFetcher = graphService.groups.GetById(property.sl_group);
            string body = string.Format("<p>{0}</p><br/><br/><p>Incident ID: <span id='x_IncidentID'>{1}</span><br/><br/>Property ID: <span id='x_PropertyID'>{2}</span></p>",
                                        incident.sl_dispatcherComments,
                                        incident.Id,
                                        property.Id
                                        );

            var newEvent = new Graph.Event
            {
                Subject = "Repair Event",
                Body    = new Graph.ItemBody
                {
                    Content     = body,
                    ContentType = Graph.BodyType.HTML
                },
                ShowAs   = Graph.FreeBusyStatus.Busy,
                Start    = model.TimeSlotsSelectedValue.ToUniversalTime(),
                End      = (model.TimeSlotsSelectedValue.AddHours(1)).ToUniversalTime(),
                Location = new Graph.Location
                {
                    DisplayName = incident.sl_roomID.Title
                },
                Reminder = 60 * 24
            };
            await unifiedGroupFetcher.Events.AddEventAsync(newEvent);

            return(newEvent);
        }
Beispiel #3
0
        public async Task AddEvent(MyEvent myEvent)
        {
            try
            {
                var graphServiceClient = await GetGraphServiceAsync();

                var requestEvent = new Microsoft.Graph.Event
                {
                    Subject = myEvent.Subject,
                    Start   = new DateTimeTimeZone()
                    {
                        DateTime = myEvent.Start.ToString(), TimeZone = DateTimeKind.Local.ToString()
                    },
                    End = new DateTimeTimeZone {
                        DateTime = myEvent.Start.ToString(), TimeZone = DateTimeKind.Local.ToString()
                    },
                    Location = new Microsoft.Graph.Location {
                        DisplayName = myEvent.Location
                    },
                    Body = new ItemBody {
                        Content = myEvent.Body
                    }
                };
                await graphServiceClient.Me.Events.Request().AddAsync(requestEvent);
            }
            catch
            {
            }
            return;
        }
Beispiel #4
0
        public async Task CreateNewMeeting()
        {
            try
            {
                Microsoft.Graph.Event evt = new Microsoft.Graph.Event();

                Location location = new Location();
                location.DisplayName = tbLocation.Text;

                ItemBody body = new ItemBody();
                body.Content     = tbBody.Text;
                body.ContentType = BodyType.Html;

                List <Attendee> attendees = new List <Attendee>();
                Attendee        attendee  = new Attendee();
                EmailAddress    email     = new EmailAddress();
                email.Address         = tbToRecipients.Text;
                attendee.EmailAddress = email;
                attendee.Type         = AttendeeType.Required;
                attendees.Add(attendee);

                evt.Subject   = tbSubject.Text;
                evt.Body      = body;
                evt.Location  = location;
                evt.Attendees = attendees;

                DateTimeTimeZone dtStart = new DateTimeTimeZone();
                dtStart.TimeZone = TimeZoneInfo.Local.Id;
                DateTime dts = dtpStartDate.Value.Date + dtpStartTime.Value.TimeOfDay;
                dtStart.DateTime = dts.ToString();

                DateTimeTimeZone dtEnd = new DateTimeTimeZone();
                dtEnd.TimeZone = TimeZoneInfo.Local.Id;
                DateTime dte = dtpEndDate.Value.Date + dtpEndTime.Value.TimeOfDay;
                dtEnd.DateTime = dte.ToString();

                evt.Start = dtStart;
                evt.End   = dtEnd;

                // log the request info
                sdklogger.Log(graphClient.Me.Events.Request().GetHttpRequestMessage().Headers.ToString());
                sdklogger.Log(graphClient.Me.Events.Request().GetHttpRequestMessage().RequestUri.ToString());

                // send the new message
                var createdEvent = await graphClient.Me.Events.Request().AddAsync(evt);

                // log the send and associated id
                sdklogger.Log("Meeting Sent : Id = " + createdEvent.Id);
            }
            catch (Exception ex)
            {
                sdklogger.Log("NewMeetingSend Failed: " + ex.Message);
                sdklogger.Log(ex.Message);
            }
            finally
            {
                // close the form
                Close();
            }
        }
 private Models.Event ToEvent(Microsoft.Graph.Event v, string feedId)
 {
     return(new Models.Event()
     {
         End = new DateTimeOffset(DateTime.Parse(v.End.DateTime, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal)),
         Start = new DateTimeOffset(DateTime.Parse(v.Start.DateTime, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal)),
         Subject = v.Subject,
         Location = new LocationData()
         {
             Address = v.Location.Address != null ? new AddressData()
             {
                 City = v.Location.Address.City,
                 CountryOrRegion = v.Location.Address.CountryOrRegion,
                 PostalCode = v.Location.Address.PostalCode,
                 State = v.Location.Address.State,
                 Street = v.Location.Address.Street
             } : null,
             Coordinate = v.Location.Coordinates != null &&
                          v.Location.Coordinates.Longitude.HasValue &&
                          v.Location.Coordinates.Longitude.HasValue ? new GeoCoordinate()
             {
                 Latitude = v.Location.Coordinates.Latitude.Value,
                 Longitude = v.Location.Coordinates.Longitude.Value
             } : null,
             Id = v.Location.UniqueId,
             Text = v.Location.DisplayName
         },
         IsAllDay = v.IsAllDay.HasValue && v.IsAllDay.Value,
         Id = v.Id,
         FeedId = feedId
     });
 }
Beispiel #6
0
        public async Task ScheduleRepairAsync(GraphServiceClient graphService, ScheduleRepairModel model)
        {
            var incident = await GetIncidentByIdAsync(model.IncidentId);

            var repairPeople = await GetRepairPeopleByEmailAddressAsync(model.RepairPeopleSelectedValue);

            string body = string.Format("<p>{0}</p><br/><br/><p>Incident ID: <span id='x_IncidentID'>{1}</span><br/><br/>Property ID: <span id='x_PropertyID'>{2}</span></p>",
                                        incident.sl_dispatcherComments,
                                        incident.Id,
                                        incident.sl_propertyID.Id
                                        );

            var attendee = new Graph.Attendee

            {
                EmailAddress = new EmailAddress
                {
                    Address = repairPeople.sl_emailaddress,
                    Name    = repairPeople.Title
                },
                Type   = AttendeeType.Required,
                Status = new ResponseStatus()
            };

            var newEvent = new Graph.Event
            {
                Subject = "Repair Event",
                Body    = new ItemBody
                {
                    Content     = body,
                    ContentType = BodyType.Html
                },
                ShowAs = FreeBusyStatus.Busy,
                Start  = new DateTimeTimeZone
                {
                    DateTime = model.TimeSlotsSelectedValue.ToString(),
                    TimeZone = TimeZone.CurrentTimeZone.StandardName
                },
                End = new DateTimeTimeZone
                {
                    DateTime = (model.TimeSlotsSelectedValue.AddHours(1)).ToString(),
                    TimeZone = TimeZone.CurrentTimeZone.StandardName
                },
                Location = new Location
                {
                    Address = new PhysicalAddress(),
                    //   Coordinates = new outlookGeoCoordinates(),
                    DisplayName = incident.sl_roomID.Title,
                },
                Attendees = new Attendee[] { attendee }
            };

            try
            {
                newEvent = await graphService.Me.Events.Request().AddAsync(newEvent);
            }
            catch
            { }
        }
Beispiel #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EventModel"/> class from MS Graph event.
        /// </summary>
        /// <param name="msftEvent">MS Graph event.</param>
        public EventModel(Microsoft.Graph.Event msftEvent)
        {
            source = EventSource.Microsoft;
            if (msftEvent.OnlineMeetingUrl == string.Empty)
            {
                msftEvent.OnlineMeetingUrl = null;
            }

            msftEventData = msftEvent;
        }
Beispiel #8
0
        /// <summary>
        /// Handles meeting invite and returns a MeetingInfo object representing the meeting.
        /// Webex invites are ignored
        /// </summary>
        /// <param name="inviteEvent"></param>
        /// <param name="appConfig"></param>
        /// <returns></returns>
        public static async Task <Meeting.MeetingInfo> HandleInvite(Microsoft.Graph.Event inviteEvent, IConfigurationRoot appConfig)
        {
            /*If invite is a Webex invite, ignore the event. We are only interested in Outlook invites */
            if (EmailListener.IsValidWebexInvitation(inviteEvent))
            {
                return(null);
            }


            /*Here, a new meeting is created
             * at the time requested in the event received. Metadata can be obtained from the event
             * in this case.*/
            else
            {
                MeetingInfo meetingInfo = new MeetingInfo
                {
                    HostInfo = new WebexHostInfo(appConfig["WEBEX_EMAIL"],
                                                 appConfig["WEBEX_PW"], appConfig["WEBEX_ID"], appConfig["WEBEX_COMPANY"], appConfig["HOST_TIMEZONE"])
                };



                /*Get start and end time in original time zone from the Graph event */
                DateTime meetingStartOrigin = DateTime.Parse(inviteEvent.Start.DateTime);
                DateTime meetingEndOrigin   = DateTime.Parse(inviteEvent.End.DateTime);
                var      originTimeZone     = inviteEvent.Start.TimeZone;

                /*Calculate meeting duration */
                var    meetingDuration    = meetingEndOrigin.Subtract(meetingStartOrigin);
                string meetingDurationStr = meetingDuration.TotalMinutes.ToString();

                /*Convert start time to the WebEx host's time zone */
                DateTime webexStartTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(meetingStartOrigin, originTimeZone, appConfig["HOST_TIMEZONE"]);


                var attendeeNames  = EmailListener.GetAttendeeNames(inviteEvent);
                var attendeeEmails = EmailListener.GetAttendeeEmails(inviteEvent).Distinct().ToList();

                /*Remove the bot email, as the bot must not receive another event. */
                foreach (var curEmail in attendeeEmails)
                {
                    if (curEmail.Equals(appConfig["BOT_Inbox"], StringComparison.OrdinalIgnoreCase))
                    {
                        attendeeEmails.Remove(curEmail);
                        break;
                    }
                }


                meetingInfo = CreateWebexMeeting(inviteEvent.Subject, attendeeNames, attendeeEmails,
                                                 webexStartTime, meetingDurationStr, meetingInfo.HostInfo, inviteEvent.Organizer.EmailAddress);

                return(meetingInfo);
            }
        }
Beispiel #9
0
        public static List <string> GetAttendeeNames(Microsoft.Graph.Event inviteEvent)
        {
            var names = new List <string>();

            foreach (var curAttendee in inviteEvent.Attendees)
            {
                names.Add(curAttendee.EmailAddress.Name);
            }

            return(names);
        }
Beispiel #10
0
        /// <summary>
        /// Get a list of attendee email addresses as strings for the specified Event
        /// </summary>
        /// <param name="inviteEvent"></param>
        /// <returns></returns>
        public static List <string> GetAttendeeEmails(Microsoft.Graph.Event inviteEvent)
        {
            var emails = new List <string>();

            foreach (var curAttendee in inviteEvent.Attendees)
            {
                emails.Add(curAttendee.EmailAddress.Address);
            }

            return(emails);
        }
        public static IObservable <IList <Event> > NewCalendarEvents(this ICalendarRequestBuilder builder, int count, string title)
        {
            var dateTime = DateTime.Now;

            return(Observable.Range(0, count).SelectMany(i => {
                var task = new Event()
                {
                    Subject = $"{i}{title}",
                    End = DateTimeTimeZone.FromDateTime(dateTime), Start = DateTimeTimeZone.FromDateTime(dateTime)
                };

                return builder.Events.Request().AddAsync(task);
            }).Buffer(count));
        }
Beispiel #12
0
        public async Task CreateGroupRepairEventAsync(GraphServiceClient graphService, ScheduleRepairModel model)
        {
            var incident = await GetIncidentByIdAsync(model.IncidentId);

            var    property            = incident.sl_propertyID;
            var    unifiedGroupFetcher = graphService.Groups[property.sl_group];
            string body = string.Format("<p>{0}</p><br/><br/><p>Incident ID: <span id='x_IncidentID'>{1}</span><br/><br/>Property ID: <span id='x_PropertyID'>{2}</span></p>",
                                        incident.sl_dispatcherComments,
                                        incident.Id,
                                        property.Id
                                        );

            var newEvent = new Graph.Event
            {
                Subject = "Repair Event",
                Body    = new ItemBody
                {
                    Content     = body,
                    ContentType = BodyType.Html
                },
                ShowAs = FreeBusyStatus.Busy,
                Start  = new DateTimeTimeZone
                {
                    DateTime = model.TimeSlotsSelectedValue.ToString(),
                    TimeZone = TimeZone.CurrentTimeZone.StandardName
                },
                End = new DateTimeTimeZone
                {
                    DateTime = (model.TimeSlotsSelectedValue.AddHours(1)).ToString(),
                    TimeZone = TimeZone.CurrentTimeZone.StandardName
                },
                Location = new Location
                {
                    DisplayName = incident.sl_roomID.Title,
                    Address     = new PhysicalAddress(),
                    //coordinates = new outlookGeoCoordinates()
                },
                ReminderMinutesBeforeStart = 60 * 24
            };

            try
            {
                newEvent = await unifiedGroupFetcher.Events.Request().AddAsync(newEvent);
            }
            catch
            { }
        }
Beispiel #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EventModel"/> class.
        /// </summary>
        /// <param name="source">the event source.</param>
        public EventModel(EventSource source)
        {
            this.source = source;
            switch (this.source)
            {
            case EventSource.Microsoft:
                msftEventData = new Microsoft.Graph.Event();
                break;

            case EventSource.Google:
                gmailEventData = new Google.Apis.Calendar.v3.Data.Event();
                break;

            default:
                throw new Exception("Event Type not Defined");
            }
        }
        public async Task <Graph.Event> ScheduleRepairAsync(GraphService graphService, ScheduleRepairModel model)
        {
            var incident = await GetIncidentByIdAsync(model.IncidentId);

            var repairPeople = await GetRepairPeopleByEmailAddressAsync(model.RepairPeopleSelectedValue);

            string body = string.Format("<p>{0}</p><br/><br/><p>Incident ID: <span id='x_IncidentID'>{1}</span><br/><br/>Property ID: <span id='x_PropertyID'>{2}</span></p>",
                                        incident.sl_dispatcherComments,
                                        incident.Id,
                                        incident.sl_propertyID.Id
                                        );
            var attendee = new Graph.Attendee
            {
                EmailAddress = new Graph.EmailAddress
                {
                    Address = repairPeople.sl_emailaddress,
                    Name    = repairPeople.Title
                },
                Type = Graph.AttendeeType.Required
            };
            var newEvent = new Graph.Event
            {
                Subject = "Repair Event",
                Body    = new Graph.ItemBody
                {
                    Content     = body,
                    ContentType = Graph.BodyType.HTML
                },
                ShowAs   = Graph.FreeBusyStatus.Busy,
                Start    = model.TimeSlotsSelectedValue.ToUniversalTime(),
                End      = (model.TimeSlotsSelectedValue.AddHours(1)).ToUniversalTime(),
                Location = new Graph.Location
                {
                    DisplayName = incident.sl_roomID.Title
                },
                Attendees = new Graph.Attendee[] { attendee }
            };
            await graphService.Me.Events.AddEventAsync(newEvent);

            return(newEvent);
        }
        private async Task <Graph.Event> CreateEventAsync(GraphService service)
        {
            var group = await service.GetGroupByDisplayNameAsync("Au Residence") as Graph.Group;

            var groupFetcher = service.groups.GetById(group.objectId);

            //var calendar = group.Calendar; // null
            //// Workaround
            //if (calendar == null)
            //    calendar = await groupFetcher.Calendar.ExecuteAsync() as Graph.Calendar;

            var @event = new Graph.Event
            {
                Subject = "Test Event " + DateTime.Now.ToString(),
                Start   = DateTime.Now.AddMinutes(30),
                End     = DateTime.Now.AddMinutes(60),
                Body    = new Graph.ItemBody
                {
                    Content = "Test Event"
                },
                Importance = Graph.Importance.Low,
                Reminder   = 60 * 24
            };

            // The line below will cause an error:
            // Multiple navigation are currently not supported in write requests.
            // await groupFetcher.Calendar.Events.AddEventAsync(@event);

            //calendar.Events.Add(@event);
            //await calendar.SaveChangesAsync();

            await groupFetcher.Events.AddEventAsync(@event);


            return(@event);
        }
 /// <summary>
 /// Adds the specified Event to the collection via POST.
 /// </summary>
 /// <param name="instancesEvent">The Event to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created Event.</returns>
 public System.Threading.Tasks.Task <Event> AddAsync(Event instancesEvent, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <Event>(instancesEvent, cancellationToken));
 }
        public async Task CreateGroupRepairEventAsync(GraphServiceClient graphService, ScheduleRepairModel model)
        {
            var incident = await GetIncidentByIdAsync(model.IncidentId);
            var property = incident.sl_propertyID;
            var unifiedGroupFetcher = graphService.Groups[property.sl_group];
            string body = string.Format("<p>{0}</p><br/><br/><p>Incident ID: <span id='x_IncidentID'>{1}</span><br/><br/>Property ID: <span id='x_PropertyID'>{2}</span></p>",
                    incident.sl_dispatcherComments,
                    incident.Id,
                    property.Id
                );

            var newEvent = new Graph.Event
            {
                Subject = "Repair Event",
                Body = new ItemBody
                {
                    Content = body,
                    ContentType = BodyType.Html
                },
                ShowAs = FreeBusyStatus.Busy,
                Start = new DateTimeTimeZone
                {
                    DateTime = model.TimeSlotsSelectedValue.ToString(),
                    TimeZone = TimeZone.CurrentTimeZone.StandardName
                },
                End = new DateTimeTimeZone
                {
                    DateTime = (model.TimeSlotsSelectedValue.AddHours(1)).ToString(),
                    TimeZone = TimeZone.CurrentTimeZone.StandardName
                },
                Location = new Location
                {
                    DisplayName = incident.sl_roomID.Title,
                    Address = new PhysicalAddress(),
                    //coordinates = new outlookGeoCoordinates()
                },
                ReminderMinutesBeforeStart = 60 * 24
            };

            try
            {
                newEvent = await unifiedGroupFetcher.Events.Request().AddAsync(newEvent);
            }
            catch
            { }
        }
        public async Task ScheduleRepairAsync(GraphServiceClient graphService, ScheduleRepairModel model)
        {
            var incident = await GetIncidentByIdAsync(model.IncidentId);
            var repairPeople = await GetRepairPeopleByEmailAddressAsync(model.RepairPeopleSelectedValue);

            string body = string.Format("<p>{0}</p><br/><br/><p>Incident ID: <span id='x_IncidentID'>{1}</span><br/><br/>Property ID: <span id='x_PropertyID'>{2}</span></p>",
                    incident.sl_dispatcherComments,
                    incident.Id,
                    incident.sl_propertyID.Id
                );

            var attendee = new Graph.Attendee

            {
                EmailAddress = new EmailAddress
                {
                    Address = repairPeople.sl_emailaddress,
                    Name = repairPeople.Title
                },
                Type = AttendeeType.Required,
                Status = new ResponseStatus()
            };

            var newEvent = new Graph.Event
            {
                Subject = "Repair Event",
                Body = new ItemBody
                {
                    Content = body,
                    ContentType = BodyType.Html
                },
                ShowAs = FreeBusyStatus.Busy,
                Start = new DateTimeTimeZone
                {
                    DateTime = model.TimeSlotsSelectedValue.ToString(),
                    TimeZone = TimeZone.CurrentTimeZone.StandardName
                },
                End = new DateTimeTimeZone
                {
                    DateTime = (model.TimeSlotsSelectedValue.AddHours(1)).ToString(),
                    TimeZone = TimeZone.CurrentTimeZone.StandardName
                },
                Location = new Location
                {
                    Address = new PhysicalAddress(),
                 //   Coordinates = new outlookGeoCoordinates(),
                    DisplayName = incident.sl_roomID.Title,

                },
                Attendees = new Attendee[] { attendee }
            };

            try
            {
                newEvent = await graphService.Me.Events.Request().AddAsync(newEvent);
            }
            catch
            { }
        }
 public async Task AddEvent(MyEvent myEvent)
 {
     try
     {
         var graphServiceClient = await GetGraphServiceAsync();
         var requestEvent = new Microsoft.Graph.Event
         {
             Subject = myEvent.Subject,
             Start = new DateTimeTimeZone() { DateTime = myEvent.Start.ToString(), TimeZone = DateTimeKind.Local.ToString() },
             End = new DateTimeTimeZone { DateTime = myEvent.End.ToString(), TimeZone = DateTimeKind.Local.ToString() },
             Location = new Microsoft.Graph.Location { DisplayName = myEvent.Location },
             Body = new ItemBody { Content = myEvent.Body }
         };
         await graphServiceClient.Me.Events.Request().AddAsync(requestEvent);
     }
     catch
     {
     }
     return;
 }
        public async Task<Graph.Event> ScheduleRepairAsync(GraphService graphService, ScheduleRepairModel model)
        {
            var incident = await GetIncidentByIdAsync(model.IncidentId);
            var repairPeople = await GetRepairPeopleByEmailAddressAsync(model.RepairPeopleSelectedValue);

            string body = string.Format("<p>{0}</p><br/><br/><p>Incident ID: <span id='x_IncidentID'>{1}</span><br/><br/>Property ID: <span id='x_PropertyID'>{2}</span></p>",
                    incident.sl_dispatcherComments,
                    incident.Id,
                    incident.sl_propertyID.Id
                );
            var attendee = new Graph.Attendee
            {
                EmailAddress = new Graph.EmailAddress
                {
                    Address = repairPeople.sl_emailaddress,
                    Name = repairPeople.Title
                },
                Type = Graph.AttendeeType.Required
            };
            var newEvent = new Graph.Event
            {
                Subject = "Repair Event",
                Body = new Graph.ItemBody
                {
                    Content = body,
                    ContentType = Graph.BodyType.HTML
                },
                ShowAs = Graph.FreeBusyStatus.Busy,
                Start = model.TimeSlotsSelectedValue.ToUniversalTime(),
                End = (model.TimeSlotsSelectedValue.AddHours(1)).ToUniversalTime(),
                Location = new Graph.Location
                {
                    DisplayName = incident.sl_roomID.Title
                },
                Attendees = new Graph.Attendee[] { attendee }
            };
            await graphService.Me.Events.AddEventAsync(newEvent);

            return newEvent;
        }
Beispiel #21
0
        static EventWorkflowHelperData()
        {
            eventEntity = new EventEntity
            {
                EventId    = "ad4b2b43-1cb5-408d-ab8a-17e28edac2baz-1234-2345",
                TeamId     = "ad4b2b43-1cb5-408d-ab8a-17e28edac2baz-1234",
                Audience   = 3,
                CategoryId = "088ddf0d-4deb-4e95-b1f3-907fc4511b02",
                AutoRegisteredAttendees = "",
                CategoryName            = "Test_Category",
                CreatedBy                   = "Jack",
                CreatedOn                   = new DateTime(2020, 09, 24),
                Description                 = "Teams Event",
                EndDate                     = new DateTime(2020, 09, 25),
                EndTime                     = new DateTime(2020, 09, 25),
                ETag                        = "",
                GraphEventId                = "088ddf0d-4deb-4e95-b1f3-907fc4511b02g",
                IsAutoRegister              = false,
                IsRegistrationClosed        = false,
                IsRemoved                   = false,
                MandatoryAttendees          = "",
                MaximumNumberOfParticipants = 10,
                MeetingLink                 = "",
                Name                        = "Mandaotory Training Event",
                NumberOfOccurrences         = 1,
                OptionalAttendees           = "",
                Photo                       = "https://testurl/img.png",
                StartDate                   = new DateTime(2020, 09, 25),
                StartTime                   = new DateTime(2020, 09, 25),
                UpdatedBy                   = "Jack",
                Venue                       = "",
                SelectedUserOrGroupListJSON = "",
                RegisteredAttendeesCount    = 0,
                Type                        = 0,
                RegisteredAttendees         = ""
            };

            validEventEntity = new EventEntity
            {
                EventId    = "ad4b2b43-1cb5-408d-ab8a-17e28edac2baz-1234-2345",
                TeamId     = "ad4b2b43-1cb5-408d-ab8a-17e28edac2baz-1234",
                Audience   = 1,
                CategoryId = "088ddf0d-4deb-4e95-b1f3-907fc4511b02",
                AutoRegisteredAttendees = "",
                CategoryName            = "Test_Category",
                CreatedBy                   = "Jack",
                CreatedOn                   = DateTime.UtcNow,
                Description                 = "Teams Event",
                EndDate                     = DateTime.UtcNow.AddDays(4).Date,
                EndTime                     = DateTime.UtcNow.AddDays(4).Date,
                ETag                        = "",
                GraphEventId                = "088ddf0d-4deb-4e95-b1f3-907fc4511b02g",
                IsAutoRegister              = false,
                IsRegistrationClosed        = false,
                IsRemoved                   = false,
                MandatoryAttendees          = "",
                MaximumNumberOfParticipants = 10,
                MeetingLink                 = "",
                Name                        = "Mandaotory Training Event",
                NumberOfOccurrences         = 1,
                OptionalAttendees           = "",
                Photo                       = "https://www.testurl.com/img.png",
                StartDate                   = DateTime.UtcNow.AddDays(2).Date,
                StartTime                   = DateTime.UtcNow.AddDays(2).Date,
                UpdatedBy                   = "Jack",
                Venue                       = "",
                SelectedUserOrGroupListJSON = "",
                RegisteredAttendeesCount    = 0,
                Type                        = 2,
                RegisteredAttendees         = ""
            };

            eventEntities = new List <EventEntity>()
            {
                new EventEntity
                {
                    EventId      = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-888",
                    CategoryId   = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba",
                    CategoryName = ""
                },
                new EventEntity
                {
                    EventId      = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999",
                    CategoryId   = "ad4b2b43-1cb5-408d-ab8a-17e28edac3ba",
                    CategoryName = ""
                }
            };

            category = new Category
            {
                CategoryId  = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba",
                Name        = "Test_Category_1",
                Description = "Description",
                CreatedBy   = "ad4b2b43-1cb5-408d-ab8a-17e28edacabc",
                CreatedOn   = DateTime.UtcNow,
                UpdatedOn   = DateTime.UtcNow,
            };

            categoryList = new List <Category>
            {
                new Category
                {
                    CategoryId  = "ad4b2b43-1cb5-408d-ab8a-17e28edac1ba",
                    Name        = "Test_Category_1",
                    Description = "Description",
                    CreatedBy   = "ad4b2b43-1cb5-408d-ab8a-17e28edacabc",
                    CreatedOn   = DateTime.UtcNow,
                    UpdatedOn   = DateTime.UtcNow,
                    IsInUse     = false,
                },
                new Category
                {
                    CategoryId  = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba",
                    Name        = "Test_Category_1",
                    Description = "Description",
                    CreatedBy   = "ad4b2b43-1cb5-408d-ab8a-17e28edacabc",
                    CreatedOn   = DateTime.UtcNow,
                    UpdatedOn   = DateTime.UtcNow,
                    IsInUse     = false,
                },
                new Category
                {
                    CategoryId  = "ad4b2b43-1cb5-408d-ab8a-17e28edac3ba",
                    Name        = "Test_Category_1",
                    Description = "Description",
                    CreatedBy   = "ad4b2b43-1cb5-408d-ab8a-17e28edacabc",
                    CreatedOn   = DateTime.UtcNow,
                    UpdatedOn   = DateTime.UtcNow,
                    IsInUse     = false,
                }
            };

            teamEvent = new Event
            {
                Subject = "Teams Event",
                Body    = new ItemBody
                {
                    ContentType = BodyType.Html,
                    Content     = eventEntity.Type == (int)EventType.LiveEvent ?
                                  $"{eventEntity.Description}<br/><br/><a href='{eventEntity.MeetingLink}'>{eventEntity.MeetingLink}</a>" :
                                  eventEntity.Description,
                },
                Attendees        = new List <Attendee>(),
                OnlineMeetingUrl = eventEntity.Type == (int)EventType.LiveEvent ? eventEntity.MeetingLink : null,
                IsReminderOn     = true,
                Location         = eventEntity.Type == (int)EventType.InPerson ? new Location
                {
                    Address = new PhysicalAddress {
                        Street = eventEntity.Venue
                    },
                }
                    : null,
                AllowNewTimeProposals = false,
                IsOnlineMeeting       = true,
                OnlineMeetingProvider = OnlineMeetingProviderType.TeamsForBusiness,
                Id = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-rrtyy"
            };

            lndTeam = new LnDTeam
            {
                ETag         = "",
                PartitionKey = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999",
                TeamId       = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-000",
                RowKey       = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-000"
            };

            graphUser = new Graph.User
            {
                DisplayName       = "Jack",
                UserPrincipalName = "Jack",
                Id   = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-001",
                Mail = "*****@*****.**"
            };

            graphUsers = new List <Graph.User>()
            {
                new Graph.User
                {
                    DisplayName       = "Jack",
                    UserPrincipalName = "Jack",
                    Id   = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-001",
                    Mail = "*****@*****.**"
                },
                new Graph.User
                {
                    DisplayName       = "Jack",
                    UserPrincipalName = "Jack",
                    Id   = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-002",
                    Mail = "*****@*****.**"
                },
                new Graph.User
                {
                    DisplayName       = "Jack",
                    UserPrincipalName = "Jack",
                    Id   = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-003",
                    Mail = "*****@*****.**"
                }
            };

            graphGroups = new List <Graph.Group>()
            {
                new Graph.Group
                {
                    DisplayName = "Jack",
                    Id          = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-001",
                    Mail        = "*****@*****.**"
                },
                new Graph.Group
                {
                    DisplayName = "Jack",
                    Id          = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-002",
                    Mail        = "*****@*****.**"
                },
                new Graph.Group
                {
                    DisplayName = "Jack",
                    Id          = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-003",
                    Mail        = "*****@*****.**"
                }
            };

            graphGroupDirectoryObject = new List <Graph.DirectoryObject>()
            {
                new Graph.DirectoryObject
                {
                    Id = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-001"
                },
                new Graph.DirectoryObject
                {
                    Id = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-002"
                },
                new Graph.DirectoryObject
                {
                    Id = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-003"
                }
            };

            fileInfo = new FormFile(new MemoryStream(), 1, 1, "sample.jpeg", "sample.jpeg");

            teamsChannelAccount = new List <TeamsChannelAccount>()
            {
                new TeamsChannelAccount
                {
                    GivenName         = "sam",
                    UserPrincipalName = "s"
                },
                new TeamsChannelAccount
                {
                    GivenName         = "jack",
                    UserPrincipalName = "j"
                }
            };

            teamEvent = new Event
            {
                Subject = "Teams Event",
                Body    = new ItemBody
                {
                    ContentType = BodyType.Html,
                    Content     = eventEntity.Type == (int)EventType.LiveEvent ?
                                  $"{eventEntity.Description}<br/><br/><a href='{eventEntity.MeetingLink}'>{eventEntity.MeetingLink}</a>" :
                                  eventEntity.Description,
                },
                Attendees        = new List <Attendee>(),
                OnlineMeetingUrl = eventEntity.Type == (int)EventType.LiveEvent ? eventEntity.MeetingLink : null,
                IsReminderOn     = true,
                Location         = eventEntity.Type == (int)EventType.InPerson ? new Location
                {
                    Address = new PhysicalAddress {
                        Street = eventEntity.Venue
                    },
                }
                    : null,
                AllowNewTimeProposals = false,
                IsOnlineMeeting       = true,
                OnlineMeetingProvider = OnlineMeetingProviderType.TeamsForBusiness,
                Id = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-rrtyy"
            };

            lndTeam = new LnDTeam
            {
                ETag         = "",
                PartitionKey = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999",
                TeamId       = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-000",
                RowKey       = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-000"
            };

            graphUser = new Graph.User
            {
                DisplayName       = "Jack",
                UserPrincipalName = "Jack",
                Id   = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-001",
                Mail = "*****@*****.**"
            };

            graphUsers = new List <Graph.User>()
            {
                new Graph.User
                {
                    DisplayName       = "Jack",
                    UserPrincipalName = "Jack",
                    Id   = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-001",
                    Mail = "*****@*****.**"
                },
                new Graph.User
                {
                    DisplayName       = "Jack",
                    UserPrincipalName = "Jack",
                    Id   = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-002",
                    Mail = "*****@*****.**"
                },
                new Graph.User
                {
                    DisplayName       = "Jack",
                    UserPrincipalName = "Jack",
                    Id   = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-003",
                    Mail = "*****@*****.**"
                }
            };

            graphGroups = new List <Graph.Group>()
            {
                new Graph.Group
                {
                    DisplayName = "Jack",
                    Id          = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-001",
                    Mail        = "*****@*****.**"
                },
                new Graph.Group
                {
                    DisplayName = "Jack",
                    Id          = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-002",
                    Mail        = "*****@*****.**"
                },
                new Graph.Group
                {
                    DisplayName = "Jack",
                    Id          = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-003",
                    Mail        = "*****@*****.**"
                }
            };

            graphGroupDirectoryObject = new List <Graph.DirectoryObject>()
            {
                new Graph.DirectoryObject
                {
                    Id = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-001"
                },
                new Graph.DirectoryObject
                {
                    Id = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-002"
                },
                new Graph.DirectoryObject
                {
                    Id = "ad4b2b43-1cb5-408d-ab8a-17e28edac2ba-445567-999-003"
                }
            };

            fileInfo = new FormFile(new MemoryStream(), 1, 1, "sample.jpeg", "sample.jpeg");

            teamsChannelAccount = new List <TeamsChannelAccount>()
            {
                new TeamsChannelAccount
                {
                    GivenName         = "sam",
                    UserPrincipalName = "s"
                },
                new TeamsChannelAccount
                {
                    GivenName         = "jack",
                    UserPrincipalName = "j"
                }
            };
        }
        public async Task<Graph.Event> CreateGroupRepairEventAsync(GraphService graphService, ScheduleRepairModel model)
        {
            var incident = await GetIncidentByIdAsync(model.IncidentId);
            var property = incident.sl_propertyID;
            var unifiedGroupFetcher = graphService.groups.GetById(property.sl_group);
            string body = string.Format("<p>{0}</p><br/><br/><p>Incident ID: <span id='x_IncidentID'>{1}</span><br/><br/>Property ID: <span id='x_PropertyID'>{2}</span></p>",
                    incident.sl_dispatcherComments,
                    incident.Id,
                    property.Id
                );

            var newEvent = new Graph.Event
            {
                Subject = "Repair Event",
                Body = new Graph.ItemBody
                {
                    Content = body,
                    ContentType = Graph.BodyType.HTML
                },
                ShowAs = Graph.FreeBusyStatus.Busy,
                Start = model.TimeSlotsSelectedValue.ToUniversalTime(),
                End = (model.TimeSlotsSelectedValue.AddHours(1)).ToUniversalTime(),
                Location = new Graph.Location
                {
                    DisplayName = incident.sl_roomID.Title
                },
                Reminder = 60 * 24
            };
            await unifiedGroupFetcher.Events.AddEventAsync(newEvent);

            return newEvent;
        }
 /// <summary>
 /// Adds the specified Event to the collection via POST.
 /// </summary>
 /// <param name="instancesEvent">The Event to add.</param>
 /// <returns>The created Event.</returns>
 public System.Threading.Tasks.Task <Event> AddAsync(Event instancesEvent)
 {
     return(this.AddAsync(instancesEvent, CancellationToken.None));
 }