Define custom application type for backoffice - intershop

We are trying to setup custom application type for Backoffice on latest Intershop 7.9, but when we try to run DBInit we get following error:
[xx.xxx.webshop.dbinit.data.organization.Channel,xx.xxx.webshop.dbinit.data.organization.ChannelLocalization,ProcessChannel-DBInit] Version:null] com.intershop.beehive.core.pipelet.pipeline.ExecutePipeline [] [Unknown] [scHAqDIFBIAAAAFjuxgo2CwQ] [RbPAqDIFZAUAAAFjuxgo2CwQ] "main" ISH-CORE-2490: Synchronous called pipeline 'CreateSalesChannel-CreateChannelObjects' of application 'CustomShop#Custom-Site (app=xx.CustomBackoffice)' has finished with exception: com.intershop.beehive.core.internal.pipeline.PipelineCallStackException: com.intershop.beehive.core.capi.pipeline.PipelineExecutionException: Required input parameter 'AppID' missing of pipeline 'ProcessApplication defined in cartridge sld_ch_base' and start node 'Create'!
Error appears when calling preparer for channels.
This is relevant code from apps.component file used to create backoffice application type:
<instance name="xx.CustomBackoffice.ApplicationTypes" with="AppRegistry"/>
<!-- register the custom B2CBackoffice to the Enterprise Backoffice of your choose -->
<fulfill of="intershop.EnterpriseBackoffice" requirement="namedObject">
<instance with="NamedObject">
<fulfill value="ChannelBackofficeApplicationType_52" requirement="name"/>
<fulfill with="xx.CustomBackoffice" requirement="object"/>
</instance>
</fulfill>
<!-- declaration of the cartridge list -->
<instance with="CartridgeListProvider" name="xx.CustomBackoffice.Cartridges">
<!-- Derive from standard webshop if you want to use the same cartridges like standard webshop -->
<fulfill requirement="parent" with="intershop.B2CBackoffice.Cartridges" />
</instance>
<!-- definition of the application type -->
<instance with="ApplicationType" name="xx.CustomBackoffice">
<fulfill requirement="id" value="xx.CustomBackoffice" />
<fulfill requirement="urlIdentifier" value="a1-shop-bo" />
<fulfill requirement="cartridgeListProvider" with="xx.CustomBackoffice.Cartridges" />
<fulfill requirement="namedObject">
<instance with="NamedObject">
<fulfill requirement="name" value="ChannelApps_52" />
<!-- register the AppRegistry containing all storefront applications of this channel -->
<fulfill requirement="object" with="xx.CustomBackoffice.ApplicationTypes" />
</instance>
</fulfill>
<!-- put additional NamedObjects, that are required by the particular business features -->
<!-- ... -->
</instance>
<!-- registration of the application type to the AppEngine -->
<fulfill of="AppEngine" with="xx.CustomBackoffice" requirement="app"/>
<fulfill requirement="namedObject" of="xx.CustomBackoffice" with="intershop.EnterpriseBackoffice.RESTAPI"/>
As soon as I remove definition for custom backoffice application type, dbinit runs successfully and frontoffice application types are created without error.
Can anybody see where is error or what is correct way to define custom application type for backoffice?
I tracked down this problem to define 2 custom application types in apps.component, especially this part:
<!-- register the custom B2CBackoffice to the Enterprise Backoffice of your choose -->
<fulfill of="intershop.EnterpriseBackoffice" requirement="namedObject">
<instance with="NamedObject">
<fulfill value="ChannelBackofficeApplicationType_52" requirement="name"/>
<fulfill with="xx.CustomBackoffice" requirement="object"/>
</instance>
</fulfill>
If I add second BO application type and try to register it with intershop.EnterpriseBackoffice with same code as above (just change xx.CustomBackoffice to xx2.CustomBackoffice):
<!-- register the custom B2CBackoffice to the Enterprise Backoffice of your choose -->
<fulfill of="intershop.EnterpriseBackoffice" requirement="namedObject">
<instance with="NamedObject">
<fulfill value="ChannelBackofficeApplicationType_52" requirement="name"/>
<fulfill with="xx2.CustomBackoffice" requirement="object"/>
</instance>
</fulfill>
Error shown above is given running DBinit. So if anyone knows hot to define and register 2 custom application types for backoffice (xx.CustomBackoffice and xx2.CustomBackoffice)?

