Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "carelearning"

Thank you @aaron and @strix20. This works; wWe have our server-side payload from the application service via the Web's SignalR.

@strix20 Thanks for the response. Here is our implementation below.

Generic Interface

public interface ISave<T>
{
  void Save(T payload);
}

Signal R Hub

[HubName("myHub")]
public class MyHub: Hub, ITransientDependency, ISave<string>
{   
   /* https://aspnetboilerplate.com/Pages/Documents/SignalR-Integration#your-signalr-code */

  public void Save(string payload)
  {
    Clients.Others.saved(payload);
   }
}

App Service

public class MyAppService : AbpZeroTemplateAppServiceBase, IMyAppService 
{
  private readonly ISave<string> _hub;

  public MyAppService(ISave<string> hub) 
  {
     _hub = hub;
  }

  public async Task<Result<Dictionary<long, long>>> SaveAsync(MasterCommandDto commands) 
  {
       /* elided */

      var payload = JsonConvert.SerializeObject(commands);
      _hub.Save(payload);

       // ..
  }
}
public class AbpZeroTemplateWebModule : AbpModule
{
  public override void Initialize()
  {
     IocManager.Register<ISave<string>, MyHub>();
  }
}

When we register the component in the Web layer we get this server error: Component MyCompanyName.AbpZeroTemplate.Web.Hubs.MyHub could not be registered. There is already a component with that name. Did you want to modify the existing component instead? If not, make sure you specify a unique name.

What is the appropriate way of adding this to the IOC container?

Hello,

Were you able to find out any more information about this issue? Thanks!

To defeat the file size limit we sent a message with an attachment to the info email address, which you provided in a prior forum suggestion.

This email contains a working example solution from Asp.Net Boilerplate that could illustrate the possible bug we have uncovered.

Thanks for your time.

Please let us know if you have follow-up questions.

@ismcagdas

I pasted the code you provided and I still get the error. Please see attached screenshot for details. Also included is a 7-Zip compressed version of the Logs.txt file. Logs.7z

LinqPad (Works)

var results = AbpUserOrganizationUnits
                .Join(Departments,
                    a => a.OrganizationUnitId,
                    d => d.OrganizationUnitId,
                    (p, d) => new { Projection = p, Departments = d })
                .Where(x => ids.Contains(x.Projection.UserId))
                .ToDictionary(x => x.Projection.UserId,
                              x => x.Departments.CustomKey);

C# (Errors)

var results = _userOrganizationUnitRepository
                .GetAll()
                .Join(_departmentRepository
                        .GetAll(),
                    a => a.OrganizationUnitId,
                    d => d.OrganizationUnitId,
                    (p, d) => new { Projection = p, Departments = d })
                .Where(x => ids.Contains(x.Projection.UserId))
                .ToDictionary(x => x.Projection.UserId,
                              x => x.Departments.CustomKey);

C# (Works)

var departments = _departmentRepository.GetAllList();
            var assignments =  _userOrganizationUnitRepository.GetAllList();

            return departments.Join(assignments,
                    d => d.OrganizationUnitId,
                    a => a.OrganizationUnitId,
                    (d, a) => new { Department = d, Assignment = a })
                .ToDictionary(x => x.Assignment.UserId,
                    x => x.Department.CustomKey);

Another point is that we can do this in Linqpad with the following code:

var ids = new List<long>{
	2,
	3,
	4,
	5,
	6,
	7,
	8
};

var assignments = AbpUserOrganizationUnits
                .Where(x => ids.Contains(x.UserId)).ToList();

var first = assignments.Join(AbpOrganizationUnits,
                                     a => a.OrganizationUnitId,
                    				 ou => ou.Id,
				                     (a, ou) => new { Assignments = a, OrganizationUnits = ou });

var second = AbpUserOrganizationUnits
                    .Join(Departments,
                    a => a.OrganizationUnitId,
                    d => d.OrganizationUnitId,
                    (p, d) => new { Projection = p, Departments = d });

var third = first.Join(second,
                f => f.Assignments.OrganizationUnitId,
                s => s.Departments.OrganizationUnitId,
                (f, s) => new { First = f, Second = s });

third.Dump();

The results are attached

We found an answer here: [https://forum.aspnetboilerplate.com/viewtopic.php?f=2&t=2947&p=7317&hilit=disable+ValidationConfiguration+Configuration.Validation#p7317]) We had to add

Configuration.Modules.AbpWebApi().IsValidationEnabledForControllers = false;

to disable validation on the services.

@Aaron

Thank you.

The

.FirstOrDefaultAsync()

and

.GetAll()...ToListAsync()

methods are exactly what we needed.

And these changes should significantly speed up some of our methods.

Hi Aaron,

Thank you for your reply. My example was probably too simple. Your answer will indeed help in some places. A real example of our code is:

var temporaryConflicts = (await _enrollmentRepository.GetAllListAsync())
                .Where(x => x is Temporary)
                .Where(x => !excludedIds.Contains(x.Id))
                .GroupBy(x => x.Detail.Username)
                .Where(g => g.Count() > 1)
                .Select(g => g.Key);

We would like something like this:

var temporaryConflicts = _enrollmentRepository.GetAllListAsync()
                .WhereAsync(x => x is Temporary)
                .WhereAsync(x => !excludedIds.Contains(x.Id))
                .GroupByAsync(x => x.Detail.Username)
                .WhereAsync(g => g.Count() > 1)
                .Select(g => g.Key);

This way the filtering is done when the data is acquired (DB level) and not done afterwards (in memory).

Thanks!

Showing 21 to 30 of 65 entries