public ApplicationSettings(string ApplicationSettingsFilePath)
        {
            APPLICATIONSETTINGSFILEPATH = ApplicationSettingsFilePath;

            _LastOperationReturn = ApplicationTypes.ApplicationSettingsReturn.NONE;

            _BasicInsertionThrottling_Enabled = false;
            _BasicInsertionThrottling_MaximumRecordsAtATime = Constants.BASIC_INSERTION_THROTTLING_MAXIMUM_RECORDS_AT_A_TIME;

            _DebugEnabled     = false;
            _DebugLevel       = "verbose";
            _DebugRetainUnit  = "files";
            _DebugRetainValue = "100";
        }
        public ApplicationTypes.ApplicationSettingsReturn Load()
        {
            Trace.TraceInformation("Enter.");

            try
            {
                if (!System.IO.File.Exists(APPLICATIONSETTINGSFILEPATH + "\\" + Constants.APPLICATIONSETTINGSFILENAME))
                {
                    Trace.TraceWarning(APPLICATIONSETTINGSFILEPATH + "\\" + Constants.APPLICATIONSETTINGSFILENAME + " was not found.");
                    _LastOperationReturn = ApplicationTypes.ApplicationSettingsReturn.FILE_NOT_FOUND;
                    return(_LastOperationReturn);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("Exception:" + ex.Message + Environment.NewLine + "StackTrace:" + ex.StackTrace);
                _LastOperationReturn = ApplicationTypes.ApplicationSettingsReturn.ERROR;
                return(_LastOperationReturn);
            }

            try
            {
                _encDec = new com.workflowconcepts.utilities.AESSymmetricEncryption(Constants.ENCRYPTION_PASSWORD, Constants.ENCRYPTION_SALT);

                System.Xml.XmlDocument   xmlDoc = null;
                System.Xml.XmlNodeReader reader = null;

                xmlDoc = new System.Xml.XmlDocument();

                xmlDoc.Load(APPLICATIONSETTINGSFILEPATH + "\\" + Constants.APPLICATIONSETTINGSFILENAME);

                reader = new System.Xml.XmlNodeReader(xmlDoc);

                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case System.Xml.XmlNodeType.Element:

                        if (reader.Name.Equals("WebServer"))
                        {
                            _WebServerIP                 = reader.GetAttribute("IP");
                            _WebServerPort               = reader.GetAttribute("Port");
                            _WebServerPrefix             = reader.GetAttribute("Prefix");
                            _WebServerDataCollectionPort = reader.GetAttribute("DataCollectionPort");
                        }

                        if (reader.Name.Equals("EmailNotifications"))
                        {
                            _EmailFrom       = reader.GetAttribute("EmailFrom");
                            _EmailTo         = reader.GetAttribute("EmailTo");
                            _EmailSMTPServer = reader.GetAttribute("SMTPServer");
                            _EmailSMTPPort   = reader.GetAttribute("SMTPPort");

                            try
                            {
                                _EmailSMTPUserName = _encDec.Decrypt(reader.GetAttribute("SMTPUser"));
                            }
                            catch
                            {
                                _EmailSMTPUserName = string.Empty;
                            }

                            try
                            {
                                _EmailSMTPPassword = _encDec.Decrypt(reader.GetAttribute("SMTPPassword"));
                            }
                            catch
                            {
                                _EmailSMTPPassword = string.Empty;
                            }

                            try
                            {
                                _EmailOnFailure = Boolean.Parse(reader.GetAttribute("OnFailure"));
                            }
                            catch
                            {
                                _EmailOnFailure = true;
                            }

                            try
                            {
                                _EmailOnSuccess = Boolean.Parse(reader.GetAttribute("OnSuccess"));
                            }
                            catch
                            {
                                _EmailOnSuccess = false;
                            }
                        }

                        if (reader.Name.Equals("UCCX"))
                        {
                            _UCCXNode1IPAddress         = reader.GetAttribute("Node1IPAddress");
                            _UCCXNode2IPAddress         = reader.GetAttribute("Node2IPAddress");
                            _UCCXApplicationPort        = reader.GetAttribute("ApplicationPort");
                            _UCCXRealtimeDataPort       = reader.GetAttribute("RealtimeDataPort");
                            _UCCXAuthorizationPrefix    = reader.GetAttribute("AuthorizationPrefix");
                            _UCCXCallbackPrefix         = reader.GetAttribute("CallbackPrefix");
                            _UCCXNumberOfIVRPorts       = reader.GetAttribute("NumberOfIVRPorts");
                            _UCCXMaxIVRPortUsagePercent = reader.GetAttribute("MaxIVRPortUsagePercent");

                            try
                            {
                                int iUCCXMaxLicenseUsagePercent = int.Parse(_UCCXMaxIVRPortUsagePercent);

                                if (iUCCXMaxLicenseUsagePercent < 0)
                                {
                                    _UCCXMaxIVRPortUsagePercent = "0";
                                }

                                if (iUCCXMaxLicenseUsagePercent >= 100)
                                {
                                    _UCCXMaxIVRPortUsagePercent = "99";
                                }
                            }
                            catch
                            {
                                _UCCXMaxIVRPortUsagePercent = "0";
                            }

                            try
                            {
                                int iUccxNumberOfLicenses = int.Parse(_UCCXNumberOfIVRPorts);

                                if (iUccxNumberOfLicenses < 0)
                                {
                                    _UCCXNumberOfIVRPorts = "0";
                                }
                            }
                            catch
                            {
                                _UCCXNumberOfIVRPorts = "0";
                            }

                            try
                            {
                                _UCCXAdminUser          = _encDec.Decrypt(reader.GetAttribute("AdminUser"));
                                _EncryptedUCCXAdminUser = reader.GetAttribute("AdminUser");
                            }
                            catch
                            {
                                _UCCXAdminUser = String.Empty;
                            }

                            try
                            {
                                _UCCXAdminPassword          = _encDec.Decrypt(reader.GetAttribute("AdminPassword"));
                                _EncryptedUCCXAdminPassword = reader.GetAttribute("AdminPassword");
                            }
                            catch
                            {
                                _UCCXAdminPassword = String.Empty;
                            }
                        }

                        if (reader.Name.Equals("CallbackRecords"))
                        {
                            try
                            {
                                _MaximumNumberOfDays = int.Parse(reader.GetAttribute("MaximumNumberOfDays"));

                                if (_MaximumNumberOfDays < 0)
                                {
                                    _MaximumNumberOfDays = Constants.MAXIMUM_NUMBER_OF_DAYS;
                                }
                            }
                            catch
                            {
                                _MaximumNumberOfDays = Constants.MAXIMUM_NUMBER_OF_DAYS;
                            }

                            try
                            {
                                _MaximumNumberOfAttempts = int.Parse(reader.GetAttribute("MaximumNumberOfAttempts"));

                                if (_MaximumNumberOfAttempts <= 0)
                                {
                                    _MaximumNumberOfAttempts = Constants.MAXIMUM_NUMBER_OF_ATTEMPTS;
                                }
                            }
                            catch
                            {
                                _MaximumNumberOfAttempts = Constants.MAXIMUM_NUMBER_OF_ATTEMPTS;
                            }

                            try
                            {
                                _MinimumIntervalBetweenRetries = int.Parse(reader.GetAttribute("MinimumIntervalBetweenRetries"));

                                if (_MinimumIntervalBetweenRetries <= 0)
                                {
                                    _MinimumIntervalBetweenRetries = Constants.MINIMUM_INTERVAL_BETWEEN_RETRIES;
                                }
                            }
                            catch
                            {
                                _MinimumIntervalBetweenRetries = Constants.MINIMUM_INTERVAL_BETWEEN_RETRIES;
                            }
                        }

                        if (reader.Name.Equals("BasicInsertionThrottling"))
                        {
                            try
                            {
                                _BasicInsertionThrottling_Enabled = Boolean.Parse(reader.GetAttribute("Enabled"));
                            }
                            catch
                            {
                                _BasicInsertionThrottling_Enabled = false;
                            }

                            try
                            {
                                _BasicInsertionThrottling_MaximumRecordsAtATime = int.Parse(reader.GetAttribute("MaximumAtATime"));

                                if (_BasicInsertionThrottling_MaximumRecordsAtATime <= 0)
                                {
                                    _BasicInsertionThrottling_MaximumRecordsAtATime = Constants.BASIC_INSERTION_THROTTLING_MAXIMUM_RECORDS_AT_A_TIME;
                                }
                            }
                            catch
                            {
                                _BasicInsertionThrottling_MaximumRecordsAtATime = Constants.BASIC_INSERTION_THROTTLING_MAXIMUM_RECORDS_AT_A_TIME;
                            }
                        }

                        if (reader.Name.Equals("API"))
                        {
                            try
                            {
                                _NumberOfAPIThreads = int.Parse(reader.GetAttribute("NumberOfHandlerThreads"));

                                if (_NumberOfAPIThreads <= 0)
                                {
                                    _NumberOfAPIThreads = Constants.NUMBER_OF_HANDLER_THREADS;
                                }
                            }
                            catch
                            {
                                _NumberOfAPIThreads = Constants.NUMBER_OF_HANDLER_THREADS;
                            }

                            try
                            {
                                _APIHandlerThreadsSleep = int.Parse(reader.GetAttribute("HandlerThreadsSleep"));

                                if (_APIHandlerThreadsSleep <= 0)
                                {
                                    _APIHandlerThreadsSleep = Constants.API_HANDLER_THREADS_SLEEP;
                                }
                            }
                            catch
                            {
                                _APIHandlerThreadsSleep = Constants.API_HANDLER_THREADS_SLEEP;
                            }
                        }

                        if (reader.Name.Equals("Debug"))
                        {
                            try
                            {
                                _DebugEnabled = Boolean.Parse(reader.GetAttribute("Enabled"));
                            }
                            catch
                            {
                                _DebugEnabled = false;
                            }

                            _DebugLevel       = reader.GetAttribute("Level");
                            _DebugRetainUnit  = reader.GetAttribute("RetainUnit");
                            _DebugRetainValue = reader.GetAttribute("RetainValue");
                        }

                        break;
                    }
                }

                reader.Close();
                reader = null;

                xmlDoc = null;

                _encDec = null;

                _LastOperationReturn = ApplicationTypes.ApplicationSettingsReturn.SUCCESS;
                return(_LastOperationReturn);
            }
            catch (Exception ex)
            {
                _encDec = null;
                Trace.TraceError("Exception:" + ex.Message + Environment.NewLine + "StackTrace:" + ex.StackTrace);
                _LastOperationReturn = ApplicationTypes.ApplicationSettingsReturn.ERROR;
                return(_LastOperationReturn);
            }
        }