The DevExpress eXpressApp Framework (XAF) is an extremely powerful low-code framework for creating line-of-business applications. To make Llama Logger integration easier, we have provided a nuget package that works with the built in Tracing mechanism to enable Llama Logger with a few lines of code.
public static int Main(string[] args) {
if(ContainsArgument(args, "help") || ContainsArgument(args, "h")) {
Console.WriteLine("Updates the database when its version does not match the application's version.");
Console.WriteLine();
Console.WriteLine($" {Assembly.GetExecutingAssembly().GetName().Name}.exe --updateDatabase [--forceUpdate --silent]");
Console.WriteLine();
Console.WriteLine("--forceUpdate - Marks that the database must be updated whether its version matches the application's version or not.");
Console.WriteLine("--silent - Marks that database update proceeds automatically and does not require any interaction with the user.");
Console.WriteLine();
Console.WriteLine($"Exit codes: 0 - {DBUpdaterStatus.UpdateCompleted}");
Console.WriteLine($" 1 - {DBUpdaterStatus.UpdateError}");
Console.WriteLine($" 2 - {DBUpdaterStatus.UpdateNotNeeded}");
}
else {
// Llama Logger Code
#if DEBUG
LlamaLoggerTracing.Setup("<YourAPIKey>", Assembly.GetExecutingAssembly().GetName().Version.ToString() + "-dev");
#else
LlamaLoggerTracing.Setup("<YourAPIKey>", Assembly.GetExecutingAssembly().GetName().Version.ToString());
#endif
LlamaLoggerTracing.Initialize();
LlamaLoggerTracing.Tracer.CustomizeLogEntry += (s,e) => { ... };
// End of Llama Logger Code
DevExpress.ExpressApp.FrameworkSettings.DefaultSettingsCompatibilityMode = DevExpress.ExpressApp.FrameworkSettingsCompatibilityMode.Latest;
IHost host = CreateHostBuilder(args).Build();
if(ContainsArgument(args, "updateDatabase")) {
using(var serviceScope = host.Services.CreateScope()) {
return serviceScope.ServiceProvider.GetRequiredService<DevExpress.ExpressApp.Utils.IDBUpdater>().Update(ContainsArgument(args, "forceUpdate"), ContainsArgument(args, "silent"));
}
}
else {
host.Run();
}
}
return 0;
}
public static int Main(string[] args) {
if(ContainsArgument(args, "help") || ContainsArgument(args, "h")) {
Console.WriteLine("Updates the database when its version does not match the application's version.");
Console.WriteLine();
Console.WriteLine($" {Assembly.GetExecutingAssembly().GetName().Name}.exe --updateDatabase [--forceUpdate --silent]");
Console.WriteLine();
Console.WriteLine("--forceUpdate - Marks that the database must be updated whether its version matches the application's version or not.");
Console.WriteLine("--silent - Marks that database update proceeds automatically and does not require any interaction with the user.");
Console.WriteLine();
Console.WriteLine($"Exit codes: 0 - {DBUpdaterStatus.UpdateCompleted}");
Console.WriteLine($" 1 - {DBUpdaterStatus.UpdateError}");
Console.WriteLine($" 2 - {DBUpdaterStatus.UpdateNotNeeded}");
return 0;
}
DevExpress.ExpressApp.FrameworkSettings.DefaultSettingsCompatibilityMode = DevExpress.ExpressApp.FrameworkSettingsCompatibilityMode.Latest;
#if EASYTEST
DevExpress.ExpressApp.Win.EasyTest.EasyTestRemotingRegistration.Register();
#endif
WindowsFormsSettings.LoadApplicationSettings();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
DevExpress.Utils.ToolTipController.DefaultController.ToolTipType = DevExpress.Utils.ToolTipType.SuperTip;
//Llama Logger Code
#if DEBUG
LlamaLoggerTracing.Setup("<YourAPIKey>", Assembly.GetExecutingAssembly().GetName().Version.ToString() + "-dev");
#else
LlamaLoggerTracing.Setup("<YourAPIKey>", Assembly.GetExecutingAssembly().GetName().Version.ToString());
#endif
if(Tracing.GetFileLocationFromSettings() == DevExpress.Persistent.Base.FileLocation.CurrentUserApplicationDataFolder) {
LlamaLoggerTracing.LocalUserAppDataPath = Application.LocalUserAppDataPath;
}
LlamaLoggerTracing.Initialize();
LlamaLoggerTracing.Tracer.CustomizeLogEntry += (s,e) => { ... };
//End Llama Logger Code
string connectionString = null;
if(ConfigurationManager.ConnectionStrings["ConnectionString"] != null) {
connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
}
#if EASYTEST
if(ConfigurationManager.ConnectionStrings["EasyTestConnectionString"] != null) {
connectionString = ConfigurationManager.ConnectionStrings["EasyTestConnectionString"].ConnectionString;
}
#endif
ArgumentNullException.ThrowIfNull(connectionString);
var winApplication = ApplicationBuilder.BuildApplication(connectionString);
if (ContainsArgument(args, "updateDatabase")) {
using var dbUpdater = new WinDBUpdater(() => winApplication);
return dbUpdater.Update(
forceUpdate: ContainsArgument(args, "forceUpdate"),
silent: ContainsArgument(args, "silent"));
}
try {
winApplication.Setup();
winApplication.Start();
}
catch(Exception e) {
winApplication.StopSplash();
winApplication.HandleException(e);
}
return 0;
}