I'm looking for the best way to forbit (de)activating a record for users that do not have a specified field security profile.
My approach was to display/hide activate/deactivate button depending on the users profiles. And add a synchronous plug-in that checks security profiles when (de)activating a record.
Is there a simpler way? With this approach I have to edit 6 button commands (hompage grid, form, subgrid - activate and deactivate button) and I have to create a new plug-in.
It looks like you have covered all the bases. The most fail safe way would be with a plugin that runs pre operation and checks the security role. From a user point of view it would return an error which might scare them. By hiding the buttons you remove that problem but have to be careful to make sure you remove them from all places you can deactivate a record.
I would say to do both if you want to be sure.
Related
I have a small one line application and recently I have been instruct to remove all persons form it. That is I have several fields and one of it is a owner field. I am not going to move the owners from the database but only hide them and I need to be able to show some fields again when I will be contacted by that person saying: "You can show my name". This is an Visual Studio application with underlying SQL database. My dream solution would be a switch that make this name field true or false so I will be able to show only those name which I am allowed to show with a click of a button.
What do you think would be the easiest way to accomplish this.
There are lots of ways to do this, since you didn't specify what type of C# application you have (ASP.NET C#, WinForms, WCF, WPF), I'll assume you mean either Winforms or WPF. The easiest way is a checkbox, and then on change, hide or show the other fields that you want to hide. Then do your database calls. That's all I can give you without more info.
There are many ways to achieve that. One way is to introduce an extra bit field/column in your ‘User’ (or whatever it is) database table that would represent whether to show or hide a user name. Based on this field you would show or hide the user name within your application. This could be checked/unchecked directly in your database (by you), or via an application UI. You could implement ‘Admin’ page/view/form that would be dedicated to admins (you) that would have enough privileges to update the above specified column.
How to detect if a control is visible to a user? I have a control that displays status of application, and I want it to be updated (it's value to be updated, for example, increase the value of a progress bar, or change a label's Text property) only if a user sees it. No need to update it if a user has minimized the form that contains this control, or if another form overlaps this control. I just don't want to do extra calculations if the control isn't visible any way.
Also, how do I detect the events that hide/show this control?
This seems to be one of the topics which is frequently asked and which has many possible solutions, depending on the context.
First, for reference sake, some links to old discussions I stumbled over during my research:
How to check absolute control visibility and how to be notified for changes of absolute visibility
C# winform check if control is physicaly visible
starting position:
An IDE for heterogenous systems with plenty of different hardware and many different transport layers where some are really slow. One feature is to display memory values of remote hw in editors. A typical use case is to have >20 editors open, where each displays between 1 and 100 different values.
Because the transport layers are limited in bandwith I was looking for a solution to "prioritise" the data acquisition.
(partial) solution:
A visibility tracker which basically manages a specialised adapter for the control itself and every ancestor control. The adapter handles the visibility dependent on the ancestors type, ie. for a Control, it's just instance.Visible, for a TabPage I check which page is selected, ...
The manager's housekeeping then is just to keep track of parent-changes for all the ancestors so that it tracks the correct visibilities.
Catching whether or not the form has focus or is minimalized is your best bet, but I am not sure that hits all cases. In general, I would update regardless of whether the user is paying attention, unless it takes tons of cycles to get the information to the form, which I doubt. Setting up conditional bits in an application just adds another place for things to go wrong.
Let's examine this a bit. Minimized forms are one thing. If the form is minimized, you know the user is not even looking at it. But, if another form is in front, then you want to check if the form has focus. the problem here is a person can be using half the screen to watch while typing in word on the other half. Word has focus, so the form does not update, which is not your intention. Same could happen if you create another form in the application. the update no longer has focus.
THere is no magic "is the user looking at me" property in Windows.
This is never necessary. Windows won't generate the Paint event when a window isn't visible. If you implemented painting yourself then be sure to only do this in the Paint event and to call Invalidate() if there's a reason to repaint.
How often does the status change? It is probably better to update the status indicator when the status changes and not worry about visibility. Let's say that status changes on average every 5 minutes. The window/control may not be visible when the status changes but could easily become visible well before the next status update. In this case, the status indicator will be wrong until the next update because you avoided changing the indicator. Unless updating the status indicator is very expensive, it's probably better not to try to project what the user will do.
Edit after reviewing other comments:
I think you might be able to achieve better efficiency improvements by identifying a model for detecting/notifying status changes instead of calculating on demand. You may need to weigh the frequency of status changes against the frequency of visibility changes to your control.
Take a look at Control.Visible, and the Control.VisibleChanged event.
Is it possible to use the standard ASP.NET login control, but just ask the user for a password? I am using a template, but the runtime complains that;
Login1: LayoutTemplate does not contain an IEditableTextControl with ID UserName for the username.
My current thinking, is to add the control with style="display:none;" which seems lame. The existing project already uses FormsAuthentication, so plan B might be to roll my own Authentication method.
Update
I have a 2 step login process. Step 1: "Who are you?" and Step 2: "What is your password?"
I'd sure style it with display:none long before rolling my own.
What functionality do you want from the Login Control? I assume your rolling your own authentication mechanism? Are you really going to gain a lot by reusing the login control? If so set the style to display:none.
Edit
If you identify the user on a previous page why not show a disabled textbox with the username or part of the username in it? I've seen some banks do this where on the first page you put the login and maybee the state you live in, then it validates that, then shows you the first three characters of the login name, and your site key and asks for your password.
Updated Answer:
Your best bet is to transform the login control into a label, and then display that over the empty textbox for their password.
Ye Olde Answer:
Why do you want to do that; what happens if two users have the same password?
I haven't tested this, and it may sound a little silly, but you might be able to write a wrapper for the login control, like a UserControl with a LoginForm as a property - Then use the Init event to assign values from the controls you create to update the values onto the LoginForm (property)
If the property doesn't work, you might be able to put it on the page, but make it hidden.
I'm currently developing a WinForms application in C#, and need some input on how to manage toolbar buttons, menus and other context sensitive elements. What is the best practice for this?
I've found the article 'Use Design Patterns to Simplify the Relationship Between Menus and Form Elements in .NET' on MSDN but I'm not sure if there is a better way since the article is pretty old (it's published in 2002).
Grateful for any constructive help.
When developing an event-intensive application (lots of menus, toolbars in lots of forms) it is common to have certain events overlap or repeat, in the sense that there are many ways to do a certain thing, and I see this redundancy as a benefit to the user, but a bane to the developer.
A well planned object-oriented approach will dictate how to manage the actions triggered by events so as to avoid duplicate or overlapping code.
You could of course find a very useful source of inspiration in Microsoft Office, as it is somewhere a standard (THE standard?).
Depending on the kind of form you are using, I guess you could set some basic rules, where for example data entry forms will have a basic menu such as validate\quit\refresh\abandon\print\export to excel\filter\order by\etc. Such menus (let's call them "Standard") will be ideally available under the "File" and\or "Edit" and\or "View" menu controls, sticking to standard Office menus (even Firefox uses this terminology).
I'd advise you to allways display this standard menus, even if some of the actions are not allways available for such or such forms. Just imagine that data contained in one of your forms cannot be updated under certain circumstances: you can still display the disabled version of the "validate" icon instead of making it invisible. This will definitely make things easier to understand for the final user.
Once this standard list of menus/options established, I guess you'll come up identifying 2 other major "menus" families, the "Details" menus and the "Actions" menus:
Details menus allow you to navigate
through forms, accessing/displaying
subforms/subsets of data, such as
Items in a Purchase Order.
Action menus allow you to run specific actions on the data, such as emitting a purchase order.
Your different menus shall be made available through a command bar, and context sensitive shortcuts. Options such as "filter" can be made available at the bound control level, while actions such as "Emit the PO" are only available at the record/form level.
People, or group of people, shall then be allowed or not to open forms and/or to run specific actions on these forms
In order to manage menus and rights, our apps have a default "menu file" on the client side, and both a "userGroup-forms" and "userGroup-actions" tables on the server side.
userGroup-forms table links groups
and forms and list view\modify rights
of each group.
userGroup-actions table contains a true value when a group has the right to perform a specific action
When connecting to the database, the user is identified and its local menu file is updated to give him corresponding view/action rights.
We are clearly here in an object oriented approach, aren't we?
The ToolStripManager class has a Merge Method, so you could have any child Forms/User Controls expose their own ToolStrips that get merged with your main form's tool strip when they have focus.
http://msdn.microsoft.com/en-us/library/5523fet0.aspx
If you are using MDI, you can also merge menu items of parent and child forms.
http://msdn.microsoft.com/en-us/library/ms404319%28VS.80%29.aspx
I have a requirement to produce a Web User Control (in C#) which will exhibit different behaviour when clicked depending on whether the shift (or control) key is pressed at the time. The control itself will contain an ImageButton and/or Hyperlink.
Is this possible?
Basically, if the logged in user is an Admin then I need to allow them access to update the associated URL. I don't want to have a separate page for this admin as it will cause confusion.
Thanks in advance
How about here?
To implement the Ctrl / Alt / Shift detection, you can use the properties event.ctrlKey, event.altKey, event.shiftKey and the deprecated Navigator-specific property event.modifiers.
Your control needs to emit some javascript to detect what keys are being pressed when it is clicked on.
Here is a primer from w3schools on events, here is a list of events of the window object you can listen to (such as onkeydown for keyboard presses).
I'd discourage this as it will get you into serious trouble with different browser versions.
As long as you aren't targeting one browser explicitly you'll be doing maintenance work for various browsers all the time.
A way around this is to find a supported Javascript library like jQuery that supports this behavior and let the maintainers of that library care about browser compatibility (You still need to update that library then..)
Well the 'powers' have decided that the Shift/Ctrl + Click approach was too clunky.
After a brainstorming session we have decided to go down the route of displaying a small 'Edit' button next to the control. This will only be visible for Administrator users and I've pulled it together in about two hours.
Thanks for taking the time to provide your input.
Can someone with a high rep please close this question for me - thanks.