Добрый день!
AX 3.0 SP2
Появилась задача сделать в 20ти отчетах вместо жирных линий - тонкие, и убрать весь жирный шрифт с целью экономии тонера (правда не понятно в чем экономия

)
В общем руками делать было лень, и я написал Job который должен решить эту задачу. Но дело все в том, что изменения не вступают в силу и линии не меняются,
а так же отчеты не сохраняются в AOT.
Перепробовал кучу вариантов, но понять в чем дело так и не смог. Может кто сталкивался с данной проблемой?
Суть в том, что я кинул все изменяемые отчеты к себе в проект, и проходя по каждому,
хочу изменить "всё жирное" на "тонкое".
После прохода по контролам собственно и
не происходит сохранения.
Вот собственно код:
X++:
static void Job10(Args _args)
{
int reportCnt,
sectionCnt,
mainSectionCnt,
sectionQty;
Map reportMap,
SectionMap, // здесь сохраняются названия
//секций, т.к. SectionGroup - это отдельный класс и как
//определить тип секции я не разобрался
SubSectionMap; //на всякий случай но не используется
str name,
properties;
Args args;
Object object;
Boolean subSection;
Report report;
ReportDesign rDesign;
ReportSection rSection;
ReportSection rHdrSection;
ReportSectionGroup rSectionGrp;
ReportControl rControl;
ReportStringControl rStrControl;
ReportDateControl rDateControl;
ReportIntegerControl rIntControl;
ReportEnumControl rEnumControl;
ReportRealControl rRealControl;
ReportShapeControl rShapeControl;
ReportTextControl rTxtControl;
ReportTimeControl rTimeControl;
ReportRun rRun;
ReportBlockType rbt;
TreeNode tn, tnReport, tnDesign, tnSection;
TreeNodeIterator tnIterator, tnDesignIt;
ProjectNode pn, pnChild;
// метод который смотрит тип контрола и меняет его св-ва
void editControl(ReportSection _reportSection, int _ctrlQty)
{
int curControl = 1;
TreeNode tnControl;
;
while(curControl <= _ctrlQty)
{
rControl = rSection.controlNo(curControl);
name = rControl.treeNodeName();
tnControl = rSection.AOTfindChild(rControl.treeNodeName());
if(rControl && _ctrlQty > 0 && rControl.treeNodeName() != 'Methods')
{
Switch(rControl.controlType())
{
case ReportFieldType::String :
rStrControl = rControl;
if(rStrControl.bold() > 4)
{
Properties = setProperty(tnControl.AOTgetProperties(), ' Bold', 'Normal');
tnControl.AOTsetProperties(Properties);
}
break;
case ReportFieldType::Box :
rShapeControl = rControl;
if(rShapeControl.thickness() > LineThickness::Hairline)
{
Properties = setProperty(rShapeControl.AOTgetProperties(), ' thickness', 'Hairline');
tnControl.AOTsetProperties(Properties);
}
break;
case ReportFieldType::Date :
rDateControl = rControl;
if(rDateControl.bold() > 4)
{
Properties = setProperty(tnControl.AOTgetProperties(), ' Bold', 'Normal');
tnControl.AOTsetProperties(Properties);
}
break;
case ReportFieldType::Integer :
rDateControl = rControl;
if(rDateControl.bold() > 4)
{
Properties = setProperty(tnControl.AOTgetProperties(), ' Bold', 'Normal');
tnControl.AOTsetProperties(Properties);
}
break;
case ReportFieldType::Real :
rRealControl = rControl;
if(rRealControl.bold() > 4)
{
Properties = setProperty(tnControl.AOTgetProperties(), ' Bold', 'Normal');
tnControl.AOTsetProperties(Properties);
}
break;
case ReportFieldType::Text :
rTxtControl = rControl;
if(rTxtControl.bold() > 4)
{
Properties = setProperty(tnControl.AOTgetProperties(), ' Bold', 'Normal');
tnControl.AOTsetProperties(Properties);
}
break;
case ReportFieldType::Enum :
rEnumControl = rControl;
if(rDateControl.bold() > 4)
{
Properties = setProperty(tnControl.AOTgetProperties(), ' Bold', 'Normal');
tnControl.AOTsetProperties(Properties);
}
break;
}
tnControl.AOTcompile();
tnControl.AOTsave();
tnControl.AOTrefresh();
curControl++;
}
}
}
;
reportCnt = 1;
reportMap = new Map(Types::Integer, Types::Class);
pn = infolog.projectRootNode().AOTfindChild("shared");
pn = pn.AOTfindChild("MyPriject"); //собсвенно сам проект
pnChild = pn.loadForInspection(); // Загружаем объекты
tnIterator = pnChild.AOTiterator(); // Итератор
tn = tnIterator.next();
while(tn)
{
if(tn.applObjectType() == UtilElementType::Report) // Т.к. в проекте Job который
//выполняет изменения с
//отчетами, то здесь мы определяем тип объекта
{
// что бы понять что за объект и увидеть его св-ва, я создаю его в памяти
args = new Args(tn.treeNodeName());
tnReport = tn.AOTfirstChild();
reportMap.insert(reportCnt, tnReport);
while(tnReport)
{
if(tnReport.treeNodeName() == 'Designs')
{
tnDesign = tnReport.AOTfirstChild();
tnDesignIt = tnDesign.AOTiterator();
args.designName(tnDesign.treeNodeName());
rRun = new ReportRun(args);
report = rRun.report();
rDesign = report.design(tnDesign.treeNodeName());
while(tnDesign)
{
// Т.к. отчеты содержат не по одному дизайну, то надо модифицировать все
if(!tnDesign.AOTObjectNode() && tnDesign.treeNodeName() == 'Generated Design')
{
sectionCnt = 1;
mainSectionCnt = 1;
sectionQty = rDesign.sectionCount();
tnSection = tnDesign.AOTfirstChild();
SectionMap = new Map(Types::Integer, Types::Class);
SubSectionMap = new Map(Types::Integer, Types::Class);
while(tnSection)
{
if(!SubSection)
SectionMap.insert(sectionCnt, tnSection);
else
SubSectionMap.insert(sectionCnt, tnSection);
name = tnSection.AOTname();
rSection = rDesign.sectionName(name);
if(rSection)
{
editControl(rSection, rSection.controlCount());
if(tnSection.AOTnextSibling())
tnSection = tnSection.AOTnextSibling();
else
{
tnSection = tnSection.AOTfirstChild();
while(tnSection && !rDesign.sectionName(tnSection.AOTname()))
{
tnSection = tnSection.AOTnextSibling();
name = tnSection ? tnSection.AOTname() : "";
if(tnSection && tnSection.AOTfirstChild())
{
tnSection = tnSection.AOTfirstChild();
break;
}
}
subSection = !tnSection ? false : true;
}
}
else
{
tnSection = tnSection.AOTfirstChild();
subSection = tnSection ? true : false;
}
if(!tnSection)
{
tnSection = SectionMap.lookup(SectionMap.elements());
tnSection = tnSection.AOTnextSibling();
}
sectionCnt++;
}
}
tnDesign = tnDesignIt.next();
}
}
tnReport = tnReport.AOTnextSibling();
}
tnReport = reportMap.lookup(reportMap.elements()).AOTparent();
// Собственно здесь и должно происходить сохранение но этого не происходит
tnReport.AOTcompile();
tnReport.AOTsave();
tnReport.AOTrefresh();
//tnReport = null;
reportCnt++;
}
tn = tnIterator.next();
}
InfoLog.projectRootNode().AOTsave();
}