In this sample we will show you the correct way to get information out of the Euphoria API using the C# API DLL.


The API DLL can be downloaded from the Euphoria TMS, Once you have logged in, tab over to Downloads and look for the API DLL.zip


Building a Visual Studio Project


1) In visual Studio, create a blank Console Application project.

2) Under the Project Reference add the downloaded DLL called "Euphoria.APIDLL.dll"

    1. This DLL has two dependency's:  "Euphoria.RegistryAccess.dll" and "Euphoria.Security.dll"
    2. The dependency's are included in the ZIP file
    3. The dependency's must be copied to your /bin/ directory otherwise the project cannot run.
3) Now open the "Program.cs", and add the following references:

  

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.XPath;

using Euphoria.APIDLL;

  

4) In in the static Main part add this code:

    

        static void Main(string[] args)
        {
            // Create an instance of the EuphoriaAPIDLL
            EuphoriaAPIDLL API = new EuphoriaAPIDLL();

            // Set up the Authorisation codes
            // See: http://support.euphoria.co.za/solution/categories/109665/folders/180195/articles/109406-obtaining-an-api
            string apiTenant = "*******";
            string apiAuthCode = "***************************";

            // Authorise the API
            API.TenantName = apiTenant;
            API.AuthCode = apiAuthCode;

            // Get the Queues
            XmlDocument queuesXml = API.GetQueues();

            // Cast results to Queues type
            Queues myQueues = API.FormatQueuesFromXML(queuesXml);

            // Output results
            Console.WriteLine("The following queues where found:");
            foreach (Queue queue in myQueues)
            {
                // Output only the name of the queue, without the tenant
                Console.WriteLine(queue.QueueName.Split('-')[0]);
            }

            // Get the queue name
            Console.WriteLine("");
            Console.WriteLine("Type the name of the queue to see more information:");
            string queueName = Console.ReadLine();

            if (String.IsNullOrEmpty(queueName)) return;

            // Get the full queue inforamtion
            XmlDocument queueCallsXml = API.GetQueuedCalls(queueName);

            // Format XML as QueueParameters
            QueueParameters queueParameters = API.FormatQueuePropertiesFromXML(queueCallsXml);
            Console.WriteLine("Queue Parameters for :" + queueParameters.Queue);
            Console.WriteLine("Calls Waiting: " + queueParameters.Calls);
            Console.WriteLine("Abandonded Calls: " + queueParameters.Abandoned);
            Console.WriteLine("Completed Calls: " + queueParameters.Completed);
            Console.WriteLine("Average Hold Time: " + queueParameters.Holdtime);

            // Format XML as QueuedCalls
            Console.WriteLine("");
            Console.WriteLine("The following callers are waiting:");
            QueuedCalls queuedCalls = API.FormatQueuedCallsFromXML(queueCallsXml);
            foreach (QueuedCall call in queuedCalls)
            {
                Console.WriteLine("Caller " + call.Position + ": " + call.CallerID + " [" + call.Channel + "] waiting for " + call.Wait);
            }

            // Format XML as QueueMembers
            Console.WriteLine("");
            Console.WriteLine("The queue has the following agents:");
            QueueMembers queueMembers = API.FormatQueueMembersFromXML(queueCallsXml);
            foreach (QueueMember member in queueMembers)
            {
                Console.WriteLine(member.CallerID + " has taken " + member.CallsTaken + " calls with a status of " + member.Status);
            }

            Console.WriteLine("");
            Console.WriteLine("Press enter to exit");
            Console.ReadLine();
        }

     

5) Build and run your code.


You can adapt this code to suit your needs. Also see the additional functions in the EuphoriaAPIDLL.


The complete cs file is attached.