From what I can see, there is a cartridgeListProvider reference:
<fulfill requirement="cartridgeListProvider" with="a1.ShopBackoffice.Cartridges" />
pointing to a1.ShopBackoffice.Cartridges but I cannot find the matching instantiation name in your codep snippet. Instead I see only xx.CustomBackoffice.Cartridges.

This example here should work:
<!-- ************************************************************************************ -->
<!-- * Application Type "custom.B2BBackoffice" * -->
<!-- ************************************************************************************ -->
<instance name="custom.B2BBackoffice.ApplicationTypes" with="AppRegistry"/>
<fulfill of="intershop.EnterpriseBackoffice" requirement="namedObject">
<instance with="NamedObject">
<fulfill value="customChannelBackofficeApplicationType_52" requirement="name"/>
<fulfill with="custom.B2BBackoffice" requirement="object"/>
</instance>
</fulfill>
<instance with="CartridgeListProvider" name="custom.B2BBackoffice.Cartridges">
<fulfill value="ish_app_bo_common" requirement="selectedCartridge"/>
<fulfill value="ish_app_bo_stock" requirement="selectedCartridge"/>
<fulfill value="ish_app_bo_user" requirement="selectedCartridge"/>
<fulfill value="sld_ch_consumer_plugin" requirement="selectedCartridge"/>
<fulfill with="intershop.EnterpriseBackoffice.Cartridges" requirement="parent"/>
</instance>
<instance with="ApplicationType" name="custom.B2BBackoffice">
<fulfill value="custom.B2BBackoffice" requirement="id"/>
<fulfill value="b2b" requirement="urlIdentifier"/>
<fulfill with="custom.B2BBackoffice.Cartridges" requirement="cartridgeListProvider"/>
<fulfill requirement="namedObject">
<instance with="NamedObject">
<fulfill requirement="name" value="ChannelApps_52" />
<fulfill requirement="object" with="custom.B2BBackoffice.ApplicationTypes" />
</instance>
</fulfill>
</instance>
<fulfill requirement="namedObject" of="intershop.EnterpriseBackoffice">
<instance with="NamedObject">
<fulfill requirement="name" value="ChannelApps_52" />
<fulfill requirement="object" with="custom.B2BBackoffice.ApplicationTypes" />
</instance>
</fulfill>
<fulfill of="AppEngine" with="custom.B2BBackoffice" requirement="app"/>
<fulfill requirement="namedObject" of="custom.B2BBackoffice" with="intershop.EnterpriseBackoffice.RESTAPI"/>
The assignment to the actual site can be done in the database using a statement like this:
UPDATE application SET appid = 'custom.B2BBackoffice' WHERE urlidentifier IN ('IshB2B', 'IshB2B-xxxb2b');

Apparently there is a way to define two application types for BO and assign them to different channels.
It's a kind of workaround but it works...
You have to define two BO application types in apps.component, and assign them to both channels, for example:
<fulfill requirement="app" with="channel1.Web" of="channel1.Backoffice.ApplicationTypes"/>
<fulfill requirement="app" with="channel1.Web" of="channel2.Backoffice.ApplicationTypes"/>
<fulfill requirement="app" with="channel2.Web" of="channel1.Backoffice.ApplicationTypes"/>
<fulfill requirement="app" with="channel2.Web" of="channel2.Backoffice.ApplicationTypes"/>
And add post DBinit preparer which executes SQL to update channel1 BO application to channel1.Backoffice (because with DBInit channel1 will be assigned to channel2.Backoffice):
UPDATE application SET appid = 'channel1.Backoffice' WHERE urlidentifier IN ('channel1', 'channel1-organization-channel1');

Related

Entity Framework Core in .NET MAUI/Xamarin.Forms

