Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "ipservant"

Sorry I have to reopen this. I desperately need a success.

I created a test project using bare NHibernate. I even used the same Entities and the same table(file) ... it worked. So why would it not work with ABP in addition? The test project is able to read the table and insert into it (just after calling Flush). The Entity class looks nearly the same so does the hbm.xml. So far it uses a different ID generator but that generator has never really been the problem. I even replaced it with the same uuid.hex but it makes no differnce. It is actually the only piece that produces SQL towards the DB.

Still my problem is: I can select data out of ABP using NHibernate and my funky DBMS. BUT I cannot Insert any data. (seemingly rolled back?) NO Exceptions happen if the supposed code is running.

Now I am fiddling in the object trees of the UnitOfWork stuff and transactions. Because my suspicion is that somehow a rolback happens. When I use a UnitOfWork-Manager and/or an [UnitOfWorkAttribute], I can see three filters in Abp.Runtime.Session.ClaimsAbpSession

  1. SoftDelete (enabled)
  2. MustHaveTenant (diabled)
  3. MayHaveTenant (enabled)

More things to considder are:

  • The result of me 'calling' my controller is : {"result":null,"targetUrl":null,"success":true,"error":null,"unAuthorizedRequest":false,"__abp":true}
  • In order to be faster in testing, I created an unauthenticated simple Controller that I can 'directly call' from the web browser. Thus I am not logged in, which may be a problem.
  • When I do both, BeginWork with a UnitOfWorkManager plus have the Attribute, I end up getting this:

Abp.AbpException: "Did not call Complete method of a unit of work."

In order to make it work in my test project I had to call Session.Flush()

            OBJEKTE o = new OBJEKTE()
            {
                ID_AKTE = "0000001235",
               ...
                ONLDATUM = System.DateTime.UtcNow,
                SAFETYLVL = "",
                ONLSTATUS = "",
                DATFTS = null,
            };
            List<OBJEKTE> all = sess.Query<OBJEKTE>().ToList();

            string generatedId = (string)sess.Save(o);
            sess.Flush();

Hi, I am forced to use a very special DBMS and we are happy that it at least works with NHibernate. Thus I am using ABP-NHibernate stuff.

So far it works quite well (after some crunches in the beginning). I get my data off the DB and I can use sync LINQ at least. But when it comes to writing to the DB it seeminly works out NOOPs. At least the Debugging measures of NHibernate do not print any SQL insert statements.

What I am trying to do: some controller calls this Manager class' SaveAsync:

    private readonly IObjekteRepository _objRepo;

    public async Task SaveAsync(OBJEKTE entity)
    {
        try
        {
            OBJEKTE res = await _objRepo.InsertAsync(entity);
        }
        catch (Exception h)
        {
            //works well actually
        }
    }

The IObjekteRepository is just an empty derivation of yours in a 2 step process (all needed for DI):

 public class ObjekteRepository : AdsRepositoryBase&lt;OBJEKTE, string&gt;, IObjekteRepository
 {
    public ObjekteRepository(INhIpsSessionProvider sessionProvider) : base(sessionProvider)
    {
    }
}

and finally :

/// &lt;summary&gt;
/// Base class for all repositories based on ADS via NHibernate in this application.
/// &lt;/summary&gt;
public abstract class AdsRepositoryBase&lt;TEntity, TPrimaryKey&gt; : NhRepositoryBase&lt;TEntity, TPrimaryKey&gt;
    where TEntity : class, IEntity&lt;TPrimaryKey&gt;
{
    protected AdsRepositoryBase(ISessionProvider sessionProvider)
        : base(sessionProvider)
    {
    }

    //add common methods for all repositories
}

So because I do not directly use NH but via your NhRepository, let me understand what's going wrong with it? is it because of the string Template as ID? Writing not supported?

I have also implemented a generator for NH and if this is commented in, it will also be invoked. Just the INSERT never happens. I boiled everything down to a very simple insertion but it is not even shown up in the log. Still I am getting a success result. What is still going wrong? File OBJEKTE.hbm.xml:

