/// <summary>
        /// Function that is called if password protection detected
        /// Calls sendEmail constructor and function to send email for password protection.
        /// </summary>
        /// <param name="uploaderID"></param>
        /// <param name="fileName"></param>
        private void sendPasswordProtection(int uploaderID, string fileName)
        {
            CIWEMails sendEmails = new CIWEMails(uploaderID, "", "", "", "", fileName);

            sendEmails.SendPasswordProtection();
        }
        /// <summary>
        /// Processes data after CIW converted to CSV
        /// </summary>
        /// <param name="uploaderID"></param>
        /// <param name="filePath"></param>
        /// <param name="isDebug"></param>
        /// <returns>Int success code</returns>
        public int ProcessCIWInformation(int uploaderID, string filePath, bool isDebug)
        {
            log.Info("Processing CIW");

            //Create validation object
            ValidateCIW validate = new Validation.ValidateCIW();

            List <CIW> ciwInformation = new List <CIW>();

            log.Info(string.Format("Getting file data from temp csv file."));

            //Gets list of CIW's after mapping from csv files
            ciwInformation = GetFileData <CIW, CIWMapping>(filePath, config);

            DataSet fipsCodes = GetFipsCodeFromCountryName(ciwInformation[0].PlaceOfBirthCountryName, ciwInformation[0].HomeCountryName, ciwInformation[0].CitizenCountryName);

            ApplyFipsCodes(ref ciwInformation, fipsCodes);

            CIWEMails sendEmails = new CIWEMails(uploaderID, ciwInformation.First().FirstName, ciwInformation.First().MiddleName,
                                                 ciwInformation.First().LastName, ciwInformation.First().Suffix, Path.GetFileName(filePath),
                                                 CheckIfChildCare(ciwInformation));

            //Delete temp csv file before proceeding
            try
            {
                log.Info(string.Format("Deleting Temp CSV File {0}.", filePath));
                File.Delete(filePath);
            }
            catch (IOException e)
            {
                log.Error("Unable to delete temp file" + e.Message);
                return(0);
            }

            log.Info("Processing " + ciwInformation.First().FullNameForLog);

            log.Info(string.Format("Checking version number. Current version is {0}", ciwInformation.First().VersionNumber));

            //Check version and begin exit if wrong version
            if (ciwInformation.First().VersionNumber != ConfigurationManager.AppSettings["VERSION"])
            {
                log.Warn("Sending Wrong Version Number E-Mail");
                sendEmails.SendWrongVersion();
                log.Warn(string.Format("Inserting error code {0}:{1} into upload table", ErrorCodes.wrong_version, (int)ErrorCodes.wrong_version));
                return((int)ErrorCodes.wrong_version);
            }
            else
            {
                log.Info(string.Format("Version OK"));
            }

            log.Info(string.Format("Checking if ARRA. ARRA selected is: {0}", ciwInformation.First().ArraLongTermContractor));

            //Check if ARRA contractor and begin exit if ARRA
            if (ciwInformation.First().ArraLongTermContractor == "Yes")
            {
                log.Warn("Sending ARRA E-Mail");
                sendEmails.SendARRA();
                log.Warn(string.Format("Inserting error code {0}:{1} into upload table", ErrorCodes.arra, (int)ErrorCodes.arra));
                return((int)ErrorCodes.arra);
            }
            else
            {
                log.Info(string.Format("ARRA is OK"));
            }

            log.Info(String.Format("Checking if {0} is a duplicate user", ciwInformation.First().FullNameForLog));

            //Check if duplicate and begin exit if duplicate exists
            if (!validate.IsDuplicate(ciwInformation))
            {
                log.Warn(String.Format("Duplicate user found for {0}", ciwInformation.First().FullNameForLog));
                sendEmails.SendDuplicateUser();
                log.Warn(string.Format("Inserting error code {0}:{1} into upload table", ErrorCodes.duplicate_user, (int)ErrorCodes.duplicate_user));
                return((int)ErrorCodes.duplicate_user);
            }

            log.Info(String.Format("No existing user found for {0}", ciwInformation.First().FullNameForLog));

            log.Info(String.Format("Company Name Primary is : {0}", !string.IsNullOrWhiteSpace(ciwInformation.FirstOrDefault().CompanyName) ? ciwInformation.FirstOrDefault().CompanyName : "No Company Name Primary"));
            log.Info(String.Format("Company Name Sub is : {0}", !string.IsNullOrWhiteSpace(ciwInformation.FirstOrDefault().CompanyNameSub) ? ciwInformation.FirstOrDefault().CompanyNameSub : "No Company Name Sub"));
            log.Info(String.Format("Checking if form is valid for user {0}", ciwInformation.First().FullNameForLog));



            //Validation is called inside if statement
            if (validate.IsFormValid(ciwInformation))
            {
                log.Info(String.Format("Form is valid for user {0}", ciwInformation.First().FullNameForLog));

                //Create object to begin insertion of ciw into database
                InsertCIW sd = new InsertCIW(ciwInformation.First(), uploaderID);

                int persID = 0;

                //Save the data
                log.Info(String.Format("Begin inserting CIW for {0}", ciwInformation.First().FullNameForLog));
                persID = sd.SaveCIW();

                //Begin sponsorship if successful
                if (persID > 0)
                {
                    sendEmails.SendSponsorshipEMail(persID);
                }
                log.Info(string.Format("Inserting error code {0}:{1} into upload table", ErrorCodes.successfully_processed, (int)ErrorCodes.successfully_processed));
                return((int)ErrorCodes.successfully_processed);
            }
            else
            {
                log.Warn(String.Format("Form failed validation for user {0}", ciwInformation.First().FullNameForLog));

                //E-Mail Failure Template
                //Send error email
                Tuple <ValidationResult, ValidationResult, ValidationResult,
                       ValidationResult, ValidationResult, ValidationResult> ValidationErrors = new Tuple <ValidationResult, ValidationResult, ValidationResult,
                                                                                                           ValidationResult, ValidationResult, ValidationResult>(null, null,
                                                                                                                                                                 null, null, null, null);

                log.Info(string.Format("Getting errors"));

                ValidationErrors = validate.GetErrors();

                log.Info(string.Format("{0} errors returned", CountErrors(ValidationErrors)));

                //send error email which contains a list of each sections errors
                sendEmails.SendErrors(ValidationErrors.Item1, ValidationErrors.Item2, ValidationErrors.Item3,
                                      ValidationErrors.Item4, ValidationErrors.Item5, ValidationErrors.Item6);
                log.Warn(string.Format("Inserting error code {0}:{1} into upload table", ErrorCodes.failed_validation, (int)ErrorCodes.failed_validation));

                return((int)ErrorCodes.failed_validation);
            }
        }
        /// <summary>
        /// Function that is called if wrong version detected.
        /// Calls sendEmail constructor and function to send email for wrong version.
        /// </summary>
        /// <param name="uploaderID"></param>
        /// <param name="fileName"></param>
        private void sendWrongVersion(int uploaderID, string fileName)
        {
            CIWEMails sendEmails = new CIWEMails(uploaderID, "", "", "", "", fileName);

            sendEmails.SendWrongVersion();
        }