I finished coding my .NET MAUI application and everything was working fine in debug mode. All my data persistence needs were being met by Entity Framework Core for Xamarin, even though I am using it on .NET MAUI.
I have made the apk file and was testing it to see if everything was okay, but turns out the database is not being created. My application crashes once I attempt to do database operations. So I am not sure if it is incompatibility of EF Core with .NET MAUI (but it was working fine in debug) or there is something I missed.
I followed the tutorial accessed here https://learn.microsoft.com/en-us/ef/core/get-started/xamarin And below is my DataContext file
DataContext.cs
using Microsoft.EntityFrameworkCore;
using MedbaseRec.Models;
namespace MedbaseRec.Utils
{
public class DataContext : DbContext
{
public DbSet<QuestionPack> QuestionPacks { get; set; }
public DbSet<Question> Questions { get; set; }
public DataContext()
{
SQLitePCL.Batteries_V2.Init();
Database.EnsureCreated();
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
string dbPath = Path.Combine(FileSystem.AppDataDirectory, "medbaseapplica.db3");
optionsBuilder.UseSqlite($"Filename={dbPath}");
}
}
}
The Android/iOS linkers are removing chunks of the Entity Framework Core / Sqlite assemblies due to the heavy use of reflection. You can instruct the linker to keep some of the important Entity Framework Core stuff like so:
Add an XML file named Linker.xml to your Android project.
Right click Linker.xml in your Solution Explorer then select Properties.
Change Build Action to LinkDescription.
Add the following XML:
<?xml version="1.0" encoding="utf-8" ?>
<linker>
<!-- Entity Framework Core -->
<assembly fullname="mscorlib">
<type fullname="System.String">
<method name="Compare"></method>
<method name="CompareTo"></method>
<method name="ToUpper"></method>
<method name="ToLower"></method>
</type>
</assembly>
<assembly fullname="System.Core" />
<assembly fullname="Microsoft.EntityFrameworkCore" />
<assembly fullname="Microsoft.EntityFrameworkCore.Sqlite" />
<assembly fullname="Microsoft.EntityFrameworkCore.Relational" />
<assembly fullname="SQLitePCLRaw.core" />
<assembly fullname="SQLitePCLRaw.batteries_v2" />
<assembly fullname="SQLitePCLRaw.lib.e_sqlite3.android" />
</linker>
The iOS linker is different and it removes some attributes Entity Framework depends on. You need to add an iOS-specific linker extension in that case:
<?xml version="1.0" encoding="utf-8" ?>
<linker>
<!-- Entity Framework Core -->
<assembly fullname="mscorlib">
<type fullname="System.String">
<method name="Compare"></method>
<method name="CompareTo"></method>
<method name="ToUpper"></method>
<method name="ToLower"></method>
</type>
<type fullname="System.Reflection.AssemblyInformationalVersionAttribute" preserve="all" />
</assembly>
<assembly fullname="System.Core" />
<assembly fullname="Microsoft.EntityFrameworkCore" />
<assembly fullname="Microsoft.EntityFrameworkCore.Sqlite" />
<assembly fullname="Microsoft.EntityFrameworkCore.Relational" />
<assembly fullname="SQLitePCLRaw.core" />
<assembly fullname="SQLitePCLRaw.batteries_v2" />
<assembly fullname="SQLitePCLRaw.lib.e_sqlite3.ios" />
</linker>
This has been verified to work against Microsoft.EntityFrameworkCore.Sqlite version 5.0.17.
The LinkDescription XML files are documented here.
The problem was with the Linker that thought that my EntityFrameworkCore dependency is not needed. It was working a bit too well.
I switched it off in the csproj file as follows
<PropertyGroup>
<AndroidLinkMode>None</AndroidLinkMode>
</PropertyGroup>
I do think however that I should have used <AndroidLinkSkip>Assembly1</AndroidLinkSkip> to make sure that the assembly would be skipped by the linker and included in the release build.
Here is a linker to the Xamarin linker page that relates to .NET MAUI too.
https://learn.microsoft.com/en-us/xamarin/android/deploy-test/linker

NLog "Input string was not in a correct format." using windows-identity

