コード例 #1
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);
            }
        }
        private bool ParseResponseIntoArraylist()
        {
            try
            {
                int iCode = 0;

                System.Xml.XmlDocument xmlDoc = null;

                xmlDoc = new System.Xml.XmlDocument();

                xmlDoc.LoadXml(sResponse);

                System.Xml.XmlNode nodCode = xmlDoc.SelectSingleNode("//response/code");

                if (nodCode != null)
                {
                    try
                    {
                        iCode = int.Parse(nodCode.InnerText);
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceWarning("Exception casting Code to integer; Code defaulted to -1.");
                        iCode = -1;
                    }
                }
                else
                {
                    Trace.TraceWarning("//response/code element not found. Code defaulted to -1");
                    iCode = -1;
                }

                if (iCode == -1)
                {
                    Trace.TraceWarning("//response/code element = -1");
                    nodCode = null;
                    xmlDoc  = null;
                    return(false);
                }

                nodCode = null;

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

                QueuedContacts.Clear();

                ContactQueuedInformation _con = null;

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

                        if (reader.Name.Equals("contact"))
                        {
                            _con = new ContactQueuedInformation();
                        }

                        if (reader.Name.Equals("contactid"))
                        {
                            _con.ID = reader.ReadString();
                        }

                        if (reader.Name.Equals("type"))
                        {
                            _con.Type = reader.ReadString();
                        }

                        if (reader.Name.Equals("implid"))
                        {
                            _con.ImplID = reader.ReadString();
                        }

                        if (reader.Name.Equals("starttime"))
                        {
                            _con.StartTime = reader.ReadString();
                        }

                        if (reader.Name.Equals("duration"))
                        {
                            _con.Duration = reader.ReadString();
                        }

                        if (reader.Name.Equals("application"))
                        {
                            _con.Application = reader.ReadString();
                        }

                        if (reader.Name.Equals("task"))
                        {
                            _con.Task = reader.ReadString();
                        }

                        if (reader.Name.Equals("session"))
                        {
                            _con.Session = reader.ReadString();
                        }

                        if (reader.Name.Equals("queuedfor"))
                        {
                            _con.QueuedFor = reader.ReadString();
                        }

                        break;

                    case System.Xml.XmlNodeType.EndElement:

                        if (reader.Name.Equals("contact"))
                        {
                            QueuedContacts.Add(_con);
                            _con = null;
                        }

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

                reader = null;
                xmlDoc = null;

                return(true);
            }
            catch (Exception ex)
            {
                Trace.TraceWarning("Exception: " + ex.Message + Environment.NewLine + "Stacktrace: " + ex.StackTrace);
                return(false);
            }
        }
