static void Main(string[] args)
        {

            bool isUnlocked = ftpclient.UnlockComponent("SCOTTGFTP_bsex2TmE3Znh");

            Database.PenChart = System.Configuration.ConfigurationManager.AppSettings["databaseConnection"];
            Database.ReminderConnection = System.Configuration.ConfigurationManager.AppSettings["reminderConnection"];
            Database.ReminderCloud = System.Configuration.ConfigurationManager.AppSettings["reminderCloud"];
            Database.ReminderOld = System.Configuration.ConfigurationManager.AppSettings["reminderOld"];
            Database.SRSMessage = System.Configuration.ConfigurationManager.AppSettings["srsMessage"];

            //patientRecords.EndOfDayUpdate();
            //UpDateProviderList();
            //if (System.Configuration
            //    .ConfigurationManager.AppSettings["createHistory"] == "T")
            //{
            //    CreateHistory();
            //}
            //reporting.PopulateReportTable();
            //monitorCommunications = new MonitorCommunications();
            //monitorCommunications.CreateSRSMessages(System.Configuration.ConfigurationManager.AppSettings["messagePath"],
            //    System.Configuration.ConfigurationManager.AppSettings["templatePath"],
            //    System.Configuration.ConfigurationManager.AppSettings["audioMessagingPath"]);

           // reporting.RepopulatePendingTelephone();
            //..patientRecords.BackupPendingTelephone

            timeToStopProgram = Convert.ToDateTime(System.Configuration
                .ConfigurationManager.AppSettings["timeToStopProgram"]);

            DeleteFolder(System.Configuration
                .ConfigurationManager.AppSettings["voiceFilePath"]);
            DeleteFolder(System.Configuration
                .ConfigurationManager.AppSettings["xmlPath"]);

            //For testing 
            //monitorCommunications = new MonitorCommunications();

            //monitorCommunications = new Monitoring.MonitorCommunications();
            //monitorCommunications.CreateSRSMessages();
            //reporting.PopulateReportTable();
            //Delete current records
            DeletePatientRecords();

            callingRecord = new List<CallingRecord>();
            appointments = new List<Appointments>();


            // Initialize a new instance of the SpeechSynthesizer.
            using (SpeechSynthesizer synth = new SpeechSynthesizer())
            {

                //    // Output information about all of the installed voices. 
                //    Console.WriteLine("Installed voices -");
                foreach (InstalledVoice voice in synth.GetInstalledVoices())
                {
                    VoiceInfo info = voice.VoiceInfo;
                    Console.WriteLine(" Voice Name: " + info.Name);
                }
            } 
            
            CallingRecordsParameters callingRecordsParameters = Common.GetCallingRecordsParameters(System.Configuration.ConfigurationManager.AppSettings["callingRecordsParameters"]);

            //appointments = CallingRecordsFactory.GetRecords(callingRecordsParameters);
          //  PatientCommunication.
            PatientCommunication.Factory.CallingRecordsFactory.GetRecords(callingRecordsParameters);

            CheckTelephoneNumbers();
            CreateVoiceFiles();
            CreateXMLFiles();

            if (System.Configuration.ConfigurationManager.AppSettings["sendToRemoteSite"] == "T")
            {
                SendDocumentsViaFTP();
            }


            //UpDateProviderList();

            MakeCallParameters makeCallParameters = new Model.MakeCallParameters();

            makeCallParameters.AuthorizationID =
                System.Configuration.ConfigurationManager.AppSettings["authid"];
            makeCallParameters.AuthorizationToken =
                System.Configuration.ConfigurationManager.AppSettings["authtoken"];
            makeCallParameters.FromNumber =
                System.Configuration.ConfigurationManager.AppSettings["fromNumber"];

            makeCallParameters.AnswerURL =
                System.Configuration.ConfigurationManager.AppSettings["answerURL"];

            makeCallParameters.HangupURL =
                System.Configuration.ConfigurationManager.AppSettings["hangupURL"];

            makeCallParameters.AnswerMethod =
                System.Configuration.ConfigurationManager.AppSettings["answerMethod"];

            makeCallParameters.NameOfFirstFile =
                            System.Configuration.ConfigurationManager.AppSettings["nameOfFirstFile"];

            makeCallParameters.Type = "R";

            makeTelephoneCalls = new MakeTelephoneCalls(makeCallParameters);

            //Initial calls have been made
            //Start loop for rest of session
            int loop = 0;
            while (loop == 0)
            {
                monitorCommunications = new Monitoring.MonitorCommunications();
                monitorCommunications.GetCallingResults();
                //wait for 30 minutes
                //Thread.Sleep(1800000);
                Thread.Sleep(900000);

                monitorCommunications = new Monitoring.MonitorCommunications();
                monitorCommunications.GetCallingResults();

                makeCallParameters.Type = "M";
                
                makeTelephoneCalls = new MakeTelephoneCalls(makeCallParameters);

                DateTime rightNow = DateTime.Now;

                //check to see if there are calls left to be made
                if (patientRecords.NumberofRecordsToCall() == 0)
                {
                    PerformEndOfDayActivity();
                    loop = 1;
                }

                //Check to see if program should end
                if (rightNow.Ticks > timeToStopProgram.Ticks && loop != 1)
                {
                    PerformEndOfDayActivity();
                    loop = 1;
                }

                //check for time to see if application should be turned off
                //loop = 1;
            }
        }
 private static void PerformEndOfDayActivity()
 {
     patientRecords.EndOfDayUpdate();
     reporting.UpdateReportingTable();
     UpDateProviderList();
     if (System.Configuration
         .ConfigurationManager.AppSettings["createHistory"] == "T")
     {
         CreateHistory();
     }
     reporting.PopulateReportTable();
     monitorCommunications = new MonitorCommunications();
     monitorCommunications.CreateSRSMessages(System.Configuration.ConfigurationManager.AppSettings["messagePath"],
         System.Configuration.ConfigurationManager.AppSettings["templatePath"],
         System.Configuration.ConfigurationManager.AppSettings["audioMessagingPath"]);
 }