I am trying to log some information to database, but being kind of new to nlog config ( until now the default config from Tutorials worked fine) I am not sure what I am missing from my config to work.
I get this error when I app starts
2022-02-24 17:06:46.1375 Error Failed loading from config file location: C:\Repos\App\bin\Debug\netcoreapp3.1\NLog.config Exception: NLog.NLogConfigurationException: Exception when parsing C:\Repos\App\bin\Debug\netcoreapp3.1\NLog.config.
---> System.FormatException: Input string was not in a correct format.
at System.Text.StringBuilder.FormatError()
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(String format, Object[] args)
at NLog.NLogConfigurationException..ctor(Exception innerException, String message, Object[] messageParameters)
at NLog.Config.LoggingConfigurationParser.ConfigureObjectFromAttributes(Object targetObject, ILoggingConfigurationElement element, Boolean ignoreType)
at NLog.Config.LoggingConfigurationParser.ParseTargetElement(Target target, ILoggingConfigurationElement targetElement, Dictionary`2 typeNameToDefaultTargetParameters)
at NLog.Config.LoggingConfigurationParser.ParseTargetsElement(ILoggingConfigurationElement targetsElement)
at NLog.Config.LoggingConfigurationParser.ParseNLogSection(ILoggingConfigurationElement configSection)
at NLog.Config.XmlLoggingConfiguration.ParseNLogSection(ILoggingConfigurationElement configSection)
at NLog.Config.LoggingConfigurationParser.LoadConfig(ILoggingConfigurationElement nlogConfig, String basePath)
at NLog.Config.XmlLoggingConfiguration.ParseNLogElement(ILoggingConfigurationElement nlogElement, String filePath, Boolean autoReloadDefault)
at NLog.Config.XmlLoggingConfiguration.ParseTopLevel(NLogXmlElement content, String filePath, Boolean autoReloadDefault)
at NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader, String fileName, Boolean ignoreErrors)
--- End of inner exception stack trace ---
at NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader, String fileName, Boolean ignoreErrors)
at NLog.Config.XmlLoggingConfiguration..ctor(XmlReader reader, String fileName, LogFactory logFactory)
at NLog.Config.LoggingConfigurationFileLoader.LoadXmlLoggingConfiguration(XmlReader xmlReader, String configFile, LogFactory logFactory)
at NLog.Config.LoggingConfigurationFileLoader.LoadXmlLoggingConfigurationFile(LogFactory logFactory, String configFile)
at NLog.Config.LoggingConfigurationFileLoader.TryLoadLoggingConfiguration(LogFactory logFactory, String configFile, LoggingConfiguration& config)
My Config files looks like this
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwConfigExceptions="true"
internalLogLevel="trace"
internalLogFile="c:\temp\internal-nlog-AspNetCore3.txt">
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
<!-- the targets to write to -->
<targets>
<!-- File Target for all log messages with basic details -->
<target xsi:type="File" name="allfile" fileName="c:\temp\nlog-AspNetCore3-all-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
<!-- File Target for own log messages with extra web details using some ASP.NET core renderers -->
<target xsi:type="File" name="ownFile-web" fileName="c:\temp\nlog-AspNetCore3-own-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}|" />
<!--Console Target for hosting lifetime messages to improve Docker / Visual Studio startup detection -->
<target xsi:type="Console" name="lifetimeConsole" layout="${MicrosoftConsoleLayout}" />
<target xsi:type="database" name="database"
layout="${longdate}|${level:uppercase=true}|${logger}|${message}|identity:${identity}|windows-identity:${windows-identity}">
<connectionString>
Data Source=MYCOMPUTER;Initial Catalog=DatabaseName;Integrated Security=True
</connectionString>
<commandText>
INSERT INTO SystemLogging(LogDate,LogLevel,LogLogger,LogMessage,LogMachineName, LogUserName, LogCallSite, LogThread, LogException, LogStackTrace)
VALUES(#time_stamp, #level, #logger, #message,#machinename, #user_name, #call_site, #threadid, #log_exception, #stacktrace);
</commandText>
<parameter name="#time_stamp" layout="${longdate}"/>
<parameter name="#level" layout="${level}"/>
<parameter name="#logger" layout="${logger}"/>
<parameter name="#message" layout="${message}"/>
<parameter name="#machinename" layout="${machinename}"/>
<parameter name="#user_name" layout="${windows-identity:domain=true}"/>
<parameter name="#call_site" layout="${callsite:filename=true}"/>
<parameter name="#threadid" layout="${threadid}"/>
<parameter name="#log_exception" layout="${exception}"/>
<parameter name="#stacktrace" layout="${stacktrace}"/>
</target>
</targets>
<!-- rules to map from logger name to target -->
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="allfile" />
<!--Output hosting lifetime messages to console target for faster startup detection -->
<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="lifetimeConsole, ownFile-web" final="true" />
<!--Skip non-critical Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<!-- BlackHole -->
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
</rules>
</nlog>
I know for a fact the problem is somewhere in line 28, layout of db connection.
layout="${longdate}|${level:uppercase=true}|${logger}|${message}|identity:${identity}|windows-identity:${windows-identity}"
If I remove this line however I get an other error
"LayoutRenderer cannot be found: 'windows-identity'"
It feels like an obvious problem, however search the internet I could not find a solution. Anyone with more experience in NLog, can you share an example of DB Logging that uses Windows-Auth for db logging and not a username/password in connection string.
I've also tried ( added '' to windows-identity, but that didn't work either )
layout="${longdate}|${level:uppercase=true}|${logger}|${message}|identity: '${identity}' | windows-identity: '${windows-identity}'"
Edit:
Updated config
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwConfigExceptions="true"
internalLogLevel="trace"
internalLogFile="c:\temp\internal-nlog-AspNetCore3.txt">
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="NLog.WindowsIdentity"/>
</extensions>
<!-- the targets to write to -->
<targets>
<!-- File Target for all log messages with basic details -->
<target xsi:type="File" name="allfile" fileName="c:\temp\nlog-AspNetCore3-all-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
<!-- File Target for own log messages with extra web details using some ASP.NET core renderers -->
<target xsi:type="File" name="ownFile-web" fileName="c:\temp\nlog-AspNetCore3-own-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}|" />
<!--Console Target for hosting lifetime messages to improve Docker / Visual Studio startup detection -->
<target xsi:type="Console" name="lifetimeConsole" layout="${MicrosoftConsoleLayout}" />
<target xsi:type="database" name="database"
layout="${longdate}|${level:uppercase=true}|${logger}|${message}|identity:${identity}|windows-identity:${environment-user}">
<connectionString>
Data Source=MYCOMPUTER;Initial Catalog=DatabaseName;Integrated Security=True
</connectionString>
<commandText>
INSERT INTO SystemLogging(LogDate,LogLevel,LogLogger,LogMessage,LogMachineName, LogUserName, LogCallSite, LogThread, LogException, LogStackTrace)
VALUES(#time_stamp, #level, #logger, #message,#machinename, #user_name, #call_site, #threadid, #log_exception, #stacktrace);
</commandText>
<parameter name="#time_stamp" layout="${longdate}"/>
<parameter name="#level" layout="${level}"/>
<parameter name="#logger" layout="${logger}"/>
<parameter name="#message" layout="${message}"/>
<parameter name="#machinename" layout="${machinename}"/>
<parameter name="#user_name" layout="${windows-identity:domain=true}"/>
<parameter name="#call_site" layout="${callsite:filename=true}"/>
<parameter name="#threadid" layout="${threadid}"/>
<parameter name="#log_exception" layout="${exception}"/>
<parameter name="#stacktrace" layout="${stacktrace}"/>
</target>
</targets>
<!-- rules to map from logger name to target -->
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="allfile" />
<!--Output hosting lifetime messages to console target for faster startup detection -->
<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="lifetimeConsole, ownFile-web" final="true" />
<!--Skip non-critical Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<!-- BlackHole -->
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
</rules>
</nlog>
So it turns out the layout is not working. I removed it and app would start with no erros. However I still had to add a rule in order to make logs in db. Here is the working version of the nlog file.
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwConfigExceptions="true"
internalLogLevel="trace"
internalLogFile="c:\temp\internal-nlog-AspNetCore3.txt">
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="NLog.WindowsIdentity"/>
</extensions>
<!-- the targets to write to -->
<targets>
<!-- File Target for all log messages with basic details -->
<target xsi:type="File" name="allfile" fileName="c:\temp\nlog-AspNetCore3-all-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
<!-- File Target for own log messages with extra web details using some ASP.NET core renderers -->
<target xsi:type="File" name="ownFile-web" fileName="c:\temp\nlog-AspNetCore3-own-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}|" />
<!--Console Target for hosting lifetime messages to improve Docker / Visual Studio startup detection -->
<target xsi:type="Console" name="lifetimeConsole" layout="${MicrosoftConsoleLayout}" />
<target xsi:type="database" name="database">
<connectionString>
Data Source=MYCOMPUTER;Initial Catalog=DbName;Integrated Security=True
</connectionString>
<commandText>
INSERT INTO SystemLogging(LogDate,LogLevel,LogLogger,LogMessage,LogMachineName, LogUserName, LogCallSite, LogThread, LogException, LogStackTrace)
VALUES(#time_stamp, #level, #logger, #message,#machinename, #user_name, #call_site, #threadid, #log_exception, #stacktrace);
</commandText>
<parameter name="#time_stamp" layout="${longdate}"/>
<parameter name="#level" layout="${level}"/>
<parameter name="#logger" layout="${logger}"/>
<parameter name="#message" layout="${message}"/>
<parameter name="#machinename" layout="${machinename}"/>
<parameter name="#user_name" layout="${windows-identity:domain=true}"/>
<parameter name="#call_site" layout="${callsite:filename=true}"/>
<parameter name="#threadid" layout="${threadid}"/>
<parameter name="#log_exception" layout="${exception}"/>
<parameter name="#stacktrace" layout="${stacktrace}"/>
</target>
</targets>
<!-- rules to map from logger name to target -->
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="allfile" />
<logger name="*" minLevel="Trace" writeTo="database"/>
<!--Output hosting lifetime messages to console target for faster startup detection -->
<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="lifetimeConsole, ownFile-web" final="true" />
<!--Skip non-critical Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<!-- BlackHole -->
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
</rules>
</nlog>
The NLog Database-Target doesn't have a Layout-property, that can be assigned. Instead use input parameter-collection.
WindowsIdentity-nuget-package is required for ${windows-identity} on NetCore, and must be included:
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="NLog.WindowsIdentity"/>
</extensions>
Maybe you are looking for ${environment-user} ?
See also: https://github.com/NLog/NLog/wiki/Windows-Identity-Layout-Renderer

to hide custom workflow from another site alfresco share

I need to hide custom workflow list for folders/documents present in " MyFiles " and other sites areas.Doing that from "show-site-workflow-modules.xml " with this configuration(code below), hides workflows from "workflows that I have started" also,which is terribly wrong.
<module>
<id>General_Workflow</id>
<description>Applies config based on site id</description>
<evaluator type="site.module.evaluator">
<params>
<sites>.*</sites>
<sitePresets>.*</sitePresets>
<applyForNonSites>true</applyForNonSites>
</params>
</evaluator>
<configurations>
<config evaluator="string-compare" condition="Workflow" replace="true">
<!-- A list of workflow definitions that are NOT displayed in Share -->
<hidden-workflows>
<!-- Hide all Custom workflows -->
<workflow name="customactiviti$xxxx" />
</hidden-workflows>
<!-- A list of workflow tasks that are NOT displayed in Share -->
<hidden-tasks>
<task type="customwf:*" />
</hidden-tasks>
</config>
</configurations>
</module>
<module>
<id>xxx_Conditional_Workflow</id>
<description>Applies config based on site id</description>
<evaluator type="site.module.evaluator">
<params>
<sites>xxx-xxx-xxx</sites>
<applyForNonSites>false</applyForNonSites>
</params>
</evaluator>
<configurations>
<config evaluator="string-compare" condition="Workflow" replace="true">
<!-- A list of workflow definitions that are NOT displayed in Share -->
<hidden-workflows>
<!-- Hide all WCM related workflows -->
<workflow name="activiti$activitiAdhoc" />
<workflow name="activiti$activitiInvitationModerated" />
<workflow name="activiti$activitiInvitationNominated" />
<workflow name="activiti$activitiInvitationNominatedAddDirect" />
<workflow name="activiti$activitiParallelGroupReview" />
<workflow name="activiti$activitiParallelReview" />
<workflow name="activiti$activitiReview" />
<workflow name="activiti$activitiReviewPooled" />
<workflow name="activiti$publishWebContent" />
</hidden-workflows>
<!-- A list of workflow tasks that are NOT displayed in Share -->
<hidden-tasks>
<!-- Hide all WCM related tasks -->
<task type="wcmwf:*" />
</hidden-tasks>
</config>
</configurations>
</module>

Alfresco custom subtypes for cm:folder not working

I tried to to create a new folder type, that inherits everything from cm:folder, so I created an xml file for myModel.xml under tomcat/shared/classes/alfresco/extension/models, and added the following content to it:
<?xml version="1.0" encoding="UTF-8"?>
<!-- xsi:schemaLocation="http://www.alfresco.org/model/dictionary/1.0 modelSchema.xsd" -->
<model name="my:custmodel"
xmlns="http://www.alfresco.org/model/dictionary/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<description>custom folder test</description>
<author>Max Mustermann</author>
<published>2015-11-24</published>
<version>1.0</version>
<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
</imports>
<namespaces>
<namespace uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
<namespace uri="http://www.alfresco.org/model/rendition/1.0" prefix="rn"/>
<namespace uri="http://www.alfresco.org/model/exif/1.0" prefix="exif"/>
<namespace uri="http://www.alfresco.org/model/audio/1.0" prefix="audio"/>
<namespace uri="http://www.alfresco.org/model/webdav/1.0" prefix="webdav"/>
<namespace uri="http://www.example.com/model/content/1.0" prefix="my" />
</namespaces>
<types>
<type name="my:folder1">
<title>folder1</title>
<parent>cm:folder</parent>
<archive>true</archive>
</type>
<type name="my:folder2">
<title>folder2</title>
<parent>cm:folder</parent>
<archive>true</archive>
</type>
</types>
then I added the following line to tomcat/shared/classes/alfresco/extension/custom-model-context.xml
<value>alfresco/extension/models/myModel.xml</value>
and finally in tomcat/shared/classes/alfresco/web-extension/share-config-custom.xml:
<type name="cm:folder">
<subtype name="my:folder1" />
<subtype name="my:folder2" />
</type>
Now the under details->change Typ, my subtypes appear, but when I try to apply them I get "cannot change type of document ..."
Your model file name in context file is mentioned as
<value>alfresco/extension/models/custModel.xml</value>
in your description you are saying name as "myModel.xml" is that a typo? Otherwise your file entries looks okey. Hope you are placing those entries properly.
This entry
<namespace uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
should be part of <imports> tag not <namespaces>
Something like this
<imports>
<!-- Import Alfresco Dictionary Definitions -->
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<!-- Import Alfresco Content Domain Model Definitions -->
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
</imports>

Unity Interception MethodSignatureMatchingRule could not be resolved

Im using Unity (3.0) interception to add some crosscutting concerns to my application. Somehow I can't use the MethodSignatureMatchingRule in my configuration getting this error message:
{"The type name or alias MethodSignatureMatchingRule could not be resolved. Please check your configuration file and verify this type name."}
My configuration:
<?xml version="1.0"?>
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<sectionExtension type="Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension, Microsoft.Practices.Unity.Interception.Configuration" />
<alias alias="singleton" type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager, Microsoft.Practices.Unity" />
<containers>
<container name="MyContainer">
<extension type="Interception"/>
<interception>
<policy name="EhabAspect">
<matchingRule name="MethodSignatureMatchingRule" type="MethodSignatureMatchingRule">
<constructor>
<param name="methodName" value="Receive" type="string"/>
</constructor>
</matchingRule>
<callHandler ... (omitted)
</policy>
</interception>
<register type="IMyClass" mapTo="MyClass">
<lifetime type="singleton" />
<interceptor type="InterfaceInterceptor"/>
<policyInjection/>
</register>
</container>
</containers>
</unity>
The same configuration with the NamespaceMatchingRule works fine.
My assembly contains a reference to
Microsoft.Practices.EnterpriseLibrary.Common
Microsoft.Practices.Unity
Microsoft.Practices.Unity.Configuration
Any suggestions?
I was facing the same problem here. I solved using the full qualified name of the of the class.
<matchingRule name="AuthorizationMethod" type="Microsoft.Practices.Unity.InterceptionExtension.MethodSignatureMatchingRule, Microsoft.Practices.Unity.Interception">
<constructor>
<param name="methodName" value="Authenticate" type="string"/>
<param name="parameterTypeNames" dependencyName="EmptyArray"/>
</constructor>
</matchingRule>

Resources