Ticket T622505
Visible to All Users

Graceful way to handle bad user diff models

created 7 years ago

When storing user diffs in the database, what is the graceful way to handle errors in the model. For example, removing a column that they're currently filtering by?

I've done just this recently (removed a property from a business object). In a test database I have, I know that a user is currently filtered to that column. So when I load the view I get the exception below.

Is there some viewcontroller magic that can happen that will catch things like this when loading and attempt to reset the view settings for that particular user?

CriteriaParserException
Parser error at line 0, character 144: Can't restore user object. Tag 'Enum', data 'TattooStudio.ExpressApp.Module.Entities.DepositCreditStatus,Canceled', Exception: 'System.InvalidOperationException: The 'TattooStudio.ExpressApp.Module.Entities.DepositCreditStatus' enum is not registered for the parse operation. Please use EnumProcessingHelper.RegisterEnum for that type.
   at DevExpress.Data.Filtering.EnumProcessingHelper.GetEnumTypeFromName(String typeName)
   at DevExpress.Data.Filtering.EnumProcessingHelper.ExtractEnumIfNeeded(UserValueProcessingEventArgs e)
   at DevExpress.Data.Filtering.Helpers.CriteriaLexer.ExtractUserValue(String tag, String data)
   at DevExpress.Data.Filtering.Helpers.CriteriaLexer.DoUserObject()'; ("[Employee!] = ##XpoObject#TattooStudio.ExpressApp.Module.Entities.Employee({a989ac13-d9a6-45ff-a7bb-0bcc11e1dfef})# And [DepositCreditStatus] = {FAILED HERE}##Enum#TattooStudio.ExpressApp.Module.Entities.DepositCreditStatus,Canceled#")
   at DevExpress.Data.Filtering.Helpers.CriteriaParser.Parse(String query, Boolean allowSort)
   at DevExpress.Data.Filtering.Helpers.CriteriaParser.Parse(String stringCriteria, OperandValue[]& criteriaParametersList)
   at DevExpress.Data.Filtering.CriteriaOperator.Parse(String criteria, Object[] parameters)
   at DevExpress.Xpo.XpoObjectInCriteriaProcessingHelper.ParseCriteria(Session session, String stringCriteria, Object[] parameters)
   at DevExpress.ExpressApp.Xpo.XPObjectSpace.ParseCriteria(String criteria)
   at DevExpress.ExpressApp.Win.Editors.ObjectSpaceCriteriaOperatorParser.Parse(String criteriaString)
   at DevExpress.ExpressApp.Win.Editors.XafColumnViewActiveFilterStringAdapter.SetActiveFilterCriteria(ColumnView columnView, String activeFilterString, ICriteriaOperatorParser criteriaOperatorParser)
   at DevExpress.ExpressApp.Win.Editors.XafColumnViewActiveFilterStringAdapter.TryApplyActiveFilterStringToGridView()
   at DevExpress.ExpressApp.Win.Editors.XafColumnViewActiveFilterStringAdapter.gridControlDataSourceManager_ControlDataSourceChanging(Object sender, EventArgs e)
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at DevExpress.ExpressApp.Win.Editors.XafGridControlDataSourceAdapter.OnControlDataSourceChanging()
   at DevExpress.ExpressApp.Win.Editors.XafGridControlDataSourceAdapter.AssignDataSourceToGridControl(Object dataSource)
   at DevExpress.ExpressApp.Win.Editors.XafGridControlDataSourceAdapter.TryAssignDataSourceToGridControl()
   at DevExpress.ExpressApp.Win.Editors.XafGridControlDataSourceAdapter.grid_HandleCreated(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnHandleCreated(EventArgs e)
   at DevExpress.XtraGrid.GridControl.OnHandleCreated(EventArgs e)
   at System.Windows.Forms.Control.WmCreate(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at DevExpress.XtraEditors.Container.EditorContainer.WndProc(Message& m)
   at DevExpress.XtraGrid.GridControl.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Comments (2)
DevExpress Support Team 7 years ago

    Hello, Nate.

    Thank you for your question. We couldn't find and immediate answer and need additional time to research this scenario. Please bear with us. We will respond once we have any results.

      Thanks Michael,

      Alternately (if possible) there was a method in the DBUpdater where I could iterate through any user differences and reset (remove) particular views or views of types, that would also be nice. Typically when I run into issues such as this I delete the entire user diff. This has made users mad in the past, so I'm trying to stop doing it and start finding better ways around it :)

      Answers approved by DevExpress Support

      created 7 years ago

      Hello, Nate.

      Please accept my apologies for the delay.

      We have researched this task but found no universal solution to handle inconsistencies and errors in user model differences. In general, I'd recommend not removing classes, properties, and enumeration items from the data model, but hiding them (e.g., decorate them with the Browsable(false) attribute). Also, you can traverse through the entire model after a user is logged in (in the UserDifferencesLoaded event handler) and modify incorrect values. However, this may take time when the model is large. Alternatively, you can handle model issues when model data is applied to controls. For example, in your scenario, you can subscribe to the ListEditor.ModelApplying and ListEditor.ModelApplied events to determine when a filter is changed from the model and replace it (in the GridView.SubstituteFilter event handler). Another possible solution to remove incorrect enumeration items from filters is to subscribe to the CriteriaOperator.UserValueParse event and return a correct value.

        Show previous comments (1)
        W W
        Willem de Vries 6 years ago

          Please ignore my comment on "Reset View Settings". The problematic listview was part of a dashboardview and the button belonged to the latter.

          Willem

          DevExpress Support Team 6 years ago

            Hi Willem,

            At the moment, I don't see other solutions except for the ones Michael suggested. Please give me some time to discuss this behavior with my team to give you a precise answer.

            DevExpress Support Team 6 years ago

              Thank you for your patience, Willem. I've created a separate ticket on your behalf (T680096: WinForms - A XAF application crashes restoring an invalid user List View filter) to research this behavior in detail. At the moment, as a workaround, set the private DevExpress.Xpo.XpoObjectInCriteriaProcessingHelper.Tweaks.SuppressExceptionsOnParse option to true in the Main method of the Program.cs file to avoid this exception.

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.