Base solution for your next web application

Activities of "mgcode"

Hello velu,

I am also interested in learning how you implemented the integration with devexpress reporting.

I would appreciate it, if you could share your link with me, as well.

Thank you in advance. Vasilis, [email protected]

Hello velu, thanks for sending your project. Since my project uses ASP.NET Core and jQuery, I would greatly appreciate it if you (or anyone in the community) could provide a project using these technologies instead of ASP.NET Core and Angular.

Thank you once more for your time and help,

Vasilis, [email protected]

Hello,

I have been assigned a project and my client has not decided on the application name yet. I have to develop a demo application, deploy it in the cloud (Azure), demonstrate it to my client, and, if the client is satisfied, deploy the live version of my project and get paid.

With that in mind, please advice on what is the best way to do it.

  1. Will I be able to achieve the above-mentioned requirements by generating a demo project? What are the actual limitations of a demo project?
  2. Is there a simple way or tool to migrate my code from the demo project with the "whatever" name to my live generated project with the right name?
  3. If I go with one name to generate a live project can I change the name later?

Thank you in advance for your time and help,

Best Regards,

Hello,

I have three user roles: administrators, supervisors and agents. I have set their role permissions so that supervisors have access to the agents and actions entities.

What is the proper way to limit the supervisors' access only to their agents and the actions their agents have conducted?

Thank you in advance for your time and help,

PS. Agents entity has a property SupervisorID and a property UserID and the Actions entity has a property AgentID

Best Regards,

Hi, with the following snippet of code I have implemented a customAppService method (SubmitQuestionnaireForm) in which I retrieve the object quesionnaire from questionnaireRepository and I set the status property to "UploadedByClient" value.

Then I call the CreateOrEdit default method in which I try to enforce some logic using the previous and new values. In real time, I realised that both questionnaire and input had the new value.

Please advice on which is the proper way to achieve this functionality and perform validation and notifications logic prior to update.

        public async Task<bool> SubmitQuestionnaireForm(object obj, int id)
        {
            var questionnaire = await _questionnaireRepository.GetAsync(id);
            questionnaire.Status = QuestionnaireStatus.UploadedByClient;

            CreateOrEditQuestionnaireDto questionnaireDto = new CreateOrEditQuestionnaireDto();
            questionnaireDto = ObjectMapper.Map<CreateOrEditQuestionnaireDto>(questionnaire);
            await _questionnairesAppService.CreateOrEdit(questionnaireDto);

            return true;
        }    
  
  
  public async Task CreateOrEdit(CreateOrEditQuestionnaireDto input)
         {
            if(input.Id == null){
				await Create(input);
			}
			else{
				await Update(input);
			}
         }
         
         

        private async Task Update(CreateOrEditQuestionnaireDto input)
        {
            var questionnaire = await _questionnaireRepository.FirstOrDefaultAsync((int)input.Id);
            
            bool sendIMS_Questionnaire_Update_Status_QuestionnaireUploadedNotification = false;

            if (questionnaire.Status != QuestionnaireStatus.UploadedByClient && input.Status == QuestionnaireStatus.UploadedByClient)
            {
                sendIMS_Questionnaire_Update_Status_QuestionnaireUploadedNotification = true;
            }

            ObjectMapper.Map(input, questionnaire);

            if (sendIMS_Questionnaire_Update_Status_QuestionnaireUploadedNotification)
            {
                await _appNotifier.IMS_Questionnaire_Update_Status_QuestionnaireUploaded(questionnaire);
            }
        }

Thank you in advance for your time and help

Prerequisites

  • What is your product version? v11.3.0
  • What is your product type (Angular or MVC)? MVC
  • What is product framework type (.net framework or .net core)? .net core

Hi,

I use notificationPublisher to send a notification to all users using the below code and it works for the web application. await _notificationPublisher.PublishAsync(AppNotificationNames.NewIncident, notificationData,severity: NotificationSeverity.Warn);

