예제 #1
0
 private static string GetTokenType(System.IdentityModel.Tokens.GenericXmlSecurityToken token)
 {
     using (System.Xml.XmlReader xmlReader = new System.Xml.XmlNodeReader(token.TokenXml))
     {
         xmlReader.MoveToContent();
         if (xmlReader.IsStartElement("BinarySecurityToken", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"))
         {
             return(xmlReader.GetAttribute("ValueType", null));
         }
     }
     return(string.Empty);
 }
예제 #2
0
        private bool ParseCallbackSettingsXML()
        {
            Trace.TraceInformation("Enter.");

            try
            {
                if (xmlDoc == null)
                {
                    Trace.TraceWarning("xmlDoc is null.");
                    return(false);
                }

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

                List <CallbackContactServiceQueue> _TempQueues = new List <CallbackContactServiceQueue>();

                CallbackContactServiceQueue _cbCSQ = null;
                CallbackContactServiceQueueSettingsProfile _profile = null;

                CallbackBackupCSQ       _bckCSQ = null;
                CallbackAlgorithmFilter _filter = null;

                bool bAcceptCallbacksTimeframeElementEnded = true;
                bool bCallbackProcessingTimeframeEnded     = true;

                bool bCallbackReentryAlgorithmElementBegan = false;
                bool bCallbackOfferedAlgorithmElementBegan = false;

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

                        if (reader.Name.Equals("csq"))
                        {
                            _cbCSQ = new CallbackContactServiceQueue();

                            _cbCSQ.Name = reader.GetAttribute("name");

                            bCallbackReentryAlgorithmElementBegan = false;
                            bCallbackOfferedAlgorithmElementBegan = false;
                        }

                        if (reader.Name.Equals("CallbackEnabled"))
                        {
                            try
                            {
                                _cbCSQ.CallbackEnabled = bool.Parse(reader.ReadString());
                            }
                            catch
                            {
                                _cbCSQ.CallbackEnabled = false;
                            }
                        }

                        if (reader.Name.Equals("CallerRecording"))
                        {
                            if (_profile == null)
                            {
                                _profile = new CallbackContactServiceQueueSettingsProfile();
                            }

                            try
                            {
                                _profile.CallerRecording = bool.Parse(reader.ReadString());
                            }
                            catch
                            {
                                _profile.CallerRecording = false;
                            }
                        }

                        if (reader.Name.Equals("RetentionPeriod"))
                        {
                            if (_profile == null)
                            {
                                _profile = new CallbackContactServiceQueueSettingsProfile();
                            }

                            try
                            {
                                _profile.RetentionPeriod = int.Parse(reader.ReadString());
                            }
                            catch
                            {
                                _profile.RetentionPeriod = 7;
                            }
                        }

                        if (reader.Name.Equals("AppServerURLPrefix"))
                        {
                            if (_profile == null)
                            {
                                _profile = new CallbackContactServiceQueueSettingsProfile();
                            }

                            _profile.AppServerURLPrefix = reader.ReadString();
                        }

                        if (reader.Name.Equals("EmailAlerts"))
                        {
                            if (_profile == null)
                            {
                                _profile = new CallbackContactServiceQueueSettingsProfile();
                            }

                            try
                            {
                                _profile.EmailAlerts = bool.Parse(reader.ReadString());
                            }
                            catch
                            {
                                _profile.EmailAlerts = false;
                            }
                        }

                        if (reader.Name.Equals("AdminEmail"))
                        {
                            if (_profile == null)
                            {
                                _profile = new CallbackContactServiceQueueSettingsProfile();
                            }

                            _profile.AdminEmail = reader.ReadString();
                        }

                        if (reader.Name.Equals("CallerIDVerify"))
                        {
                            if (_profile == null)
                            {
                                _profile = new CallbackContactServiceQueueSettingsProfile();
                            }

                            try
                            {
                                _profile.CallerIDVerify = bool.Parse(reader.ReadString());
                            }
                            catch
                            {
                                _profile.CallerIDVerify = false;
                            }
                        }

                        if (reader.Name.Equals("AbandonCallback"))
                        {
                            if (_profile == null)
                            {
                                _profile = new CallbackContactServiceQueueSettingsProfile();
                            }

                            try
                            {
                                _profile.AbandonCallback = bool.Parse(reader.ReadString());
                            }
                            catch
                            {
                                _profile.AbandonCallback = false;
                            }
                        }

                        if (reader.Name.Equals("AbandonCBMinQTime"))
                        {
                            if (_profile == null)
                            {
                                _profile = new CallbackContactServiceQueueSettingsProfile();
                            }

                            try
                            {
                                _profile.AbandonCBMinQTime = int.Parse(reader.ReadString());
                            }
                            catch
                            {
                                _profile.AbandonCBMinQTime = 0;
                            }
                        }

                        if (reader.Name.Equals("AbandonCBMinInterCallTime"))
                        {
                            if (_profile == null)
                            {
                                _profile = new CallbackContactServiceQueueSettingsProfile();
                            }

                            try
                            {
                                _profile.AbandonCBMinInterCallTime = int.Parse(reader.ReadString());
                            }
                            catch
                            {
                                _profile.AbandonCBMinInterCallTime = 0;
                            }
                        }

                        if (reader.Name.Equals("CBQueue"))
                        {
                            if (_profile == null)
                            {
                                _profile = new CallbackContactServiceQueueSettingsProfile();
                            }

                            _bckCSQ = new CallbackBackupCSQ();

                            _bckCSQ.Name = reader.GetAttribute("csq");

                            try
                            {
                                _bckCSQ.OverflowTime = int.Parse(reader.GetAttribute("overflowtime"));
                            }
                            catch
                            {
                                _bckCSQ.OverflowTime = 0;
                            }

                            _profile.BackupCSQs.Add(_bckCSQ);

                            _bckCSQ = null;
                        }

                        if (reader.Name.Equals("AcceptCallbacksTimeframe"))
                        {
                            if (_profile == null)
                            {
                                _profile = new CallbackContactServiceQueueSettingsProfile();
                            }

                            bAcceptCallbacksTimeframeElementEnded = false;
                        }

                        if (reader.Name.Equals("Begin"))
                        {
                            if (!bAcceptCallbacksTimeframeElementEnded)
                            {
                                _profile.AcceptCallbacksTimeframeBegin = reader.ReadString();
                            }

                            if (!bCallbackProcessingTimeframeEnded)
                            {
                                _profile.CallbackProcessingTimeframeBegin = reader.ReadString();
                            }
                        }

                        if (reader.Name.Equals("End"))
                        {
                            if (!bAcceptCallbacksTimeframeElementEnded)
                            {
                                _profile.AcceptCallbacksTimeframeEnd = reader.ReadString();
                            }

                            if (!bCallbackProcessingTimeframeEnded)
                            {
                                _profile.CallbackProcessingTimeframeEnd = reader.ReadString();
                            }
                        }

                        if (reader.Name.Equals("CallbackOfferedAlgorithm"))
                        {
                            bCallbackOfferedAlgorithmElementBegan = true;
                        }

                        if (reader.Name.Equals("CallbackReentryAlgorithm"))
                        {
                            bCallbackReentryAlgorithmElementBegan = true;
                        }

                        if (reader.Name.Equals("TotalInQueue") ||
                            reader.Name.Equals("CSQAgentsReady") ||
                            reader.Name.Equals("CSQCallsWaiting") ||
                            reader.Name.Equals("AgentsLoggedIn") ||
                            reader.Name.Equals("CallsWaiting") ||
                            reader.Name.Equals("LongestQueueTime") ||
                            reader.Name.Equals("CallbackRequests"))
                        {
                            if (_profile == null)
                            {
                                _profile = new CallbackContactServiceQueueSettingsProfile();
                            }

                            _filter = new CallbackAlgorithmFilter();

                            _filter.Name = reader.Name;

                            try
                            {
                                _filter.Enabled = bool.Parse(reader.GetAttribute("Enabled"));
                            }
                            catch
                            {
                                _filter.Enabled = false;
                            }

                            _filter.Operation = reader.GetAttribute("Operation");

                            try
                            {
                                _filter.Value = int.Parse(reader.GetAttribute("Value"));
                            }
                            catch
                            {
                                _filter.Value = 0;
                            }

                            if (bCallbackOfferedAlgorithmElementBegan)
                            {
                                _profile.OfferedAlgorithmFilters.Add(_filter);
                            }

                            if (bCallbackReentryAlgorithmElementBegan)
                            {
                                _profile.ReentryAlgorithmFilters.Add(_filter);
                            }

                            _filter = null;
                        }

                        if (reader.Name.Equals("CallbackProcessingTimeframe"))
                        {
                            if (_profile == null)
                            {
                                _profile = new CallbackContactServiceQueueSettingsProfile();
                            }

                            bCallbackProcessingTimeframeEnded = false;
                        }

                        if (reader.Name.Equals("EndOfDayPurgeCallbackRequests"))
                        {
                            if (_profile == null)
                            {
                                _profile = new CallbackContactServiceQueueSettingsProfile();
                            }

                            try
                            {
                                _profile.EndOfDayPurgeCallbackRequests = bool.Parse(reader.ReadString());
                            }
                            catch
                            {
                                _profile.EndOfDayPurgeCallbackRequests = false;
                            }
                        }

                        break;

                    case System.Xml.XmlNodeType.EndElement:

                        if (reader.Name.Equals("csq"))
                        {
                            if (_cbCSQ != null)
                            {
                                _cbCSQ.Profile = _profile;
                                _TempQueues.Add(_cbCSQ);
                            }
                            else
                            {
                                Trace.TraceWarning("CSQ was not added to list because _cbCSQ is null.");
                            }

                            _profile = null;
                            _cbCSQ   = null;
                        }

                        if (reader.Name.Equals("CallbackReentryAlgorithm"))
                        {
                            bCallbackReentryAlgorithmElementBegan = false;
                        }

                        if (reader.Name.Equals("AcceptCallbacksTimeframe"))
                        {
                            bAcceptCallbacksTimeframeElementEnded = true;
                        }

                        if (reader.Name.Equals("CallbackOfferedAlgorithm"))
                        {
                            bCallbackOfferedAlgorithmElementBegan = false;
                        }

                        if (reader.Name.Equals("CallbackProcessingTimeframe"))
                        {
                            bCallbackProcessingTimeframeEnded = true;
                        }

                        break;
                    } //switch (reader.NodeType)
                }     //while (reader.Read())

                reader.Close();
                reader = null;

                xmlDoc = null;

                _Queues = _TempQueues;

                _TempQueues = null;
                _profile    = null;
                _cbCSQ      = null;

                return(true);
            }
            catch (Exception ex)
            {
                Trace.TraceError("Exception:" + ex.Message + Environment.NewLine + "StackTrace:" + ex.StackTrace);
                xmlDoc = null;
                return(false);
            }
        }
        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);
            }
        }
