简体   繁体   中英

Tibco spotfire; Refresh tables under conditions using ironpython

I wrote the following script in order to refresh tables under specific conditions.

I have created a document property under the name "lob".

Some tables will be refreshed according to lob's value, while othes will be refreshed despite lob's value.

Please note that some tables may not be refreshed at all. That's the reason for begging my script with data's deletion from every single table and then refreshing.

Moreover, i have created a document property under the name "PIAreadyToDisplay". This property equals "No" while tables are being refreshed. When the table's refresh is finished, the document property equals to "Yes".

It seems that tables are refreshing according my needs but the document property "PIAreadyToDisplay" does not work as it should.

Do you find any mistake in my script?

Thank you in advance for your reply.

**Script**

Document.Properties["PIAreadyToDisplay"] = "No"

import clr

from Spotfire.Dxp.Data import RowSelection, IndexSet

MyTable = Document.Data.Tables["In Force"]

MyTable.RemoveRows(RowSelection(IndexSet(MyTable.RowCount,True)))

MyTable = Document.Data.Tables["ACP_IF"]

MyTable.RemoveRows(RowSelection(IndexSet(MyTable.RowCount,True)))

MyTable = Document.Data.Tables["NAYO_IF"]

MyTable.RemoveRows(RowSelection(IndexSet(MyTable.RowCount,True)))

MyTable = Document.Data.Tables["In Force"]

MyTable.RemoveRows(RowSelection(IndexSet(MyTable.RowCount,True)))

MyTable = Document.Data.Tables["pol_start_dt"]

MyTable.RemoveRows(RowSelection(IndexSet(MyTable.RowCount,True)))

MyTable = Document.Data.Tables["Policy_Info_Fire_append_non_fire"]

MyTable.RemoveRows(RowSelection(IndexSet(MyTable.RowCount,True)))

MyTable = Document.Data.Tables["policy_info_covers_mani"]

MyTable.RemoveRows(RowSelection(IndexSet(MyTable.RowCount,True)))

MyTable = Document.Data.Tables["Intermediaries"]

MyTable.RemoveRows(RowSelection(IndexSet(MyTable.RowCount,True)))

MyTable = Document.Data.Tables["Policy_Info_HH _with_Descriptions"]

MyTable.RemoveRows(RowSelection(IndexSet(MyTable.RowCount,True)))

MyTable = Document.Data.Tables["Policy_info_Companies_with_descriptions"]

MyTable.RemoveRows(RowSelection(IndexSet(MyTable.RowCount,True)))

MyTable = Document.Data.Tables["policy_multiple_Usages"]

MyTable.RemoveRows(RowSelection(IndexSet(MyTable.RowCount,True)))

import clr

from System.Collections.Generic import List, Dictionary

from Spotfire.Dxp.Data import DataTable

from Spotfire.Dxp.Framework.ApplicationModel import NotificationService



--- Empty list to hold DataTables

Tbls = List[DataTable]()

str1 = Document.Properties["lob"] ;

str2 = "5049242";

if (str2 in str1)==True:

Tbls.Add(ACP)

str3 = "5049234";

if (str3 in str1)==True:

Tbls.Add(NAYO_IF)

str4 = "Πυρός";

if (str4 in str1)==True:

Tbls.Add(house)

Tbls.Add(companies)

Tbls.Add(use)



Tbls.Add(polstart)

Tbls.Add(interm)

Tbls.Add(covers)


--- Notification service

notify = Application.GetService[NotificationService]();

--- Execute something after tables are loaded

def afterLoad(exception, Document=Document, notify=notify):

if not exception:

  Document.Properties["PIAreadyToDisplay"] = "Yes"



else:

  notify.AddErrorNotification("Error refreshing table(s)","Error details",str(exception))

--- Refresh table(s)

Document.Data.Tables.RefreshAsync(Tbls, afterLoad)

Solved

In order to show the value of document property "PIAreadyToDisplay":

  1. I inserted an text area I inserted a label - property control.
  2. In order to do that, i selected a table in the "Data" field and i selected my document property in the "Values" field. When the table (of step 2) was not refreshed, document property's value was not changed.

In step 2, i selected a table which will always have been refreshed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM