Im about to create a very simple online event reservation application and currently have 3 tables:
User
PK_UserID
UserName
Event
PK_EventID
EventName
EventDescription
EventStartDate
EventEndDate
SeatsAvailable
BookedEvents
ID
FK_UserID
FK_EventID
Do you have any experience of how to handle SeatsAvailable? I mean if SeatsAvailable is set to 5 and there are 5 users online and want to book event. And some user has started to fill out the form then changed his mind. Then seats in database can just leak. I was thinking about sessions - like to limit every user to 5 minutes to complete the booking but i dont really know if its good idea. Do you have any suggestions?
I dont really see your problem.
SeatsAvailable would be the total allowed seats, and the number of booked users would be the sum of the rows on BookedEvents.
in your procedure to enter a user to BookedEvents you would read the count of BookedEvents and SeatsAvailable in a transaction, if the event is full then the users gets a message saying the they are too late
am i missing something?
I would use your way as well, but I would reset the timeout everytime the booking is progressed (ie. new page). I know from experience you sometimes have to look something up or similar, and I really hate pages timing out in that case. You should be fine with a timeout.
Related
Good day all,
I am work on C# .net 4.0 framework, and database is microsoft SQL server 2008 R2.
There is a system to let user do gift redemption. When User click on the "redeem" button, system will :
check on the gift inventory first before update customer_gift table,
and update the gift_inventory table for the particular gift.
If the inventory is less than 0, then it will prompt error message to tell user that the gift is already finish, and then cancel the redemption process.
There is a problem happen in the following condition :
Gift A only have 1 quantity in inventory now.
Customer Jack click on "redeem" button at 2013-11-11 09:22:27.780.
Customer Jess click on "redeem" button at 2013-11-11 09:22:27.497.
The different time they click on "redeem" button is only 0.0283 seconds.
Thus, maybe the different time is too short, both of them was successful redeem the gift because, before the system (first customer) update the gift_inventory table, the system (second customer) already get the data from inventory (Gift A), thus, system still let second customer to proceed because the inventory is still equal to 1.
I have think out of a way to solve this problem, which is describe as follow :
Create a new column for the gift_inventory table, name lock, with data type Boolean . When customer clicked on the redeem button, and before the system check the gift inventory, set the Boolean to true. Thus, if the second customer, try to access to the gift inventory, and found that the lock = true, then system will wait for 1 seconds and then try to access again, until the lock = false, then only access and get the inventory data.
However, I dun think this is a good solution. I think this may cause the database become slow.
Any idea and suggestion?
I think you can achieve this just by doing each update in a transaction and by using row locking in database.
Read more here:
Transactions
http://technet.microsoft.com/en-us/library/jj856598.aspx
Locking
http://technet.microsoft.com/en-us/library/aa213039(v=sql.80).aspx
Hello and thanks for reading this, could really use some help ;)
On my site, you play a puzzle after you entered your information and when you either complete the game before the time runs out or not your score will be posted into the gridview below.
I cant post a image but you can check the site if you want a good view about what I'm talking about Website
everything is working right now. you can play it and as you can see the time is showed. in the database that the information is stored in you every row has a unique ID.
here is my question - when someone hits "start spillet" and adds the information to the database, how can i get the unique ID that when that just been created and store it into a session so i can use it later.
(here is a row from my Database)
ID NAME EMAIL COLLEGE CLASS/TEAM TIME
114 Carsten TESTUSER#mediacollege.dk Technology h0dt100413 54
public string generateID()
{
return Guid.NewGuid().ToString("N");
}
using this function you will get a unique id and you can user it as session.
it will different every time
Over the last few weeks I was tasked with developing a ticketing system specific to my companies needs. Alright, not a huge deal.. Now I am onto a little trickier subject that I just can't wrap my head around completely.
Notification System based on a tickets last update time.
Alright so as we all know in a ticketing system we have tickets, lots of them.. Each of our tickets have a ticket "state" such as "Waiting on Client", "Pending Shipment" etc. These states have different thresholds I.E: 60 minutes, 120 minutes..
Basically I have a server application that runs every two hours. It loops through all the open tickets in the system, checks their ticket state and threshold and if the LastUpdate time is outside of my threshold of 60 minutes then the system fires off a notification saying that this ticket hasn't been taken care of and someone needs to get on top of it. Alright great, so that means every two hours the system runs it will check the time, if the ticket does not comply with its threshold then a level 2 notification gets sent out. The same process applies for notification 3.
The problem with this scenario is that what happens when Friday rolls around? There may only be 3 tickets that have notifications that need to be sent by the close of business Friday. However when Monday rolls around and this system runs again, it is going to find every ticket out of compliance which means we will more than likely have over 100 tickets in peoples mailbox. This seems like such a common problem among any notification system that operates off a datetime.
Any suggestions?
EDIT: Now that I know it's a C# app..
When your application is deciding whether or not to send a notification.. first, check if it is the weekend:
if (DateTime.Now.DayOfWeek != DayOfWeek.Saturday && DateTime.Now.DayOfWeek != DayOfWeek.Sunday)
// start sending notifications.
Or, you could do this:
if (TimeSpanElapsedToSendNotificationFor(thisItem)) {
if (isWeekend()) {
thisItem.LastUpdate.AddDays(2);
persist(thisItem); // update the DB
return;
}
// send notification here..
}
So, first check to see if the desired notification time has passed. If it has.. double check if it's the weekend.. if it is.. add 2 days to the LastUpdate property on this item then exit the function. If its a weekday, it will continue processing. Using this second method, your very first check will be false on the second run-through for all jobs unless they are added on the weekend.
PS: Why don't you just use a scheduled task and only run it during work hours?
We are developing a shopping cart application.
For every single user session i have to give the user 20 minutes after he adds first product to shopping cart to go to checkout process. If the user adds another product, i have to reset the clock and start 20 minutes from the beginning. ıf user doesnt do anything in 20 minutes, i have to end the session. If user goes to checkout process another clock for checkout process will start. It will be 15 minutes. But if he cancels the checkout process and comes back to store, first clock has to start where it was left..
Hope i am clear.
What approach I can use? Am I gonna use threads, sessions vs..?
Thanks alot.
You would want to use Session state for this. You can set a timestamp in the session everytime the user does something - for instance, adds an item / etc. Before you open any page, you would check the time and see if
(DateTime.Now - Session[LastAccessTime]) > new TimeSpan(0, 20, 0)
If it is greater, then show a message saying that the time expired, else continue on.
On the shopping pages, you can check for 20 minutes, on the checkout pages, check for 15 mins.
Check out this answer too: Session time out with Timer
You would definately use the session for this as mentioned by Shiroy - however I would have thought you could simply use the Session.Timeout property, setting it as appropriate as you enter different areas of your site.
Let's say I wanted to display a Reminder (dynamically created by user) in my ASP.NET MVC View
Every WEEK/MONTH/.... until "infinity".
This reminder has to be seperate database record (or in my case EF Entity Instance object) for each reocurrence, because i'm storing specific data in my database for each occurrence.
How would you guys go about "inserting" these reminder clones into the database?
I Can't insert infinite reminders, .. And choosing an arbitrary date say "2000 years" from now seems wrong, and also inserts a lot of records into the database.
Kind of clueless here...
Thanks in advance for any (alternative) solution/ advice.
*It is key tough that i can store data for each occurence!*
Inserting reminders into the database, IMHO, is a bad way of implementing it. It is just lazy.
My approach would be to store the conditions and then test the conditions on a regular basis. Perhaps just keeping a timestamp of last reminder check and if it is more than 8 hours, re-calculate - something around these lines.
UPDATE
In order to know which reminder has been seen by the user or not, for every type you just keep a timestamp of when it was read. If the difference is more than the item interval, then it must be shown. If timestamp is less than the the time reminder must be shown, then it must be shown.
Is there the remotest possibility that your code will be used in 10 years time?
If not try 10 years.