public void GetCallingResults()
        {

            CallResults logCall = new CallResults();
            List<CallResults> logCalls = patientRecords.GetLoggedCallsToMonitor();

            for (int i = 0; i < logCalls.Count; i++)
            {
                if (logCalls[i].Duration < 15 && logCalls[i].Duration > 0)
                {
                    if (patientRecords.ReturnCallCount(logCalls[i].CallerName) >= 1)
                    {
                        //Update Calling Record
                        patientRecords.UpdateCallingRecordCompletedTimeToShort(logCalls[i].CallerName, logCalls[i].Duration, logCalls[i].EndTime);

                        //Delete Logged Record
                        patientRecords.DeleteLoggedRecord(logCalls[i].ID.ToString());
                        continue;
                    }
                    else
                    {
                        patientRecords.UpdateCallingRecordNotCompleted(logCalls[i].CallerName, logCalls[i].Duration, logCalls[i].EndTime, logCalls[i].HangupCause);
                        patientRecords.DeleteLoggedRecord(logCalls[i].ID.ToString());
                        continue;
                    }
                }

                //Call completed normally
                if (logCalls[i].HangupCause == "NORMAL_CLEARING")
                {
                    //Update Calling Record
                    patientRecords.UpdateCallingRecordCompleted(logCalls[i].CallerName, logCalls[i].Duration, logCalls[i].EndTime);

                    //Delete Logged Record
                    patientRecords.DeleteLoggedRecord(logCalls[i].ID.ToString());
                }
                //Call completed normally
                else if (logCalls[i].HangupCause == "NORMAL_UNSPECIFIED")
                {
                    //Update Calling Record
                    patientRecords.UpdateCallingRecordCompleted(logCalls[i].CallerName, logCalls[i].Duration, logCalls[i].EndTime);

                    //Delete Logged Record
                    patientRecords.DeleteLoggedRecord(logCalls[i].ID.ToString());
                }
                else if (logCalls[i].HangupCause == "NO_USER_RESPONSE")
                {
                    //Update Calling Record
                    patientRecords.UpdateCallingRecordCompleted(logCalls[i].CallerName, logCalls[i].Duration, logCalls[i].EndTime);

                    //Delete Logged Record
                    patientRecords.DeleteLoggedRecord(logCalls[i].ID.ToString());
                }
                else
                {
                    patientRecords.UpdateCallingRecordNotCompleted(logCalls[i].CallerName, logCalls[i].Duration, logCalls[i].EndTime, logCalls[i].HangupCause);
                    patientRecords.DeleteLoggedRecord(logCalls[i].ID.ToString());
                }
            }
        }
 public void InsertLogCall(CallResults logCall)
 {
     //string conn = "Server=mysql2.myregisteredsite.com;User ID=117224_walden;password=0Griswold;Database=117224_waldenweb;Persist Security Info=True";
     using (MySqlConnection db = new MySqlConnection(Database.ReminderConnection))
     {
         try
         {
             const string query =
                 "insert into logcall(Direction,TotalCost,HangupCause,FromNumber,ALegUUID,CallerName,"
                 + "Duration,BillDuration,BillRate,ToNumber,AnswerTime,StartTime,CallUUID,ALegRequestUUID,"
                 + " RequestUUID,EndTime,CallStatus,Event)"
                 + " values(@Direction,@TotalCost,@HangupCause,@FromNumber,@ALegUUID,@CallerName,@Duration,"
                 + " @BillDuration,@BillRate,@ToNumber,@AnswerTime,@StartTime,@CallUUID,@ALegRequestUUID,"
                 + " @RequestUUID,@EndTime,@CallStatus,@Event)";
             int rowsAffectd = db.Execute(query, logCall);
         }
         catch (Exception er)
         {
             string s1 = er.Message;
             //Log.WhichProgram = "Labcorp Interface";
             Log.LogMessage(er.ToString());
         }
     }
 }
        public void UpdateCallInformation(FormCollection collection)
        {
            Database.ReminderConnection = System.Configuration
                .ConfigurationManager.AppSettings["reminderConnection"];
            PatientCommunication.Model.CallResults logCall = new PatientCommunication.Model.CallResults();
            string logFilePath = System.Configuration
                .ConfigurationManager.AppSettings["logfile"];

            string direction = string.Empty;
            double totalCost = 0;
            string hangupCause = string.Empty;
            string fromNumber = string.Empty;
            string aLegUUID = string.Empty;
            string callerName = string.Empty;
            double duration = 0;
            double billDuration = 0;
            double billRate = 0;
            string toNumber = string.Empty;
            DateTime AnswerTime = DateTime.Now;
            DateTime StartTime = DateTime.Now;
            string CallUUID = string.Empty;
            string ALegRequestUUID = string.Empty;
            string RequestUUID = string.Empty;
            DateTime EndTime = DateTime.Now;
            string CallStatus = string.Empty;
            string theEvent = string.Empty;

            try
            {
                direction = collection["Direction"];
            }
            catch
            {
                direction = string.Empty;
            }
            logCall.Direction = direction;
            try
            {
                totalCost = double.Parse(collection["TotalCost"]);
            }
            catch
            {
                totalCost = 0;
            }
            logCall.TotalCost = totalCost;
            try
            {
                hangupCause = collection["HangupCause"];
            }
            catch
            {
                hangupCause = string.Empty;
            }
            logCall.HangupCause = hangupCause;
            try
            {
                fromNumber = collection["From"];
            }
            catch
            {
                fromNumber = string.Empty;
            }
            logCall.FromNumber = fromNumber;
            try
            {
                aLegUUID = collection["ALegUUID"];
            }
            catch
            {
                aLegUUID = string.Empty;
            }
            logCall.ALegUUID = aLegUUID;
            try
            {
                callerName = collection["CallerName"];
            }
            catch
            {
                callerName = string.Empty;
            }
            logCall.CallerName = callerName;
            try
            {
                duration = double.Parse(collection["Duration"]);
            }
            catch
            {
                duration = 0;
            }
            logCall.Duration = duration;
            try
            {
                billDuration = double.Parse(collection["BillDuration"]);
            }
            catch
            {
                billDuration = 0;
            }
            logCall.BillDuration = billDuration;
            try
            {
                billRate = double.Parse(collection["BillRate"]);
            }
            catch
            {
                billRate = 0;
            }
            logCall.BillRate = billRate;
            try
            {
                toNumber = collection["To"];
            }
            catch
            {
                toNumber = string.Empty;
            }
            logCall.ToNumber = toNumber;
            try
            {
                AnswerTime = Convert.ToDateTime(ConvertDate(collection["AnswerTime"]));
            }
            catch
            {

            }
            logCall.AnswerTime = AnswerTime;
            try
            {
                StartTime = Convert.ToDateTime(ConvertDate(collection["StartTime"]));
            }
            catch
            {

            }
            logCall.StartTime = StartTime;
            try
            {
                CallUUID = collection["CallUUID"];
            }
            catch
            {

            }
            logCall.CallUUID = CallUUID;
            try
            {
                ALegRequestUUID = collection["ALegRequestUUID"];
            }
            catch
            {

            }
            logCall.ALegRequestUUID = ALegRequestUUID;
            try
            {
                RequestUUID = collection["RequestUUID"];
            }
            catch
            {

            }
            logCall.RequestUUID = RequestUUID;
            try
            {
                EndTime = Convert.ToDateTime(ConvertDate(collection["EndTime"]));
            }
            catch
            {

            }
            logCall.EndTime = EndTime;
            try
            {
                CallStatus = collection["CallStatus"];
            }
            catch
            {

            }
            logCall.CallStatus = CallStatus;
            try
            {
                theEvent = collection["Event"];
            }
            catch
            {

            }
            logCall.Event = theEvent;

            PatientRecords patientRecords = new PatientRecords();
            patientRecords.InsertLogCall(logCall);
        }