public void LogACall(LogCall logCall) { using (MySqlConnection db = new MySqlConnection(Database.ReminderConnection)) { try { const string query = "insert into log_call(Company_ID,NameID,FirstName,Provider,DateOfAppointment," + "TimeOfAppointment,TelephoneNumber,Result,LogTime,Length_Of_Call)" + "values(@Company_ID,@NameID,@FirstName,@Provider,@DateOfAppointment," + "@TimeOfAppointment,@TelephoneNumber,@Result,@LogTime,@Length_Of_Call)"; int rowsAffectd = db.Execute(query, logCall); } catch (Exception er) { Log.LogMessage(er.ToString()); } } }
//public void UpdateCallingTimeToShortNotCompleted(string patientID, double duration, DateTime endOfCall, string callOutcome) public void UpdateCallingRecordNotCompleted(string telephoneID, double duration, DateTime endOfCall, string callOutcome) { string resultDescription = string.Empty; DateTime currentTime = DateTime.Now.AddMinutes(30); long newcallingTime = currentTime.Ticks; int numberOfCalls = ReturnSingleInt(" select call_count from pendingtelephone" + " where TelephoneID = " + telephoneID); numberOfCalls++; switch (callOutcome) { case "UNALLOCATED_NUMBER": resultDescription = " , resultdescription = 'Unallocated Number'"; break; case "USER_BUSY": resultDescription = " , resultdescription = 'Phone Busy'"; break; case "NORMAL_TEMPORARY_FAILURE": resultDescription = " , resultdescription = 'Normal Temporary Failure'"; break; case "NO_ANSWER": resultDescription = " , resultdescription = 'No Answer'"; break; case "CALL_REJECTED": resultDescription = " , resultdescription = 'Call Rejected'"; break; case "NORMAL_CLEARING": resultDescription = " , resultdescription = 'Patient did not Hear Message'"; break; default: resultDescription = " , resultdescription = 'Unknown'"; break; } using (MySqlConnection db = new MySqlConnection(Database.ReminderConnection)) { try { string query = "update pendingtelephone" + " set completed = 'N'" + resultDescription + " , time_of_call = @time_of_call" + " , call_count = @call_count" + " , callwait = @callwait" + " where TelephoneID = @telephoneID"; int rowsAffectd = db.Execute(query, new { @telephoneID = telephoneID, @call_count = numberOfCalls, @time_of_call = endOfCall.ToShortDateString() + " " + endOfCall.ToShortTimeString(), @callwait = newcallingTime.ToString() }); } catch (Exception er) { Log.LogMessage(er.ToString()); } try { List<CallingRecord> callingRecord = new List<CallingRecord>(); LogCall logCall = new LogCall(); callingRecord = GetPatientRecord(telephoneID); logCall.Company_ID = callingRecord[0].Company_ID; logCall.DateOfAppointment = callingRecord[0].DateOfAppointment; logCall.Provider = callingRecord[0].Provider; logCall.FirstName = callingRecord[0].FirstName + " " + callingRecord[0].LastName; logCall.Length_Of_Call = callingRecord[0].TelephoneID; logCall.LogTime = DateTime.Now; logCall.NameID = callingRecord[0].NameID; logCall.Length_Of_Call = (int)duration; logCall.TelephoneNumber = callingRecord[0].TelephoneFile; logCall.TimeOfAppointment = callingRecord[0].TimeOfAppointment; logCall.Result = callingRecord[0].ResultDescription; LogACall(logCall); } catch (Exception er) { Log.LogMessage(er.ToString()); } } //DateTime currentTime = DateTime.Now.AddMinutes(30); //long newcallingTime = currentTime.Ticks; //bool isVoicMailCall = false; //int numberOfCalls = ReturnSingleInt(" select call_count from pendingtelephone" // + " where nameid = " + patientID); //numberOfCalls++; //using (MySqlConnection cn = new MySqlConnection(Database.ReminderConnection)) //{ // cn.Open(); // using (MySqlCommand cm = cn.CreateCommand()) // { // cm.CommandText = "select count(*) from pendingtelephone " // + " where nameid = @NameID" // + " and resultdescription = 'Call Completed - VoiceMail'"; // cm.CommandType = System.Data.CommandType.Text; // cm.Parameters.AddWithValue("@NameID", patientID); // MySqlDataReader dr = cm.ExecuteReader(); // dr.Read(); // if (dr.GetInt32(0) > 0) // { // isVoicMailCall = true; // } // else // { // isVoicMailCall = false; // } // } //} //if (isVoicMailCall == false) //{ // using (MySqlConnection db = new MySqlConnection(Database.ReminderConnection)) // { // try // { // string query = // "update pendingtelephone" // + " set completed = 'Y'" // + " , resultdescription = 'Call Completed - Person Picked Up'" // + " , time_of_call = @time_of_call" // + " , call_count = @call_count" // + " , messageTime = @messageTime" // + " where nameID = @nameID"; // int rowsAffectd = db.Execute(query, new // { // @nameID = patientID, // @call_count = numberOfCalls, // @time_of_call = endOfCall.ToShortDateString() + " " + endOfCall.ToShortTimeString(), // @messageTime = duration // }); // } // catch (Exception er) // { // Log.LogMessage(er.ToString()); // } // try // { // List<CallingRecord> callingRecord = new List<CallingRecord>(); // LogCall logCall = new LogCall(); // callingRecord = GetPatientRecord(patientID); // logCall.Company_ID = callingRecord[0].Company_ID; // logCall.DateOfAppointment = callingRecord[0].DateOfAppointment; // logCall.Provider = callingRecord[0].Provider; // logCall.FirstName = callingRecord[0].FirstName + " " + callingRecord[0].LastName; // logCall.Length_Of_Call = callingRecord[0].TelephoneID; // logCall.LogTime = DateTime.Now; // logCall.NameID = callingRecord[0].NameID; // logCall.Length_Of_Call = (int)duration; // logCall.TelephoneNumber = callingRecord[0].TelephoneFile; // logCall.TimeOfAppointment = callingRecord[0].TimeOfAppointment; // logCall.Result = callingRecord[0].ResultDescription; // LogACall(logCall); // } // catch (Exception er) // { // Log.LogMessage(er.ToString()); // } // } //} //else //{ // using (MySqlConnection db = new MySqlConnection(Database.ReminderConnection)) // { // try // { // string query = // "update pendingtelephone" // + " set completed = 'Y'" // + " , time_of_call = @time_of_call" // + " , call_count = @call_count" // + " , messageTime = @messageTime" // + " where nameID = @nameID"; // int rowsAffectd = db.Execute(query, new // { // @nameID = patientID, // @call_count = numberOfCalls, // @time_of_call = endOfCall.ToShortDateString() + " " + endOfCall.ToShortTimeString(), // @messageTime = duration // }); // } // catch (Exception er) // { // Log.LogMessage(er.ToString()); // } // try // { // List<CallingRecord> callingRecord = new List<CallingRecord>(); // LogCall logCall = new LogCall(); // callingRecord = GetPatientRecord(patientID); // logCall.Company_ID = callingRecord[0].Company_ID; // logCall.DateOfAppointment = callingRecord[0].DateOfAppointment; // logCall.Provider = callingRecord[0].Provider; // logCall.FirstName = callingRecord[0].FirstName + " " + callingRecord[0].LastName; // logCall.Length_Of_Call = callingRecord[0].TelephoneID; // logCall.LogTime = DateTime.Now; // logCall.NameID = callingRecord[0].NameID; // logCall.Length_Of_Call = (int)duration; // logCall.TelephoneNumber = callingRecord[0].TelephoneFile; // logCall.TimeOfAppointment = callingRecord[0].TimeOfAppointment; // logCall.Result = callingRecord[0].ResultDescription; // LogACall(logCall); // } // catch (Exception er) // { // Log.LogMessage(er.ToString()); // } // } //} }
public void UpdateCallingNoAnswer(string telephoneID, double duration, DateTime endOfCall) { DateTime currentTime = DateTime.Now.AddMinutes(30); long newcallingTime = currentTime.Ticks; int numberOfCalls = ReturnSingleInt(" select call_count from pendingtelephone" + " where TelephoneID = " + telephoneID); numberOfCalls++; using (MySqlConnection db = new MySqlConnection(Database.ReminderConnection)) { try { string query = "update pendingtelephone" + " set completed = 'N'" + " , resultdescription = 'No Answer'" + " , time_of_call = @time_of_call" + " , call_count = @call_count" + " , callwait = @callwait" + " where TelephoneID = @telephoneID"; int rowsAffectd = db.Execute(query, new { @telephoneID = telephoneID, @call_count = numberOfCalls, @time_of_call = endOfCall.ToShortDateString() + " " + endOfCall.ToShortTimeString(), @callwait = newcallingTime.ToString() }); } catch (Exception er) { Log.LogMessage(er.ToString()); } try { List<CallingRecord> callingRecord = new List<CallingRecord>(); LogCall logCall = new LogCall(); callingRecord = GetPatientRecord(telephoneID); logCall.Company_ID = callingRecord[0].Company_ID; logCall.DateOfAppointment = callingRecord[0].DateOfAppointment; logCall.Provider = callingRecord[0].Provider; logCall.FirstName = callingRecord[0].FirstName + " " + callingRecord[0].LastName; logCall.TelephoneID = callingRecord[0].TelephoneID.ToString(); logCall.LogTime = DateTime.Now; logCall.NameID = callingRecord[0].NameID; logCall.Length_Of_Call = (int)duration; logCall.TelephoneNumber = callingRecord[0].TelephoneFile; logCall.TimeOfAppointment = callingRecord[0].TimeOfAppointment; logCall.Result = callingRecord[0].ResultDescription; LogACall(logCall); } catch (Exception er) { Log.LogMessage(er.ToString()); } } }
public void UpdateCallingRecordCompleted(string telephoneID, double duration, DateTime endOfCall) { DateTime currentTime = DateTime.Now.AddMinutes(30); long newcallingTime = currentTime.Ticks; bool isVoicMailCall = false; int numberOfCalls = ReturnSingleInt(" select call_count from pendingtelephone" + " where TelephoneID = " + telephoneID); numberOfCalls++; using (MySqlConnection cn = new MySqlConnection(Database.ReminderConnection)) { cn.Open(); using (MySqlCommand cm = cn.CreateCommand()) { cm.CommandText = "select count(*) from pendingtelephone " + " where TelephoneID = @telephoneID" + " and resultdescription = 'Call Completed - VoiceMail'"; cm.CommandType = System.Data.CommandType.Text; cm.Parameters.AddWithValue("@telephoneID", telephoneID); MySqlDataReader dr = cm.ExecuteReader(); dr.Read(); if (dr.GetInt32(0) > 0) { isVoicMailCall = true; } else { isVoicMailCall = false; } } } if (isVoicMailCall == false) { using (MySqlConnection db = new MySqlConnection(Database.ReminderConnection)) { try { string query = "update pendingtelephone" + " set completed = 'Y'" + " , resultdescription = 'Call Completed - Person Picked Up'" + " , time_of_call = @time_of_call" + " , call_count = @call_count" + " , messageTime = @messageTime" + " where TelephoneID = @telephoneID"; int rowsAffectd = db.Execute(query, new { @telephoneID = telephoneID, @call_count = numberOfCalls, @time_of_call = endOfCall.ToShortDateString() + " " + endOfCall.ToShortTimeString(), @messageTime = duration }); } catch (Exception er) { Log.LogMessage(er.ToString()); } try { List<CallingRecord> callingRecord = new List<CallingRecord>(); LogCall logCall = new LogCall(); callingRecord = GetPatientRecord(telephoneID); logCall.Company_ID = callingRecord[0].Company_ID; logCall.DateOfAppointment = callingRecord[0].DateOfAppointment; logCall.Provider = callingRecord[0].Provider; logCall.FirstName = callingRecord[0].FirstName + " " + callingRecord[0].LastName; logCall.TelephoneID = callingRecord[0].TelephoneID.ToString(); logCall.LogTime = DateTime.Now; logCall.NameID = callingRecord[0].NameID; logCall.Length_Of_Call = (int)duration; logCall.TelephoneNumber = callingRecord[0].TelephoneFile; logCall.TimeOfAppointment = callingRecord[0].TimeOfAppointment; logCall.Result = callingRecord[0].ResultDescription; LogACall(logCall); } catch (Exception er) { Log.LogMessage(er.ToString()); } } } else { using (MySqlConnection db = new MySqlConnection(Database.ReminderConnection)) { try { string query = "update pendingtelephone" + " set completed = 'Y'" + " , time_of_call = @time_of_call" + " , call_count = @call_count" + " , messageTime = @messageTime" + " where TelephoneID = @telephoneID"; int rowsAffectd = db.Execute(query, new { @telephoneID = telephoneID, @call_count = numberOfCalls, @time_of_call = endOfCall.ToShortDateString() + " " + endOfCall.ToShortTimeString(), @messageTime = duration }); } catch (Exception er) { Log.LogMessage(er.ToString()); } try { List<CallingRecord> callingRecord = new List<CallingRecord>(); LogCall logCall = new LogCall(); callingRecord = GetPatientRecord(telephoneID); logCall.Company_ID = callingRecord[0].Company_ID; logCall.DateOfAppointment = callingRecord[0].DateOfAppointment; logCall.Provider = callingRecord[0].Provider; logCall.FirstName = callingRecord[0].FirstName + " " + callingRecord[0].LastName; logCall.TelephoneID = callingRecord[0].TelephoneID.ToString(); logCall.LogTime = DateTime.Now; logCall.NameID = callingRecord[0].NameID; logCall.Length_Of_Call = (int)duration; logCall.TelephoneNumber = callingRecord[0].TelephoneFile; logCall.TimeOfAppointment = callingRecord[0].TimeOfAppointment; logCall.Result = callingRecord[0].ResultDescription; LogACall(logCall); } catch (Exception er) { Log.LogMessage(er.ToString()); } } } }