Click here to Skip to main content
15,909,737 members
Home / Discussions / C#
   

C#

 
GeneralRe: Sepia ColorMatrix Pin
frankforward16-Sep-09 4:01
frankforward16-Sep-09 4:01 
GeneralRe: Sepia ColorMatrix Pin
Don Grout4-Aug-11 9:55
Don Grout4-Aug-11 9:55 
GeneralSerialization. Pin
fmarcos28-Feb-05 8:12
fmarcos28-Feb-05 8:12 
GeneralRe: Serialization. Pin
turbochimp28-Feb-05 9:45
turbochimp28-Feb-05 9:45 
GeneralRe: Serialization. Pin
fmarcos1-Mar-05 1:31
fmarcos1-Mar-05 1:31 
GeneralDataSet problem Pin
Kwai Cheng Kane28-Feb-05 7:39
Kwai Cheng Kane28-Feb-05 7:39 
GeneralRe: DataSet problem Pin
Rob Graham28-Feb-05 8:29
Rob Graham28-Feb-05 8:29 
GeneralRe: DataSet problem Pin
Kwai Cheng Kane28-Feb-05 10:18
Kwai Cheng Kane28-Feb-05 10:18 
Here is the database query... it is dynamically generated in the program...

--------------------------------
declare @StartDate datetime
declare @EndDate datetime

set @StartDate='3/10/2004 8:00:00 AM'
set @EndDate='3/11/2004 7:59:59 AM'

declare @config TABLE
(
Paytable varchar(60),
Skin varchar(60),
Denomination int,
EPSName int,
Configuration varchar(60),
ChangeDate datetime,
RemovalDate datetime,
MACAddress varchar(30),
LegalConfigNumber int,
Bank varchar(30),
Zone varchar(30)
)

declare @playwk TABLE
(
EPSName int,
PaytableName varchar(60) NULL default '',
SkinName varchar(60) NULL default '',
Denomination int NULL default '',
StartDate datetime NULL default 0,
EndDate datetime NULL default 0
)

declare @cashintmp TABLE
(
EPSName int,
StartDate datetime NULL default 0,
EndDate datetime NULL default 0
)

declare @cashintmp2 TABLE
(
EPSName int,
StartDate datetime NULL default 0,
EndDate datetime NULL default 0
)

declare @cashin TABLE
(
EPSName int,
PaytableName varchar(60) NULL default '',
SkinName varchar(60) NULL default '',
Denomination int NULL default '',
CurrentDate datetime NULL default 0,
StartDate datetime NULL default 0,
EndDate datetime NULL default 0
)

declare @cashouttmp TABLE
(
EPSName int,
CurrentDate datetime NULL default 0
)

declare @cashout TABLE
(
EPSName int,
CurrentDate datetime NULL default 0
)
declare @MarketCode int
select @MarketCode=MarketCode from Bingo.dbo.casino

INSERT INTO @config
SELECT RTrim(e.PaytableName), RTrim(e.SkinDescription), g.Denomination,
CAST (e.EPSName AS INTEGER) AS EPSName, RTrim(l.ConfigurationName) As Configuration,
e.ChangeDate, '1jan2100', e.MacAddress, l.SequenceNumber As LegalConfigNumber,
e.BankName As Bank, e.ZoneName As Zone
from Bingo.dbo.EPSConfiguration e
left outer join Bingo.dbo.GameConfig g
ON (e.GameConfiguration = g.SequenceNumber)
left outer join Bingo.dbo.LegalConfiguration l
ON (e.PaytableNumber = l.PaytableNumber)
And (RTrim(e.SkinDescription) = RTrim(l.SkinDescription))
And (g.SequenceNumber = l.GameConfigNumber)
And ((power (2,@MarketCode) & l.validmarkets) <> 0)
WHERE (CAST(e.EPSName AS INTEGER) <> 0)
ORDER BY CAST(e.EPSName As INTEGER)

declare @res TABLE
(
EPSName int,
Amount int,
AmountSum int,
CashInCount int,
CashInType int,
EPSMacAddress varchar(30),
PaytableName varchar(60),
SkinName varchar(60),
Denomination int,
Configuration varchar(60),
LegalConfigNumber int,
Bank varchar(30),
Zone varchar(30),
CurrentDate datetime NULL default 0,
ChangeDate datetime NULL default 0,
RemovalDate datetime NULL default 0
)
declare @res2 TABLE
(
EPSName int,
Amount int,
AmountSum int,
CashInCount int,
CashInType int,
EPSMacAddress varchar(30),
PaytableName varchar(60),
SkinName varchar(60),
Denomination int,
Configuration varchar(60),
LegalConfigNumber int,
Bank varchar(30),
Zone varchar(30),
CurrentDate datetime NULL default 0,
ChangeDate datetime NULL default 0,
RemovalDate datetime NULL default 0
)

