Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
We're building an application using the Qlikview OCX control. Opening documents on the server works just fine.
axQlikOCX1.OpenDocument(@"qvp://company-qvs/Presentation/doc1.qvw", login, passwd);
But we need to know the path to every document. We want to provide a list of available documents outside the OCX. So here's my questions: How do a get a list/array/etc. of documents from our server? Is there a way to fetch this via QVP?
something like
List<QlikView.Document> list = qvs.fetchDocumentList(@"qvp://company-qvs/Presentation/", login, passwd);
List<QlikView.Document> list = qvs.fetchDocumentList(@"qvp://company-qvs/", login, passwd);
whould be helpful.
Add a reference to QvsNetRemote.dll in your C# project, add a listbox called lbDocs and try the following code, bye.
corrado
using QlikTech.NetClient;
QvClient client = new QvClient(txServer.Text.ToString(), QvClient.Mode.Admin);
XmlDocument answer = new XmlDocument();
//Retrieve document list
answer.LoadXml(client.Execute("<Global method='GetDocListEx'><Type>16</Type></Global>"));
XmlElement root = answer.DocumentElement;
XmlNodeList elemList = root.GetElementsByTagName("DisplayName");
XmlNodeList elemListPath = root.GetElementsByTagName("Path");
for (int i = 1; i < elemList.Count; i++)
{
if (elemList.InnerXml.ToString().Trim() != "" && elemListPath.InnerXml.ToString().Trim() != "")
{
lbDocs.Items.Add(elemListPath.InnerXml);
}
}
XmlNode msg = answer.DocumentElement.SelectSingleNode("message/@text");
if (msg != null && msg.InnerText != string.Empty)
{
MessageBox.Show(this, msg.InnerText, "Error");
}
I forgot to mention, that fetching the document names/paths would be enough.
As far as I know there's no way to do this with OCX. However, 8.5 came with a useful file called QvDocList.js that is still included in 9.0 as a legacy file (see C:\Program Files\QlikView\Server\Legacy Files\Webpages\scripts). As demonstrated in this file, you can access the document list and path information through Javascript. I recommend that you do this recursively. The code might look something like this:
var doc;
if (window.ActiveXObject) {
doc = new ActiveXObject ("Microsoft.XMLDOM");
} else {
doc = window.document.implementation.createDocument ("", "", null);
}
for (var i = 0; i < doc.documentElement.childNodes.length; i++) {
//Remove spaces in [ i ] parameter
var path = doc.documentElement.childNodes[ i ].getAttribute ("Path");
var name = doc.documentElement.childNodes[ i ].getAttribute ("Name");
}
For more details, see the syntax within the file.
Best regards,
Sounds fine, but how does this work together with the QlikView user management? What we are suppost do on our client side(C# .net app using the OCX)? We want to get only the List of documents for a specific user. If we access the server and a invoke the skript, does that works with an authentication?
Oh ok, you didn't specify that you needed to check it against security permissions. I'm assuming that you're using NTFS authorization. If that's the case, pass the results of the Javascript function above to a function that checks NTFS permissions on the returned files. Then create a simple function that reduces the results and just shows the list of files for a specified user. Here is a good example of a function that checks NTFS permissions on a file: http://www.devx.com/cplus/Article/16711/1954. I found it very adaptable and should serve this purpose gracefully.
Add a reference to QvsNetRemote.dll in your C# project, add a listbox called lbDocs and try the following code, bye.
corrado
using QlikTech.NetClient;
QvClient client = new QvClient(txServer.Text.ToString(), QvClient.Mode.Admin);
XmlDocument answer = new XmlDocument();
//Retrieve document list
answer.LoadXml(client.Execute("<Global method='GetDocListEx'><Type>16</Type></Global>"));
XmlElement root = answer.DocumentElement;
XmlNodeList elemList = root.GetElementsByTagName("DisplayName");
XmlNodeList elemListPath = root.GetElementsByTagName("Path");
for (int i = 1; i < elemList.Count; i++)
{
if (elemList.InnerXml.ToString().Trim() != "" && elemListPath.InnerXml.ToString().Trim() != "")
{
lbDocs.Items.Add(elemListPath.InnerXml);
}
}
XmlNode msg = answer.DocumentElement.SelectSingleNode("message/@text");
if (msg != null && msg.InnerText != string.Empty)
{
MessageBox.Show(this, msg.InnerText, "Error");
}
Thanks for your help, but the answer is always empty. If i set a UserName and Password i get a SocketException. Here are the changes i made to your code:
QvClient client = new QvClient(@"ws-dbserver");
client.UserName = login;
client.Password = passwd;
client.Connect(QvClient.Mode.Admin); // Exception1
XmlDocument answer = new XmlDocument();
answer.LoadXml(client.Execute("<Global method='GetDocListEx'><Type>16</Type></Global>")); // Exception2
If i catch Exception1, client.Execute(...) throws the same exception. The exception message says someting like: "A blockingoperation was interrupted by calling WSACancelBlockingCall". I hope i solve this problem on my own, but if you know the problem i would be thankful for a hint.
Ok, we found the problem.
client.Connect(QvClient.Mode.Authenticate);
Thanks for your help.
Hi,
I copied your code and try to use it on a Web Service but the result I received does not contain the document names.
But when I use this code on Console application I was able to retrieve all the document names.
Kindly help give some idea on this.
Thanks a lot.
Arnold
Have you tried getting the application from the OCX, e.g. myOCX.Application and them making a call something like
QlikView.IArrayOfDocListEntry docs = myOCX.Application.GetServerDocList("qvp://<serviceName");