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

Activities of "OriAssurant"

I separate host and tenant databases and inherit AbpDbContext for tenant databases.

When seeding data, I'm using var user1 = _dbcontext.Users().Any(u=>u.UserName = ***) to identify if a user exists.

But I could not get any result from _dbcontext.Users().Any() even though there are records in the database. This causes duplicate data to be seeded if I run migrator multiple times.

I've tried set current unitofwork to either disable tenant filter or settenant to the target tenant's Id but still couldn't make it work:

_context.CurrentUnitOfWorkProvider.Current.DisableFilter(AbpDataFilters.MayHaveTenant);
_context.CurrentUnitOfWorkProvider.Current.Settenant(2);

Any idea why the normal Linq query doesn't work in this case?

Thank you,

I am trying to map 2 complex object in CustomDtoMapper and unable to do it because the second mapping, does not seem to work.

Second Mapping to EntityLine from DtoInputEntity results in null values. none of the values get assigned.

Here is my CustomDtoMapper class:

internal static class CustomDtoMapper { private static volatile bool _mappedBefore; private static readonly object SyncObj = new object();

    public static void CreateMappings(IMapperConfigurationExpression mapper)
    {
        lock (SyncObj)
        {
            if (_mappedBefore)
            {
                return;
            }

            CreateMappingsInternal(mapper);              

            _mappedBefore = true;
        }
    }
          

    private static void CreateMappingsInternal(IMapperConfigurationExpression mapper)
    {
        mapper.CreateMap<User, UserEditDto>()
            .ForMember(dto => dto.Password, options => options.Ignore())
            .ReverseMap()
            .ForMember(user => user.Password, options => options.Ignore());
   
        
        mapper.CreateMap<DtoInputEntity, Entity>()
              .ForMember(entityCreateDto => entityCreateDto.OrderNumber,
                        dtoInputEntity => dtoInputEntity.MapFrom(input => input.Response.OrderNumber))
              .ForMember(entityCreateDto => entityCreateDto.ShipmentNumber,
                        dtoInputEntity => dtoInputEntity.MapFrom(input => input.Response.ShipmentNumber));
            
        mapper.CreateMap<DtoInputEntity, EntityLine>()
           .ForPath(entityLineCreateDto => entityLineCreateDto.ExternalModelIdentifier, opt => opt.MapFrom(dtoInputEntity => dtoInputEntity.Response.UTModelIdentifier))
           .ForPath(entityLineCreateDto => entityLineCreateDto.SKU, opt => opt.MapFrom(dtoInputEntity => dtoInputEntity.Response.ModelIdentifier))
           .ForPath(entityLineCreateDto => entityLineCreateDto.ShipmentNumber, opt => opt.MapFrom(dtoInputEntity => dtoInputEntity.Response.ShipmentNumber))
           .ForPath(entityLineCreateDto => entityLineCreateDto.LineNumber, opt => opt.MapFrom(dtoInputEntity => dtoInputEntity.Response.LineNumber));
        
    }
}

We're using AngularJS+MVC5.*. Is there a way to modify the abp.sweet-alert.js to show close button on the pop-up modal?

