3

I have an winform/OCX that consumes a qlikview document. We have gotten a patch from QV so that RefreshDocument works in the OCX as the RefreshDocument does in QV application. But the Application shows a nice enabled button when the document has been reload on the server.

Does anyone know what needs to be done to detect that. Either in C# or in macro code or ManagementAPI ?

This is the ReloadDocument Code.

    private void button2_Click(object sender, EventArgs e)
    {
        var myBloodybookmarkHack = "dynaBookmark" + Guid.NewGuid().ToString().Replace("-","");
        axQlikOCX1.ActiveDocument.CreateUserBookmark(myBloodybookmarkHack, true);
        //axQlikOCX1.OpenDocument(@"qvp://qvSeverName/path/MyDocument.qvw?bookmark=Server\dynaBookmarkb5aa82ae467540fdb0d18bb499044ed9");
        axQlikOCX1.RefreshDocument();
        axQlikOCX1.ActiveDocument.RecallUserBookmark(myBloodybookmarkHack);
        axQlikOCX1.ActiveDocument.RemoveUserBookmark(myBloodybookmarkHack);
   }

By suppressing the paint event I get this to run pretty ok. Next patch will include that it keeps the selections (Will be fixed in 11.2 servicerelease 6).

You need to detect if CreateUserBookmark was successfull or not and not restore the bookmark if the creation failed.

This code works in QV 11.2 serviceRelease 5.

Archlight
  • 2,019
  • 2
  • 21
  • 34
  • We have verified with the coders at QV, that they even do this bookmark type hack at one place. But there is now a bug ticket on this one and hopefully in sr6 scheduled for apil 2014 should remove the need for the bookmark hack – Archlight Feb 17 '14 at 08:31

3 Answers3

1

The filesystem reads a new modified time when the qvw file is rewritten after load. Assuming the data portion of this application is not broken out from the QVW file. Likely, you could come very close to accomplishing this by checking for new timestamps. Alternatively, if logging is enabled in the qvw document you could log read the text file* that QlikView generates to accomplish the same thing.

*The text file writes are delayed sometimes so your file might be refreshed a little bit before the log states that it is.

  • Reading the qv Log is something we tried and it works. But it got too complicated too quickly as the document users dont have access to the filesystem. – Archlight Feb 17 '14 at 08:09
1

We ended up using the QV Management api to get the last task reload time

Download the Qv management api demo from QV

This code shows you how to get tasks on a document. Through that you get when "last document reload task" was finished.

 private DateTime GetLastDocumentRun(string documentName)
    {
        string QMS = "http://MyQlikviewserver:4799/QMS/Service";
        var client = new QMSClient("BasicHttpBinding_IQMS", QMS);
        string key = client.GetTimeLimitedServiceKey();
        ServiceKeyClientMessageInspector.ServiceKey = key;

        var taskStatusFilter = new TaskStatusFilter();

        var clientTaskStatuses = client.GetTaskStatuses(taskStatusFilter, TaskStatusScope.All);
        foreach (var taskStatus in clientTaskStatuses)
        {
            Trace.WriteLine(taskStatus.General.TaskName);
            if (taskStatus.General.TaskName.ToLower().Contains(documentName.ToLower()))
            {
                string fin = taskStatus.Extended.FinishedTime + "";

                DateTime finishedTime;
                if (DateTime.TryParse(fin, out finishedTime))
                    return finishedTime;
               Logger.ErrMessage("QvManagementApi.GetLastDocumentRun",new Exception("Task finished time did not return a valid datetime value:" + fin));
               return DateTime.MinValue;
            }
        }
        return DateTime.MinValue;
    }

This is slow, so you should run on a different thread. Also this does not show if the task is successfully reloaded. We haven't fix that yet but on taskStatus.Extended you have the last log, which you can text parse to get if it was successfully reloaded or not.

Community
  • 1
  • 1
Archlight
  • 2,019
  • 2
  • 21
  • 34
  • This worked perfectly also got the last failed/successful reload from the extanded - log too. – Joshua Duxbury Apr 18 '16 at 16:31
  • With the QMS API, under general there is a TaskStatusValue Enum which you can use to see the status of the reload now too. So even though you could still read the last log and parse to find the status you don't need to, just use that TaskStatusValue flag. – Joshua Duxbury Apr 19 '16 at 09:07
0

If I understand correctly you want to know if a document has finished reloading on a QlikView server right?

I've you OCX application has a constant connection, you could evaluate the ReloadTime() function in the document which would tell you when the document was last reloaded. If you listen for the function and issuing a DocumentRefresh while doing this, then you would get a changed timestamp once the newly reloaded document becomes avaible on the server.

The code your posting, does not reload a QlikView document. At least not in QlikView lingo, it just open the documents on the server.

Please elaborate if I misunderstand you.

Regards Torber

seebach
  • 621
  • 3
  • 10
  • There was a slight error in the code example. im using myQvOcx.RefreshDocument(); But I only want to enable the refresh button if the document on the server has been reloaded. Also the document settings are Client initalizes refresh. I can detect from the ocx when the document has LAST been refreshed. But not that there is a new copy on the server, as far as I Know. Im trying to get the management api to work.. but it doesent quite work – Archlight Jan 28 '14 at 20:30