Base solution for your next web application

Activities of "giel83"

Hey ismcagdas,

Thanks a lot :). This works great!

Greetings,

<cite>ismcagdas: </cite> Hi,

Can you share your second DbContext definition ?

Thanks.

Hey, thanks for your response and sorry for the slow reply!

My second DB Context looks as following:

public class SecondDbContext : AbpDbContext
    {
        public virtual DbSet<tblRelatie> tblRelatie { get; set; }


        public SecondDbContext(DbContextOptions<SecondDbContext> options)
            : base(options)
        {
        }
    }

Hello,

For a client of ours I need to target a few databases to extract and insert information. Now, I've tried creating the following classes in the EntityFrameworkCore project:

  • SecondDbContext.cs
  • SecondDbContextConfigurer.cs
  • SecondDbContextFactory.cs

I've also added the following in the Preinitialize() of the FirstInterfaceEntityFrameworkCoreModule.cs:

//add linkedin robot db context
                Configuration.Modules.AbpEfCore().AddDbContext<SecondDbContext>(configuration =>
                {
                    SecondDbContextConfigurer.Configure(configuration.DbContextOptions, configuration.ConnectionString);
                });

But for some reason when I try to use an appservice for the second database, it says table not found because it is trying to connect with the first database.

I'm not sure what i'm doing wrong here? :( Thanks in advance!

Answer

Thanks, works like a charm :).

For others, this is what I did exactly:

Added the following class to MpaNavigationProvider.cs

public static class UserMenuItemExtensions
    {
        public static bool IsMenuActive(this UserMenuItem menuItem, string currentPageName)
        {
            if (menuItem.Name == currentPageName)
            {
                return true;
            }

            if (menuItem.Items != null)
            {
                foreach (var subMenuItem in menuItem.Items)
                {
                    if (subMenuItem.IsMenuActive(currentPageName))
                    {
                        return true;
                    }
                }
            }

            return false;
        }
    }

Updated _sidebar.cshtml

From

<div class="page-sidebar navbar-collapse collapse">
    
    
    
    
    
    
    <ul class="page-sidebar-menu" data-keep-expanded="false" data-auto-scroll="true" data-slide-speed="200">
        @for (var i = 0; i < Model.Menu.Items.Count; i++)
        {
            var menuItem = Model.Menu.Items[i];
            var isActive = Model.CurrentPageName == menuItem.Name ||
                           (!menuItem.Items.IsNullOrEmpty() && menuItem.Items.Any(item => item.Name == Model.CurrentPageName));
                <li class="@(i==0 ? "start" : "") @(isActive ? "active" : "")">
                @if (menuItem.Items.IsNullOrEmpty())
                {
                    <a href="@calculateMenuUrl(menuItem.Url)">
                        <i class="@menuItem.Icon"></i>
                        <span class="title">@menuItem.DisplayName</span>
                    </a>
                }
                else
                {
                    <a href="javascript:;" class="auto">
                        <i class="@menuItem.Icon"></i>
                        <span class="title">@menuItem.DisplayName</span>
                        <span class="arrow"></span>
                    </a>
                    <ul class="sub-menu">
                        @foreach (var childMenuItem in menuItem.Items)
                        {
                                <li class="@(Model.CurrentPageName == childMenuItem.Name ? "active" : "")">
                                @if (childMenuItem.Items.IsNullOrEmpty())
                                {
                                    <a href="@calculateMenuUrl(childMenuItem.Url)">
                                        <span><i class="sub-menu-icon @childMenuItem.Icon"></i> @childMenuItem.DisplayName</span>
                                    </a>
                                }
                                else
                                {
                                    <a href="javascript:;" class="auto">
                                        <i class="@childMenuItem.Icon"></i>
                                        <span class="title">@childMenuItem.DisplayName</span>
                                        <span class="arrow"></span>
                                    </a>
                                    <ul class="sub-menu">
                                        @foreach (var secondLevelChildMenuItem in childMenuItem.Items)
                                        {
                                                <li class="@(Model.CurrentPageName == secondLevelChildMenuItem.Name ? "active" : "")">
                                                <a href="@calculateMenuUrl(secondLevelChildMenuItem.Url)">
                                                    <span><i class="sub-menu-icon @secondLevelChildMenuItem.Icon"></i> @secondLevelChildMenuItem.DisplayName</span>
                                                </a>
                                            </li>
                                        }
                                    </ul>
                                }
                            </li>
                        }
                    </ul>
                }
            </li>
        }
    </ul>
</div>

To

