Hello,
I have unique prefixes depending on what user is working on. When user needs a new number, I query database, find the last entry, remove the prefix and generate my next number in sequence. There are times when users are needing to generate multiple sequential numbers for a prefix. As long as they are the only ones requesting new numbers, all works well, it is when there are 2 or more needing a new number that I am having trouble. If while generating the multiple sequential numbers someone requests a number, it breaks the numeric sequence the first user is expecting to see.
This is where I am having trouble. I am in ASP.Net 4.0 using C#. To create the sequential numbers, I am using a for loop because the user will indicate how many they are needing. I suspect I am generating my sequential numbers the hard way, but I am not sure the best method.
So my question is, is there a way that once the for loop is generating the sequential list of numbers that another request from a different user has to wait until the first request is finished?
Example of the numbering:
ZZ1111-000156
ZZ2222-000157
ZZ3333-000158
If a user request a series of 25 numbers, I need that request to create say ZZ3333-000159 thru ZZ3333-000184 without one sneaking in there for a single request of ZZ4444-XXXXXXX in the middle somewhere.
below is not what the users are expecting.
ZZ3333-000159
ZZ4444-000160
ZZ3333-000161
ZZ3333-000162
Should be
ZZ3333-000159
ZZ3333-000160
ZZ3333-000161
etc unitl ZZ3333-000184
ZZ4444-000185
Hope this explains what I am trying to accomplish. No need to focus on the prefixes as there is specific criteria that is used to create those numbers, I just need to get the sequential numbers to workout.
Thank you for any suggestions.
Dave
I have unique prefixes depending on what user is working on. When user needs a new number, I query database, find the last entry, remove the prefix and generate my next number in sequence. There are times when users are needing to generate multiple sequential numbers for a prefix. As long as they are the only ones requesting new numbers, all works well, it is when there are 2 or more needing a new number that I am having trouble. If while generating the multiple sequential numbers someone requests a number, it breaks the numeric sequence the first user is expecting to see.
This is where I am having trouble. I am in ASP.Net 4.0 using C#. To create the sequential numbers, I am using a for loop because the user will indicate how many they are needing. I suspect I am generating my sequential numbers the hard way, but I am not sure the best method.
So my question is, is there a way that once the for loop is generating the sequential list of numbers that another request from a different user has to wait until the first request is finished?
Example of the numbering:
ZZ1111-000156
ZZ2222-000157
ZZ3333-000158
If a user request a series of 25 numbers, I need that request to create say ZZ3333-000159 thru ZZ3333-000184 without one sneaking in there for a single request of ZZ4444-XXXXXXX in the middle somewhere.
below is not what the users are expecting.
ZZ3333-000159
ZZ4444-000160
ZZ3333-000161
ZZ3333-000162
Should be
ZZ3333-000159
ZZ3333-000160
ZZ3333-000161
etc unitl ZZ3333-000184
ZZ4444-000185
Hope this explains what I am trying to accomplish. No need to focus on the prefixes as there is specific criteria that is used to create those numbers, I just need to get the sequential numbers to workout.
Thank you for any suggestions.
Dave