Locking a page

D

David

Hi all,

I need to be able to 'lock' a page. It doesn't need to be a full lock, but
just to stop some actions if someone else is in a page.

I was thinking of using the application state and putting a List<T> into it,
but I am not sure how to do this. Any ideas?

In fact, the whole scenario is making my head hurt. Here is what I need to
do...

1. Add the page user and what querystring value he is looking at.
2. if someone else is in the same page and querystring value, show the
original page user.
3. If a different page, then reset the page the user to the new querystring
or make it null if away from the page.

The application[] space is probably the best place to put this to share
across multiple pages, but I am not sure how to put a key/value pair (and
more than one key/value pair) into the application[].

An example of how I am visualising it, but I don't think it will work like
this...

Application["users_in_page"].add("david", "123.234.345.456");

(I know the above is not valid, but I need it to work like an array)

and then in each page check if 123.234.345.456 is in the array and show
david as in the page.

Now, if I put "david" and "123.234.345.456" in a List, then added it to the
array, when I have another user, "john" and "132.432.543.372" to add, I
think I need to read the list, add john to it, then add the List to the
Application["users_in_page"], but that will also give me issues due to
timing.

Hhhmmm. Any ideas on how to get around this would be very much appreciated.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
A

Alexey Smirnov

1. Add the page user and what querystring value he is looking at.
2. if someone else is in the same page and querystring value, show the
original page user.
3. If a different page, then reset the page the user to the new querystring
or make it null if away from the page.

Maybe you can use the OutputCache directive?

<%@ OutputCache Duration="60" VaryByParam="query" %>


Application["users_in_page"].add("david", "123.234.345.456");

(I know the above is not valid, but I need it to work like an array)

Session?
 
D

David

No, that won't help.

Basically, my application is a database driven application.

When a user comes into the page, if he is the first user and if certain
conditions exist, the page does an action. Without the conditions existing,
the user clicks something to create the condition, then clicks again to do
the action (in this case, send an SMS)

However, if while he is in the page and has clicked to create the condition,
another user can very easily come into the page and the automatic action
will happen.

So, I want the page to know who is in the page and if no-one is in it and
the conditions are met, then the SMS is sent. However, if someone is in it
already, it will display who is in it, so the users can shout across the
office to double check.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
1. Add the page user and what querystring value he is looking at.
2. if someone else is in the same page and querystring value, show the
original page user.
3. If a different page, then reset the page the user to the new
querystring
or make it null if away from the page.

Maybe you can use the OutputCache directive?

<%@ OutputCache Duration="60" VaryByParam="query" %>


Application["users_in_page"].add("david", "123.234.345.456");

(I know the above is not valid, but I need it to work like an array)

Session?
 
N

Norman Yuan

You do not lock the "Page". The web app by nature is disconnected, so, lock
a page /view is very difficult, if not taotal impossible.

You may implement a "Check-in/Check-out" type of logic to the key
information used for that page. For exaple, if the page displays a
record/document content and the user action is to manipulate the
information, then he has to check the record/document out. Then the
record/document is locked out to all others until the record/document is
checked back in.
 
D

David

Hi,

I know that I can't 'lock' the page. It was just the terminology I used to
describe what I am trying to achieve.

I need to be able to do something like locking it out AND showing who has
the page. If I have a checkout/checkin, the problem of closed browsers or a
crashed browser will keep something checked out. What I want to achieve is
to not allow the automated action when the page is viewed IF someone has it.
It should expire after a couple of minutes or so. The 'automated' action
will be available as a button click and a shout across the office will clear
the confusion.

It is purely to see who has the page open and to stop an automated action if
the page is open by someone.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available


Norman Yuan said:
You do not lock the "Page". The web app by nature is disconnected, so,
lock a page /view is very difficult, if not taotal impossible.

You may implement a "Check-in/Check-out" type of logic to the key
information used for that page. For exaple, if the page displays a
record/document content and the user action is to manipulate the
information, then he has to check the record/document out. Then the
record/document is locked out to all others until the record/document is
checked back in.


David said:
Hi all,

I need to be able to 'lock' a page. It doesn't need to be a full lock,
but just to stop some actions if someone else is in a page.

I was thinking of using the application state and putting a List<T> into
it, but I am not sure how to do this. Any ideas?

In fact, the whole scenario is making my head hurt. Here is what I need
to do...

1. Add the page user and what querystring value he is looking at.
2. if someone else is in the same page and querystring value, show the
original page user.
3. If a different page, then reset the page the user to the new
querystring or make it null if away from the page.

The application[] space is probably the best place to put this to share
across multiple pages, but I am not sure how to put a key/value pair (and
more than one key/value pair) into the application[].

An example of how I am visualising it, but I don't think it will work
like this...

Application["users_in_page"].add("david", "123.234.345.456");

(I know the above is not valid, but I need it to work like an array)

and then in each page check if 123.234.345.456 is in the array and show
david as in the page.

Now, if I put "david" and "123.234.345.456" in a List, then added it to
the array, when I have another user, "john" and "132.432.543.372" to add,
I think I need to read the list, add john to it, then add the List to the
Application["users_in_page"], but that will also give me issues due to
timing.

Hhhmmm. Any ideas on how to get around this would be very much
appreciated.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
H

Hans Kesting

David wrote on 7-9-2009 :
Hi all,

I need to be able to 'lock' a page. It doesn't need to be a full lock, but
just to stop some actions if someone else is in a page.

I was thinking of using the application state and putting a List<T> into it,
but I am not sure how to do this. Any ideas?

In fact, the whole scenario is making my head hurt. Here is what I need to
do...