<div class="page-sidebar navbar-collapse collapse">
    
    
    
    
    
    
    <ul class="page-sidebar-menu" data-keep-expanded="false" data-auto-scroll="true" data-slide-speed="200">
        @for (var i = 0; i < Model.Menu.Items.Count; i++)
        {
            var menuItem = Model.Menu.Items[i];
            var isActive = Model.CurrentPageName == menuItem.Name ||
                           (!menuItem.Items.IsNullOrEmpty() && menuItem.Items.Any(item => item.Name == Model.CurrentPageName));
            <li class="@(i==0 ? "start" : "") @(menuItem.IsMenuActive(Model.CurrentPageName) ? "active" : "")">
                @*<li class="@(i==0 ? "start" : "") @(isActive ? "active" : "")">*@
                @if (menuItem.Items.IsNullOrEmpty())
                {
                    <a href="@calculateMenuUrl(menuItem.Url)">
                        <i class="@menuItem.Icon"></i>
                        <span class="title">@menuItem.DisplayName</span>
                    </a>
                }
                else
                {
                    <a href="javascript:;" class="auto">
                        <i class="@menuItem.Icon"></i>
                        <span class="title">@menuItem.DisplayName</span>
                        <span class="arrow"></span>
                    </a>
                    <ul class="sub-menu">
                        @foreach (var childMenuItem in menuItem.Items)
                        {
                            <li class="@(childMenuItem.IsMenuActive(Model.CurrentPageName) ? "active" : "")">
                                @*<li class="@(Model.CurrentPageName == childMenuItem.Name ? "active" : "")">*@
                                @if (childMenuItem.Items.IsNullOrEmpty())
                                {
                                    <a href="@calculateMenuUrl(childMenuItem.Url)">
                                        <span><i class="sub-menu-icon @childMenuItem.Icon"></i> @childMenuItem.DisplayName</span>
                                    </a>
                                }
                                else
                                {
                                    <a href="javascript:;" class="auto">
                                        <i class="@childMenuItem.Icon"></i>
                                        <span class="title">@childMenuItem.DisplayName</span>
                                        <span class="arrow"></span>
                                    </a>
                                    <ul class="sub-menu">
                                        @foreach (var secondLevelChildMenuItem in childMenuItem.Items)
                                        {
                                            <li class="@(secondLevelChildMenuItem.IsMenuActive(Model.CurrentPageName) ? "active" : "")">
                                                @*<li class="@(Model.CurrentPageName == secondLevelChildMenuItem.Name ? "active" : "")">*@
                                                <a href="@calculateMenuUrl(secondLevelChildMenuItem.Url)">
                                                    <span><i class="sub-menu-icon @secondLevelChildMenuItem.Icon"></i> @secondLevelChildMenuItem.DisplayName</span>
                                                </a>
                                            </li>
                                        }
                                    </ul>
                                }
                            </li>
                        }
                    </ul>
                }
            </li>
        }
    </ul>

</div>
Question

Hi!

I am creating a menu-tree, which looks as following: Menu A -> Submenu A -> Submenu item A -> Submenu item B

Now, when I click on submenu item A or B, the entire menu tree closes. I want the tree to stay opened when I click on Submenu item A or B. I think I'm doing something wrong in the MpaNavigationProvider and PageNames class. But i'm not sure what is going wrong there.

(P.S, it's a MPA project)

Help is much appreciated! Thanks :)

Yes, here it is!

[AbpAuthorize(AppPermissions.Pages_Administration_Users_Edit)] protected virtual async Task UpdateUserAsync(CreateOrUpdateUserInput input) { Debug.Assert(input.User.Id != null, "input.User.Id should be set.");

        var user = await UserManager.FindByIdAsync(input.User.Id.Value);

        //Update user properties
        input.User.MapTo(user); //Passwords is not mapped (see mapping configuration)

        if (!input.User.Password.IsNullOrEmpty())
        {
            CheckErrors(await UserManager.ChangePasswordAsync(user, input.User.Password));
        }

        CheckErrors(await UserManager.UpdateAsync(user));
        try {
            //Update roles
            CheckErrors(await UserManager.SetRoles(user, input.AssignedRoleNames));

            await UserManager.SetRoles(user, input.AssignedRoleNames);
            if (input.SendActivationEmail)
            {
                user.SetNewEmailConfirmationCode();
                await _userEmailer.SendEmailActivationLinkAsync(user, input.User.Password);
            }
        }catch(Exception ex)
        {
            throw ex.InnerException;
        }
    }

Btw, the CheckErrors method for update roles is the first line that throws the error

Hi,

I can't get the dto because it's somewhere in the boilerplate dll's, I haven't touched those. So when this is executed: var user = await UserManager.FindByIdAsync(input.User.Id.Value); the roles in user are indeed empty, but I can't have a good look at the FindByIdAsync method.

Thanks

Hi,

This is everything of the stacktrace I can get

StackTrace = " at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)\r\n at Abp.Authorization.Users.AbpUserManager3.<SetRoles>d__7e.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.Compiler...

Thanks

Hi,

I'm using ABP 0.83 (I think) with asp net zero and I'm getting an error when I'm trying to edit a user. The error is thrown at the UserAppService.cs: await UserManager.SetRoles(user, input.AssignedRoleNames); It cannot save the roles and the following error occurs:

Value cannot be null.\r\nParameter name: source

Attached are the properties of the user, and the assignedRoleNames are also filled properly (at least that is what it looks like)

Any idea what's going wrong and how to solve this?

Thanks

Anyone? Still struggling with this issue....

Showing 1 to 10 of 11 entries