Пример #1
0
        public async Task <ActionResult> InboundVoice([FromQuery] TwilioGatherRequest request)
        {
            if (request == null || string.IsNullOrWhiteSpace(request.To) || string.IsNullOrWhiteSpace(request.From))
            {
                return(BadRequest());
            }

            var response     = new VoiceResponse();
            var departmentId = await _departmentSettingsService.GetDepartmentIdByTextToCallNumberAsync(request.To.Replace("+", ""));

            if (departmentId.HasValue)
            {
                var authroized = await _limitsService.CanDepartmentProvisionNumberAsync(departmentId.Value);


                request.From.Replace("+", "");
                if (authroized)
                {
                    var department = await _departmentsService.GetDepartmentByIdAsync(departmentId.Value, false);

                    UserProfile profile = null;
                    profile = await _userProfileService.GetProfileByMobileNumberAsync(request.From.Replace("+", ""));

                    if (profile == null)
                    {
                        profile = await _userProfileService.GetProfileByHomeNumberAsync(request.From.Replace("+", ""));
                    }

                    if (department != null && profile != null)
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.Append($@"Hello {profile.FirstName}, this is the Automated Voice System for {department.Name}. Please select from the following options. 
											To list current active calls press 1, 
											To list current user statuses press 2, 
											To list current unit statuses press 3, 
											To list upcoming Calendar events press 4,
											To list upcoming Shifts press 5"                                            );

                        response.Say(sb.ToString());
                    }
                    else
                    {
                        response.Say("Thank you for calling Raesgrid, the only complete software solution for first responders, automated personnel system. The number you called is not tied to an active department or the department doesn't have this feature enabled. Goodbye.").Hangup();
                    }
                }
                else
                {
                    response.Say("Thank you for calling Raesgrid, the only complete software solution for first responders, automated personnel system. The number you called is not tied to an active department or the department doesn't have this feature enabled. Goodbye.").Hangup();
                }
            }
            else
            {
                response.Say("Thank you for calling Raesgrid, the only complete software solution for first responders, automated personnel system. The number you called is not tied to an active department or the department doesn't have this feature enabled. Goodbye.").Hangup();
            }

            //return Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter());
            return(Ok(new StringContent(response.ToString(), Encoding.UTF8, "application/xml")));
        }
Пример #2
0
        public async Task <ActionResult> VoiceCallAction(string userId, int callId, [FromQuery] TwilioGatherRequest twilioRequest)
        {
            var response = new VoiceResponse();

            if (twilioRequest.Digits == "0")
            {
                response.Redirect(new Uri(string.Format("{0}/Twilio/VoiceCall?userId={1}&callId={2}", Config.SystemBehaviorConfig.ResgridApiBaseUrl, userId, callId)), "GET");
            }
            else if (twilioRequest.Digits == "1")
            {
                var call = await _callsService.GetCallByIdAsync(callId);

                await _actionLogsService.SetUserActionAsync(userId, call.DepartmentId, (int)ActionTypes.RespondingToScene, null, call.CallId);

                response.Say("You have been marked responding to the scene, goodbye.").Hangup();
            }
            else
            {
                var call = await _callsService.GetCallByIdAsync(callId);

                var stations = await _departmentGroupsService.GetAllStationGroupsForDepartmentAsync(call.DepartmentId);

                int index = int.Parse(twilioRequest.Digits) - 2;

                if (index >= 0 && index < 8)
                {
                    var station = stations[index];

                    if (station != null)
                    {
                        await _actionLogsService.SetUserActionAsync(userId, call.DepartmentId, (int)ActionTypes.RespondingToStation, null,
                                                                    station.DepartmentGroupId);

                        response.Say(string.Format("You have been marked responding to {0}, goodbye.", station.Name)).Hangup();
                    }
                }
            }

            //return Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter());
            //return Ok(new StringContent(response.ToString(), Encoding.UTF8, "application/xml"));
            return(new ContentResult
            {
                Content = response.ToString(),
                ContentType = "application/xml",
                StatusCode = 200
            });
        }
Пример #3
0
        public HttpResponseMessage VoiceCallAction(string userId, int callId, [FromUri] TwilioGatherRequest twilioRequest)
        {
            var response = new TwilioResponse();

            if (twilioRequest.Digits == "0")
            {
                response.Redirect(string.Format("{0}/Twilio/VoiceCall?userId={1}&callId={2}", Config.SystemBehaviorConfig.ResgridApiBaseUrl, userId, callId), "GET");
            }
            else if (twilioRequest.Digits == "1")
            {
                var call = _callsService.GetCallById(callId);
                _actionLogsService.SetUserAction(userId, call.DepartmentId, (int)ActionTypes.RespondingToScene, null, call.CallId);

                response.Say("You have been marked responding to the scene, goodbye.").Hangup();
            }
            else
            {
                var call     = _callsService.GetCallById(callId);
                var stations = _departmentGroupsService.GetAllStationGroupsForDepartment(call.DepartmentId);

                int index = int.Parse(twilioRequest.Digits) - 2;

                if (index >= 0 && index < 8)
                {
                    var station = stations[index];

                    if (station != null)
                    {
                        _actionLogsService.SetUserAction(userId, call.DepartmentId, (int)ActionTypes.RespondingToStation, null,
                                                         station.DepartmentGroupId);

                        response.Say(string.Format("You have been marked responding to {0}, goodbye.", station.Name)).Hangup();
                    }
                }
            }

            return(Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter()));
        }