Activities of "commitdeveloper1"

I tried this, but its not working. Can we have a remote session on this? Pls expedidte this as we need to deliver the solution.

8a) Open Solution & from Services-> AdministrationService -> Right Click & added "OrderService.Application.Contracts.dll" by adding Project Reference (right click)

Can you try to update the csporj to use ProjectReference instead add dll file?

I tried adding the csproj project reference insteal dll files and when i am building the solution, its gving me the same error. Order service is not building properly. i have also updated the CLI & dot net to latest 4.4 version.

Hi again @commitdeveloper1, you can not access directly to precompanyname property because you are keeping Employment as collection instead of class. In other words, you need to iterate to collection to reach its properties.

public async Task<List<EmploymentEducation>> GetListAsync(int skipCount, int maxResultCount, string sorting, string filter = null) 
        { 
            var queryable = await GetMongoQueryableAsync(); 
            return await queryable 
                .WhereIf<EmploymentEducation, IMongoQueryable<EmploymentEducation>>( 
                            !filter.IsNullOrWhiteSpace(), 
                            //you need to iterate collection to reach its properties(prevcompanyname) 
                            employment => employment.Employments.Any(x => x.PrevCompanyName.Contains(filter)) 
                        ) 
                        .OrderBy(sorting) 
                        .As<IMongoQueryable<EmploymentEducation>>() 
                                //.Skip(skipCount) 
                                //.Take(maxResultCount) 
                                .ToListAsync(); 
        } 

Thanks... We got it now :)

Can you share your EmploymentEducationRepository class?

Yes,,here it is:

Thanks,

Can you also check your EmploymentEducationRepository class? Is it both inherit from MongoDbRepository<IMyMongoDbContext, EmploymentEducation, Guid> and IEmploymentRepository?

It's recommended.

Yes... it worked when we are inheriting both. But the problem is that there is "precompanyname" which is coming from another class (employment)

How do we use that as this class (Employment) is in Domain.Shared Project? and we are using this class in domain project as a collection.

(How to access the property of a collection class)

Here is the code:

using MongoDB.Driver.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Text; using MongoDB.Driver; using System.Linq.Dynamic.Core; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.MongoDB; using ZW.EmpSvc.EmploymentEducations; using ZW.EmpSvc.Employments;

namespace ZW.EmpSvc.MongoDB.EmploymentEducations { public class MongoDbEmploymentEducationRepository : MongoDbRepository<EmpSvcMongoDbContext, EmploymentEducation, Guid> , IEmploymentEducationRepository

{
    public MongoDbEmploymentEducationRepository(
        IMongoDbContextProvider&lt;EmpSvcMongoDbContext&gt; dbContextProvider
        ) : base(dbContextProvider)
    {
    }

    

    public async Task&lt;List&lt;EmploymentEducation&gt;> GetListAsync(
       int skipCount,
       int maxResultCount,
       string sorting,
       string filter = null
       )
    {

        var queryable = await GetMongoQueryableAsync();
        return await queryable
            .WhereIf&lt;EmploymentEducation, IMongoQueryable&lt;EmploymentEducation&gt;>(
                !filter.IsNullOrWhiteSpace(),
                employment => employment.PreCompanyName.Contains(filter)
            )
            .OrderBy(sorting)
            .As&lt;IMongoQueryable&lt;EmploymentEducation&gt;>()
            //.Skip(skipCount)
            //.Take(maxResultCount)
            .ToListAsync();
    }
}

}

Can you share your EmploymentEducationRepository class?

Yes,,here it is:

Did you add your Employment, EmploymentEducation and Education classes into your dbcontext class? (Like below)

... 
 
public DbSet<Employment> Employments {get; set;} 
public DbSet<EmploymentEducation> EmploymentEducations {get; set;} 
public DbSet<Education> Educations {get; set;} 
 
... 