INSERT INTO @res
SELECT c.EPSName, c.Amount, c.Amount, 1, c.CashInType,
c.EPSMACAddress, RTrim(e.Paytable), RTrim(e.Skin), e.Denomination,
e.Configuration, e.LegalConfigNumber, e.Bank, e.Zone,
c.CurrentDate, e.ChangeDate, e.RemovalDate
FROM bingohistory.dbo.cashin c
left outer join @config e
ON (RTrim(c.EPSMACAddress) = (RTrim(e.MACAddress)))
WHERE (TestMode = 0) And (currentdate >= @StartDate) and (currentdate <= @EndDate)


declare @nulcnt int
select @nulcnt=count(*) FROM @res
where (ISNULL(RTrim(PaytableName),'') = '')

if (@nulcnt > 0)
Begin
/* some configurations are missing for this old data... so reconstruct */
/* from other table data */

/* get min/max play range for each cashin... */
INSERT INTO @playwk
SELECT EPSName, PaytableName, SkinName, Denomination, MIN(CurrentDate), MAX(CurrentDate)
FROM Bingo.dbo.Play
WHERE (CurrentDate >= DateAdd(Hour,-12,@StartDate)) And (CurrentDate <= DateAdd(Hour,12,@EndDate))
GROUP BY EPSName, PaytableName, SkinName, Denomination

INSERT INTO @playwk
SELECT EPSName, PaytableName, SkinName, Denomination, MIN(CurrentDate), MAX(CurrentDate)
FROM BingoHistory.dbo.Play
WHERE (CurrentDate >= DateAdd(Hour,-12,@StartDate)) And (CurrentDate <= DateAdd(Hour,12,@EndDate))
GROUP BY EPSName, PaytableName, SkinName, Denomination

/* get cashout matching cashins */
INSERT INTO @cashouttmp
SELECT EPSName, CurrentDate
FROM Bingo.dbo.CashOut
WHERE (CurrentDate >= @StartDate) And (CurrentDate <= DateAdd(Hour,2,@EndDate))

INSERT INTO @cashouttmp
SELECT EPSName, CurrentDate
FROM BingoHistory.dbo.CashOut
WHERE (CurrentDate >= @StartDate) And (CurrentDate <= DateAdd(Hour,2,@EndDate))

INSERT INTO @cashout
SELECT EPSName, CurrentDate
FROM @cashouttmp
GROUP BY EPSName, CurrentDate

/* mate cashout to cashin to form the min/max range for the cashin */
INSERT INTO @cashintmp
SELECT i.EPSName, i.CurrentDate,
CASE ISNULL(MIN(o.CurrentDate),'') WHEN '' THEN @EndDate ELSE MIN(o.CurrentDate) END
FROM Bingo.dbo.CashIn i
left outer join @cashout o
ON (i.EPSName = o.EPSName) And (o.CurrentDate >= i.CurrentDate)
WHERE (i.CurrentDate >= @StartDate) And (i.CurrentDate <= @EndDate)
GROUP BY i.EPSName, i.CurrentDate

INSERT INTO @cashintmp
SELECT i.EPSName, i.CurrentDate,
CASE ISNULL(MIN(o.CurrentDate),'') WHEN '' THEN @EndDate ELSE MIN(o.CurrentDate) END
FROM BingoHistory.dbo.CashIn i
left outer join @cashout o
ON (i.EPSName = o.EPSName) And (o.CurrentDate >= i.CurrentDate)
WHERE (i.CurrentDate >= @StartDate) And (i.CurrentDate <= @EndDate)
GROUP BY i.EPSName, i.CurrentDate

/* mate the cashin ranges to the play to obtain configurations from play records */
/* generated within the cashin min/max range */
INSERT INTO @cashin
SELECT c.EPSName, MAX(p.PaytableName), MAX(p.SkinName), MAX(p.Denomination), c.StartDate,
MIN(CASE ISNULL(p.StartDate,'') WHEN '' THEN c.StartDate ELSE p.StartDate END),
MAX(CASE ISNULL(p.EndDate,'') WHEN '' THEN c.EndDate ELSE p.EndDate END)
FROM @cashintmp c
left outer join @playwk p
ON (c.EPSName = p.EPSName) And ((c.StartDate >= p.StartDate) Or (p.EndDate <= c.EndDate))
GROUP BY c.EPSName, c.StartDate

