eXpandFramework / eXpand

DevExpress XAF (eXpressApp) extension framework. 𝗹𝗶𝗻𝗸𝗲𝗱𝗶𝗻.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺, 𝘆𝗼𝘂𝘁𝘂𝗯𝗲.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺 and 𝘁𝘄𝗶𝘁𝘁𝗲𝗿 @𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸 and or simply 𝗦𝘁𝗮𝗿/𝘄𝗮𝘁𝗰𝗵 this repository and get notified from 𝗚𝗶𝘁𝗛𝘂𝗯
http://expand.expandframework.com
Microsoft Public License
222 stars 115 forks source link

ModelViewInheritance not working when creating IModelMergedDifferences in Setup(ApplicationModulesManager moduleManager) #946

Closed krombipils closed 9 months ago

krombipils commented 2 years ago

I'm trying to use your ModelViewInheritance module similar to the sample linked on the documentation (https://www.youtube.com/watch?v=uh4SMPwJ5pU). Unfortunately this does not seem to work.

I think the problem is, that ModelViewInheritanceService.CreateUnchangeableLayer() is executed before IModelMergedDifferences nodes are created in the moduleManager.WhenGeneratingModelNodes(){...}.

apobekiaris commented 2 years ago

does not work in runtime as well?

krombipils commented 2 years ago

For me it also does not work in runtime. I attached a small sample project. In this project I create ModelMergedDifference nodes with View = BaseObject_ListView.

moduleManager.WhenGeneratingModelNodes<IModelMergedDifferences>()
    .Do(differences =>
    {
        var diff = differences.AddNode<IModelMergedDifference>("MergedDiffFromSetup");
        diff.View = (IModelListView)differences.Application.Views.GetNode("BaseObject_ListView");
    }).Subscribe(this);

ModelChanges of the BaseObject_ListView, e.g. ShowGroupPanel are not merged, e.g. to the PersistentClass1_ListView. For the PersistentClass2_ListView I added another ModelMergedDifference node with the ModelEditor. Now the changes are merged to PersistentClass2_ListView.

I think the ModelViewInheritance module has another problem, when using the new simplified XAF solution structure: By default there is no win specific module anymore and changes are directly stored in the Model.xafml of the win executable project. The Model.xafml has a 'Content' build action, but the CreateUnchangeableLayer implementation searches for embedded resources diffs. Am I right?

ModdelInheritanceTest.zip

apobekiaris commented 2 years ago

I think the ModelViewInheritance module has another problem, when using the new simplified XAF solution structure: By default there is no win specific module anymore and changes are directly stored in the Model.xafml of the win executable project. The Model.xafml has a 'Content' build action, but the CreateUnchangeableLayer implementation searches for embedded resources diffs. Am I right?

most probably the package was not desinged with the front end model in mind. It will take some time to examine the case be aware. Do I understand correctly that the problem is also there when u using embedded models?

apobekiaris commented 2 years ago

By default there is no win specific module anymore and changes are directly stored in the Model.xafml of the win executable project. The Model.xafml

i think we already have an auto merge all embeded models functionality, did u tried to add a new embeded model to your project?

https://github.com/eXpandFramework/Reactive.XAF/blob/58e357d4d619144da1bf5f2f982f35236c1b873c/src/Modules/Reactive/RXApp.cs#L140

krombipils commented 2 years ago

Never used your MDO concept. So what do you suggest? Add a MDO embedded resource to the win project and check if ModelViewInheritance works?

apobekiaris commented 2 years ago

if it works for a module with embedded models the MDO is no differnent

apobekiaris commented 2 years ago

and the Win project if it has a ModuleBase descenant also behaves like a hybrid module-frontend

apobekiaris commented 2 years ago

if it does not have just add one and register it with your app

krombipils commented 2 years ago

You mean adding an embedded model in addition to the model.xafml in the win project? Nevertheless right now, the ModelViewInheritance does not work, when using embedded models (I have one in my agnostic module). Imho the service does not 'see' the ModelMergedDifferences nodes, because they are created 'too late'.

