Ejemplo n.º 1
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
            { }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create online event
        /// </summary>
        /// <param name="graphServiceClient">Graph service client </param>
        /// <param name="eventViewModel">Event view details</param>
        /// <param name="participants">Participant details</param>
        /// <returns>Event details</returns>
        public async Task <Event> CreateOnlineEvent(GraphServiceClient graphServiceClient, EventViewModel eventViewModel, List <Models.Participant> participants)
        {
            List <Microsoft.Graph.Attendee> attendees = new List <Microsoft.Graph.Attendee>();

            foreach (var participant in participants)
            {
                var attendee = new Microsoft.Graph.Attendee
                {
                    EmailAddress = new EmailAddress
                    {
                        Address = participant.EmailId,
                        Name    = participant.Name
                    },
                    Type = AttendeeType.Required
                };
                attendees.Add(attendee);
            }

            var @event = new Event
            {
                Subject = eventViewModel.Subject,
                Body    = new ItemBody
                {
                    ContentType = BodyType.Html,
                    Content     = eventViewModel.Subject
                },
                Start = new DateTimeTimeZone
                {
                    DateTime = eventViewModel.StartDate.ToString("yyyy-MM-ddTHH:mm:ss"),
                    TimeZone = "UTC"
                },
                End = new DateTimeTimeZone
                {
                    DateTime = eventViewModel.EndDate.ToString("yyyy-MM-ddTHH:mm:ss"),
                    TimeZone = "UTC"
                },
                Location = new Location
                {
                    DisplayName = "Teams meeting"
                },

                Attendees             = attendees,
                IsOnlineMeeting       = true,
                OnlineMeetingProvider = OnlineMeetingProviderType.TeamsForBusiness
            };

            try
            {
                return(await graphServiceClient.Me.Events
                       .Request()
                       .AddAsync(@event));
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message + ' ' + e.StackTrace);
                return(null);
            }
        }
        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);
        }
        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;
        }
        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
            { }
        }