Parameter value as attribute value - wix

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>

Related

How to set wix property in custom action of vbs?

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.

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();

Adding onto an existing ColdFusion 2016 ORM application

I am working on adding to a ColdFusion 2016 application with ORM. The application pulls up and doesn't give any type of errors prior to adding the second table code (TableTwo). As soon as the second table code is added, it gives an error saying:
Can't create table XXXXX.YYYYY (errno: 150 "Foreign key constraint
is incorrectly formed")
Where XXXXX is the name of the application as a whole - not TableOne, TableTwo or BaseTable.
Are there any ideas as to what is causing the application to give such an error?
If I delete all references to TableTwo and reload ORM, the application will pull up again. TableOne and TableTwo need to join to the BaseTable, but will not join to each other.
Below is an example of how the code is currently formatted.
TableOne.cfc
component {
property name="id" fieldType="id" ormtype="int" type="numeric" generator="native";
property name="baseTableID" ormtype="int" type="numeric" insert="false" update="false";
//relations
property name"baseTable" fieldType="one-to-one" cfc="BaseTable" fkcolumn="baseTableID" joincolumn="id" notnull="true" casecade="save-update";
}
BaseTable.cfc
component {
property name="id" fieldType="id" ormtype="int" type="numeric" generator="native";
//relations
property name="TableOne" fieldtype="one-to-one" cfc="TableOne" mappedby="baseTable" cascade="all-delete-orphan";
--Attempting to add a second one
property name="TableTwo" fieldtype="one-to-one" cfc="TableTwo" mappedby="baseTable" cascade="all-delete-orphan";
}
TableTwo.cfc
component {
property name="id" fieldType="id" ormtype="int" type="numeric" generator="native";
property name="baseTableID" ormtype="int" type="numeric" insert="false" update="false";
//relations
property name"BaseTable" fieldType="one-to-one" cfc="BaseTable" fkcolumn="baseTableID" joincolumn="id" notnull="true" casecade="save-update";
}

while adding records separately using many-to-one relationship getting variable undefined

I am using ColdFusion ORM with FW/1.
I have two tables student and parent, I have given many-to-one relationship as we know parent can have more wards in a school. I am adding student and parent separately, while adding parent I need parentId to be stored in student table so that I can list or get student with their parents for further features and activity.
Can anyone help me out how should I save the parent in a parent table and also parentId in student table?
student.cfc
component output="false" persistent="true" accessors="true" entityname="Student" table="school_student" {
// Use a mysql autonumber for an ID
property name="StudentId" column="school_studentid" type=numeric fieldtype="id" generator="identity";
property name="Fullname" column="school_studentFullname" type="string" length="128" notnull="true";
property name="email" column="school_studentEmail" type="string" length="128" notnull="true";
property name="password" column="school_studentPassword" type="string" length="64";
property name="Parent" fieldtype="many-to-one" cfc="Parent" fkcolumn="student_school_parentId" lazy="true" singularname="Parent";
}
parent.cfc
component output="false" accessors="true" persistent="true" entityname="Parent" table="school_parent" {
//use mysql autonumber id
property name="parentId" fieldtype="id" column="school_parentid" generator="identity";
property name="name" type="string" column="school_parentname" length="128";
property name="email" type="string" column="school_parentemail" length="128" ;
property name="password" type="string" column="school_parentpassword" length="64";
//relate parent with Student.
property name="Student" fieldtype="one-to-many" cfc="Student" fkcolumn="student_school_parentId" lazy="extra" inverse="true";
This is the way i am saving parent in my controllers:
<cfargument name="rc" type="struct" required="true">
<cfset parent = getParentService().parent(arguments.rc.parentid)>
<cfset student = getStudentService().student(arguments.rc.studentId)>
<cfset parent.setName(arguments.rc.name)>
<cfset parent.setEmail(arguments.rc.email)>
<cfset parent.setPassword(arguments.rc.password)>
<cfset getParentService().save(parent)>
<cfset student.addparent(parent)>
<cfset variables.fw.redirect('parent.list')>
How can I save parentid in student table while saving parent? I mean how can i call student save method to have parentid in student table?
Any help would be appreciated.
thanks
Try this
<cfset parent.addstudent(student)>
<cfset getParentService().save(parent)>
And try setting cascade="any" on the student property of Parent. This should allow you to save both objects...even if they are both are new objects being persisted for the first time.

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!" />