Base solution for your next web application

Activities of "patrickglaudemans"

Hi,

I have an entity called Job. It has property (child object) Report (many to one). Each Job has only one report.

While saving the job through a standard ZERO setup (application service with all the standard setup), it's not possible to only save the Id of the report entity while saving only a job. At current, at the moment of update, Job has a populated property Report indeed. When updating it is going through the automated validation of DBContext etc. etc. When there are child properties within the report object (which aren't loaded ofcourse) then the save of the Job entity will fail because of the Report entity! But I don't want to save Report! I want to save Job with only the Report ID (the reference)..

How can I force to only store Job with report Id/reference and not going to store Report entity as well?!

This is partly a EF question but since the DBContext is hidden in the standard JobRepository it's caused by zero setup.

<code> public async Task CreateOrUpdateJob(CreateOrUpdateJobInput input) {

        if (input.Job.Id > 0)
        {
            //existing Job
            var Job = await _JobRepository.GetAsync(input.Job.Id);
            input.Job.MapTo(Job);
            await _JobRepository.UpdateAsync(Job);
        }
        else
        {
            //new Job
            await CreateJobAsync(input);
        }
    }

</code>

Hold it - I solved it. Obviously it had something to do with dependencies to other libraries in the project. To begin with the data layer ;-)

Hi,

Used the Console App (Acm.PhoneBook) as example to setup access from console classlib to zero implementation (application layer etc.)

Created all the proper instances and bootstrapper. Initializing is running well but after calling: var eventProcessor = bootstrapper.IocManager.Resolve<ReportAppService>(); I get this error:

Can't create component 'Intertek.BI.Reporting.Reports.ReportAppService' as it has dependencies to be satisfied.

'Intertek.BI.Reporting.Reports.ReportAppService' is waiting for the following dependencies:

  • Service 'Abp.Domain.Repositories.IRepository`1[[Intertek.BI.Entities.Report, Intertek.BI.Core, Version=1.4.1.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.
  • Service 'Abp.Domain.Repositories.IRepository`1[[Intertek.BI.Entities.SiteOffice, Intertek.BI.Core, Version=1.4.1.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.
  • Service 'Intertek.BI.Reporting.Core.ReportManager' which was not registered.
  • Service 'Intertek.BI.Storage.DbBinaryObjectManager' which was registered but is also waiting for dependencies. 'Intertek.BI.Storage.DbBinaryObjectManager' is waiting for the following dependencies:
  • Service 'Abp.Domain.Repositories.IRepository`2[[Intertek.BI.Storage.BinaryObject, Intertek.BI.Core, Version=1.4.1.0, Culture=neutral, PublicKeyToken=null],[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' which was not registered.
  • Service 'Abp.Domain.Repositories.IRepository`1[[Intertek.BI.Entities.DataSource, Intertek.BI.Core, Version=1.4.1.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.
  • Service 'Abp.Domain.Repositories.IRepository`1[[Intertek.BI.Entities.ReportTableCommand, Intertek.BI.Core, Version=1.4.1.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.

It' seems that DI is not working since registration was not done properly.

pglaudemans

thanks!

Thanks, but can you supply proper link - link is broken!

Hi,

I want to access my ZERO application services from within an external class library (console/win service etc.) Therefore I need to initialize the IocManager like IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()); This is only working in a AbpModule. What's the proper way to setup this up.

Thanks! Let me check again. If it keeps on failing I will sent requested code items.

Hi,

contentGroup.Users.Add(new User());

can be ignored - it was for testing p.

Hi,

Thanks for your reply. Last time I provided incomplete code for the example - that's where the null check failed but that is irrelevant. Here is, however, the complete method code. Still the users are not get saved, al other properties like reports, do! THis code is in exact the same appservice structure like recommended in manual etc.

public async Task UpdateContentGroupMembers(UpdateContentGroupMembersInput input)
        {

            if (input != null)
            {
                ContentGroup contentGroup = null;
                if (input.ReportMembers != null)
                {
                    if (input.ReportMembers.Any())
                    {
                        contentGroup = _contentGroupRepository.GetAll()
                            .Include(c=>c.Reports)
                            .Include(c=>c.Users).FirstOrDefault();
                        if (contentGroup != null)
                        {
                            //check if selection is in saved selection - if not add
                            foreach (var selection in input.ReportMembers)
                            {
                                if (contentGroup.Reports.Find(r => r.Id == selection) == null)
                                {
                                    //selected but not yet in saved selection: add
                                    contentGroup.Reports.Add(_reportRepository.Get(selection));
                                }
                            }
                            //check if selection is in saved
                            foreach (var savedSelection in contentGroup.Reports)
                            {
                                if (!input.ReportMembers.Contains(savedSelection.Id))
                                {
                                    //in saved but not selected anymore: delete
                                    contentGroup.Reports.Remove(savedSelection);
                                }
                            }  
                        }
                    }

                    if (input.UserMembers != null)
                    {
                        if (input.UserMembers.Any())
                        {
                            if (contentGroup == null)
                            {
                                contentGroup = _contentGroupRepository.GetAll()
                                    .Include(c => c.Reports)
                                    .Include(c => c.Users).FirstOrDefault();
                            }
                            if (contentGroup != null)
                            {
                                //check if selection is in saved selection - if not add
                                foreach (var selection in input.UserMembers)
                                {
                                    if (contentGroup.Users.Find(r => r.Id == selection) == null)
                                    {
                                        //selected but not yet in saved selection: add
                                        var user = await UserManager.GetUserByIdAsync(System.Convert.ToInt64(selection));
                                        contentGroup.Users.Add(user);
                                    }
                                }
                                //check if selection is in saved
                                foreach (var savedSelection in contentGroup.Users)
                                {
                                    if (!input.UserMembers.Contains(System.Convert.ToInt32(savedSelection.Id)))
                                    {
                                        //in saved but not selected anymore: delete
                                        contentGroup.Users.Remove(savedSelection);
                                    }
                                }

                            }
                        }
                        contentGroup.Users.Add(new User());
                    }
                }

               



                if (contentGroup != null)
                {
                    await _contentGroupRepository.UpdateAsync(contentGroup);    
                }
                else
                {
                    //nothing to do - bye
                }
            }

        }

Best,

My last sentence was not quite clear. What I ment to say is that is has something to do with the user entity not being monitored for changes by the Entity Framework.

Halil any comments? Thanks, Patrick

Showing 31 to 40 of 47 entries