Base solution for your next web application

Activities of "Astech"

Hi,

I'm trying to get a Signalr Client Hubconnection working on Xamarin but only receiving timeouts.

The Hubconnection works fine on the web application:

Information: Normalizing '/signalr-document-conversion' to 'https://localhost:44302/signalr-document-conversion'. WebSocket connected to wss://localhost:44302/signalr-document-conversion?id=b8_kizi_mCESajbklz7pyQ.

The Xamarin code:

` try { HubConnection = new HubConnectionBuilder() .WithUrl("https://192.168.0.22:44302/signalr-document-conversion" ).ConfigureLogging(logging => { logging.SetMinimumLevel(LogLevel.Debug); logging.AddConsole(); logging.AddDebug(); }) .Build();

            HubConnection.On<int, int>("DocumentReordered", (documentId, newOrderIndex) =>
            {
                Console.WriteLine("TEST");
            });

            HubConnection.On<int, string, string, string>("DocumentStatusChanged", (documentId, status, fileName, fileTypeImageName) =>
            {
                Console.WriteLine("TEST");
            });

            await HubConnection.StartAsync();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }

`

The log

` 08-03 12:46:59.476 I/mono-stdout(13938): Starting HubConnection. dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[1] Starting HttpConnection. 08-03 12:46:59.481 I/mono-stdout(13938): dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[1] 08-03 12:46:59.481 I/mono-stdout(13938): Starting HttpConnection. [0:] Microsoft.AspNetCore.Http.Connections.Client.HttpConnection: Debug: Starting HttpConnection. dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[8] 08-03 12:46:59.493 I/mono-stdout(13938): dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[8] Establishing connection with server at 'https://192.168.0.22:44302/signalr-document-conversion'. 08-03 12:46:59.493 I/mono-stdout(13938): Establishing connection with server at 'https://192.168.0.22:44302/signalr-document-conversion'. [0:] Microsoft.AspNetCore.Http.Connections.Client.HttpConnection: Debug: Establishing connection with server at 'https://192.168.0.22:44302/signalr-document-conversion'. 08-03 12:46:59.537 V/ViewRootImpl(13938): The specified message queue synchronization barrier token has not been posted or has already been removed 08-03 12:46:59.565 D/DecorView(13938): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@5231d85[MainActivity] fail: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[10] Failed to start connection. Error getting negotiation response from 'https://192.168.0.22:44302/signalr-document-conversion'. System.Net.Http.HttpRequestException: Connection timed out ---> System.Net.Sockets.SocketException: Connection timed out at System.Net.Http.ConnectHelper.ConnectAsync (System.String host, System.Int32 port, System.Threading.CancellationToken cancellationToken) [0x000c8] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs:65 --- End of inner exception stack trace --- at System.Net.Http.ConnectHelper.ConnectAsync (System.String host, System.Int32 port, System.Threading.CancellationToken cancellationToken) [0x00180] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/Sock 08-03 12:47:24.563 I/mono-stdout(13938): fail: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[10]etsHttpHandler/ConnectHelper.cs:84 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.CreateConnectionAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x000ea] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:385 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync (System.Threading.Tasks.ValueTask1[TResult] creationTask) [0x000a2] in /Users/builder/jenkins/w

08-03 12:47:24.563 I/mono-stdout(13938): Failed to start connection. Error getting negotiation response from 'https://192.168.0.22:44302/signalr-document-conversion'.orkspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:543 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.SendWithRetryAsync (System.Net.Http.HttpRequestMessage request, System.Boolean doRequestAuth, System.Threading.CancellationToken cancellationToken) [0x0003f] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:284 at System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00070] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net

`

The Xamarin app is being run from a phone and the webhost is on a pc. I'm able to connect to all the other services from the phone just fine.

Prerequisites What is your product version? - v10.0.0 What is your product type (Angular or MVC)? - MVC What is product framework type (.net framework or .net core)? - Core

Hi,

We are using string format to join two or more localisations together. For example:

<?xml version="1.0" encoding="utf-8" ?> <localizationDictionary culture="en"> <texts> <text name="CreateNewSomething">Create new {0}</text> <text name="Role">Role</text> <text name="OrganisationUnit">Organisation Unit</text> </texts> </localizationDictionary>

We are then using it these in our views like so: string.Format(@L("CreateNewSomething"),@L("Role").ToLower())

This works great. However, we have now run into a problem trying to set the text for permissions in AppAuthorizationProvider.cs: roles.CreateChildPermission(AppPermissions.Pages_Administration_Roles_Create, L("CreatingNewRole"));

The second parameter here expects ILocalizableString and not String. Therefore we cannot do a string format in the same way as above.

Is there a way to do this please?

Thanks,

Prerequisites

  • What is your product version? - v10.0.0
  • What is your product type (Angular or MVC)? - MVC JQuery
  • What is product framework type (.net framework or .net core)? - Core

We have the following background job:

class BuildAgendaJob : ITransientDependency
{
	private readonly IAppNotifier _appNotifier;
	private readonly IAgendasAppService _agendasAppService;
	private readonly IDocumentsAppService _documentsAppService;
	private readonly IHubContext<BuildProgressHub> _buildProgressHub;
	private readonly IAbpSession _session;
	private readonly IRepository<Agenda> _agendaRepository;
	private readonly IUnitOfWorkManager _unitOfWorkManager;

	public BuildAgendaJob(IAppNotifier appNotifier,
							IAgendasAppService agendasAppService,
							IHubContext<BuildProgressHub> buildProgressHub,
							IAbpSession session,
							IRepository<Agenda> agendaRepository,
							IDocumentsAppService documentsAppService,
							IUnitOfWorkManager unitOfWorkManager)
	{
		_appNotifier = appNotifier;
		_agendasAppService = agendasAppService;
		_buildProgressHub = buildProgressHub;
		_session = session;
		_agendaRepository = agendaRepository;
		_documentsAppService = documentsAppService;
		_unitOfWorkManager = unitOfWorkManager;
	}

	public async Task BuildAgenda(BuildAgendaJobArgs args, CancellationToken token)
	{
		using (var uow = _unitOfWorkManager.Begin())
		{
			// Set tenant Id
			_unitOfWorkManager.Current.SetTenantId(args.TenantId);

			// Run the job with the same permissions as the person that started it
			using (_session.Use(args.TenantId, args.UserId))
			{
				try
				{
					await _agendasAppService.AddAgendaDocument(
						new AddAgendaDocumentDto
						{
							AgendaId = args.AgendaId,
							FileName = "Agenda.docx",
						});

					//Notify the UI
					await _buildProgressHub.Clients.All.SendAsync("AgendaBuildFinished" + args.AgendaId);

					// Notify the user
					AsyncHelper.RunSync(() => _appNotifier.AgendaBuiltAsync(args));
				}
				catch (OperationCanceledException)
				{
					await _buildProgressHub.Clients.All.SendAsync("AgendaBuildFinished" + args.AgendaId);
					return;
				}
				catch (Exception ex)
				{
					//TODO
				}
			}
		}
	}
}

<br> As you can see above, it calls:

_agendasAppService.AddAgendaDocument

Which inserts the new record into the database. It appears to be working as in that method it returns the next available id in the database after its insert. However, the database does not get updated. Is as if the code has inserted the record but it has not pushed the changes to EF/database.

I have attempted to add: <br>

await _unitOfWorkManager.Current.SaveChangesAsync();

at the end of the background job however the record does still not get pushed to the database.

Am I missing something? Usually the app service will push any changes to the dbcontext automatically. Why is this not the case here?

Thanks

Hi, I'm unable to run "npm install" or "yarn" in my MVC project.

I tried running this with a fresh copy of node.js.

`C:\Repos\Congresso\src\Congresso.Web.Mvc>npm install npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: abpzerotemplate@10.0.0 npm ERR! Found: bootstrap@4.3.1 npm ERR! node_modules/bootstrap npm ERR! bootstrap@"4.3.1" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer bootstrap@"^3.1.1" from bootstrap-switch@3.3.4 npm ERR! node_modules/bootstrap-switch npm ERR! bootstrap-switch@"3.3.4" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force, or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! See C:\Users\JRadu\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\JRadu\AppData\Local\npm-cache_logs\2021-04-21T10_10_38_671Z-debug.log`

