Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

OCX Reloading time issue

Hello,

I want to avoid the reloading after setting variables inside my report via C#

The reason is when I generate customer reports with huge amount of data flow, this take for each reload about 5-10minutes.

And now, if I want to filter those variables for 500 customers, this takes 5x500=2500minutes to 10x500=5000minutes, which actually takes around 8-16hours of export because the report is being reloaded everytime.

I'm using following code to set the variables.

public void SetVariables(IDictionary<string, object> parameters)

{

            foreach (KeyValuePair<string, object> p in parameters)

            {

                Variable v = qvReport.Variables(p.Key);

                if (v != null)

                {

                        //Console.WriteLine("Before modification content : " + v.GetContent().String);

                        v.SetContent(p.Value.ToString(), true);

                        //Console.WriteLine("Current content : " + v.GetContent().String);

                        variables = null;

                }

            }

            qvReport.Reload(0);  // don't reload it but change only selection

}

And for retrieving variables:

public IList<QlikViewVariable> GetVariables()

        {

            if (qvReport == null)

                throw new Exception("Load a QlikView Report before accessing Shapes");

            if (variables == null)

            {

                IList<QlikViewVariable> list = new List<QlikViewVariable>();

                for (int i = 0; i < qvReport.GetVariableDescriptions().Count; i++)

                {

                    IVariableDescription v = qvReport.GetVariableDescriptions();

                    //Console.WriteLine("Variable name : "+v.Name);

                    if (!(v.Name.Contains("filter")))

                    {

                        //Console.WriteLine(qvReport.GetVariable(v.Name).GetRawContent());

                        list.Add(new QlikViewVariable(v.Name, qvReport.GetVariable(v.Name).GetRawContent()));

                    }

                }

                variables = list;

            }

            return variables;

        }

I didn't find anything in the QlikView OCX reference manual to avoid the reloading process, but only change the variables in real time.

Because, in the Editor Script, when I open the document, I set

Set listbox=ActiveDocument.GetSheetObject("LB01")

listbox.SelectAll()

And in my sheet I create a listbox with following expression

=if($(v_Load_ID)=Load_ID,Load_ID)

Means, my variable v_Load_ID will be changed while injection process. It will automatically change my reports charts according to the variable on document opening.

So global idea:

Change variable with C# -> open document -> avoid reload process if the reload was already done today -> update charts -> I export them -> close document

The process I want to be done in better way is

*avoid reload process if the reload was already done today

Any idea?

Thanks

1 Solution

Accepted Solutions
Not applicable
Author

Found out how to skip it in an easier way.

    DateTime dt = File.GetLastWriteTime(qvReport.GetPathName());

    if (dt.Date!=DateTime.Today)

    {

        Console.WriteLine("Fetching newest information from database");

        qvReport.Reload(0); // Reloading the document with new variables

    }

    else

    {

         Console.WriteLine("File has been opened today and doesn't require to be reloaded");

    }

I defined that, if it has been launched once the same day, it won't be launched again and I save it in order to get a new modification time. Since, the report will be created once and never modified again, I can suppose that nobody will work on it anymore.

View solution in original post

3 Replies
Not applicable
Author

Nobody?

johnpaul
Partner - Creator
Partner - Creator

Perhaps a hack...

Have 2 documents, one that does the data load and then do a binary load in your report document. That should be really fast.

Not applicable
Author

Found out how to skip it in an easier way.

    DateTime dt = File.GetLastWriteTime(qvReport.GetPathName());

    if (dt.Date!=DateTime.Today)

    {

        Console.WriteLine("Fetching newest information from database");

        qvReport.Reload(0); // Reloading the document with new variables

    }

    else

    {

         Console.WriteLine("File has been opened today and doesn't require to be reloaded");

    }

I defined that, if it has been launched once the same day, it won't be launched again and I save it in order to get a new modification time. Since, the report will be created once and never modified again, I can suppose that nobody will work on it anymore.