コード例 #3
0
        private bool ParseResponseIntoArraylist()
        {
            try
            {
                int iCode = 0;

                System.Xml.XmlDocument xmlDoc = null;

                xmlDoc = new System.Xml.XmlDocument();

                xmlDoc.LoadXml(sResponse);

                System.Xml.XmlNode nodCode = xmlDoc.SelectSingleNode("//response/code");

                if (nodCode != null)
                {
                    try
                    {
                        iCode = int.Parse(nodCode.InnerText);
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceWarning("Exception casting Code to integer; Code defaulted to -1.");
                        iCode = -1;
                    }
                }
                else
                {
                    Trace.TraceWarning("//response/code element not found. Code defaulted to -1");
                    iCode = -1;
                }

                if (iCode == -1)
                {
                    Trace.TraceWarning("//response/code element = -1");
                    nodCode = null;
                    xmlDoc  = null;
                    return(false);
                }

                nodCode = null;

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

                CSQInfo.Clear();

                ContactServiceQueueInformation _con = null;

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

                        if (reader.Name.Equals("csq"))
                        {
                            _con = new ContactServiceQueueInformation();
                        }

                        if (reader.Name.Equals("id"))
                        {
                            _con.ID = reader.ReadString();
                        }

                        if (reader.Name.Equals("name"))
                        {
                            _con.Name = reader.ReadString();
                        }

                        if (reader.Name.Equals("agentsloggedin"))
                        {
                            _con.AgentsLoggedIn = int.Parse(reader.ReadString());
                        }

                        if (reader.Name.Equals("agentsnotready"))
                        {
                            _con.AgentsNotReady = int.Parse(reader.ReadString());
                        }

                        if (reader.Name.Equals("agentsready"))
                        {
                            _con.AgentsReady = int.Parse(reader.ReadString());
                        }

                        if (reader.Name.Equals("agentstalking"))
                        {
                            _con.AgentsTalking = int.Parse(reader.ReadString());
                        }

                        if (reader.Name.Equals("agentswork"))
                        {
                            _con.AgentsWork = int.Parse(reader.ReadString());
                        }

                        if (reader.Name.Equals("contactswaiting"))
                        {
                            _con.ContactsWaiting = int.Parse(reader.ReadString());
                        }

                        if (reader.Name.Equals("longestwaitingcontact"))
                        {
                            _con.LongestWaitingContact = int.Parse(reader.ReadString());
                        }

                        break;

                    case System.Xml.XmlNodeType.EndElement:

                        if (reader.Name.Equals("csq"))
                        {
                            CSQInfo.Add(_con);
                            _con = null;
                        }

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

                reader = null;
                xmlDoc = null;

                return(true);
            }
            catch (Exception ex)
            {
                Trace.TraceWarning("Exception: " + ex.Message + Environment.NewLine + "Stacktrace: " + ex.StackTrace);
                return(false);
            }
        }
コード例 #4
0
        public String GetVoiceCSQList()
        {
            try
            {
                if (_UCCXMasterNode == null)
                {
                    Trace.TraceWarning("_UCCXMasterNode is null.");
                    return(null);
                }

                if (_UCCXMasterNode == String.Empty)
                {
                    Trace.TraceWarning("_UCCXMasterNode is empty.");
                    return(null);
                }

                if (_UCCXUsername == null)
                {
                    Trace.TraceWarning("_UCCXUsername is null.");
                    return(null);
                }

                if (_UCCXUsername == String.Empty)
                {
                    Trace.TraceWarning("_UCCXUsername is empty.");
                    return(null);
                }

                if (_UCCXPassword == null)
                {
                    Trace.TraceWarning("_UCCXPassword is null.");
                    return(null);
                }

                if (_UCCXPassword == String.Empty)
                {
                    Trace.TraceWarning("_UCCXPassword is empty.");
                    return(null);
                }

                if (!SendRequest("http://" + _UCCXMasterNode + "/adminapi/csq"))
                {
                    Trace.TraceWarning("SendRequest() returned false.");
                    return(null);
                }

                StringBuilder sbCSQList = new StringBuilder();

                sbCSQList.Append("<csqs>");

                System.Xml.XmlDocument xmlDoc = null;

                xmlDoc = new System.Xml.XmlDocument();

                xmlDoc.LoadXml(sResponse);

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

                String _CSQID   = String.Empty;
                String _CSQName = String.Empty;

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

                        if (reader.Name.Equals("id"))
                        {
                            _CSQID = reader.ReadString();
                        }

                        if (reader.Name.Equals("name"))
                        {
                            _CSQName = reader.ReadString();
                        }

                        if (reader.Name.Equals("queueType"))
                        {
                            if (reader.ReadString() == "VOICE")
                            {
                                sbCSQList.Append("<csq>");
                                sbCSQList.Append("<id>" + _CSQID + "</id>");
                                sbCSQList.Append("<name>" + _CSQName + "</name>");
                                sbCSQList.Append("</csq>");

                                _CSQID   = String.Empty;
                                _CSQName = String.Empty;
                            }
                        }

                        break;

                    case System.Xml.XmlNodeType.EndElement:

                        break;
                    }
                }

                reader = null;
                xmlDoc = null;

                sbCSQList.Append("</csqs>");

                return(sbCSQList.ToString());
            }
            catch (Exception ex)
            {
                Trace.TraceWarning("Exception: " + ex.Message + Environment.NewLine + "StackTrace: " + ex.StackTrace);

                return(null);
            }
        }
コード例 #5
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);
            }
        }