1. Add the page user and what querystring value he is looking at.
2. if someone else is in the same page and querystring value, show the
original page user.
3. If a different page, then reset the page the user to the new querystring
or make it null if away from the page.

The application[] space is probably the best place to put this to share
across multiple pages, but I am not sure how to put a key/value pair (and
more than one key/value pair) into the application[].

An example of how I am visualising it, but I don't think it will work like
this...

Application["users_in_page"].add("david", "123.234.345.456");

(I know the above is not valid, but I need it to work like an array)

and then in each page check if 123.234.345.456 is in the array and show david
as in the page.

Now, if I put "david" and "123.234.345.456" in a List, then added it to the
array, when I have another user, "john" and "132.432.543.372" to add, I think
I need to read the list, add john to it, then add the List to the
Application["users_in_page"], but that will also give me issues due to
timing.

Hhhmmm. Any ideas on how to get around this would be very much appreciated.

You can store any object in the Application. So you could for instance
add a Dictionary<string, string> where you store the name/value pairs.
You will need to do some casting, as you retrieve it as a plain Object.

Maybe you can use Cache: store an object with a page-specific key and a
timeout. If the object is in the Cache, then the page is "locked", else
it is "free" (either no-one has visited it or it was too long ago)

Hans Kesting
 
D

David

Thank you Hans,

I was thinking along the lines of hashkeys which could do the same thing.

I will look at the cache. I had never even considered that, but it has also
given me an idea for using Application, though the application one wouldn't
have a timeout.

What I need to do though is to reset the value should the user leave the
page... so I am thinking if I used the cache with a user specific key, then
looped through the cache objects to see if any values are the same as the
page.

Hhmmm. some thoughts to be getting on with.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
Hans Kesting said:
David wrote on 7-9-2009 :
Hi all,

I need to be able to 'lock' a page. It doesn't need to be a full lock,
but just to stop some actions if someone else is in a page.

I was thinking of using the application state and putting a List<T> into
it, but I am not sure how to do this. Any ideas?

In fact, the whole scenario is making my head hurt. Here is what I need
to do...

1. Add the page user and what querystring value he is looking at.
2. if someone else is in the same page and querystring value, show the
original page user.
3. If a different page, then reset the page the user to the new
querystring or make it null if away from the page.

The application[] space is probably the best place to put this to share
across multiple pages, but I am not sure how to put a key/value pair (and
more than one key/value pair) into the application[].

An example of how I am visualising it, but I don't think it will work
like this...

Application["users_in_page"].add("david", "123.234.345.456");

(I know the above is not valid, but I need it to work like an array)

and then in each page check if 123.234.345.456 is in the array and show
david as in the page.

Now, if I put "david" and "123.234.345.456" in a List, then added it to
the array, when I have another user, "john" and "132.432.543.372" to add,
I think I need to read the list, add john to it, then add the List to the
Application["users_in_page"], but that will also give me issues due to
timing.

Hhhmmm. Any ideas on how to get around this would be very much
appreciated.

You can store any object in the Application. So you could for instance add
a Dictionary<string, string> where you store the name/value pairs.
You will need to do some casting, as you retrieve it as a plain Object.

Maybe you can use Cache: store an object with a page-specific key and a
timeout. If the object is in the Cache, then the page is "locked", else it
is "free" (either no-one has visited it or it was too long ago)

Hans Kesting
 
W

William Niver

Why not create a DataTable in your Database that holds page states for pages
that need to be lockable?

From what yer saying, it sounds like you'd want to store:
Requested URL
UserID
UserName
a TimeDate Stamp of the action
maybe some type of code for how it was locked / unlocked

Then create a custom object that holds that info when its retrieved.

Create a base LockablePage that inhetits from System.Web.UI.Page
Have your pages that need to be locked inherit from LockablePage rather than
System.Web.UI.Page

Add in a Property in LockablePage named Locked.
Have the Getter retrieve the state from the DataBase and load the custom
object.
Have the Setter set the state in the Database and load the custom object.

Add in whatever other logic you require for pages that are lockable, maybe
even a function that returns an HtmlGenericControl of your "This page is
locked" display.
You'll also likely want to check if the user visiting the page is the one
with it locked and all that type of stuff.

Example:

Private Function CreateDisplay_PageIsLocked() as HtmlGenericControl
Dim MyDiv as New HtmlGenericControl("div")
With MyDiv
'create and add display elements here using info from your custom object
or straight from the DataTable
End With
Return MyDiv
End Function

If someone visits the page (and does whatever else it is you want) lock it.
Now, if anyone visits the page, just check the Locked State. If it is
locked, add the control CreateDisplay_PageIsLocked() to the display instead
of your usual content.

Hope that helps get ya started!

William


David said:
No, that won't help.

Basically, my application is a database driven application.

When a user comes into the page, if he is the first user and if certain
conditions exist, the page does an action. Without the conditions
existing, the user clicks something to create the condition, then clicks
again to do the action (in this case, send an SMS)

However, if while he is in the page and has clicked to create the
condition, another user can very easily come into the page and the
automatic action will happen.

So, I want the page to know who is in the page and if no-one is in it and
the conditions are met, then the SMS is sent. However, if someone is in it
already, it will display who is in it, so the users can shout across the
office to double check.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
1. Add the page user and what querystring value he is looking at.
2. if someone else is in the same page and querystring value, show the
original page user.
3. If a different page, then reset the page the user to the new
querystring
or make it null if away from the page.

Maybe you can use the OutputCache directive?

<%@ OutputCache Duration="60" VaryByParam="query" %>


Application["users_in_page"].add("david", "123.234.345.456");

(I know the above is not valid, but I need it to work like an array)

Session?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top