apobekiaris commented 2 years ago

You mean adding an embedded model in addition to the model.xafml i

yes and the Win project should also have a ModuleBase descenant added to your Application.Modules collection

Imho the service does not 'see' the ModelMergedDifferences nodes, because they are created 'too late'.

first u add the node, then u compile then u open again the ME and it should see

apobekiaris commented 2 years ago

note there are a few test on the package that test the runtime and they green so at least some parts should work

apobekiaris commented 2 years ago

apologies the previous link i posted with MDO should not work in this case as it uses WhenCreateCustomUserModelDifferenceStore this is too late merge, u need to add a new agnostic module project to host your models

apobekiaris commented 2 years ago
 var streams = modelDifferenceStores.OfType<ResourcesModelStore>()
                .Select(store => {
                    var assembly = ((Assembly) store.GetFieldValue("assembly"));
                    var value = (string) store.GetFieldValue("modelDesignedDiffsName");
                    var name = assembly.GetManifestResourceNames().FirstOrDefault(s => s.EndsWith(value));
                    return name != null ? (stream:assembly.GetManifestResourceStream(name),assembly,modelName:value) : default;
                })
                .WhereNotDefault();

modifying this method on the ModelViewInheritanceService to included additional emdedded models might help resolve this case

krombipils commented 2 years ago

In my agnostic model I have this embedded model diff:

grafik

In the runtime model editor, the MergedDifference node is created, but for the PersistentClass1_Listview, the diff is not inherited/merged:

grafik

But for the PersistentClass2_ListView (with a MergedDifference node created in the embedded resource model), the diff is merged:

grafik

apobekiaris commented 2 years ago

assuimng u already

first u add the node, then u compile then u open again the ME and it should see

unfortunately i cannot help u unless i spent time debugging it

krombipils commented 2 years ago

No problem, it's not that urgentl

apobekiaris commented 2 years ago

it should be rather easy to debug it yourself is just one method CreateUnchangeableLayer and u know how to compile now. In any case if u attempt it let me know please so we do not double spent resources

krombipils commented 2 years ago

I already tried to debug. In CreateUnchangeableLayer you load the embedded models and try to get 'rules'. But nodes added in the WhenGeneratingModelNodes are not 'physically' added to the models. Am I wrong?

apobekiaris commented 2 years ago

as far as I remember was some model layers reposition, that is collecting the diffs and position them in the generation layer, not sure if this funcationality works, but should given that u said:

But for the PersistentClass2_ListView (with a MergedDifference node created in the embedded resource model), the diff is merged:

and as I understand u having problems merging views of different types e.g. BaseListView

krombipils commented 2 years ago

u having problems merging views of different types e.g. BaseListView I'm having problems, when trying to setup the merging 'dynamically' in the the Setup(...) override. Adding the merging directly/physically in the model is working fine. Actually I'm trying to combine cloning and merging (based on some conditions) and therefore I need this dynamic/runtime approach

apobekiaris commented 2 years ago

hopefully your sample demos your problem clear enough, if not please repost it

apobekiaris commented 2 years ago

I upgrade Harmony and restore design time for all related packages e.g. ModelViewInheritance, ModelMapper etc. In my tests I see no issues for both Xpand or native ModelEditors. However the approach of the doc is not implemented you can use the model for now

apobekiaris commented 2 years ago

that for the next minor

apobekiaris commented 2 years ago

The pre-release 4.221.5.0 in the Reactive.XAF lab branch includes commits that relate to this task:

To minimize version conflicts we recommend that you use the Xpand.XAF.Core.All, Xpand.XAF.Win.All, Xpand.XAF.Web.All packages. Doing so, all packages will be at your disposal and .NET will add a dependecy only to those packages that you actually use and not to all (see the Modules installation-registrations youtube video).

