Hon.IFS.SiteManagement.EntityFrameworkCore.Domains.Contacts.ContactRepositoryTests.GetListAsync Source: ContactRepositoryTests.cs line 21 Duration: 1 ms
Message: Volo.Abp.AbpInitializationException : An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Hon.IFS.SiteManagement.SiteManagementTestBaseModule, Hon.IFS.SiteManagement.TestBase, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: Object reference not set to an instance of an object.. See the inner exception for details. ---- System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
ModuleManager.InitializeModules(ApplicationInitializationContext context)
AbpApplicationBase.InitializeModules()
AbpApplicationWithExternalServiceProvider.Initialize(IServiceProvider serviceProvider)
AbpIntegratedTest1.ctor() SiteManagementTestBase1.ctor()
SiteManagementEntityFrameworkCoreTestBase.ctor()
ContactRepositoryTests.ctor() line 14
RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
----- Inner Stack Trace -----
SiteManagementDataSeedContributor.SeedAsync(DataSeedContext context) line 58
<11 more frames...>
ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
TaskExtensions.WaitAndUnwrapException(Task task)
AsyncContext.Run(Func1 action) AsyncHelper.RunSync(Func1 action)
SiteManagementTestBaseModule.SeedTestData(ApplicationInitializationContext context) line 32
SiteManagementTestBaseModule.OnApplicationInitialization(ApplicationInitializationContext context) line 27
OnApplicationInitializationModuleLifecycleContributor.Initialize(ApplicationInitializationContext context, IAbpModule module)
ModuleManager.InitializeModules(ApplicationInitializationContext context)
I don't have any exception if you want I will share the logs
[RemoteService(IsEnabled = false)] public abstract class SendGridEmailNotificationAppServiceBase : SiteHostAppService { protected IEmailSender _emailSender; private readonly ITemplateRenderer _templateRenderer; private readonly Microsoft.Extensions.Configuration.IConfiguration _configuration; private readonly ITenantRepository _tenantRepository; private readonly ICurrentTenant _currentTenant; private readonly IStringEncryptionService _stringEncryption;
public SendGridEmailNotificationAppServiceBase(IEmailSender emailSender, ITemplateRenderer templateRenderer,
Microsoft.Extensions.Configuration.IConfiguration configuration, ITenantRepository tenantRepository, ICurrentTenant currentTenant, IStringEncryptionService stringEncryption)
{
_emailSender = emailSender;
_templateRenderer = templateRenderer;
_configuration = configuration;
_tenantRepository = tenantRepository;
_currentTenant = currentTenant;
_stringEncryption = stringEncryption;
}
public virtual async Task EmailNotification(SendGridEmailNotificationDto input)
{
string emailBody = null!;
input.BaseSiteUrl = _configuration["App:SelfUrl"]?.Trim();
try
{
if (input.MailSubject.Equals("CHANGEPASSWORD", StringComparison.InvariantCultureIgnoreCase))
{
input.MailSubject = "Your Password Has Been Successfully Changed";
var model = new ChangePasswordModel
{
Name = input.Name,
Url = input.BaseSiteUrl + "/Account/login",
Type = input.Type,
TenantName = input.TenantName
};
model.setCurrentDateTime();
emailBody = await LoadTemplate("ChangePassword.tpl", model);
}
else if (input.MailSubject.Equals("NEWUSERCREATED", StringComparison.InvariantCultureIgnoreCase))
{
input.MailSubject = "Your IFS Account Details and Next Steps";
var angularUrl = _configuration["App:SelfUrl"]?.Trim()?.TrimEnd('/');
if (string.IsNullOrEmpty(angularUrl))
{
throw new InvalidOperationException("App:AngularUrl is not set in configuration.");
}
string tenantHostName = await GetTenantHostNameAsync();
string navigationUrl;
if (_currentTenant.Id.HasValue)
{
string encryptedtenantHostName = _stringEncryption.Encrypt(tenantHostName);
navigationUrl = $"{angularUrl}/Account/Login?tenantName={Uri.EscapeDataString(encryptedtenantHostName)}";
}
else
{
navigationUrl = $"{angularUrl}/Account/Login";
}
var model = new UserCreationModel
{
Email = input.MailTo,
Username = input.Username,
Name = input.Name,
TenantId = input.TenantId,
UserId = input.Id,
Password = input.Password,
Url = navigationUrl
};
emailBody = await LoadTemplate("UserCreation.tpl", model);
}
else
{
throw new UserFriendlyException("Unsupported email subject type.");
}
await _emailSender.SendAsync(
to: input.MailTo,
subject: input.MailSubject,
body: emailBody,
isBodyHtml: input.IsBodyHtml
);
}
catch (Exception ex)
{
Logger.LogError(ex, "An error occurred while sending the email notification.");
throw new UserFriendlyException($"Failed to send the email. Reason: {ex.Message}. Please try again later.");
}
}
private async Task<string> LoadTemplate(string templateName, object model)
{
string renderedContent = null!;
try
{
if (string.IsNullOrWhiteSpace(templateName))
{
throw new UserFriendlyException("Template name is invalid.");
}
string templateDirectory;
var isDevEnv = Convert.ToBoolean(_configuration["IsDevEnv"] ?? "false");
templateDirectory = isDevEnv
? Path.Combine(Directory.GetCurrentDirectory(), "Emailing", "Templates")
: Path.Combine(AppContext.BaseDirectory, "Emailing", "Templates");
string templatePath = Path.Combine(templateDirectory, templateName);
if (!File.Exists(templatePath))
{
throw new FileNotFoundException($"Email template not found at path: {templatePath}");
}
var templateContent = await File.ReadAllTextAsync(templatePath);
// Apply replacements based on template name
if (templateName.Equals("UserCreation.tpl", StringComparison.OrdinalIgnoreCase) && model is UserCreationModel userModel)
{
renderedContent = templateContent
.Replace("{{model.Name}}", userModel.Name)
.Replace("{{model.Email}}", userModel.Email)
.Replace("{{model.Username}}", userModel.Username)
.Replace("{{model.Password}}", userModel.Password)
.Replace("{{model.Url}}", userModel.Url);
}
else if (templateName.Equals("ChangePassword.tpl", StringComparison.OrdinalIgnoreCase) && model is ChangePasswordModel passwordModel)
{
renderedContent = templateContent
.Replace("{{model.Name}}", passwordModel.Name)
.Replace("{{model.Date}}", passwordModel.Date.ToString("MMMM d, yyyy 'at' h:mm tt"))
.Replace("{{model.TenantName}}",passwordModel.TenantName)
.Replace("{{model.Url}}", passwordModel.Url);
}
else
{
throw new UserFriendlyException($"Unsupported template or model type for: {templateName}");
}
return renderedContent;
}
catch (Exception ex)
{
Logger.LogInformation(renderedContent);
Logger.LogError(ex, $"Failed to load or process email template: {templateName}");
throw new UserFriendlyException($"An error occurred while preparing the email content. --> {ex.Message}");
}
}
private async Task<string> GetTenantHostNameAsync()
{
string tenantHostName = "default";
if (_currentTenant.Id.HasValue)
{
var tenant = await _tenantRepository.FindAsync(_currentTenant.Id.Value);
if (tenant?.ExtraProperties.TryGetValue("tenantHostName", out var hostNameObj) == true)
{
tenantHostName = hostNameObj?.ToString() ?? tenantHostName;
}
}
return tenantHostName;
}
" private async Task<string> RenderEmailBodyAsync(string templateName, object model) { string renderedBody = null!; try { // Render the email body using the template renderer renderedBody = await _templateRenderer.RenderAsync(templateName, model); return renderedBody; } catch (Exception ex) { // Log the error and rethrow a user-friendly exception //Logger.LogError(ex, $"Failed to render email template: {templateName}"); throw new UserFriendlyException($"renderedBody string = {renderedBody} --> {ex.ToString()} for template {templateName} An error occurred while preparing the email content."); }" }
}
Hi,
We have 2 host applications (Host 1 and Host 2). Both have their respective Document Management Module 1 -> Host 1 and Document Management Module 2 -> Host 2. I would like to leverage the Document Management Module 1 in Host 1 and Host 2 rather than creating 2 different modules like above statement.
I am asking like below kind of code snippet.
ObjectExtensionManager.Instance.Modules()
.ConfigureElsa(Workflowdefinitions =>
{
identity.ConfigureUser(user =>
{
user.AddOrUpdateProperty<string>( //property type: string
"SocialSecurityNumber", //property name
property =>
{
//validation rules
property.Attributes.Add(new RequiredAttribute());
property.Attributes.Add(new StringLengthAttribute(64) { MinimumLength = 4 });
//...other configurations for this property
}
);
});
});
If I would like to extend WorkflowDefinitions, Workflowinstances tables by using ObjectExtensionManager.Instance.Modules(), will I be able, do it?
The reason for extending with additional columns is to store certain other details in the existing WorkflowDefinitions, Workflowinstances tables rather than creating a newly.
Hi,
Are you saying adding below line will create the Elsa related tables in the backend. .UseWorkflowRuntime(runtime => runtime.UseEntityFrameworkCore(ef => ef.UseSqlServer(connectionString)))
Does ABP Elsa pro does not generate the Elsa entities? Are you suggesting to use Elsa open source rather than ABP Elsa pro? If we use ABP elsa pro, then will we able to generate Elsa entities? if not, it stores in local storage. Am I right?
[maliming] said: hi
The Elsa Pro module doesn't contain any
Entitieshttps://abp.io/docs/latest/modules/elsa-pro
Can you check the code of https://abp.io/docs/latest/samples/elsa-workflows-demo
Thanks.
If Abp elsa pro won't generate the entities (workflowdefinitions, workflowinstances etc) , then where workflow and activity informations will store. will it store in in memory db? and will be lost when the application will restart?
Why AI bot is generating the answers saying workflowdefinitions, workflowinstances etc tables will generate with ABP Elsa pro?
If not ABP elsa pro, then should I try Elsa open source 3.x to generate the above entities?
Appreciate for the quick response
Should it be Volo.Abp.ElsaPro.Application.Contracts or Volo.Abp.Elsa.Application.Contracts
this is not solving the problem and seems like package reference are wrong