In the below job we are deleting all data related to Kanban (prefix).you can use it for different prefix,just change the prefix in the code.
static void KanbanDelete(Args _args)
{
int i =1;
#AviFiles
SysOperationProgress progress = new SysOperationProgress();
Common common;
#AOT
Name name;
NumberOf recordCount;
TreeNode treeNode;
SysDictTable sysDictTable;
Connection connection;
Statement statement;
str query;
DataAreaId currentDataArea;
;
progress.setCaption("Loading…");
progress.setAnimation(#AviUpdate);
treeNode = TreeNode::findNode(#TablesPath);
treeNode = treeNode.AOTfirstChild();
progress.setTotal(treeNode.AOTchildNodeCount());
while (treeNode)
{
name = treeNode.AOTname();
if(name like "kanban")
{
sysDictTable = SysDictTable::newTableId(treeNode.applObjectId());
recordCount = sysDictTable.recordCount();
if (recordCount)
{
connection = new Connection();
statement = connection.createStatement();
currentDataArea = curext();
query = "delete from "+name;
new SqlStatementExecutePermission(query).assert();
statement.executeUpdate(query);
CodeAccessPermission::revertAssert();
}
}
progress.setText(strFmt("%1" ,name));
progress.setCount(i, 1);
i++;
treeNode = treeNode.AOTnextSibling();
}
}
static void KanbanDelete(Args _args)
{
int i =1;
#AviFiles
SysOperationProgress progress = new SysOperationProgress();
Common common;
#AOT
Name name;
NumberOf recordCount;
TreeNode treeNode;
SysDictTable sysDictTable;
Connection connection;
Statement statement;
str query;
DataAreaId currentDataArea;
;
progress.setCaption("Loading…");
progress.setAnimation(#AviUpdate);
treeNode = TreeNode::findNode(#TablesPath);
treeNode = treeNode.AOTfirstChild();
progress.setTotal(treeNode.AOTchildNodeCount());
while (treeNode)
{
name = treeNode.AOTname();
if(name like "kanban")
{
sysDictTable = SysDictTable::newTableId(treeNode.applObjectId());
recordCount = sysDictTable.recordCount();
if (recordCount)
{
connection = new Connection();
statement = connection.createStatement();
currentDataArea = curext();
query = "delete from "+name;
new SqlStatementExecutePermission(query).assert();
statement.executeUpdate(query);
CodeAccessPermission::revertAssert();
}
}
progress.setText(strFmt("%1" ,name));
progress.setCount(i, 1);
i++;
treeNode = treeNode.AOTnextSibling();
}
}
No comments:
Post a Comment