Base solution for your next web application

Activities of "rafalpiotrowski"

I just found this related issue: https://support.aspnetzero.com/QA/Questions/7490

it worked for me!

Hi I have just recently updated to version 7.2.2 from 6.5 and when starting Web.Host I am getting Swagger exception. It say that Element with the same key already exists! How can I debug/findout which Element it is?

INFO  2019-09-28 22:14:32,691 [9    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:22742/Ui  
WARN  2019-09-28 22:14:32,696 [9    ] calization.RequestLocalizationMiddleware - AbpUserRequestCultureProvider returned the following unsupported cultures 'null'.
WARN  2019-09-28 22:14:32,696 [9    ] calization.RequestLocalizationMiddleware - AbpUserRequestCultureProvider returned the following unsupported UI Cultures 'null'.
INFO  2019-09-28 22:14:32,697 [9    ] ft.AspNetCore.Routing.EndpointMiddleware - Executing endpoint 'MyAspNetZeroApplication.Web.Controllers.UiController.Index (MyAspNetZeroApplication.Web.Host)'
INFO  2019-09-28 22:14:32,704 [9    ] ore.Mvc.Internal.ControllerActionInvoker - Route matched with {action = "Index", controller = "Ui", area = ""}. Executing action MyAspNetZeroApplication.Web.Controllers.UiController.Index (MyAspNetZeroApplication.Web.Host)
INFO  2019-09-28 22:14:33,746 [9    ] ore.Mvc.Internal.ControllerActionInvoker - Executing action method MyAspNetZeroApplication.Web.Controllers.UiController.Index (MyAspNetZeroApplication.Web.Host) - Validation state: Valid
INFO  2019-09-28 22:14:34,204 [3    ] ore.Mvc.Internal.ControllerActionInvoker - Executed action method MyAspNetZeroApplication.Web.Controllers.UiController.Index (MyAspNetZeroApplication.Web.Host), returned result Microsoft.AspNetCore.Mvc.ViewResult in 458.5404ms.
INFO  2019-09-28 22:14:34,253 [3    ] Core.Mvc.ViewFeatures.ViewResultExecutor - Executing ViewResult, running view Index.
INFO  2019-09-28 22:14:34,356 [3    ] Core.Mvc.ViewFeatures.ViewResultExecutor - Executed ViewResult - view Index executed in 144.4864ms.
INFO  2019-09-28 22:14:34,356 [3    ] ore.Mvc.Internal.ControllerActionInvoker - Executed action MyAspNetZeroApplication.Web.Controllers.UiController.Index (MyAspNetZeroApplication.Web.Host) in 1652.133ms
INFO  2019-09-28 22:14:34,356 [3    ] ft.AspNetCore.Routing.EndpointMiddleware - Executed endpoint 'MyAspNetZeroApplication.Web.Controllers.UiController.Index (MyAspNetZeroApplication.Web.Host)'
INFO  2019-09-28 22:14:34,359 [3    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 1667.7219ms 200 text/html; charset=utf-8
INFO  2019-09-28 22:14:37,323 [12   ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:22742/swagger/index.html  
WARN  2019-09-28 22:14:37,329 [12   ] calization.RequestLocalizationMiddleware - AbpUserRequestCultureProvider returned the following unsupported cultures 'null'.
WARN  2019-09-28 22:14:37,329 [12   ] calization.RequestLocalizationMiddleware - AbpUserRequestCultureProvider returned the following unsupported UI Cultures 'null'.
INFO  2019-09-28 22:14:37,501 [12   ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 178.4679ms 200 text/html
INFO  2019-09-28 22:14:37,729 [3    ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:22742/swagger/v1/swagger.json  
WARN  2019-09-28 22:14:37,733 [3    ] calization.RequestLocalizationMiddleware - AbpUserRequestCultureProvider returned the following unsupported cultures 'null'.
WARN  2019-09-28 22:14:37,733 [3    ] calization.RequestLocalizationMiddleware - AbpUserRequestCultureProvider returned the following unsupported UI Cultures 'null'.
ERROR 2019-09-28 22:14:38,330 [3    ] nostics.DeveloperExceptionPageMiddleware - An unhandled exception has occurred while executing the request.
System.ArgumentException: Element o tym samym kluczu zosta³ ju¿ dodany.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at MyAspNetZeroApplication.Web.Swagger.SwaggerOperationFilter.Apply(Operation operation, OperationFilterContext context)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreateOperation(ApiDescription apiDescription, ISchemaRegistry schemaRegistry)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreatePathItem(IEnumerable`1 apiDescriptions, ISchemaRegistry schemaRegistry)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.<>c__DisplayClass6_0.<CreatePathItems>b__2(IGrouping`2 group)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreatePathItems(IEnumerable`1 apiDescriptions, ISchemaRegistry schemaRegistry)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath, String[] schemes)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.<Invoke>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.<Invoke>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.AspNetZeroCore.Web.Authentication.JwtBearer.JwtTokenMiddleware.<>c__DisplayClass0_0.<<UseJwtTokenMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
INFO  2019-09-28 22:14:38,454 [3    ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 725.5123ms 500 text/html; charset=utf-8

OK solved the problem.

The whole chain of classes has to be marked Audited or DisableAuditing in order for the EntityHistory to work

Hi, I have updated User entity to have an address. When I update the address or create user I get NullReferenceException in the Abp.ZeroCore.EntityFrameworkCore.dll when executing CheckErrors(await UserManager.UpdateAsync(user)); from UserAppService

When I change anything else in the User (standard properties) and do not change the user I get not errors! Happens only when I change my extended User properties

Also the HomeAddress is not null not the properties in the instance of HomeAddress

Here is how the User class looks like:

    /// <summary>
    /// Represents a user in the system.
    /// </summary>
    public class User : AbpUser<User>
    {
        public virtual Guid? ProfilePictureId { get; set; }

        public virtual bool ShouldChangePasswordOnNextLogin { get; set; }

        public DateTime? SignInTokenExpireTimeUtc { get; set; }

        public string SignInToken { get; set; }

        public string GoogleAuthenticatorKey { get; set; }

        //Can add application specific user properties here

        public PlasticsTrader.Crm.Address HomeAddress { get; set; }

        public User()
        {
            IsLockoutEnabled = true;
            IsTwoFactorEnabled = true;
        }

        /// <summary>
        /// Creates admin <see cref="User"/> for a tenant.
        /// </summary>
        /// <param name="tenantId">Tenant Id</param>
        /// <param name="emailAddress">Email address</param>
        /// <returns>Created <see cref="User"/> object</returns>
        public static User CreateTenantAdminUser(int tenantId, string emailAddress)
        {
            var user = new User
            {
                TenantId = tenantId,
                UserName = AdminUserName,
                Name = AdminUserName,
                Surname = AdminUserName,
                EmailAddress = emailAddress,
                HomeAddress = new Crm.Address()
            };

            user.SetNormalizedNames();

            return user;
        }

        public static string CreateRandomPassword()
        {
            return Guid.NewGuid().ToString("N").Truncate(16);
        }

        public override void SetNewPasswordResetCode()
        {
            /* This reset code is intentionally kept short.
             * It should be short and easy to enter in a mobile application, where user can not click a link.
             */
            PasswordResetCode = Guid.NewGuid().ToString("N").Truncate(10).ToUpperInvariant();
        }

        public void Unlock()
        {
            AccessFailedCount = 0;
            LockoutEndDateUtc = null;
        }

        public void SetSignInToken()
        {
            SignInToken = Guid.NewGuid().ToString();
            SignInTokenExpireTimeUtc = Clock.Now.AddMinutes(1).ToUniversalTime();
        }

When I disable the EntityHistory Configuration.EntityHistory.IsEnabled = false; it works

I tried to have it enable but to put

 [DisableAuditing]
        public PlasticsTrader.Crm.Address HomeAddress { get; set; }

still does not work!

removed all migrations and run

  1. Add-Migration InitialCreate
  2. changed first entry in __EFMigrationsHistory MigrationId = 20190130234948_InitialCreate and ProductVersion to the one from XXXDbContextModelSnaphot
  3. removed all other entried in the __EFMigrationsHistory table except the first one that we changed

not Add-Migration works and can add new migrations

Hi, I try to add migration to EF and get null pointer exception

How can I debug the process?

PM> Add-Migration "Added_xxx" -Context xxxDbContext
Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework\Add-Migration' for Entity Framework 6.
System.NullReferenceException: Odwołanie do obiektu nie zostało ustawione na wystąpienie obiektu.
   w Microsoft.EntityFrameworkCore.Update.Internal.SharedTableEntryMap`1.CreateSharedTableEntryMapFactory(IReadOnlyList`1 entityTypes, IStateManager stateManager, String tableName, String schema)
   w Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.DiffData(TableMapping source, TableMapping target, DiffContext diffContext)
   w Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.<Diff>d__35.MoveNext()
   w Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.<DiffCollection>d__73`1.MoveNext()
   w System.Linq.Enumerable.&lt;ConcatIterator&gt;d__59`1.MoveNext()
   w System.Linq.Enumerable.<ConcatIterator>d__59`1.MoveNext()
   w System.Linq.Enumerable.&lt;ConcatIterator&gt;d__59`1.MoveNext()
   w System.Linq.Enumerable.<ConcatIterator>d__59`1.MoveNext()
   w Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.Sort(IEnumerable`1 operations, DiffContext diffContext)
   w Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.GetDifferences(IModel source, IModel target)
   w Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.ScaffoldMigration(String migrationName, String rootNamespace, String subNamespace, String language)
   w Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
   w Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
   w Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_1.<.ctor>b__0()
   w Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.&lt;Execute&gt;b__0()
   w Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Odwołanie do obiektu nie zostało ustawione na wystąpienie obiektu.

its closed

Yes we can!

need to installnuget package Hangfire.MySqlStorage in AspNetZeroProject.Web.Core

and in AspNetZeroProject.Web.Host Startup.cs file add this

            services.AddHangfire(config =>
            {
                new MySqlStorage(_appConfiguration.GetConnectionString("Hangfire_MySQL"));
            });
            JobStorage.Current = new MySqlStorage(_appConfiguration.GetConnectionString("Hangfire_MySQL"));

Hi, Is this possible to use MS SQL Server for main "Default" db and another db like MySQL for Hangfire?

Question

Hi, When the background worker (singleton) is executing the method DoWork and it has not finished yet but the time to run it again has come (eg. worker is scheduled to run every 1 min, but the DoWork is taking longer to finish) will it try to execute DoWork again before the first is finished?

regards Rafal

Showing 1 to 10 of 78 entries