, that looks like exactly the kind of hint I need! I shall give it a whirl ASAP.
Original Message:
Sent: 06-12-2020 03:50
From: Douglas Suyemoto
Subject: How to use ICWS C# Library to retrieve configuration data?
Here is a simpler example in C# to retrieve user properties.
public void Execute()
{
WebServiceUtility webServiceUtility = new WebServiceUtility()
{
Port = 8018,
IsHttps = false,
Server = "name_of_server"
};
Console.WriteLine(webServiceUtility.Port);
var result = new ConnectionResource(webServiceUtility).CreateConnection(
new CreateConnectionRequestParameters()
{
Accept_Language = "en-us",
Include = "features"
},
new IcAuthConnectionRequestSettingsDataContract()
{
UserID = "cic_user_id",
Password = "cic_user_password",
ApplicationName = "PureConnectService",
}).Result;
Console.WriteLine(result.ININ_ICWS_Session_ID);
result.PerformIfResponseIs201(response => {
webServiceUtility.SessionParameters =
new AuthenticationParameters
{
SessionId = response.SessionId,
Cookie = result.Set_Cookie,
ININ_ICWS_CSRF_Token = response.CsrfToken
};
});
Console.WriteLine(result.StatusCode);
UsersResource usersResource = new UsersResource(webServiceUtility);
UsersResource.GetUserResponses userResult = usersResource.GetUser(new UsersResource.GetUserRequestParameters()
{
Id = "cic_user_id"
}).Result;
Console.WriteLine(userResult.StatusCode);
userResult.PerformIfResponseIs200(u => {
if (u.SkillsHasValue)
Console.WriteLine(u.Skills);
});
}
To sum up, you need to create the WebServiceUtility which will be used to pass to the resource you wish to retrieve, then use a callback to retrieve the response from the web service. Keep in mind, this example leaves out the ability to try a second server if you are running a server as backup, so you should always use the active server in the server name.
------------------------------
Douglas Suyemoto
Latham & Watkins LLP
Original Message:
Sent: 06-09-2020 16:07
From: Tyler Style
Subject: How to use ICWS C# Library to retrieve configuration data?
Thanks Douglas - and sorry for the very late reply, life kept on happening to me...
I really appreciate the examples, but since they're abstracted away from the actual ICWS code and the resultant wrappers are missing - coupled with my inexperience with C# and my unfamiliarity with the referenced assemblies - makes them almost unintelligible to me. I'm just missing too many key assumptions and understandings. I'm sure with an actual bare bones example of a simple fetch for something like a Schedule or User I could make headway from that but as it is it's all just a huge wall of thousands of classes with nothing really showing how they work together to produce results.
------------------------------
Tyler Style
Interactive Intelligence Engineer, WellCare Health Plans
Original Message:
Sent: 05-01-2020 15:04
From: Douglas Suyemoto
Subject: How to use ICWS C# Library to retrieve configuration data?
Hi Tyler,
Here is some code I use to make the initial connection, referencing "ININ.ICWS.Managed.dll" and "ININ.Webservices.Core.dll":
using ININ.ICWS;
using ININ.ICWS.Common;
using ININ.ICWS.Connection;
using ININ.WebServices.Core;
using System;
using System.Collections.Generic;
using static ININ.ICWS.Connection.ConnectionResource;
namespace PureConnect
{
public class ININService : IININService
{
private WebServiceUtility _webServiceUtility;
private CreateConnectionRequestParameters _createConnectionRequestParameters;
private IcAuthConnectionRequestSettingsDataContract _icAuthConnectionRequestSettingsDataContract;
private List<string> _connectAlternateHosts = new List<string>();
private bool _tryingBackupServer = false;
public bool IsConnected { get; private set; } = false;
public ININService()
{
_createConnectionRequestParameters = new CreateConnectionRequestParameters()
{
Accept_Language = "en-us",
Include = "features"
};
_icAuthConnectionRequestSettingsDataContract = new IcAuthConnectionRequestSettingsDataContract()
{
ApplicationName = "PureConnectService",
};
}
public WebServiceUtility Connect(ININServerCredentials ininServerCredentials)
{
return Connect(ininServerCredentials.Server, ininServerCredentials.Username, ininServerCredentials.Password);
}
public WebServiceUtility Connect(string server, string username, string password, int maxTries=3)
{
_icAuthConnectionRequestSettingsDataContract.UserID = username;
_icAuthConnectionRequestSettingsDataContract.Password = password;
ConnectServer(server);
return _webServiceUtility;
}
private void ConnectServer(string server)
{
IsConnected = false;
_webServiceUtility = new WebServiceUtility()
{
Port = 8018,
IsHttps = false,
Server = server
};
var result = new ConnectionResource(_webServiceUtility)
.CreateConnection(
_createConnectionRequestParameters,
_icAuthConnectionRequestSettingsDataContract).Result;
result.PerformIfResponseIs201(response => HandleConnection201(response, result.Set_Cookie));
result.PerformIfResponseIs400(response => HandleConnectionError(response));
result.PerformIfResponseIs410(response => HandleConnectionError(response));
result.PerformIfResponseIs503(response => HandleConnection503(response));
}
private void HandleConnection201(ConnectionResponseDataContract response, string cookie)
{
_webServiceUtility.SessionParameters =
new AuthenticationParameters
{
SessionId = response.SessionId,
Cookie = cookie,
ININ_ICWS_CSRF_Token = response.CsrfToken
};
IsConnected = true;
_connectAlternateHosts.Clear();
_tryingBackupServer = false;
}
private void HandleConnectionError(ErrorDataContract errorDataContract)
{
throw new Exception(errorDataContract.Message);
}
private void HandleConnection503(AlternateHostsDataContract response)
{
if (response.AlternateHostListHasValue && !_tryingBackupServer)
{
_connectAlternateHosts = response.AlternateHostList;
_tryingBackupServer = true;
}
if (!IsConnected && _connectAlternateHosts.Count > 0)
{
var alternateHost = _connectAlternateHosts[0];
_connectAlternateHosts.Remove(alternateHost);
ConnectServer(alternateHost);
}
}
}
}
This essentially uses callbacks to capture the responses and adds it back to the webservice so that you can use the connection to make further calls to resources. For example, to get information about an interaction, you would use the following code:
using ININ.ICWS.Interactions;
using System.Threading.Tasks;
using static ININ.ICWS.Interactions.InteractionsResource;
namespace PureConnect
{
public class ININInteractionsResource : IININInteractionsResource
{
IININService _ininService;
InteractionsResource _interactionsResource;
public ININInteractionsResource(IININService ininService)
{
_ininService = ininService;
}
public void Connect(string server, string username, string password)
{
_interactionsResource = new InteractionsResource(_ininService.Connect(server, username, password));
}
public async Task<ININGetInteractionAttributesResponse> GetInteractionAttributesAsync(
ININGetInteractionAttributesRequestParameters ininGetInteractionAttributesRequestParameters
)
{
return new ININGetInteractionAttributesResponse(
await _interactionsResource.GetInteractionAttributes(
new GetInteractionAttributesRequestParameters()
{
InteractionId = ininGetInteractionAttributesRequestParameters.InteractionId,
Select = ininGetInteractionAttributesRequestParameters.Select
}));
}
}
}
Here is sample code to initialize and get attribute info from an interaction:
var ininInteractionsResource = new ININInteractionsResource(new ININService());
ininInteractionsResource.Connect("serverName", "username", "password");
var interactionId = "12345678";
var attributeNames = new string[]{ "Eic_Note" };
var responses = ininInteractionsResource.GetInteractionAttributesAsync(
new ININGetInteractionAttributesRequestParameters()
{
InteractionId = interactionId,
Select = string.Join(",", attributeNames)
}
).Result;
Keep in mind I've created wrappers around the ININ classes, so they are referenced here with ININ in the class names so they won't resolve if you just copy and paste in VS, but hopefully this should clarify how to create the code. If you need all the wrapper classes, let me know and I think I can upload them. Also, you don't need to defer the connection until the method call like I am doing, you can simply initialize the web service using the credentials, make the connection, then inject them into the resource.
Essentially, you need to find out which resource you need, initialize that resource, inject the webservice and use it to retrieve the resources data. For example, if you need to retrieve user info, use the following class:
ININ.ICWS.Configuration.People.UsersResource
Which contains all the CRUD operations for the user class/resource. You can look at the object browser in VS for ININ.ICWS.Managed.dll or you can even look in the ICWS reference library on the Genesys website, since they're essentially the same to find out which resource you need to use.
------------------------------
Douglas Suyemoto
Latham & Watkins LLP
Original Message:
Sent: 05-01-2020 09:39
From: Tyler Style
Subject: How to use ICWS C# Library to retrieve configuration data?
For the record, I gave up on trying to puzzle this out and just wrote my own using RestSharp. Took about an hour. I'd still like to know if anyone can shed light on it, though!
------------------------------
Tyler Style
Interactive Intelligence Engineer, WellCare Health Plans
Original Message:
Sent: 04-30-2020 17:18
From: Tyler Style
Subject: How to use ICWS C# Library to retrieve configuration data?
I'm trying to get some config data (ie, workstations, users, skills, etc) using a C# app and the #ICWS C# DLLs. However, the provided example is not very helpful and there seems to be zero other documentation. Can anyone provide some guidance on simple retrieval of data using this library, rather than using it for managing calls? I'd really appreciate it!
#Handlers
#Integrations
#Unsure/Other
------------------------------
Tyler Style
Interactive Intelligence Engineer, WellCare Health Plans
------------------------------