How to set wix property in custom action of vbs? - wix

I need to check if C:\Windows\System32\vcruntime*.dll exist before any other custom actions written by QT c++.
<CustomAction Id="prechecksystem" Script="vbscript" Execute="deferred" Return="check">
<![CDATA[
Dim fso, sys32
Set fso = CreateObject("Scripting.FileSystemObject")
'0:WindowsFolder, 1:SystemFolder, 2:TemporaryFolder'
Set sys32 = fso.GetSpecialFolder(1)
If fso.FileExists(sys32 & "\vcruntime140.dll") Then
Session.Property("HSRSUPPORTVCRUNTIME") = "true"
End If
]]>
</CustomAction>
<Property Id="HSRSUPPORTVCRUNTIME" Value="false" />
<InstallUISequence>
<Custom Action="prechecksystem" After="CostFinalize"></Custom>
<Show Dialog="VcruntimeNotSupportWarning" Sequence="501"> <![CDATA[ ( HSRSUPPORTVCRUNTIME="false" ) ]]> </Show>
...
<InstallUISequence/>
But msiexec says that variable HSRSUPPORTVCRUNTIME was not defined?

You don't need ab custom action to do this and definitely should not user VBScript. Use FileSearch element.

Related

Bind Custom Properties to LoggingEvent Object in Log4Net

I am using log4net and I am trying to figure out the best way, or if there is anyway, to bind custom fields to the LoggingEvent object, that is used in the Append override method of the AppenderSkeleton.
For example, this could be a guid property to add to the other properties such as level, renderedMessage, etc.
However, I am planning on using the Log4net.Appenders.Fluentd with the log4net.Ext.Json, so the appender in the xml would look something like this:
<appender name="Fluentd" type="Log4net.Appenders.Fluentd.FluentdAppender, Log4net.Appenders.Fluentd">
<Host>127.0.0.1</Host>
<Port>24224</Port>
<Tag>YourTagHere</Tag>
<NoDelay>false</NoDelay>
<ReceiveBufferSize>8192</ReceiveBufferSize>
<SendBufferSize>8192</SendBufferSize>
<SendTimeout>1000</SendTimeout>
<ReceiveTimeout>1000</ReceiveTimeout>
<LingerEnabled>true</LingerEnabled>
<LingerTime>1000</LingerTime>
<EmitStackTraceWhenAvailable>true</EmitStackTraceWhenAvailable>
<IncludeAllProperties>false</IncludeAllProperties>
<!--json formatted log4net logging-->
<layout type="log4net.Layout.SerializedLayout, log4net.Ext.Json">
<decorator type="log4net.Layout.Decorators.StandardTypesDecorator, log4net.Ext.Json" />
<member value="date:date" />
<member value="level:level" />
<member value="message:messageObject" />
</layout>
</appender>
I was hoping there would be something like this in the end:
<!--json formatted log4net logging-->
<layout type="log4net.Layout.SerializedLayout, log4net.Ext.Json">
<decorator type="log4net.Layout.Decorators.StandardTypesDecorator, log4net.Ext.Json" />
<member value="date:date" />
<member value="level:level" />
<member value="message:messageObject" />
<member value="guid:guid" />
</layout>
Is this something I would have to some how carry out in the Log4net.Appenders.Fluentd source code?
You can use the ThreadContext to add a custom property to the LoggingEvent object that is passed into the Append override method of the AppenderSkeleton and the Format override method of the LayoutSkeleton.
Set it:
ThreadContext.Properties["my_custom_prop"] = "my custom property"
Then retrieve it:
var prop = evt.GetProperties()["my_custom_prop"].ToString();

Set <chart:guide> value at runtime