We are using mongodb as database. We are using single class with multiple array :

 public IMongoCollection<EmploymentEducation> EmploymentEducation => Collection<EmploymentEducation>();
 modelBuilder.Entity<EmploymentEducation>(b =>
            {
                b.CollectionName = "EmploymentEducation";
            });

We are creating this class in domain project

public ICollection<Employment> Employment { get; set; }
        public ICollection<Education> Education { get; set; }

and this is what is in domain.shared

 public class Education
    {
        public string SchoolName { get; set; }
        public string Degree_Diploma { get; set; }
        public string Course { get; set; }
        public string GradeAchieved { get; set; }
        public DateTime CourseStartPeriod { get; set; }
        public DateTime CourseEndPeriod { get; set; }
        public DateTime DateOfCompletion { get; set; }
        public string FieldOfStudy { get; set; }
    }
 
    public class Employment
    {
        public string PrevCompanyName { get; set; }
        public string JobTitle { get; set; }
        public string EmploymentPeriod { get; set; }
 
        public string Designation { get; set; }
        public int TotalSalary { get; set; }
        public string References { get; set; }
    }

Your issue may be related to mapper. Could you please check?

If the problem is not resolved please share the relevant logs, thank you.

Mapper is ok.
I am attaching the snippet of log where the error is showing:

2021-08-03 11:31:13.516 +05:30 [INF] Authorization was successful.
2021-08-03 11:31:13.525 +05:30 [INF] Executing endpoint 'ZW.EmpSvc.EmploymentEducations.EmploymentEducationAppService.CreateAsync (ZW.EmpSvc.Application)'
2021-08-03 11:31:13.542 +05:30 [INF] Route matched with {action = "Create", controller = "EmploymentEducation", area = "", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[ZW.EmpSvc.EmploymentEducations.EmploymentEducationDto] CreateAsync(ZW.EmpSvc.EmploymentEducations.CreateEmploymentEducationDto) on controller ZW.EmpSvc.EmploymentEducations.EmploymentEducationAppService (ZW.EmpSvc.Application).
2021-08-03 11:31:13.544 +05:30 [DBG] Login Url: /Account/Login
2021-08-03 11:31:13.544 +05:30 [DBG] Login Return Url Parameter: ReturnUrl
2021-08-03 11:31:13.544 +05:30 [DBG] Logout Url: /Account/Logout
2021-08-03 11:31:13.544 +05:30 [DBG] ConsentUrl Url: /Consent
2021-08-03 11:31:13.544 +05:30 [DBG] Consent Return Url Parameter: returnUrl
2021-08-03 11:31:13.544 +05:30 [DBG] Error Url: /Account/Error
2021-08-03 11:31:13.544 +05:30 [DBG] Error Id Parameter: errorId
2021-08-03 11:31:13.644 +05:30 [ERR] ---------- RemoteServiceErrorInfo ----------
{
  "code": null,
  "message": "An internal error occurred during your request!",
  "details": null,
  "data": {
    "ActivatorChain": "Castle.Proxies.EmploymentEducationAppServiceProxy"
  },
  "validationErrors": null
}

2021-08-03 11:31:13.647 +05:30 [ERR] An exception was thrown while activating Castle.Proxies.EmploymentEducationAppServiceProxy.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating Castle.Proxies.EmploymentEducationAppServiceProxy.
 ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Volo.Abp.Autofac.AbpAutofacConstructorFinder' on type 'Castle.Proxies.EmploymentEducationAppServiceProxy' can be invoked with the available services and parameters:
Cannot resolve parameter 'ZW.EmpSvc.EmploymentEducations.IEmploymentEducationRepository employmentEducationRepository' of constructor 'Void .ctor(Castle.DynamicProxy.IInterceptor[], ZW.EmpSvc.EmploymentEducations.IEmploymentEducationRepository, ZW.EmpSvc.EmploymentEducations.EmploymentEducationManager, ZW.EmpSvc.Employees.IEmployeeRepository)'.
   at Autofac.Core.Activators.Reflection.ReflectionActivator.GetAllBindings(ConstructorBinder[] availableConstructors, IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Reflection.ReflectionActivator.&lt;ConfigurePipeline&gt;b__11_0(ResolveRequestContext ctxt, Action`1 next)
   at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Builder.RegistrationBuilder`3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext ctxt, Action`1 next)
   at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   --- End of inner exception stack trace ---
   at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request)
   at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request)
   at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
   at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
   at Microsoft.AspNetCore.Mvc.Controllers.ServiceBasedControllerActivator.Create(ControllerContext actionContext)
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.&lt;&gt;c__DisplayClass5_0.&lt;CreateControllerFactory&gt;g__CreateController|0(ControllerContext controllerContext)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeNextExceptionFilterAsync&gt;g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2021-08-03 11:31:13.659 +05:30 [ERR] ---------- Exception Data ----------
ActivatorChain = Castle.Proxies.EmploymentEducationAppServiceProxy

2021-08-03 11:31:13.682 +05:30 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.Http.RemoteServiceErrorResponse'.
2021-08-03 11:31:13.698 +05:30 [INF] Executed action ZW.EmpSvc.EmploymentEducations.EmploymentEducationAppService.CreateAsync (ZW.EmpSvc.Application) in 155.3672ms

Here is the code for application service.

using Microsoft.AspNetCore.Authorization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using ZW.EmpSvc.Employees;
using ZW.EmpSvc.Permissions;
using System.Linq.Dynamic.Core;

namespace ZW.EmpSvc.EmploymentEducations
{
    [Authorize(EmpSvcPermissions.EmploymentEducationPermissions.Default)]
    public class EmploymentEducationAppService : EmpSvcAppService, IEmploymentEducationAppService
    {
        private readonly IEmploymentEducationRepository _employmentEducationRepository;
        private readonly EmploymentEducationManager _employmentEducationManager;
        private readonly IEmployeeRepository _employeeRepository;
        public EmploymentEducationAppService(
            IEmploymentEducationRepository employmentEducationRepository,
            EmploymentEducationManager employmentEducationManager,
            IEmployeeRepository employeeRepository)
        {
            _employmentEducationRepository = employmentEducationRepository;
            _employmentEducationManager = employmentEducationManager;
            _employeeRepository = employeeRepository;
        }

        public async Task<EmploymentEducationDto> GetAsync(Guid id)
        {
            var employment = await _employmentEducationRepository.GetAsync(id);
            var employmentDto = ObjectMapper.Map<EmploymentEducation, EmploymentEducationDto>(employment);

            var employee = await _employeeRepository.GetAsync(employment.EmployeeID);
            employmentDto.EmployeeName = employee.FirstName;
            return employmentDto;
        }


        public async Task<ListResultDto<EmploymentEducationLookupDto>> GetEmployeeLookupAsync()
        {
            var employees = await _employeeRepository.GetListAsync();

            return new ListResultDto<EmploymentEducationLookupDto>(
                ObjectMapper.Map<List<Employee>, List<EmploymentEducationLookupDto>>(employees)
            );
        }


        private async Task<Dictionary<Guid, Employee>>
           GetEmployeeDictionaryAsync(List<EmploymentEducation> employments)
        {
            var employeeIds = employments
                .Select(b => b.EmployeeID)
                .Distinct()
                .ToArray();

            var queryable = await _employeeRepository.GetQueryableAsync();

            var employees = await AsyncExecuter.ToListAsync(
                queryable.Where(a => employeeIds.Contains(a.Id))
            );

            return employees.ToDictionary(x => x.Id, x => x);
        }


        public async Task<PagedResultDto<EmploymentEducationDto>> GetListAsync(GetEmploymentEducationListDto input)
        {
            

            var employmentEducation = await _employmentEducationRepository.GetListAsync(
                input.SkipCount,
                input.MaxResultCount,
                input.Sorting,
                input.Filter
            );

            var totalCount = input.Filter == null
                ? await _employmentEducationRepository.CountAsync()
                : await _employmentEducationRepository.CountAsync();

            var queryable = await _employmentEducationRepository.GetQueryableAsync();


            var employments = await AsyncExecuter.ToListAsync(
             queryable
               .OrderBy(input.Sorting)
               .Skip(input.SkipCount)
                .Take(input.MaxResultCount)
        );

            var employmentDtos = ObjectMapper.Map<List<EmploymentEducation>, List<EmploymentEducationDto>>(employments);

            var employeeDictionary = await GetEmployeeDictionaryAsync(employments);

            employmentDtos.ForEach(employmentDtos => employmentDtos.EmployeeName =
                             employeeDictionary[employmentDtos.EmployeeID].FirstName);

            return new PagedResultDto<EmploymentEducationDto>(
                 totalCount,
                 employmentDtos
            );
        }


        [Authorize(EmpSvcPermissions.EmploymentEducationPermissions.Create)]
        public async Task<EmploymentEducationDto> CreateAsync(CreateEmploymentEducationDto input)
        {
            var employee = await _employmentEducationManager.CreateAsync(
            input.EmployeeID,
                input.Employment,
                input.Education
            );

            await _employmentEducationRepository.InsertAsync(employee);

            return ObjectMapper.Map<EmploymentEducation, EmploymentEducationDto>(employee);
        }

        [Authorize(EmpSvcPermissions.EmploymentEducationPermissions.Edit)]
        public async Task UpdateAsync(Guid id, UpdateEmploymentEducationDto input)
        {
            var employee = await _employmentEducationRepository.GetAsync(id);

            
            employee.EmployeeID = input.EmployeeID;
            employee.Employment = input.Employment;
            
            await _employmentEducationRepository.UpdateAsync(employee);
        }


        [Authorize(EmpSvcPermissions.EmploymentEducationPermissions.Delete)]
        public async Task DeleteAsync(Guid id)
        {
            await _employmentEducationRepository.DeleteAsync(id);
        }
    }
}

Pls check

Hello, I am getting An internal error occcured : "ActivatorChain": "Castle.Proxies.EmploymentEducationAppServiceProxy" when trying to run swagger api. Earlier the solution was running fine. The only change i did was to change the class to collectiontype class.

I am attaching the screeshots below. Error Screen:

Collection Class: DTO declarataion:

Please let me know, what is wrong here.

Yes, these are steps i am following:

  1. Runnin CLI command to create a new service in the solution
*abp new OrderService -t microservice-service-pro*
  1. Then building the new service in the \services\order directory:
dotnet build
  1. Adding the new service to the solution (project solution - run powershell) --dotnet sln add services/order/src/Acme.BookStore.OrderService.HttpApi.Host/Acme.BookStore.OrderService.HttpApi.Host.csproj --solution-folder services
dotnet sln add services/order/src/MicroserviceSolution.OrderService.HttpApi.Host/MicroserviceSolution.OrderService.HttpApi.Host.csproj --solution-folder services
  1. Trying to Update Other Dependent Services - Administration (permission)

<ProjectReference Include="......\order\src\Acme.BookStore.OrderService.Application.Contracts\Acme.BookStore.OrderService.Application.Contracts.csproj" /> <ProjectReference Include="......\order\src\MicroserviceSolution.OrderService.Application.Contracts\MicroserviceSolution.OrderService.Application.Contracts.csproj" />

8a) Open Solution & from Services-> AdministrationService -> Right Click & added "OrderService.Application.Contracts.dll" by adding Project Reference (right click)

8b) Open "AdministrationServiceHttpApiHostModule.cs" class and add the following module dependency "typeof(OrderServiceApplicationContractsModule)" -> and fix the potential "using MicroserviceSolution.OrderService;"

These are the steps....and just after that i am getting the above thread errors.

Showing 1 to 10 of 16 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07