Questions regarding Role-based Security


Author
Message
Ben Kim
Ben Kim
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 99, Visits: 253
Hello,

I am creating an application base that will be used for all of our WinForm executables.  Attached is the project that illustrates the following three issues:

1.  When applying themes to the application, the User Panel's label controls do not update with the chosen "theme" until I run the mouse cursor over the control.  Is there a way to force a refresh?  Should I have to?

2.  Create a new security user and save the new record.  Next Edit the same record and try to change the Permissions: Default Action and Restrictions.  Notice there should not be any permission records available.  The framework throws a Null Reference Exception:

NullReferenceException
 Object reference not set to an instance of an object.

Source     : MicroFour StrataFrame Security

Stack Trace:
   at MicroFour.StrataFrame.Security.UserEditor.SaveData(TreeNode Node, SetDataPiece SetPiece)
   at MicroFour.StrataFrame.Security.UserEditor.cboAction_SelectedIndexChanged(Object sender, EventArgs e)
   at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
   at System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
   at System.Windows.Forms.ComboBox.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)

Should these controls be available if there are no Permission records?  Is there a way to more gracefully trap this error?

3. Restart the application.  Use the new user created in step 2 to sign on.  A SQL exception will occur:

System.Data.SqlClient.SqlException was unhandled by user code
  Class=16
  ErrorCode=-2146232060
  LineNumber=1
  Message="Invalid object name 'dbo.SFSUserRolePermissionInfo'."
  Number=208
  Procedure=""
  Server="DEVSVR2"
  Source=".Net SqlClient Data Provider"
  State=1
  StackTrace:
       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
       at System.Data.SqlClient.SqlDataReader.get_MetaData()
       at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
       at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
       at MicroFour.StrataFrame.Data.DbDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)
       at MicroFour.StrataFrame.Data.SqlDataSourceItem.GetDataTable(DbCommand Command, OnChangeEventHandler CallBack)
       at MicroFour.StrataFrame.Data.DataLayer.GetDataTable(DbCommand Command, Boolean RegisterNotification)
       at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(DbCommand CommandToExecute)
       at MicroFour.StrataFrame.Security.BusinessObjects.SFSUserRolePermissionInfoBO.FillByUser(Int32 UserPK)
       at MicroFour.StrataFrame.Security.LoggedInUser.CreatePermissionsListRolesOnly(Int32 UserPK)
       at MicroFour.StrataFrame.Security.LoggedInUser.CreateNew(SFSUsersBO UserInfo)
       at MicroFour.StrataFrame.Security.Login.AttemptLogin(Object sender, EventArgs e)
       at ApplicationBase.ETILogin.OnAttemptLogin() in C:\ETIDev\ApplicationBase\ETILogin.vb:line 30
       at ApplicationBase.ETILogin.cmdOk_Click(Object sender, EventArgs e) in C:\ETIDev\ApplicationBase\ETILogin.vb:line 282
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.PerformClick()
       at System.Windows.Forms.Form.ProcessDialogKey(Keys keyData)
       at System.Windows.Forms.ContainerControl.ProcessDialogKey(Keys keyData)
       at System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData)
       at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
       at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
       at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)

I am unsure about this issue.  I do not see any tables, even in your samples that have this name.  Could this be caused by the fact I do not have any securable forms created as of yet in this project?

Any ideas would be greatly appreciated!

Ben Kim

Attachments
AppBase.zip (256 views, 778.00 KB)
Replies
Ben Kim
Ben Kim
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 99, Visits: 253
Thank you.  Regarding the ApplicationThemeChanged event, where can I find documentation on how to use this feature?   I need it for a third party control that will always be displayed (ie. user can change theme and I want to repaint the control's background with the appropriate theme colors).

I have the following code currently on this form:

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)

If ApplicationTheme.Theme <> ApplicationThemeName.NoTheme Then

TreeGX1.BackgroundStyle.BackColor = ApplicationTheme.ThemeProperties.ThemeFormBodyGradientBegin

TreeGX1.BackgroundStyle.BackColor2 = ApplicationTheme.ThemeProperties.ThemeFormBodyGradientEnd

Else

TreeGX1.BackgroundStyle.BackColor = Nothing

TreeGX1.BackgroundStyle.BackColor2 = Nothing

MyBase.OnPaint(e)

End If

End Sub

---

Which appears to work "most" of the time.  Does the OnPaint event sometimes not get called when the theme is changing? To reproduce:

1. Use the application sample I sent you earlier
2. Add a new form - set the Window State to Maximize
3. Add code to Launch the form from the toolbar
4. Add a third party control (in my case I used TreeGX from DevComponents)
5. Add code similar to the above code snippet
6. Run the application
7. Launch the new form
8. Change the theme - Notice the form reacts correctly
9. "Restore" the new form window (form resizes)
10. Try to change the theme again

(OR download and run the new sample attached to this message - you can download an eval of TreeGX from www.devcomponents.com if you do not have this control already)

At this point the connection between the theming and the form are broken.  You can minimize the application and maximize it so it redraws the correct them.  Ideas on this one?

Ben


Attachments
AppBase2.zip (255 views, 988.00 KB)
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You can handle the MicroFour.StrataFrame.UI.Windows.Forms.ApplicationTheme.ApplicationThemeChanged event.  It's a shared event, so you can just type in:

MicroFour.StrataFrame.UI.Windows.Forms.ApplicationTheme.ApplicationThemeChanged += new EventHandler(methodname);

Then, just reset the properties on your control to the new theme colors.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search