For example: swal({ title: "Are you sure?", text: "Test message?", type: "info", showCancelButton: true, focusConfirm: false, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes", cancelButtonText: "No", showCloseButton: true }, function (isConfirm) {})

Thank you :ugeek: !

I am using ITypeConvertor in the WebAPI project of Majestic. I had to add it as a dependency in the WebAPIModule class. Configuration.Modules.AbpAutoMapper().Configurators.Add(mapper => { TrackerMapper.CreateMappings(mapper); });

Now, I am trying to write test cases for the classes written in WebAPI project. But, I am getting this error during test cases:

The mapper initializations in webApi aren’t invoked from test module, as it is throwing the following error: System.InvalidOperationException : Mapper not initialized. Call Initialize with appropriate configuration. If you are trying to use mapper instances through a container or otherwise, make sure you do not have any calls to the static Mapper.Map methods, and if you're using ProjectTo or UseAsDataSource extension methods, make sure you pass in the appropriate IConfigurationProvider instance.

I have added the depends on attribute to the module as below. Which does not seem to help. Adding the tag DependsOn(typeof(MajesticWebApiModule) in TestModule class

Will appreciate inputs on why I am not able to using ITypeConvertor in the Test project.

My project is MVC 5.* and AngularJS. I'm using multi-tenancy structure with one host database and multiple tenant databases.

When we're calling the app.services in angularJS module, I see abp is using IApplicationService to identify AngularJS services. I guess IApplicationService is leveraging abpsession.TenantId information to find the correct database. But even if I set the connectionstring in abptenants table to null and add the tenant connectionstring to web.config, app.services is still able to perform CRUB on correct database. I suspect that IApplicationService is selecting database based on the order of connectionstring in web.config.

Anyway, this part confuses me as lot. Could anyone please explain or provide some material?

Thank you,

I use MVC5.* + AngularJS and enabled multitenancy for the project. I separate out host database and tenant databases, keeping all tenant users in the host database and only using tenant database for application services.

So I hope that the workflow of login process would be: find user --> get user.tenantId -> find the connectionstring of the tenant -> route all app.services to the tenant database.

But seems there is an auto-filter on the tenant when I'm logging in. Suppose I'm trying to find a user who belongs to tenant 2 with either UserManager or HostDbContext, the query will automatically filter user by tenant = null as I didn't set UnitOfWorkManager.Current.SetTenantId before I search for the user. If I hard code UnitOfWorkManager.Current.SetTenantId to be 2 before I search, then I'm able to find the user.

var ur = await _userManager.Users.Where(u => u.PhoneNumber == model.MobilePhone).FirstOrDefaultAsync();

or

var hostDbContext = new HostDbContext();
                SqlParameter param = new SqlParameter()
                {
                    ParameterName = "@UserID",
                    SqlDbType = SqlDbType.BigInt,
                    Direction = ParameterDirection.Output
                };
                var t = hostDbContext.Database.ExecuteSqlCommand("select top 1 tenantId from abpusers where id = @UserID", param);

Could anyone give some hint on the way to find the user before I set the tenantId in UnitOfWorkManager?

Thank you,

I am creating two tables: OrganizationUnitType - containing Id and Name OrganizationUnitDetails - containing more information about OrganizationUnitTable.

In .Core Project, I have create a new class called OrganizationUnitType : [Table("OrganizationUnitType")] public class OrganizationUnitType : Entity {

    [Key]
    public override  int Id { get; set; }

    public virtual string Name { get; set; }

public OrganizationUnitType() {

    }

    public OrganizationUnitType(string _name)
    {
        Name = _name;           
    }
}

}

And seeding the Data for the same after creating IDBSet in a new file under Tenants folder like below:

public class OrganizationUnitTypeCreator { private readonly MajesticDbContext _context; public OrganizationUnitTypeCreator() {

    }
    public OrganizationUnitTypeCreator(MajesticDbContext context)
    {
        _context = context;
    }

    public void Create()
    {
        var organizationUnitType1 = _context.OrganizationUnitTypes.FirstOrDefault(p => p.Name == "Door");
        if (organizationUnitType1 == null)
        {
            _context.OrganizationUnitTypes.Add(
                new OrganizationUnitType
                {
                    Name = "ABC"
                });
        }
        _context.SaveChanges();}}

I have also added a MigrationHistory file Up() methodwith the below data to create my second table: - OrganizationUnitDetails

CreateTable( "dbo.OrganizationUnitDetail", c => new { Id = c.Long(nullable: false, identity: true), OrganizationUnitId = c.Long(), OrganizationUnitTypeID = c.Int(),
StreetAddress1 = c.String(nullable: false, maxLength: 256), StreetAddress2 = c.String(nullable: true, maxLength: 256), City = c.String(nullable: false, maxLength: 256), State = c.String(nullable: false, maxLength: 256), PostalCode = c.String(nullable: false, maxLength: 256)
}) .PrimaryKey(t => t.Id) .ForeignKey("dbo.AbpOrganizationUnits", t => t.OrganizationUnitId, cascadeDelete: true) .ForeignKey("dbo.OrganizationUnitType", t => t.OrganizationUnitTypeID, cascadeDelete: true);

After doing the above things - when I try to run the update command I am getting this error:

Column 'dbo.OrganizationUnitType.Id' is not the same data type as referencing column 'PermissionOrganizationUnitType.OrganizationUnitTypeId' in foreign key 'FK_dbo.PermissionOrganizationUnitType_dbo.OrganizationUnitType_OrganizationUnitTypeId'. Could not create constraint. See previous errors.

I don't quite understand because the data type I have specified in class for OrganizationUnitType is same as the foreign key specified in migration history file.

Can someone please point me in the right direction?

I have a kendoui grid in .Web project and App/ folder as index.cshtml

From index.js when I attempt to make a call to the web api. (Web API which was automatically created by ASP Net Zero after implementing DI)

The service is called CartService and below is the method I am trying to access:

    public PagedResultDto<ShoppingCartListDto> GetCartData()
    {
  }

The error I am getting is :

{"message":"An error has occurred.","exceptionMessage":"There is an action GetCartData defined for api controller app/shoppingCartService but with a different HTTP Verb. Request verb is GET. It should be Post","exceptionType":"System.Web.HttpException","stackTrace":" at Abp.WebApi.Controllers.Dynamic.Selectors.AbpApiControllerActionSelector.GetActionDescriptorByActionName(HttpControllerContext controllerContext, DynamicApiControllerInfo controllerInfo, String actionName)\r\n at Abp.WebApi.Controllers.Dynamic.Selectors.AbpApiControllerActionSelector.SelectAction(HttpControllerContext controllerContext)\r\n at System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)\r\n at Castle.Proxies.DynamicApiController1Proxy_3.ExecuteAsync_callback(HttpControllerContext controllerContext, CancellationToken cancellationToken)\r\n at Castle.Proxies.Invocations.ApiController_ExecuteAsync_3.InvokeMethodOnTarget()\r\n at Castle.DynamicProxy.AbstractInvocation.Proceed()\r\n at Abp.WebApi.Controllers.Dynamic.Interceptors.AbpDynamicApiControllerInterceptor1.Intercept(IInvocation invocation)\r\n at Castle.DynamicProxy.AbstractInvocation.Proceed()\r\n at Castle.Proxies.DynamicApiController`1Proxy_3.ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.

I understand that the problem here is to specify the method as GET. But, how do I do that in ASP NET Zero class?

We want to show a ASPNetZero theme based popup to the user to get confirmation before deleting a particular record from the grid.

Could someone please help in pointing me to an example for the same?

Hi,

When we were using the SPA (MVC & jQuery) we had access to a WebAPI Controller.

When we migrated (mostly everything) to SPA solution, everything works and builds, except now we can't hit the custom controller we built in the WebAPI proj.

This is the error from hitting the Controller w/valid input: {"message":"An error has occurred."}

Here is what it looks like, more or less:

public class nameOfController : MajesticApiControllerBase
    {
        public nameOfController()
        {
        }

        [HttpGet, ActionName("CheckIfSIM")]
        public IHttpActionResult nameOfController(string value)
        {
        }
}

I also want to mention that it vanished from Swagger.

Thanks for the help.

Showing 41 to 50 of 60 entries