Base solution for your next web application

Activities of "vnetonline"

Thanks. Works perfectly!!

Hi.

Just needed to call a stored procedure from within the AppService. I had a look at this page,

#3001@1ae4525e-277b-4e15-9771-14ec911be476

but it still isn't very clear as to how to implement this. Your help would be much appreciated.

Thinking of doing something on these lines

    public async System.Threading.Tasks.Task<System.Collections.Generic.List<int>> CallStoreProc()
    {
        return await Context.Database.SqlQuery<int>("get_id_of_customer").SingleAsync();
    }

Regards

The only problem with that approach would be that if the migration files are lost, the change is going to be lost too.. See if you or someone in the team can come up with a solution, otherwise we will just let cascade delete to be set to false for this one table. It shouldn't affect the app in any ways.

Regards

Thank you very much for this.

I think the write permission is the reason for the log file not being deployed.

However, with regards to the first problem, I still cannot make the cascade delete false.

modelBuilder.Entity<EditionFeatureSetting>().HasMany(r => r.Edition).WithRequired().WillCascadeOnDelete(true);

Had there been a ICollection<Feature> property this would have worked. Edition is not a collection (since the relationship between edition and feature is one to many) and this does not compile.

Can someone help out with this please.

Hi

Two questions here

Firstly, I am trying to remove the cascade delete conventions using modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>()

However it gives me a migration file with the following entries

public override void Up() { DropForeignKey("dbo.AbpFeatures", "EditionId", "dbo.AbpEditions"); DropForeignKey("dbo.AbpPermissions", "RoleId", "dbo.AbpRoles"); DropForeignKey("dbo.AbpUserClaims", "UserId", "dbo.AbpUsers"); DropForeignKey("dbo.AbpUserLogins", "UserId", "dbo.AbpUsers"); DropForeignKey("dbo.AbpPermissions", "UserId", "dbo.AbpUsers"); DropForeignKey("dbo.AbpUserRoles", "UserId", "dbo.AbpUsers");

        AddForeignKey("dbo.AbpFeatures", "EditionId", "dbo.AbpEditions", "Id");
        AddForeignKey("dbo.AbpPermissions", "RoleId", "dbo.AbpRoles", "Id");
        AddForeignKey("dbo.AbpUserClaims", "UserId", "dbo.AbpUsers", "Id");
        AddForeignKey("dbo.AbpUserLogins", "UserId", "dbo.AbpUsers", "Id");
        AddForeignKey("dbo.AbpPermissions", "UserId", "dbo.AbpUsers", "Id");
        AddForeignKey("dbo.AbpUserRoles", "UserId", "dbo.AbpUsers", "Id");

}

Hence it is removing the cascade deletes from some core tables that came with Aspnet boiler plate, which I don't want to do. To overcome this behavior I added this piece of code below after the call to modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();

        modelBuilder.Entity&lt;Role&gt;().HasMany(r => r.Permissions).WithRequired().WillCascadeOnDelete(true);
        modelBuilder.Entity&lt;User&gt;().HasMany(u => u.Roles).WithRequired().WillCascadeOnDelete(true);
        modelBuilder.Entity&lt;User&gt;().HasMany(u => u.Permissions).WithRequired().WillCascadeOnDelete(true);
        modelBuilder.Entity&lt;User&gt;().HasMany(u => u.Logins).WithRequired().WillCascadeOnDelete(true);
        modelBuilder.Entity&lt;User&gt;().HasMany(u => u.Claims).WithRequired().WillCascadeOnDelete(true);

This works and now the only entry I get in the migration file is DropForeignKey("dbo.AbpFeatures", "EditionId", "dbo.AbpEditions"); AddForeignKey("dbo.AbpFeatures", "EditionId", "dbo.AbpEditions", "Id");

Basically, this is because I have not been able to locate the AbpFeature and AbpEdition tables that have access to the Edition Id and the Edition collection. Can you refer me to the code classes for these tables.

Secondly, where do I view the logs. There is a logs.txt on my dev environment, but cannot seem to find this file on production (IIS). Is there a config setting that I have to change somewhere for logs to be displayed on the server. I see there is a AbpAuditLogs table in the database, however it does not store the errors that are thrown when incorrect data is passed through the REST api in swagger.

Thanks for all the help..

Thank you for your response, although in the custom session implementation, the break point does not hit SignInAsync(User user, ClaimsIdentity identity = null, bool rememberMe = false) . However I investigated further to find out that the username does get populated in the claims object which can be retrieved simply by doing a var cp = claimsPrincipal.Claims.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name");

Since it is this simple to get a username and the fact that it is highly unlikely that we will need to get any objects from the other context within this context's core functions, this solution will do. I guess the problem was accessing the other context within the methods of this context which is not a good practice in either case. In normal scenario, I would be using repositories.

Thanks though as your response directed me to the correct solution.

Thank you for your prompt reply as always.

After setting the MSDTC (Distributed Transaction Coordinator windows service) to be enabled on both the database server and the web server, I get the following error

The underlying provider failed on Commit. System.Data.Entity.Core.EntityException: The underlying provider failed on Commit. ---> System.ArgumentNullException: Value cannot be null. Parameter name: connection

I was thinking on giving up on this approach and instead use the sessions object to pass the value. Hence any documentation on custom session objects would be very helpful. When I googled this, I got the link below, but would appreciate it if you can refer me to the correct github repository for adding claims to sessions.

#41@d7ff85a3-fbf9-44f1-ab2c-2d3de54aec24

Thanks

Hi

There are two contexts in my application, one is the standard context and the other the database first context which talks to another database.

Normal context public class NormalContext : AbpZeroDbContext<Tenant, Role, User>

and Database first context

public class MyDbContext : AbpDbContext

I need to fetch some information from NormalContext within the MyDbContext. I am currently using the following function in MyDbContext

    private string GetUserName(long? userId)
    {
        if (userId == null)
            return null;
        using (var context = LocalIocManager.Resolve&lt;NormalContext &gt;())
        {
            var user = context.Users.Find(userId);
            return user.Name;
        }
    }

However this throws an exception

nHandling.AbpApiExceptionFilterAttribute - The underlying provider failed on Open. System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.Transactions.TransactionAbortedException: The transaction has aborted. ---> System.Transactions.TransactionPromotionException: Failure while attempting to promote transaction. ---> System.Data.SqlClient.SqlException: MSDTC on server 'PC120' is unavailable.

PC120 is the local server that hosts the database for the NormalContext .

I dont know if I am resolving the NormalContext in the right manner.

Any help would be appreciated here.

Thanks for directing me to the correct reference. I eventually ending up overriding the two methods namely SetCreationAuditProperties and SetModificationAuditProperties.

Showing 21 to 30 of 57 entries