public void Post([FromBody] List<Person> person)
        {
            EBSEmployee employee = null;
            string voiceMessage = string.Empty;
            string textMessage = string.Empty;
            string emailSubject = string.Empty;
            string emailMessage = string.Empty;
            SendEmail sendEmail;
            RestAPI plivo = new RestAPI(EBSParamters.AuthorizationID,EBSParamters.AuthorizationToken);

            EBSParamters.FileNumber = GetFileNumber();
            AddOneToCurrentFileNumber();

            EBSParamters.AnswerURL = Properties.Settings.Default.websiteaddress
                + "ems/audiofiles/"
                + EBSParamters.FileNumber
                + Properties.Settings.Default.AnswerURL;

            string textFromNumber = string.Empty;

            string[] messages = person[0].Message.Split('~');

            voiceMessage = messages[0];
            textMessage = messages[3];
            emailSubject = messages[1];
            emailMessage = messages[2];
            //CreateVoiceMessage
            DeleteFolder(EBSParamters.CopyVoiceFileTo);
            CreateXMLFiles();
            CreateVoiceFile(voiceMessage, "", "");

            for (int i = 0; i < person.Count; i++)
            {
                employee = ebsData.GetEmployeeData(person[i].EmployeeID);


                try
                {
                    employee.Phone_Mobile = employee.Phone_Mobile.Replace("-", "")
                        .Replace("(", "")
                        .Replace(")", "")
                        .Replace(" ", "");
                }
                catch { }


                try
                {
                    employee.Phone_Home = employee.Phone_Home.Replace("-", "")
                        .Replace("(", "")
                        .Replace(")", "")
                        .Replace(" ", "");
                }
                catch { }
                
                //make call to home phone
                if(employee.Flag_Home_tel == "Y")
                {
                    try
                    {
                        // Place a call
                        // string ss = plivo.get_cdr.PlivoVersion;
                        IRestResponse<Call> resp = plivo.make_call(new dict {
                        { "to", "1" + employee.Phone_Home},
                        { "from", EBSParamters.FromNumber},
                        { "answer_url", EBSParamters.AnswerURL },
                        { "hangup_url", EBSParamters.HangUpURL},
                        { "answer_method", "GET"},
                        { "caller_name", employee.Name_First}
                        });
                        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);
                        }
                    }
                    catch (Exception er)
                    {
                        //Log(er.Message, logpath);
                    }
                }
                //Send text
                if (employee.flag_mobile_tel == "Y")
                {
                    // RestAPI plivo = new RestAPI(textAuthId, textAuthToken);
                    IRestResponse<MessageResponse> resp = plivo.send_message(new Dictionary<string, string>() 
                        {
                            { "src", EBSParamters.FromNumber },
                            { "dst", "1" + employee.Phone_Mobile},
                            { "text", textMessage }
                        });


                    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);
                        //Console.ReadKey();
                    }



                }
                //Send email
                if (employee.Flag_email == "Y")
                {
                    sendEmail = new SendEmail();
                    sendEmail._emailFrom = EBSParamters.MailFrom;
                    sendEmail._emailFromFriendlyName = EBSParamters.MailFromFriendlyName;
                    sendEmail._smtpHost = EBSParamters.SmtpHost;
                    sendEmail._smtpHostUserName = EBSParamters.SmtpUser;
                    sendEmail._smtpHostPassword = EBSParamters.SmtpPassword;
                    sendEmail._emailBody = emailMessage;
                    sendEmail._emailSubject = emailSubject;
                    sendEmail._emailTo = employee.Email_personal;
                    sendEmail._emailToFriendlyName = employee.Name_First + " " + employee.Name_Last;

                    try
                    {
                        sendEmail.SendAnEmail();
                    }
                    catch (Exception er)
                    {
                        //Log(er.Message, logFilePath);
                    }
                }
                //make call to mobile
                if (employee.flag_mobile_tel == "Y")
                {
                    try
                    {
                        // Place a call
                        // string ss = plivo.get_cdr.PlivoVersion;
                        IRestResponse<Call> resp = plivo.make_call(new dict {
                        { "to", "1" + employee.Phone_Mobile},
                        { "from", EBSParamters.FromNumber},
                        { "answer_url", EBSParamters.AnswerURL },
                        { "hangup_url", EBSParamters.HangUpURL},
                        { "answer_method", "GET"},
                        { "caller_name", employee.Name_First}
                        });
                        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);
                        }
                    }
                    catch (Exception er)
                    {
                        //Log(er.Message, logpath);
                    }
                }
            }

            string ff = string.Empty;
            //locations.UpdateLocation(locationList);
        }
        public void Post([FromBody] List<Person> person)
        {
            EBSEmployee employee = null;
            string voiceMessage = string.Empty;
            string textMessage = string.Empty;
            string emailSubject = string.Empty;
            string emailMessage = string.Empty;
            SendEmail sendEmail;
            RestAPI plivo = new RestAPI(EBSParamters.AuthorizationID, EBSParamters.AuthorizationToken);

            EBSParamters.FileNumber = GetFileNumber();
            AddOneToCurrentFileNumber();

            EBSParamters.AnswerURL = Properties.Settings.Default.websiteaddress
                + "ems/audiofiles/"
                + EBSParamters.FileNumber
                + Properties.Settings.Default.AnswerURL;

            string textFromNumber = string.Empty;

            string[] messages = person[0].Message.Split('~');

            voiceMessage = messages[0];
            textMessage = messages[3];
            emailSubject = messages[1];
            emailMessage = messages[2];
            DeleteFolder(EBSParamters.CopyVoiceFileTo);
            CreateXMLFiles();
            CreateVoiceFile(voiceMessage, "", "");

            for (int i = 0; i < person.Count; i++)
            {
                employee = ebsData.GetEmployeeData(person[i].EmployeeID);
                try
                {
                    employee.Phone_Mobile = employee.Phone_Mobile.Replace("-", "")
                        .Replace("(", "")
                        .Replace(")", "")
                        .Replace(" ", "");
                }
                catch { }


                try
                {
                    employee.Phone_Home = employee.Phone_Home.Replace("-", "")
                        .Replace("(", "")
                        .Replace(")", "")
                        .Replace(" ", "");
                }
                catch { }

                if (employee.Flag_Home_tel == "Y")
                {
                    try
                    {
                        IRestResponse<Call> resp = plivo.make_call(new dict {
                        { "to", "1" + employee.Phone_Home},
                        { "from", EBSParamters.FromNumber},
                        { "answer_url", EBSParamters.AnswerURL },
                        { "hangup_url", EBSParamters.HangUpURL},
                        { "answer_method", "GET"},
                        { "caller_name", employee.Name_First}
                        });
                        if (resp.Data != null)
                        {
                            Log("C:\\temp\\", "EBSRunnint.log", "Call to: " + employee.Phone_Home + " successful");
                        }
                        else
                        {
                            Console.WriteLine(resp.ErrorMessage);
                            Log("C:\\temp\\", "EBSRunnint.log", "Call to: " + employee.Phone_Home + " failed");
                        }
                    }
                    catch (Exception er)
                    {
                        Log("C:\\temp\\", "Error.log", er.ToString());
                    }
                }
                if (employee.flag_mobile_tel == "Y")
                {
                    try
                    {
                        IRestResponse<MessageResponse> resp = plivo.send_message(new Dictionary<string, string>() 
                        {
                            { "src", EBSParamters.FromNumber },
                            { "dst", "1" + employee.Phone_Mobile},
                            { "text", textMessage }
                        });


                        if (resp.Data != null)
                        {
                            Log("C:\\temp\\", "EBSRunnint.log", "Text to: " + employee.Phone_Mobile + " successful");
                        }
                        else
                        {
                            Log("C:\\temp\\", "EBSRunnint.log", "Text to: " + employee.Phone_Mobile + " failed");
                        }
                    }
                    catch (Exception er)
                    {
                        Log("C:\\temp\\", "Error.log", er.ToString());
                    }
                }
                if (employee.Flag_email == "Y")
                {
                    sendEmail = new SendEmail();
                    sendEmail._emailFrom = EBSParamters.MailFrom;
                    sendEmail._emailFromFriendlyName = EBSParamters.MailFromFriendlyName;
                    sendEmail._smtpHost = EBSParamters.SmtpHost;
                    sendEmail._smtpHostUserName = EBSParamters.SmtpUser;
                    sendEmail._smtpHostPassword = EBSParamters.SmtpPassword;
                    sendEmail._emailBody = emailMessage;
                    sendEmail._emailSubject = emailSubject;
                    sendEmail._emailTo = employee.Email_personal;
                    sendEmail._emailToFriendlyName = employee.Name_First + " " + employee.Name_Last;
                    try
                    {
                        sendEmail.SendAnEmail();
                        Log("C:\\temp\\", "EBSRunnint.log", "Email to: " + employee.Email_personal + " successful");
                    }
                    catch (Exception er)
                    {
                        Log("C:\\temp\\", "EBSRunnint.log", "Email to: " + employee.Email_personal + " failed");
                        Log("C:\\temp\\", "Error.log", er.ToString());
                    }
                }
                if (employee.flag_mobile_tel == "Y")
                {
                    try
                    {
                        IRestResponse<Call> resp = plivo.make_call(new dict {
                        { "to", "1" + employee.Phone_Mobile},
                        { "from", EBSParamters.FromNumber},
                        { "answer_url", EBSParamters.AnswerURL },
                        { "hangup_url", EBSParamters.HangUpURL},
                        { "answer_method", "GET"},
                        { "caller_name", employee.Name_First}
                        });
                        if (resp.Data != null)
                        {
                            Log("C:\\temp\\", "EBSRunnint.log", "Call to : " + employee.Phone_Mobile + " successful");
                        }
                        else
                        {
                            Log("C:\\temp\\", "EBSRunnint.log", "Call to : " + employee.Phone_Mobile + " failed");
                            Console.WriteLine(resp.ErrorMessage);
                        }
                    }
                    catch (Exception er)
                    {
                        Log("C:\\temp\\", "Error.log", er.ToString());
                    }
                }
            }
        }
        public string ProcessNotifications(string textMessage, string emailSubject, string emailMessage)
        {
            string _pathTofile = string.Empty;
            string _first = string.Empty;
            string _last = string.Empty;
            string _email = string.Empty;
            string _cellPhone = string.Empty;
            string _callPhone = string.Empty;
            string _phoneCallToTheHouse1 = string.Empty;
            string _phoneCallToMobilePhone2 = string.Empty;
            string _textMessageToMobilePhone3 = string.Empty;
            string _emailToThirdPartyAddress4 = string.Empty;
            string _reminders = string.Empty;
            string _waldenReminderPublic = string.Empty;
            string _name = string.Empty;
            bool _callsAreBeingMade = false;
            SendEmail _sendEmail;
            int _telephoneID = 1000;
            int _nameID = 100;
            string textAuthId = string.Empty;
            string textAuthToken = string.Empty;
            string textFromNumber = string.Empty;
            string logFilePath = System.Configuration
                .ConfigurationManager.AppSettings["logfile"];

            string name = string.Empty;
            string answerURL = System.Configuration
                .ConfigurationManager.AppSettings["answer"];
            string hangupURL = System.Configuration
                .ConfigurationManager.AppSettings["hangup"];
            string connection = System.Configuration
                       .ConfigurationManager.AppSettings["sqlconnection"];

            string xlmFile = string.Empty;

            textAuthId = ConfigurationManager.AppSettings["textAuthId"];
            textAuthToken = ConfigurationManager.AppSettings["textAuthToken"];
            textFromNumber = ConfigurationManager.AppSettings["textFromNumber"];


            //Issue with ampersand
            //public string ProcessNotifications(string textMessage, string emailSubject, string emailMessage)

            RestAPI plivo = new RestAPI(textAuthId, textAuthToken);

            _reminders = ConfigurationManager.ConnectionStrings["reminders"].ConnectionString;
            /*
            try
            {
                //File.Delete("C:\\waldenltd\\CONNECTEMG.WAV");
                System.IO.File.Delete(ConfigurationManager.AppSettings["PathToVoiceFiles"]
                    + ConfigurationManager.AppSettings["FileName"]);
            }
            catch (Exception er)
            {
                Log(er.Message, logFilePath);            
            }

            try
            {
               // Debug.WriteLine(RadAsyncUpload1.TargetFolder + "\\" + RadAsyncUpload1.UploadedFiles[0].GetName());
               // WAVFile.CopyAndConvert(RadAsyncUpload1.TargetFolder + "\\" + RadAsyncUpload1.UploadedFiles[0].GetName()
               //     , ConfigurationManager.AppSettings["PathToVoiceFiles"]
               //     + ConfigurationManager.AppSettings["FileName"], 8, false);
            }
             */
            //catch (Exception er)
            //{
            //    Log(er.Message, logFilePath);            
            //}


            _pathTofile = ConfigurationManager.AppSettings["copyvoicefileto"] + ConfigurationManager.AppSettings["employeefilename"];
            int counter = 0;
            string line;

            string _delimStr = ",";
            char[] _delimiter = _delimStr.ToCharArray();
            string[] _list = null;
            string[] _names = null;


            string _delimStr2 = " ";
            char[] _delimiter2 = _delimStr2.ToCharArray();

            // Read the file and display it line by line.
            System.IO.StreamReader file =
               new System.IO.StreamReader(_pathTofile);
            while ((line = file.ReadLine()) != null)
            {
                //Debug.WriteLine(DateTime.Now.ToShortTimeString());

                _list = line.Split(_delimiter, 15);

                _name = _list[1].Replace("\"", "");

                _names = _name.Split(_delimiter2, 2);

                _last = _names[0];
                _first = _names[1];
                _email = _list[4].Replace("\"", "");
                _cellPhone = _list[3].Replace("\"", "");
                _cellPhone = _cellPhone.Replace("-", "")
                    .Replace("(", "")
                    .Replace(")", "")
                    .Replace(" ", "");

                _callPhone = _list[2].Replace("\"", "");

                _callPhone = _callPhone.Replace("-", "")
                    .Replace("(", "")
                    .Replace(")", "")
                    .Replace(" ", "");

                //The first flag in the file is for calling home
                _phoneCallToTheHouse1 = _list[5].Replace("\"", "");

                //The second flag in the file is for calling mobile                
                _phoneCallToMobilePhone2 = _list[6].Replace("\"", "");

                //The third flag in the file is for sending text to mobile phone
                _textMessageToMobilePhone3 = _list[7].Replace("\"", "");

                //The fourth flag in the file is for sending email
                _emailToThirdPartyAddress4 = _list[8].Replace("\"", "");

                //Do texting first because calling text phone number may have 9 in it
                if (_textMessageToMobilePhone3 == "Y")
                {
                    // RestAPI plivo = new RestAPI(textAuthId, textAuthToken);
                    IRestResponse<MessageResponse> resp = plivo.send_message(new Dictionary<string, string>() 
                        {
                            { "src", textFromNumber },
                            { "dst", "1" + _cellPhone },
                            { "text", textMessage }
                        });


                    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);
                        //Console.ReadKey();
                    }
                }

                if (_phoneCallToTheHouse1 == "Y")
                {
                    _callsAreBeingMade = true;

                    if (_callPhone.Length > 9)
                    {
                        try
                        {
                            ////using (OdbcConnection cn2 = new OdbcConnection(Database.WaldenReminderPublic))
                            //using (MySql.Data.MySqlClient.MySqlConnection cn2 = new MySql.Data.MySqlClient.MySqlConnection(_reminders))
                            //{
                            //    cn2.Open();
                            //    using (MySql.Data.MySqlClient.MySqlCommand cm2 = cn2.CreateCommand())
                            //    {
                            //        cm2.CommandText = "insert into pendingtelephone(IDTelephone,Company_ID,"
                            //            + "MessageTime,NameID,FirstName,LastName,DateOfAppointment,"
                            //            + "TimeOfAppointment,TimeForDelete,"
                            //            + "TelephoneNumber1,TelephoneNumber2,TelephoneFile,"
                            //            + "Completed,InUse,CallWait,ResultDescription,"
                            //            + "Acknowledge,CallBack,Cancel,Busy,Call_Count,Charge"
                            //            + ")values("
                            //            + _telephoneID.ToString() + ","		                            //IDTelephone
                            //            + ConfigurationManager.AppSettings["CompanyID"] + ","	        //Company_ID
                            //            + "0,"                                		                    //MessageTime
                            //            + _nameID.ToString() + ","	    		                        //NameID
                            //            + "'" + _first.Replace("'", "''") + "',"	                    //FirstName
                            //            + "'" + _last.Replace("'", "''") + "',"		                    //LastName
                            //            //+ "'" + dr["DoctorToSee"].ToString().Replace("'", "''") + "',"//DoctorToSee
                            //            + "'" + DateTime.Now.ToShortDateString() + "',"	                //DateOfAppointme
                            //            + "'" + DateTime.Now.ToShortTimeString() + "',"	            //TimeOfAppointment
                            //            + "'1899-12-30 09:15:00',"		                                 //TimeForDelete
                            //            //+ "'" + dr["Day"].ToString() + "',"		                    //Day
                            //            //+ "'" + dr["Date1"].ToString() + "',"		                    //Date1
                            //            //+ "'" + dr["Date2"].ToString() + "',"		                    //Date2
                            //            //+ "'" + dr["ApTime"].ToString() + "',"		                //ApTime
                            //            //+ "'" + dr["Location"].ToString().Replace("'", "''") + "',"	//Location
                            //            + "'" + _callPhone + "',"	                                    //TelephoneNumber1
                            //            + "'0',"	                                                    //TelephoneNumber1
                            //            + "'" + _callPhone + "',"		                                //TelephoneFile
                            //            //+ "'" + dr["ReasonCode"].ToString().Replace("'", "''") + "',"	//ReasonCode
                            //            //+ "'" + dr["ReasonForAppointment"].ToString().Replace("'", "''") + "',"//ReasonForAppointment
                            //            + "'N',"		                                                //Completed
                            //            + "'N',"		                                                //InUse
                            //            + "'0',"		                                                //CallWait
                            //            + "'Waiting To Call',"                                        //ResultDescription
                            //            + "'N',"		                                                //Acknowledge
                            //            + "'N',"		                                                //CallBack
                            //            + "'N',"		                                                //Cancel
                            //            + "'0',"		                                                //Busy
                            //            + "0,"		                                                    //Call_Count
                            //            //+ "'" + dr["Time_Of_Call"].ToString() + "',"		            //Time_Of_Call
                            //            + "'0')";		                                                //Charge

                            //        Debug.WriteLine(cm2.CommandText);
                            //        cm2.ExecuteNonQuery();
                            //    }
                            //}
                        }
                        catch (Exception er)
                        {
                            //Log(er.Message, logFilePath);
                        }
                        _telephoneID++;
                        _nameID++;
                    }
                }
                if (_phoneCallToMobilePhone2 == "Y")
                {
                    _callsAreBeingMade = true;
                    if (_cellPhone.Length > 9)
                    {
                        try
                        {
                            ////using (OdbcConnection cn2 = new OdbcConnection(Database.WaldenReminderPublic))
                            //using (MySql.Data.MySqlClient.MySqlConnection cn2 = new MySql.Data.MySqlClient.MySqlConnection(_reminders))
                            //{
                            //    cn2.Open();
                            //    using (MySql.Data.MySqlClient.MySqlCommand cm2 = cn2.CreateCommand())
                            //    {

                            //        cm2.CommandText = "insert into pendingtelephone(IDTelephone,Company_ID,"
                            //            + "MessageTime,NameID,FirstName,LastName,DateOfAppointment,"
                            //            + "TimeOfAppointment,TimeForDelete,"
                            //            + "TelephoneNumber1,TelephoneNumber2,TelephoneFile,"
                            //            + "Completed,InUse,CallWait,ResultDescription,"
                            //            + "Acknowledge,CallBack,Cancel,Busy,Call_Count,Charge"
                            //            + ")values("
                            //            + _telephoneID.ToString() + ","		                            //IDTelephone
                            //            + ConfigurationManager.AppSettings["CompanyID"] + ","	        //Company_ID
                            //            + "0,"                                		                    //MessageTime
                            //            + _nameID.ToString() + ","	    		                        //NameID
                            //            + "'" + _first.Replace("'", "''") + "',"	                    //FirstName
                            //            + "'" + _last.Replace("'", "''") + "',"		                    //LastName
                            //            //+ "'" + dr["DoctorToSee"].ToString().Replace("'", "''") + "',"//DoctorToSee
                            //            + "'" + DateTime.Now.ToShortDateString() + "',"	                //DateOfAppointme
                            //            + "'" + DateTime.Now.ToShortTimeString() + "',"	            //TimeOfAppointment
                            //            + "'1899-12-30 09:15:00',"		                                 //TimeForDelete
                            //            //+ "'" + dr["Day"].ToString() + "',"		                    //Day
                            //            //+ "'" + dr["Date1"].ToString() + "',"		                    //Date1
                            //            //+ "'" + dr["Date2"].ToString() + "',"		                    //Date2
                            //            //+ "'" + dr["ApTime"].ToString() + "',"		                //ApTime
                            //            //+ "'" + dr["Location"].ToString().Replace("'", "''") + "',"	//Location
                            //            + "'" + _cellPhone + "',"	                                    //TelephoneNumber1
                            //            + "'0',"	                                                    //TelephoneNumber1
                            //            + "'" + _cellPhone + "',"		                                //TelephoneFile
                            //            //+ "'" + dr["ReasonCode"].ToString().Replace("'", "''") + "',"	//ReasonCode
                            //            //+ "'" + dr["ReasonForAppointment"].ToString().Replace("'", "''") + "',"//ReasonForAppointment
                            //            + "'N',"		                                                //Completed
                            //            + "'N',"		                                                //InUse
                            //            + "'0',"		                                                //CallWait
                            //            + "'Waiting To Call',"                                        //ResultDescription
                            //            + "'N',"		                                                //Acknowledge
                            //            + "'N',"		                                                //CallBack
                            //            + "'N',"		                                                //Cancel
                            //            + "'0',"		                                                //Busy
                            //            + "0,"		                                                    //Call_Count
                            //            //+ "'" + dr["Time_Of_Call"].ToString() + "',"		            //Time_Of_Call
                            //            + "'0')";		                                                //Charge

                            //        //Debug.WriteLine(cm2.CommandText);
                            //        try
                            //        {
                            //            cm2.ExecuteNonQuery();
                            //        }
                            //        catch (Exception er)
                            //        {
                            //            Log(er.Message, logFilePath);
                            //        }
                            //    }
                            //}
                        }
                        catch (Exception er)
                        {
                            //Log(er.Message, logFilePath);
                        }
                        _telephoneID++;
                        _nameID++;
                    }
                }

                if (_emailToThirdPartyAddress4 == "Y")
                {
                    _sendEmail = new SendEmail();
                    _sendEmail._emailFrom = ConfigurationManager.AppSettings["MailFrom"];
                    _sendEmail._emailFromFriendlyName = ConfigurationManager.AppSettings["MailFromFriendlyName"];
                    _sendEmail._smtpHost = ConfigurationManager.AppSettings["SmtpHost"];
                    _sendEmail._smtpHostUserName = ConfigurationManager.AppSettings["SmtpUser"];
                    _sendEmail._smtpHostPassword = ConfigurationManager.AppSettings["SmtpPassword"];
                    _sendEmail._emailBody = emailMessage;
                    _sendEmail._emailSubject = emailSubject;
                    _sendEmail._emailTo = _email;
                    _sendEmail._emailToFriendlyName = _first + " " + _last;
                    try
                    {
                        _sendEmail.SendAnEmail();
                    }
                    catch (Exception er)
                    {
                        //Log(er.Message, logFilePath);
                    }
                }
                //Debug.WriteLine(_last);
                Console.WriteLine(line);
                counter++;
            }

            file.Close();

            //xlmFile = CreateXMLFiles();

            //using (var process = new Process())
            //{
            //    process.StartInfo.FileName = ConfigurationManager.AppSettings["callingapp"];
            //    process.StartInfo.Arguments = xlmFile;
            //    process.Start();
            //}

            //Put code in that will make calls
            //***************************************************************************************************
            //using (MySqlConnection cn = new MySqlConnection(_reminders))
            //{
            //    cn.Open();
            //    using (MySqlCommand cm = cn.CreateCommand())
            //    {
            //        cm.CommandText = "select ID,FirstName,LastName,TelephoneNumber1 from pendingtelephone"
            //            + " where ResultDescription = 'Waiting To Call'";
            //        cm.CommandType = System.Data.CommandType.Text;
            //        MySqlDataReader dr = cm.ExecuteReader();
            //        while (dr.Read())
            //        {
            //            Console.WriteLine(dr["TelephoneNumber1"].ToString());
            //            name = dr["FirstName"].ToString() + " " + dr["LastName"].ToString();
            //            // Place a call
            //            IRestResponse<Call> resp = plivo.make_call(new dict {
            //            { "to", "1" +  dr["TelephoneNumber1"].ToString()},
            //            { "from", textFromNumber},
            //            { "answer_url", xlmFile },
            //            { "hangup_url", hangupURL},
            //            { "answer_method", "GET" },
                        
            //            { "caller_name", name }
            //            });
            //            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);
            //            using (MySql.Data.MySqlClient.MySqlConnection cn2 = new MySql.Data.MySqlClient.MySqlConnection(_reminders))
            //            {
            //                cn2.Open();
            //                using (MySql.Data.MySqlClient.MySqlCommand cm2 = cn2.CreateCommand())
            //                {
            //                    cm2.CommandText = "update pendingtelephone set busy = 60"
            //                        + " ,COMPLETED = 'Y'"
            //                        + " ,RESULTDESCRIPTION = 'Call Completed'"
            //                        + " WHERE ID = " + dr["ID"].ToString();

            //                    // Debug.WriteLine(cm2.CommandText);
            //                    cm2.ExecuteNonQuery();
            //                }
            //            }
            //        }
            //    }
            //}
            //AddOneToCurrentFileNumber();

            return "OK";
        }