Base solution for your next web application

Activities of "alliance225"

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, Action1 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

Question

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&lt;IMyDomainServices, MyDomainServices&gt;();

}

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&lt;StatsVente&gt; _statsVenteRepository;
private readonly IRepository&lt;SortiesLocales&gt; _sortiesLocalesRepository;

public MyDomainServices(
    IUnitOfWorkManager unitOfWorkManager,
    IServiceScopeFactory serviceScopeFactory,
           IRepository&lt;StatsVente&gt; statsVenteRepository,
    IRepository&lt;SortiesLocales&gt; sortiesLocalesRepository)
{
    _unitOfWorkManager = unitOfWorkManager;
    _serviceScopeFactory = serviceScopeFactory;
          _statsVenteRepository = statsVenteRepository;
    _sortiesLocalesRepository = sortiesLocalesRepository;
}

[AbpAllowAnonymous]
public async Task UpdateVentesAsync()
{
    using (var scope = _serviceScopeFactory.CreateScope())
    {
        var userManager = scope.ServiceProvider.GetRequiredService&lt;UserManager&gt;();
        var abpSession = scope.ServiceProvider.GetRequiredService&lt;IAbpSession&gt;();
        var unitOfWorkManager = scope.ServiceProvider.GetRequiredService&lt;IUnitOfWorkManager&gt;();
        var sortiesLocalesesAppService = scope.ServiceProvider.GetRequiredService&lt;ISortiesLocalesesAppService&gt;();
        var periodesAppService = scope.ServiceProvider.GetRequiredService&lt;IPeriodesAppService&gt;();

        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&lt;int&gt; 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">

                    &lt;div class=&quot;my-3&quot;&gt;
                        &lt;div class=&quot;input-group&quot;&gt;
                            &lt;input type=&quot;text&quot; id=&quot;VisasTableFilter&quot; class=&quot;form-control reload-on-change&quot; placeholder=&#39;@L(&quot;SearchWithThreeDot&quot;)&#39; value=&quot;@Model.FilterText&quot;&gt;
                            &lt;button id=&quot;GetVisasButton&quot; class=&quot;btn btn-primary&quot; type=&quot;submit&quot;&gt;&lt;i class=&quot;flaticon-search-1&quot;&gt;&lt;/i&gt;&lt;/button&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;

                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
        &lt;div id=&quot;AdvacedAuditFiltersArea&quot; style=&quot;display: none&quot; class=&quot;row mb-4&quot;&gt;
            &lt;div class=&quot;col-md-12&quot;&gt;

            &lt;/div&gt;

            &lt;div class=&quot;col-md-3&quot;&gt;
                &lt;div class=&quot;my-3&quot;&gt;
                    &lt;label class=&quot;form-label&quot; for=&quot;NumeroFilterId&quot;&gt;@L("Numero")&lt;/label&gt;
                    &lt;input type=&quot;text&quot; class=&quot;form-control reload-on-keyup&quot; name=&quot;numeroFilter&quot; id=&quot;NumeroFilterId&quot;&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class=&quot;col-md-3&quot;&gt;
                &lt;div class=&quot;my-3&quot;&gt;
                    &lt;label class=&quot;form-label&quot; for=&quot;MinDateObtentionFilterId&quot;&gt;@L("DateObtentionRange")&lt;/label&gt;
                    &lt;div class=&quot;input-group&quot;&gt;
                        &lt;input class=&quot;form-control m-input date-picker startDate&quot; type=&quot;text&quot; placeholder=&quot;@L(&quot; MinValue&quot;)&quot; id=&quot;MinDateObtentionFilterId&quot;&gt;
                        &lt;span style=&quot;line-height: 40px;padding: 0 15px 0 15px;&quot;&gt; &mdash; &lt;/span&gt;
                        &lt;input class=&quot;form-control m-input date-picker endDate&quot; type=&quot;text&quot; placeholder=&quot;@L(&quot; MaxValue&quot;)&quot; id=&quot;MaxDateObtentionFilterId&quot;&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class=&quot;col-md-3&quot;&gt;
                &lt;div class=&quot;my-3&quot;&gt;
                    &lt;label class=&quot;form-label&quot; for=&quot;MinDateValiditeFilterId&quot;&gt;@L("DateValiditeRange")&lt;/label&gt;
                    &lt;div class=&quot;input-group&quot;&gt;
                        &lt;input class=&quot;form-control m-input date-picker startDate&quot; type=&quot;text&quot; placeholder=&quot;@L(&quot; MinValue&quot;)&quot; id=&quot;MinDateValiditeFilterId&quot;&gt;
                        &lt;span style=&quot;line-height: 40px;padding: 0 15px 0 15px;&quot;&gt; &mdash; &lt;/span&gt;
                        &lt;input class=&quot;form-control m-input date-picker endDate&quot; type=&quot;text&quot; placeholder=&quot;@L(&quot; MaxValue&quot;)&quot; id=&quot;MaxDateValiditeFilterId&quot;&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;

            &lt;div class=&quot;col-md-3&quot;&gt;
                &lt;div class=&quot;my-3&quot;&gt;
                    &lt;label class=&quot;form-label&quot; for=&quot;ProduitLibelleFilterId&quot;&gt;(@L("Produit")) @L("Libelle")&lt;/label&gt;
                    &lt;input type=&quot;text&quot; class=&quot;form-control&quot; name=&quot;produitLibelleFilter&quot; id=&quot;ProduitLibelleFilterId&quot;&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class=&quot;col-md-3&quot;&gt;
                &lt;div class=&quot;my-3&quot;&gt;
                    &lt;label class=&quot;form-label&quot; for=&quot;PaysLibelleFilterId&quot;&gt;(@L("Pays")) @L("Libelle")&lt;/label&gt;
                    &lt;input type=&quot;text&quot; class=&quot;form-control&quot; name=&quot;paysLibelleFilter&quot; id=&quot;PaysLibelleFilterId&quot;&gt;
                &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class=&quot;col-md-12 mt-5&quot;&gt;
                &lt;button class=&quot;btn btn-secondary btn-sm&quot; id=&quot;btn-reset-filters&quot;&gt;Reset&lt;/button&gt;
            &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;row my-4&quot;&gt;
            &lt;div class=&quot;col-xl-12&quot;&gt;
                &lt;span id=&quot;ShowAdvancedFiltersSpan&quot; class=&quot;text-muted clickable-item&quot;&gt;&lt;i class=&quot;fa fa-angle-down&quot;&gt;&lt;/i&gt; @L("ShowAdvancedFilters")&lt;/span&gt;
                &lt;span id=&quot;HideAdvancedFiltersSpan&quot; class=&quot;text-muted clickable-item&quot; style=&quot;display: none&quot;&gt;&lt;i class=&quot;fa fa-angle-up&quot;&gt;&lt;/i&gt; @L("HideAdvancedFilters")&lt;/span&gt;
            &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;row align-items-center&quot;&gt;
            &lt;table id=&quot;VisasTable&quot; class=&quot;table align-middle table-row-dashed fs-6 gy-5 dataTable no-footer&quot;&gt;
                &lt;thead&gt;
                    &lt;tr&gt;
                        &lt;th&gt;&lt;/th&gt;

                        &lt;th&gt;@L("Actions")&lt;/th&gt;
                        &lt;th&gt;@L("Numero")&lt;/th&gt;
                        &lt;th&gt;@L("DateObtention")&lt;/th&gt;
                        &lt;th&gt;@L("DateValidite")&lt;/th&gt;
                        &lt;th&gt;@L("Fichier")&lt;/th&gt;
                        &lt;th&gt;@L("ProduitLibelle")&lt;/th&gt;
                        &lt;th&gt;@L("PaysLibelle")&lt;/th&gt;
                    &lt;/tr&gt;
                &lt;/thead&gt;
            &lt;/table&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

</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 &lt;= input.MaxDateObtentionFilter)
                    .WhereIf(input.MinDateValiditeFilter != null, e =&gt; e.DateValidite >= input.MinDateValiditeFilter)
                    .WhereIf(input.MaxDateValiditeFilter != null, e => e.DateValidite &lt;= input.MaxDateValiditeFilter)
                    .WhereIf(!string.IsNullOrWhiteSpace(input.ProduitLibelleFilter), e =&gt; 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

Question

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;
        }
    }
  
}

}

