I have the Asp.Net Core MVC Jquery version 12.3.0 I am trying to add a custom widget.
After doing necessary config I ran npm run create-bundles. After that, when loading the dashbaord I get these errors:
TypeError: Cannot read properties of undefined (reading 'defaults') pointing to: app-layout-libs.min.js /* Set the defaults for DataTables initialisation */ $.extend( true, DataTable.defaults, { dom: "<'row'<'col-xs-12 col-md-6'l><'col-xs-12 col-md-6'f>>" + "<'row'<'col-xs-12'tr>>" + "<'row'<'col-xs-12 col-md-5'i><'col-xs-12 col-md-7'p>>", renderer: 'bootstrap' } );
Hello,
I am having issues with the Localization. Currently users are not able to change their language. The flag remains french and the language stays french However, I am able to set the default language as admin. But even then le flag remains French however it switches to the new default language
I recently am coming accross these errors on the logging page ASP.NET CORE MVC & jQuery .NET 7.0 v12.3.1
Uncaught TypeError: abp.services is undefined <anonymous> https://localhost:44302/view-resources/Areas/App/Views/_Bundles/common-scripts.min.js?v=yzE80BD7kYAKvvWECWXiQgYKMuzJ-MHGMHL61D8d018:6 <anonymous> https://localhost:44302/view-resources/Areas/App/Views/_Bundles/common-scripts.min.js?v=yzE80BD7kYAKvvWECWXiQgYKMuzJ-MHGMHL61D8d018:9
Uncaught TypeError: app.ModalManager is not a constructor <anonymous> https://localhost:44302/view-resources/Views/Shared/Components/TenantChange/Default.js:2 <anonymous> https://localhost:44302/view-resources/Views/Shared/Components/TenantChange/Default.js:53
Uncaught TypeError: app.consts is undefined trySubmitForm https://localhost:44302/view-resources/Views/Account/Login.min.js?v=zCuu3L2lfWMUL0d4XPVBlEXYW7zIL7xMWeH9x0gdpQI:60 setCaptchaToken https://localhost:44302/view-resources/Views/Account/Login.min.js?v=zCuu3L2lfWMUL0d4XPVBlEXYW7zIL7xMWeH9x0gdpQI:46 trySubmitForm https://localhost:44302/view-resources/Views/Account/Login.min.js?v=zCuu3L2lfWMUL0d4XPVBlEXYW7zIL7xMWeH9x0gdpQI:55 handleLogin https://localhost:44302/view-resources/Views/Account/Login.min.js?v=zCuu3L2lfWMUL0d4XPVBlEXYW7zIL7xMWeH9x0gdpQI:7 dispatch https://localhost:44302/view-resources/Areas/App/Views/_Bundles/account-layout-libs.min.js?v=HZIXkg3Jlrqq8HxqxbGYXs75uhUxOpU_nHhuj8kCEBU:5628 handle https://localhost:44302/view-resources/Areas/App/Views/_Bundles/account-layout-libs.min.js?v=HZIXkg3Jlrqq8HxqxbGYXs75uhUxOpU_nHhuj8kCEBU:5432
I am getting this on all my aspnet zero projects
Hello, I am trying to use the default ABP background worker.
In my controller i have call my job; await _updateSalesDomaineService.TriggerStatsVentesMoisJob((int)PeriodeId);
Here is my Job:
using Abp.BackgroundJobs;
using Abp.Domain.Services;
using System.Threading.Tasks;
namespace DocuPro.DomainServices
{
public class UpdateSalesDomaineService : DomainService, IDomainService
{
private readonly IBackgroundJobManager _backgroundJobManager;
public UpdateSalesDomaineService(IBackgroundJobManager backgroundJobManager)
{
_backgroundJobManager = backgroundJobManager;
}
public async Task TriggerStatsVentesMoisJob(int periodeId)
{
Logger.Warn("UpdateStatsVentesMoisJob. Job STARTED");
await _backgroundJobManager.EnqueueAsync<UpdateStatsVentesMoisJob, StatsVentesMoisJobArgs>(new StatsVentesMoisJobArgs
{
PeriodeId = periodeId
});
Logger.Warn("UpdateStatsVentesMoisJob. Job ENDED");
}
// Other domain service methods...
}
public class StatsVentesMoisJobArgs
{
public int PeriodeId { get; set; }
}
}
And here is my method:
using Abp.BackgroundJobs;
using Abp.Dependency;
using Abp.Domain.Repositories;
using Abp.Domain.Uow;
using DocuPro.CommonBases;
using DocuPro.SortiesLocalesBases;
using System;
using System.Threading.Tasks;
namespace DocuPro.DomainServices
{
public class UpdateStatsVentesMoisJob : BackgroundJob<StatsVentesMoisJobArgs>, ITransientDependency
{
private readonly ISortiesLocalesesAppService _sortiesLocalesesAppService;
private readonly IRepository<Periode> _periodeRepository;
public UpdateStatsVentesMoisJob(
ISortiesLocalesesAppService sortiesLocalesesAppService,
IRepository<Periode> periodeRepository)
{
_sortiesLocalesesAppService = sortiesLocalesesAppService;
_periodeRepository = periodeRepository;
}
[UnitOfWork]
public override void Execute(StatsVentesMoisJobArgs args)
{
Logger.Warn("UpdateStatsVentesMoisJob. Job STARTED.");
var periodeId = args.PeriodeId;
if (periodeId <= 0)
{
Logger.Warn("Invalid PeriodeId provided to UpdateStatsVentesMoisJob. Job aborted.");
return;
}
try
{
_sortiesLocalesesAppService.UpdateStatsVentesMois(periodeId);
}
catch (Exception ex)
{
Logger.Error($"An error occurred while executing UpdateStatsVentesMoisJob for PeriodeId {periodeId}.", ex);
}
}
}
}
Here is my UpdateStatsVentesMois method:
public async Task UpdateStatsVentesMois(int periodeId)
{
Logger.Warn("UpdateStatsVentesMoisJob. Job STARTED. UpdateStatsVentesMois");
var statsList = await GetStatsVentesMois(periodeId); // Assuming this returns a list of VentesMoisStatsDto
await _statsVentesRepository.DeleteAllByPeriodeId(periodeId);
Logger.Warn($"UpdateStatsVentesMoisJob. NOMBRE MOIS. DELETED ");
foreach (var stat in statsList)
{
// Insert new record
var newStat = new CreateOrEditStatsVenteDto
{
Pays = stat.Pays,
Grossiste = stat.Grossiste,
GrossisteId= stat.GrossisteId,
ProduitLibelle = stat.ProduitLibelle,
Ventes = (int)stat.Ventes,
VentesMois = (int)stat.VentesMois,
Poids = stat.Poids,
VentesMoisMMinus1 = (int)stat.VentesMoisMMinus1,
TauxEvol = stat.TauxEvol,
BudgetMois = stat.BudgetMois,
TauxReal = stat.TauxReal,
BudgetAnnee = stat.BudgetAnnee,
TauxRealCumulBudget = stat.TauxRealCumulBudget,
AvgVentesLast3Months = (int)stat.AvgVentesLast3Months,
AvgVentesLast6Months = (int)stat.AvgVentesLast6Months,
AvgVentesLast12Months = (int)stat.AvgVentesLast12Months,
CAMois = (int)stat.CAMois,
CAMoisMMinus1 = (int)stat.CAMoisMMinus1,
TauxEvolCA = stat.TauxEvolCA,
BudgetMoisCA = (int)stat.BudgetMoisCA,
TauxRealCA = stat.TauxRealCA,
BudgetAnneeCA = (int)stat.BudgetAnneeCA,
CumulCA = (int)stat.CumulCA,
CumulBudgetCA = (int)stat.CumulBudgetCA,
TauxRealCumulBudgetCA = stat.TauxRealCumulBudgetCA,
PGHT = stat.PGHT,
SortieLocalesId = stat.SortieLocalesId, // Assuming this is the correct property name
PeriodeId = stat.PeriodeId,
};
await _statsVentesRepository.CreateOrEdit(newStat);
}
Logger.Warn($"UpdateStatsVentesMoisJob. FIN ");
}
On this : var statsList = await GetStatsVentesMois(periodeId);
I get an error :
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> Microsoft.Data.SqlClient.SqlException (0x80131904): The transaction operation cannot be performed because there are pending requests working on this transaction.
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
I have set MultipleActiveResultSets=true;
I am sending you my application, database and Log by email
Hello, I am using asp.net core mvc. I have multitenancy enabled but for now I have only one tenant with many users. on login page I want to set by default tenant to the current tenant which is not default.
How do i achieve that?
Hello, I configured Hangfire and I have this job running: RecurringJob.AddOrUpdate<IMyDomainServices>( service => service.UpdateVentesAsync(), "*/2 * * * *"); // Cron expression for every 2 minutes
I have this in my module: public override void PreInitialize() { //Adding authorization providers Configuration.Authorization.Providers.Add<AppAuthorizationProvider>();
//Adding custom AutoMapper configuration
Configuration.Modules.AbpAutoMapper().Configurators.Add(CustomDtoMapper.CreateMappings);
IocManager.Register<IMyDomainServices, MyDomainServices>();
}
Here is my interface: namespace DocuPro.DomainServices { public interface IMyDomainServices: IDomainService { Task UpdateVentesAsync(); } }
And this is my Service:
using Abp.Authorization; using Abp.Domain.Repositories; using Abp.Domain.Uow; using Abp.Runtime.Session; using DocuPro; using DocuPro.Authorization.Users; using DocuPro.CommonBases; using DocuPro.DomainServices; using DocuPro.SortiesLocalesBases; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using System; using System.Linq; using System.Threading.Tasks;
public class MyDomainServices : DocuProAppServiceBase, IMyDomainServices { private readonly IUnitOfWorkManager _unitOfWorkManager; private readonly IServiceScopeFactory _serviceScopeFactory;
private readonly IRepository<StatsVente> _statsVenteRepository;
private readonly IRepository<SortiesLocales> _sortiesLocalesRepository;
public MyDomainServices(
IUnitOfWorkManager unitOfWorkManager,
IServiceScopeFactory serviceScopeFactory,
IRepository<StatsVente> statsVenteRepository,
IRepository<SortiesLocales> sortiesLocalesRepository)
{
_unitOfWorkManager = unitOfWorkManager;
_serviceScopeFactory = serviceScopeFactory;
_statsVenteRepository = statsVenteRepository;
_sortiesLocalesRepository = sortiesLocalesRepository;
}
[AbpAllowAnonymous]
public async Task UpdateVentesAsync()
{
using (var scope = _serviceScopeFactory.CreateScope())
{
var userManager = scope.ServiceProvider.GetRequiredService<UserManager>();
var abpSession = scope.ServiceProvider.GetRequiredService<IAbpSession>();
var unitOfWorkManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>();
var sortiesLocalesesAppService = scope.ServiceProvider.GetRequiredService<ISortiesLocalesesAppService>();
var periodesAppService = scope.ServiceProvider.GetRequiredService<IPeriodesAppService>();
var adminUser = await userManager.FindByNameAsync("admin");
if (adminUser == null)
{
throw new InvalidOperationException("Admin user not found.");
}
using (var unitOfWork = unitOfWorkManager.Begin())
{
using (abpSession.Use(adminUser.TenantId, adminUser.Id))
{
var periodeId = await GetLatestPeriodeId();
await sortiesLocalesesAppService.UpdateStatsVentesMois(periodeId);
}
await unitOfWork.CompleteAsync();
}
}
}
public async Task<int> GetLatestPeriodeId()
{
var usedPeriodeIds = await _statsVenteRepository
.GetAll()
.Select(sv => sv.PeriodeId)
.Distinct()
.ToListAsync();
var latestPeriodeId = await _sortiesLocalesRepository
.GetAll()
.Where(p => !usedPeriodeIds.Contains(p.PeriodeId)) // Exclude PeriodeIds that are in _statsVenteRepository
.OrderByDescending(p => p.PeriodeId) // Order by PeriodeId descending
.Select(p => p.PeriodeId)
.FirstOrDefaultAsync(); // Get the first (latest) PeriodeId that is not used
return latestPeriodeId; // This will be the latest PeriodeId not used in _statsVenteRepository
}
}
My problem is that any database call returns 0 rows even though there are data there.
As you can see I struggled with authorization, unitofwork, etc. to make it work.
What is the best way to do this?
Hello,
I created this:
public class Visa : FullAuditedEntity, IMayHaveTenant { public int? TenantId { get; set; }
[Required]
public virtual string Numero { get; set; }
public virtual DateTime DateObtention { get; set; }
public virtual DateTime DateValidite { get; set; }
//File
public virtual Guid? Fichier { get; set; } //File, (BinaryObjectId)
public virtual int ProduitId { get; set; }
[ForeignKey("ProduitId")]
public Produit ProduitFk { get; set; }
public virtual int PaysId { get; set; }
[ForeignKey("PaysId")]
public Pays PaysFk { get; set; }
} from powertools and it created this view:
<div class="@(await GetContainerClass())"> <div class="card card-custom gutter-b"> <div class="card-body"> <div class="form"> <div class="row align-items-center mb-4"> <div class="col-xl-12">
<div class="my-3">
<div class="input-group">
<input type="text" id="VisasTableFilter" class="form-control reload-on-change" placeholder='@L("SearchWithThreeDot")' value="@Model.FilterText">
<button id="GetVisasButton" class="btn btn-primary" type="submit"><i class="flaticon-search-1"></i></button>
</div>
</div>
</div>
</div>
</div>
<div id="AdvacedAuditFiltersArea" style="display: none" class="row mb-4">
<div class="col-md-12">
</div>
<div class="col-md-3">
<div class="my-3">
<label class="form-label" for="NumeroFilterId">@L("Numero")</label>
<input type="text" class="form-control reload-on-keyup" name="numeroFilter" id="NumeroFilterId">
</div>
</div>
<div class="col-md-3">
<div class="my-3">
<label class="form-label" for="MinDateObtentionFilterId">@L("DateObtentionRange")</label>
<div class="input-group">
<input class="form-control m-input date-picker startDate" type="text" placeholder="@L(" MinValue")" id="MinDateObtentionFilterId">
<span style="line-height: 40px;padding: 0 15px 0 15px;"> — </span>
<input class="form-control m-input date-picker endDate" type="text" placeholder="@L(" MaxValue")" id="MaxDateObtentionFilterId">
</div>
</div>
</div>
<div class="col-md-3">
<div class="my-3">
<label class="form-label" for="MinDateValiditeFilterId">@L("DateValiditeRange")</label>
<div class="input-group">
<input class="form-control m-input date-picker startDate" type="text" placeholder="@L(" MinValue")" id="MinDateValiditeFilterId">
<span style="line-height: 40px;padding: 0 15px 0 15px;"> — </span>
<input class="form-control m-input date-picker endDate" type="text" placeholder="@L(" MaxValue")" id="MaxDateValiditeFilterId">
</div>
</div>
</div>
<div class="col-md-3">
<div class="my-3">
<label class="form-label" for="ProduitLibelleFilterId">(@L("Produit")) @L("Libelle")</label>
<input type="text" class="form-control" name="produitLibelleFilter" id="ProduitLibelleFilterId">
</div>
</div>
<div class="col-md-3">
<div class="my-3">
<label class="form-label" for="PaysLibelleFilterId">(@L("Pays")) @L("Libelle")</label>
<input type="text" class="form-control" name="paysLibelleFilter" id="PaysLibelleFilterId">
</div>
</div>
<div class="col-md-12 mt-5">
<button class="btn btn-secondary btn-sm" id="btn-reset-filters">Reset</button>
</div>
</div>
<div class="row my-4">
<div class="col-xl-12">
<span id="ShowAdvancedFiltersSpan" class="text-muted clickable-item"><i class="fa fa-angle-down"></i> @L("ShowAdvancedFilters")</span>
<span id="HideAdvancedFiltersSpan" class="text-muted clickable-item" style="display: none"><i class="fa fa-angle-up"></i> @L("HideAdvancedFilters")</span>
</div>
</div>
<div class="row align-items-center">
<table id="VisasTable" class="table align-middle table-row-dashed fs-6 gy-5 dataTable no-footer">
<thead>
<tr>
<th></th>
<th>@L("Actions")</th>
<th>@L("Numero")</th>
<th>@L("DateObtention")</th>
<th>@L("DateValidite")</th>
<th>@L("Fichier")</th>
<th>@L("ProduitLibelle")</th>
<th>@L("PaysLibelle")</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
in my js i have
listAction: { ajaxFunction: _visasService.getAll, inputFilter: function () { return { //filter: $('#VisasTableFilter').val(), //numeroFilter: $('#NumeroFilterId').val(), filter: $('#VisasTableFilter').val(), numeroFilter: $('#NumeroFilterId').val() ? '' + $('#NumeroFilterId').val() + '' : '',
minDateObtentionFilter: getDateFilter($('#MinDateObtentionFilterId')),
maxDateObtentionFilter: getMaxDateFilter($('#MaxDateObtentionFilterId')),
minDateValiditeFilter: getDateFilter($('#MinDateValiditeFilterId')),
maxDateValiditeFilter: getMaxDateFilter($('#MaxDateValiditeFilterId')),
fichierFilter: $('#FichierFilterId').val(),
//produitLibelleFilter: $('#ProduitLibelleFilterId').val(),
//paysLibelleFilter: $('#PaysLibelleFilterId').val(),
produitLibelleFilter: $('#ProduitLibelleFilterId').val() ? '*' + $('#ProduitLibelleFilterId').val() + '*' : '',
paysLibelleFilter: $('#PaysLibelleFilterId').val() ? '*' + $('#PaysLibelleFilterId').val() + '*' : '',
};
}, },
and in my service I have
var filteredVisas = _visaRepository.GetAll()
.Include(e => e.ProduitFk)
.Include(e => e.PaysFk)
.WhereIf(!string.IsNullOrWhiteSpace(input.Filter), e => false || e.Numero.Contains(input.Filter))
.WhereIf(!string.IsNullOrWhiteSpace(input.NumeroFilter), e => e.Numero.Contains(input.NumeroFilter))
.WhereIf(input.MinDateObtentionFilter != null, e => e.DateObtention >= input.MinDateObtentionFilter)
.WhereIf(input.MaxDateObtentionFilter != null, e => e.DateObtention <= input.MaxDateObtentionFilter)
.WhereIf(input.MinDateValiditeFilter != null, e => e.DateValidite >= input.MinDateValiditeFilter)
.WhereIf(input.MaxDateValiditeFilter != null, e => e.DateValidite <= input.MaxDateValiditeFilter)
.WhereIf(!string.IsNullOrWhiteSpace(input.ProduitLibelleFilter), e => e.ProduitFk != null && e.ProduitFk.Libelle.ToLower().Contains(input.ProduitLibelleFilter.ToLower()))
.WhereIf(!string.IsNullOrWhiteSpace(input.PaysLibelleFilter), e => e.PaysFk != null && e.PaysFk.Libelle.Contains(input.PaysLibelleFilter));
When I filter Numero, I am able to get correct data but not with ProduitLibelle and PaysLibelle.
Please help
Hello,
I used this https://aspnetboilerplate.com/Pages/Documents/Hangfire-Integration Hi get this error on Hangfire dashboard
An exception occurred during performance of the job. Abp.Authorization.AbpAuthorizationException (desktop-5bai7bg:34012)
L'utilisateur courant ne peut pas s'authentifier à l'application!
Abp.Authorization.AbpAuthorizationException: L'utilisateur courant ne peut pas s'authentifier à l'application! at Abp.Authorization.AuthorizationHelper.AuthorizeAsync(IEnumerable`1 authorizeAttributes) at Abp.Authorization.AuthorizationHelper.CheckPermissionsAsync(MethodInfo methodInfo, Type type) at Abp.Authorization.AuthorizationHelper.AuthorizeAsync(MethodInfo methodInfo, Type type) at Abp.Authorization.AuthorizationInterceptor.InternalInterceptAsynchronous(IInvocation invocation) at SendNotificationJob.SendTestNotification() in xxxxl\src\DocuPro.Application\HelperControllers\NotificationBase.cs:line 61 at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
Here is my method:
using Abp.Configuration.Startup; using Abp.Domain.Repositories; using Abp.Runtime.Session; using Abp; using DocuPro.Authorization.Users; using DocuPro.Notifications; using System.Threading.Tasks; using System.Linq; using Abp.Domain.Uow; using System;
public class SendNotificationJob { private readonly INotificationAppService _notificationAppService; private readonly IAbpSession _abpSession; private readonly IRepository<User, long> _userRepository; private readonly UserManager _userManager; private readonly IMultiTenancyConfig _multiTenancyConfig; private readonly IUnitOfWorkManager _unitOfWorkManager; public SendNotificationJob( INotificationAppService notificationAppService, IAbpSession abpSession, IRepository<User, long> userRepository, UserManager userManager, IMultiTenancyConfig multiTenancyConfig, IUnitOfWorkManager unitOfWorkManager) { _notificationAppService = notificationAppService; _abpSession = abpSession; _userRepository = userRepository; _userManager = userManager; _multiTenancyConfig = multiTenancyConfig; _unitOfWorkManager = unitOfWorkManager; }
public async Task SendNotifications()
{
using (var unitOfWork = _unitOfWorkManager.Begin())
{
try
{
var users = _userRepository.GetAll().ToList();
foreach (var user in users)
{
var userIdentifier = new UserIdentifier(1, user.Id);
var message = "Your New Hangfire notification message"; // Replace with your message
await _notificationAppService.SendNotificationUsingHangfireAsync(userIdentifier, message);
}
// Commit the unit of work if everything is successful
unitOfWork.Complete();
}
catch (Exception ex)
{
// Handle exceptions or roll back the unit of work if necessary
unitOfWork.Dispose();
throw;
}
}
}
}
Hi there, how do I seed data like countries?
This is a feature request if it applies: Actually Power Tools allows you to:
My question is it possible to automate just:
for an existing model using Power Tool?