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

Activities of "rbarbosa"

Hi, thanks for your help, sadly this did not help, looking at the source : https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.Dapper/Dapper/Repositories/DapperRepositoryBaseOfTEntityAndTPrimaryKey.cs#L102 it seems that dapper retrieves the command timeout from a parameter, which is not being passed

https://github.com/StackExchange/Dapper/blob/master/Dapper/SqlMapper.cs#L647

What i did was override DapperRepositoryBase, inject UOWManager and get the data from there

private int? CommandTimeout =>
            _unitOfWorkManager.Current?.Options.Timeout != null
                ? (int?) Convert.ToInt32(_unitOfWorkManager.Current.Options.Timeout?.TotalSeconds)
                : null;

public override Task<IEnumerable<TAny>> QueryAsync<TAny>(string query, object parameters = null)
        {
            return Connection.QueryAsync<TAny>(query, parameters, ActiveTransaction, commandTimeout: CommandTimeout);
        }

I am unsure if this is the right path but it seems to get the data where it needs to be either via attribute or with a using statement, gets a bit confusing as the attribute takes the time as INT Milliseconds, the UnitOfWorkOptions take the time as a TimeSpan, which convert to double seconds, and Dapper takes the time as Int seconds

[UnitOfWork(isTransactional: false, timeout: TIME_IN_MS)]

Eitherways it seems to solve my issue, but I am open on seeing a better way on doing this. Thanks

Adding the serviceProxyModule did not make a difference

although that did remind me that this file needs the service proxies to be added, i completely forgot about that. https://docs.aspnetzero.com/documents/aspnet-core-angular/latest/Infrastructure-Angular-NSwag Thank you

Thank you @ismcagdas that solves the UOW issue. Happy new year!

However I dont seem to be able to find a way to get the index of the property's parent when an array of them are being sent, as shown here:

https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.Web.Api/WebApi/Validation/WebApiActionInvocationValidator.cs#L33

public void AddValidationErrors(CustomValidationContext context)
        {

            var skuManager = context.IocResolver.Resolve<ISkuManager>();
            var productTypeManager = context.IocResolver.Resolve<IProductTypeManager>();
           // var actionContext = context.IocResolver.Resolve<HttpActionContext>();
            try
            {

                AsyncHelper.RunSync(() => skuManager.ValidateDuplicateSkuAsync(Sku));
            }
            catch (UserFriendlyException e)
            {
                context.Results.Add(new ValidationResult(e.Message, new[] {"Sku" }));
            }
        }
{
    "result": null,
    "targetUrl": null,
    "success": false,
    "error": {
        "code": 0,
        "message": "Your request is not valid!",
        "details": "The following errors were detected during validation.\r\n - SKU duplicateSku already exists.\r\n - UPC: duplicateUpc already exists for a different SKU\r\n - Division: BadDivision not found.\r\n - SKU duplicateSku already exists.\r\n - UPC: duplicateUPC already exists for a different SKU\r\n",
        "validationErrors": [
            {
                "message": "SKU duplicateSku already exists.",
                "members": [
                    "sku"
                ]
            },
            {
                "message": "UPC: duplicateUpc already exists for a different SKU",
                "members": null
            },
            {
                "message": "Division: badDivision not found.",
                "members": null
            },
            {
                "message": "SKU duplicateSku already exists.",
                "members": [
                    "sku"
                ]
            },
            {
                "message": "UPC: duplicateUpc already exists for a different SKU",
                "members": null
            }
        ]
    },
    "unAuthorizedRequest": false,
    "__abp": true
}

is it better to abandon this validation style?

Hello

I have modified the code to handle the error in the pipe like so:

getReturnParameters(): void {

            this._returnAppService.validate(this.id)
            .pipe(
                //catchError cannot return void, can return of([])  to stop bubble
                catchError((err) => {console.log('error catchError', err); return throwError(err); }) 
            )
            .subscribe(result  => {
                this.validatedReturnOrder = result;
            }, err => {
                console.log('error subscribe', err);
            });
        }