/* now match the whole thing together... */
INSERT INTO @res2
SELECT r.EPSName, r.Amount, Sum(r.AmountSum), Sum(r.CashInCount), r.CashInType, MAX(r.EPSMACAddress),
MAX(RTrim(r.PaytableName)), MAX(RTrim( r.SkinName )), MAX(RTrim( r.Denomination )),
MAX(Configuration), MAX(LegalConfigNumber), MAX(Bank), MAX(Zone),
r.CurrentDate, MIN(r.ChangeDate), MAX(r.RemovalDate)
FROM @res r
WHERE (ISNULL(r.PaytableName,'') <> '') And (ISNULL(r.SkinName,'') <> '') And (ISNULL(r.Denomination,0) <> 0)
GROUP BY r.EPSName, r.CurrentDate, r.Amount, r.CashInType
ORDER BY r.EPSName, r.Amount, r.CashInType

INSERT INTO @res2
SELECT r.EPSName, r.Amount, Sum(r.AmountSum), Sum(r.CashInCount), r.CashInType, MAX(r.EPSMACAddress),
MAX(RTrim( c.PaytableName )), MAX(RTrim( c.SkinName )), MAX(RTrim( c.Denomination )),
MAX(Configuration), MAX(LegalConfigNumber), MAX(Bank), MAX(Zone),
r.CurrentDate, MIN(r.ChangeDate), MAX(r.RemovalDate)
FROM @res r
left outer join @cashin c
ON (r.EPSName = c.EPSName) And (r.CurrentDate = c.CurrentDate)
WHERE (ISNULL(r.PaytableName,'') = '') Or (ISNULL(r.SkinName,'') = '') Or (ISNULL(r.Denomination,0) = 0)
GROUP BY r.EPSName, r.CurrentDate, r.Amount, r.CashInType
ORDER BY r.EPSName, r.Amount, r.CashInType
End
Else
Begin
/* no missing configuration values on cashin... */
INSERT INTO @res2
SELECT EPSName, Amount, Sum(AmountSum), Sum(CashInCount), CashInType,
MAX(EPSMACAddress), MAX(RTrim(PaytableName)), MAX(RTrim(SkinName)), MAX(Denomination),
MAX(Configuration), MAX(LegalConfigNumber), MAX(Bank), MAX(Zone),
CurrentDate, MIN(ChangeDate), MAX(RemovalDate)
FROM @res
GROUP BY EPSName, CurrentDate, Amount, CashInType
ORDER BY EPSName, Amount, CashInType
End

/* clean up anything still missing configuration values */
UPDATE @res2 set EPSMacAddress='[UNKNOWN]' WHERE (ISNULL(EPSMacAddress,'') = '')
UPDATE @res2 set PaytableName='[UNKNOWN]' WHERE (ISNULL(PaytableName,'') = '')
UPDATE @res2 set SkinName='[UNKNOWN]' WHERE (ISNULL(SkinName,'') = '')
UPDATE @res2 set Denomination=0 WHERE (ISNULL(Denomination,0) = 0)
UPDATE @res2 set Configuration='[UNKNOWN]' WHERE (ISNULL(Configuration,'') = '')
UPDATE @res2 set LegalConfigNumber=99999 WHERE (ISNULL(LegalConfigNumber,0) = 0)

SELECT * from @res2

--------------------------------------
Here is where I am running the query...
:
:
:
dbData = dbRead.ReadDataSet(SQLSelect2, "CashIn", ProcessTimeout);