But when I connect, using signalr, to abpcommonhub in xamarin application (connection established successfully based on https://support.aspnetzero.com/QA/Questions/6841/Push-notification-implementation-in-Xamarin-Mobile-application) and subscribe to above notification message, I cannot receive it with the below hubconnection message subscription code. HubConnection.On(AppNotificationNames.NewIncident, (message) => { Console.WriteLine("TEST"); });

Below is the code of NotificationService in Xamarin application.

public class NotificationService : ISingletonDependency, INotificationService { public HubConnection HubConnection { get; }

private readonly IAccessTokenManager _accessTokenManager;
private bool _isConnecting;

public NotificationService(IAccessTokenManager accessTokenManager)
{
    try
    {
        _accessTokenManager = accessTokenManager;

        HubConnection = new HubConnectionBuilder()
            .WithUrl(CreateHubUrl(),

            (opts) =>
                {
                    opts.HttpMessageHandlerFactory = (message) =>
                    {
                        if (message is HttpClientHandler clientHandler)
                            // bypass SSL certificate
                            clientHandler.ServerCertificateCustomValidationCallback +=
                                (sender, certificate, chain, sslPolicyErrors) => { return true; };
                        return message;
                    };
                }
            )
            .ConfigureLogging(logging => {
                logging.SetMinimumLevel(LogLevel.Debug);
                logging.AddConsole();
                logging.AddDebug();
            })
            .Build();


        HubConnection.On<string>(AppNotificationNames.NewIncident, (message) =>
        {
            Console.WriteLine("TEST");
        });


        HubConnection.Closed += TryToConnectIfNeeds;

        ConnectAsync().ConfigureAwait(true);
    }
    catch (Exception ex)
    {
        ExceptionHandler.LogException(ex);
    }
}

private async Task TryToConnectIfNeeds(Exception connectionException)
{
    try
    {
        ExceptionHandler.LogException(connectionException);

        if (!_accessTokenManager.IsUserLoggedIn)
        {
            return;
        }

        await Task.Delay(new Random().Next(0, 5) * 1000);
        await HubConnection.StartAsync();
    }
    catch (Exception ex)
    {
        ExceptionHandler.LogException(ex);
    }
}

public async Task<bool> ConnectAsync()
{
    try
    {
        if (HubConnection.State == HubConnectionState.Connected)
        {
            return true;
        }

        if (_isConnecting)
        {
            return false;
        }

        _isConnecting = true;

        await HubConnection.StartAsync();

        Console.WriteLine(@"Connected!");
        return true;
    }
    catch (Exception ex)
    {
        ExceptionHandler.LogException(ex);
        return false;
    }
    finally
    {
        _isConnecting = false;
    }
}


public async Task<bool> DisconnectAsync()
{
    try
    {
        if (HubConnection.State == HubConnectionState.Disconnected)
        {
            return true;
        }

        await HubConnection.StopAsync();

        Console.WriteLine(@"Disconnected!");
        return true;
    }
    catch (Exception ex)
    {
        ExceptionHandler.LogException(ex);
        return false;
    }
}

private string CreateHubUrl()
{
    string accessToken = _accessTokenManager.AuthenticateResult.EncryptedAccessToken;
    return ApiUrlConfig.BaseUrl +
           AppConsts.SignalRAbpCommonHubPath.TrimStart('/')
           + "?" +
           AppConsts.EncryptedAuthTokenQueryStringName + "=" +
           Uri.EscapeDataString(accessToken);
}

}`

Could you please help me?
Thank you in advance!

Hi,

I start Web.Host from Visual Studio with Mobile profile, but I tried the bat file also. The CreateHubUrl result is https://10.0.2.2:44301/signalr?enc_auth_token=Jqd586PETXlUKqd7js8a6xjlbaFHQkj%2F9v3QPtCkH%2BS9y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uq7CqeRhT4s3sk6%2B6OiAtK3ZD2ZoXlcicnW3sTffFRAt0tz8vw4bDEH4atH1BgxM7tx0Ifk5LRVtXpvIn837fNts4Zcr7xva3Yc1pJstqenV7dZuDhQQJi01CIO%2F8HdZieo%2FSh11MxjG6%2BfhSjJoXT5ZpmVf7NScBmvLNskh22j12ubNlyUDcIlBwUPj8G1FAS8e3MotNdAZ9oln%2BqxeE%2F7K0kuUSdU8kq9N5ZZd8Vx3m9OLi%2BobRZ5acVpT3TvtJMA2DNf9OGvC6y4eTrN9n3YoIMqvu8593mcW5fTIEgH7OjJV6UBoqH2c%2BjiNi1ZZsK9o6KlESd8i4v8C2DF52mBlTIG0tYkXI5KRom9ADo%2Bg%2F%2BGsCAiJPOHedlOBRsro%2BQ3iV6tjbgad2LwF2azWYCQBdmwSk3UJFpeHUc6cUvhMcy0BJ5tKE

and from Web.Host Logs I get DEBUG 2022-11-09 09:16:49,918 [29 ] Abp.AspNetCore.SignalR.Hubs.AbpCommonHub - A client is connected: {"ConnectionId":"OT1w2usalDZHMcb4OoyyCQ","IpAddress":"127.0.0.1","TenantId":1,"UserId":3,"ConnectTime":"2022-11-09T09:16:49.9163277+02:00","Properties":{}}

I send the notification using the below function in AppNotifier when I create a new object

    public async Task NewIncidentAsync(Incident incident)
    {
        var notificationData = new MessageNotificationData("New " + incident.Criticality.ToString() + " " + 
            incident.Type.ToString() + " incident:" + incident.Description);

        notificationData["description"] = incident.Description;
        notificationData["type"] = incident.Type.ToString();
        notificationData["critical"] = incident.Criticality.ToString();
        notificationData["lat"] = incident.Latitude;
        notificationData["lon"] = incident.Longitude;
        notificationData["id"] = incident.Id;

        await _notificationPublisher.PublishAsync(AppNotificationNames.NewIncident, notificationData,severity: NotificationSeverity.Warn);
    }

but maybe I do something wrong in message subscription code.

HubConnection.On<string>(AppNotificationNames.NewIncident, (message) => { Console.WriteLine("TEST"); });

Thank you!

Hi,

I have not change anything else about hub configuration. In Web.Host Startup.cs I have the default code. app.UseEndpoints(endpoints => { endpoints.MapHub<AbpCommonHub>("/signalr"); endpoints.MapHub<ChatHub>("/signalr-chat"); ... I may not have understood something correctly about how Notifications work. I have not implemented a separate hub. Do the notifications send a message to the AbpCommonHub signalr hub? If there was a sample or some code on how i can get them in xamarin application that would be great.

Thank you!

Hi,

I created a new separate hub with a new signalr communicator similar to SignalRChatCommunicator. I modified the Startup with the new endpoint of the new hub. Also I created a new console application in order to test the code and subscribe to then event of the new hub. I manage to connect to the new hub (I checked the log for the connection id) running Host in Mobile profile but I cannot get the message.

I send a message to all clients of the hub using the code below await _incHub.Clients.All.SendAsync("getIncidentMessage", "test");

The code of the console application is `var hubConnection = new HubConnectionBuilder() .WithUrl("https://localhost:44301/inchub", (opts) => { opts.HttpMessageHandlerFactory = (message) => { if (message is HttpClientHandler clientHandler) // bypass SSL certificate clientHandler.ServerCertificateCustomValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; }; return message; }; } ) .Build();

hubConnection.On("getMessage", message => Console.WriteLine(message)); hubConnection.On("getIncidentMessage", message => Console.WriteLine(message)); hubConnection.On("App.NewIncident", message => Console.WriteLine(message)); hubConnection.StartAsync().Wait();`

Could you please provide a sample code like the code above that works with any message in default hub or chathub of the asp.net zero. If I had the implementation in Xamarin would be perfect.

I cannot find a solution that works.

Thank you one more time for your help.

Hi m.aliozkaya,

Thank you very much for your help and your code.

I used the chathub and your code and I managed to send a message from xamarin to web mvc application and at the same time the On<ChatMessageDto> was called when I sent the message from Xamarin.

But when I send a chat message from the mvc web application then the xamarin application does not receive it. On web mvc application I can send a chat message from one user to another.

Please note that I do not use Angular but MVC.

Any help would be appreciated. Thank you once more!

Showing 1 to 10 of 15 entries