Base solution for your next web application

Activities of "rferrari"

I am working on a single project, also if I created multiple copies of it in the past.

Now it works this way. First build, required access, ko; stop express server, buld again ok, no need for access.

Hi,

now I discovered that I do not need to restart Visual Studio. It sufficient to stop the local web server. Something dirty is around. When I publish the solution everything is ok, so it is in the local web chain. I can live with that currently... I will try to understand.

I cleaned the browser cache multiple times but no avail.

Regards

By the way, when I close and restart Visual Studio and build the solution the system do not even ask me to log in! I am already in.

Hi,

I was working well with ABP 9.6. When 9.7 came out I upgraded the libraries and I could not login into the application. So I downgraded to 9.6, reinstalling the correct version of all the other packages. Now at every build I cannot login and I have to close Visual Studio and open again.

I find the following in the log:

WARN  2016-07-05 09:04:35,230 [12   ] Abp.Logging.LogHelper                    - Abp.Authorization.AbpAuthorizationException: Current user did not login to the application!
   at Abp.Authorization.AuthorizeAttributeHelper.<AuthorizeAsync>d__13.MoveNext() in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Authorization\AuthorizeAttributeHelper.cs:line 29
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t)
   at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nito.AsyncEx.AsyncContext.Run(Func`1 action)
   at Abp.Authorization.AuthorizeAttributeHelper.Authorize(IEnumerable`1 authorizeAttributes) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Authorization\AuthorizeAttributeHelper.cs:line 45
   at Abp.Authorization.AuthorizeAttributeHelper.Authorize(IAbpAuthorizeAttribute authorizeAttribute) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Authorization\AuthorizeAttributeHelper.cs:line 50
   at Abp.Web.Mvc.Authorization.AbpMvcAuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) in D:\Halil\GitHub\aspnetboilerplate\src\Abp.Web.Mvc\Web\Mvc\Authorization\AbpMvcAuthorizeAttribute.cs:line 41
Abp.Authorization.AbpAuthorizationException: Current user did not login to the application!
   at Abp.Authorization.AuthorizeAttributeHelper.<AuthorizeAsync>d__13.MoveNext() in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Authorization\AuthorizeAttributeHelper.cs:line 29
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t)
   at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nito.AsyncEx.AsyncContext.Run(Func`1 action)
   at Abp.Authorization.AuthorizeAttributeHelper.Authorize(IEnumerable`1 authorizeAttributes) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Authorization\AuthorizeAttributeHelper.cs:line 45
   at Abp.Authorization.AuthorizeAttributeHelper.Authorize(IAbpAuthorizeAttribute authorizeAttribute) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Authorization\AuthorizeAttributeHelper.cs:line 50
   at Abp.Web.Mvc.Authorization.AbpMvcAuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) in D:\Halil\GitHub\aspnetboilerplate\src\Abp.Web.Mvc\Web\Mvc\Authorization\AbpMvcAuthorizeAttribute.cs:line 41

Can you give me a way out?

Thanks

To share what I did this is my app service now:

[AbpAuthorize(AppPermissions.Pages_Tenant_Partners_CreatePartner)]
        public async Task EditPartner(EditPartnerInput input)
        {
            var partner = input.MapTo<Partner>();
            var phones = input.Phones.MapTo<List<Phone>>();
            var phonesToDelete = input.DeletedPhones.MapTo<List<Phone>>();
            var phonesToAdd = input.AddedPhones.MapTo<List<Phone>>();
            var query = await _partnerRepository.UpdateAsync(partner);
            await CurrentUnitOfWork.SaveChangesAsync();

            foreach (var phoneToAdd in phonesToAdd)
            {
                await _phoneRepository.InsertAsync(phoneToAdd);
                // await CurrentUnitOfWork.SaveChangesAsync();
            }
            foreach (var phone in phones)
            {
                var phoneToUpdate = await _phoneRepository.GetAsync(phone.Id);
                phone.MapTo(phoneToUpdate);
                await _phoneRepository.UpdateAsync(phoneToUpdate);
            }
            foreach (var phoneToDelete in phonesToDelete)
            {
                await _phoneRepository.DeleteAsync(phoneToDelete.Id);
            }
        }

This the Dto:

using Abp.AutoMapper;
using Abp.Application.Services.Dto;

namespace stake.Partners.Dto
{
    [AutoMapTo(typeof(Partner))]
    public class EditPartnerInput : IInputDto
    {
        public int Id { get; set; }

        public string Name { get; set; }

        public string Surname { get; set; }

        public PartnerPhoneDto[] Phones { get; set; }

        public PartnerPhoneDto[] DeletedPhones { get; set; }

        public PartnerPhoneDto[] AddedPhones { get; set; }
    }
}

I finally solved it!

First I discovered that it was not a problem of this piece of code alone:

