Hi,
I have had a problem with one client of mine where they run a court
rental agency for various councils and they do everything on a
shoestring. I believe everything in the office is run on a laptop with 4
gig memory including my software which includes a web server which
provides their users with the ability to book courts. I have had no
reports of the problem from any of my other clients.
The specific issue is when I check that there are no present bookings
before allowing a new booking for any specific time frame.
I have little in-depth knowledge of asp.net however I do believe that
each customer logged on have their own session state and the html is
created in that state and then fed to the customers browser. There
should be no cross-over of this data in-memory however I notice that the
problem seems to occur when there are more than two users logged in. I
mention this because the problem may be with my coding and not with the
database.
Here's the code which I have only just heavily modified in an effort to
capture the specific problem:
[code=csharp]
bool available = true;
string location = "";
Columns columns = requestedColumnNames(bookingStartDT,
bookingPeriods);
int columnsToBeCheckedCount = columns.ColumnsFirstDay.Count;
int conflictsFound = 0;
int columnsChecked = 0;
using (MCData.DBManager dbManager = new
MCData.DBManager(AppSettings.DataDirectory))
{
try
{
location = "Day 1";
dbManager.Open();
dbManager.AddParameter("@BookingDate", bookingStartDT.Date);
dbManager.AddParameter("@FacilityID", facilityID);
dbManager.ExecuteReader(CommandType.Text,
string.Format("SELECT BookingDate, Court, {0} FROM BTable
WHERE BookingDate = @BookingDate AND Court = @FacilityID",
columns.CSVFirstDay));
logger.Debug("+++ FacilityID [{0}]",
dbManager.Parameter["@FacilityID"].Value);
logger.Debug("+++ BookingStartDT [{0}]",
dbManager.Parameter["@BookingDate"].Value);
logger.Debug("+++ SQL [{0}]", dbManager.Command.CommandText);
logger.Debug("+++ Connection string [{0}]",
dbManager.ConnectionString);
int fieldsReturned = 0;
using (IDataReader rdr = dbManager.DataReader)
{
while (rdr.Read())
{
for (int i = 0; i < rdr.FieldCount; i++)
{
string column = rdr.GetName(i).ToString();
if (column.StartsWith("T"))
{
fieldsReturned++;
columnsChecked++;
if (!Convert.IsDBNull(rdr.GetValue(i)))
{
logger.Debug("+++ Facility [{0}] Date [{1}] Column
[{2}] value is not null [{3}].",
facilityID, bookingStartDT.Date, column,
rdr.GetValue(i));
conflictsFound++;
}
}
else if (column == "BookingDate")
{
logger.Debug("+++ BookingDate returned [{0:yyyy-MM-dd
HH:mm:ss}]", rdr.GetValue(i));
}
else if (column == "Court")
{
logger.Debug("+++ Court returned [{0}]",
rdr.GetValue(i));
}
}
}
}
logger.Debug("+++ Number of fields tested for null value
[{0}] of a total TColumn count of [{1}]",
fieldsReturned, columns.ColumnsFirstDay.Count);
logger.Debug("+++ Columns to be checked count [{0}] Columns
cheked count [{1}]",
columnsToBeCheckedCount, columnsChecked);
if (columnsChecked == columnsToBeCheckedCount &&
conflictsFound > 0)
{
logger.Debug("+++ All columns checked. Number of conflicts
found [{0}]", conflictsFound);
available = false;
}
if (available && columnsChecked != columnsToBeCheckedCount)
{
logger.Debug("+++ Not all columns checked. Setting
availability to false.");
available = false;
}
if (available && conflictsFound > 0)
{
logger.Debug("+++ Number of conflicts found [{0}]",
conflictsFound);
available = false;
}
logger.Debug("+++ Available status is [{0}]", available);
[/code]
Now here's the log portion:
2014-02-12 09:42:07.9304 HP-HP MyCourtsOnline.Default.#wPc ypaul
Checking For Booking Conflicts RequestedFacilityID [6] RequestedStartDT
[12/02/2014 5:30:00 PM] RequestedPeriods [3]
2014-02-12 09:42:07.9704 HP-HP
MyCourtsOnline.CheckForConflictingBookings.#9gg ypaul +++ FacilityID [6]
2014-02-12 09:42:07.9704 HP-HP
MyCourtsOnline.CheckForConflictingBookings.#9gg ypaul +++ BookingStartDT
[12/02/2014 12:00:00 AM]
2014-02-12 09:42:07.9704 HP-HP
MyCourtsOnline.CheckForConflictingBookings.#9gg ypaul +++ SQL [SELECT
BookingDate, Court,
T1730,T1740,T1745,T1800,T1815,T1820,T1830,T1840,T1845 FROM BTable WHERE
BookingDate = @BookingDate AND Court = @FacilityID]
2014-02-12 09:42:07.9704 HP-HP
MyCourtsOnline.CheckForConflictingBookings.#9gg ypaul +++ Connection
string [Data Source = 'C:\ProgramData\Aquarius
Communications\MyCourts\Resources\MyCourts.vdb4';Pooling=false;Open
Mode=NonExclusiveReadWrite]
2014-02-12 09:42:07.9704 HP-HP
MyCourtsOnline.CheckForConflictingBookings.#9gg ypaul +++ Number of
fields tested for null value [0] of a total TColumn count of [9]
2014-02-12 09:42:07.9704 HP-HP
MyCourtsOnline.CheckForConflictingBookings.#9gg ypaul +++ Columns to be
checked count [9] Columns cheked count [0]
2014-02-12 09:42:07.9704 HP-HP
MyCourtsOnline.CheckForConflictingBookings.#9gg ypaul +++ Not all
columns checked. Setting availability to false.
2014-02-12 09:42:07.9704 HP-HP
MyCourtsOnline.CheckForConflictingBookings.#9gg ypaul +++ Available
status is [False]
As you can see, my code has not checked any of the returned fields
starting with 'T' and hence, by default, returned false. In fact, there
were no bookings recorded/conflicting and had the fields been checked
would have returned true.
I'm at a loss to see where my coding is at fault. Could this in anyway
be related to the sql query result, asp.net or perhaps a memory issue.
Any suggestions will be greatly appreciated cause I'm at wits end.
Regards,
Glen.