Thank you @aaron for catching our silly mistake.
Hello,
What is the best way to mock this linq statement:
var results = _groupRepository
.GetAllIncluding(x => x.OrganizationUnit)
.Where(x => x.Id != id)
.ToList();
We have tried something like:
_groupRepository.Setup(x => x.GetAllIncluding(It.IsAny<Expression<Func<Group, object>>>)
.Where(It.IsAny<Expression<Func<Group, bool>>>))
.Returns(groups.AsQueryable);
This will not compiled due to " Error CS1503: Argument 1: cannot convert from 'method group' to 'Expression<Func<Group, object>>' " Is this possible?
Thanks.
We inverted the filtering by passing the owner connection id (aka the sender) to the server. Not certain the cause but intermittently it appeared that the SignalR Hub's Context.ConnectionId was wrong.
Here is our work-around
Server hub method
public void Save(string id, string payload)
{
Clients.AllExcept(id).saved(payload);
}
client invoking method
function processIndividuals() {
// elided
var connectionId = $.connection.hub.id;
abp.services.app.enrollment.save(connectionId, data).done(...)
};
server application service method
public async Task<Result<Dictionary<long, long>>> SaveAsync (string id, JObject data) {
// elided
var payload = JsonConvert.SerializeObject(result);
_hub.Save(id, payload); // invokes ISaved<string> interface implemented by SignalR hub
}
HTH
@aaron we are not calling save in multiple places. However, we believe we have a fix in place and will let you know later this afternoon if it works. Thanks.
Hello,
We are trying to implement SignalR changes in order to alert and sync different simultaneous users. We have followed [https://aspnetboilerplate.com/Pages/Documents/SignalR-Integration]) and have a mysterious issue.
We first posted here [https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=10680]) and found it initially worked. Upon further testing, we found that occasionally the hub method (see below)
Clients.Others.saved(payload);
was broadcasting to the original sending client and not to the other clients. To be explicit we altered the save method to this:
public void Save(string payload)
{
var ownerId = Context.ConnectionId;
Clients.All.saved(new KeyValuePair<string, string>(ownerId, payload));
}
and on the client we are attempting to filter on the connectionId like this:
function processChangeFromAnotherUser(kvp) {
var id = kvp.Key;
console.log('owner', id);
var connectionId = hub.connection.id;
console.log('connectionId', connectionId);
if (connectionId === id) {
return;
};
var data = JSON.parse(kvp.Value);
}
Unfortunately we are seeing the same unexpected behavior. We are testing using two different browsers (Chrome 63 on the left and Firefox Dev Edition (quantum) v59 on the right ). The website is hosted by IIS Express on a developer's computer. The "saved" message at the top of the screen should appear only on the right browser, but it appears on the left instead. As you can see the right browser has a connectionId which matches the sender's ID (which should be the browser on the left). Please see a screenshot here
Do you have any ideas as to what could be responsible for this unexpected behavior?
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?
We want a way to broadcast a message from the application service layer. However, signalR Hubs are only available in the Web layer. Therefore, we cannot call from a service into the Web layer. Using [https://aspnetboilerplate.com/Pages/Documents/Notification-System]) as a guide we have:
//server
public async Task PublishSaveAsync()
{
await _notificationPublisher.PublishAsync("message");
}
//client
function initializeHub() {
abp.event.on('abp.notifications.received', processSaved);
};
function processSaved(saveNotification) {
console.log('saveNotification', saveNotification);
};
The server code is executed, but the log statement is never written. Are we doing something incorrectly or is there a better way to do this?
Thanks.
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.