1)AOT\Forms\Jimmy_LabelLists\init()
public void init()
{
super();
LabelModuleId.text("SYS");
infolog.globalCache().set(FormStr(Jimmy_LabelLists),"RefreshCurrentForm",element);
}
2) AOT\Forms\Jimmy_LabelLists\canClose()
public boolean canClose()
{
boolean ret;
ret = super();
infolog.globalCache().remove(FormStr(Jimmy_LabelLists),"RefreshCurrentForm");
return ret;
}
3)AOT\Forms\Jimmy_LabelLists\button\
void clicked()
{
;
Jimmy_Label::Jimmy_FindUnUsedLabels();
//super();
}
AOT\Classes\Jimmy_Label\Jimmy_FindUnUsedLabels()
static void Jimmy_FindUnUsedLabels()
{
str 50 labelId;
int m,NumModule;
int maxLabel,LookModule,initTimeNow;
LabelModuleId labelModuleId;
LanguageId LanguageEN,LanguageCN,LanguageFR;
Dialog dialog = new Dialog("Update Labes");
DialogField dlgMax = dialog.addField(types::Integer,"Max Lable Num.","127510");
Container conValue;
#Macrolib.AviFiles
SysOperationProgress progress;
Jimmy_LabelLists LabelLists;
Jimmy_LabelModuleTable labelModuleTable,UpLabelTable;
FormRun fr;
FormStringControl formStringControl;
FormDataSource formDataSource;
int findLabelFromModuleId(LabelModuleId _LabelModuleId)
{
str LabelCN,LabelEN,LabelFR;
int i,numbers;
int maxLabelKey;
xRefNames xRefNames;
XRefReferences XRefReferences;
;
maxLabelKey = Jimmy_LabelModuleTable::find(_LabelModuleId).MaxLabelKey;
while (i <= maxLabel)
{
labelId = "@" + _LabelModuleId + int2str(i);
progress.incCount(1);
progress.setText(strfmt("正在更新 - %1%2 %3 - 进度 - %4% [已完成 %5 / %6]",
"@",
_LabelModuleId,int2str(i),
i / (labelModuleTable.MaxLabelKey ? labelModuleTable.MaxLabelKey : maxLabel) * 100,
m,
LookModule)
);
//this will show the operation progress
/*
//Find if the label id has an cross reference record
select recid from xRefNames
where xRefNames.Name == labelid
exists join XRefReferences
where xRefNames.RecId == XRefReferences.xRefNameRecId;*/
LabelCN = SysLabel::labelId2String(labelId,LanguageCN);
LabelEN = SysLabel::labelId2String(labelId,LanguageEN);
LabelFR = SysLabel::labelId2String(labelId,LanguageFR);
if(LabelFR == labelId)
LabelFR = "";
if(LabelEN == labelId)
LabelEN = "";
if(LabelCN == labelId)
LabelCN = "";
//If there is no record in cross reference then log it
if (//! xRefNames.RecId &&
(LabelCN || LabelEN || LabelFR) &&
//avoid logging labels that are already deleted (This is because of sequential check like IFC1, IFC2, IFC3 etc...)
LabelCN != labelId)
{
numbers++;
LabelLists.clear();
LabelLists.LabelId = labelId;
LabelLists.LabelEN = LabelEN;
LabelLists.LabelCN = LabelCN;
LabelLists.LabelFR = LabelFR;
LabelLists.KeyId = i;
LabelLists.LabelType = "@" + _LabelModuleId;
LabelLists.LabelModuleId = _LabelModuleId;
LabelLists.doInsert();
}
i++;
if(maxLabelKey && i > maxLabelKey)
break;
// progress.incCount();
progress.update(true);
}
return numbers;
}
;
dialog.doInit();
conValue = xSysLastValue::getValue(curext(),curuserid(),UtilElementType::ClassStaticMethod,funcname(),"");
if(conValue == conNull())
dlgMax.value(0);
else
dlgMax.value(conpeek(conValue,1));
if(!dialog.run())
return;
global::startLengthyOperation();
initTimeNow = timeNow();
maxLabel = dlgMax.value();
LanguageCN = "ZH-HANS";
LanguageEN = "EN-US";
LanguageFR = "FR";
select count(RecId) from labelModuleTable
where labelModuleTable.isActived == Noyes::Yes;
LookModule = int642int(labelModuleTable.RecId,false);
while select labelModuleTable
where labelModuleTable.isActived == Noyes::Yes
{
m++;
delete_From LabelLists
where LabelLists.LabelModuleId == labelModuleTable.LabelModuleId &&
LabelLists.KeyId <= maxLabel;
progress = new SysOperationProgress();
progress.setCaption(strfmt("Update[%1] - %2 - %3" ,
labelModuleTable.LabelModuleId,
labelModuleTable.MaxLabelKey ? labelModuleTable.MaxLabelKey : maxLabel,
funcname()));
progress.setAnimation(#AviUpdate);
if(labelModuleTable.MaxLabelKey)
progress.setTotal(labelModuleTable.MaxLabelKey);
else
progress.setTotal(maxLabel);
NumModule = findLabelFromModuleId(labelModuleTable.LabelModuleId);
info(strfmt("%1 - %2 [have %3 Labels]",m < 10 ? "0" + int2str(m) : int2str(m),labelModuleTable.LabelModuleId,NumModule));
}
ttsbegin;
while select forupdate UpLabelTable order by UpLabelTable.LabelModuleId
{
select firstonly LabelLists order by LabelLists.KeyId desc
where LabelLists.LabelModuleId == UpLabelTable.LabelModuleId;
if(LabelLists.KeyId > UpLabelTable.MaxLabelKey)
{
UpLabelTable.MaxLabelKey = LabelLists.KeyId;
UpLabelTable.update();
}
}
ttscommit;
if(infolog.globalCache().get(FormStr(Jimmy_LabelLists),"RefreshCurrentForm"))
{
fr = infolog.globalCache().get(FormStr(Jimmy_LabelLists),"RefreshCurrentForm");
formStringControl = fr.design().controlName("LabelModuleId");
formStringControl.text("SYS");
formDataSource = fr.dataSource("Jimmy_LabelLists");
if(formDataSource)
{
formDataSource.reread();
formDataSource.refresh();
formDataSource.executeQuery();
//fr.dataSource("Jimmy_LabelLists").research();
formDataSource.findRecord(Jimmy_LabelLists::find("SYS",127239));//127510
}
}
global::endLengthyOperation();
xSysLastValue::putValue([maxLabel],curext(),curUserId(),UtilElementType::ClassStaticMethod,funcname(),"");
info(strfmt("Total took to [ %1 ] times",global::time2StrHMS(timenow() - initTimeNow)));
}
没有评论:
发表评论