Forums
Forums are Read-Only. Use the new Support Center. To start a general discussion, use the General category when submitting your question.

A reusable XAF module for storing model settings in the database (security system type insensitive!)

Last post 5/8/2012 3:18 AM by dab2001 dab2001. 40 replies.
1 2 3 Next
Sort Posts: Previous Next
  • Dennis (DevExpress Support)

    Gift [G] A reusable XAF module for storing model settings in the database (security system type insensitive!)

    12/27/2011 10:34 AM
    • Top 25 Contributor
    • Joined on 7/16/2007
    • Posts 1,755

    Last week I helped to a customer who tried to marry our E2813 and E968 examples. After helping the customer, I decided to refactor the latter example to make it more universal. Of course, fortune and hunger for coding are not the only reasons for this. I remember that in the past, our customers wanted to use E968 with different security strategies while we only had an example for the simple security system, which is not as popular. Another reason is that the way of managing settings for all application users can be improved (currently it is possible by running the application with a special command line parameter). Finally, the current example class structure might be simplified. So, I decided to kill all these birds with a single stone.

    Attached is a zipped version of what I came up with in the end. Notice the new DbModelStore XAF module  that is ready to use in your application. It depends on the core stuff only. The core of the module itself is a couple of persistent classes used to store model differences and aspects in the database + a custom ModelDifferenceStore. You can provide your own versions of persistent classes as they both implement the base IModelAspect and IModelDifference interfaces. Of course, a custom ModelDifferenceStore talks to interfaces instead of real classes.
    If you provide your own versions of these classes you can specify their types via the respective ModelAspectType and ModelDifferenceType properties of the DbModelStore module (via the Application Designer).

    To manage default model settings for all users, a special Configurator user is used (if the security system is enabled). I have also shared a small video to show this process in action.
    Take special note that once the configuration is finished, users must restart their applications. If you want, you can specify a custom user name via the respective property of the DbModelStore module.

    I hope that one day a similar functionality will be implemented in our framework by default. At least, this is the first step toward it;-)
    As always, I will be glad to hear your feedback on how this works and whether you like what you see. Thank you in advance!

  • Nate Laff

    Re: A reusable XAF module for storing model settings in the database (security system type insensitive!)

    12/27/2011 11:17 AM
    • Top 50 Contributor
    • Joined on 5/6/2007
    • Denver, CO
    • Posts 595
    That looks good, Dennis! I will try to implement later. I use the previous example of this, and prefer the -admin switch for "Admin Mode" to the seperate "Configurator" user. So will probably retain that, but other than that, very nice!
  • James Zhong

    Re: A reusable XAF module for storing model settings in the database (security system type insensitive!)

    12/29/2011 8:57 AM
    • Top 500 Contributor
    • Joined on 10/13/2010
    • Posts 68

    Hello Dennis, 

    I've viewed your screencast. This feature is very useful, and I hope it will be introduced into XAF soon, supporting the new (improved) security systems.  

    By making this useful feature generally available, XAF developers will benefit from the simplified and more flexible model data storing. 

    Regards,
    James 

  • Dennis (DevExpress Support)

    Re: A reusable XAF module for storing model settings in the database (security system type insensitive!)

    1/12/2012 10:11 AM
    • Top 25 Contributor
    • Joined on 7/16/2007
    • Posts 1,755
    Thank you for the feedback, guys. I have published this version of the solution at Code Central.
  • John Botibol

    Re: A reusable XAF module for storing model settings in the database (security system type insensitive!)

    1/13/2012 4:05 AM
    • Top 100 Contributor
    • Joined on 8/16/2007
    • Dorset, UK
    • Posts 235

    Hi Dennis

    This is a great example as is the reference section on it in the documentation, thank you. I have one question if I may...

    If an Administrator does something silly to the Model (stored in the database) which causes the application to break and users can no longer logon, how would you rectify that so the application can run without recourse to deleting database records?

    Many thanks

    John  

  • Dennis (DevExpress Support)

    Re: A reusable XAF module for storing model settings in the database (security system type insensitive!)

    1/13/2012 5:59 PM
    • Top 25 Contributor
    • Joined on 7/16/2007
    • Posts 1,755

    John Botibol:
    If an Administrator does something silly to the Model (stored in the database) which causes the application to break and users can no longer logon, how would you rectify that so the application can run without recourse to deleting database records?

    What is the best solution in this situation for you? Tell me and I will think about its implementation.

  • Dennis (DevExpress Support)

    Re: A reusable XAF module for storing model settings in the database (security system type insensitive!)

    1/17/2012 5:12 PM
    • Top 25 Contributor
    • Joined on 7/16/2007
    • Posts 1,755
    Based on the feedback I received I have updated the DatabaseModelDifferenceStore implementation a little bit - it now takes into account the default model settings stored in the Model.XAFML file (it was not available in the first version and the Configurator user was used there instead).
  • John Botibol

    Re: A reusable XAF module for storing model settings in the database (security system type insensitive!)

    1/18/2012 4:01 AM
    • Top 100 Contributor
    • Joined on 8/16/2007
    • Dorset, UK
    • Posts 235

    Dennis (DevExpress Support):
    What is the best solution in this situation for you? Tell me and I will think about its implementation.

    I guess maybe a startup switch to load a blank model. It's a tricky one but the first time I tried out eXpand this is what happened, I made a change in the Model which caused the application to throw a fatal error and there was no way back. 

    Best wishes

    John 

  • Dennis (DevExpress Support)

    Re: A reusable XAF module for storing model settings in the database (security system type insensitive!)

    1/18/2012 4:50 AM
    • Top 25 Contributor
    • Joined on 7/16/2007
    • Posts 1,755

    John, in my current implementation I throw an exception when this situation occurs (because I consider that without any model settings users should not access their applications - there may be some critical settings in a generic case). You can modify the code and not throw an exception, and thus prevent the application execution, e.g. you can just write the error into the log file...

    Simply try to comment the lines where I throw the exceptions. Hope this helps.

     

  • Robert Fuchs

    Re: A reusable XAF module for storing model settings in the database (security system type insensitive!)

    1/18/2012 4:34 PM
    • Top 25 Contributor
    • Joined on 5/4/2007
    • Tirol, Austria
    • Posts 2,495
    Maybe a dumb question, but how can I run it for the thirst time?
    I get: “Cannot load model differences from the database.”
     
    Robert
     
     
     
  • Dennis (DevExpress Support)

    Re: A reusable XAF module for storing model settings in the database (security system type insensitive!)

    1/18/2012 4:59 PM
    • Top 25 Contributor
    • Joined on 7/16/2007
    • Posts 1,755
    Robert Fuchs:
    Maybe a dumb question, but how can I run it for the thirst time?
    I get: “Cannot load model differences from the database.”
     
    Robert
     
     
     

    I appreciate your interest, Robert. Hm, it runs prettry well for me. I have just double-checked it with a fresh db. Probably you are using some outdated version, e.g. the one I posted in the beginning. I suggest you download the one from E968 I updated today.
  • Robert Fuchs

    Re: A reusable XAF module for storing model settings in the database (security system type insensitive!)

    1/18/2012 6:53 PM
    • Top 25 Contributor
    • Joined on 5/4/2007
    • Tirol, Austria
    • Posts 2,495
    > Probably you are using some outdated version, e.g. the one I posted in the beginning. I suggest you download the one from E968 I updated today.
     
    I downloaded the newest version at about 10 PM.
    I’ll clear cache and re-download.
     
    Robert
     
     
  • Robert Fuchs

    Re: A reusable XAF module for storing model settings in the database (security system type insensitive!)

    1/18/2012 7:27 PM
    • Top 25 Contributor
    • Joined on 5/4/2007
    • Tirol, Austria
    • Posts 2,495
    Sorry, my fault. Forgot to uncomment a connection string in app.config.
    Oh my, I’m getting old.
     
    And tired.
    Going to bed now, 1:25 AM
     
    Robert
     
  • Dennis (DevExpress Support)

    Re: A reusable XAF module for storing model settings in the database (security system type insensitive!)

    1/19/2012 4:22 AM
    • Top 25 Contributor
    • Joined on 7/16/2007
    • Posts 1,755
    Robert Fuchs:
    Sorry, my fault. Forgot to uncomment a connection string in app.config.
    Oh my, I’m getting old.
     
    And tired.
    Going to bed now, 1:25 AM
     
    Robert
     

    Thank you for informing us of your results, Robert!
  • Dennis (DevExpress Support)

    Re: A reusable XAF module for storing model settings in the database (security system type insensitive!)

    1/30/2012 7:33 AM
    • Top 25 Contributor
    • Joined on 7/16/2007
    • Posts 1,755

    I have just updated this example by adding ExportUserSettingsController. Next would be implementing a suggestion from one of our users:

    "Carlitos Melgar How about importing? It would be nice to export user A settings and import into user B."

1 2 3 Next
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.