foreach (var phone in phones)
            {
                if (phone.Id == 0)
                {
                    {
                        var currentPartner = _partnerRepository.Get(partner.Id);
                        currentPartner.Phones.Add(phone);
                      //  await CurrentUnitOfWork.SaveChangesAsync();
                    }
                }

but of the interference with previous partner update:

var query = await _partnerRepository.UpdateAsync(partner);

each of the actions alone worked well, but they did not work together, I do not really know why, maybe because of interference between the collection partner.Phones and the separate addition of phones.

When I discovered that I took the following actions:

  1. Added a line to the Dto for added phones as I did for deleted ones
  2. Modified the cshtml and the js so that each added phone goes in an addedPhones list and not on the original vm.partner.phones

In that way everything works I can add as many phones I want, delete as many I want, edit as many I want and also edit the partner name and surname on the same page and everything get updated.

Thanks for the support!

I tried... same error

By the way is it correct to use 4.6.1 as target framework or I should stay on 4.5.1?

Could it be some wrong dll version?

here my configs

CORE

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Abp" version="0.9.5.0" targetFramework="net461" />
  <package id="Abp.AutoMapper" version="0.9.5.0" targetFramework="net461" />
  <package id="Abp.Zero" version="0.9.4.0" targetFramework="net461" />
  <package id="Abp.Zero.Ldap" version="0.9.4.0" targetFramework="net461" />
  <package id="AutoMapper" version="4.2.1" targetFramework="net461" />
  <package id="Castle.Core" version="3.3.3" targetFramework="net451" />
  <package id="Castle.LoggingFacility" version="3.3.0" targetFramework="net451" />
  <package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net461" />
  <package id="Nito.AsyncEx" version="3.0.1" targetFramework="net451" />
  <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net461" />
</packages>

EntityFramework

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Abp" version="0.9.5.0" targetFramework="net461" />
  <package id="Abp.AutoMapper" version="0.9.5.0" targetFramework="net461" />
  <package id="Abp.EntityFramework" version="0.9.5.0" targetFramework="net461" />
  <package id="Abp.EntityFramework.Common" version="0.9.5.0" targetFramework="net461" />
  <package id="Abp.Zero" version="0.9.4.0" targetFramework="net461" />
  <package id="Abp.Zero.EntityFramework" version="0.9.4.0" targetFramework="net461" />
  <package id="AutoMapper" version="4.2.1" targetFramework="net461" />
  <package id="Castle.Core" version="3.3.3" targetFramework="net461" />
  <package id="Castle.LoggingFacility" version="3.3.0" targetFramework="net451" />
  <package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
  <package id="EntityFramework" version="6.1.3" targetFramework="net451" />
  <package id="EntityFramework.DynamicFilters" version="1.4.10.2" targetFramework="net461" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net461" />
  <package id="Nito.AsyncEx" version="3.0.1" targetFramework="net451" />
  <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net461" />
</packages>

application

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Abp" version="0.9.5.0" targetFramework="net461" />
  <package id="Abp.AutoMapper" version="0.9.5.0" targetFramework="net461" />
  <package id="Abp.Zero" version="0.9.4.0" targetFramework="net461" />
  <package id="Abp.Zero.Ldap" version="0.9.4.0" targetFramework="net461" />
  <package id="AutoMapper" version="4.2.1" targetFramework="net461" />
  <package id="Castle.Core" version="3.3.3" targetFramework="net451" />
  <package id="Castle.LoggingFacility" version="3.3.0" targetFramework="net451" />
  <package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
  <package id="EntityFramework" version="6.1.3" targetFramework="net451" />
  <package id="EPPlus" version="4.0.5" targetFramework="net452" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net461" />
  <package id="Nito.AsyncEx" version="3.0.1" targetFramework="net451" />
  <package id="SharpZipLib" version="0.86.0" targetFramework="net461" />
  <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net461" />
  <package id="System.Linq.Dynamic" version="1.0.6" targetFramework="net452" />
</packages>

Thanks in advance for your support. Here are my entities:

Partner:

using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using Abp.Domain.Entities.Auditing;
using System.Collections.Generic;

namespace stake.Partners
{
    [Table("stakePartners")]
    public class Partner : FullAuditedEntity
    {
        public const int MaxNameLength = 50;
        public const int MaxSurnameLength = 50;

        [Required]
        [MaxLength(MaxNameLength)]
        public virtual string Name { get; set; }

        [Required]
        [MaxLength(MaxSurnameLength)]
        public virtual string Surname { get; set; }

        public virtual RelationshipType RelationshipType { get; set; }
        public virtual ResponseLevel ResponseLevel { get; set; }
        public virtual InterestLevel InterestLevel { get; set; }
        public virtual InfluenceLevel InfluenceLevel { get; set; }
        public virtual InfluenceArea InfluenceArea { get; set; }
        public virtual InterestArea InterestArea { get; set; }
        public virtual ReactivityLevel ReactivityLevel { get; set; }
        public virtual LikingLevel LikingLevel { get; set; }

        public virtual ICollection<Phone> Phones { get; set; }
        public virtual ICollection<Social> Socials { get; set; }
        public virtual ICollection<Email> Emails { get; set; }
        public virtual ICollection<Address> Addresses { get; set; }
    }
}

Phone:

using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using Abp.Domain.Entities.Auditing;
using System.Collections.Generic;

namespace stake.Partners
{
    [Table("stakePhones")]
    public class Phone : FullAuditedEntity
    {
        public const int MaxNumberLength = 16;

        [ForeignKey("PartnerId")]
        public virtual Partner Partner { get; set; }
        public virtual int PartnerId { get; set; }

        [ForeignKey("PhoneTypeId")]
        public virtual PhoneType PhoneType { get; set; }
        public virtual int PhoneTypeId { get; set; }

        [Required]
        [MaxLength(MaxNumberLength)]
        public virtual string Name { get; set; }

    }
}

Phonetype (to complete the chain:

using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using Abp.Domain.Entities.Auditing;
using System.Collections.Generic;

namespace stake.Partners
{
    [Table("stakePhoneTypes")]
    public class PhoneType : FullAuditedEntity
    {
        public const int MaxNameLength = 50;

        [Required]
        [MaxLength(MaxNameLength)]
        public virtual string Name { get; set; }

        public virtual ICollection<Phone> Phones { get; set; }
    }
}
Showing 21 to 30 of 38 entries