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

Activities of "affern"

Question

Hi again guys. I have created a domain class with a composite keys:

    public class MultiAnswer 
    {

        [Key]
        [Column(Order = 1)]
        public long SurveyId { get; set; }
        [Key]
        [Column(Order = 2)]
        public long UserId { get; set; }
     
        [Key]
        [Column(Order = 3)]
        public int ItemId { get; set; }
      
        [Required]       
        public int AnswerId { get; set; }
                       
        public DateTime DateAnswer { get; set; }
        
        [ForeignKey("SurveyId")]
        public virtual Survey Survey { get; set; }

    }

But how do I declare a MultiAnswer Repository with 3 keys? The IRepository is for one primary key.

@ismcagdas Thanks for advice.

@aaron, no I don't have any scripts between the header tags. I have inserted 2 javascript references to InfoLinks manually after the app-root tags. But the rest is registered in angular-cli.

Hello guys.

My Asp.Net Zero solution, https://www.votecha.com has Angular 4 as a client app and run in Azure. But on first time visits the page load very slow.

I have developed a public modul after the same pattern as the account module. In the code the public module is set to lazy load like the account module.

I wonder if you have any tips on how I can reduce "the first visit" response time? Should I try to preload the public module? If so, how can I do this? Or is there other solutions I should try?

I know I can optimize my queries and also use Azure Redis cache, but it is mainly the first visit loading that is the problem.

This is my code in root-routing.module.ts:

import { NgModule } from '@angular/core';
import { Routes, RouterModule, Router, NavigationEnd } from '@angular/router';

const routes: Routes = [
    { path: '', redirectTo: '/app/main/mysite', pathMatch: 'full' },
    {
        path: 'account',
        loadChildren: 'account/account.module#AccountModule', //Lazy load account module
        data: { preload: true }
    },
    {
        path: 'public',
        loadChildren: 'public/public.module#PublicModule', //Lazy load public module
        data: { preload: true }
    }
];

@NgModule({
    imports: [RouterModule.forRoot(routes)],
    exports: [RouterModule],
    providers: []
})
export class RootRoutingModule {
    constructor(private router: Router) {
        router.events.subscribe((event: NavigationEnd) => {
            setTimeout(() => {
                this.toggleBodyCssClass(event.url);
            }, 0);
        });
    }

    toggleBodyCssClass(url: string): void {
        if (url) {

            if (url === '/') {
                if (abp.session.userId > 0) {
                    $('body').attr('class', 'page-md page-header-fixed page-sidebar-closed-hide-logo');
                } else {
                    $('body').attr('class', 'page-md login');
                }
            }

            if (url.indexOf("/account/") >= 0) {
                $('body').attr('class', 'page-md login');
            }
            else if (url.indexOf("/public") >= 0) {
                if (abp.session.userId > 0) {
                    $('body').attr('class', 'page-md page-header-fixed page-sidebar-closed-hide-logo');
                } else {
                    $('body').attr('class', 'page-md login');
                }
            }
            else {
                $('body').attr('class', 'page-md page-header-fixed page-sidebar-closed-hide-logo');
            }
        }
    }
}

Thanks, mate! :-)

Yes. I installed it with Yarn: yarn add owl.carousel jquery

Hello.

I wonder if anyone here using Google Adsense together with AspNetZero? I'm trying to use ng2-adsense (https://www.npmjs.com/package/ng2-adsense) since I have an Angular solution, but I'm not able to get it to work.

Is it ok to put this code in the head tags in the index.html file? <div class="highlight"><pre class="editor editor-colors"><div class="line"><span class="text html"><span class="meta tag any html"><span class="punctuation definition tag html"><span><</span></span><span class="entity name tag html"><span>script</span></span><span> </span><span class="entity other attribute-name html"><span>async</span></span><span> </span><span class="entity other attribute-name html"><span>src</span></span><span>=</span><span class="string unquoted html"><span>//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js</span></span><span class="punctuation definition tag html"><span>></span><span class="meta scope html"><span><</span></span><span>/</span></span><span class="entity name tag html"><span>script</span></span><span class="punctuation definition tag html"><span>></span></span></span></span></div></pre></div>

Hello

I'm trying to install owl-carousel in my solution but I get error message Property 'owlCarousel' does not exist on type 'JQuery'. If i put this code in typings.d.ts: interface JQuery { owlCarousel(...any): any; }

then I get this error: TypeError: owl.owlCarousel is not a function I have this code in my component:

import * as $ from 'jquery'; import 'owl.carousel/dist/assets/owl.carousel.css'; import 'owl.carousel';

export class SiteComponent extends AppComponentBase implements OnInit, AfterViewInit { @ViewChild('owl') owl: ElementRef;

ngAfterViewInit() { $(this.owl.nativeElement).owlCarousel(); }

.angular-cli.json:

"styles": ["../node_modules/owl.carousel/dist/assets/owl.theme.default.css"] "scripts": ["../node_modules/jquery/dist/jquery.js", "../node_modules/owl.carousel/dist/owl.carousel.js" ],

