[quote author=hsujdik link=topic=9642.msg43602#msg43602 date=1465338666]
I don't currently have Visual Studio installed, so I didn't test the code below, but I feel that would be way easier if you used ConfService. You would get rid of all the XmlDocument manipulation hell. For example:
[code]
/// Step 1 Opening a connection ////
// HSUJDIK: create the ConfService before opening the ConfServerProtocol:
EventBrokerService brokerService = BrokerServiceFactory.CreateEventBroker(protocol);
ConfService service = ConfServiceFactory.CreateConfService(confServerProtocol, brokerService);
confServerProtocol.Open(); // opening a connection
///Step 2 Authenticating a Username and password of a User whose details are available in CME ... ///
RequestAuthenticate RequestAuthenticateObj = RequestAuthenticate.Create(AgentName, Agentpassw);
// HSUJDIK: use the method .Request instead of .Send so you will get the message back
// without need to use the method .Receive()
(Message) authResponse = confServerProtocol.Request(RequestAuthenticateObj);
// HSUJDIK: check if EventAuthenticated or EventError was returned.
/// Step 3 Once authenticated I am trying to get the DBID of that User from Cfgperson ... the user who is authenticated above ///
/// and once done I am trying to further fetch his Login code from CfgAgentLogin ///
// HSUJDIK:
CfgPersonQuery query = new CfgPersonQuery(confservice);
query.UserName("user_name");
CfgPerson person = null;
try {
person = query.ExecuteSingleResult();
} catch (Exception e) {
// ERROR TRYING TO GET THE USER PROPERTIES. Proceed as you wish
}
List<CfgAgentLogin> agentLogins = person.AgentInfo.AgentLogins;
foreach (CfgAgentLogin agentLogin in agentLogins) {
// HSUJDIK: Do whatever you need with each CfgAgentLogin
}
/// Step 4 pass a filter query again with the DBID obtained from previous step.. to get his tenant id / logithis time I am getting below exception
// HSUJDIK:
int dbid = person.Tenant.DBID;
[/code]
[/quote]
********************************************************************************
Hi Hsujdik
I tried your method to remove those XML handling and tried with Confservice.
I am seeing one odd event .. the 2nd var Agentinfo = queryforLoginID.Execute(); for agentloginQuery is returning null
please advice
[code] // CfgAgentLoginQuery query = new CfgAgentLoginQuery(service);
var query = new CfgPersonQuery(service) { UserName = AgentName };
//testing Dbid = DBID UserName = AgentName
// retrieve all persons with given parameter UserName
var readedPersons = query.Execute();
if ((readedPersons != null) && (readedPersons.Count > 0))
{
foreach (CfgPerson readedPerson in readedPersons)
{
// notify to a view that person has been read
MessageBox.Show(readedPerson.DBID.ToString());
DBID = readedPerson.DBID;
}
}
var queryforLoginID = new CfgAgentLoginQuery(service) { Dbid = DBID };
//retrieve all persons with given parameter UserName
var Agentinfo = queryforLoginID.Execute(); //// I am seeing that this query is returning null value.. am I missing something
// List<CfgAgentLogin> Agentinfo = queryforLoginID.Execute();
if ((Agentinfo != null) && (Agentinfo.Count > 0))
{
foreach (CfgAgentLogin info in Agentinfo)
{
// notify to a view that person has been read
MessageBox.Show(info.LoginCode.ToString());
}
}
[/code]