<class name = "OBJEKTE" > <id name="Id" column="INT_ID"> <!--<generator class="IPSweb.AdsNHibernate.Gen.IpsHiLoGenerator, IPSweb.AdsNHibernate" > </generator>--> </id>

EDIT: Well actually after overriding the Insert method of the Repository using my own implementation of Save() NHibernate still won't do an Insert to the DBMS. Seems like a NHbiernate with ADS problem. But any hints are welcome

Hello,

What is the suggested way to create individual views to display (and later edit) data from multiple tables/entities? We have worked with the RAD tool already, this is a great start but limited to the standards of course. The goal now is to show data from several entities in some sort of overview tab, in some cases process or calculate on the data prior to showing it to the user.

Would also be great being able to open multiple of these overview pages at the same time - either as new browser tab or some kind of floating element in the main tab.

Thank you for letting us know the best practices for Zero before we're starting in a specific direction.

I have the same or a similar Problem after upgrading my source code with the Version 6.7. Must have overtaken like 2 minor versions.

I was able to track it down from

     public override void PostInitialize()
    {
        IocManager.RegisterIfNot&lt;IChatCommunicator,             NullChatCommunicator&gt;();
       IocManager.Resolve&lt;ChatUserStateWatcher&gt;().Initialize();
        
        ..
        //which needs 
        IocManager.Resolve&lt;IUserFriendsCache&gt;();
        //which needs
        IocManager.Resolve&lt;UserManager&gt;();
        //which needs
        var user = IocManager.Resolve&lt;UserStore&gt;();
        //which has apparently a circular reference (see above)

what should we do. Looks harmful to me if no UserManager is there.

OK, I came up with something and I share this with you here: Maybe there is also some inspiration for the future framework.

Essentially I went without initializing the Abp.NHibernate module plus creating my own ISessionFactory singleton which is initialized in PreInitialize().

//[DependsOn(typeof(AbpNHibernateModule))]
[DependsOn(typeof(IPSwebCoreModule))]
public class MyAppAdsDataModule : AbpModule
{
        private ISessionFactory _sessionFactory;
    public override void PreInitialize()
    {
        var connStr = _appConfiguration["ConnectionStrings:AdsConnString"];

        var cfg = new NHibernate.Cfg.Configuration();
        _sessionFactory = Fluently.Configure(cfg)
            .Database(AdsIntegration.ConnectionString(connStr))
            .Mappings(m => m.HbmMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
            .BuildSessionFactory();
    }

Problems arose with satisfying my Repoisitoy class - winsor-castle did not know how to resolve my custom repo.

public class KarteiRepository : AdsRepositoryBase&lt;KARTEIKARTE, int&gt;, IKarteiRepository
{
    public KarteiRepository(INhMySessionProvider sessionProvider) : base(sessionProvider)
    {
    }

In order to avoid clashes (my code used to use ISessionProvider as ctor-Param. So I created my own INhMySessionProvider and programmed it like this:

public interface INhMySessionProvider : ISessionProvider
{ }

public class NhMySessionProvider : INhMySessionProvider
{
    private readonly ISessionFactory f;

    public NhMySessionProvider(ISessionFactory f)
    {
        this.f = f;
    }

    public ISession Session
    {
        get
        {
            return f.OpenSession();
        }
    }
}

Then, the only thing needed to to (to let it be resolved) was to add some lines to my Data module's initialize method:

    public override void Initialize()
    {
        IocManager.IocContainer.Register(
            Component.For&lt;ISessionFactory&gt;().Instance(_sessionFactory).LifeStyle.Singleton,
            Component.For&lt;INhMySessionProvider&gt;().ImplementedBy&lt;NhMySessionProvider&gt;().LifeStyle.Transient);

        IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
    }

PS. AdsIntegration.ConnectionString(connStr) is my customization for SAP Advanced DB. but this is a different topic.

So eventually I did not need Apb.NHibernate. Still my reference is there... let's see

I managed to create a separate NHibernate assembly for the DB access and the custom repositories (ones that inherit IRepository) plus a MyAppNhRepositoryBase abstract base implementation. I still have my Module a such:

[DependsOn(typeof(AbpNHibernateModule))]
[DependsOn(typeof(IPSwebCoreModule))]
public class MyAppdsDataModule : AbpModule
{

Now what happens depends on the order on my main module.

if the order of the attributes is like so:

    [DependsOn(
    typeof(MyAppEntityFrameworkCoreModule),
    typeof(MyAppNHibDataModule),
    ...
    typeof(AbpHangfireAspNetCoreModule) 
)]
public class MyAppWebCoreModule : AbpModule
{

I get this exception at startup in UnitOfWorkBase.cs: System.InvalidCastException: "Unable to cast object of type 'Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork' to type 'Abp.NHibernate.Uow.NhUnitOfWork'." .. and similar ones

however if the oder is reverse like so:

    [DependsOn(
    typeof(MyAppNHibDataModule),
    typeof(MyAppEntityFrameworkCoreModule),
    ...
    typeof(AbpHangfireAspNetCoreModule) 
)]
public class MyAppWebCoreModule : AbpModule
{

The result is that IRepository<User> gets resolved with an NH-Implementation of IRepository.

I understand, why that happens and I know that castle windsor can be highly customized. But I rather want to ask especially what or how I should customize the resolution/registration of types.

  1. Is it at all possible to use NH and the AbpNHibernateModulein conjunction with EF?
    1. Or will it clash central components?
  2. If yes, how can it be accomplished and is there a forseen way?
  3. Can I claim land if I omit dependency of AbpNHibernateModule and register the AbpNHibernate classes myself with WC?

Hi, in our situation, we want to use two DBs for our application. Because it is the web port of an existing App, we still need access to the old DB data. And that DBMS is barely supported by NHibernate, not talking about EF core.

So my approach is to keep the MyApp.EntityFrameworkCore assembly as is AND create a new Assembly MyApp.NHibernateAccess Then all the User, Role, Log, ... access will be made using EF core (as in the downloaded template) and my access to the existing data would go via repositories to the old DBMS via NHibernate.

Is this a known or valid way to have several IRepository<> of different ORMs? I anticipate some problems when IoC-resolving just a IRepository<EntityX>. Well, I could just restrict myselt to creating custom IBlaBlaRepository repositories. And they should be resolved by Windsor Castle just fine.

Here are some problems that I had when trying this approach:

I followed basically the steps off ASP.Net boilerplate to using NHibernate. (https://aspnetboilerplate.com/Pages/Documents/NHibernate-Integration)

So I crated a module (as abp supposes) and depended on AbpNHibernateModule.

    [DependsOn(typeof(AbpNHibernateModule))]
    [DependsOn(typeof(IPSwebCoreModule))]
    public class MyAppdsDataModule : AbpModule
    {

This causes AbpNHibernateModule to IoC-register it's verions of UnitOfWork implementations. Which gives me an exception in MyApp.EntityFrameworkCore.DatabaseCheckHelper :

Exception : "Unable to cast object of type 'Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork' to type 'Abp.NHibernate.Uow.NhUnitOfWork'."

At:

            try
            {
                using (var uow =_unitOfWorkManager.Begin())  <<----
                {

So the question rather goes like: Is there a place to further configure the IoC-Container to return the right type depending on a string or requesting type (feature of WC)? or is there a need to include [DependsOn(typeof(AbpNHibernateModule))]? Because if I leave this commented out, it does not create conflicting IoC-registrations.... So far... just being confused.

Hi, eger to add a new page to the navigation. Like so:

new AppMenuItem('Editions', 'Pages.Editions', 'flaticon-app', '/app/admin/editions'), I wantet do give it its own icon. But I can't make sense of that flaticon-* stuff. Seems to be a font in different formats but what are the supported names and what icons are included in there. Please give me some starting point.

Maybe that also explains how I could possibly extend the supplied icon set with my own or downloaded ones.

Showing 41 to 48 of 48 entries