public MakeTelephoneCalls(MakeCallParameters makeCallParameters) { AnswerMethod = makeCallParameters.AnswerMethod; AnswerURL = makeCallParameters.AnswerURL; AuthorizationID = makeCallParameters.AuthorizationID; AuthorizationToken= makeCallParameters.AuthorizationToken; HangUpURL = makeCallParameters.HangupURL; FromNumber = makeCallParameters.FromNumber; NameOfFirstFile = makeCallParameters.NameOfFirstFile; //Get list of calls to be made and make List<MakeCall> makeCalls = new List<MakeCall>(); MakeCall extras = new MakeCall(); extras.Type = makeCallParameters.Type; makeCalls = patientRecords.GetListToCall(extras); MakeACall makeACall = new MakeACall(); for (int i = 0; i < makeCalls.Count; i++) { makeACall = new MakeACall(); makeACall.ToNumber = makeCalls[i].ToNumber; makeACall.CallerName = makeCalls[i].CallerName; MakeATelephoneCall(makeACall); //System.Threading.Thread.Sleep(2000); System.Threading.Thread.Sleep(3500); } NumberOfCalls = makeCalls.Count; }
public void MakeATelephoneCall(MakeACall makeACall) { RestAPI plivo = new RestAPI(AuthorizationID,AuthorizationToken); try { // Place a call // string ss = plivo.get_cdr.PlivoVersion; IRestResponse<Call> resp = plivo.make_call(new dict { { "to", "1" + makeACall.ToNumber}, { "from", FromNumber}, { "answer_url", AnswerURL + makeACall.CallerName + NameOfFirstFile }, { "hangup_url", HangUpURL}, { "answer_method", AnswerMethod}, { "caller_name", makeACall.CallerName} }); if (resp.Data != null) { PropertyInfo[] proplist = resp.Data.GetType().GetProperties(); foreach (PropertyInfo property in proplist) Console.WriteLine("{0}: {1}", property.Name, property.GetValue(resp.Data, null)); } else { Console.WriteLine(resp.ErrorMessage); } } catch (Exception er) { //Log(er.Message, logpath); } }