Base solution for your next web application

Activities of "kansoftware"

Hi, I was tried to use below code to enable lazy load.

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
    optionsBuilder.UseLazyLoadingProxies();
}

For this i install the Microsoft.EntityFrameworkCore.Proxies NuGet package into your project. After this i am getting error in below image. I done project upgrade version 8 to 12.1.0 and then i instill this library

Hi,

Thanks, we have reproduced the problem but we need to see the source code in order to detect the source of the problem. We have replied via email, we can continue via email for this problem.

I have reverted back on the mail.

Waiting for your response.

Thanks

Hi @kansoftware

We have replied to your email but probably you didn't receive the reply. We will send a reply again. We couldn't reproduce the problem.

Hi,

I have added a screen recording for replicating. Please find the URL to access the recording : https://a.fyntst.com/Common/Recording.mp4

Hi,

I called a function 'LikePost' from JS on some case, it will call a procedure which will insert a new entry in one table and update a field in another. After the above work is completed i want to send notification which I want to call asynchronously. When i am doing that it gives me the below error in audit log:

Microsoft.Data.SqlClient.SqlException (0x80131904): The transaction operation cannot be performed because there are pending requests working on this transaction. at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at Microsoft.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at Microsoft.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[] buffer, TransactionManagerRequestType request, String transactionName, TransactionManagerIsolationLevel isoLevel, Int32 timeout, SqlInternalTransaction transaction, TdsParserStateObject stateObj, Boolean isDelegateControlRequest) at Microsoft.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest transactionRequest, String transactionName, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest) at Microsoft.Data.SqlClient.SqlInternalTransaction.Commit() at Microsoft.Data.SqlClient.SqlTransaction.Commit() at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.Commit() at Abp.EntityFrameworkCore.Uow.DbContextEfCoreTransactionStrategy.Commit() at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.CommitTransaction() at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.CompleteUowAsync() at Abp.Domain.Uow.UnitOfWork...

Can you please help me out in resolving this.

I am pasting the code below: public async Task<int> LikePost(GetLikePostInput input) { var LikeCount = 0; Int64 FeedCreatorUserId = 0;

        try
        {
            _storedProcedureCalling.EnsureConnectionOpen();

            SqlParameter[] parameters = new SqlParameter[]
                {
             new SqlParameter(){ Direction=ParameterDirection.Input, SqlDbType =SqlDbType.UniqueIdentifier,ParameterName="@FeedId",Value= input.PostId}
            ,new SqlParameter(){ Direction=ParameterDirection.Input, SqlDbType =SqlDbType.BigInt,ParameterName="@UserId",Value= AbpSession.UserId}
            ,new SqlParameter(){ Direction=ParameterDirection.Input, SqlDbType =SqlDbType.Int,ParameterName="@TenantId",Value= AbpSession.TenantId}
            ,new SqlParameter(){ Direction=ParameterDirection.Input, SqlDbType =SqlDbType.Int,ParameterName="@PostReferenceType",Value= PostReferenceType.Like}
            ,new SqlParameter(){ Direction=ParameterDirection.Input, SqlDbType =SqlDbType.Bit,ParameterName="@IsLike",Value= input.IsLikeClick}
                };

            List&lt;IDataRecord&gt; outputUserOrderdsDataReader = new List&lt;IDataRecord&gt;();
            var outputPOEmailDataReader = new List&lt;IDataRecord&gt;();
            using (var command = _storedProcedureCalling.CreateCommand("LikePostOrComment", CommandType.StoredProcedure, parameters))
            {
                using (var dataReader = await command.ExecuteReaderAsync())
                {
                    if (dataReader.HasRows)
                    {
                        DataTable dt = new DataTable();
                        dt.Load(dataReader);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            LikeCount = Convert.ToInt32(dt.Rows[0]["LikeCount"]);
                            FeedCreatorUserId = Convert.ToInt64(dt.Rows[0]["CreatorUserId"]);
                        }
                    }
                }
            }
           
            if (input.IsLikeClick)
            {
                if ((long)AbpSession.UserId != FeedCreatorUserId)
                {                   
                    await _customNotificationAppService.GenerateLikeNotification((Guid)input.PostId, (long)AbpSession.UserId, "postlike");                     

                }
            }              

        }
        catch (Exception ex)
        {
            Logger.Info("LikePost error: " + ex.StackTrace);
            return 0;
            throw new UserFriendlyException(ex.Message + " " + ex.StackTrace);
        }
        

        return LikeCount;

}

