[Quantproject-developers] QuantProject/b2_DataAccess/Tables Quotes.cs,1.25,1.26
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2005-06-02 18:06:29
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19794/b2_DataAccess/Tables Modified Files: Quotes.cs Log Message: Fixed bug in the isAtLeastOneValueChanged method (the method is used by the TickerDownloader object) Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Quotes.cs,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Quotes.cs 4 May 2005 18:25:51 -0000 1.25 --- Quotes.cs 2 Jun 2005 18:06:17 -0000 1.26 *************** *** 318,355 **** #region IsAdjustedCloseToCloseRatioChanged private static bool isAtLeastOneValueChanged(DataTable tableDB, DataTable tableSource) { ! try { ! int numRows = tableDB.Rows.Count; ! DateTime date; ! float adjCTCInDatabase; ! float adjCTCInSource; ! double absoluteDifference; ! DataRow rowToCheck; ! for(int i = 0;i != numRows;i++) { ! date = (DateTime)tableDB.Rows[i][Quotes.Date]; ! adjCTCInDatabase = (float)tableDB.Rows[i][Quotes.AdjustedCloseToCloseRatio]; ! rowToCheck = tableSource.Rows.Find(date); ! if(rowToCheck != null) ! { ! adjCTCInSource = (float)rowToCheck[Quotes.AdjustedCloseToCloseRatio]; ! absoluteDifference = Math.Abs(adjCTCInDatabase - adjCTCInSource); ! if(absoluteDifference > ConstantsProvider.MaxDifferenceForCloseToCloseRatios ) ! { ! Quotes.DateWithDifferentCloseToClose = date; ! return true; ! } ! } } } ! catch(Exception ex) ! { ! string notUsed = ex.ToString(); ! } ! return false; } --- 318,356 ---- #region IsAdjustedCloseToCloseRatioChanged + + private static void isAtLeastOneValueChanged_setPrimaryKey(DataTable tableToBeSet) + { + DataColumn[] columnPrimaryKeys = new DataColumn[1]; + columnPrimaryKeys[0] = tableToBeSet.Columns[Quotes.Date]; + tableToBeSet.PrimaryKey = columnPrimaryKeys; + } private static bool isAtLeastOneValueChanged(DataTable tableDB, DataTable tableSource) { ! bool returnValue = false; ! int numRows = tableDB.Rows.Count; ! DateTime date; ! float adjCTCInDatabase, adjCTCInSource; ! double absoluteDifference; ! DataRow rowToCheck; ! for(int i = 0;i != numRows;i++) { ! date = (DateTime)tableDB.Rows[i][Quotes.Date]; ! adjCTCInDatabase = (float)tableDB.Rows[i][Quotes.AdjustedCloseToCloseRatio]; ! isAtLeastOneValueChanged_setPrimaryKey(tableSource); ! rowToCheck = tableSource.Rows.Find(date); ! if(rowToCheck != null) { ! adjCTCInSource = (float)rowToCheck[Quotes.AdjustedCloseToCloseRatio]; ! absoluteDifference = Math.Abs(adjCTCInDatabase - adjCTCInSource); ! if(absoluteDifference > ConstantsProvider.MaxDifferenceForCloseToCloseRatios ) ! { ! Quotes.DateWithDifferentCloseToClose = date; ! returnValue = true; ! } } } ! return returnValue; } |