Base solution for your next web application

Activities of "justinp"

Hello,

I have built a new app service that I intend for the tenants to use to create a new object. I have also seeded the database for the default tenant with several objects to test and ensure the service. However, when I write a test, I get an error and the test fails.

Message: 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.

Since this is a template, what is the procedure for testing tenant services?

Running a simple update to 4.1.3 Angular + Core. My first step is to download 4.1.3 and get it running in Azure, then we move our changes over once it is verified to run.

We've created a new database in Azure and run Update-Database EF command against it.

Our build fails during the tests on the Create_Language test. Is there a reason this would succeed locally, then fail when deployed?

Here's the test:

[Fact]
        public async Task Create_Language()
        {
            //Act
            var output = await _languageAppService.GetLanguageForEdit(new NullableIdDto(null));

            //Assert
            output.Language.Id.ShouldBeNull();
            output.LanguageNames.Count.ShouldBeGreaterThan(0);
            output.Flags.Count.ShouldBeGreaterThan(0);

            //Arrange
            var currentLanguages = await _languageManager.GetLanguagesAsync(AbpSession.TenantId);
            var nonRegisteredLanguages = output.LanguageNames.Where(l => currentLanguages.All(cl => cl.Name != l.Value)).ToList();

            //Act
            var newLanguageName = nonRegisteredLanguages[RandomHelper.GetRandom(nonRegisteredLanguages.Count)].Value;
            await _languageAppService.CreateOrUpdateLanguage(
                new CreateOrUpdateLanguageInput
                {
                    Language = new ApplicationLanguageEditDto
                    {
                        Icon = output.Flags[RandomHelper.GetRandom(output.Flags.Count)].Value,
                        Name = newLanguageName
                    }
                });

            //Assert
            currentLanguages = await _languageManager.GetLanguagesAsync(AbpSession.TenantId);
            currentLanguages.Count(l => l.Name == newLanguageName).ShouldBe(1);
        }

Here's the error:

