/// <summary> /// Unknown Visitor incident. /// </summary> /// <param name="incidentRequestData">The incident data.</param> /// <returns>The task for await.</returns> public async Task <ICall> CallUnknownVisitorAsync(IncidentRequestData incidentRequestData) { // A tracking id for logging purposes. Helps identify this call in logs. var scenarioId = string.IsNullOrEmpty(incidentRequestData.ScenarioId) ? Guid.NewGuid() : new Guid(incidentRequestData.ScenarioId); string incidentId = Guid.NewGuid().ToString(); var incidentStatusData = new IncidentStatusData(incidentId, incidentRequestData); var incident = this.IncidentStatusManager.AddIncident(incidentId, incidentStatusData); var receptionObjectId = incidentRequestData.ObjectIds.First(); // call the receptionist var buildingObjectId = incidentRequestData.ObjectIds.Last(); // call the building var receptionTarget = new ParticipantInfo { Identity = new IdentitySet { User = new Identity { Id = receptionObjectId, }, }, }; var buildingTarget = new ParticipantInfo { Identity = new IdentitySet { User = new Identity { Id = buildingObjectId, }, }, }; var call = new Call { Targets = new[] { receptionTarget }, MediaConfig = new ServiceHostedMediaConfig { }, RequestedModalities = new List <Modality> { Modality.Video }, TenantId = incidentRequestData.TenantId, }; // call the receptionist var statefulCall = await this.Client.Calls().AddAsync(call, scenarioId: scenarioId).ConfigureAwait(false); // add the building var addParticipantRequestData = new AddParticipantRequestData() { ObjectId = buildingObjectId, }; await this.MyAddParticipantAsync(statefulCall.Id, addParticipantRequestData).ConfigureAwait(false); this.graphLogger.Info($"Call creation complete: {statefulCall.Id}"); // return botMeetingCall; return(null); }
/// <summary> /// add current responder to incident meeting as participant. /// </summary> private void TransferToIncidentMeeting() { Task.Run(async() => { try { var incidentMeetingCallId = this.statusData?.BotMeetingCallId; var responderStatusData = this.statusData?.GetResponder(this.responderId); if (incidentMeetingCallId != null && responderStatusData != null) { var addParticipantRequestData = new AddParticipantRequestData() { ObjectId = responderStatusData.ObjectId, ReplacesCallId = responderStatusData.NotificationCallId, }; await this.Bot.AddParticipantAsync(incidentMeetingCallId, addParticipantRequestData).ConfigureAwait(false); this.Logger.Info("Finished to transfer to incident meeting. "); } else { this.Logger.Warn( $"Tried to transfer to incident meeting but needed info are not valid. Meeting call-id: {incidentMeetingCallId}; status data: {responderStatusData}"); } } catch (Exception ex) { this.Logger.Error(ex, $"Failed to transfer to incident meeting."); throw; } }); }
/// <summary> /// add current responder to incident meeting as participant. /// </summary> private void TransferToIncidentMeeting() { Task.Run(async() => { try { var incidentMeetingCallId = this.statusData?.BotMeetingCallId; var responderStatusData = this.statusData?.GetResponder(this.responderId); if (incidentMeetingCallId != null && responderStatusData != null) { var addParticipantRequestData = new AddParticipantRequestData() { ObjectId = responderStatusData.ObjectId, ReplacesCallId = responderStatusData.NotificationCallId, }; await this.Bot.AddParticipantAsync(incidentMeetingCallId, addParticipantRequestData).ConfigureAwait(false); } } catch (Exception ex) { throw; } }); }
public async Task <IActionResult> AddParticipantAsync(string callLegId, [FromBody] AddParticipantRequestData addParticipantBody) { Validator.IsTrue(Guid.TryParse(callLegId, out Guid result), nameof(callLegId), "call leg id must be a valid guid."); Validator.NotNull(addParticipantBody, nameof(addParticipantBody)); try { await this.bot.AddParticipantAsync(callLegId, addParticipantBody).ConfigureAwait(false); return(this.Ok()); } catch (Exception e) { return(this.Exception(e)); } }
/// <summary> /// Adds participants asynchronously. /// </summary> /// <param name="callLegId">which call to add participants.</param> /// <param name="addParticipantBody">The add participant body.</param> /// <returns>The <see cref="Task"/>.</returns> public async Task AddParticipantAsync(string callLegId, AddParticipantRequestData addParticipantBody) { if (string.IsNullOrEmpty(callLegId)) { throw new ArgumentNullException(nameof(callLegId)); } if (string.IsNullOrEmpty(addParticipantBody.ObjectId)) { throw new ArgumentNullException(nameof(addParticipantBody.ObjectId)); } var target = new IdentitySet { User = new Identity { Id = addParticipantBody.ObjectId, }, }; await this.Client.Calls()[callLegId].Participants .InviteAsync(target, addParticipantBody.ReplacesCallId) .ConfigureAwait(false); }