Question

Hi there, how do I seed data like countries?

This is a feature request if it applies: Actually Power Tools allows you to:

  • Create your models or entities
  • Create DTOs, Service, etc.
  • Create your controller
  • Create your views
  • Create the permissions
  • Create entries in your localization structure at least for en
  • Create an entry in the menu
  • etc.

My question is it possible to automate just:

  • Create a controller
  • Create the view
  • Create the permissions
  • Create entries in your localization structure at least for en
  • Create an entry in the menu

for an existing model using Power Tool?

Hi, I have these entities: namespace DocuPro.DocumentBase { [Table("DocumentVersions")] [Audited] public class DocumentVersion : Entity, IMayHaveTenant { public int? TenantId { get; set; }

    public virtual int? DocumentId { get; set; }

    [ForeignKey("DocumentId")]
    public Document DocumentFk { get; set; }
    public virtual ICollection&lt;DocumentVersionFile&gt; DocumentVersionFiles { get; set; }


}

} namespace DocuPro.DocumentBase { [Table("DocumentVersionFiles")] [Audited] public class DocumentVersionFile : Entity, IMayHaveTenant { public int? TenantId { get; set; }

    public virtual string OCR { get; set; }

    public virtual string FileName { get; set; }
    
    
    public virtual int? DocumentVersionId { get; set; }

    [ForeignKey("DocumentVersionId")]
    public DocumentVersion DocumentVersionFk { get; set; }
    

    
    public virtual int? FileTypeId { get; set; }

    [ForeignKey("FileTypeId")]
    public FileType FileTypeFk { get; set; }

}

} namespace DocuPro.DocumentBase { [Table("FileTypes")] public class FileType : Entity {

    [Required]
    public virtual string Extension { get; set; }

}

}

