Ошибка проверки — Поле MaxResultCount должно находиться в диапазоне от 1 до 2147483647

#angular #aspnetboilerplate

Вопрос:

Я недавно добавил новую сущность в этот проект, однако я столкнулся с этой ошибкой проверки, когда я нажимаю на недавно созданную страницу

введите описание изображения здесь

Я не совсем уверен, что вызывает эту проблему, так как другие объекты имеют почти те же размеры. Я тщательно изучил эту проблему в Интернете, но, к сожалению, не нашел подходящего решения.

Вот часть кода в сервисе-прокси:

 /**
     * @param keyword (optional) 
     * @param isActive (optional) 
     * @param skipCount (optional) 
     * @param maxResultCount (optional) 
     * @return Success
     */
    getAll(keyword: string | undefined, maxResultCount: number | undefined, skipCount: number | undefined): Observable<DeductionsAndExpenseFlatDtoPagedResultDto> {
        let url_ = this.baseUrl   "/api/services/app/DeductionsAndExpensesFlat/GetAll?";
        if (keyword === null)
            throw new Error("The parameter 'keyword' cannot be null.");
        else if (keyword !== undefined)
            url_  = "Keyword="   encodeURIComponent(""   keyword)   "amp;";
        if (maxResultCount === null)
            throw new Error("The parameter 'maxResultCount' cannot be null.");
        else if (maxResultCount !== undefined)
            url_  = "MaxResultCount="   encodeURIComponent(""   maxResultCount)   "amp;";
        if (skipCount === null)
            throw new Error("The parameter 'skipCount' cannot be null.");
        else if (skipCount !== undefined)
            url_  = "SkipCount="   encodeURIComponent(""   skipCount)   "amp;";
        url_ = url_.replace(/[?amp;]$/, "");


        let options_ : any = {
            observe: "response",
            responseType: "blob",           
            headers: new HttpHeaders({
                "Accept": "text/plain"
            })
        };

        return this.http.request("get", url_, options_).pipe(_observableMergeMap((response_ : any) => {
            return this.processGetAll(response_);
        })).pipe(_observableCatch((response_: any) => {
            if (response_ instanceof HttpResponseBase) {
                try {
                    return this.processGetAll(<any>response_);
                } catch (e) {
                    return <Observable<DeductionsAndExpenseFlatDtoPagedResultDto>><any>_observableThrow(e);
                }
            } else
                return <Observable<DeductionsAndExpenseFlatDtoPagedResultDto>><any>_observableThrow(response_);
        }));
    }

    protected processGetAll(response: HttpResponseBase): Observable<DeductionsAndExpenseFlatDtoPagedResultDto> {
        const status = response.status;
        const responseBlob = 
            response instanceof HttpResponse ? response.body : 
            (<any>response).error instanceof Blob ? (<any>response).error : undefined;

        let _headers: any = {}; if (response.headers) { for (let key of response.headers.keys()) { _headers[key] = response.headers.get(key); }};
        if (status === 200) {
            return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => {
            let result200: any = null;
            let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
            result200 = DeductionsAndExpenseFlatDtoPagedResultDto.fromJS(resultData200);
            return _observableOf(result200);
            }));
        } else if (status !== 200 amp;amp; status !== 204) {
            return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => {
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
            }));
        }
        return _observableOf<DeductionsAndExpenseFlatDtoPagedResultDto>(<any>null);
    }
 

А вот код машинописного текста:

 import { Component, Injector } from '@angular/core';
import { MatDialog } from '@angular/material';
import { finalize } from 'rxjs/operators';
import { appModuleAnimation } from '@shared/animations/routerTransition';
import {
    PagedListingComponentBase,
    PagedRequestDto
} from 'shared/paged-listing-component-base';
import {
    DeductionsAndExpensesFlatServiceProxy,
    DeductionsAndExpenseFlatDto,
    DeductionsAndExpenseFlatDtoPagedResultDto
} from '@shared/service-proxies/service-proxies';
import { Router, ActivatedRoute } from '@angular/router';
import { NavigationRoutes, NavigationDirection, NavigationPropertyEnum, NavigationSource } from 'enums/app.enums';
import { AppUrlService } from '@shared/nav/app-url.service';
import { UserGroupService } from '@app/services/user-group.service';
import { CreateDeductionsAndExpenseFlatDialogComponent } from './create-deductions-and-expense-flat/create-deductions-and-expense-flat.component';
import { EditFlatDeductionsAndExpenseComponent } from './edit-flat-deductions-and-expense/edit-flat-deductions-and-expense.component';

class PagedDeductionsAndExpensesFlatRequestDto extends PagedRequestDto {
  keyword: string;
  isActive: boolean | null;
}