Abp error with message is caught correctly before pipe code runs

:22742/api/services/app/Returns/Validate:1 POST http://localhost:22742/api/services/app/Returns/Validate 500 (Internal Server Error)
abp.js:350 ERROR: 
abp.js:350 {code: -2, message: "No more returns for this order.", details: null, validationErrors: null}

Pipe catchError gets SwaggerException

return-by-order-detail.component.ts:75
error catchError Error: An unexpected server error occurred.
    at new SwaggerException (service-proxies.ts:22907)
    at throwException (service-proxies.ts:22927)
    at MergeMapSubscriber.project (service-proxies.ts:6583)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext (mergeMap.js:60)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._next (mergeMap.js:50)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
    at Observable._subscribe (service-proxies.ts:22933)
    at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe (Observable.js:42)
    at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (Observable.js:28)
    at MergeMapOperator.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapOperator.call (mergeMap.js:28)

Subscribe Error gets SwaggerException

return-by-order-detail.component.ts:80 
error subscribe Error: An unexpected server error occurred.
    at new SwaggerException (service-proxies.ts:22907)
    at throwException (service-proxies.ts:22927)
    at MergeMapSubscriber.project (service-proxies.ts:6583)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext (mergeMap.js:60)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._next (mergeMap.js:50)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
    at Observable._subscribe (service-proxies.ts:22933)
    at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe (Observable.js:42)
    at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (Observable.js:28)
    at MergeMapOperator.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapOperator.call (mergeMap.js:28)

UserFriendlyException returns an Http 500 status code

return content looks like this:

{
  "result": null,
  "targetUrl": null,
  "success": false,
  "error": {
    "code": -2,
    "message": "No more returns for this order.",
    "details": null,
    "validationErrors": null
  },
  "unAuthorizedRequest": false,
  "__abp": true
}

so when trying to catch the error on the subscribe method it just returns a generic swagger error after the framework logs it:

ERROR: 
abp.js:350 {code: -2, message: "No more returns for this order.", details: null, validationErrors: null}

abp.js:350 is:

abp.log.log = function (logObject, logLevel) {
        if (!window.console || !window.console.log) {
            return;
        }

        if (logLevel != undefined && logLevel < abp.log.level) {
            return;
        }

        console.log(logObject); // 350
    };

after that the error pops through the rest:

ERROR Error: An unexpected server error occurred.
    at new SwaggerException (service-proxies.ts:22907)
    at throwException (service-proxies.ts:22927)
    at MergeMapSubscriber.project (service-proxies.ts:6583)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext (mergeMap.js:60)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._next (mergeMap.js:50)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
    at Observable._subscribe (service-proxies.ts:22933)
    at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe (Observable.js:42)
    at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (Observable.js:28)
    at MergeMapOperator.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapOperator.call (mergeMap.js:28)

and this SwaggerException is what the subscribe(err) method is handling.

I ran into this a while ago, this is a webAPI issue, check this code as an example for the service

public interface IHtmlResponseAppService : IApplicationService
 {
     HttpResponseMessage GetHTMLResult()
 } 

 public class HtmlResponseAppService : AbpAppServiceBase, IHtmlResponseAppService
 {
    public HttpResponseMessage GetHTMLResult()
    {
        string result = "something";

        var resp = new HttpResponseMessage(HttpStatusCode.OK);
        resp.Content = new StringContent(result, System.Text.Encoding.UTF8, "text/html");
        return resp;
    }
}

works on dynamic webapi and whatnot

Answered my own question...missed adding the explicit DLL

Configuration.Modules.AbpWebApi().DynamicApiControllerBuilder
                .ForAll<IApplicationService>(typeof(NeoDynamicsBarcodeModule).Assembly, "app")
                .Build();

Do you have any examples of a hello world style controller/view/routes that comes from a module?

Showing 1 to 8 of 8 entries