Question

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.

Was it helpful?

Solution 2

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.

OTHER TIPS

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top