2017-08-13T18:46:40.7656928Z Failed   Company.Project.Tests.Localization.LanguageAppService_Tests.Create_Language
2017-08-13T18:46:40.7656928Z Error Message:
2017-08-13T18:46:40.7656928Z  Shouldly.ShouldAssertException : 0
2017-08-13T18:46:40.7656928Z     should be
2017-08-13T18:46:40.7656928Z 1
2017-08-13T18:46:40.7656928Z     but was not
2017-08-13T18:46:40.7656928Z Stack Trace:
2017-08-13T18:46:40.7656928Z    at Shouldly.ShouldlyCoreExtensions.AssertAwesomely[T](T actual, Func`2 specifiedConstraint, Object originalActual, Object originalExpected, Func`1 customMessage, String shouldlyMethod)
2017-08-13T18:46:40.7656928Z    at Shouldly.ShouldBeTestExtensions.ShouldBe[T](T actual, T expected, Func`1 customMessage)
2017-08-13T18:46:40.7656928Z    at Shouldly.ShouldBeTestExtensions.ShouldBe[T](T actual, T expected)
2017-08-13T18:46:40.7656928Z    at Akesotek.Apollo.Tests.Localization.LanguageAppService_Tests.<Create_Language>d__4.MoveNext() in d:\a\1\s\test\Akesotek.Apollo.Tests\Localization\LanguageAppService_Tests.cs:line 67
2017-08-13T18:46:40.7656928Z --- End of stack trace from previous location where exception was thrown ---
2017-08-13T18:46:40.7656928Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2017-08-13T18:46:40.7656928Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2017-08-13T18:46:40.7656928Z --- End of stack trace from previous location where exception was thrown ---
2017-08-13T18:46:40.7656928Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2017-08-13T18:46:40.7656928Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2017-08-13T18:46:40.7656928Z --- End of stack trace from previous location where exception was thrown ---
2017-08-13T18:46:40.7656928Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2017-08-13T18:46:40.7656928Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2017-08-13T18:47:21.8278038Z [xUnit.net 00:02:10.0703411]   Finished:    Company.Project.Tests

Hello,

I've downloaded 4.1 and the left side menue doesn't collapse when you click the "hamburger". I have testers on tablets and used multiple browsers (chrome, edge(!), ie and firefox).

Thanks,

Justin

I am incredibly frustrated in trying to sort out why the issue with not being able to create new services and getting what appeared to be a CORS issue (#3448).

I have lost a week on this issue and posted and emailed my code. I finally gave up and loaded 4.1 to start over by hand to try and get something working.

The first thing I did was add a new service interface and service. All it does is accept a string and return that same string:

public interface IConnectionAppService : IApplicationService
    {
        string TestConnection(string input);
    }

public class ConnectionsAppService : ApolloAppServiceBase, IConnectionAppService
    {
        public string TestConnection(string input)
        {
            return input;
        }
    }

Then I ran the service and updated the Angular service-proxies (refresh.bat). Finally, I created a simple component that ngOnInit calls the service. created a "Connections" page under the "app\admin" and added my component routing and module to the admin.module.ts and admin-routing.module.ts. Here's the component code:

import { Component, Injector, OnInit } from '@angular/core';
import { AppComponentBase } from '@shared/common/app-component-base';
import { appModuleAnimation } from '@shared/animations/routerTransition';
import { ConnectionsServiceProxy } from '@shared/service-proxies/service-proxies';

@Component({
    templateUrl: './connection-manager.component.html',
    animations: [appModuleAnimation()],
    providers: [ConnectionsServiceProxy]
})

export class ConnectionManagerComponent extends AppComponentBase implements OnInit {

    private resultString: string;

    constructor(
        injector: Injector,
        private _ConnectionsService: ConnectionsServiceProxy
    ) {
        super(injector);
    }

    ngOnInit(): void {
        this._ConnectionsService.testConnection("Testing from API.").subscribe(
            (result) => { this.resultString = result; },
            (result) => { this.resultString = result; },
            () => { }
        );
    }

}

I am still seeing the same error UI popup, and 500 error, even though my code executes without throwing an error on the Server side.

XMLHttpRequest cannot load http://localhost:22742/api/services/app/Connections/TestConnection?input=Testing%20from%20API.. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 500.

Can someone take a look at this or the code I sent in (shared via Google Drive).

Thanks in advance,

Justin

I just downloaded the Core + Angular 4.1 to take a look.

I opened the server side aspnet-core solution, set Web.Host project as startup project and build the solution. I updated the connection string to the database in the appsettings.json file. I opened the Package Manager Console and set EntityFrameworkCore project as default project and run Update-Database command.

I was immediately met with the error:

The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Cannot find path '\asp-core\src\Akesotek.Apollo.Web.Host\obj\project.assets.json' because it does not exist.

I double checked the tutorial and don't believe I'm missing a step.

I am working to add some functionality to validate connections to customer systems. I have a basic form where the user puts in a valid URI and clicks a button to test the connection.

This is the Angular4+.NET Core version of ABP, so the connection string is passed to a webservice in the API called testConnection(URI connectionString). The application tries a connection and right now only returns a string of "Success" or "Error." I also have a breakpoint set to watch execution.

When I call the webservice via swagger, the breakpoint is hit, the connection is successful and I get the expected result. When I call the webservice via the Angular front end, the breakpoint is hit, the connection is also successful, but I get a 500 with the error:

XMLHttpRequest cannot load <a class="postlink" href="http://localhost:22742/api/services/app/Connections/TestConnection?connectionString=http%3A%2F%2Fspark.furore.com%2Ffhir&">http://localhost:22742/api/services/app ... om%2Ffhir&</a>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 500.

This is a classic CORS error. However, I cannot figure out how to enable this type of functionality within ABPZ. I tried changing this line in the Startup.cs:

.WithOrigins(_appConfiguration["App:CorsOrigins"].Split(",", StringSplitOptions.RemoveEmptyEntries).Select(o => o.RemovePostFix("/")).ToArray())

to this:

.AllowAnyOrigin();

but that did not fix the issue. Any help is much appreciated. <a class="postlink" href="https://stackoverflow.com/questions/40043097/cors-in-net-core">https://stackoverflow.com/questions/400 ... n-net-core</a>

I've included a JTable in one of my components. It seems to be working we for displaying the rows, however when it tries to create a modal, the style isn't coming over. I've attached a screen shot of the issue.

Do I need to include a style file for JTable in my component?

Hello,

I am getting the attached error when I switch languages from English to Spanish.

How do I switch it back to English, since I cannot modify it through the UI? I have already tried changing the dbo.AbpSettings table, where the entry showed the setting. That doesn't seem to change anything. EDIT: I think there was some caching issue but fixing the database may have fixed the issue of switching back to english.

How can I get localization working? I'd like users to be able to select a language.

I noticed when I added a birthdate to a class and created an AppService with public DateTime BirthDate { get; set; }, swagger will generate code that looks like this:

toJS(data?: any) { data = data === undefined ? {} : data; data["active"] = this.active !== undefined ? this.active : null; data["birthDate"] = this.birthDate ? this.birthDate.toISOString() : null; return data; }

The problem is that this generates the following javascript error: ERROR TypeError: this.birthDate.toISOString is not a function

I have to manually change the line of code from .toISOString() to .toString() to fix the problem.

Is there a way to have swagger create the correct code? Should I be doing something special with dates when I create my app service?

Thanks

Question

Hey all,

I'm porting things over to v4.0 and realized that one of the changes with moving to EF Core is that ABPZero isn't using the IDbSet, instead using the default DbSet. No big deal, but the comment in the file still says:

/* Define an IDbSet for each entity of the application */

Just a small change. If there's somewhere better to put this kind of information (e.g. Git), please let me know.

Showing 1 to 10 of 20 entries