if (dbData.Tables == null)
{
----- debugger shows it is not ending up here -------
MyLogFile.Warning( "No data returned from CashIn!" );
if (dbRead.Exception == true)
MyLogFile.Error(dbRead.ExceptionMsg);
}
else if (dbData.Tables.Count <= 0)
{
----- debugger shows it is ending up here -------
MyLogFile.Warning( "No data returned from CashIn!" );
if (dbRead.Exception == true)
MyLogFile.Error(dbRead.ExceptionMsg);
}
else if (dbRead.Exception == false)
{
--------- got data so process it ----------
:
:
:

public class DataAccess
{
:
:
:
private string ErrorMessage;
public string ExceptionMsg
{
get
{
string Msg = "Ok";
if (Exception == true)
Msg = ErrorMessage;
Exception = false;
return Msg;
}
}

private bool GotException = false;
public bool Exception
{
set
{
GotException = false;
ErrorMessage = "";
}
get {return GotException;}
}

public DataSet ReadDataSet( string SQLQuery, string dsName, int TimeOut )
{
Exception = false;
dbCommand = new OdbcCommand(SQLQuery, dbConnect);
dbAdapter = new OdbcDataAdapter();
dbData = new DataSet();
dbAdapter.SelectCommand = dbCommand;
---- debugger confirmed that "TimeOut" is 600 here ----
if (TimeOut >= 0)
dbCommand.CommandTimeout = TimeOut;
try
{
dbAdapter.Fill(dbData, dsName);
}
catch (System.Data.Odbc.OdbcException err)
{
---- this is not tripped ----
GotException = true;
ErrorMessage = err.Message.ToString() + ". " + ReadException;
if (LogFileSet==true)
{
MyLog.WriteLine(ErrorMessage);
MyLog.WriteLine( "SQL Query: " );
MyLog.WriteLine( SQLQuery );
}
if (DoingTransaction == true)
Rollback();
}
catch (System.Exception err)
{
--- this is not tripped --------
GotException = true;
ErrorMessage = err.Message.ToString() + ". " + ReadException;
if (LogFileSet==true)
{
MyLog.WriteLine(ErrorMessage);
MyLog.WriteLine( "SQL Query: " );
MyLog.WriteLine( SQLQuery );
}
if (DoingTransaction == true)
Rollback();
}
catch
{
----- this is not tripped ----
GotException = true;
ErrorMessage = ReadException;
if (LogFileSet==true)
{
MyLog.WriteLine(ErrorMessage);
MyLog.WriteLine( "SQL Query: " );
MyLog.WriteLine( SQLQuery );
}
if (DoingTransaction == true)
Rollback();
}
--- it proceeds from the "fill()" command ----
--- directly to here -------
return dbData;
}
:
:
:
}

--------------------------
And here is the snippet from the log...

2005Feb28 151252 STATUS Getting CashIn data...
2005Feb28 151332 WARNING No data returned from CashIn!
2005Feb28 151332 STATUS Getting Play data...
2005Feb28 151336 STATUS Processing Play data...
2005Feb28 151337 STATUS Play records processed: 163
2005Feb28 151337 STATUS Processing CashOut records...
2005Feb28 151337 STATUS CashOut records processed: 1244
GeneralRe: DataSet problem Pin
Rob Graham28-Feb-05 15:58
Rob Graham28-Feb-05 15:58 
GeneralRe: DataSet problem Pin
Kwai Cheng Kane1-Mar-05 4:30
Kwai Cheng Kane1-Mar-05 4:30 
GeneralRe: DataSet problem Pin
Kwai Cheng Kane1-Mar-05 12:20
Kwai Cheng Kane1-Mar-05 12:20 
GeneralRe: DataSet problem Pin
Kwai Cheng Kane4-Mar-05 11:09
Kwai Cheng Kane4-Mar-05 11:09 
GeneralIncluding Application Pin
Goobers28-Feb-05 6:10
Goobers28-Feb-05 6:10 
GeneralRe: Including Application Pin
Dave Kreskowiak28-Feb-05 6:41
mveDave Kreskowiak28-Feb-05 6:41 
Generalcalling a function in a C# DLL Pin
xanacrows28-Feb-05 5:55
xanacrows28-Feb-05 5:55 
GeneralRe: calling a function in a C# DLL Pin
Dave Kreskowiak28-Feb-05 6:38
mveDave Kreskowiak28-Feb-05 6:38 
Questionhow to implement mathematical integration and derivative function is C# Pin
iramg28-Feb-05 4:37
iramg28-Feb-05 4:37 
AnswerRe: how to implement mathematical integration and derivative function is C# Pin
Dave Kreskowiak28-Feb-05 7:10
mveDave Kreskowiak28-Feb-05 7:10 
AnswerRe: how to implement mathematical integration and derivative function is C# Pin
(Steven Hicks)n+128-Feb-05 16:57
(Steven Hicks)n+128-Feb-05 16:57 
GeneralUpdate DataSource when DataGrid is lost focus Pin
Anonymous28-Feb-05 4:35
Anonymous28-Feb-05 4:35 
GeneralA simple question about FileIO Pin
RockRock28-Feb-05 3:53
RockRock28-Feb-05 3:53 
GeneralRe: A simple question about FileIO Pin
Dave Kreskowiak28-Feb-05 6:34
mveDave Kreskowiak28-Feb-05 6:34 
GeneralDrag &amp; Drop Pin
sreejith ss nair28-Feb-05 3:15
sreejith ss nair28-Feb-05 3:15 
GeneralWorking directly with pixel of a bitmap Pin
Anonymous28-Feb-05 2:05
Anonymous28-Feb-05 2:05 
GeneralRe: Working directly with pixel of a bitmap Pin
leppie28-Feb-05 6:15
leppie28-Feb-05 6:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.