Hi,
This is the angular service code as below :
selectedInvoicesToExcelDownloadByInput(body: any): Observable<any> {
let url = `${this.apiUrl.url}/api/InvoiceManagement/AR/invoice/selectedInvoicesToExcelDownload`
return this.http.post(url, body, {
responseType: 'blob'
})
}
Thie is the method where service method is called, code as below :
this.Invoiceservice.selectedInvoicesToExcelDownloadByInput(program).subscribe((res) => {
var blob = new Blob([res], { type: res.type.toString() });
var url = window.URL.createObjectURL(blob);
var anchor = document.createElement("a");
anchor.download = this.fileformatName();
anchor.href = url;
anchor.click();
});
What I need is to get access of the below marked blue rectangle :
How do I access this ? If I go with normal approach of state as per document I get parsing error where I cant prase my returned blob to excel file. The only way I was able to generate excel file is by implementation done above, but now I cannot access the name of the file.
Code sample will help alot !!!
Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.
While updating from multiple threads, the updateAsync() throws error sometime not always, error as below
Exception - Volo.Abp.Data.AbpDbConcurrencyException: Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
I tried using await CurrentUnitOfWork.SaveChangesAsync();
but then my Db went into DeadLock state.
Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.
The issue occures while doing unit test cases are as below
There are few more issue I am facing where the code works fine in Production but giving error while Unit Testing, Are there any limitation for testing ? If yes then how to overcome them ?
Please find below error log for your reference. Thanks
Exception Messages :
System.NotSupportedException : SQLite cannot order by expressions of type 'decimal'. Convert the values to a supported type or use LINQ to Objects to order the results.
Stack Trace:
SqliteQueryableMethodTranslatingExpressionVisitor.TranslateThenBy(ShapedQueryExpression source, LambdaExpression keySelector, Boolean ascending)
QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
MethodCallExpression.Accept(ExpressionVisitor visitor)
ExpressionVisitor.Visit(Expression node)
QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
MethodCallExpression.Accept(ExpressionVisitor visitor)
ExpressionVisitor.Visit(Expression node)
QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
Database.CompileQuery[TResult](Expression query, Boolean async)
QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
<>c__DisplayClass12_0`1.<ExecuteAsync>b__0()
CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken)
EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
EntityQueryable`1.GetAsyncEnumerator(CancellationToken cancellationToken)
ConfiguredCancelableAsyncEnumerable`1.GetAsyncEnumerator()
EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
InvoiceAppService.GetCreditNotesForInvoiceSelectionAsync(List`1 supplierCodes) line 1412
InvoiceAppService.ApplyInvoiceLinkedCreditNotesAsync(GetQuoteInputDto input) line 1455
AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
InvoiceApplicationTests.ApplyInvoiceLinkedCreditNotesAsync() line 451
Message:
System.InvalidOperationException : The LINQ expression '(GroupByShaperExpression:
KeySelector: new {
StatusId = (i.StatusId),
Code = (t.Code)
},
ElementSelector:(EntityShaperExpression:
EntityType: Invoice
ValueBufferExpression:
(ProjectionBindingExpression: EmptyProjectionMember)
IsNullable: False
)
)
.Sum(x => x.Amount)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
Stack Trace:
RelationalSqlTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
MethodCallExpression.Accept(ExpressionVisitor visitor)
ExpressionVisitor.Visit(Expression node)
RelationalSqlTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
MethodCallExpression.Accept(ExpressionVisitor visitor)
ExpressionVisitor.Visit(Expression node)
RelationalSqlTranslatingExpressionVisitor.Translate(Expression expression)
RelationalProjectionBindingExpressionVisitor.Visit(Expression expression)
RelationalProjectionBindingExpressionVisitor.VisitMemberAssignment(MemberAssignment memberAssignment)
ExpressionVisitor.VisitMemberBinding(MemberBinding node)
RelationalProjectionBindingExpressionVisitor.VisitMemberInit(MemberInitExpression memberInitExpression)
MemberInitExpression.Accept(ExpressionVisitor visitor)
ExpressionVisitor.Visit(Expression node)
RelationalProjectionBindingExpressionVisitor.Visit(Expression expression)
RelationalProjectionBindingExpressionVisitor.Translate(SelectExpression selectExpression, Expression expression)
RelationalQueryableMethodTranslatingExpressionVisitor.TranslateSelect(ShapedQueryExpression source, LambdaExpression selector)
QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
MethodCallExpression.Accept(ExpressionVisitor visitor)
ExpressionVisitor.Visit(Expression node)
QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
MethodCallExpression.Accept(ExpressionVisitor visitor)
ExpressionVisitor.Visit(Expression node)
QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
Database.CompileQuery[TResult](Expression query, Boolean async)
QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
<>c__DisplayClass9_0`1.<Execute>b__0()
CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
QueryCompiler.Execute[TResult](Expression query)
EntityQueryProvider.Execute[TResult](Expression expression)
Queryable.FirstOrDefault[TSource](IQueryable`1 source)
InvoiceAppService.GetInvoiceSummaryAsync(InvoiceSummaryInputDto input) line 221
AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
InvoiceApplicationTests.GetInvoiceSummaryAsync() line 188
--- End of stack trace from previous location where exception was thrown ---
Hi @alper,
Below code is for Executing SP on SQL server:
public async Task UpdateEmail(Guid id, string email, CancellationToken cancellationToken = default)
{
await DbContext.Database.ExecuteSqlRawAsync(
"EXEC UpdateEmailById @email, @id",
new List<object> {new SqlParameter("id", id), new SqlParameter("email", email)},
cancellationToken);
}
I am using PostgreSQL 13 , Is this the same way to execute it on PostgreSQL and even I am not able to find SqlParameter i.e. new SqlParameter("id", id)
do I need to install any package for same ?
Hi @alper,
As stated above my custom repo method performs 2 operations
public virtual async Task CreateQuote()
{
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
{
//...my code
//custom repository bulk update called
//ERROR OCCURED
await uow.CompleteAsync();
}
}
So as per what you are saying all the updates and inserts will be roll backed in the above cenario right ?
Hi @hikalkan
My method is POST method, So it's starting transaction. If you are sure that your UOW is transactional, then we will try to reproduce it in our side -- YES I AM SURE
My custom repository method is performing 2 operations at a time.
My Requirement ->
1st operation : To update table XYZ_1 where I update status of some records in bulk. 2nd operation : Is to insert the id's of updated records and the changed status in another XYZ_2 table which I later on use for auditing and other operations.
Issue : Even if my update fails I found that, from almost 40k records very small amount of records got inserted in 2nd operation (around 10-20 records)
Hi @liangshiwei,
My code is almost same as your code. Even I thought it was working fine, while trying to recreate the same issue I was able to recreate it only once in 9-10 attempts. If you can read the comments for ExecuteSqlRawAsync in it's Interface it says :
Executes the given SQL against the database and returns the number of rows affected.
Note that this method does not start a transaction. To use this method with a
transaction, first call Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.BeginTransaction(Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade,System.Data.IsolationLevel)
or Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.UseTransaction(Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade,System.Data.Common.DbTransaction).
Note that the current Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy
is not used by this method since the SQL may not be idempotent and does not run
in a transaction. An ExecutionStrategy can be used explicitly, making sure to
also use a transaction if the SQL is not idempotent.
My question here is how can I use this in my cenario so I can use my methods transaction or in anyway I can able to execute my SQL in same transaction or something : Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.UseTransaction(Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade,System.Data.Common.DbTransaction)
Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.
Hi,
There is a case where I have to update more than 40k records in a single go.
What I tried : 1st Approach
foreach (var item in xyzList_1)
{
var data = await xyz_repository.GetAsync(item.Some_Id);
if (data != null)
{
data.FieldName = xyz;
await xyz_repository.UpdateAsync(data);
}
}
The above code block for 40k invoices was taking too long to execute, So I decided to switch to rawSQL query where I tried to pass all the Id's in IN_CLAUSE as below.
2nd Approach:
UPDATE "XYZ_TABLE" SET "FieldName" = 'some_value' WHERE "Id" IN (...)
The above code is in my custom repository , sample given below :
public async Task<int> UpdateRecods(string inClauseData)
{
return await DbContext.Database.ExecuteSqlRawAsync(UPDATE "XYZ_TABLE" SET "FieldName" = 'some_value' WHERE "Id" IN (inClauseData));
}
1st approach was in UOW transaction and used to roll back if there was any error in the process but is too slow as per performance point of view. 2nd approach is fast but doesn't roll back the changes.
There is a similar thing happening for bulk insert as well. Basically my requirement is to perform BULK CRUD in a single transaction scope.
I need a solution on both aspects which are rollback if any issue and performance. If you can suggest any other approach I am good with it.
Thanks !!!
I am using PostgreSQL functions and stored procedure.
I tried using it this approach https://khalidabuhakmeh.com/add-custom-database-functions-for-entity-framework-core
but I got below error: [ERR] xyzFunctionName cannot be called client side
Tried to look into abp document but no luck.
Please provide sample code if available. Thank you in advance !!!
Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.
ABP Framework version: v3.0.4
UI type: Angular / MVC: Angular
DB provider: EF Core / MongoDB
Tiered (MVC) or Identity Server Seperated (Angular): yes / no : no
Exception message and stack trace: Working: http://localhost:4200/account;accountType=supplier/login Exptected Result: http://localhost:4200/account/login?accountType=supplier
Steps to reproduce the issue: We customize the AccountComponent
app.module.ts
@NgModule({
declarations: [AppComponent, AccountComponent, .....],
imports: [
AccountConfigModule.forRoot(),
IdentityConfigModule.forRoot(),
....
.....
],
entryComponents: [AccountComponent]
app-routing.module.ts
const routes: Routes = [
{
path: '',
loadChildren: () => import('./home/home.module').then((m) => m.HomeModule)
}
{
path: 'account',
loadChildren: () => import('@volo/abp.ng.account')
.then((m) => m.AccountModule.forLazy({ redirectUrl: '/' })),
},
{
path: 'dashboard',
loadChildren: () => import('./dashboard/dashboard.module').then((m) => m.DashboardModule),
}]
Home.component.ts
if (this.hasLoggedIn){
this.router.navigate(['dashboard'])
}else {
this.router.navigate(['account', { accountType: 'supplier' }]);
}
How to acheive this, Kindly give any suggestions
Thanks
Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.
As Per requirement we need to show notification Icon on after login, So I am adding menu item as follwing this document
https://docs.abp.io/en/abp/latest/UI/Angular/Modifying-the-Menu#how-to-add-an-element-to-right-part-of-the-menu
In app.component.ts constructor( private navItems: NavItemsService) { navItems.addItems([ { id: 'notification-litmus', order: 1, component: LitmusNotificationComponent, }]) } Using NavItemService I added menu Item, It's adding after login, showing the menu item on menu as expected,
Issue: ngOninit hook of LitmusNotificationComponent calling even after logout, because of this whatever functions calling in oninit all are calling even after logout.
litmus-notification.component.ts export class LitmusNotificationComponent implements OnInit ngOnInit(): void { alert('oninit') } }
How to handle this? If need to remove item from navItems then How to do it ? , From Documentation I did not understood remove item from navItems?
Apart from this what I am doing wrong?
Kindly help"