예제 #4
0
        private bool ParseResponse()
        {
            try
            {
                System.Xml.XmlDocument xmlDoc = null;

                xmlDoc = new System.Xml.XmlDocument();

                xmlDoc.LoadXml(sResponse);

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

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

                        if (reader.Name.Equals("CSQ"))
                        {
                            _Information      = new ContactServiceQueueInformation();
                            _Information.Name = reader.GetAttribute("name");
                        }

                        if (reader.Name.Equals("LoggedIn"))
                        {
                            try
                            {
                                _Information.AgentsLoggedIn = int.Parse(reader.ReadString());
                            }
                            catch (Exception ex)
                            {
                                _Information.AgentsLoggedIn = -99;
                            }
                        }

                        if (reader.Name.Equals("Talking"))
                        {
                            try
                            {
                                _Information.AgentsTalking = int.Parse(reader.ReadString());
                            }
                            catch (Exception ex)
                            {
                                _Information.AgentsTalking = -99;
                            }
                        }

                        if (reader.Name.Equals("Ready"))
                        {
                            try
                            {
                                _Information.AgentsReady = int.Parse(reader.ReadString());
                            }
                            catch (Exception ex)
                            {
                                _Information.AgentsReady = -99;
                            }
                        }

                        if (reader.Name.Equals("NotReady"))
                        {
                            try
                            {
                                _Information.AgentsNotReady = int.Parse(reader.ReadString());
                            }
                            catch (Exception ex)
                            {
                                _Information.AgentsNotReady = -99;
                            }
                        }

                        if (reader.Name.Equals("Work"))
                        {
                            try
                            {
                                _Information.AgentsWork = int.Parse(reader.ReadString());
                            }
                            catch (Exception ex)
                            {
                                _Information.AgentsWork = -99;
                            }
                        }

                        if (reader.Name.Equals("CallsWaiting"))
                        {
                            try
                            {
                                _Information.ContactsWaiting = int.Parse(reader.ReadString());
                            }
                            catch (Exception ex)
                            {
                                _Information.ContactsWaiting = -99;
                            }
                        }

                        if (reader.Name.Equals("LongestQueueTime"))
                        {
                            try
                            {
                                _Information.LongestWaitingContact = int.Parse(reader.ReadString());
                            }
                            catch (Exception ex)
                            {
                                _Information.LongestWaitingContact = -99;
                            }
                        }

                        //if (reader.Name.Equals("TotalInQueue"))
                        //{
                        //    try
                        //    {
                        //        _Information.TotalInQueue = int.Parse(reader.ReadString());
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        _Information.TotalInQueue = -99;
                        //    }
                        //}

                        break;

                    case System.Xml.XmlNodeType.EndElement:

                        if (reader.Name.Equals("CSQ"))
                        {
                        }

                        break;
                    }
                }

                reader = null;
                xmlDoc = null;

                return(true);
            }
            catch (Exception ex)
            {
                Trace.TraceWarning("Exception: " + ex.Message + Environment.NewLine + "Stacktrace: " + ex.StackTrace);
                return(false);
            }
        }