I have this DTO: namespace DocuPro.DocumentBase.Dtos { public class GetDocumentVersionForViewDto { public DocumentVersionDto DocumentVersion { get; set; }

    public string DocumentLibelle { get; set; }

}

}

In my service I have this method:

public virtual async Task<List<GetDocumentVersionForViewDto>> GetAllDocumentVersion(int documentId) { // Fetching all DocumentVersions (and associated DocumentVersionFiles) for a specific documentId var documentVersions = await _documentVersionRepository.GetAllIncluding(dv => dv.DocumentVersionFiles) .Where(dv => dv.DocumentId == documentId) .ToListAsync();

  // Mapping to DTO
  var documentVersionDtos = ObjectMapper.Map&lt;List&lt;GetDocumentVersionForViewDto&gt;>(documentVersions);

  return documentVersionDtos;

}

I get this error: XHRGET https://localhost:44302/App/DocumentTabs/TabViewInfomations?documentId=8 [HTTP/2 500 Internal Server Error 250ms]

AutoMapper.AutoMapperMappingException: Error mapping types.

Mapping types:

List1 -> List1

System.Collections.Generic.List1[[DocuPro.DocumentBase.DocumentVersion, DocuPro.Core, Version=12.3.0.0, Culture=neutral, PublicKeyToken=null]] -> System.Collections.Generic.List1[[DocuPro.DocumentBase.Dtos.GetDocumentVersionForViewDto, DocuPro.Application.Shared, Version=12.3.0.0, Culture=neutral, PublicKeyToken=null]]

---> AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping.

Mapping types: DocumentVersion -> GetDocumentVersionForViewDto DocuPro.DocumentBase.DocumentVersion -> DocuPro.DocumentBase.Dtos.GetDocumentVersionForViewDto at lambda_method3201(Closure, DocumentVersion, GetDocumentVersionForViewDto, ResolutionContext) at lambda_method3200(Closure, Object, List`1, ResolutionContext)

--- End of inner exception stack trace --- at lambda_method3200(Closure, Object, List1, ResolutionContext) at Abp.AutoMapper.AutoMapperObjectMapper.Map[TDestination](Object source) at DocuPro.DocumentBase.DocumentVersionsAppService.GetAllDocumentVersion(Int32 documentId) in C:\Users\hp\OneDrive\APPS\DocuProV10\src\DocuPro.Application\DocumentBase\DocumentVersionsAppService.cs:line 43 at Abp.Authorization.AuthorizationInterceptor.InternalInterceptAsynchronous[TResult](IInvocation invocation) at DocuPro.Web.Areas.App.Controllers.Documents.DocumentTabsController.TabViewInfomations(Nullable1 state, Int32 documentId) in C:\Users\hp\OneDrive\APPS\DocuProV10\src\DocuPro.Web.Mvc\Areas\App\Controllers\Documents\DocumentTabsController.cs:line 84 at lambda_method3030(Closure, Object)

Showing 1 to 10 of 13 entries