Esempio n. 1
0
        private ScheduleHangUpResponse ScheduleHangUpCall(ScheduleHangUpRequest request)
        {
            ScheduleHangUpResponse response = new ScheduleHangUpResponse();

            if (string.IsNullOrEmpty(request.CallUUID))
            {
                response.Message = "CallUUID Parameter must be present";
                response.Result = false;
            }
            else if (string.IsNullOrEmpty(request.Time))
            {
                response.Message = "Time Parameter must be present";
            }
            else
            {
                try
                {
                    int time = 0;
                    if (int.TryParse(request.Time, out time))
                    {
                        if (time <= 0)
                        {
                            response.Message = "Time Parameter must be > 0 !";
                            response.Result = false;
                        }
                        else
                        {
                            string sched_id = Guid.NewGuid().ToString();
                            APIResponse res = (APIResponse)fsInbound.APICommand(string.Format("sched_api {0} +{1} uuid_kill {2} ALLOTTED_TIMEOUT", sched_id, time, request.CallUUID));
                            if (res.IsSuccess())
                            {
                                response.Message = string.Format("Scheduled Hangup Done with SchedHangupId {0}", sched_id);
                                response.Result = true;
                                response.ScheduleId = sched_id;
                            }
                            else
                            {
                                response.Message = string.Format("Scheduled Hangup Failed: {0}", res.GetResponse());
                                response.Result = false;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    response.Message = "Invalid Time Parameter !";
                    response.Result = false;
                }

            }
            return response;
        }
Esempio n. 2
0
        private ScheduleHangUpResponse ScheduleHangUpCall(ScheduleHangUpRequest request)
        {
            ScheduleHangUpResponse response = new ScheduleHangUpResponse();

            if (string.IsNullOrEmpty(request.CallUUID))
            {
                response.Message = "CallUUID Parameter must be present";
                response.Result  = false;
            }
            else if (string.IsNullOrEmpty(request.Time))
            {
                response.Message = "Time Parameter must be present";
            }
            else
            {
                try
                {
                    int time = 0;
                    if (int.TryParse(request.Time, out time))
                    {
                        if (time <= 0)
                        {
                            response.Message = "Time Parameter must be > 0 !";
                            response.Result  = false;
                        }
                        else
                        {
                            string      sched_id = Guid.NewGuid().ToString();
                            APIResponse res      = (APIResponse)fsInbound.APICommand(string.Format("sched_api {0} +{1} uuid_kill {2} ALLOTTED_TIMEOUT", sched_id, time, request.CallUUID));
                            if (res.IsSuccess())
                            {
                                response.Message    = string.Format("Scheduled Hangup Done with SchedHangupId {0}", sched_id);
                                response.Result     = true;
                                response.ScheduleId = sched_id;
                            }
                            else
                            {
                                response.Message = string.Format("Scheduled Hangup Failed: {0}", res.GetResponse());
                                response.Result  = false;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    response.Message = "Invalid Time Parameter !";
                    response.Result  = false;
                }
            }
            return(response);
        }