Base solution for your next web application

Activities of "kansoftware"

We are upgrading our project from ASP.NET Zero 8 to 12.1 (Metronic V6 to V8). Currently, we are encountering issues with the main header menu. Upon increasing the number of menu items in the list, some items have become invisible, and the scrollbar is not visible to check the bottom menu items. Project Type: ASP .NET Core + jQuery.

Thanks

Currently our application is a multi tenant with single host database. But now we are switching to multi database i.e. tenant specific database. We use stored procedures, user defined functions, triggers, and so on in sql for our application.

I there a way I can manage this scripts for tenant database, so that I don't need do it manually in sql each time I create a new tenant. Also how can I maintain that for all tenant database whenever I create a new procedure.

Currently our application is a multi tenant with single host database. But now we are switching to multi database i.e. tenant specific database. We were using stored procedures to perform task. I have a StoredProcedureCalling.cs class. So my doubt is, what changes are required to be made in my StoredProcedureCalling.cs for multi-database so that during execution it will use the tenant specific database.

Below is the definition of StoredProcedureCalling.cs

using Abp.Data; using Abp.EntityFrameworkCore; using Microsoft.Data.SqlClient; using System.Data; using System.Data.Common; using CDP.EntityFrameworkCore.Repositories; using CDP.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Abp.Domain.Entities; using System.Threading.Tasks;

namespace CDP.StoredProcedures { public class StoredProcedureCalling<TEntity, TPrimaryKey> : CDPRepositoryBase<TEntity, TPrimaryKey>, IStoredProcedureCalling<TEntity, TPrimaryKey> where TEntity : class, IEntity<TPrimaryKey> { private readonly IActiveTransactionProvider _transactionProvider;

    public StoredProcedureCalling(IDbContextProvider&lt;CDPDbContext&gt; dbContextProvider, IActiveTransactionProvider transactionProvider)
        : base(dbContextProvider)
    {
        _transactionProvider = transactionProvider;
    }

    public DbCommand CreateCommand(string commandText, CommandType commandType, params SqlParameter[] parameters)
    {
        var command = Context.Database.GetDbConnection().CreateCommand();

        command.CommandText = commandText;
        command.CommandType = commandType;
        command.Transaction = GetActiveTransaction();

        foreach (var parameter in parameters)
        {
            command.Parameters.Add(parameter);
        }

        return command;
    }

    public void EnsureConnectionOpen()
    {
        var connection = Context.Database.GetDbConnection();

        if (connection.State != ConnectionState.Open)
        {
            connection.Open();
        }
    }

    public DbTransaction GetActiveTransaction()
    {
        return (DbTransaction)_transactionProvider.GetActiveTransaction(new ActiveTransactionProviderArgs
        {
            {"ContextType", typeof(CDPDbContext) },
            {"MultiTenancySide", MultiTenancySide }
        });
    }

}

}

And I have ActionItemAppService where I am calling the procedure

public class ActionItemsAppService : CDPAppServiceBase, IActionItemsAppService { private readonly IStoredProcedureCalling<Tenant, int> _storedProcedureCalling; public ActionItemsAppService(IDbContextProvider<CDPDbContext> dbContextProvider,IActiveTransactionProvider transactionProvider) { _storedProcedureCalling = new StoredProcedureCalling<Tenant, int>(dbContextProvider, transactionProvider); }

 public async Task&lt;List&lt;GetActionItemsForViewDto&gt;> GetAllActionItemsList(GetAllActionItemsInput input)
    {

        List&lt;GetActionItemsForViewDto&gt; ActionItemList = new List&lt;GetActionItemsForViewDto&gt;();

        _storedProcedureCalling.EnsureConnectionOpen();
        List&lt;IDataRecord&gt; outputPostDataReader = new List&lt;IDataRecord&gt;();

        SqlParameter[] parameters = new SqlParameter[]
        {
             new SqlParameter(){ Direction=ParameterDirection.Input, SqlDbType =SqlDbType.BigInt,ParameterName="@TenantID",Value=AbpSession.TenantId},
         };

        try
        {

            using (var command = _storedProcedureCalling.CreateCommand("GetAllActionItems", CommandType.StoredProcedure, parameters))
            {
                using (var dataReader = await command.ExecuteReaderAsync())
                {
                    if (dataReader.HasRows)
                    {
                        outputPostDataReader = dataReader.Cast&lt;IDataRecord&gt;().ToList();
                    }

                }

                foreach (var user in outputPostDataReader)
                {
                    var ActionItem = new GetActionItemsForViewDto
                    {
                        Id = user.GetInt64(user.GetOrdinal("Id")),
                        Title = user.GetString(user.GetOrdinal("Title")),
                    };
                    ActionItemList.Add(ActionItem);
                }

            }
        }
        catch (Exception ex)
        {
            throw new UserFriendlyException(ex.Message + " " + ex.StackTrace);
        }

        return ActionItemList;
    }

}

Hi,

I want use localization for only language in both side client and server side, do not want to change date format and numeric / decimal format.

Could you please help for this.

Thanks Regards Mohit

I want to format message from user notification in app service just the same way we use abp.notifications.getFormattedMessageFromUserNotification(userNotification) in JS to do the same. Can you please help me out.

Hi, Our application is failed in VAPT test for, Cryptographic failure - Password sent in Clear text format

Check below details:

**Threat Description: ** The pathway of sensitive data like passwords is reflected in plain texts which leads the intruders to get these details by capturing the HTTP requests either using from wire shark or burp suite or any malicious attempts. Impact: A third-party attacker is able to read the user credentials like passwords by intercepting a connection. Evidence: In the below screen shot, we will intercept and capture the login username and password request in Burpsuite.

Recommendations: • It is recommended to use strong encryption algorithm like SHA512 to encrypt sensitive data in transit. • All sensitive parameters must be encrypted using strong algorithm

Please provide the solution for this test, while login the application

We have upgraded our existing project from 8.1 to 12.3 and with use of asp.net core + jQuery .Here for every confirmation message we get two buttons "OK" and "Cancel" but we want to replace them with "Yes" and "No" respectively. For this we renamed "OK" with "Yes" and "Cancel" with "No" in app-layout-libs.min.js file. By this the purpose for confirmation message was resolved but if any other sweet alert and error message is coming in that case instead of "OK" here also "Yes" is shown.

Concern is that , we want to show "Yes" and "No" buttons for any confirmation message and for sweet alert and error message where on single is visible "OK" should be shown. kindly look into this on urgent basis and let us know about the solution ASAP.

Thanks

Hi Team,

On Upgrading Aspnetzero version from 8.1 to 12.1

We are getting UI Issues as Metronics version got upgraded along with the Bootstrap from 4 to 5 Now we are facing various issue with Data-toggle like tabs, Dropdowns, tooltips etc. not working please find the below screenshot where we have made changes to make it work. But we have more than 500 pages in entire application where this is getting utilized. Please guide us in the same.

Also what would happen if we create a new entity will it new classes or the old one? Regards, Harshit

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,

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);                
        }

}

Showing 21 to 30 of 96 entries