//public string GetMostRecentConferenceNameFromNumber(string twilioPhonenumber) //{ // string conferenceName = "mango"; // try // { // using (var _dbContext = new TwilloDbContext()) // { // // Note: This has to return a value // // This is the most recent conference started via a // // specific Twilio number and which is Active // // Only worry right now is to ensure that // // periodic maintenace of the conference calls takes place every now and then // // ensuring that not too many records in the conference table. // TwilioConferenceCall found = _dbContext.TwilioConferenceCalls // .Where(c => c.CallIsActive // && c.ConferenceSID != null // && c.TwilioPhoneNumber == string.Format("+{0}", twilioPhonenumber)) // .OrderByDescending(c => c.CallStartTime).SingleOrDefault(); // conferenceName = found.ConferenceName; // } // } // catch (Exception ex) // { // ErrorMessage(string.Format("Error Message - {0} 1.Source {1} 2.Trace {2} 3.Inner Exception {3} ", // ex.Message, ex.Source, ex.StackTrace, ex.InnerException)); // } // return conferenceName; //} public string GetMostRecentConferenceNameFromNumber(ref int conFerenceId, string twilioPhonenumber) { string conferenceName = ""; try { using (var _dbContext = new TwilloDbContext()) { TwilioConferenceCall found = _dbContext.TwilioConferenceCalls .Where(c => c.CallIsActive && c.ConferenceSID != null // && c.ConferenceStartTime != null && c.TwilioPhoneNumber == twilioPhonenumber) .OrderByDescending(c => c.CallStartTime).SingleOrDefault(); if (found != null) { conferenceName = found.ConferenceName; conFerenceId = found.Id; } else { conferenceName = "mango"; // Just assigning an arbit value } } } catch (Exception ex) { ErrorMessage(string.Format("|Error Message - {0}| 1.Source {1} | 2.Trace {2} |3.Inner Exception {3} |", ex.Message, ex.Source, ex.StackTrace, ex.InnerException)); } return(conferenceName); }
public TwilioConferenceCall GetConferenceBySid(string callSid) { TwilioConferenceCall found = null; try { using (var _dbContext = new TwilloDbContext()) { found = _dbContext.TwilioConferenceCalls.FirstOrDefault(x => x.ConferenceSID == callSid); } } catch (Exception ex) { ErrorMessage(string.Format("|Error Message - {0}| 1.Source {1} | 2.Trace {2} |3.Inner Exception {3} |", ex.Message, ex.Source, ex.StackTrace, ex.InnerException)); } return(found); }
public void UpdateConference(TwilioConferenceCall conference) { try { using (var _dbContext = new TwilloDbContext()) { var found = _dbContext.TwilioConferenceCalls.Find(conference.Id); found.ConferenceSID = conference.ConferenceSID; found.SystemStatus = SystemStatus.CONFERENCE_IN_PROGRESS; _dbContext.SaveChanges(); } } catch (Exception ex) { ErrorMessage(string.Format("|Error Message - {0}| 1.Source {1} | 2.Trace {2} |3.Inner Exception {3} |", ex.Message, ex.Source, ex.StackTrace, ex.InnerException)); throw; } }
public TwilioConferenceCall GetConferenceRecord(int id) { TwilioConferenceCall found = null; try { using (var _dbContext = new TwilloDbContext()) { found = _dbContext.TwilioConferenceCalls.Find(id); } } catch (Exception ex) { ErrorMessage(string.Format("|Error Message - {0}| 1.Source {1} | 2.Trace {2} |3.Inner Exception {3} |", ex.Message, ex.Source, ex.StackTrace, ex.InnerException)); throw; } return(found); }
public TwilioConferenceCall CreateTwilioConferenceRecord(string phoneFrom, string phoneTo, string twilioPhoneNumber, string conferenceName, string phoneCall1Sid, double hangupIntervalinSeconds, double messageIntervalinSeconds, double warningIntervalInSeconds, DateTime callStartTime) { using (var _dbContext = new TwilloDbContext()) { TwilioConferenceCall callRecord = new TwilioConferenceCall(); try { callRecord.PhoneFrom = phoneFrom; callRecord.CallStartTime = callStartTime; callRecord.PhoneTo = phoneTo; callRecord.TwilioPhoneNumber = twilioPhoneNumber; callRecord.ConferenceName = conferenceName; callRecord.PhoneCall1SID = phoneCall1Sid; callRecord.CallIsActive = true; callRecord.hangupIntervalInSeconds = hangupIntervalinSeconds; callRecord.messageIntervalInSeconds = messageIntervalinSeconds; callRecord.warningIntervalInSeconds = warningIntervalInSeconds; callRecord.SystemStatus = SystemStatus.RECORD_CREATED; _dbContext.TwilioConferenceCalls.Add(callRecord); _dbContext.SaveChanges(); } catch (Exception ex) { ErrorMessage(string.Format("|Error Message - {0}| 1.Source {1} | 2.Trace {2} |3.Inner Exception {3} |", ex.Message, ex.Source, ex.StackTrace, ex.InnerException)); throw; } return(callRecord); } }