Released packages: Xpand.Extensions v.4.221.5
Xpand.Extensions.Blazor v.4.221.5
Xpand.Extensions.Mono.Cecil v.4.221.5
Xpand.Extensions.Office.Cloud v.4.221.5
Xpand.Extensions.Office.Cloud.Google.Blazor v.4.221.5
Xpand.Extensions.Reactive v.4.221.5
Xpand.Extensions.XAF v.4.221.5
Xpand.Extensions.XAF.Xpo v.4.221.5
Xpand.TestsLib v.4.221.5
Xpand.TestsLib.Blazor v.4.221.5
Xpand.TestsLib.Common v.4.221.5
Xpand.TestsLib.EasyTest v.4.221.5
Xpand.VersionConverter v.4.221.5
Xpand.XAF.Core.All v.4.221.5
Xpand.XAF.Modules.AutoCommit v.4.221.5
Xpand.XAF.Modules.Blazor v.4.221.5
Xpand.XAF.Modules.BulkObjectUpdate v.4.221.5
Xpand.XAF.Modules.CloneMemberValue v.4.221.5
Xpand.XAF.Modules.CloneModelView v.4.221.5
Xpand.XAF.Modules.Email v.4.221.5
Xpand.XAF.Modules.GridListEditor v.4.221.5
Xpand.XAF.Modules.HideToolBar v.4.221.5
Xpand.XAF.Modules.JobScheduler.Hangfire v.4.221.5
Xpand.XAF.Modules.JobScheduler.Notification v.4.221.5
Xpand.XAF.Modules.MasterDetail v.4.221.5
Xpand.XAF.Modules.ModelMapper v.4.221.5
Xpand.XAF.Modules.ModelViewInheritance v.4.221.5
Xpand.XAF.Modules.Office.Cloud.Google v.4.221.5
Xpand.XAF.Modules.Office.Cloud.Google.Calendar v.4.221.5
Xpand.XAF.Modules.Office.Cloud.Google.Tasks v.4.221.5
Xpand.XAF.Modules.Office.Cloud.Microsoft v.4.221.5
Xpand.XAF.Modules.Office.Cloud.Microsoft.Calendar v.4.221.5
Xpand.XAF.Modules.Office.Cloud.Microsoft.Todo v.4.221.5
Xpand.XAF.Modules.Office.DocumentStyleManager v.4.221.5
Xpand.XAF.Modules.OneView v.4.221.5
Xpand.XAF.Modules.PositionInListView v.4.221.5
Xpand.XAF.Modules.ProgressBarViewItem v.4.221.5
Xpand.XAF.Modules.RazorView v.4.221.5
Xpand.XAF.Modules.Reactive v.4.221.5
Xpand.XAF.Modules.Reactive.Logger v.4.221.5
Xpand.XAF.Modules.Reactive.Logger.Client.Win v.4.221.5
Xpand.XAF.Modules.Reactive.Logger.Hub v.4.221.5
Xpand.XAF.Modules.Reactive.Rest v.4.221.5
Xpand.XAF.Modules.RefreshView v.4.221.5
Xpand.XAF.Modules.SequenceGenerator v.4.221.5
Xpand.XAF.Modules.Speech v.4.221.5
Xpand.XAF.Modules.StoreToDisk v.4.221.5
Xpand.XAF.Modules.SuppressConfirmation v.4.221.5
Xpand.XAF.Modules.TenantManager v.4.221.5
Xpand.XAF.Modules.ViewEditMode v.4.221.5
Xpand.XAF.Modules.ViewItemValue v.4.221.5
Xpand.XAF.Modules.ViewWizard v.4.221.5
Xpand.XAF.Modules.Windows v.4.221.5
Xpand.XAF.Web.All v.4.221.5
Xpand.XAF.Win.All v.4.221.5

Please update the related Nuget packages and test if issues is addressed. These are nightly nuget packages available only from our NugetServer.

If you do not use these packages directly but through a module of the main eXpandFramework project, please wait for the bot to notify you again when integration is finished or update the related packages manually.

Thanks a lot for your contribution.

expand commented 9 months ago

Closing issue for age. Feel free to reopen it at any time.

.Thank you for your contribution.