public void UpdateConference(int id, string Call2Sid, SystemStatus systemStatus) { try { //SystemStatus sysStat = (SystemStatus)systemStatus; using (var _dbContext = new TwilloDbContext()) { var found = _dbContext.TwilioConferenceCalls.Find(id); if (found != null) { if (found.PhoneCall2SID == null) { found.PhoneCall2SID = Call2Sid; } if (found.SystemStatus != SystemStatus.CONFERENCE_COMPLETED) { found.SystemStatus = systemStatus; } } _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 string returnStatus(string twilioPhoneNumber) { var retVal = String.Empty; try { using (var context = new TwilloDbContext()) { var user = context .User .Where(u => u.Service_User_Twilio_Phone_Number == twilioPhoneNumber.ToString().Substring(2)).FirstOrDefault(); retVal = Convert.ToBoolean(user.AvailableStatus) ? "Available" : "Not Available"; } } 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(retVal); }
public void UpdateConferenceStartTime(int id, DateTime conferenceStartTime) { try { using (var _dbContext = new TwilloDbContext()) { var found = _dbContext.TwilioConferenceCalls.Find(id); found.ConferenceStartTime = conferenceStartTime; _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 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 bool CheckAvailabilityAndFetchDetails(string Service_User_Twilio_Phone_Number, ref string struserName, ref string Service_User_Conference_With_Number, ref string strTimeZoneID) { var retVal = true; try { using (var _dbContext = new TwilloDbContext()) { var user = _dbContext .User .Where(u => u.Service_User_Twilio_Phone_Number == Service_User_Twilio_Phone_Number) .FirstOrDefault(); struserName = user.UserFullName; Service_User_Conference_With_Number = user.Service_User_Conference_With_Number; strTimeZoneID = user.IANATimeZone; retVal = Convert.ToBoolean(user.AvailableStatus); } } 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(retVal); }
public void ErrorMessage(string message, int id = 0) { using (var _dbContext = new TwilloDbContext()) { _dbContext.LogMessages.Add(new LogMessage() { LogTime = DateTime.Now, ConferenceRecordId = id, Message = message }); _dbContext.SaveChanges(); } }
public void LogMessage(string message, int seq = 0, int id = 0) { //if (!Logging_enabled) return; using (var _dbContext = new TwilloDbContext()) { _dbContext.LogMessages.Add(new LogMessage() { LogTime = DateTime.Now, ConferenceRecordId = id, Seq = seq, Message = message }); _dbContext.SaveChanges(); } }
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 void UpdateSystemStatus(int id, SystemStatus status) { try { using (var _dbContext = new TwilloDbContext()) { var found = _dbContext.TwilioConferenceCalls.Find(id); found.SystemStatus = status; _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 void UpdateActiveStatus(int id, bool v) { try { using (var _dbContext = new TwilloDbContext()) { var found = _dbContext.TwilioConferenceCalls.Find(id); if (found != null) { found.CallIsActive = v; found.SystemStatus = SystemStatus.CONFERENCE_COMPLETED; } _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)); } }
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); } }
public string updateStatus(Int16 requiredStatus, string twilioPhoneNumber) { var retVal = string.Empty; try { using (var context = new TwilloDbContext()) { var user = context .User .Where(u => u.Service_User_Twilio_Phone_Number == twilioPhoneNumber.ToString().Substring(2)).FirstOrDefault(); switch (Convert.ToBoolean(requiredStatus)) { case true: { if ((user.AvailableStatus) == true) { retVal = "Status is already Available"; } // Do nothing else { user.AvailableStatus = true; context.SaveChanges(); retVal = "Status is now set to Available"; } } break; case false: { if ((user.AvailableStatus) == false) { retVal = "Status is already Not Available"; } // Do nothing else { user.AvailableStatus = false; context.SaveChanges(); retVal = "Status is now set to Not Available"; } } break; default: break; } } } 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(retVal); }