How can i stop two people booking the same appointment time - asp.net

As the title states, how can i stop two users from booking the same appointment time.
Example, two users logging, on there screen they can both see that a 1pm appointment is available. They both try to book themselves into that appointment time.
How can i stop this from happening and ensure only one user can book it, then refresh the screen to show the next available booking time to the other user.
Thanks.

That's a fairly classic use case. You can simply display the appointment plan at a specific time. That can remain static or you can set up a periodic process (for example, every five seconds) to update the plan with new information.
Then, when the user/operator decides to book a free timeslot, it tries to do an (atomic) update that will fail if someone else has slipped in (using primary key or some other unique constraint). The atomicity of the update operation guarantees that only one person can book the timeslot. If the update works, voila, you have your time booked.
If it fails, notify the user of that fact and then load up the new appointment plan.
Rinse and repeat until the user has their booking or they wander off, disgruntled.

I do not think that this is optimal. Why don't you opt for a first clicked/first served pattern ?
What may happen if you have 10 users or more viewing the same page ? A user viewing a page does not mean that he will click on a time slot. So IMHO wait for a user to REALLY click and then notify eventually other users that a time slot they are viewing has been booked (As it happens with StackOverFlow when somebody answers a question while you are answering)

Related

Add Multiple Time Values to A UserForm

I need assistance with displaying multiple time values on a userform. They will be listed in a list box and will need to remain static should a record require editing.. The user will not have access to the excel worksheet. I need to didplay: time in: time seen; time out on the userform and on a hidden worksheet. I can use the NOW function to record the current time when the customer fills out the form and submits their record(time in). How would I go about writing code that will record the time when the clerk retrieves the customer for service(time seen) and when the customer leaves the office(time out)?
Our clerks have to bring walkin customers in for service within 30 mins of arrival. They also have to issue badges to customers with appointments within 30mins of arrival. Hope that explanation helps. Thanks.
If you are talking about frontend technology then i will suggest Angular with Reactive forms where you can generate the form fields without writing multiple times by using form builder feature. follow below link to know more.
Angular Reactive form guide

Is there a way to programmatically determine how long a conference room resource has been available for a given time slot?

For example, let's say a conference room was booked for a 12-1pm meeting. At 9am that same morning, a user cancelled that meeting, freeing up the conference room. Is there any way to programmatically run a script which would indicate, if run at 10am, that the room had become available one hour ago?
If you retrieve the event that was cancelled via Events.get, you can get the updated time field as a response, which, in case the event got cancelled, equals the time the event was cancelled. Then, the script can calculate the difference between current time and the time it got cancelled.
You could also use Freebusy to make sure that no one created another event after the previous one got cancelled and that the resource is free for that time.
Update
If you want to know for how long a certain conference room has been free for a certain time, you can:
Get the list of events related to this resource via Events.list, including the ones that were cancelled (set showDeleted to true) to achieve that.
Check if there are any events whose scheduled time matches the time you want to look for (fields start and end).
If any of these events matches, you can calculate, for that event (and in case the event got cancelled and the resource is indeed free - event status is cancelled), the difference between current time and the time the event got cancelled (by checking the field updated).
I hope this is what you wanted.

Updating value of previously sent ecommerce transactions

I am installing ecommerce tracking for a pretty simple ecommerce site. I am tracking the conversion on the order confirmation page, recording the transaction ID and order value, and everything's working fine.
However, sometimes the system issues the customer an offer to make an additional purchase on the order confirmation page with a single click (some small accessories that are discounted). If the customer chooses to make an additional purchase, I would like to be able to update the previously sent conversion. I do not want to assign a new transaction ID, because that will artificially inflate my conversion rate. I have tried sending the new amount of revenue with the same transaction ID, however that does not seem to have consistent results (sometimes ignored, sometimes value is just doubled).
I cannot hold back sending the conversion to GA until the customer makes a decision, because oftentimes the customer simply exits the browser without stating whether he is going to accept or decline the offer - in this case no conversion data would be sent at all.
Any ideas? Is there something in the GA library that I'm missing for this situation? Thanks
Nope, there is nothing. Even if a transaction with the same id goes through it's internally treated as a second transaction w/r/t the conversion rate.
If you want to get really fancy you could try and collect the transaction hit on your own server, wait a few minutes to see if you need to add another product and add a queue time parameter to offset for the actual collection time before you send it to Google. While this would work in theory I am not sure it is really feasible in a production environment (and in any case it would probably be more work than it's worth).

How to keep session alive across multiple tab if one of the tab is active and make it die if all tab is inactivity

The user is accessing the website and opened multiple tab.
The session should keep alive when:
Any of the tab is active (mouse move & key strokes on keyboard).
The session should die and redirect to login page automatically when:
All the tabs is inactivity (no mouse move, no key strokes)
Can you please hint me how to do this?
It's a dirty solution, and I haven't tried it yet, but this could work in theory:
When you have detected activity on the page, save a flag in a database table to denote that there is activity on the page (probably also want the timestamp to help you determine how long ago the activity happened and the user identifier to make sure it's the right session). Depending on how often you want to make this save, you could use a simple script like this (https://stackoverflow.com/a/3877867/987905) to keep track of the most recent keystroke or whatever you want to track, then after a certain amount of time (say 5 minutes), decide to save it to a database if there ever was activity (that way you aren't making database saves every time there is activity detection).
During your check to see if the session is active, check the database for the flag and timestamp to see if the session has been reported as alive on any instances of that user being logged in. If so, re-activate the session via your keep alive, or re-authenticate.
Again, I haven't tried this, but have been thinking about it recently. It seems to be a viable solution, just comes with the downside of making database saves/calls behind the scenes, possibly hurting performance.

How to handle concurrency in an ASP.Net WebSite? (auctioneer site)

my problem is follow:
I have an auctioneer site, in which many different objects will be auctioneerd.
My problem is very simple to clear for an more experience user I thinK. How I can handle business and database logic without opened a site or them?
My problem is to say directly, if nights at 3 no user is on the site, the winner (e.g.) must be set - if a page is opened or not.
So I need some kind of "every 2 seconds, do this method" - without opened a site.
My idea was a sepereate application which uses the same business and database-layer as the asp.net page and let this run at the server. Is that a good or bad idea?
The separate process (scheduled app or Windows service) is the only reliable way you can achieve this.
Using the same BLL and DAL are exactly the right thing to do too.
Check out this article on windows services http://msdn.microsoft.com/en-us/library/aa984074(VS.71).aspx
To let every user query the database every 2 seconds would create unnecessary traffic on your site, which is not a good idea. (users tend to refresh the page many times just before the auction closes anyway)
My thoughts:
Add a date to the auction when it closes.
The last user that places a bid is always the winner, and you can't place bids after 3 am (the date the auction closes), so if you visit the site after 3 am (you can't place a bid and) the winning user is displayed. If somebody opens the site just before 3 am and places a bid after 3 am your business logic should check the date of the bid and deny it.. (also: users might live in different timezones so consider displaying the server time on your site).
Setting the date to 'now' would close the auction immediately.
You can also add javascript to refresh the page if your clock passes the hour or something like that. (or use the number of seconds left before the auction closes in a setTimeout function or metarefresh)

Resources