static void Main(string[] args) { string authID = System.Configuration .ConfigurationManager.AppSettings["authid"]; string authToken = System.Configuration .ConfigurationManager.AppSettings["authtoken"]; RestAPI plivo = new RestAPI(authID, authToken); string name = string.Empty; string answerURL = System.Configuration .ConfigurationManager.AppSettings["answerURL"]; string hangupURL = System.Configuration .ConfigurationManager.AppSettings["hangupURL"]; string answerMethod = System.Configuration .ConfigurationManager.AppSettings["answerMethod"]; string fromNumber = System.Configuration .ConfigurationManager.AppSettings["fromnumber"]; string connection = System.Configuration .ConfigurationManager.AppSettings["sqlconnection"]; string logpath = System.Configuration .ConfigurationManager.AppSettings["logpath"]; Database.ReminderConnection = System.Configuration .ConfigurationManager.AppSettings["reminderConnection"]; List<MakeCall> makeCalls = new List<MakeCall>(); MakeCall makeCall = new MakeCall(); MakeCall extras = new MakeCall(); PatientRecords patientRecords = new PatientRecords(); //new comment extras.AnswerURL = answerURL; extras.HangUpURL = hangupURL; extras.FromNumber = fromNumber; extras.AnswerMethod = answerMethod; extras.NameOfFirstFile = System.Configuration .ConfigurationManager.AppSettings["nameOfFirstFile"]; try { makeCalls = new List<MakeCall>(); makeCalls = patientRecords.GetListToCall(extras); //makeCalls.Add(makeCall); /* for (int i = 0; i < makeCalls.Count; i++) { // Place a call // string ss = plivo.get_cdr.PlivoVersion; IRestResponse<Call> resp = plivo.make_call(new dict { { "to", "1" + makeCalls[i].ToNumber}, { "from", makeCalls[i].FromNumber}, { "answer_url", makeCalls[i].AnswerURL + makeCalls[i].CallerName + extras.NameOfFirstFile }, { "hangup_url", makeCalls[i].HangUpURL}, { "answer_method", makeCalls[i].AnswerMethod}, { "caller_name", makeCalls[i].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); } */ for (int i = 0; i < makeCalls.Count; i++) { // Place a call // string ss = plivo.get_cdr.PlivoVersion; IRestResponse<Call> resp = plivo.make_call(new dict { { "to", "1" + "8602325449"}, { "from", fromNumber}, { "answer_url", answerURL }, { "hangup_url", hangupURL}, { "answer_method", "GET"}, { "caller_name", "None"} }); 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); } System.Threading.Thread.Sleep(2000); } } catch (Exception er) { Log(er.Message, logpath); } }
public List<MakeCall> GetListToCall(MakeCall extras) { List<CallingRecord> callingRecords = new List<CallingRecord>(); PatientRecords patientRecords = new PatientRecords(); List<MakeCall> makeCalls = new List<MakeCall>(); if (extras.Type == "R") { callingRecords = patientRecords.GetListOfCallingRecords(); } else if (extras.Type == "M") { callingRecords = patientRecords.GetListOfCallingRecordsMonitor(); } for (int i = 0; i < callingRecords.Count; i++) { MakeCall makeCall = new MakeCall(); makeCall.CallerName = callingRecords[i].TelephoneID.ToString(); makeCall.AnswerMethod = "GET"; makeCall.FromNumber = extras.FromNumber; makeCall.ToNumber = callingRecords[i].TelephoneNumber1; makeCall.AnswerURL = extras.AnswerURL; makeCall.HangUpURL = extras.HangUpURL; makeCalls.Add(makeCall); } return makeCalls; }
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; }