        Any ideas? 

Do you know how to set maxlength on the PrimeNG Editor?

Answer

<cite>aaron: </cite> Show code for your loop.

private void CreateVolumeTestUsers() { var userRoleForUser = _context.Roles.FirstOrDefault(r => r.TenantId == 1 && r.Name == StaticRoleNames.Tenants.User); if (userRoleForUser == null) { userRoleForUser = _context.Roles.Add(new Role(1, StaticRoleNames.Tenants.User, StaticRoleNames.Tenants.User) { IsStatic = true, IsDefault = true }).Entity; _context.SaveChanges(); }

        int testUsers_NOR10000 = 10000;
        var testUserNOR1 = _context.Users.FirstOrDefault(u => u.TenantId == 1 && u.UserName == "[email protected]");
        //var testUserNOR51 = _context.Users.FirstOrDefault(u => u.TenantId == null && u.UserName == "[email protected]");
        if (testUserNOR1 == null)
        {
            for (int i = 1; i &lt; testUsers_NOR10000; i++)
            {
                var testUserName = &quot;TestuserNOR&quot; + i + &quot;@testuser.com&quot;;
                var testUserNOR = _context.Users.FirstOrDefault(u =&gt; u.TenantId == null && u.UserName == testUserName);
                if (testUserNOR == null)
                {
                    var testUser = new User
                    {
                        //UserId = Guid.NewGuid(),
                        TenantId = 1,
                        UserName = "TestuserNOR" + i + "@testuser.com",
                        Name = "TestNOR" + i.ToString(),
                        Surname = "UserNOR" + i.ToString(),
                        CountryId = 3,
                        AreaId = 53,
                        SubAreaId = 425,
                        CityId = 1,
                        BirthYear = 1979,
                        Gender = Model.Common.MySolutionEnums.GenderType.Woman,
                        EmailAddress = "TestuserNOR" + i + "@testuser.com",
                        IsEmailConfirmed = true,
                        ShouldChangePasswordOnNextLogin = false,
                        IsActive = true,
                        Password = "AM4OLBpptxBYmM79lGOX9egzZk3vIQU3d/gFCJzaBjAPXzYIK3tQ2N7X4fcrHtElTw==" //123qwe
                    };

                    if (i % 2 == 0)
                    {
                        testUser.Gender = Model.Common.MySolutionEnums.GenderType.Man;
                        testUser.BirthYear = 1972;
                    }

                    if (i % 4 == 0)
                    {
                        testUser.CityId = 2;
                        testUser.BirthYear = 1988;
                    }

                    testUser.SetNormalizedNames();

                    testUserNOR = _context.Users.Add(testUser).Entity;
                    _context.SaveChanges();

                    _context.UserRoles.Add(new UserRole(null, testUserNOR.Id, userRoleForUser.Id));
                    _context.SaveChanges();

                    //User account of test user
                    _context.UserAccounts.Add(new UserAccount
                    {
                        TenantId = 1,
                        UserId = testUserNOR.Id,
                        UserName = testUserNOR.UserName,
                        EmailAddress = testUserNOR.EmailAddress
                    });

                    _context.SaveChanges();
                }

            }
        }


        int testUsers_US = 2000;
        var testUserUS1 = _context.Users.FirstOrDefault(u => u.TenantId == 1 && u.UserName == "[email protected]");
        if (testUserUS1 == null)
        {
            for (int i = 1; i &lt; testUsers_US; i++)
            {
                var testUserName = &quot;TestuserUS&quot; + i + &quot;@testuser.com&quot;;
                var testUserUS = _context.Users.FirstOrDefault(u =&gt; u.TenantId == null && u.UserName == testUserName);
                if (testUserUS == null)
                {
                    var testUser = new User
                    {
                        //UserId = Guid.NewGuid(),
                        TenantId = 1,
                        UserName = "TestuserUS" + i + "@testuser.com",
                        Name = "TestUS" + i.ToString(),
                        Surname = "UserUS" + i.ToString(),
                        EmailAddress = "TestuserUS" + i + "@testuser.com",
                        CountryId = 1,
                        AreaId = 32,
                        CityId = 15,
                        BirthYear = 1979,
                        Gender = Model.Common.MySolutionEnums.GenderType.Woman,
                        IsEmailConfirmed = true,
                        ShouldChangePasswordOnNextLogin = false,
                        IsActive = true,
                        Password = "AM4OLBpptxBYmM79lGOX9egzZk3vIQU3d/gFCJzaBjAPXzYIK3tQ2N7X4fcrHtElTw==" //123qwe
                    };

                    if (i % 2 == 0)
                    {
                        testUser.Gender = Model.Common.MySolutionEnums.GenderType.Man;
                        testUser.BirthYear = 1982;
                    }

                    if (i % 6 == 0)
                    {
                        testUser.CityId = 16;
                        testUser.AreaId = 5;
                        testUser.BirthYear = 1967;
                    }
                    testUser.SetNormalizedNames();

                    testUserUS = _context.Users.Add(testUser).Entity;
                    _context.SaveChanges();

                    //User account of test user
                    _context.UserAccounts.Add(new UserAccount
                    {
                        TenantId = 1,
                        UserId = testUserUS.Id,
                        UserName = testUserUS.UserName,
                        EmailAddress = testUserUS.EmailAddress
                    });

                    _context.SaveChanges();
                }

            }
        }

        var userRoleForCustomer = _context.Roles.FirstOrDefault(r => r.TenantId == 1 && r.Name == StaticRoleNames.Tenants.CustomerContact);
        if (userRoleForCustomer == null)
        {
            userRoleForCustomer = _context.Roles.Add(new Role(1, StaticRoleNames.Tenants.CustomerContact, StaticRoleNames.Tenants.CustomerContact) { IsStatic = true, IsDefault = false }).Entity;
            _context.SaveChanges();
        }
    }
Question

Hello I wonder if you have ever tried to run a volume test on the aspnetzero solution? How many million users can I expect the solution to handle? :)

I tried to insert a loop that created users in the HostRoleAndUserCreator class, but if I use a loop greater than 100, the script or VS starts hanging. Maybe I have to create a stored procedure in Sql server?

Showing 11 to 20 of 98 entries