public IEnumerable <string> GetServicesAgent([FromUri] UserParameters user) { try { if (MainObject.MainList.ContainsKey(user.AgentId)) { CApp mpApp = MainObject.MainList[user.AgentId]; string json = string.Empty; if (mpApp.AssignedServices != null) { List <DialServiceParameters> list = new List <DialServiceParameters>(); foreach (CService item in mpApp.AssignedServices) { DialServiceParameters dsp = new DialServiceParameters(); dsp.ServiceId = item.ServiceId.ToString(); dsp.ServiceName = item.ServiceName; list.Add(dsp); } if (list.Count > 0) { json = JsonConvert.SerializeObject(list); } else { json = string.Empty; } return(new string[] { json.Replace(@"\", "") }); } else { return(new string[] { "" }); } } else { return(new string[] { "" }); } } catch (Exception ex) { Log.logException(ex); return(new string[] { "" }); } }
public HttpResponseMessage TakeCallsPost([FromBody] UserParameters user) { try { if (MainObject.MainList.ContainsKey(user.AgentId)) { var mpApp = MainObject.MainList[user.AgentId]; if (mpApp.CurrentState is CStateAuthenticated) { mpApp.TakeCalls(); mpApp.EnableKeepAlives = true; string json = string.Empty; List <DialServiceParameters> list = new List <DialServiceParameters>(); if (mpApp.CurrentCall == null) { foreach (CService item in mpApp.AssignedServices) { DialServiceParameters dsp = new DialServiceParameters(); dsp.ServiceId = item.ServiceId.ToString(); dsp.ServiceName = item.serviceName; list.Add(dsp); } if (list.Count > 0) { json = JsonConvert.SerializeObject(list); } } return(Request.CreateResponse(HttpStatusCode.OK, list)); } else { return(Request.CreateResponse(HttpStatusCode.Unauthorized, "Agent not authenticate")); } } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "Agent not found")); } } catch (Exception ex) { Log.logException(ex); return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message)); } }