@Component({
  templateUrl: './deductions-and-expenses-flat.component.html',
  animations: [appModuleAnimation()],
    styles: [
        `
          mat-form-field {
            padding: 10px;
          }
        `
    ]
})
export class DeductionsAndExpensesFlatComponent extends PagedListingComponentBase<DeductionsAndExpenseFlatDto> {
  deductionsAndExpensesFlat: DeductionsAndExpenseFlatDto[] = [];
  keyword = '';
  isActive: boolean | null;
  passedID: number; canAdd: boolean;
  searchText: number;

  constructor(
      injector: Injector,
      private _deductionsAndExpenseFlatService: DeductionsAndExpensesFlatServiceProxy,
      private _dialog: MatDialog,
      private router: Router,
      private activatedRoute: ActivatedRoute,
      private appUrlService: AppUrlService,
      private userGroupService: UserGroupService,
  ) {
      super(injector);
      this.appUrlService.getNavigationExtras();
  }

  getGroupName(group: number): string {
      return this.userGroupService.getGroupName(group);
  }

  list(
      request: PagedDeductionsAndExpensesFlatRequestDto,
      pageNumber: number,
      finishedCallback: Function
  ): void {

      request.keyword = this.keyword;
      request.isActive = this.isActive;

      this._deductionsAndExpenseFlatService
          .getAll(request.keyword, request.skipCount, request.maxResultCount)
          .pipe(
              finalize(() => {
                  finishedCallback();
              })
          )
          .subscribe((result: DeductionsAndExpenseFlatDtoPagedResultDto) => {

              this.deductionsAndExpensesFlat = this.appUrlService.passedId === 0 ?
                  result.items : result.items.filter(x => Array.isArray(this.appUrlService.passedId) ?
                      this.appUrlService.passedId.includes(x.aoCaseId)
                      : x.aoCaseId === this.appUrlService.passedId);
              this.canAdd = !Array.isArray(this.appUrlService.passedId) amp;amp; this.appUrlService.passedId !== 0;
              this.showPaging(result, pageNumber);
          });
  }

  getSource() {
      return NavigationSource.Other;
  }

  delete(deductionsAndExpenseFlat: DeductionsAndExpenseFlatDto): void {
      abp.message.confirm(
          this.l('DeductionsAndExpenseFlatDeleteWarningMessage', deductionsAndExpenseFlat.said),
          undefined,
          (result: boolean) => {
              if (result) {
                  this._deductionsAndExpenseFlatService
                      .delete(deductionsAndExpenseFlat.id)
                      .pipe(
                          finalize(() => {
                              abp.notify.success(this.l('SuccessfullyDeleted'));
                              this.refresh();
                          })
                      )
                      .subscribe(() => { });
              }
          }
      );
  }

  createDeductionsAndExpenseFlat(): void {
      this.showCreateOrEditDeductionsAndExpenseFlatDialog();
  }

  editDeductionsAndExpense(deductionsAndExpenseFlat: DeductionsAndExpenseFlatDto): void {
      this.showCreateOrEditDeductionsAndExpenseFlatDialog(deductionsAndExpenseFlat.id);
  }

  showCreateOrEditDeductionsAndExpenseFlatDialog(id?: number): void {
      let createOrEditDeductionsAndExpenseDialog;
      if (id === undefined || id <= 0) {
          createOrEditDeductionsAndExpenseDialog = this._dialog.open(CreateDeductionsAndExpenseFlatDialogComponent, {
              data: { id: this.appUrlService.passedId, groupId: this.appUrlService.groupId }
          });
      } else {
          createOrEditDeductionsAndExpenseDialog = this._dialog.open(EditFlatDeductionsAndExpenseComponent, {
              data: id
          });
      }

      createOrEditDeductionsAndExpenseDialog.afterClosed().subscribe(result => {
          if (result) {
              this.refresh();
          }
      });
  }

  getNavigationPropertyEnum() {
      return NavigationPropertyEnum.DetailedDeductionsAndExpenses;
  }
}



 

Наконец, вот вывод журнала.
введите описание изображения здесь

Любая помощь будет очень признательна и заранее благодарна.

Ответ №1:

Неважно, я решил эту проблему. Я переключил свои параметры, в результате чего были переданы разные значения.

 this._deductionsAndExpenseFlatService
          .getAll(request.keyword, request.skipCount, request.maxResultCount)
          .pipe(
              finalize(() => {
                  finishedCallback();
              })
          )
 

Не совпадало с

 getAll(keyword: string | undefined, maxResultCount: number | undefined, skipCount: number | undefined)
 

поэтому я поменял местами параметры здесь:

 this._deductionsAndExpenseFlatService
          .getAll(request.keyword, request.maxResultCount, request.skipCount)
          .pipe(
              finalize(() => {
                  finishedCallback();
              })
          )
 

Что решило проблему. Закрываем этот запрос.