I'm trying to access the
<chart:guide>
value property from the screen controller, but I can't find any getter to reach it. The xml block is like this:
<chart:valueAxes>
<chart:axis position="LEFT"
stackType="REGULAR"
title="Graph Title">
<chart:guides>
<chart:guide
value="0"
inside="true"
lineAlpha="1"
/>
</chart:guides>
</chart:axis>
</chart:valueAxes>
I need to set the value of the guide at runtime. Any suggestion?
Let's say we have the following SerialChart:
<chart:serialChart id="serialChart"
caption="Serial chart"
height="100%"
width="100%"
categoryField="x">
<chart:graphs>
<chart:graph valueField="y"/>
</chart:graphs>
<chart:valueAxes>
<chart:axis position="LEFT">
<chart:guides>
<chart:guide value="12"
inside="true"
lineAlpha="1"/>
</chart:guides>
</chart:axis>
</chart:valueAxes>
<chart:data>
<chart:item>
<chart:property name="x" value="10"/>
<chart:property name="y" value="12"/>
</chart:item>
<chart:item>
<chart:property name="x" value="11"/>
<chart:property name="y" value="2"/>
</chart:item>
<chart:item>
<chart:property name="x" value="12"/>
<chart:property name="y" value="120"/>
</chart:item>
<chart:item>
<chart:property name="x" value="13"/>
<chart:property name="y" value="16"/>
</chart:item>
</chart:data>
</chart:serialChart>
You can simply get ValueAxis and then get Guide object by index or iterate collection and find by id (optional attribute of Guide):
#Inject
private SerialChart serialChart;
ValueAxis valueAxis = serialChart.getValueAxes().get(0);
Guide guide = valueAxis.getGuides().get(0);
guide.setValue(15);
serialChart.repaint();
Note, if we want to change already displayed chart configuration then we have to call repaint() method.
If you use CUBA 6.4 or older, you have to obtain Configuration object first using getConfiguration() method and cast it to appropriate chart type as shown here: https://doc.cuba-platform.com/charts-6.4/cdp_screen_controller.html

Parameter value as attribute value

I'm trying to pass parameter value as value for attribute, but it uses parameter name as string value. Here is what I mean:
<CustomAction Id="TryToSetAsDefault" Property="CONFIG_XML_FILE_NAME" Value="config.xml"/>
...
<Component Id="cid" Guid="{...}" Permanent="yes">
<File Id="fid" Name="[CONFIG_XML_FILE_NAME]" Source="$(var.SourceRoot)\config.xml"/>
</Component>

Pass Parameter to LinqDataSource "OnSelecting" for Stored Procedure

I'm building a semi-elaborate RadGrid where within my NestedViewTemplate I want to have a LinqDataSource that uses a Stored Procedure to get data from the database.
Here's what I have so far
<asp:HiddenField runat="server" ID="HiddenID" Value='<%#DataBinder.Eval(Container.DataItem, "ID")%>' />
<asp:LinqDataSource ID="LinqDataSource1" runat="server" OnSelecting="LinqDataSource_Selecting">
<WhereParameters>
<asp:ControlParameter ControlID="HiddenID" PropertyName="ID" Type="String" Name="ID" />
</WhereParameters>
</asp:LinqDataSource>
any my Code Behind...
Protected Sub LinqDataSource_Selecting(ByVal sender As Object, ByVal e As LinqDataSourceSelectEventArgs)
Dim hdc As New DAL.HealthMonitorDataContext()
e.Result = hdc.bt_HealthMonitor_GetByID(Integer.Parse(e.WhereParameters("ID")))
End Sub
but unfortunately hdc.bt_HealthMonitor_GetByID(Integer.Parse(e.WhereParameters("ID"))) isn't playing nice...
Exception Details:
System.FormatException: Input string was not in a correct format.
The "PropertyName" was incorrect in the WhereParameters.
<asp:ControlParameter ControlID="HiddenID"
PropertyName="Value"
Type="String"
Name="ID" />

Ordering the execution of WiX SetProperty actions

I have a sequence of SetProperty actions which rely on each other. Here is a simplified example:
<SetProperty Id="A" Before="AppSearch" Value="Hello" />
<SetProperty Id="B" Before="AppSearch" Value="[A] world!" />
Property A needs to be set before property B in this case, so that the value of B becomes "Hello world!".
Since WiX doesn't define an attribute to set the custom action name in this case, I don't have a name to use in the Before or After attributes.
I did notice that the execution order of these actions matches the alphabetical order of the property names, but that feels like an implementation detail that I should not rely on.
How do I cleanly enforce the order of SetProperty custom actions?
You can also use the “Action” attribute of the SetProperty element to nail down the name of the custom action. This becomes essential if you wish to set the same property in two distinct SetProperty actions as it removes ambiguous “SetXXX” action names.
For example:
<SetProperty Id="A" Action="MyFirstAction" Before="AppSearch" Value="Hello" />
<SetProperty Id="B" Action="MySecondAction" After="MyFirstAction" Value="[A] world!" />
<SetProperty Id="A" Action="MyThirdAction" After ="MySecondAction" Value="Goodbye cruel world!" />
I used orca to discover the names generated for the custom actions. They turn out to be SetA and SetB. The following does what I want:
<SetProperty Id="A" Before="AppSearch" Value="Hello" />
<SetProperty Id="B" After="SetA" Value="[A] world!" />