We are using Hangfire to run a long running job. When the job is finished we require it to update a column in the database:

public override void Execute(BuildLogJobArgs args)
{
    using (CurrentUnitOfWork.SetTenantId(args.TenantId))
    {
        var itemsCount = 100;
        for (int i = 0; i <= itemsCount; i++)
        {
            //Simulating work
            System.Threading.Thread.Sleep(100);
            SendProgress(i, itemsCount);
        }
        // Send notification to user.
        AsyncHelper.RunSync(() => _appNotifier.LogBuiltAsync(args));

        //Finish the job
        AsyncHelper.RunSync(() => _logsAppService.FinishBuildLog(args.LogId));
    }
}

_logsAppService.FinishBuildLog_logsAppService.FinishBuildLog is responsible for updating the database. However when run we are getting:

Abp.Authorization.AbpAuthorizationException: Current user did not login to the application!

The FinishBuildLog method is protected with [AbpAuthorize....] and we want this to continue to be the case for obvious security reasons.

In which case how can we allow the running job the same permissions to the app service that the user that started the job would have? We do have the User object available to us in the BuildLogJobArgs.

Or is there a better way to go about this?

Thanks,

Scott

Hi,

When I include the ContentPage.BindingContext on my page, the app crashes when trying to load the page.

`

<ContentPage.BindingContext>
    <local:TeamsView />
</ContentPage.BindingContext>

` I'm trying to use OpenContextMenu command which is a command inside my viewmodel.

`

    <Button Text="{StaticResource VerticalEllipsisIcon}"
        FontFamily="{StaticResource IconsFont}"
        Command="{Binding BindingContext.OpenContextMenuCommand}"
        CommandParameter="{Binding}"
        TextColor="DarkGray"
        BackgroundColor="Transparent"
        VerticalOptions="Center"

The viewmodel command: public TeamsViewModel(ITeamsAppService teamsAppService) { _teamsAppService = teamsAppService;

        OpenContextMenuCommand = new Command<TeamModel>(item => item.IsPopupOpen = !item.IsPopupOpen);
        Teams = new ObservableRangeCollection<TeamModel>();
    }

    public Command<TeamModel> OpenContextMenuCommand { get; }

`

  • What is your product type (Angular or MVC)? MVC
  • What is product framework type (.net framework or .net core)? .NET Core

When I change a setting "App.UiManagement.Theme" for tenant on the mobile application, the old value remains on the web application. This updates fine when the application is started fresh however, is there a way to forcefully load a setting from the db.AbpSettings?

Thanks!

  • What is your product type (Angular or MVC)? MVC
  • What is product framework type (.net framework or .net core)? .NET Core
  • What is ABP Framework version? 6.0

Hi,

We are using the ASP Net Zero lookup:

I can see in the code it is essentially a disabled text box that shows the selection of the picker:

Is there any way to make the control required? i.e. a selection must be made. At the moment adding required to the input does not work because it is disabled. And we want to keep it disabled because we only want the text set from the picker.

Any ideas? Cheers

Hi,

We are relatively new to Zero and are wanting to add a permission based system to the entities that we create. We have seen the following URL which suggests using Organisation Units:

https://support.aspnetzero.com/QA/Questions/7163/More-detailed-permissions-per-entity

It links to this guide:

https://aspnetboilerplate.com/Pages/Documents/Articles\How-To\add-custom-data-filter-ef-core

The guide details how to have a single OU associated to a user, however in our business model both users and entities can have multiple OUs associated. So for example, an entity may have 3 OUs associated that can access it. A user may be in 5 OUs. As long as one of the OUs matches, they will have access.

Is there a method/guide for acheiving this?

As an additional question is there a premade UI control that we can plug into for the entity OU selection? We have spotted the lookup modal. Should we use this to lookup OUs and allow multi selection of them for each entity or is there a more "built in" way of handling such entity permissions?

We are using the latest Zero version for .NET Core/Jquery.

Thanks in advance

Scott

Showing 21 to 29 of 29 entries