Macros

Macros are pieces of code specified by developers that run on the server.

Macros can be used in Reports, javascript files, all HTML contents, and Map CSS contents. Although some simplifications have been made in the syntax based on the place to be used in, the general usage is as in this document.

The macro language is set to C #. All methods of the object accessed via the API can be used.

Macros are defined as [= ...].

Map CSS and some special fields do not use square brackets. Information can be found in the relevant documents.


(warning) When it is necessary to use square brackets, it should be written as \] instead of ].


[=4*4]
[=new Random().Next(0,500)]
[=Math.Round(0.47)
[=DateTime.Now]
[="test".ToUpper()]

The macro expression contains two objects named context (c) and Data (d).

Data (d)

The type of macro varies depending on where it is used.  If the macro is used, the data type of the data object must be known. The types  are written in the  developer documentation and Readme.txt files. In GEODI reports, the Data object is GeodiEntry.

<div>
	<label> File name : </label> [=d.OutputGeodiContent.DisplayName]
</div>

context (c)

Content is available wherever a macro is used. It is an EvaluatorContext object. It includes helper methods and information about map such as details about geometry that is being drawn and scale level.

[=c.ToString(DateTime.Now,"en-US","dd MMM yyyy")]
<div>
	<dcc:panel visible='c.HasPermission("DECE.SYSTEMMANAGER")'>
		You are the system manager.
	</dcc:panel>
</div>

The context contains a limited number of helper methods. More helper methods can be accessed using the context ["HelperName"] method. A list of all helper classes is available here.


<div>
	<a href='[=c["geodi.link"\].ViewerLink(d)]'> [=d.OutputGeodiContent.DisplayName] </a>
</div>