Base solution for your next web application

Activities of "soulmate"

Thank, that worked!

Hi,

I am using hangfire for jobs. In my dev environment I can open /dashboard to access my hangfire dashboard. However, in production my admin user does not have access to that page. According to <a class="postlink" href="http://docs.hangfire.io/en/latest/configuration/using-dashboard.html">http://docs.hangfire.io/en/latest/confi ... board.html</a> it is possible to integrate a custom auth system with hangfire. However, I have no clue how to combine the ABP Framework user management system with hangfire. Do you have any idea?

Thanks. That solved my problem

Thanks, this fixed my problem

Hey Hikalkan,

since Patrick also has this problem: Is this maybe a general problem with automatic generated mapping entities? Do you have any idea how to track this one?

Thank you!

Hello,

as I learnt I have to register jobs in the post init event:

public override void PostInitialize()
        {
            base.PostInitialize();
            
            var workManager = IocManager.Resolve<IBackgroundWorkerManager>();
            workManager.Add(IocManager.Resolve<MakeInactiveUsersPassiveWorker>());
        }

However, would it be possible to automatic register all jobs that implement an specific interface (like you do for WebApi Service?). I think that would further increase productivity.

Thank you

Hello,

I have following code:

public class OfferFileController : AbpController
    {

        private readonly ILogger _logger;
        private readonly IMapper _mapper;
        private readonly IOfferFileService _offerFileService;
        private readonly IOfferService _offerService;
        private readonly UserManager _userManager;

        
        public OfferFileController(IOfferService offerService, UserManager userManager,
            IOfferFileService offerFileService,
            IMapper mapper,
            ILogger logger)
        {
            _offerService = offerService;
            _offerFileService = offerFileService;
            _userManager = userManager;
            _mapper = mapper;
            _logger = logger;
            
        }

        public ActionResult UploadFiles(IEnumerable<HttpPostedFileBase> files, int offerId)
        {
            // The Name of the Upload component is "files"
            if (files != null)
            {
                foreach (var file in files)
                {
                    var offerFile = new OfferFile();
                    var fileName = Path.GetFileName(file.FileName);

                    //Check if file exist
                    offerFile = _offerFileService.GetByNameAndOfferId(fileName, offerId) ?? new OfferFile();

                    offerFile.Name = fileName;
                    offerFile.FileType = file.ContentType;
                    offerFile.OfferId = offerId;
                    using (var binaryReader = new BinaryReader(file.InputStream))
                    {
                        offerFile.File = binaryReader.ReadBytes(file.ContentLength);
                    }

                    //Save
                    _offerFileService.Save(offerFile);

                }
            }

            // Return an empty string to signify success
            return Content("");
        }

When I pass a file I receive

Object reference not set to an instance of an object. 
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

 Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 


 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 



[NullReferenceException: Object reference not set to an instance of an object.]
   Abp.Web.Mvc.Controllers.AbpController.ConvertArgumentsToJson(IDictionary`2 arguments) in D:\Halil\GitHub\aspnetboilerplate\src\Abp.Web.Mvc\Web\Mvc\Controllers\AbpController.cs:515
   Abp.Web.Mvc.Controllers.AbpController.HandleAuditingBeforeAction(ActionExecutingContext filterContext) in D:\Halil\GitHub\aspnetboilerplate\src\Abp.Web.Mvc\Web\Mvc\Controllers\AbpController.cs:428
   Abp.Web.Mvc.Controllers.AbpController.OnActionExecuting(ActionExecutingContext filterContext) in D:\Halil\GitHub\aspnetboilerplate\src\Abp.Web.Mvc\Web\Mvc\Controllers\AbpController.cs:299

However, if I replace the AbpController with the default Controller (meaning public class OfferFileController : Controller) it works. Do you have any idea why this happens?

Hi, Yes, in controller the countries are added. This was just a test. I rewrite the test code, in following scenario a country with id 2 is loaded. However, the mapping is still not saved:

public async Task SaveAsync(IProvider provider, bool saveChanges = true)
        {
            var entity = provider as Provider;

            if (entity == null)
                throw new ArgumentNullException(nameof(provider));


            //Clear existing entities
            entity.Countries= new List<Country>();


                var country = _countryRepository.Get(2);

                entity.Countries.Add(country);
        
            _providerRepository.InsertOrUpdate(entity);


            if (saveChanges)
            {
             

                await CurrentUnitOfWork.SaveChangesAsync();
            }
        }

I have a SaveAsync method that accepts the provider entity and adds countries here

public async Task SaveAsync(Provider provider)
        {
            var entity = provider;


            var countriesToAdd = provider.Countries.ToList();

            //Clear existing entities
            entity.Countries.Clear();


            foreach (var countryToAdd in countriesToAdd)
            {
                var country = _countryRepository.Get(countryToAdd.Id);

                entity.Countries.Add(country);
            }
            _providerRepository.InsertOrUpdate(entity);


          
                await CurrentUnitOfWork.SaveChangesAsync();
         
        }

Hey, Thank you for your reply. I already had a working provider configuration:

using System.Data.Entity.ModelConfiguration;

namespace Entities
{
    public class ProviderConfiguration : EntityTypeConfiguration<Provider>
    {
        public ProviderConfiguration()
        {
      
    HasMany(c => c.Countries).WithMany(i => i.Providers)
    .Map(t => t.MapLeftKey("ProviderId")
        .MapRightKey("CountryId")
        .ToTable("Providers_Countries"));

         
        }
    }
}

However, I deleted the configuration to follow your sugesstions. The database structure looks good for me (see attachment). However, I still cant save entities :(

Showing 21 to 30 of 33 entries