Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I'm trying to get the active users<->documents using the QMS API. I've found a method that works - GetQVSDocumentsAndUsers. Our environment is clustered and include 3 QV servers. The problem is that GetQVSDocumentsAndUsers returns the active docs/users only for the main server (where QMS is installed) and i'm not sure how to ask for the all docs/users in the cluster.
Is there a way to get all the users/docs in the cluster?
The code that im using at the moment is:
QMSClient Client;
Client = new QMSClient("BasicHttpBinding_IQMS");
string key = Client.GetTimeLimitedServiceKey();
ServiceKeyClientMessageInspector.ServiceKey = key;
System.Guid a = new Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"); //QVS@qvcluster guid
var t = Client.GetQVSDocumentsAndUsers(a, QueryTarget.Resource);
string userdocs = "";
foreach (KeyValuePair<string, string[]> entry in t)
{
var doc = entry.Key;
for (int b = 0; b < entry.Value.Length; b++)
{
userdocs = userdocs + doc + "," + entry.Value + Environment.NewLine;
}
}
File.WriteAllText(@"c:\development\users.csv", userdocs);
Console.WriteLine("done");
Console.ReadLine();
Stefan
Ok I've figure it out by myself. The thing that was missing for me was how to get the underlying servers in the cluster and make a call to get their users<->documents. The method that return the list of the servers in the cluster is: GetServiceStatuses. After this the code that will return the data look like this:
string resultfile = @"s:\development\stefan\users.csv";
if (!File.Exists(resultfile))
{
File.WriteAllText(resultfile, "timestamp,server,document,user" + Environment.NewLine);
}
QMSClient Client;
Client = new QMSClient("BasicHttpBinding_IQMS");
string key = Client.GetTimeLimitedServiceKey();
ServiceKeyClientMessageInspector.ServiceKey = key;
ServiceInfo[] myServices = Client.GetServices(ServiceTypes.All);
var guids = new Guid[1];
foreach (ServiceInfo service in myServices)
{
Console.WriteLine(service.Type + " " + service.Name + " " + service.ID);
if (service.Type.ToString() == "QlikViewServer")
{
guids[0] = service.ID;
}
}
var executiondate = DateTime.Now.ToString("yyyyMMddHHmmss");
var stats = Client.GetServiceStatuses(guids);
var members = stats[0].MemberStatusDetails;
string userdocs = "";
userdocs = "";
for (int m = 0; m < members.Length; m++)
{
var a = members
.ID; var t = Client.GetQVSDocumentsAndUsers(a, QueryTarget.ClusterMember);
foreach (KeyValuePair<string, string[]> entry in t)
{
var doc = entry.Key;
for (int b = 0; b < entry.Value.Length; b++)
{
userdocs = userdocs + executiondate.ToString() + "," + members
.Host + "," + doc + "," + entry.Value + Environment.NewLine; }
}
}
File.AppendAllText(resultfile, userdocs);
Console.WriteLine("done");
Console.ReadLine();
Stefan
Ok I've figure it out by myself. The thing that was missing for me was how to get the underlying servers in the cluster and make a call to get their users<->documents. The method that return the list of the servers in the cluster is: GetServiceStatuses. After this the code that will return the data look like this:
string resultfile = @"s:\development\stefan\users.csv";
if (!File.Exists(resultfile))
{
File.WriteAllText(resultfile, "timestamp,server,document,user" + Environment.NewLine);
}
QMSClient Client;
Client = new QMSClient("BasicHttpBinding_IQMS");
string key = Client.GetTimeLimitedServiceKey();
ServiceKeyClientMessageInspector.ServiceKey = key;
ServiceInfo[] myServices = Client.GetServices(ServiceTypes.All);
var guids = new Guid[1];
foreach (ServiceInfo service in myServices)
{
Console.WriteLine(service.Type + " " + service.Name + " " + service.ID);
if (service.Type.ToString() == "QlikViewServer")
{
guids[0] = service.ID;
}
}
var executiondate = DateTime.Now.ToString("yyyyMMddHHmmss");
var stats = Client.GetServiceStatuses(guids);
var members = stats[0].MemberStatusDetails;
string userdocs = "";
userdocs = "";
for (int m = 0; m < members.Length; m++)
{
var a = members
.ID; var t = Client.GetQVSDocumentsAndUsers(a, QueryTarget.ClusterMember);
foreach (KeyValuePair<string, string[]> entry in t)
{
var doc = entry.Key;
for (int b = 0; b < entry.Value.Length; b++)
{
userdocs = userdocs + executiondate.ToString() + "," + members
.Host + "," + doc + "," + entry.Value + Environment.NewLine; }
}
}
File.AppendAllText(resultfile, userdocs);
Console.WriteLine("done");
Console.ReadLine();
Stefan