public async Task GenerateLikeNotification(Guid FeedId, long UserId, string LikeType) { _storedProcedureCalling.EnsureConnectionOpen(); List<IDataRecord> outputDataReader = new List<IDataRecord>();

        SqlParameter[] parameters = new SqlParameter[]
        {
                 new SqlParameter(){ Direction=ParameterDirection.Input, SqlDbType =SqlDbType.UniqueIdentifier,ParameterName="@FeedId",Value= FeedId}
                ,new SqlParameter(){ Direction=ParameterDirection.Input, SqlDbType =SqlDbType.BigInt,ParameterName="@SenderUserId",Value= UserId}                    
                ,new SqlParameter(){ Direction=ParameterDirection.Input, SqlDbType =SqlDbType.NVarChar,ParameterName="@LikeType",Value= LikeType}
        };
        
        try
        {
            DataTable dt = new DataTable();
            using (var command = _storedProcedureCalling.CreateCommand("GenerateLikeNotification", CommandType.StoredProcedure, parameters))
            {
                using (var dataReader = await command.ExecuteReaderAsync()) 
                {
                    if (dataReader.HasRows)
                    {
                        dt.Load(dataReader);                            
                    }
                    
                }
            }

            /*real time notification in web*/
            if (dt != null && dt.Rows.Count > 0)
            {
                var notificationData = new LocalizableMessageNotificationData(new LocalizableString(dt.Rows[0]["SendMsgType"].ToString(), CDPConsts.LocalizationSourceName));
                notificationData["0"] = dt.Rows[0]["SenderName"].ToString();

                var userNotifications = new List&lt;UserNotification&gt;();
                userNotifications = dt.AsEnumerable().Select(dataRow => new UserNotification
                {
                    Id = Guid.Parse(dataRow["UserNotificationsId"].ToString()),
                    TenantId = Convert.ToInt32(dataRow["TenantId"]),
                    UserId = Convert.ToInt64(dataRow["ReceiverID"]),
                    State = (UserNotificationState)Convert.ToInt32(dataRow["State"]),
                    Notification = new TenantNotification()
                    {
                        Id = Guid.Parse(dataRow["TenantNotificationId"].ToString()),
                        NotificationName = dataRow["NotificationName"].ToString(),
                        TenantId = Convert.ToInt32(dataRow["TenantId"]),
                        Severity = NotificationSeverity.Info,
                        Data = notificationData,
                        CreationTime = DateTime.UtcNow
                    }
                }).ToList();

                await _realTimeNotifier.SendNotificationsAsync(userNotifications.ToArray());
            }
            
        }
        catch (Exception e)
        {
            Logger.Info("GenerateLikeNotification error: " + e.StackTrace);                
        }

}

Hi @kansoftware,

Sorry for the delay, we'll get back to you as soon as possible.

Hi

Were you able to replicate it? Waiting for your response

Hi @kansoftware

Thanks, we got the email and checking the problem.

Hi Waiting for your response.

Hi,

Is it possible to share a test account with us via [email protected] so we can reproduce on your app to better understand the problem ?

Thanks,

Hi,

I have mailed the required details with subject 'Support ticket no 11564 - Permission denied error on host when session logout from impersonated user'.

Hi,

If you wait till the session expires while you are logged in as a tenant user, then the website keeps TenantId in cookies I guess. Do you go to login page after step 3 ? If so, do you see the Tenant selected on login page ?

Thanks,

Hi,

Yes it goes to the login page after session logout occurs. Our application is tenant domain specific so it redirects to that tenant domain. For eg : https://tenancyname.domain.com

After that we call the admin url and then login with admin. For eg : https://admin.domain.com

Hi @kansoftware

Could you write exact steps to reproduce this problem ? By the way, do you use Angular UI ?

Our project is in asp.net core with jquery. It's a multitenancy app.

  1. I login from host/admin
  2. Then I login to a tenant user through impersonation.
  3. Then we waited till the session log out of that user.
  4. Once the session get's log out of the impersonated user, I again login from host/admin and I get permission denied error

Hi,

I impersonated a user from host and when that user's session get logout and again when I login from host then I get permission denied error. I think that might be previous user permission cache is not cleared, but i am not sure is this the case. I tried to clear user permission cache on login and logout using this line of code: await _permissionCache.RemoveAsync(user.Id.ToString()); but it doesn't work.

Can you please help me out how to resolve this issue.

Showing 61 to 70 of 195 entries